mpqc::FermionOccupationNBitString< Ns > Class Template Reference

Documentation

template<size_t Ns>
class mpqc::FermionOccupationNBitString< Ns >

A "dense" nullable string represents occupancies of a set of Ns states by a fixed-width 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 = std::bitset< Ns >
 
using base_type = parent_type
 
using state_index_type = orbital_index_type
 
using vectorofbool_t = boost::container::small_vector< bool, Ns >
 

Public Member Functions

 FermionOccupationNBitString () noexcept=default
 constructs a null string More...
 
 FermionOccupationNBitString (const FermionOccupationNBitString &other) noexcept
 
 FermionOccupationNBitString (FermionOccupationNBitString &&) noexcept=default
 move ctor More...
 
FermionOccupationNBitStringoperator= (const FermionOccupationNBitString &other) noexcept
 
FermionOccupationNBitStringoperator= (FermionOccupationNBitString &&) noexcept=default
 move assignment More...
 
 ~FermionOccupationNBitString () noexcept=default
 
 FermionOccupationNBitString (int N, bool default_to_occupied=false)
 
 FermionOccupationNBitString (int N, const base_type &bitset)
 
 FermionOccupationNBitString (int N, unsigned long ulong_bitset)
 
template<typename IntegralRange , typename = std::enable_if_t< TiledArray::detail::is_integral_range_v<IntegralRange>>>
 FermionOccupationNBitString (int nstates, IntegralRange &&occupied_states)
 
template<typename Integer , typename = std::enable_if_t<std::is_integral_v<Integer>>>
 FermionOccupationNBitString (int nstates, const std::initializer_list< Integer > &occupied_states)
 
 operator bool () const
 
FermionOccupationNBitString clone () const
 
bool empty () const
 
void reset ()
 
FermionOccupationNBitStringflip ()
 
size_t size () const
 
size_t count () const
 
auto occupied_states () const
 
auto unoccupied_states () const
 
const PopulatedSparseOrbitalRangepopulated_states () const
 
std::int64_t find_first_occupied () const
 
std::int64_t find_next_occupied (std::int64_t pos) const
 
FermionOccupationNBitStringremove (size_t from)
 
FermionOccupationNBitStringremove_unsafe (size_t from)
 
FermionOccupationNBitStringadd (size_t to)
 
FermionOccupationNBitStringadd_unsafe (size_t to)
 
size_t count (std::int64_t pos1, size_t pos2) const
 
size_t hash_value () const
 
boost::dynamic_bitset to_bitset () const
 
vectorofbool_t to_vectorofbool () const
 
unsigned long to_ulong () const
 
template<size_t M>
bool operator== (const FermionOccupationNBitString< M > &other) const
 
template<size_t M>
bool operator!= (const FermionOccupationNBitString< M > &other) const
 
FermionOccupationNBitString operator+ (const FermionOccupationNBitString &other) const
 
FermionOccupationNBitString operator^ (const FermionOccupationNBitString &other) const
 
FermionOccupationNBitString operator& (const FermionOccupationNBitString &other) const
 
FermionOccupationNBitString operator| (const FermionOccupationNBitString &other) const
 

Member Typedef Documentation

◆ base_type

template<size_t Ns>
using mpqc::FermionOccupationNBitString< Ns >::base_type = parent_type

◆ parent_type

template<size_t Ns>
using mpqc::FermionOccupationNBitString< Ns >::parent_type = std::bitset<Ns>

◆ state_index_type

◆ vectorofbool_t

template<size_t Ns>
using mpqc::FermionOccupationNBitString< Ns >::vectorofbool_t = boost::container::small_vector<bool, Ns>

Constructor & Destructor Documentation

◆ FermionOccupationNBitString() [1/8]

template<size_t Ns>
mpqc::FermionOccupationNBitString< Ns >::FermionOccupationNBitString ( )
defaultnoexcept

constructs a null string

◆ FermionOccupationNBitString() [2/8]

template<size_t Ns>
mpqc::FermionOccupationNBitString< Ns >::FermionOccupationNBitString ( const FermionOccupationNBitString< Ns > &  other)
inlinenoexcept

copy ctor

Note
does not copy memoized part of state

◆ FermionOccupationNBitString() [3/8]

template<size_t Ns>
mpqc::FermionOccupationNBitString< Ns >::FermionOccupationNBitString ( FermionOccupationNBitString< Ns > &&  )
defaultnoexcept

move ctor

◆ ~FermionOccupationNBitString()

template<size_t Ns>
mpqc::FermionOccupationNBitString< Ns >::~FermionOccupationNBitString ( )
defaultnoexcept

◆ FermionOccupationNBitString() [4/8]

template<size_t Ns>
mpqc::FermionOccupationNBitString< Ns >::FermionOccupationNBitString ( int  N,
bool  default_to_occupied = false 
)
inlineexplicit

Constructs a set of N states

Parameters
[in]Nnumber of states represented by this string, asserted to be less than or equal to Ns
[in]default_to_occupiedif true, will make all states occupied

◆ FermionOccupationNBitString() [5/8]

template<size_t Ns>
mpqc::FermionOccupationNBitString< Ns >::FermionOccupationNBitString ( int  N,
const base_type bitset 
)
inlineexplicit

Constructs a string of N states using bits encoded by a std::bitset

Parameters
[in]Nnumber of states represented by this string, asserted to be less than or equal to Ns
[in]std::bitset

◆ FermionOccupationNBitString() [6/8]

template<size_t Ns>
mpqc::FermionOccupationNBitString< Ns >::FermionOccupationNBitString ( int  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; see std::bitset<>::bitset(unsigned long)

◆ FermionOccupationNBitString() [7/8]

template<size_t Ns>
template<typename IntegralRange , typename = std::enable_if_t< TiledArray::detail::is_integral_range_v<IntegralRange>>>
mpqc::FermionOccupationNBitString< Ns >::FermionOccupationNBitString ( int  nstates,
IntegralRange &&  occupied_states 
)
inline

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

Template Parameters
IntegralRangea range of integers
Parameters
[in]nstatesnumber of states represented by this string, asserted to be nonnegative and less than or equal to Ns ;
occupied_statesthe sequence of occupied states

◆ FermionOccupationNBitString() [8/8]

template<size_t Ns>
template<typename Integer , typename = std::enable_if_t<std::is_integral_v<Integer>>>
mpqc::FermionOccupationNBitString< Ns >::FermionOccupationNBitString ( int  nstates,
const std::initializer_list< Integer > &  occupied_states 
)
inline

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

Template Parameters
Integeran integral type
Parameters
[in]nstatesnumber of states represented by this string, asserted to be nonnegative and less than or equal to Ns ;
occupied_statesthe sequence of occupied states

Member Function Documentation

◆ add()

template<size_t Ns>
FermionOccupationNBitString& mpqc::FermionOccupationNBitString< Ns >::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

◆ add_unsafe()

template<size_t Ns>
FermionOccupationNBitString& mpqc::FermionOccupationNBitString< Ns >::add_unsafe ( 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.)
Warning
unsafe version of add() , does not check whether fram is empty

◆ clone()

template<size_t Ns>
FermionOccupationNBitString mpqc::FermionOccupationNBitString< Ns >::clone ( ) const
inline
Returns
clone of *this

◆ count() [1/2]

template<size_t Ns>
size_t mpqc::FermionOccupationNBitString< Ns >::count ( ) const
inline

Reports the number of occupied states

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

◆ count() [2/2]

template<size_t Ns>
size_t mpqc::FermionOccupationNBitString< Ns >::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()

template<size_t Ns>
bool mpqc::FermionOccupationNBitString< Ns >::empty ( ) const
inline

are all states empty?

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

◆ find_first_occupied()

template<size_t Ns>
std::int64_t mpqc::FermionOccupationNBitString< Ns >::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()

template<size_t Ns>
std::int64_t mpqc::FermionOccupationNBitString< Ns >::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()

template<size_t Ns>
FermionOccupationNBitString& mpqc::FermionOccupationNBitString< Ns >::flip ( )
inline

flips the occupancies of all states

Returns
reference to *this
Note
asserts that this is nonnull

◆ hash_value()

template<size_t Ns>
size_t mpqc::FermionOccupationNBitString< Ns >::hash_value ( ) const
inline

computes the hash value of this

Warning
for Ns <= 64 this is optimized to return this->to_ulong()

◆ occupied_states()

template<size_t Ns>
auto mpqc::FermionOccupationNBitString< Ns >::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()

template<size_t Ns>
mpqc::FermionOccupationNBitString< Ns >::operator bool ( ) const
inlineexplicit

converts to true is valid (nonnull) string

◆ operator!=()

template<size_t Ns>
template<size_t M>
bool mpqc::FermionOccupationNBitString< Ns >::operator!= ( const FermionOccupationNBitString< M > &  other) const
inline
Parameters
[in]otheranother string
Returns
true if (*this)==other is false

◆ operator&()

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

◆ operator+()

template<size_t Ns>
FermionOccupationNBitString mpqc::FermionOccupationNBitString< Ns >::operator+ ( const FermionOccupationNBitString< Ns > &  other) const
inline

concatenates this string and another string

Parameters
otheranother string
Returns
the result of concatenating 2 strings
Note
asserts that the current states of this and other are nonnull
Postcondition
result.size()==this->size()+other.size()

◆ operator=() [1/2]

template<size_t Ns>
FermionOccupationNBitString& mpqc::FermionOccupationNBitString< Ns >::operator= ( const FermionOccupationNBitString< Ns > &  other)
inlinenoexcept

copy assignment

Note
does not copy memoized part of state

◆ operator=() [2/2]

template<size_t Ns>
FermionOccupationNBitString& mpqc::FermionOccupationNBitString< Ns >::operator= ( FermionOccupationNBitString< Ns > &&  )
defaultnoexcept

move assignment

◆ operator==()

template<size_t Ns>
template<size_t M>
bool mpqc::FermionOccupationNBitString< Ns >::operator== ( const FermionOccupationNBitString< M > &  other) const
inline
Parameters
[in]otheranother string
Returns
true if both are null, or both are valid and equal

◆ operator^()

template<size_t Ns>
FermionOccupationNBitString mpqc::FermionOccupationNBitString< Ns >::operator^ ( const FermionOccupationNBitString< Ns > &  other) const
inline
Parameters
otheranother string
Returns
XOR of *this with other
Precondition
this->size() == other.size()

◆ operator|()

template<size_t Ns>
FermionOccupationNBitString mpqc::FermionOccupationNBitString< Ns >::operator| ( const FermionOccupationNBitString< Ns > &  other) const
inline
Parameters
otheranother string
Returns
OR of *this with other
Precondition
this->size() == other.size()

◆ populated_states()

template<size_t Ns>
const PopulatedSparseOrbitalRange& mpqc::FermionOccupationNBitString< Ns >::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()

template<size_t Ns>
FermionOccupationNBitString& mpqc::FermionOccupationNBitString< Ns >::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

◆ remove_unsafe()

template<size_t Ns>
FermionOccupationNBitString& mpqc::FermionOccupationNBitString< Ns >::remove_unsafe ( size_t  from)
inline

Removes a particle from state from.

Parameters
fromthe 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.)
Warning
unsafe version of remove() , does not check whether fram is occupied

◆ reset()

template<size_t Ns>
void mpqc::FermionOccupationNBitString< Ns >::reset ( )
inline

empties all states

◆ size()

template<size_t Ns>
size_t mpqc::FermionOccupationNBitString< Ns >::size ( ) const
inline

Reports the total number of states

Returns
the total number states
Note
asserts that this is nonnull

◆ to_bitset()

template<size_t Ns>
boost::dynamic_bitset mpqc::FermionOccupationNBitString< Ns >::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()

template<size_t Ns>
unsigned long mpqc::FermionOccupationNBitString< Ns >::to_ulong ( ) const
inline

converts to unsigned long

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

◆ to_vectorofbool()

template<size_t Ns>
vectorofbool_t mpqc::FermionOccupationNBitString< Ns >::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()

template<size_t Ns>
auto mpqc::FermionOccupationNBitString< Ns >::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 files:
size_t size() const
Definition: string.h:241
constexpr SpinCase1 other(SpinCase1 S)
given 1-spin return the other 1-spin
Definition: spin.cpp:61