fulqrum.core.Bitset¶
- class Bitset¶
Bitset wrapper for Boost dynamic_bitset
Methods
all(self)Check if all bits are set
any(self)Check if any bits are set
count(self)Count the number of set bits
empty(self)Check if bitset has size zero
find_first(self)Finds first set bit
find_next(self, size_t pos=0)Finds next set bit with index > pos
flip(self, bits)Flip one or more bits inplace
ladder_int(self, width_t[, ...)Compute the ladder integer of a bitset for the given indices
none(self)Check if bitset has no set bits
num_blocks(self)Number of blocks (int64) used to store Bitset
offdiag_flip(self, QubitOperator op)Flip bits corresponding to off-diagonal operators in a single Hamiltonian term
size(self)Number of bits in Bitset
to_int(self)Convert Bitset to Python integer
to_string(self)Convert Bitset to string
- all(self)¶
Check if all bits are set
- Returns:
bool
- any(self)¶
Check if any bits are set
- Returns:
bool
- count(self)¶
Count the number of set bits
- Returns:
int
- empty(self)¶
Check if bitset has size zero
- Returns:
bool
- find_first(self)¶
Finds first set bit
- Returns:
Index of first set bit
- Return type:
int
- find_next(self, size_t pos=0)¶
Finds next set bit with index > pos
- Parameters:
pos (int) – Integer position
- Returns:
Index of next set bit
- Return type:
int
- flip(self, bits)¶
Flip one or more bits inplace
- Parameters:
bits (int or array_like) – Indices to flip
- ladder_int(self, width_t[: :1] inds, width_t ladder_width=4)¶
Compute the ladder integer of a bitset for the given indices
- Parameters:
inds (ndarray) – Unsigned int indices to use
ladder_width (int) – Number of bits to consider, default = 3
Notes
If the number of indices is less than the ladder_width then that is the new ladder_width
- none(self)¶
Check if bitset has no set bits
- Returns:
bool
- num_blocks(self)¶
Number of blocks (int64) used to store Bitset
- Returns:
Number of blocks
- Return type:
int
- offdiag_flip(self, QubitOperator op)¶
Flip bits corresponding to off-diagonal operators in a single Hamiltonian term
- Parameters:
op (QubitOperator) – QubitOperator with a single-term
- Returns:
Bitset with off-diagonal bits flipped
- Return type:
- Raises:
FulqrumError – Operator must have a single-term
FulqrumError – Size of Bitset and QubitOperator do not match
- size(self)¶
Number of bits in Bitset
- Returns:
Number of bits
- Return type:
int
- to_int(self)¶
Convert Bitset to Python integer
- Returns:
Integer value for Bitset
- Return type:
int
- to_string(self)¶
Convert Bitset to string
- Returns:
String representation of Bitset
- Return type:
str