qiskit-documentation/docs/api/qiskit/0.29/qiskit.providers.aer.librar...

40 lines
2.1 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: save_expectation_value
description: API reference for qiskit.providers.aer.library.save_expectation_value
in_page_toc_min_heading_level: 1
python_api_type: function
python_api_name: qiskit.providers.aer.library.save_expectation_value
---
# qiskit.providers.aer.library.save\_expectation\_value
<Function id="qiskit.providers.aer.library.save_expectation_value" isDedicatedPage={true} github="https://github.com/qiskit/qiskit-aer/tree/stable/0.8/qiskit/providers/aer/library/save_instructions/save_expectation_value.py" signature="save_expectation_value(self, operator, qubits, label='expectation_value', unnormalized=False, pershot=False, conditional=False)">
Save the expectation value of a Hermitian operator.
**Parameters**
* **operator** ([*Pauli*](qiskit.quantum_info.Pauli "qiskit.quantum_info.Pauli") *or*[*SparsePauliOp*](qiskit.quantum_info.SparsePauliOp "qiskit.quantum_info.SparsePauliOp") *or*[*Operator*](qiskit.quantum_info.Operator "qiskit.quantum_info.Operator")) a Hermitian operator.
* **qubits** (*list*) circuit qubits to apply instruction.
* **label** (*str*) the key for retrieving saved data from results.
* **unnormalized** (*bool*) If True return save the unnormalized accumulated or conditional accumulated expectation value over all shot \[Default: False].
* **pershot** (*bool*) if True save a list of expectation values for each shot of the simulation rather than the average over all shots \[Default: False].
* **conditional** (*bool*) if True save the average or pershot data conditional on the current classical register values \[Default: False].
**Returns**
with attached instruction.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
**Raises**
**ExtensionError** if the input operator is invalid or not Hermitian.
<Admonition title="Note" type="note">
This method appends a [`SaveExpectationValue`](qiskit.providers.aer.library.SaveExpectationValue "qiskit.providers.aer.library.SaveExpectationValue") instruction to the quantum circuit.
</Admonition>
</Function>