Documentation
¶
Overview ¶
Package operator provides quantum channel representations and conversions.
A quantum channel (completely positive trace-preserving map) can be represented in several equivalent forms:
- Kraus: a set of Kraus operators {E_k} satisfying sum_k E_k-dagger E_k = I.
- SuperOp: a d^2 x d^2 superoperator matrix S = sum_k (E_k (x) conj(E_k)).
- Choi: a d^2 x d^2 Choi matrix (Choi-Jamiolkowski representation).
- PTM: a d^2 x d^2 real Pauli transfer matrix.
The package provides lossless conversions between all representations, validity checks (IsCP, IsTP, IsCPTP), composition (Compose, Tensor), and channel fidelity measures (AverageGateFidelity, ProcessFidelity).
Existing noise.Channel values can be lifted into operator representations via FromChannel.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AverageGateFidelity ¶
AverageGateFidelity computes the average gate fidelity of a channel relative to the identity channel. F_avg = (d * F_pro + 1) / (d + 1)
func IsCP ¶
IsCP checks if a channel (given as Choi matrix) is completely positive. A channel is CP if and only if its Choi matrix is positive semidefinite. All eigenvalues must be >= -tol.
func IsTP ¶
IsTP checks if a channel (given as Kraus operators) is trace-preserving. A channel is TP if sum_k E_k-dagger * E_k = I.
func ProcessFidelity ¶
ProcessFidelity computes the entanglement fidelity (process fidelity) of a channel relative to the identity channel. F_pro = Tr(Choi_identity-dagger * Choi_actual) / d^2 For the identity channel, Choi_identity[ik,jl] = delta_ij * delta_kl / d, which means F_pro = sum_{i,j} Choi_actual[ii, jj] / d^2 = (1/d^2) * sum of the "diagonal blocks" diagonal entries. Equivalently, F_pro = (1/d) * sum_k |Tr(E_k)|^2 / d.
Types ¶
type Choi ¶
type Choi struct {
// contains filtered or unexported fields
}
Choi represents a quantum channel via its Choi matrix (Choi-Jamiolkowski). Lambda = sum_k vec(E_k) * vec(E_k)-dagger. The matrix is dim^2 x dim^2 flat row-major.
func KrausToChoi ¶
KrausToChoi converts a Kraus representation to a Choi matrix. Lambda = sum_k vec(E_k) * vec(E_k)-dagger where vec(E) stacks columns: vec[j*dim+i] = E[i,j].
func NewChoi ¶
func NewChoi(nq int, matrix []complex128) *Choi
NewChoi creates a Choi from a dim^2 x dim^2 flat row-major matrix.
func PTMToChoi ¶
PTMToChoi converts a PTM to a Choi matrix. Lambda = (1/d) * sum_ij R_ij * (sigma_j^T (x) sigma_i) Note: we use the relation that the Choi matrix can be reconstructed from the PTM via the Pauli basis.
func SuperOpToChoi ¶
SuperOpToChoi converts a superoperator to a Choi matrix. The superoperator has S[a*dim+b, c*dim+d] = E[a,c] * conj(E[b,d]). The Choi matrix has Lambda[c*dim+a, d*dim+b] = E[a,c] * conj(E[b,d]). Reshuffling: S[a*dim+b, c*dim+d] -> Lambda[c*dim+a, d*dim+b].
func (*Choi) Matrix ¶
func (c *Choi) Matrix() []complex128
Matrix returns a defensive copy of the Choi matrix.
type Kraus ¶
type Kraus struct {
// contains filtered or unexported fields
}
Kraus represents a quantum channel via Kraus operators. Each operator is a dim x dim flat row-major complex matrix where dim = 2^nq.
func ChoiToKraus ¶
ChoiToKraus converts a Choi matrix to Kraus operators. Eigendecomposes the Choi matrix, then reshapes eigenvectors corresponding to positive eigenvalues into Kraus operators.
func Compose ¶
Compose returns the sequential composition of two channels: first a, then b. The resulting Kraus operators are {B_j * A_i} for all pairs (i, j). Both channels must act on the same number of qubits.
func FromChannel ¶
FromChannel bridges an existing noise.Channel to a Kraus representation.
func NewKraus ¶
func NewKraus(nq int, operators [][]complex128) *Kraus
NewKraus creates a Kraus representation from the given operators. Each operator must be a dim x dim flat row-major matrix where dim = 2^nq.
func PTMToKraus ¶
PTMToKraus converts a PTM to Kraus operators via Choi decomposition. First converts PTM -> Choi, then Choi -> Kraus.
func Tensor ¶
Tensor returns the tensor product of two channels acting on disjoint qubits. If a acts on nA qubits and b acts on nB qubits, the result acts on nA+nB qubits. The resulting Kraus operators are {A_i (x) B_j} for all pairs (i, j).
func (*Kraus) Operators ¶
func (k *Kraus) Operators() [][]complex128
Operators returns a defensive copy of the Kraus operators.
type PTM ¶
type PTM struct {
// contains filtered or unexported fields
}
PTM represents a quantum channel as a Pauli transfer matrix. R_ij = Tr(sigma_i * E(sigma_j)) / d. The matrix is dim^2 x dim^2 flat row-major real.
func KrausToPTM ¶
KrausToPTM converts a Kraus representation to a Pauli transfer matrix. R_ij = Tr(sigma_i * E(sigma_j)) / d where E(sigma_j) = sum_k E_k * sigma_j * E_k-dagger.
func SuperOpToPTM ¶
SuperOpToPTM converts a superoperator to a PTM.
type SuperOp ¶
type SuperOp struct {
// contains filtered or unexported fields
}
SuperOp represents a quantum channel as a superoperator matrix. S = sum_k (E_k (x) conj(E_k)), acts on vec(rho). The matrix is dim^2 x dim^2 flat row-major.
func ChoiToSuperOp ¶
ChoiToSuperOp converts a Choi matrix to a superoperator. Inverse reshuffling: Lambda[c*dim+a, d*dim+b] -> S[a*dim+b, c*dim+d].
func KrausToSuperOp ¶
KrausToSuperOp converts a Kraus representation to a superoperator. S = sum_k (E_k (x) conj(E_k)).
func NewSuperOp ¶
func NewSuperOp(nq int, matrix []complex128) *SuperOp
NewSuperOp creates a SuperOp from a dim^2 x dim^2 flat row-major matrix.
func (*SuperOp) Matrix ¶
func (s *SuperOp) Matrix() []complex128
Matrix returns a defensive copy of the superoperator matrix.