21#ifndef _libint2_src_bin_libint_braket_h_
22#define _libint2_src_bin_libint_braket_h_
26#include <global_macros.h>
27#include <libint2/util/intrinsic_types.h>
28#include <polyconstr.h>
38template <
class BFS,
unsigned int NP>
54 typedef bfs_type& bfs_ref;
55 typedef const BFS& bfs_cref;
62 ArrayBraket(
const std::vector<std::vector<BFS> >& braket);
68 bfs_cref
member(
unsigned int p,
unsigned int i = 0)
const;
70 bfs_ref
member(
unsigned int p,
unsigned int i = 0);
74 void set_member(
const BFS&,
unsigned int p,
unsigned int i = 0);
86 inline LIBINT2_UINT_LEAST64
key()
const;
88 LIBINT2_UINT_LEAST64
max_key()
const;
89#if COMPUTE_SIZE_DIRECTLY
90 unsigned int size()
const;
98#if COMPUTE_SIZE_DIRECTLY
99 mutable unsigned int size_;
103template <
class BFS,
unsigned int NP>
105#if COMPUTE_SIZE_DIRECTLY
110template <
class BFS,
unsigned int NP>
112 for (
int i = 0; i < NP; i++) bfs_[i] = braket[i];
113#if COMPUTE_SIZE_DIRECTLY
118template <
class BFS,
unsigned int NP>
120 const std::vector<std::vector<BFS> >& braket) {
121 assert(braket.size() == NP);
122 for (
unsigned int i = 0; i < NP; i++) {
123 assert(braket[i].size() == 1);
124 bfs_[i] = braket[i][0];
126#if COMPUTE_SIZE_DIRECTLY
131template <
class BFS,
unsigned int NP>
132ArrayBraket<BFS, NP>::~ArrayBraket() {}
134template <
class BFS,
unsigned int NP>
136 for (
int i = 0; i < NP; i++)
137 if (bfs_[i] != a[i])
return false;
141template <
class BFS,
unsigned int NP>
143 unsigned int p,
unsigned int i)
const {
144 assert(i == 0 && p < NP);
148template <
class BFS,
unsigned int NP>
150 unsigned int p,
unsigned int i) {
151 assert(i == 0 && p < NP);
156template <
class BFS,
unsigned int NP>
158 unsigned int i)
const {
159 assert(i == 0 && p < NP);
163template <
class BFS,
unsigned int NP>
166 assert(i == 0 && p < NP);
171template <
class BFS,
unsigned int NP>
173 unsigned int p,
unsigned int i) {
174 assert(i == 0 && p < NP);
179template <
class BFS,
unsigned int NP>
181 LIBINT2_UINT_LEAST64 pfac = 1;
182 LIBINT2_UINT_LEAST64 key = 0;
183 for (
int p = NP - 1; p >= 0; p--) {
184 key += pfac * bfs_[p].key();
185 pfac *= BFS::max_key;
187 assert(key < this->max_key());
191template <
class BFS,
unsigned int NP>
193 LIBINT2_UINT_LEAST64 max_key = 1;
194 for (
int p = NP - 1; p >= 0; p--) {
195 max_key *= BFS::max_key;
200#if COMPUTE_SIZE_DIRECTLY
201template <
class BFS,
unsigned int NP>
203 if (size_ > 0)
return size_;
206 for (
int p = NP - 1; p >= 0; p--) {
207 size_ *= bfs_[p].
num_bf();
214template <
class BFS,
unsigned int NP>
215void ArrayBraket<BFS, NP>::reset_cache() {
221template <
typename BFS>
230template <
typename BFS>
246template <
class BFS, BraketType BKType>
251 typedef BFS bfs_type;
262 const BFS& operator[](
unsigned int i)
const {
263 if (i == 0)
return bfs_.first;
264 if (i == 1)
return bfs_.second;
265 throw std::logic_error(
"BraketPair::operator[] -- argument out of range");
271 std::pair<BFS, BFS> bfs_;
298template <
class BFS, BraketType BKTypeL, BraketType BKTypeR>
299algebra::Wedge<BraketPair<BFS, BKTypeL>, BraketPair<BFS, BKTypeR> > operator^(
300 const BraketPair<BFS, BKTypeL>& L,
const BraketPair<BFS, BKTypeR>& R) {
301 return algebra::make_wedge(L, R);
ArrayBraket is a lightweight implementation of Braket concept.
Definition src/bin/libint/braket.h:39
bool operator==(const this_type &) const
Comparison function.
Definition src/bin/libint/braket.h:135
LIBINT2_UINT_LEAST64 max_key() const
key lies in range [0,max_key())
Definition src/bin/libint/braket.h:192
static constexpr auto num_particles
The total # of particles.
Definition src/bin/libint/braket.h:49
static constexpr auto num_bf
The total # of basis functions = # of particles (since 1 bf / particle)
Definition src/bin/libint/braket.h:51
unsigned int num_members(unsigned int p) const
Returns the number of BFS for particle p.
Definition src/bin/libint/braket.h:79
LIBINT2_UINT_LEAST64 key() const
Implements Hashable::key()
Definition src/bin/libint/braket.h:180
ArrayBraket()
This one is a very dangerous constructor – do not to use it if at all possible.
Definition src/bin/libint/braket.h:104
void set_member(const BFS &, unsigned int p, unsigned int i=0)
Sets i-th function for particle p.
Definition src/bin/libint/braket.h:164
ArrayBraket< BFS, NP > this_type
This type.
Definition src/bin/libint/braket.h:42
SubIterator * member_subiter(unsigned int p, unsigned int i=0) const
Returns pointer to the SubIterator for i-th BFS of particle p.
Definition src/bin/libint/braket.h:157
unsigned int num_part() const
Returns the number of particles.
Definition src/bin/libint/braket.h:84
bfs_cref member(unsigned int p, unsigned int i=0) const
Returns cref to the i-th function for particle p.
Definition src/bin/libint/braket.h:142
ArrayBraket< typename BFS::iter_type, NP > iter_type
The iterator through ArrayBraket.
Definition src/bin/libint/braket.h:47
BraketPair is a trimmed down version of ArrayBraket specialized for same-particle or different-partic...
Definition src/bin/libint/braket.h:247
bool operator==(const this_type &rhs) const
Comparison function.
Definition src/bin/libint/braket.h:268
BraketPair(const BFS &f1, const BFS &f2)
This one is a very dangerous constructor – do not to use it if at all possible.
Definition src/bin/libint/braket.h:256
BraketPair< BFS, BKType > this_type
This type.
Definition src/bin/libint/braket.h:250
ConstructablePolymorphically is a base for all objects which can be constructed using a std::shared_p...
Definition polyconstr.h:30
SubIteratorBase<T> provides a base class for a sub-iterator class for T.
Definition iter.h:73
Iterator provides a base class for all object iterator classes.
Definition iter.h:43
BraketPair< F, PKet > _pket(const F &f1, const F &f2)
Physicists ket.
Definition src/bin/libint/braket.h:283
BraketPair< F, PBra > _pbra(const F &f1, const F &f2)
Physicists bra.
Definition src/bin/libint/braket.h:278
BraketPair< F, CBra > _cbra(const F &f1, const F &f2)
Chemists bra.
Definition src/bin/libint/braket.h:288
BraketPair< F, CKet > _cket(const F &f1, const F &f2)
Chemists ket.
Definition src/bin/libint/braket.h:293
Defaults definitions for various parameters assumed by Libint.
Definition algebra.cc:24
BraketType
enumerates types of brakets used for describing two-electron integrals: CBra and CKet are bra and ket...
Definition src/bin/libint/braket.h:241
There's no parent.
Definition src/bin/libint/braket.h:44
This is the implementation of the Braket concept used by GenIntegralSet_1_1.
Definition src/bin/libint/braket.h:222
ArrayBraket< BFS, 1 > Result
This defines which Braket implementation to use.
Definition src/bin/libint/braket.h:224
This is the implementation of the Braket concept used by GenIntegralSet_11_11.
Definition src/bin/libint/braket.h:231
ArrayBraket< BFS, 2 > Result
This defines which Braket implementation to use.
Definition src/bin/libint/braket.h:233
TrivialBFSet<T> defines static member result, which is true if T is a basis function set consisting o...
Definition bfset.h:906