mimiqcircuits.operations.operators.lossyoperator¶
Classes
|
Kraus operator of a loss branch: a matrix plus the qubits it loses. |
- class LossyOperator(mat, lossy=None)[source]¶
Bases:
AbstractOperatorKraus operator of a loss branch: a matrix plus the qubits it loses.
Only one- and two-qubit lossy operators are supported.
A
LossyOperatorrepresents a tagged custom operator used as a loss branch inside aKrauschannel. The matrix is expressed in the computational basis, exactly likeOperator, whilelossymarks which of the operator’s local qubits leak when this branch is selected.The
lossyindices are local to the operator and numbered from 1 toN(not from 0). They are not circuit-global qubit indices. When a surroundingKrauschannel is applied to circuit targets(q_1, ..., q_N), each local indexiinlossymaps to the corresponding physical targetq_i.A
Krauschannel that contains one or moreLossyOperatorbranches is a loss-aware channel. The helpersKraus.hasloss(),Kraus.lossoperators(),Kraus.survivaloperators(), andKraus.losseffect()inspect those branches.See also
AbstractOperator,Operator,Kraus- Parameters:
mat (symengine.Matrix | sympy.Matrix | numpy.ndarray) – The \(2^N \times 2^N\) matrix of the operator.
lossy (int | tuple | list) – One or more local qubit indices, from 1 to
N, that leak when this branch is selected. Stored sorted in thelossyattribute. For one-qubit operators the default is(1,); for two-qubit operators it must be given.
- Raises:
TypeError – If
matis not a SymEngine, SymPy or NumPy matrix, orlossyis not an int, tuple or list.ValueError – If
matis not square, its size is not 2 or 4,lossyis missing for a two-qubit operator, or an index is out of range or repeated.
Examples
>>> from mimiqcircuits import * >>> from symengine import Matrix, sqrt >>> op = LossyOperator(Matrix([[0, 1], [0, 0]])) >>> op 1-qubit LossyOperator (lossy=(1,)): ├── 0 1 └── 0 0
>>> # amplitude damping where the decay branch also loses the qubit >>> c = Circuit() >>> c.push(Kraus([Matrix([[1, 0], [0, sqrt(0.9)]]), ... LossyOperator(Matrix([[0, sqrt(0.1)], [0, 0]]))]), 1) 2-qubit circuit with 1 instruction: └── Kraus(Operator([[1, 0], [0, 0.948683298050514]]), LossyOperator([[0, 0.316227766016838], [0, 0]]; lossy=(1,))) @ q[1]
- property parnames¶
Names of the operation’s parameters, as a tuple of strings.
Read-only: assigning to it raises
ValueError.
- lossyqubits()[source]¶
Return the local indices of the lost qubits, numbered from 1.
- Returns:
The sorted
lossyindices.- Return type:
- lossytargets(*targets)[source]¶
Return the circuit qubits lost by this branch for the given targets.
- Parameters:
*targets – The
Ncircuit qubits the operator is applied to, as separate arguments or as one tuple.- Returns:
The entries of
targetsselected by thelossyindices.- Return type:
- Raises:
ValueError – If the number of targets is not
N.
Examples
>>> from mimiqcircuits import * >>> from symengine import Matrix >>> # a two-qubit branch that loses its second qubit >>> op = LossyOperator(Matrix([[0, 0, 0, 0], [1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]), 2) >>> op.lossytargets(5, 7) (7,)
- unwrappedmatrix()[source]¶
Return the numeric matrix of the operator as a NumPy array.
Use this instead of
matrix()when plain numbers are needed, for example to feed a simulator. Gates with a fast numeric path (seemimiqcircuits.numerics) skip SymEngine entirely; other operators build the SymEngine matrix and convert it.Operators fully determined by their type return a cached, read-only array. Copy it before modifying it.
- Returns:
The matrix, with dtype
complex128.- Return type:
- Raises:
UnexpectedSymbolics – If any parameter is still symbolic.
Examples
>>> from mimiqcircuits import * >>> GateX().unwrappedmatrix() array([[0.+0.j, 1.+0.j], [1.+0.j, 0.+0.j]])