LIBINT  2.6.0
intset_to_ints.h
1 /*
2  * Copyright (C) 2004-2019 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 
34 using namespace std;
35 
36 
37 namespace libint2 {
38 
42  protected:
43  virtual ~IntegralSet_to_Integrals_base() {}
44  };
45 
49  template <class I>
52  public:
53  typedef I TargetType;
54  typedef typename I::iter_type ChildType;
57 
58  IntegralSet_to_Integrals(const SafePtr<I>&);
59  virtual ~IntegralSet_to_Integrals() {}
60 
62  static SafePtr<IntegralSet_to_Integrals<I>> Instance(const SafePtr<TargetType>& Tint, unsigned int dir) {
63  assert(dir == 0);
64  // attempt to construct
65  SafePtr<IntegralSet_to_Integrals<I>> this_ptr(new IntegralSet_to_Integrals<I>(Tint));
66  // if succeeded (nchildren > 0) do post-construction
67  assert(this_ptr->num_children() != 0);
68  return this_ptr;
69  }
70  static bool directional() { return false; }
71 
72 
74  unsigned int num_children() const { return children_.size(); };
76  SafePtr<TargetType> target() const { return target_; };
78  SafePtr<ChildType> child(unsigned int i) const;
80  SafePtr<DGVertex> rr_target() const { return static_pointer_cast<DGVertex,TargetType>(target()); }
82  SafePtr<DGVertex> rr_child(unsigned int i) const { return static_pointer_cast<DGVertex,ChildType>(child(i)); }
84  bool is_simple() const {
85  return true;
86  }
88  bool invariant_type() const {
89  // Converts from one BFSet to another!
90  return false;
91  }
92 
93  private:
94  SafePtr<TargetType> target_;
95  vector< SafePtr<ChildType> > children_;
96 
98  std::string generate_label() const {
99  return "IntegralSet_to_Integrals";
100  //throw std::runtime_error("IntegralSet_to_Integrals::label() -- code for this RR is never generated, so this function should never be used");
101  }
103  std::string spfunction_call(const SafePtr<CodeContext>& context,
104  const SafePtr<ImplicitDimensions>& dims) const
105  {
106  throw logic_error("IntegralSet_to_Integrals::spfunction_call -- should not call this function");
107  }
108 
109  };
110 
111 
112  template <class I>
113  IntegralSet_to_Integrals<I>::IntegralSet_to_Integrals(const SafePtr<I>& Tint) :
114  target_(Tint)
115  {
116  target_ = Tint;
117 
118  // Construct a subiterator for I
119  SubIteratorBase<I> siter(Tint);
120 
121  // Set children pointers
122  for(siter.init(); siter; ++siter)
123  children_.push_back(siter.elem());
124  };
125 
126  template <class I>
127  SafePtr<typename I::iter_type>
129  {
130  return children_.at(i);
131  };
132 
133 
134 };
135 
136 #endif
137 
SafePtr< ChildType > child(unsigned int i) const
child(i) returns pointer i-th child
Definition: intset_to_ints.h:128
Defaults definitions for various parameters assumed by Libint.
Definition: algebra.cc:24
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:62
AlgebraicOperator is an algebraic operator that acts on objects of type T.
Definition: algebra.h:48
IntegralSet_to_Integrals_base is dummy class used for dynamic casts only.
Definition: intset_to_ints.h:41
SafePtr< DGVertex > rr_child(unsigned int i) const
Implementation of RecurrenceRelation's child()
Definition: intset_to_ints.h:82
unsigned int num_children() const
Implementation of RecurrenceRelation::num_children()
Definition: intset_to_ints.h:74
RecurrenceRelation describes all recurrence relations.
Definition: rr.h:101
RecurrenceRelation::ExprType ExprType
The type of expressions in which RecurrenceRelations result.
Definition: intset_to_ints.h:56
SafePtr< TargetType > target() const
target() returns pointer to target
Definition: intset_to_ints.h:76
bool invariant_type() const
Reimplementation of RecurrenceRelation::invariant_type()
Definition: intset_to_ints.h:88
SafePtr< DGVertex > rr_target() const
Implementation of RecurrenceRelation's target()
Definition: intset_to_ints.h:80
bool is_simple() const
Implementation of RecurrenceRelation::is_simple()
Definition: intset_to_ints.h:84
IntegralSet_to_Integrals converts I, a set of integrals, to individual integrals.
Definition: intset_to_ints.h:50