59 lines
2.6 KiB
Plaintext
59 lines
2.6 KiB
Plaintext
---
|
||
title: MatrixExpectation
|
||
description: API reference for qiskit.opflow.expectations.MatrixExpectation
|
||
in_page_toc_min_heading_level: 1
|
||
python_api_type: class
|
||
python_api_name: qiskit.opflow.expectations.MatrixExpectation
|
||
---
|
||
|
||
# MatrixExpectation
|
||
|
||
<Class id="qiskit.opflow.expectations.MatrixExpectation" isDedicatedPage={true} github="https://github.com/qiskit/qiskit/tree/stable/0.46/qiskit/opflow/expectations/matrix_expectation.py" signature="qiskit.opflow.expectations.MatrixExpectation" modifiers="class">
|
||
Bases: [`ExpectationBase`](qiskit.opflow.expectations.ExpectationBase "qiskit.opflow.expectations.expectation_base.ExpectationBase")
|
||
|
||
An Expectation converter which converts Operator measurements to be matrix-based so they can be evaluated by matrix multiplication.
|
||
|
||
<Admonition title="Deprecated since version 0.24.0" type="danger">
|
||
The class `qiskit.opflow.expectations.matrix_expectation.MatrixExpectation` is deprecated as of qiskit-terra 0.24.0. It will be removed in the Qiskit 1.0 release. For code migration guidelines, visit [https://qisk.it/opflow\_migration](https://qisk.it/opflow_migration).
|
||
</Admonition>
|
||
|
||
## Methods
|
||
|
||
### compute\_variance
|
||
|
||
<Function id="qiskit.opflow.expectations.MatrixExpectation.compute_variance" signature="compute_variance(exp_op)">
|
||
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.
|
||
|
||
**Parameters**
|
||
|
||
**exp\_op** ([*OperatorBase*](qiskit.opflow.OperatorBase "qiskit.opflow.operator_base.OperatorBase")) – The full expectation value Operator.
|
||
|
||
**Returns**
|
||
|
||
The variances or lists thereof (if exp\_op contains ListOps) of the expectation value estimation, equal to 0.
|
||
|
||
**Return type**
|
||
|
||
[list](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.12)") | [float](https://docs.python.org/3/library/functions.html#float "(in Python v3.12)")
|
||
</Function>
|
||
|
||
### convert
|
||
|
||
<Function id="qiskit.opflow.expectations.MatrixExpectation.convert" signature="convert(operator)">
|
||
Accept an Operator and return a new Operator with the Pauli measurements replaced by Matrix based measurements.
|
||
|
||
**Parameters**
|
||
|
||
**operator** ([*OperatorBase*](qiskit.opflow.OperatorBase "qiskit.opflow.operator_base.OperatorBase")) – The operator to convert.
|
||
|
||
**Returns**
|
||
|
||
The converted operator.
|
||
|
||
**Return type**
|
||
|
||
[*OperatorBase*](qiskit.opflow.OperatorBase "qiskit.opflow.operator_base.OperatorBase")
|
||
</Function>
|
||
</Class>
|
||
|