55 lines
1.8 KiB
Plaintext
55 lines
1.8 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.20/qiskit/opflow/expectations/matrix_expectation.py" signature="MatrixExpectation" modifiers="class">
|
||
Bases: `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.
|
||
|
||
## Methods Defined Here
|
||
|
||
### compute\_variance
|
||
|
||
<Function id="qiskit.opflow.expectations.MatrixExpectation.compute_variance" signature="MatrixExpectation.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`) – The full expectation value Operator.
|
||
|
||
**Return type**
|
||
|
||
`Union`\[`list`, `float`]
|
||
|
||
**Returns**
|
||
|
||
The variances or lists thereof (if exp\_op contains ListOps) of the expectation value estimation, equal to 0.
|
||
</Function>
|
||
|
||
### convert
|
||
|
||
<Function id="qiskit.opflow.expectations.MatrixExpectation.convert" signature="MatrixExpectation.convert(operator)">
|
||
Accept an Operator and return a new Operator with the Pauli measurements replaced by Matrix based measurements.
|
||
|
||
**Parameters**
|
||
|
||
**operator** (`OperatorBase`) – The operator to convert.
|
||
|
||
**Return type**
|
||
|
||
`OperatorBase`
|
||
|
||
**Returns**
|
||
|
||
The converted operator.
|
||
</Function>
|
||
</Class>
|
||
|