fulqrum.core.SubspaceHamiltonian

class SubspaceHamiltonian(*args, **kwargs)[source]

A SciPy LinearOperator that represents a Hamiltonian restricted to the given subspace.

Methods

diagonal_vector()

Return diagonal vector of Hamiltonian in subspace

get_n_th_bitstring(n)

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

minimum_diagonal_energy()

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

H

Hermitian adjoint.

T

Transpose this linear operator.

ndim

num_groups

Number 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 n is >= 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

to_csr_linearoperator(verbose=False)[source]

Convert subspace Hamiltonian to a LinearOperator wrapping a CSR matrix

Parameters:

verbose (bool) – Turn on verbose mode, default=False.

Returns:

LinearOperator wrapping a CSR matrix.

Return type:

CSRLinearOperator

to_csr_linearoperator_fast(verbose=False)[source]

Convert subspace Hamiltonian to a CSR LinearOperator faster but with a copy

Parameters:

verbose (bool) – Turn on verbose mode, default=False.