pygsti.tools.jamiolkowski

Utility functions related to the Choi representation of gates.

Module Contents

Functions

jamiolkowski_iso(→ Union[numpy.ndarray, cvxpy.Expression])

Return a Choi matrix (in the choi_mx_basis) for operation_mx, when operation_mx

jamiolkowski_iso_inv(→ Union[numpy.ndarray, ...)

Given a choi matrix (interpreted in choi_mx_basis), return the corresponding

fast_jamiolkowski_iso_std(→ numpy.ndarray)

Returns the standard-basis representation of the Choi matrix for operation_mx,

fast_jamiolkowski_iso_std_inv(→ numpy.ndarray)

Given a choi matrix in the standard basis, return the corresponding

sum_of_negative_choi_eigenvalues_gate(op_mx, op_mx_basis)

Compute the sum of the negative Choi eigenvalues of a process matrix.

sum_of_negative_choi_eigenvalues(model[, weights])

Compute the amount of non-CP-ness of a model.

sums_of_negative_choi_eigenvalues(model)

Compute the amount of non-CP-ness of a model.

magnitudes_of_negative_choi_eigenvalues(model)

Compute the magnitudes of the negative eigenvalues of the Choi matrices for each gate in model.

Attributes

BasisLike

pygsti.tools.jamiolkowski.BasisLike
pygsti.tools.jamiolkowski.jamiolkowski_iso(operation_mx: numpy.ndarray | cvxpy.Expression, op_mx_basis: BasisLike = 'pp', choi_mx_basis: BasisLike = 'pp', normalized: bool = True) numpy.ndarray | cvxpy.Expression

Return a Choi matrix (in the choi_mx_basis) for operation_mx, when operation_mx is interpreted in the op_mx_basis.

Parameters

operation_mxnumpy array or cvxpy Expression

the operation matrix to compute Choi matrix of.

op_mx_basisBasis object

The source and destination basis, respectively. Allowed values are Matrix-unit (std), Gell-Mann (gm), Pauli-product (pp), and Qutrit (qt) (or a custom basis object).

choi_mx_basisBasis object

The source and destination basis, respectively. Allowed values are Matrix-unit (std), Gell-Mann (gm), Pauli-product (pp), and Qutrit (qt) (or a custom basis object).

normalizedbool

If normalized=True, then this function maps trace-preserving operation matrices to trace-1 Choi matrices.

Returns

numpy array or cvxpy Expression

the Choi matrix, in the desired basis.

pygsti.tools.jamiolkowski.jamiolkowski_iso_inv(choi_mx: numpy.ndarray | cvxpy.Expression, choi_mx_basis: BasisLike = 'pp', op_mx_basis: BasisLike = 'pp', normalized: bool = True) numpy.ndarray | cvxpy.Expression

Given a choi matrix (interpreted in choi_mx_basis), return the corresponding operation matrix (in op_mx_basis).

This function performs the inverse of jamiolkowski_iso().

Parameters

choi_mxnumpy array

the Choi matrix, normalized to have trace == 1, to compute operation matrix for.

choi_mx_basisBasis object

The source and destination basis, respectively. Allowed values are Matrix-unit (std), Gell-Mann (gm), Pauli-product (pp), and Qutrit (qt) (or a custom basis object).

op_mx_basisBasis object

The source and destination basis, respectively. Allowed values are Matrix-unit (std), Gell-Mann (gm), Pauli-product (pp), and Qutrit (qt) (or a custom basis object).

normalizedbool

If normalized=True, then we assume choi_mx was computed with the convention that trace-preserving maps have trace-1 choi matrices.

Returns

numpy array

operation matrix in the desired basis.

pygsti.tools.jamiolkowski.fast_jamiolkowski_iso_std(operation_mx: numpy.ndarray, op_mx_basis: BasisLike, normalized: bool = True) numpy.ndarray

Returns the standard-basis representation of the Choi matrix for operation_mx, where operation_mx is interpreted in op_mx_basis.

This routine only computes the case of the Choi matrix being in the standard (matrix unit) basis, but does so more quickly than jamiolkowski_iso() and so is particularly useful when only the eigenvalues of the Choi matrix are needed.

Parameters

operation_mxnumpy array

the operation matrix to compute Choi matrix of.

op_mx_basisBasis object

The source and destination basis, respectively. Allowed values are Matrix-unit (std), Gell-Mann (gm), Pauli-product (pp), and Qutrit (qt) (or a custom basis object).

normalizedbool

If normalized=True, then this function maps trace-preserving operation matrices to trace-1 Choi matrices.

Returns

numpy array

the Choi matrix, normalized to have trace == 1, in the std basis.

pygsti.tools.jamiolkowski.fast_jamiolkowski_iso_std_inv(choi_mx: numpy.ndarray, op_mx_basis: BasisLike, normalized: bool = True) numpy.ndarray

Given a choi matrix in the standard basis, return the corresponding operation matrix (in op_mx_basis).

This function performs the inverse of fast_jamiolkowski_iso_std().

Parameters

choi_mxnumpy array

the Choi matrix in the standard (matrix units) basis, normalized to have trace == 1, to compute operation matrix for.

op_mx_basisBasis object

The source and destination basis, respectively. Allowed values are Matrix-unit (std), Gell-Mann (gm), Pauli-product (pp), and Qutrit (qt) (or a custom basis object).

normalizedbool

If normalized=True, then we assume choi_mx was computed with the convention that trace-preserving maps have trace-1 choi matrices.

Returns

numpy array

operation matrix in the desired basis.

pygsti.tools.jamiolkowski.sum_of_negative_choi_eigenvalues_gate(op_mx, op_mx_basis)

Compute the sum of the negative Choi eigenvalues of a process matrix.

Parameters

op_mx : np.array

op_mx_basis : Basis

Returns

float

the sum of the negative eigenvalues of the Choi representation of op_mx

pygsti.tools.jamiolkowski.sum_of_negative_choi_eigenvalues(model, weights=None)

Compute the amount of non-CP-ness of a model.

This is defined (somewhat arbitrarily) by summing the negative eigenvalues of the Choi matrix for each gate in model.

Parameters

modelModel

The model to act on.

weightsdict

A dictionary of weights used to multiply the negative eigenvalues of different gates. Keys are operation labels, values are floating point numbers.

Returns

float

the sum of negative eigenvalues of the Choi matrix for each gate.

pygsti.tools.jamiolkowski.sums_of_negative_choi_eigenvalues(model)

Compute the amount of non-CP-ness of a model.

This is defined (somewhat arbitrarily) by summing the negative eigenvalues of the Choi matrix for each gate in model separately. This function is different from sum_of_negative_choi_eigenvalues() in that it returns sums separately for each operation of model.

Parameters

modelModel

The model to act on.

Returns

list of floats

each element == sum of the negative eigenvalues of the Choi matrix for the corresponding gate (as ordered by model.operations.iteritems()).

pygsti.tools.jamiolkowski.magnitudes_of_negative_choi_eigenvalues(model)

Compute the magnitudes of the negative eigenvalues of the Choi matrices for each gate in model.

Parameters

modelModel

The model to act on.

Returns

list of floats

list of the magnitues of all negative Choi eigenvalues. The length of this list will vary based on how many negative eigenvalues are found, as positive eigenvalues contribute nothing to this list.