20 #ifndef _libint2_src_bin_libint_braket_h_ 21 #define _libint2_src_bin_libint_braket_h_ 23 #include <polyconstr.h> 26 #include <libint2/intrinsic_types.h> 27 #include <global_macros.h> 40 typedef bfs_stor& bfs_ref;
41 typedef const bfs_stor& bfs_cref;
42 typedef vector< bfs_stor > BFSVector;
43 typedef vector< BFSVector > BFSMatrix;
57 bfs_ref
member(
unsigned int p,
unsigned int i);
59 bfs_cref
member(
unsigned int p,
unsigned int i)
const;
63 void set_member(bfs_cref,
unsigned int p,
unsigned int i);
71 inline LIBINT2_UINT_LEAST64
key()
const;
73 LIBINT2_UINT_LEAST64
max_key()
const;
105 typename VectorBraket<BFS>::bfs_ref
108 return bfs_.at(p).at(i);
112 typename VectorBraket<BFS>::bfs_cref
115 return bfs_.at(p).at(i);
129 if (p >= bfs_.size())
131 if (i >= bfs_[p].size())
134 bfs_[p][i] = bfs_tmp;
145 if (p >= bfs_.size())
147 if (i >= bfs_[p].size())
149 bfs_[p][i] = bfs_cast;
156 return bfs_.at(p).size();
170 return bfs_ == a.bfs_;
177 LIBINT2_UINT_LEAST64 pfac = 1;
178 LIBINT2_UINT_LEAST64
key = 0;
179 const int np = bfs_.size();
180 for(
int p=np-1; p>=0; p--) {
181 const BFSVector& row = bfs_[p];
182 const int nf = row.size();
183 for(
int f=nf-1; f>=0; f--) {
184 key += pfac*row[f].key();
185 pfac *= BFS::max_key;
196 LIBINT2_UINT_LEAST64
max_key = 1;
197 const int np = bfs_.size();
198 for(
int p=np-1; p>=0; p--) {
199 const BFSVector& row = bfs_[p];
200 const int nf = row.size();
201 for(
int f=nf-1; f>=0; f--) {
202 max_key *= BFS::max_key;
223 typedef BFS bfs_type;
224 typedef bfs_type& bfs_ref;
225 typedef const BFS& bfs_cref;
237 bfs_cref
member(
unsigned int p,
unsigned int i=0)
const;
239 bfs_ref
member(
unsigned int p,
unsigned int i=0);
243 void set_member(
const BFS&,
unsigned int p,
unsigned int i=0);
247 unsigned int num_members(
unsigned int p)
const { assert(p<NP);
return 1; }
251 inline LIBINT2_UINT_LEAST64
key()
const;
253 LIBINT2_UINT_LEAST64
max_key()
const;
254 #if COMPUTE_SIZE_DIRECTLY 255 unsigned int size()
const;
263 #if COMPUTE_SIZE_DIRECTLY 264 mutable unsigned int size_;
268 template <
class BFS,
unsigned int NP>
271 #if COMPUTE_SIZE_DIRECTLY 276 template <
class BFS,
unsigned int NP>
278 for(
int i=0; i<NP; i++)
280 #if COMPUTE_SIZE_DIRECTLY 285 template <
class BFS,
unsigned int NP>
287 assert(braket.size()==NP);
288 for(
unsigned int i=0; i<NP; i++) {
289 assert(braket[i].size()==1);
290 bfs_[i] = braket[i][0];
292 #if COMPUTE_SIZE_DIRECTLY 297 template <
class BFS,
unsigned int NP>
300 template <
class BFS,
unsigned int NP>
303 for(
int i=0; i<NP; i++)
309 template <
class BFS,
unsigned int NP>
310 typename ArrayBraket<BFS,NP>::bfs_cref
312 assert(i==0 && p<NP);
316 template <
class BFS,
unsigned int NP>
317 typename ArrayBraket<BFS,NP>::bfs_ref
319 assert(i==0 && p<NP);
324 template <
class BFS,
unsigned int NP>
327 assert(i==0 && p<NP);
331 template <
class BFS,
unsigned int NP>
334 assert(i==0 && p<NP);
339 template <
class BFS,
unsigned int NP>
342 assert(i==0 && p<NP);
347 template <
class BFS,
unsigned int NP>
350 LIBINT2_UINT_LEAST64 pfac = 1;
351 LIBINT2_UINT_LEAST64
key = 0;
352 for(
int p=NP-1; p>=0; p--) {
353 key += pfac*bfs_[p].key();
354 pfac *= BFS::max_key;
360 template <
class BFS,
unsigned int NP>
363 LIBINT2_UINT_LEAST64
max_key = 1;
364 for(
int p=NP-1; p>=0; p--) {
365 max_key *= BFS::max_key;
370 #if COMPUTE_SIZE_DIRECTLY 371 template <
class BFS,
unsigned int NP>
374 if (size_ > 0)
return size_;
377 for(
int p=NP-1; p>=0; p--) {
378 size_ *= bfs_[p].num_bf();
385 template <
class BFS,
unsigned int NP>
393 template <
typename BFS>
401 template <
typename BFS>
420 typedef BFS bfs_type;
427 const BFS& operator[](
unsigned int i)
const {
428 if (i == 0)
return bfs_.first;
429 if (i == 1)
return bfs_.second;
430 throw std::logic_error(
"BraketPair::operator[] -- argument out of range");
434 return rhs.bfs_ == bfs_;
438 std::pair<BFS,BFS> bfs_;
461 template <
class BFS, BraketType BKTypeL, BraketType BKTypeR>
464 return algebra::make_wedge(L,R);
LIBINT2_UINT_LEAST64 key() const
Implements Hashable::key()
Definition: braket.h:175
BraketPair< F, CBra > _cbra(const F &f1, const F &f2)
Chemists bra.
Definition: braket.h:452
LIBINT2_UINT_LEAST64 max_key() const
key lies in range [0,max_key())
Definition: braket.h:362
bfs_cref member(unsigned int p, unsigned int i=0) const
Returns cref to the i-th function for particle p.
Definition: braket.h:311
TrivialBFSet<T> defines static member result, which is true if T is a basis function set consisting o...
Definition: bfset.h:879
unsigned int num_members(unsigned int p) const
Returns the number of BFS for particle p.
Definition: braket.h:247
ConstructablePolymorphically is a base for all objects which can be constructed using a SafePtr to a ...
Definition: polyconstr.h:30
LIBINT2_UINT_LEAST64 max_key() const
key lies in range [0,max_key())
Definition: braket.h:194
bool operator==(const this_type &rhs) const
Comparison function.
Definition: braket.h:433
There's no parent.
Definition: braket.h:219
Defaults definitions for various parameters assumed by Libint.
Definition: algebra.cc:23
Objects of Hashable<T> class provide hashing function key() which computes keys of type KeyType...
Definition: hashable.h:72
BraketPair< F, PKet > _pket(const F &f1, const F &f2)
Physicists ket.
Definition: braket.h:448
bool operator==(const this_type &) const
Comparison function.
Definition: braket.h:302
BraketPair< F, CKet > _cket(const F &f1, const F &f2)
Chemists ket.
Definition: braket.h:456
Wedge is a typeholder for the result of a wedge product.
Definition: algebra.h:245
ArrayBraket< BFS, NP > this_type
This type.
Definition: braket.h:217
ArrayBraket()
This one is a very dangerous constructor – do not to use it if at all possible.
Definition: braket.h:269
void set_member(bfs_cref, unsigned int p, unsigned int i)
Sets i-th function for particle p.
Definition: braket.h:127
BraketType
enumerates types of brakets used for describing two-electron integrals: CBra and CKet are bra and ket...
Definition: braket.h:412
SubIteratorBase<T> provides a base class for a sub-iterator class for T.
Definition: iter.h:72
LIBINT2_UINT_LEAST64 key() const
Implements Hashable::key()
Definition: braket.h:349
unsigned int num_part() const
Returns the number of particles.
Definition: braket.h:161
ArrayBraket< typename BFS::iter_type, NP > iter_type
The iterator through ArrayBraket.
Definition: braket.h:221
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:326
SubIterator * member_subiter(unsigned int p, unsigned int i) const
Returns pointer to the SubIterator for i-th BFS of particle p.
Definition: braket.h:120
void set_member(const BFS &, unsigned int p, unsigned int i=0)
Sets i-th function for particle p.
Definition: braket.h:333
ArrayBraket< BFS, 1 > Result
This defines which Braket implementation to use.
Definition: braket.h:396
VectorBraket()
This one is a very dangerous constructor – do not to use it if at all possible.
Definition: braket.h:82
This is the implementation of the Braket concept used by GenIntegralSet_1_1.
Definition: braket.h:394
Iterator provides a base class for all object iterator classes.
Definition: iter.h:44
unsigned int num_part() const
Returns the number of particles.
Definition: braket.h:249
bool operator==(const VectorBraket &) const
Comparison function.
Definition: braket.h:168
unsigned int num_members(unsigned int p) const
Returns the number of BFS for particle p.
Definition: braket.h:154
This is the implementation of the Braket concept used by GenIntegralSet_11_11.
Definition: braket.h:402
BraketPair is a trimmed down version of ArrayBraket specialized for same-particle or different-partic...
Definition: braket.h:416
BraketPair< F, PBra > _pbra(const F &f1, const F &f2)
Physicists bra.
Definition: braket.h:444
ArrayBraket is a lightweight implementation of Braket concept.
Definition: braket.h:214
BraketPair< BFS, BKType > this_type
This type.
Definition: braket.h:419
bfs_ref member(unsigned int p, unsigned int i)
Returns pointer to the i-th function for particle p.
Definition: braket.h:106
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:424
ArrayBraket< BFS, 2 > Result
This defines which Braket implementation to use.
Definition: braket.h:404
VectorBraket is a std::vector-based type that can be used as a BraSetType or a KetSetType parameter t...
Definition: braket.h:35