21 #ifndef _libint2_src_bin_libint_braket_h_ 22 #define _libint2_src_bin_libint_braket_h_ 24 #include <polyconstr.h> 27 #include <libint2/util/intrinsic_types.h> 28 #include <global_macros.h> 52 typedef bfs_type& bfs_ref;
53 typedef const BFS& bfs_cref;
65 bfs_cref
member(
unsigned int p,
unsigned int i=0)
const;
67 bfs_ref
member(
unsigned int p,
unsigned int i=0);
71 void set_member(
const BFS&,
unsigned int p,
unsigned int i=0);
75 unsigned int num_members(
unsigned int p)
const { assert(p<NP);
return 1; }
79 inline LIBINT2_UINT_LEAST64
key()
const;
81 LIBINT2_UINT_LEAST64
max_key()
const;
82 #if COMPUTE_SIZE_DIRECTLY 83 unsigned int size()
const;
91 #if COMPUTE_SIZE_DIRECTLY 92 mutable unsigned int size_;
96 template <
class BFS,
unsigned int NP>
99 #if COMPUTE_SIZE_DIRECTLY 104 template <
class BFS,
unsigned int NP>
106 for(
int i=0; i<NP; i++)
108 #if COMPUTE_SIZE_DIRECTLY 113 template <
class BFS,
unsigned int NP>
115 assert(braket.size()==NP);
116 for(
unsigned int i=0; i<NP; i++) {
117 assert(braket[i].size()==1);
118 bfs_[i] = braket[i][0];
120 #if COMPUTE_SIZE_DIRECTLY 125 template <
class BFS,
unsigned int NP>
126 ArrayBraket<BFS,NP>::~ArrayBraket() {}
128 template <
class BFS,
unsigned int NP>
131 for(
int i=0; i<NP; i++)
137 template <
class BFS,
unsigned int NP>
138 typename ArrayBraket<BFS,NP>::bfs_cref
140 assert(i==0 && p<NP);
144 template <
class BFS,
unsigned int NP>
145 typename ArrayBraket<BFS,NP>::bfs_ref
147 assert(i==0 && p<NP);
152 template <
class BFS,
unsigned int NP>
155 assert(i==0 && p<NP);
159 template <
class BFS,
unsigned int NP>
162 assert(i==0 && p<NP);
167 template <
class BFS,
unsigned int NP>
170 assert(i==0 && p<NP);
175 template <
class BFS,
unsigned int NP>
178 LIBINT2_UINT_LEAST64 pfac = 1;
179 LIBINT2_UINT_LEAST64 key = 0;
180 for(
int p=NP-1; p>=0; p--) {
181 key += pfac*bfs_[p].key();
182 pfac *= BFS::max_key;
184 assert(key < this->max_key());
188 template <
class BFS,
unsigned int NP>
191 LIBINT2_UINT_LEAST64 max_key = 1;
192 for(
int p=NP-1; p>=0; p--) {
193 max_key *= BFS::max_key;
198 #if COMPUTE_SIZE_DIRECTLY 199 template <
class BFS,
unsigned int NP>
202 if (size_ > 0)
return size_;
205 for(
int p=NP-1; p>=0; p--) {
206 size_ *= bfs_[p].
num_bf();
213 template <
class BFS,
unsigned int NP>
215 ArrayBraket<BFS,NP>::reset_cache() {
221 template <
typename BFS>
229 template <
typename BFS>
248 typedef BFS bfs_type;
255 const BFS& operator[](
unsigned int i)
const {
256 if (i == 0)
return bfs_.first;
257 if (i == 1)
return bfs_.second;
258 throw std::logic_error(
"BraketPair::operator[] -- argument out of range");
262 return rhs.bfs_ == bfs_;
266 std::pair<BFS,BFS> bfs_;
289 template <
class BFS, BraketType BKTypeL, BraketType BKTypeR>
290 algebra::Wedge< BraketPair<BFS,BKTypeL>, BraketPair<BFS,BKTypeR> >
291 operator^(
const BraketPair<BFS,BKTypeL>& L,
const BraketPair<BFS,BKTypeR>& R) {
292 return algebra::make_wedge(L,R);
BraketPair< F, CBra > _cbra(const F &f1, const F &f2)
Chemists bra.
Definition: braket.h:280
unsigned int num_members(unsigned int p) const
Returns the number of BFS for particle p.
Definition: braket.h:75
TrivialBFSet<T> defines static member result, which is true if T is a basis function set consisting o...
Definition: bfset.h:892
bool operator==(const this_type &rhs) const
Comparison function.
Definition: braket.h:261
ConstructablePolymorphically is a base for all objects which can be constructed using a SafePtr to a ...
Definition: polyconstr.h:31
There's no parent.
Definition: braket.h:43
Defaults definitions for various parameters assumed by Libint.
Definition: algebra.cc:24
BraketPair< F, PKet > _pket(const F &f1, const F &f2)
Physicists ket.
Definition: braket.h:276
BraketPair< F, CKet > _cket(const F &f1, const F &f2)
Chemists ket.
Definition: braket.h:284
ArrayBraket< BFS, NP > this_type
This type.
Definition: braket.h:41
unsigned int num_part() const
Returns the number of particles.
Definition: braket.h:77
ArrayBraket()
This one is a very dangerous constructor – do not to use it if at all possible.
Definition: braket.h:97
BraketType
enumerates types of brakets used for describing two-electron integrals: CBra and CKet are bra and ket...
Definition: braket.h:240
SubIteratorBase<T> provides a base class for a sub-iterator class for T.
Definition: iter.h:73
ArrayBraket< typename BFS::iter_type, NP > iter_type
The iterator through ArrayBraket.
Definition: braket.h:45
static constexpr auto num_bf
The total # of basis functions = # of particles (since 1 bf / particle)
Definition: braket.h:49
void set_member(const BFS &, unsigned int p, unsigned int i=0)
Sets i-th function for particle p.
Definition: braket.h:161
ArrayBraket< BFS, 1 > Result
This defines which Braket implementation to use.
Definition: braket.h:224
LIBINT2_UINT_LEAST64 key() const
Implements Hashable::key()
Definition: braket.h:177
LIBINT2_UINT_LEAST64 max_key() const
key lies in range [0,max_key())
Definition: braket.h:190
This is the implementation of the Braket concept used by GenIntegralSet_1_1.
Definition: braket.h:222
Iterator provides a base class for all object iterator classes.
Definition: iter.h:45
This is the implementation of the Braket concept used by GenIntegralSet_11_11.
Definition: braket.h:230
BraketPair is a trimmed down version of ArrayBraket specialized for same-particle or different-partic...
Definition: braket.h:244
static constexpr auto num_particles
The total # of particles.
Definition: braket.h:47
BraketPair< F, PBra > _pbra(const F &f1, const F &f2)
Physicists bra.
Definition: braket.h:272
bfs_cref member(unsigned int p, unsigned int i=0) const
Returns cref to the i-th function for particle p.
Definition: braket.h:139
ArrayBraket is a lightweight implementation of Braket concept.
Definition: braket.h:38
BraketPair< BFS, BKType > this_type
This type.
Definition: braket.h:247
SubIterator * member_subiter(unsigned int p, unsigned int i=0) const
Returns pointer to the SubIterator for i-th BFS of particle p.
Definition: braket.h:154
bool operator==(const this_type &) const
Comparison function.
Definition: braket.h:130
BraketPair(const BFS &f1, const BFS &f2)
This one is a very dangerous constructor – do not to use it if at all possible.
Definition: braket.h:252
ArrayBraket< BFS, 2 > Result
This defines which Braket implementation to use.
Definition: braket.h:232