fulqrum.core.Bitset¶
- class Bitset¶
Bitset wrapper for Boost dynamic_bitset
Methods
flip(self, bits)Flip one or more bits inplace
ladder_int(self, unsigned int[, ...)Compute the ladder integer of a bitset for the given indices
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
- flip(self, bits)¶
Flip one or more bits inplace
- Parameters:
bits (int or array_like) – Indices to flip
- ladder_int(self, unsigned int[::1] inds, unsigned int 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
- 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