mpqc::FermionOccupationDBitString Class Reference
Collaboration diagram for mpqc::FermionOccupationDBitString:

Documentation

A "dense" nullable string represents occupancies of a set of Ns states by a bitstring. The null string is distinct from a string in space of 0 states.

Template Parameters
Nsthe number of states

Public Types

using parent_type = boost::dynamic_bitset<>
 
using base_type = parent_type
 
using state_index_type = orbital_index_type
 
using vectorofbool_t = boost::container::small_vector< bool, 128 >
 

Public Member Functions

 FermionOccupationDBitString ()
 constructs an invalid (null) string More...
 
 FermionOccupationDBitString (const FermionOccupationDBitString &other)
 
 FermionOccupationDBitString (FermionOccupationDBitString &&)=default
 move ctor More...
 
FermionOccupationDBitStringoperator= (const FermionOccupationDBitString &other)
 
FermionOccupationDBitStringoperator= (FermionOccupationDBitString &&)=default
 move assignment More...
 
 ~FermionOccupationDBitString ()=default
 
 FermionOccupationDBitString (size_t N, bool default_to_occupied=false)
 
 FermionOccupationDBitString (size_t N, unsigned long ulong_bitset)
 
 FermionOccupationDBitString (boost::dynamic_bitset<> &&bs, bool includes_extra_bit=false)
 
template<typename IntegralRange , typename = std::enable_if_t< TiledArray::detail::is_integral_range_v<IntegralRange>>>
 FermionOccupationDBitString (size_t N, IntegralRange &&occupied_states)
 
template<typename Integer , typename = std::enable_if_t<std::is_integral_v<Integer>>>
 FermionOccupationDBitString (size_t N, const std::initializer_list< Integer > &occupied_states)
 
size_t size () const
 
 operator bool () const
 
bool empty () const
 
void reset ()
 
FermionOccupationDBitString clone () const
 
FermionOccupationDBitStringflip ()
 
size_t count () const
 
auto occupied_states () const
 
auto unoccupied_states () const
 
const PopulatedSparseOrbitalRangepopulated_states () const
 
FermionOccupationDBitStringremove (size_t from)
 
FermionOccupationDBitStringadd (size_t to)
 
size_t count (std::int64_t pos1, size_t pos2) const
 
std::int64_t find_first_occupied () const
 
std::int64_t find_next_occupied (std::int64_t pos) const
 
size_t hash_value () const
 
boost::dynamic_bitset to_bitset () const
 
vectorofbool_t to_vectorofbool () const
 
unsigned long to_ulong () const
 
bool operator== (const FermionOccupationDBitString &other) const
 
bool operator!= (const FermionOccupationDBitString &other) const
 
FermionOccupationDBitString operator^ (const FermionOccupationDBitString &other) const
 
FermionOccupationDBitString operator& (const FermionOccupationDBitString &other) const
 
FermionOccupationDBitString operator| (const FermionOccupationDBitString &other) const
 

Member Typedef Documentation

◆ base_type

◆ parent_type

using mpqc::FermionOccupationDBitString::parent_type = boost::dynamic_bitset<>

◆ state_index_type

◆ vectorofbool_t

using mpqc::FermionOccupationDBitString::vectorofbool_t = boost::container::small_vector<bool, 128>

Constructor & Destructor Documentation

◆ FermionOccupationDBitString() [1/8]

mpqc::FermionOccupationDBitString::FermionOccupationDBitString ( )
inline

constructs an invalid (null) string

◆ FermionOccupationDBitString() [2/8]

mpqc::FermionOccupationDBitString::FermionOccupationDBitString ( const FermionOccupationDBitString other)
inline

copy ctor

Note
does not copy memoized part of state

◆ FermionOccupationDBitString() [3/8]

mpqc::FermionOccupationDBitString::FermionOccupationDBitString ( FermionOccupationDBitString &&  )
default

move ctor

◆ ~FermionOccupationDBitString()

mpqc::FermionOccupationDBitString::~FermionOccupationDBitString ( )
default

◆ FermionOccupationDBitString() [4/8]

mpqc::FermionOccupationDBitString::FermionOccupationDBitString ( size_t  N,
bool  default_to_occupied = false 
)
inlineexplicit

Constructs a set of N states

Parameters
[in]Nthe number of states
[in]default_to_occupiedif true, will make all states occupied

◆ FermionOccupationDBitString() [5/8]

mpqc::FermionOccupationDBitString::FermionOccupationDBitString ( size_t  N,
unsigned long  ulong_bitset 
)
inlineexplicit

Constructs a string of N states using bits encoded by an unsigned long

Parameters
[in]Nnumber of states represented by this string, asserted to be less than or equal to Ns
[in]ulong_bitsetan unsigned long encoding the string

◆ FermionOccupationDBitString() [6/8]

mpqc::FermionOccupationDBitString::FermionOccupationDBitString ( boost::dynamic_bitset<> &&  bs,
bool  includes_extra_bit = false 
)
inlineexplicit

Constructs a set of states specified by a bitset

Parameters
bsa bitset specifying the occupancies of the states (set bit indicates occupied states)

◆ FermionOccupationDBitString() [7/8]

template<typename IntegralRange , typename = std::enable_if_t< TiledArray::detail::is_integral_range_v<IntegralRange>>>
mpqc::FermionOccupationDBitString::FermionOccupationDBitString ( size_t  N,
IntegralRange &&  occupied_states 
)
inline

Constructs FermionOccupationDBitString using a (possibly-empty) set of indices of occupied states

Template Parameters
IntegralRangea range of integers
Parameters
[in]Nnumber of states represented by this string
occupied_statesthe sequence of occupied states

◆ FermionOccupationDBitString() [8/8]

template<typename Integer , typename = std::enable_if_t<std::is_integral_v<Integer>>>
mpqc::FermionOccupationDBitString::FermionOccupationDBitString ( size_t  N,
const std::initializer_list< Integer > &  occupied_states 
)
inline

Constructs FermionOccupationDBitString using a (possibly-empty) set of indices of occupied states

Template Parameters
Integeran integral type
Parameters
[in]Nnumber of states represented by this string
occupied_statesthe sequence of occupied states

Member Function Documentation

◆ add()

FermionOccupationDBitString& mpqc::FermionOccupationDBitString::add ( size_t  to)
inline

Adds a particle to state to_.

Parameters
tothe state to which the particle will be added.
Returns
reference to this string, for chaining operations (e.g. a.remove(0).remove(7).add(13) etc.)
Note
if this object is null, this is noop

◆ clone()

FermionOccupationDBitString mpqc::FermionOccupationDBitString::clone ( ) const
inline
Returns
clone of *this s

◆ count() [1/2]

size_t mpqc::FermionOccupationDBitString::count ( ) const
inline

Reports the number of occupied states

Returns
the number of occupied states
Note
asserts that this is nonnull

◆ count() [2/2]

size_t mpqc::FermionOccupationDBitString::count ( std::int64_t  pos1,
size_t  pos2 
) const
inline

counts the number of bits in (pos1,pos2) (assumes pos2 >= pos1)

Parameters
pos1integer in [-1,Ns), set to -1 to count bits in [0,pos2)
pos2integer in [0,Ns)
Returns
the number of bits in (pos1,pos2)
Note
asserts that this is nonnull

◆ empty()

bool mpqc::FermionOccupationDBitString::empty ( ) const
inline

are all states empty?

Returns
true if all states are empty
Note
asserts that this is nonnull

◆ find_first_occupied()

std::int64_t mpqc::FermionOccupationDBitString::find_first_occupied ( ) const
inline
Returns
the lowest index i such as state i is occupied, or -1 if *this has no occupied states.

◆ find_next_occupied()

std::int64_t mpqc::FermionOccupationDBitString::find_next_occupied ( std::int64_t  pos) const
inline
Returns
the lowest index i greater than pos such as state i is occupied, or -1 if no such occupied states exist.

◆ flip()

FermionOccupationDBitString& mpqc::FermionOccupationDBitString::flip ( )
inline

flips the occupancies of all states

Returns
reference to *this
Note
asserts that this is nonnull

◆ hash_value()

size_t mpqc::FermionOccupationDBitString::hash_value ( ) const
inline
Warning
for 64 or fewer states this is optimized to return this->to_ulong()

◆ occupied_states()

auto mpqc::FermionOccupationDBitString::occupied_states ( ) const
inline

Reports the states that are occupied in this string

Returns
a range with the indices of all occupied states (in increasing order)
Note
asserts that this is nonnull

◆ operator bool()

mpqc::FermionOccupationDBitString::operator bool ( ) const
inlineexplicit
Returns
true of string is not in a null state

◆ operator!=()

bool mpqc::FermionOccupationDBitString::operator!= ( const FermionOccupationDBitString other) const
inline
Parameters
[in]otheranother string
Returns
true if (*this)==other is false

◆ operator&()

FermionOccupationDBitString mpqc::FermionOccupationDBitString::operator& ( const FermionOccupationDBitString other) const
inline
Parameters
otheranother string
Returns
AND of *this with other
Precondition
this->size() == other.size()

◆ operator=() [1/2]

FermionOccupationDBitString& mpqc::FermionOccupationDBitString::operator= ( const FermionOccupationDBitString other)
inline

copy assignment

Note
does not copy memoized part of state

◆ operator=() [2/2]

FermionOccupationDBitString& mpqc::FermionOccupationDBitString::operator= ( FermionOccupationDBitString &&  )
default

move assignment

◆ operator==()

bool mpqc::FermionOccupationDBitString::operator== ( const FermionOccupationDBitString other) const
inline
Parameters
[in]otheranother string
Returns
true if both are null, or both are valid and equal

◆ operator^()

FermionOccupationDBitString mpqc::FermionOccupationDBitString::operator^ ( const FermionOccupationDBitString other) const
inline
Parameters
otheranother string
Returns
XOR of *this with other
Precondition
this->size() == other.size()

◆ operator|()

FermionOccupationDBitString mpqc::FermionOccupationDBitString::operator| ( const FermionOccupationDBitString other) const
inline
Parameters
otheranother string
Returns
OR of *this with other
Precondition
this->size() == other.size()

◆ populated_states()

const PopulatedSparseOrbitalRange& mpqc::FermionOccupationDBitString::populated_states ( ) const
inline

Reports the states in the order of their occupancy (occupied first, unoccupied second)

Returns
a const reference to (memoized) PopulatedSparseOrbitalRange object, with occupied orbitals preceding occupied orbitals
Note
asserts that this is nonnull

◆ remove()

FermionOccupationDBitString& mpqc::FermionOccupationDBitString::remove ( size_t  from)
inline

Removes a particle from_ state from_.

Parameters
from_the state from_ which the particle will be removed.
Returns
reference to this string, for chaining operations (e.g. a.remove(0).remove(7).add(13) etc.)
Note
if this object is null, this is noop

◆ reset()

void mpqc::FermionOccupationDBitString::reset ( )
inline

empties all states

◆ size()

size_t mpqc::FermionOccupationDBitString::size ( ) const
inline

Reports the total number of states

Returns
the total number states
Note
asserts that this is nonnull

◆ to_bitset()

boost::dynamic_bitset mpqc::FermionOccupationDBitString::to_bitset ( ) const
inline

converts to the bitset representation of this string

Returns
bitset representation of this string
Note
asserts that this is nonnull

◆ to_ulong()

unsigned long mpqc::FermionOccupationDBitString::to_ulong ( ) const
inline

converts to unsigned long

Returns
unsigned long representation of this string
Note
asserts that this is nonnull

◆ to_vectorofbool()

vectorofbool_t mpqc::FermionOccupationDBitString::to_vectorofbool ( ) const
inline

converts to the vector-of-bool representation of this string

Returns
vector-of-bool representation of this string
Note
asserts that this is nonnull

◆ unoccupied_states()

auto mpqc::FermionOccupationDBitString::unoccupied_states ( ) const
inline

Reports the states that are unoccupied in this string

Returns
a range with the indices of all unoccupied states (in increasing order)
Note
asserts that this is nonnull

The documentation for this class was generated from the following file: