Defining quantum subspaces

The second main component of eigensolving, after the QubitOperator is the Subspace. The Subspace class is the Fulqrum representation of counts sampled from a quantum device or simulator.

[1]:
import fulqrum as fq

At present, Subspace objects are generated from counts represented by sampled bit-strings represented as Python strings in a dictionary”

[2]:
# 1 million Pseudo counts
num_qubits = 20
counts = []
for kk in range(int(1e5)):
    counts.append(bin(kk)[2:].zfill(num_qubits))
[3]:
S = fq.Subspace([counts])

It is possible to query the size of the subspace using:

[4]:
S.size()
[4]:
100000

or

[5]:
len(S)
[5]:
100000

It is also possible to get a specific element of the subspace by index. Like Python dictionaries, the elements are in order:

[6]:
S[-1]
[6]:
Bitset('00011000011010011111')

The BitsetView object is a view onto an underlying Bitset representing the bit-string of interest. Here, view means that one is not allowed to manipulate the underlying data.

These objects can also be converted to integers:

[7]:
S[-1].to_int()
[7]:
99999

or strings:

[8]:
S[-1].to_string()
[8]:
'00011000011010011111'

It is also possible to go directly to a string by passing the index:

[9]:
S.get_n_th_bitstring(99999)
[9]:
'00011000011010011111'