qiskit-documentation/docs/api/qiskit/0.26/qiskit.providers.aer.utils....

381 lines
23 KiB
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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: NoiseTransformer (v0.26)
description: API reference for qiskit.providers.aer.utils.NoiseTransformer in qiskit v0.26
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit.providers.aer.utils.NoiseTransformer
---
<span id="qiskit-providers-aer-utils-noisetransformer" />
# qiskit.providers.aer.utils.NoiseTransformer
<Class id="qiskit.providers.aer.utils.NoiseTransformer" isDedicatedPage={true} github="https://github.com/qiskit/qiskit-aer/tree/stable/0.8/qiskit/providers/aer/utils/noise_transformation.py" signature="NoiseTransformer" modifiers="class">
Transforms one quantum channel to another based on a specified criteria.
### \_\_init\_\_
<Function id="qiskit.providers.aer.utils.NoiseTransformer.__init__" signature="__init__()">
Initialize self. See help(type(self)) for accurate signature.
</Function>
## Methods
| | |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`__init__`](#qiskit.providers.aer.utils.NoiseTransformer.__init__ "qiskit.providers.aer.utils.NoiseTransformer.__init__")() | Initialize self. |
| [`channel_matrix_representation`](#qiskit.providers.aer.utils.NoiseTransformer.channel_matrix_representation "qiskit.providers.aer.utils.NoiseTransformer.channel_matrix_representation")(operators) | We convert the operators to a matrix by applying the channel to the four basis elements of the 2x2 matrix space representing density operators; this is standard linear algebra |
| [`compute_P`](#qiskit.providers.aer.utils.NoiseTransformer.compute_P "qiskit.providers.aer.utils.NoiseTransformer.compute_P")(As) | This method creates the matrix P in the f(x) = 1/2(x\*P\*x)+q\*x representation of the objective function :param As: list of symbolic matrices repersenting the channel matrices :type As: list |
| [`compute_channel_operation`](#qiskit.providers.aer.utils.NoiseTransformer.compute_channel_operation "qiskit.providers.aer.utils.NoiseTransformer.compute_channel_operation")(rho, operators) | Given a quantum states density function rho, the effect of the channel on this state is: rho -> sum\_\{i=1}^n E\_i \* rho \* E\_i^dagger |
| [`compute_q`](#qiskit.providers.aer.utils.NoiseTransformer.compute_q "qiskit.providers.aer.utils.NoiseTransformer.compute_q")(As, C) | This method creates the vector q for the f(x) = 1/2(x\*P\*x)+q\*x representation of the objective function :param As: list of symbolic matrices repersenting the quadratic program :type As: list :param C: matrix representing the the constant channel matrix :type C: matrix |
| [`fidelity`](#qiskit.providers.aer.utils.NoiseTransformer.fidelity "qiskit.providers.aer.utils.NoiseTransformer.fidelity")(channel) | Calculates channel fidelity |
| [`flatten_matrix`](#qiskit.providers.aer.utils.NoiseTransformer.flatten_matrix "qiskit.providers.aer.utils.NoiseTransformer.flatten_matrix")(m) | **param m**The matrix to flatten |
| [`generate_channel_matrices`](#qiskit.providers.aer.utils.NoiseTransformer.generate_channel_matrices "qiskit.providers.aer.utils.NoiseTransformer.generate_channel_matrices")(…) | Generate symbolic channel matrices. |
| [`generate_channel_quadratic_programming_matrices`](#qiskit.providers.aer.utils.NoiseTransformer.generate_channel_quadratic_programming_matrices "qiskit.providers.aer.utils.NoiseTransformer.generate_channel_quadratic_programming_matrices")(…) | Generate matrices for quadratic program. |
| [`get_const_matrix_from_channel`](#qiskit.providers.aer.utils.NoiseTransformer.get_const_matrix_from_channel "qiskit.providers.aer.utils.NoiseTransformer.get_const_matrix_from_channel")(channel, symbols) | Extract the numeric constant matrix. |
| [`get_matrix_from_channel`](#qiskit.providers.aer.utils.NoiseTransformer.get_matrix_from_channel "qiskit.providers.aer.utils.NoiseTransformer.get_matrix_from_channel")(channel, symbol) | Extract the numeric parameter matrix. |
| [`operator_circuit`](#qiskit.providers.aer.utils.NoiseTransformer.operator_circuit "qiskit.providers.aer.utils.NoiseTransformer.operator_circuit")(operator) | Converts an operator representation to noise circuit. |
| [`operator_matrix`](#qiskit.providers.aer.utils.NoiseTransformer.operator_matrix "qiskit.providers.aer.utils.NoiseTransformer.operator_matrix")(operator) | Converts an operator representation to Kraus matrix representation |
| [`prepare_channel_operator_list`](#qiskit.providers.aer.utils.NoiseTransformer.prepare_channel_operator_list "qiskit.providers.aer.utils.NoiseTransformer.prepare_channel_operator_list")(ops\_list) | Prepares a list of channel operators. |
| [`prepare_honesty_constraint`](#qiskit.providers.aer.utils.NoiseTransformer.prepare_honesty_constraint "qiskit.providers.aer.utils.NoiseTransformer.prepare_honesty_constraint")(…) | Prepares the honesty constraint. |
| [`solve_quadratic_program`](#qiskit.providers.aer.utils.NoiseTransformer.solve_quadratic_program "qiskit.providers.aer.utils.NoiseTransformer.solve_quadratic_program")(P, q) | Solve the quadratic program optimization problem. |
| [`transform_by_given_channel`](#qiskit.providers.aer.utils.NoiseTransformer.transform_by_given_channel "qiskit.providers.aer.utils.NoiseTransformer.transform_by_given_channel")(channel\_matrices, …) | Transform by by quantum channels. |
| [`transform_by_operator_list`](#qiskit.providers.aer.utils.NoiseTransformer.transform_by_operator_list "qiskit.providers.aer.utils.NoiseTransformer.transform_by_operator_list")(…) | Transform input Kraus operators. |
### channel\_matrix\_representation
<Function id="qiskit.providers.aer.utils.NoiseTransformer.channel_matrix_representation" signature="channel_matrix_representation(operators)">
We convert the operators to a matrix by applying the channel to the four basis elements of the 2x2 matrix space representing density operators; this is standard linear algebra
**Parameters**
**operators** (*list*) The list of operators to transform into a Matrix
**Returns**
The matrx representation of the operators
**Return type**
sympy.Matrix
</Function>
### compute\_P
<Function id="qiskit.providers.aer.utils.NoiseTransformer.compute_P" signature="compute_P(As)">
This method creates the matrix P in the f(x) = 1/2(x\*P\*x)+q\*x representation of the objective function :param As: list of symbolic matrices repersenting the channel matrices :type As: list
**Returns**
The matrix P for the description of the quadaric program
**Return type**
matrix
</Function>
### compute\_channel\_operation
<Function id="qiskit.providers.aer.utils.NoiseTransformer.compute_channel_operation" signature="compute_channel_operation(rho, operators)" modifiers="static">
Given a quantum states density function rho, the effect of the channel on this state is: rho -> sum\_\{i=1}^n E\_i \* rho \* E\_i^dagger
**Parameters**
* **rho** (*number*) Density function
* **operators** (*list*) List of operators
**Returns**
The result of applying the list of operators
**Return type**
number
</Function>
### compute\_q
<Function id="qiskit.providers.aer.utils.NoiseTransformer.compute_q" signature="compute_q(As, C)">
This method creates the vector q for the f(x) = 1/2(x\*P\*x)+q\*x representation of the objective function :param As: list of symbolic matrices repersenting the quadratic program :type As: list :param C: matrix representing the the constant channel matrix :type C: matrix
**Returns**
The vector q for the description of the quadaric program
**Return type**
list
</Function>
### fidelity
<Function id="qiskit.providers.aer.utils.NoiseTransformer.fidelity" signature="fidelity(channel)" modifiers="static">
Calculates channel fidelity
</Function>
### flatten\_matrix
<Function id="qiskit.providers.aer.utils.NoiseTransformer.flatten_matrix" signature="flatten_matrix(m)" modifiers="static">
**Parameters**
**m** (*Matrix*) The matrix to flatten
**Returns**
A row vector repesenting the flattened matrix
**Return type**
list
</Function>
### generate\_channel\_matrices
<Function id="qiskit.providers.aer.utils.NoiseTransformer.generate_channel_matrices" signature="generate_channel_matrices(transform_channel_operators_list)">
Generate symbolic channel matrices.
Generates a list of 4x4 symbolic matrices describing the channel defined from the given operators. The identity matrix is assumed to be the first element in the list:
```python
[(I, ), (A1, B1, ...), (A2, B2, ...), ..., (An, Bn, ...)]
```
E.g. for a Pauli channel, the matrices are:
```python
[(I,), (X,), (Y,), (Z,)]
```
For relaxation they are:
```python
[(I, ), (|0><0|, |0><1|), |1><0|, |1><1|)]
```
We consider this input to symbolically represent a channel in the following manner: define indeterminates $x_0, x_1, ..., x_n$ which are meant to represent probabilities such that $x_i \ge 0$ and $x0 = 1-(x_1 + ... + x_n)$.
Now consider the quantum channel defined via the Kraus operators ${\sqrt(x_0)I, \sqrt(x_1) A_1, \sqrt(x1) B_1, ..., \sqrt(x_m)A_n, \sqrt(x_n) B_n, ...}$ This is the channel C symbolically represented by the operators.
**Parameters**
**transform\_channel\_operators\_list** (*list*) A list of tuples of matrices which represent Kraus operators.
**Returns**
A list of 4x4 complex matrices `([D1, D2, ..., Dn], E)` such that the matrix $x_1 D_1 + ... + x_n D_n + E$ represents the operation of the channel C on the density operator. we find it easier to work with this representation of C when performing the combinatorial optimization.
**Return type**
list
</Function>
### generate\_channel\_quadratic\_programming\_matrices
<Function id="qiskit.providers.aer.utils.NoiseTransformer.generate_channel_quadratic_programming_matrices" signature="generate_channel_quadratic_programming_matrices(channel, symbols)">
Generate matrices for quadratic program.
**Parameters**
* **channel** (*Matrix*) a 4x4 symbolic matrix
* **symbols** (*list*) the symbols x1, …, xn which may occur in the matrix
**Returns**
A list of 4x4 complex matrices (\[D1, D2, …, Dn], E) such that: channel == x1\*D1 + … + xn\*Dn + E
**Return type**
list
</Function>
### get\_const\_matrix\_from\_channel
<Function id="qiskit.providers.aer.utils.NoiseTransformer.get_const_matrix_from_channel" signature="get_const_matrix_from_channel(channel, symbols)" modifiers="static">
Extract the numeric constant matrix.
**Parameters**
* **channel** (*matrix*) a 4x4 symbolic matrix.
* **symbols** (*list*) The full list \[x1, …, xn] of symbols used in the matrix.
**Returns**
a 4x4 numeric matrix.
**Return type**
matrix
**Additional Information:**
Each entry of the 4x4 symbolic input channel matrix is assumed to be a polynomial of the form a1x1 + … + anxn + c. The corresponding entry in the output numeric matrix is c.
</Function>
### get\_matrix\_from\_channel
<Function id="qiskit.providers.aer.utils.NoiseTransformer.get_matrix_from_channel" signature="get_matrix_from_channel(channel, symbol)" modifiers="static">
Extract the numeric parameter matrix.
**Parameters**
* **channel** (*matrix*) a 4x4 symbolic matrix.
* **symbol** (*list*) a symbol xi
**Returns**
a 4x4 numeric matrix.
**Return type**
matrix
**Additional Information:**
Each entry of the 4x4 symbolic input channel matrix is assumed to be a polynomial of the form a1x1 + … + anxn + c. The corresponding entry in the output numeric matrix is ai.
</Function>
### operator\_circuit
<Function id="qiskit.providers.aer.utils.NoiseTransformer.operator_circuit" signature="operator_circuit(operator)">
Converts an operator representation to noise circuit.
**Parameters**
**operator** (*operator*) operator representation. Can be a noise circuit or a matrix or a list of matrices.
**Returns**
The operator, converted to noise circuit representation.
**Return type**
List
</Function>
### operator\_matrix
<Function id="qiskit.providers.aer.utils.NoiseTransformer.operator_matrix" signature="operator_matrix(operator)">
Converts an operator representation to Kraus matrix representation
**Parameters**
**operator** (*operator*) operator representation. Can be a noise circuit or a matrix or a list of matrices.
**Returns**
the operator, converted to Kraus representation.
**Return type**
[Kraus](qiskit.quantum_info.Kraus "qiskit.quantum_info.Kraus")
</Function>
### prepare\_channel\_operator\_list
<Function id="qiskit.providers.aer.utils.NoiseTransformer.prepare_channel_operator_list" signature="prepare_channel_operator_list(ops_list)" modifiers="static">
Prepares a list of channel operators.
**Parameters**
**ops\_list** (*List*) The list of operators to prepare
**Returns**
The channel operator list
**Return type**
List
</Function>
### prepare\_honesty\_constraint
<Function id="qiskit.providers.aer.utils.NoiseTransformer.prepare_honesty_constraint" signature="prepare_honesty_constraint(transform_channel_operators_list)">
Prepares the honesty constraint.
**Parameters**
* **transform\_channel\_operators\_list** (*list*) A list of tuples of matrices which represent
* **operators.** ([*Kraus*](qiskit.quantum_info.Kraus "qiskit.quantum_info.Kraus"))
</Function>
### solve\_quadratic\_program
<Function id="qiskit.providers.aer.utils.NoiseTransformer.solve_quadratic_program" signature="solve_quadratic_program(P, q)">
Solve the quadratic program optimization problem.
This function solved the quadratic program to minimize the objective function f(x) = 1/2(x\*P\*x)+q\*x subject to the additional constraints Gx \<= h
Where P, q are given and G,h are computed to ensure that x represents a probability vector and subject to honesty constraints if required :param P: A matrix representing the P component of the objective function :type P: matrix :param q: A vector representing the q component of the objective function :type q: list
**Returns**
The solution of the quadratic program (represents probabilities)
**Return type**
list
**Additional information:**
This method is the only place in the code where we rely on the cvxpy library should we consider another library, only this method needs to change.
</Function>
### transform\_by\_given\_channel
<Function id="qiskit.providers.aer.utils.NoiseTransformer.transform_by_given_channel" signature="transform_by_given_channel(channel_matrices, const_channel_matrix)">
Transform by by quantum channels.
This method creates objective function representing the Hilbert-Schmidt norm of the matrix (A-B) obtained as the difference of the input noise channel and the output channel we wish to determine.
This function is represented by a matrix P and a vector q, such that f(x) = 1/2(x\*P\*x)+q\*x where x is the vector we wish to minimize, where x represents probabilities for the noise operators that construct the output channel
**Parameters**
* **channel\_matrices** (*list*) A list of 4x4 symbolic matrices
* **const\_channel\_matrix** (*matrix*) a 4x4 constant matrix
**Returns**
a list of the optimal probabilities for the channel matrices, determined by the quadratic program solver
**Return type**
list
</Function>
### transform\_by\_operator\_list
<Function id="qiskit.providers.aer.utils.NoiseTransformer.transform_by_operator_list" signature="transform_by_operator_list(transform_channel_operators, noise_kraus_operators)">
Transform input Kraus operators.
Allows approximating a set of input Kraus operators as in terms of a different set of Kraus matrices.
For example, setting $[X, Y, Z]$ allows approximating by a Pauli channel, and $[(|0 \langle\rangle 0|, |0\langle\rangle 1|), |1\langle\rangle 0|, |1 \langle\rangle 1|)]$ represents the relaxation channel
In the case the input is a list $[A_1, A_2, ..., A_n]$ of transform matrices and $[E_0, E_1, ..., E_m]$ of noise Kraus operators, the output is a list $[p_1, p_2, ..., p_n]$ of probabilities such that:
1. $p_i \ge 0$
2. $p_1 + ... + p_n \le 1$
3. $[\sqrt(p_1) A_1, \sqrt(p_2) A_2, ..., \sqrt(p_n) A_n, \sqrt(1-(p_1 + ... + p_n))I]$ is a list of Kraus operators that define the output channel (which is “close” to the input channel given by $[E_0, ..., E_m]$.)
This channel can be thought of as choosing the operator $A_i$ in probability $p_i$ and applying this operator to the quantum state.
More generally, if the input is a list of tuples (not necessarily of the same size): $[(A_1, B_1, ...), (A_2, B_2, ...), ..., (A_n, B_n, ...)]$ then the output is still a list $[p_1, p_2, ..., p_n]$ and now the output channel is defined by the operators: $[\sqrt(p_1)A1, \sqrt(p_1)B_1, ..., \sqrt(p_n)A_n, \sqrt(p_n)B_n, ..., \sqrt(1-(p_1 + ... + p_n))I]$
**Parameters**
* **noise\_kraus\_operators** (*List*) a list of matrices (Kraus operators) for the input channel.
* **transform\_channel\_operators** (*List*) a list of matrices or tuples of matrices representing Kraus operators that can construct the output channel.
**Returns**
A list of amplitudes that define the output channel.
**Return type**
List
</Function>
</Class>