ffsim.addresses_to_strings

ffsim.addresses_to_strings(addresses, norb, nelec, concatenate=True, bitstring_type=BitstringType.INT)[source]

Convert state vector addresses to bitstrings.

Example:

import ffsim

norb = 3
nelec = (2, 1)
dim = ffsim.dim(norb, nelec)

strings = ffsim.addresses_to_strings(range(5), norb, nelec)
print(strings)  # prints [11, 19, 35, 13, 21]

strings = ffsim.addresses_to_strings(
    range(5), norb, nelec, bitstring_type=ffsim.BitstringType.STRING
)
print(strings)  # prints ['001011', '010011', '100011', '001101', '010101']

strings = ffsim.addresses_to_strings(
    range(5), norb, nelec, bitstring_type=ffsim.BitstringType.BIT_ARRAY
)
print(strings)
# prints
# [[False False  True False  True  True]
#  [False  True False False  True  True]
#  [ True False False False  True  True]
#  [False False  True  True False  True]
#  [False  True False  True False  True]]
Parameters:
  • addresses (Sequence[int] | ndarray) – The state vector addresses to convert to bitstrings.

  • norb (int) – The number of spatial orbitals.

  • nelec (int | tuple[int, int]) – Either a single integer representing the number of fermions for a spinless system, or a pair of integers storing the numbers of spin alpha and spin beta fermions.

  • bitstring_type (BitstringType) – The desired type of bitstring output.

  • concatenate (bool) – Whether to concatenate the spin-alpha and spin-beta parts of the bitstrings. If True, then a single list of concatenated bitstrings is returned. The strings are concatenated in the order \(s_b s_a\), that is, the alpha string appears on the right. If False, then two lists are returned, (strings_a, strings_b). Note that the list of alpha strings appears first, that is, on the left. In the spinless case (when nelec is an integer), this argument is ignored.

Returns:

The bitstrings. The type of the output depends on bitstring_type and concatenate.