#include <BitsetSlater.hpp>
Public Member Functions | |
| void | set (size_t alpha) |
| Set a bit (place particle). | |
| void | unset (size_t alpha) |
| Clear a bit (remove particle). | |
| int | get (size_t alpha) const |
| Read a bit (check for particle). | |
| size_t | mem () const |
| Compute the memory in bytes used by the BitsetSlater object. | |
| size_t | count () const |
| Count the number of bits set, i.e., the number of particles. | |
| size_t | count_between (size_t a, size_t b) |
| Count bits set (particles) in the range [a, b) (i.e., exclusive b). | |
| void | count_evenodd (int &even, int &odd) const |
| Count the number of even-numbered and odd-numbered bits set. | |
| int | analyze_difference (const BitsetSlater &phi, size_t alpha[], size_t beta[], size_t p[], size_t q[], int n) |
| Analyze the difference between two Slater dets, i.e., how many and which occupied orbitals are different in the two. | |
| int | create (size_t alpha) |
| "Create a particle" at orbital alpha. Returns sign change of operation. | |
| int | annihilate (size_t alpha) |
| "Destroy a particle" at orbital alpha. Returns sign change of operation. | |
| std::string | to_binary (int K=N) const |
| Compute binary number representation of Slater determinant. | |
| std::string | to_string () const |
| Compute string representation of Slater determinant; each occupied orbital becomes an integer with a space after. | |
| void | find_ones (std::vector< size_t > &ones) |
| Compute a vector containing the positions of all the set bits, i.e., occupied orbitals. | |
| void | print () const |
| Write the slater determinant to cerr. | |
| bool | operator== (const BitsetSlater< N > &c2) const |
| Comparison operator. | |
| bool | operator< (const BitsetSlater< N > &x) const |
| Comparison operator. Requires the hacked version of std::bitset. | |
| size_t | last_index () const |
| Compute the last set bit, i.e., the particle in the orbital with the highest alpha, i.e., the MSB of the bitset. | |
| void | bitwise_xor (const BitsetSlater< N > &c) |
| Bitwise XOR of bit patterns. | |
| void | bitwise_and (const BitsetSlater< N > &c) |
| Bitwise AND of bit patterns. | |
| BitsetSlater< N > & | operator= (const std::bitset< N > &x) |
| Copy from a std::bitset<N>r. | |
This class encapsulates the occupation number formalism version of a Slater determinant. It basically is a std::bitset<N> instance with additional functionality.
Let A be the number of particles in a system, i.e., in a Slater determinant. In the occupation number formalism, instead of specifying A distinct orbitals (integer indices), one specifies single integer (huge in general!) with A bits set, leaving the others blank. So, if 3 particles resides in orbitals 4, 5, and 10, the occupation number formalism specification of the slater determinant is phi = |...00010000110000>.
Notice, that while the oroginal Slater determinant specification was not unique (it had 3! = 6 different representations with different signs), the occupation number formalism specifies a unique integer with 3 bits set. Conversely, all integers with A bits set is a legal A-body Slater determinant.
When we speak of 'bits' in the documentation here, we speak of orbitals ('bit numbers') and particles in orbitals ('set bits').
Implementation note: We chose to have the std::bitset<N> instance as a private member for clarity, but it would be better to derive it. Most importantly, since std::bitset<N> does not have an operator<() defined, and this is needed in some applications, but not essential, we had to hack the original header file. Moreover, the bitset_base class defined in <bitset> is private to bitset, so we cannot access it directly... In my opininon, the STL should define operator<() etc for bitsets.
| int manybody::BitsetSlater< N >::analyze_difference | ( | const BitsetSlater< N > & | phi, | |
| size_t | alpha[], | |||
| size_t | beta[], | |||
| size_t | p[], | |||
| size_t | q[], | |||
| int | n | |||
| ) | [inline] |
Analyze the difference between two Slater dets, i.e., how many and which occupied orbitals are different in the two.
| phi | BitsetSlater to compare with | |
| alpha | output; indices of bits in *this different from phi | |
| beta | output; indices of bits in phi different from *this | |
| p | output; bit numbers of the bits in alpha, i.e., number of transpositions needed to bring creation operator to front. | |
| q | output; bit numbers of the bits in beta | |
| n | input; maximum number of differing bits to detect |
| int manybody::BitsetSlater< N >::annihilate | ( | size_t | alpha | ) | [inline] |
"Destroy a particle" at orbital alpha. Returns sign change of operation.
| alpha | Position of particle to destroy |
Here is the call graph for this function:
| size_t manybody::BitsetSlater< N >::count | ( | ) | const [inline] |
Count the number of bits set, i.e., the number of particles.
| size_t manybody::BitsetSlater< N >::count_between | ( | size_t | a, | |
| size_t | b | |||
| ) | [inline] |
Count bits set (particles) in the range [a, b) (i.e., exclusive b).
| a | First endpoint | |
| b | Last endpoint |
| void manybody::BitsetSlater< N >::count_evenodd | ( | int & | even, | |
| int & | odd | |||
| ) | const [inline] |
Count the number of even-numbered and odd-numbered bits set.
This function is typically used whenever even spins are 'up' and odd are 'down'.
| even | Output: number of even-numbered bits set (starting with 0) | |
| odd | Output: number of odd-numbered bits set (starting with 1) |
| int manybody::BitsetSlater< N >::create | ( | size_t | alpha | ) | [inline] |
"Create a particle" at orbital alpha. Returns sign change of operation.
| alpha | Position of particle to create |
Here is the call graph for this function:
| void manybody::BitsetSlater< N >::find_ones | ( | std::vector< size_t > & | ones | ) | [inline] |
Compute a vector containing the positions of all the set bits, i.e., occupied orbitals.
| ones | Reference to std::vector<size_t> where the result is stored. Resized automatically. |
Here is the call graph for this function:
| int manybody::BitsetSlater< N >::get | ( | size_t | alpha | ) | const [inline] |
Read a bit (check for particle).
| alpha | Position of bit (orbital number) |
| size_t manybody::BitsetSlater< N >::mem | ( | ) | const [inline] |
| void manybody::BitsetSlater< N >::set | ( | size_t | alpha | ) | [inline] |
Set a bit (place particle).
| alpha | Position of bit (orbital number) |
| std::string manybody::BitsetSlater< N >::to_binary | ( | int | K = N |
) | const [inline] |
Compute binary number representation of Slater determinant.
| K | Number of bits to use; defaults to all bits. |
| std::string manybody::BitsetSlater< N >::to_string | ( | ) | const [inline] |
Compute string representation of Slater determinant; each occupied orbital becomes an integer with a space after.
| void manybody::BitsetSlater< N >::unset | ( | size_t | alpha | ) | [inline] |
Clear a bit (remove particle).
| alpha | Position of bit (orbital number) |
1.4.7