qiskit-documentation/docs/api/qiskit/0.26/qiskit.aqua.operators.conve...

44 lines
5.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: converters (v0.26)
description: API reference for qiskit.aqua.operators.converters in qiskit v0.26
in_page_toc_min_heading_level: 2
python_api_type: module
python_api_name: qiskit.aqua.operators.converters
---
<span id="module-qiskit.aqua.operators.converters" />
<span id="qiskit-aqua-operators-converters" />
<span id="converters-qiskit-aqua-operators-converters" />
# Converters
`qiskit.aqua.operators.converters`
Converters are objects which manipulate Operators, usually traversing an Operator to change certain sub-Operators into a desired representation. Often the converted Operator is isomorphic or approximate to the original Operator in some way, but not always. For example, a converter may accept [`CircuitOp`](qiskit.aqua.operators.primitive_ops.CircuitOp "qiskit.aqua.operators.primitive_ops.CircuitOp") and return a [`SummedOp`](qiskit.aqua.operators.list_ops.SummedOp "qiskit.aqua.operators.list_ops.SummedOp") of [`PauliOp`](qiskit.aqua.operators.primitive_ops.PauliOp "qiskit.aqua.operators.primitive_ops.PauliOp")s representing the circuit unitary. Converters may not have polynomial space or time scaling in their operations. On the contrary, many converters, such as a [`MatrixExpectation`](qiskit.aqua.operators.expectations.MatrixExpectation "qiskit.aqua.operators.expectations.MatrixExpectation") or [`MatrixEvolution`](qiskit.aqua.operators.evolutions.MatrixEvolution "qiskit.aqua.operators.evolutions.MatrixEvolution"), which convert [`PauliOp`](qiskit.aqua.operators.primitive_ops.PauliOp "qiskit.aqua.operators.primitive_ops.PauliOp")s to [`MatrixOp`](qiskit.aqua.operators.primitive_ops.MatrixOp "qiskit.aqua.operators.primitive_ops.MatrixOp")s internally, will require time or space exponential in the number of qubits unless a clever trick is known (such as the use of sparse matrices).
<Admonition title="Note" type="note">
Not all converters are in this module, as [`expectations`](qiskit.aqua.operators.expectations#module-qiskit.aqua.operators.expectations "qiskit.aqua.operators.expectations") and [`evolutions`](qiskit.aqua.operators.evolutions#module-qiskit.aqua.operators.evolutions "qiskit.aqua.operators.evolutions") are also converters.
</Admonition>
# Converter Base Class
The converter base class simply enforces the presence of a [`convert()`](qiskit.aqua.operators.converters.ConverterBase#convert "qiskit.aqua.operators.converters.ConverterBase.convert") method.
| | |
| ------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------- |
| [`ConverterBase`](qiskit.aqua.operators.converters.ConverterBase "qiskit.aqua.operators.converters.ConverterBase") | Converters take an Operator and return a new Operator, generally isomorphic in some way with the first, but with certain desired properties. |
# Converters
In addition to the base class, directory holds a few miscellaneous converters which are used frequently around the Operator flow.
| | |
| --------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [`CircuitSampler`](qiskit.aqua.operators.converters.CircuitSampler "qiskit.aqua.operators.converters.CircuitSampler") | The CircuitSampler traverses an Operator and converts any CircuitStateFns into approximations of the state function by a DictStateFn or VectorStateFn using a quantum backend. |
| [`AbelianGrouper`](qiskit.aqua.operators.converters.AbelianGrouper "qiskit.aqua.operators.converters.AbelianGrouper") | The AbelianGrouper converts SummedOps into a sum of Abelian sums. |
| [`DictToCircuitSum`](qiskit.aqua.operators.converters.DictToCircuitSum "qiskit.aqua.operators.converters.DictToCircuitSum") | Converts `DictStateFns` or `VectorStateFns` to equivalent `CircuitStateFns` or sums thereof. |
| [`PauliBasisChange`](qiskit.aqua.operators.converters.PauliBasisChange "qiskit.aqua.operators.converters.PauliBasisChange") | Converter for changing Paulis into other bases. |