# qiskit.opflow.expectations.MatrixExpectation¶

class MatrixExpectation[código fonte]

An Expectation converter which converts Operator measurements to be matrix-based so they can be evaluated by matrix multiplication.

__init__()

Initialize self. See help(type(self)) for accurate signature.

Methods

 Initialize self. compute_variance(exp_op) Compute the variance of the expectation estimator. convert(operator) Accept an Operator and return a new Operator with the Pauli measurements replaced by Matrix based measurements.
compute_variance(exp_op)[código fonte]

Compute the variance of the expectation estimator. Because this expectation works by matrix multiplication, the estimation is exact and the variance is always 0, but we need to return those values in a way which matches the Operator’s structure.

Parâmetros

exp_op (OperatorBase) – The full expectation value Operator.

Tipo de retorno

Union[list, float]

Retorna

The variances or lists thereof (if exp_op contains ListOps) of the expectation value estimation, equal to 0.

convert(operator)[código fonte]

Accept an Operator and return a new Operator with the Pauli measurements replaced by Matrix based measurements.

Parâmetros

operator (OperatorBase) – The operator to convert.

Tipo de retorno

OperatorBase

Retorna

The converted operator.