github.com/itsubaki/q/quantum/density.
What are Kraus operators?
What are Kraus operators?
A quantum channel The matrices This constraint guarantees that the channel is trace-preserving (probabilities stay normalised) and completely positive (the output is always a valid density matrix, even when the system is entangled with an environment). Each built-in channel in this package has its Kraus operators pre-computed. You can also supply your own via
ε acting on density matrix ρ is written as:{Kᵢ} are called Kraus operators. They must satisfy the completeness relation:NewChannel or ApplyKraus.The
qb int parameter specifies which qubit index (0-based) the channel acts on within an n-qubit system.Channel type
Channel
Channel holds the Kraus operators for a single quantum channel. When applied to a density matrix, each operator Kᵢ is embedded into the full 2ⁿ × 2ⁿ space via a tensor product before use.
NewChannel
Channel from the provided Kraus operators. Use this to assemble a custom channel from hand-crafted matrices.
ChannelFunc
ChannelFunc is a factory that receives the total qubit count n of the target density matrix and returns a *Channel with Kraus operators expanded to the full 2ⁿ × 2ⁿ space. All built-in channel constructors return a ChannelFunc. Pass one or more to DensityMatrix.ApplyChannelFunc.
Built-in channels
BitFlip
qb with probability p. With probability 1-p the qubit is left unchanged; with probability p the Pauli X gate is applied, swapping |0⟩ ↔ |1⟩.
Kraus operators:
Bit-flip probability. Must satisfy
0 ≤ p ≤ 1.Target qubit index (0-based).
PhaseFlip
qb with probability p. The phase of the |1⟩ component is flipped, leaving |0⟩ unchanged.
Kraus operators:
Phase-flip probability. Must satisfy
0 ≤ p ≤ 1.Target qubit index (0-based).
BitPhaseFlip
qb with probability p. A Y gate combines a bit-flip and a phase-flip simultaneously.
Kraus operators:
Bit-phase-flip probability. Must satisfy
0 ≤ p ≤ 1.Target qubit index (0-based).
Depolarizing
1-p the qubit is undisturbed; with probability p one of X, Y, or Z is applied with equal likelihood p/3 each. This is equivalent to Pauli(p/3, p/3, p/3, qb).
Kraus operators:
Total depolarizing probability. Must satisfy
0 ≤ p ≤ 1.Target qubit index (0-based).
AmplitudeDamping
|1⟩ decays to the ground state |0⟩ with probability gamma. This is the quantum analogue of spontaneous emission.
Kraus operators:
Decay probability (damping parameter). Must satisfy
0 ≤ gamma ≤ 1. At gamma = 0 the channel is the identity; at gamma = 1 the qubit always relaxes to |0⟩.Target qubit index (0-based).
PhaseDamping
Dephasing probability. Must satisfy
0 ≤ gamma ≤ 1. At gamma = 1 all coherences vanish and the qubit becomes a classical mixture.Target qubit index (0-based).
AmplitudeDamping and PhaseDamping share the same K₀ operator but differ in K₁. Amplitude damping has an off-diagonal K₁ that transfers population; phase damping has a diagonal K₁ that only affects coherences.Pauli
px, py, pz. The identity is applied with probability 1 - px - py - pz. Depolarizing is a special case with px = py = pz = p/3.
Kraus operators:
Probability of an X error.
Probability of a Y error.
Probability of a Z error. The sum
px + py + pz must satisfy 0 ≤ px + py + pz ≤ 1.Target qubit index (0-based).
Flip
1-p the qubit is unchanged; with probability p the arbitrary unitary u is applied. BitFlip, PhaseFlip, and BitPhaseFlip are all built on top of Flip.
Kraus operators:
Flip probability. Must satisfy
0 ≤ p ≤ 1.The unitary applied on a flip event. Must be a 2×2 unitary matrix.
Target qubit index (0-based).
Applying channels
There are two ways to apply channels to aDensityMatrix.
Via convenience methods (single channel)
Each built-in channel has a matching method on*DensityMatrix that applies it directly and returns a new *DensityMatrix:
Via ApplyChannelFunc (chainable, multiple channels)
Pass multiple ChannelFunc values to apply them sequentially in a single call:
ApplyChannel (which takes *Channel values directly) and ApplyKraus (which takes raw *matrix.Matrix operators):