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