manybody::BitsetSlater< N > Class Template Reference

Class definition of BitsetSlater. More...

#include <BitsetSlater.hpp>

List of all members.

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.


Detailed Description

template<int N>
class manybody::BitsetSlater< N >

Class definition of BitsetSlater.

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.


Member Function Documentation

template<int N>
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.

Parameters:
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
Returns:
0, 1, 2, 3, ... n, (or n+1 for >n; then alpha, beta, p and q are not defined) bits different.

template<int N>
int manybody::BitsetSlater< N >::annihilate ( size_t  alpha  )  [inline]

"Destroy a particle" at orbital alpha. Returns sign change of operation.

Parameters:
alpha Position of particle to destroy
Returns:
-1 if odd permutation is reqiured, 1 if even permutation, 0 if particle didn't already exist.

Here is the call graph for this function:

template<int N>
size_t manybody::BitsetSlater< N >::count (  )  const [inline]

Count the number of bits set, i.e., the number of particles.

Returns:
Number of bits set (particles)

template<int N>
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).

Parameters:
a First endpoint
b Last endpoint
Returns:
Number of bits (particles)

template<int N>
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'.

Parameters:
even Output: number of even-numbered bits set (starting with 0)
odd Output: number of odd-numbered bits set (starting with 1)

template<int N>
int manybody::BitsetSlater< N >::create ( size_t  alpha  )  [inline]

"Create a particle" at orbital alpha. Returns sign change of operation.

Parameters:
alpha Position of particle to create
Returns:
-1 if odd permutation is reqiured, 1 if even permutation, 0 if particle already exists.

Here is the call graph for this function:

template<int N>
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.

Parameters:
ones Reference to std::vector<size_t> where the result is stored. Resized automatically.

Here is the call graph for this function:

template<int N>
int manybody::BitsetSlater< N >::get ( size_t  alpha  )  const [inline]

Read a bit (check for particle).

Parameters:
alpha Position of bit (orbital number)

template<int N>
size_t manybody::BitsetSlater< N >::mem (  )  const [inline]

Compute the memory in bytes used by the BitsetSlater object.

Returns:
Number of bytes

template<int N>
void manybody::BitsetSlater< N >::set ( size_t  alpha  )  [inline]

Set a bit (place particle).

Parameters:
alpha Position of bit (orbital number)

template<int N>
std::string manybody::BitsetSlater< N >::to_binary ( int  K = N  )  const [inline]

Compute binary number representation of Slater determinant.

Parameters:
K Number of bits to use; defaults to all bits.
Returns:
String sequence of 0's and 1's

template<int N>
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.

Returns:
String, example: 01001 --> "0 3 "

template<int N>
void manybody::BitsetSlater< N >::unset ( size_t  alpha  )  [inline]

Clear a bit (remove particle).

Parameters:
alpha Position of bit (orbital number)


The documentation for this class was generated from the following file:
Generated on Wed Jun 17 11:44:03 2009 for OpenFCI by  doxygen 1.4.7