cuquantum.densitymat.OperatorSpectrumSolver¶
- class cuquantum.densitymat.OperatorSpectrumSolver(operator: Operator, which: str, hermitian: bool, config: Optional[Union[OperatorSpectrumConfig, dict]] = None)[source]¶
Eigenvalue solver for computing the spectrum (eigenvalues and eigenstates) of quantum operators.
This class provides an interface for finding eigenvalues and eigenstates of
Operator
objects using iterative methods.- Parameters
operator – The quantum operator whose eigenvalues and eigenstates are to be computed. Must be an instance of
Operator
.which – Specifies which eigenvalues to compute. Accepted values are: -
"SA"
: Smallest Algebraic - eigenvalues with smallest real parts, ordered ascending -"LA"
: Largest Algebraic - eigenvalues with largest real parts, ordered descendinghermitian – Whether the operator is Hermitian. This affects the choice of eigenvalue algorithm and can improve performance for Hermitian operators. Currently, only Hermitian operators are supported.
config – Specify options for the eigensolver as a
OperatorSpectrumConfig
object. Alternatively, adict
containing the parameters for theOperatorSpectrumConfig
constructor can also be provided. If not specified, the defaults documented inOperatorSpectrumConfig
are used.
Methods
- __init__(operator: Operator, which: str, hermitian: bool, config: Optional[Union[OperatorSpectrumConfig, dict]] = None) None [source]¶
- compute(t: float, params: Optional[Union[numpy.ndarray, cupy.ndarray, Sequence[float]]], states: Sequence[DensePureState], tol: Optional[Union[float, numpy.ndarray]] = None) OperatorSpectrumResult [source]¶
Compute the spectrum of the provided
Operator
using block Krylov iteration. This function is blocking, i.e. it will only return after the computation is complete.- Parameters
t – Time argument to be passed to all callback functions.
params – Additional arguments to be passed to all callback functions. The element type is required to be float (i.e
"float64"
for arrays). If batched operators or coefficients are used, they need to be passed as 2-dimensional the last dimension of which is the batch size. To avoid copy of the argument array, it can be passed as a fortran-contiguous GPU array.states – Block of linearly-independent initial states for Krylov iteration, which will be in-place updated with the final eigenstates. The number of requested eigenstates is equal to the number of provided initial states.
tol – Tolerance for residuals
||A*x - lambda*x||
. Can be either scalar or array of shape [num_eigvals] or [num_eigvals, batch_size]. If None, square root of machine precision is used.
- Returns
Dataclass holding the requested eigenvalues and eigenstates of the
Operator
.- Return type
- configure(config: Union[OperatorSpectrumConfig, dict]) None [source]¶
Configure the eigensolver.
- Parameters
config – Configuration for the eigensolver. Can be instance of
OperatorSpectrumConfig
ordict
.
- prepare(ctx: WorkStream, repr_state: DensePureState, max_num_eigvals: int = 1) None [source]¶
Prepare the eigensolver for computation.
- Parameters
ctx –
WorkStream
to use for computation. This includes library handle, workspace buffer allocation as well stream on which the computation will be performed.repr_state – Representative state to use for computation.
max_num_eigvals – Maximum number of eigenvalues to compute.
Attributes
- config¶
Configuration options for this solver. Direct modification of the return argument by the user leads to undefined behaviour. Call
OperatorSpectrumSolver.configure()
to modify the configuration.
- is_hermitian¶
Whether the operator is Hermitian.
- which¶
Which eigenvalues this solver computes.