fulqrum.core.SubspaceHamiltonian¶
- class SubspaceHamiltonian(*args, **kwargs)[source]¶
A SciPy LinearOperator that represents a Hamiltonian restricted to the given subspace.
Methods
Return diagonal vector of Hamiltonian in subspace
Return n-th bitstring in the SubspaceHamiltonian
interpret_vector(vec[, atol, sort, renormalize])Convert solution vector into dict of counts and real or complex amplitudes
matvec(x)Matrix-free implementation of SpMV for subspace Hamiltonian
Return the minimum diagonal energy
to_csr_linearoperator([verbose])Convert subspace Hamiltonian to a LinearOperator wrapping a CSR matrix
to_csr_linearoperator_fast([verbose])Convert subspace Hamiltonian to a CSR LinearOperator faster but with a copy
Attributes
HHermitian adjoint.
TTranspose this linear operator.
ndimNumber of off-diagonal groupings
- diagonal_vector()[source]¶
Return diagonal vector of Hamiltonian in subspace
- Returns:
Complex vector for diagonal of Hamiltonian
- Return type:
ndarray
- get_n_th_bitstring(n)[source]¶
Return n-th bitstring in the SubspaceHamiltonian
- Parameters:
n (int) – Index of the expected bitstring.
- Returns:
N-th bitstring in the subspace.
- Return type:
str
Note
Both Python dictionaries and emhash8::HashMap retain insertion order.
- Raises:
ValueError – If
nis >= to the number of bit-strings in the subspace.
- interpret_vector(vec, atol=1e-14, sort=False, renormalize=True)[source]¶
Convert solution vector into dict of counts and real or complex amplitudes
- Parameters:
vec (ndarray) – Complex or real solution vector
atol (double) – Absolute tolerance for truncation, default=1e-14
sort (bool) – Sort output dict by integer representation, default=False.
renormalize (bool) – Renormalize values such that probabilities sum to one, default = True
- Returns:
Dictionary with bit-string keys and complex values
- Return type:
dict
Note
Truncation can be disabled by calling atol=0
- matvec(x)[source]¶
Matrix-free implementation of SpMV for subspace Hamiltonian
- Parameters:
x (ndarray) – Input array
- Returns:
Output vector after SpMV on input vector
- Return type:
ndarray
- minimum_diagonal_energy()[source]¶
Return the minimum diagonal energy
- Returns:
Lowest energy value
- Return type:
double
- property num_groups¶
Number of off-diagonal groupings
- Returns:
Number of groups in operator
- Return type:
int