Skip to main contentIBM Quantum Documentation
This page is from an old version of Qiskit SDK and does not exist in the latest version. We recommend you migrate to the latest version. See the release notes for more information.

qiskit.aqua.algorithms.NumPyEigensolver

class NumPyEigensolver(operator=None, k=1, aux_operators=None, filter_criterion=None)

GitHub

The NumPy Eigensolver algorithm.

NumPy Eigensolver computes up to the first kk eigenvalues of a complex-valued square matrix of dimension n×nn \times n, with knk \leq n.

Note

Operators are automatically converted to MatrixOperator as needed and this conversion can be costly in terms of memory and performance as the operator size, mostly in terms of number of qubits it represents, gets larger.

Parameters

  • operator (Union[OperatorBase, LegacyBaseOperator, None]) – Operator instance. If None is supplied it must be provided later before run() is called. Allowing None here permits the algorithm to be configured and used later when operator is available, say creating an instance an letting application stack use this algorithm with an operator it creates.
  • k (int) – How many eigenvalues are to be computed, has a min. value of 1.
  • aux_operators (Optional[List[Union[OperatorBase, LegacyBaseOperator, None]]]) – Auxiliary operators to be evaluated at each eigenvalue
  • filter_criterion (Optional[Callable[[Union[List, ndarray], float, Optional[List[float]]], bool]]) – callable that allows to filter eigenvalues/eigenstates, only feasible eigenstates are returned in the results. The callable has the signature filter(eigenstate, eigenvalue, aux_values) and must return a boolean to indicate whether to keep this value in the final returned result or not. If the number of elements that satisfies the criterion is smaller than k then the returned list has fewer elements and can even be empty.

__init__

__init__(operator=None, k=1, aux_operators=None, filter_criterion=None)

Parameters

  • operator (Union[OperatorBase, LegacyBaseOperator, None]) – Operator instance. If None is supplied it must be provided later before run() is called. Allowing None here permits the algorithm to be configured and used later when operator is available, say creating an instance an letting application stack use this algorithm with an operator it creates.
  • k (int) – How many eigenvalues are to be computed, has a min. value of 1.
  • aux_operators (Optional[List[Union[OperatorBase, LegacyBaseOperator, None]]]) – Auxiliary operators to be evaluated at each eigenvalue
  • filter_criterion (Optional[Callable[[Union[List, ndarray], float, Optional[List[float]]], bool]]) – callable that allows to filter eigenvalues/eigenstates, only feasible eigenstates are returned in the results. The callable has the signature filter(eigenstate, eigenvalue, aux_values) and must return a boolean to indicate whether to keep this value in the final returned result or not. If the number of elements that satisfies the criterion is smaller than k then the returned list has fewer elements and can even be empty.

Methods

__init__([operator, k, aux_operators, …])type operatorUnion[OperatorBase, LegacyBaseOperator, None]
compute_eigenvalues([operator, aux_operators])Computes eigenvalues.
run()Execute the classical algorithm.
supports_aux_operators()Whether computing the expectation value of auxiliary operators is supported.

Attributes

aux_operatorsReturns the auxiliary operators.
filter_criterionreturns the filter criterion if set
kreturns k (number of eigenvalues requested)
operatorReturn the operator.
randomReturn a numpy random.

aux_operators

Returns the auxiliary operators.

Return type

Optional[List[Optional[OperatorBase]]]

compute_eigenvalues

compute_eigenvalues(operator=None, aux_operators=None)

Computes eigenvalues. Operator and aux_operators can be supplied here and if not None will override any already set into algorithm so it can be reused with different operators. While an operator is required by algorithms, aux_operators are optional. To ‘remove’ a previous aux_operators array use an empty list here.

Parameters

  • operator (Union[OperatorBase, LegacyBaseOperator, None]) – If not None replaces operator in algorithm
  • aux_operators (Optional[List[Union[OperatorBase, LegacyBaseOperator, None]]]) – If not None replaces aux_operators in algorithm

Return type

EigensolverResult

Returns

EigensolverResult

filter_criterion

returns the filter criterion if set

Return type

Optional[Callable[[Union[List, ndarray], float, Optional[List[float]]], bool]]

k

returns k (number of eigenvalues requested)

Return type

int

operator

Return the operator.

Return type

Optional[OperatorBase]

random

Return a numpy random.

run

run()

Execute the classical algorithm.

Returns

results of an algorithm.

Return type

dict

supports_aux_operators

classmethod supports_aux_operators()

Whether computing the expectation value of auxiliary operators is supported.

Return type

bool

Returns

True if aux_operator expectations can be evaluated, False otherwise

Was this page helpful?
Report a bug or request content on GitHub.