LIBINT 2.7.2
intset_to_ints.h
1/*
2 * Copyright (C) 2004-2021 Edward F. Valeev
3 *
4 * This file is part of Libint.
5 *
6 * Libint is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * Libint is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with Libint. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21#include <iostream>
22#include <string>
23#include <vector>
24#include <stdexcept>
25#include <cassert>
26#include <rr.h>
27#include <integral.h>
28#include <iter.h>
29#include <algebra.h>
30
31#ifndef _libint2_src_bin_libint_intsettoints_h_
32#define _libint2_src_bin_libint_intsettoints_h_
33
34namespace libint2 {
35
39 protected:
41 };
42
46 template <class I>
49 public:
50 typedef I TargetType;
51 typedef typename I::iter_type ChildType;
54
55 IntegralSet_to_Integrals(const SafePtr<I>&);
56 virtual ~IntegralSet_to_Integrals() {}
57
59 static SafePtr<IntegralSet_to_Integrals<I>> Instance(const SafePtr<TargetType>& Tint, unsigned int dir) {
60 assert(dir == 0);
61 // attempt to construct
62 SafePtr<IntegralSet_to_Integrals<I>> this_ptr(new IntegralSet_to_Integrals<I>(Tint));
63 // if succeeded (nchildren > 0) do post-construction
64 assert(this_ptr->num_children() != 0);
65 return this_ptr;
66 }
67 static bool directional() { return false; }
68
69
71 unsigned int num_children() const override { return children_.size(); }
73 SafePtr<TargetType> target() const { return target_; };
75 SafePtr<ChildType> child(unsigned int i) const;
77 SafePtr<DGVertex> rr_target() const override { return static_pointer_cast<DGVertex,TargetType>(target()); }
79 SafePtr<DGVertex> rr_child(unsigned int i) const override { return static_pointer_cast<DGVertex,ChildType>(child(i)); }
81 bool is_simple() const override {
82 return true;
83 }
85 bool invariant_type() const override {
86 // Converts from one BFSet to another!
87 return false;
88 }
89
90 private:
91 SafePtr<TargetType> target_;
92 std::vector< SafePtr<ChildType> > children_;
93
95 std::string generate_label() const override {
96 return "IntegralSet_to_Integrals";
97 //throw std::runtime_error("IntegralSet_to_Integrals::label() -- code for this RR is never generated, so this function should never be used");
98 }
100 std::string spfunction_call(const SafePtr<CodeContext>& context,
101 const SafePtr<ImplicitDimensions>& dims) const override
102 {
103 throw std::logic_error("IntegralSet_to_Integrals::spfunction_call -- should not call this function");
104 }
105
106 };
107
108
109 template <class I>
110 IntegralSet_to_Integrals<I>::IntegralSet_to_Integrals(const SafePtr<I>& Tint) :
111 target_(Tint)
112 {
113 target_ = Tint;
114
115 // Construct a subiterator for I
116 SubIteratorBase<I> siter(Tint);
117
118 // Set children pointers
119 for(siter.init(); siter; ++siter)
120 children_.push_back(siter.elem());
121 };
122
123 template <class I>
124 SafePtr<typename I::iter_type>
126 {
127 return children_.at(i);
128 };
129
130
131};
132
133#endif
134
AlgebraicOperator is an algebraic operator that acts on objects of type T.
Definition: algebra.h:50
IntegralSet_to_Integrals_base is dummy class used for dynamic casts only.
Definition: intset_to_ints.h:38
IntegralSet_to_Integrals converts I, a set of integrals, to individual integrals.
Definition: intset_to_ints.h:48
SafePtr< ChildType > child(unsigned int i) const
child(i) returns pointer i-th child
Definition: intset_to_ints.h:125
SafePtr< DGVertex > rr_target() const override
Implementation of RecurrenceRelation's target()
Definition: intset_to_ints.h:77
SafePtr< DGVertex > rr_child(unsigned int i) const override
Implementation of RecurrenceRelation's child()
Definition: intset_to_ints.h:79
bool is_simple() const override
Implementation of RecurrenceRelation::is_simple()
Definition: intset_to_ints.h:81
RecurrenceRelation::ExprType ExprType
The type of expressions in which RecurrenceRelations result.
Definition: intset_to_ints.h:53
bool invariant_type() const override
Reimplementation of RecurrenceRelation::invariant_type()
Definition: intset_to_ints.h:85
unsigned int num_children() const override
Implementation of RecurrenceRelation::num_children()
Definition: intset_to_ints.h:71
SafePtr< TargetType > target() const
target() returns pointer to target
Definition: intset_to_ints.h:73
static SafePtr< IntegralSet_to_Integrals< I > > Instance(const SafePtr< TargetType > &Tint, unsigned int dir)
Return an instance if applicable, or a null pointer otherwise.
Definition: intset_to_ints.h:59
RecurrenceRelation describes all recurrence relations.
Definition: rr.h:99
Defaults definitions for various parameters assumed by Libint.
Definition: algebra.cc:24