LIBINT  2.6.0
comp_11_r1dotr2g12_11.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 #ifndef _libint2_src_bin_libint_cr11r1dotr2g1211_h_
22 #define _libint2_src_bin_libint_cr11r1dotr2g1211_h_
23 
24 #include <iostream>
25 #include <sstream>
26 #include <string>
27 #include <vector>
28 #include <stdexcept>
29 #include <cassert>
30 #include <dgvertex.h>
31 #include <rr.h>
32 #include <rr.templ.h>
33 #include <integral.h>
34 #include <r1dotr2g12_11_11.h>
35 #include <algebra.h>
36 #include <flop.h>
37 #include <prefactors.h>
38 #include <context.h>
39 #include <default_params.h>
40 
41 using namespace std;
42 
43 
44 namespace libint2 {
45 
50  template <template <typename,typename,typename> class I, class BFSet>
52  {
53 
54  public:
56  typedef BFSet BasisFunctionType;
58  typedef I<BFSet,R1dotR2_G12,EmptySet> TargetType;
62 
66  static SafePtr<ThisType> Instance(const SafePtr<TargetType>&);
67  virtual ~CR_11_R1dotR2G12_11() {}
68 
70  unsigned int num_children() const { return nchildren_; };
72  SafePtr<TargetType> target() const { return target_; };
74  SafePtr<ChildType> child(unsigned int i) const;
76  SafePtr<DGVertex> rr_target() const { return static_pointer_cast<DGVertex,TargetType>(target()); }
78  SafePtr<DGVertex> rr_child(unsigned int i) const { return dynamic_pointer_cast<DGVertex,ChildType>(child(i)); }
80  bool is_simple() const {
82  }
83 
84  private:
90  CR_11_R1dotR2G12_11(const SafePtr<TargetType>&);
91 
92 #if 0
93  bool register_with_rrstack() const;
95 #endif
96 
97  static const unsigned int max_nchildren_ = 18;
98  SafePtr<TargetType> target_;
99  SafePtr<ChildType> children_[max_nchildren_];
100  unsigned int nchildren_;
101 
102  std::string generate_label() const
103  {
104  ostringstream os;
105  os << "RR ( " << rr_target()->label() << " )";
106  return os.str();
107  }
108 
109 
110  };
111 
112  template <template <typename,typename,typename> class I, class F>
113  SafePtr< CR_11_R1dotR2G12_11<I,F> >
114  CR_11_R1dotR2G12_11<I,F>::Instance(const SafePtr<TargetType>& Tint)
115  {
116  SafePtr<ThisType> this_ptr(new ThisType(Tint));
117  // Do post-construction duties
118  if (this_ptr->num_children() != 0) {
119  this_ptr->register_with_rrstack<ThisType>();
120  return this_ptr;
121  }
122  return SafePtr<ThisType>();
123  }
124 
125  template <template <typename,typename,typename> class I, class F>
126  CR_11_R1dotR2G12_11<I,F>::CR_11_R1dotR2G12_11(const SafePtr<TargetType>& Tint) :
127  ParentType(), target_(Tint), nchildren_(0)
128  {
129  F sh_a(Tint->bra(0,0));
130  F sh_b(Tint->ket(0,0));
131  F sh_c(Tint->bra(1,0));
132  F sh_d(Tint->ket(1,0));
133 
134  vector<F> bra;
135  vector<F> ket;
136  bra.push_back(sh_a);
137  bra.push_back(sh_c);
138  ket.push_back(sh_b);
139  ket.push_back(sh_d);
140 
141  vector<F>* bra_ref = &bra;
142  vector<F>* ket_ref = &ket;
143 
144  const unsigned int ndirs = is_simple() ? 3 : 1;
145  for(int xyz=0; xyz<ndirs; xyz++) {
146 
147  // a+1_i c+1_i
148  bra_ref->operator[](0).inc(xyz);
149  bra_ref->operator[](1).inc(xyz);
150  int next_child = nchildren_;
151  children_[next_child] = ChildType::Instance(bra[0],ket[0],bra[1],ket[1],0);
152  ++nchildren_;
153 
154  if (is_simple()) {
155  SafePtr<ExprType> expr0_ptr(new ExprType(ExprType::OperatorTypes::Times,Scalar(1.0),rr_child(next_child)));
156  add_expr(expr0_ptr);
157  nflops_ += 1;
158  }
159  bra_ref->operator[](0).dec(xyz);
160  bra_ref->operator[](1).dec(xyz);
161  }
162  }
163 
164  template <template <typename,typename,typename> class I, class F>
165  SafePtr< typename CR_11_R1dotR2G12_11<I,F>::ChildType >
166  CR_11_R1dotR2G12_11<I,F>::child(unsigned int i) const
167  {
168  assert(i>=0 && i<nchildren_);
169  unsigned int nc=0;
170  for(int c=0; c<max_nchildren_; c++) {
171  if (children_[c] != 0) {
172  if (nc == i)
173  return children_[c];
174  nc++;
175  }
176  }
177  };
178 
180  typedef CR_11_R1dotR2G12_11<GenIntegralSet_11_11,CGShell> CR_11_R1dotR2G12_11_sq;
181  typedef CR_11_R1dotR2G12_11<GenIntegralSet_11_11,CGF> CR_11_R1dotR2G12_11_int;
182 
183 };
184 
185 #endif
SafePtr< DGVertex > rr_child(unsigned int i) const
Implementation of RecurrenceRelation::rr_child()
Definition: comp_11_r1dotr2g12_11.h:78
TrivialBFSet<T> defines static member result, which is true if T is a basis function set consisting o...
Definition: bfset.h:892
CR_11_R1dotR2G12_11< GenIntegralSet_11_11, CGShell > CR_11_R1dotR2G12_11_sq
Useful typedefs.
Definition: comp_11_r1dotr2g12_11.h:177
void add_expr(const SafePtr< ExprType > &a, int minus=1)
Adds a (or -a, if minus = -1) to expr_.
Definition: rr.cc:306
Defaults definitions for various parameters assumed by Libint.
Definition: algebra.cc:24
unsigned int num_children() const
Implementation of RecurrenceRelation::num_children()
Definition: comp_11_r1dotr2g12_11.h:70
SafePtr< DGVertex > rr_target() const
Implementation of RecurrenceRelation::rr_target()
Definition: comp_11_r1dotr2g12_11.h:76
RecurrenceRelation::ExprType ExprType
The type of expressions in which RecurrenceRelations result.
Definition: comp_11_r1dotr2g12_11.h:61
Compute relation for 2-e integrals of the r1.r2 x G12 operators.
Definition: comp_11_r1dotr2g12_11.h:51
AlgebraicOperator is an algebraic operator that acts on objects of type T.
Definition: algebra.h:48
bool is_simple() const
Implementation of RecurrenceRelation::is_simple()
Definition: comp_11_r1dotr2g12_11.h:80
RecurrenceRelation describes all recurrence relations.
Definition: rr.h:101
Set of basis functions.
Definition: bfset.h:42
SafePtr< ChildType > child(unsigned int i) const
child(i) returns pointer to the i-th child
Definition: comp_11_r1dotr2g12_11.h:166
SafePtr< TargetType > target() const
target() returns pointer to the i-th child
Definition: comp_11_r1dotr2g12_11.h:72
Definition: integral_decl.h:38