MatchCake

matchcake.operations.single_particle_transition_matrices package

Submodules

matchcake.operations.single_particle_transition_matrices.single_particle_transition_matrix module

class matchcake.operations.single_particle_transition_matrices.single_particle_transition_matrix.SingleParticleTransitionMatrixOperation(matrix: TensorLike, wires: Sequence[int] | Wires | None = None, *, id=None, clip_angles: bool = True, check_angles: bool = False, check_matrix: bool = False, normalize: bool = False, **kwargs)

Bases: Operation

Represents a single-particle transition matrix (SPTM) operation.

This class defines and implements the behavior of single-particle transition matrix operations in a quantum computation framework. A SPTM is defined as

\[R = \exp(4 h)\]

where \(R\) is the SPTM and \(h\) is the free fermionic integrals, or transition energies between orbitals. The free fermions hamiltonian is then defines as

\[H = i \sum_{i,j=0}^{2N - 1} h_{i,j} c_i c_j\]

where \(c_k\) is the k-th majorana operator and \(N\) is the number of orbitals/qubits/wires.

In terms of matchgate, the SPTM is defined as

\[R_{\mu\nu} = \frac{1}{4} \text{Tr}((U c_\mu U^\dagger)c_\nu)\]

where \(R_{\mu\nu}\) are the matrix elements of the SPTM and \(U\) is a matchgate.

ALLOWED_ANGLES = None
DEFAULT_CHECK_ANGLES = False
DEFAULT_CHECK_MATRIX = False
DEFAULT_CLIP_ANGLES = True
DEFAULT_NORMALIZE = False
EQUAL_ALLOWED_ANGLES = None
__init__(matrix: TensorLike, wires: Sequence[int] | Wires | None = None, *, id=None, clip_angles: bool = True, check_angles: bool = False, check_matrix: bool = False, normalize: bool = False, **kwargs)

Initialize an operation that applies a single-particle transition represented by the specified matrix with optional parameters for clipping angles, checking matrix and angle validity, and normalization.

Parameters:
  • matrix – A tensor-like object defining the transition matrix.

  • wires – Optional; Specifies the wires or subsystems the operation acts on. Can be a sequence of integers or a Wires object.

  • id – Optional; The operation’s unique identifier.

  • clip_angles – Boolean flag indicating whether to clip angles in the matrix. Defaults to DEFAULT_CLIP_ANGLES.

  • check_angles – Boolean flag indicating whether to validate the angles in the matrix. Defaults to DEFAULT_CHECK_ANGLES.

  • check_matrix – Boolean flag indicating whether to check if the matrix lies within the SO(4) group. Defaults to DEFAULT_CHECK_MATRIX.

  • normalize – Boolean flag indicating whether to orthonormalize the matrix prior to initialization. Defaults to DEFAULT_NORMALIZE.

  • kwargs – Additional keyword arguments passed to parent classes or methods.

Raises:

ValueError – If check_matrix is True and the provided matrix does not belong to the SO(4) group.

adjoint() SingleParticleTransitionMatrixOperation

Create an operation that is the adjoint of this one.

Adjointed operations are the conjugated and transposed version of the original operation. Adjointed ops are equivalent to the inverted operation for unitary gates.

Returns:

The adjointed operation.

property batch_size

Batch size of the operator if it is used with broadcasted parameters.

The batch_size is determined based on ndim_params and the provided parameters for the operator. If (some of) the latter have an additional dimension, and this dimension has the same size for all parameters, its size is the batch size of the operator. If no parameter has an additional dimension, the batch size is None.

Returns:

Size of the parameter broadcasting dimension if present, else None.

Return type:

int or None

casting_priorities: List[Literal['numpy', 'autograd', 'jax', 'tf', 'torch']] = ['numpy', 'autograd', 'jax', 'tf', 'torch']
classmethod check_angles(angles)

If the ALLOWED_ANGLES is not none, check if the angles are in the allowed range.

check_is_in_so4(atol=1e-06, rtol=1e-06)
check_is_unitary(atol=1e-06, rtol=1e-06)
classmethod clip_angles(angles)

If the ALLOWED_ANGLES is not none, set the angles to the closest allowed angle. If all the angles are equal in the last dimension, the EQUAL_ALLOWED_ANGLES is used instead.

classmethod clip_to_allowed_angles(angles, allowed_angles: Sequence[float] | None = None)

If the ALLOWED_ANGLES is not none, set the angles to the closest allowed angle.

static compute_decomposition(*params: TensorLike, wires: Wires | Iterable[Hashable] | Hashable | None = None, **hyperparameters: dict[str, Any])

Representation of the operator as a product of other operators (static method).

\[O = O_1 O_2 \dots O_n.\]

Note

Operations making up the decomposition should be queued within the compute_decomposition method.

See also

decomposition().

Parameters:
  • *params (list) – trainable parameters of the operator, as stored in the parameters attribute

  • wires (Iterable[Any], Wires) – wires that the operator acts on

  • **hyperparams (dict) – non-trainable hyperparameters of the operator, as stored in the hyperparameters attribute

Returns:

decomposition of the operator

Return type:

list[Operator]

property cs_wires
classmethod from_operation(op: Operator | SingleParticleTransitionMatrixOperation, **kwargs) SingleParticleTransitionMatrixOperation

Creates an instance of SingleParticleTransitionMatrixOperation from the given operation.

This class method allows the construction of a SingleParticleTransitionMatrixOperation instance from various types of operators. If the input operator is already an instance of SingleParticleTransitionMatrixOperation, it is directly returned. It also checks if the provided operator has the to_sptm_operation method or the single_particle_transition_matrix attribute. If it’s the case, the SPTM will be constructed from to_sptm_operation or from single_particle_transition_matrix if the first doesn’t exist. When none of the required attributes or methods are present, we try to build a MatchGateOperation from the given operation matrix. If nothing works, a ValueError is raised.

Parameters:
  • op – The input operator to be converted. It can be an instance of Operator or SingleParticleTransitionMatrixOperation.

  • kwargs – Any additional keyword arguments passed to the method.

Returns:

A new instance of SingleParticleTransitionMatrixOperation.

Return type:

SingleParticleTransitionMatrixOperation

Raises:

ValueError – When the input operator cannot be converted due to missing attributes or methods.

classmethod from_operations(ops: Iterable[Any | SingleParticleTransitionMatrixOperation], **kwargs) SingleParticleTransitionMatrixOperation

This method will contract multiple SingleParticleTransitionMatrixOperations into a single one. Each operation must act on a different set of wires.

Parameters:
  • ops – The operations to contract.

  • kwargs – Additional keyword arguments.

Returns:

The contracted SingleParticleTransitionMatrixOperation.

Return type:

SingleParticleTransitionMatrixOperation

generator = None
grad_method = 'A'
grad_recipe = None

Gradient recipe for the parameter-shift method.

This is a tuple with one nested list per operation parameter. For parameter \(\phi_k\), the nested list contains elements of the form \([c_i, a_i, s_i]\) where \(i\) is the index of the term, resulting in a gradient recipe of

\[\frac{\partial}{\partial\phi_k}f = \sum_{i} c_i f(a_i \phi_k + s_i).\]

If None, the default gradient recipe containing the two terms \([c_0, a_0, s_0]=[1/2, 1, \pi/2]\) and \([c_1, a_1, s_1]=[-1/2, 1, -\pi/2]\) is assumed for every parameter.

Type:

tuple(Union(list[list[float]], None)) or None

static make_wires_continuous(wires: Wires)
matrix(wire_order=None) TensorLike

Representation of the operator as a matrix in the computational basis.

If wire_order is provided, the numerical representation considers the position of the operator’s wires in the global wire order. Otherwise, the wire order defaults to the operator’s wires.

If the matrix depends on trainable parameters, the result will be cast in the same autodifferentiation framework as the parameters.

A MatrixUndefinedError is raised if the matrix representation has not been defined.

See also

compute_matrix()

Parameters:

wire_order (Iterable) – global wire order, must contain all wire labels from the operator’s wires

Returns:

matrix representation

Return type:

tensor_like

num_params = 1
num_wires: int | WiresEnum = -1

Number of wires the operator acts on.

pad(wires: Wires)
par_domain = 'A'
classmethod random(wires: Wires, batch_size=None, **kwargs)
classmethod random_params(batch_size=None, **kwargs)
real()
property shape
property sorted_wires
to_cuda()
to_matchgate()
to_qubit_operation() Operation

Converts the current object into a qubit operation.

This method determines the appropriate qubit operation based on the number of wires in the object. If the number of wires is two, it converts the object to a matchgate operation. Otherwise, it falls back to converting the object into a generic qubit unitary operation.

Returns:

An instance of Operation representing either a match gate or a qubit unitary operation, depending on the number of wires.

Return type:

Operation

to_qubit_unitary() QubitUnitary

Converts the internal matrix representation to a qml.QubitUnitary object. The method takes the unitary matrix representation of the object and associates it with the specified wires. This is primarily used for creating quantum operations that act on qubits in Pennylane.

Returns:

A qml.QubitUnitary object that represents the unitary operation acting on the specified wires.

Return type:

qml.QubitUnitary

to_torch()
static to_unitary_matrix(matrix: TensorLike) TensorLike

Compute the Matchgate unitary matrix from the single particle transition matrix.

… :math:

U = exp(-sumlimits_{i,j=0}^{2N-1} h_{ij} c_i c_j) R = exp(4 h) implies h = frac{1}{4} log(R)

where \(c_i\) are the Majorana operators, \(R\) is the current single particle transition matrix.

matchcake.operations.single_particle_transition_matrices.sptm_angle_embedding module

class matchcake.operations.single_particle_transition_matrices.sptm_angle_embedding.SptmAngleEmbedding(features, wires, rotations='X', id=None, **kwargs)

Bases: Operation

__init__(features, wires, rotations='X', id=None, **kwargs)

Construct a new Matchgate AngleEmbedding operation.

Note:

It is better to have one more wire than the number of features because every gate acts on two wires.

Parameters:
  • features – The features to embed.

  • wires – The wires to embed the features on.

  • id – The id of the operation.

Keyword Arguments:

contract_rots – If True, contract the rotations. Default is False.

static compute_decomposition(*params, wires=None, **hyperparameters)

Representation of the operator as a product of other operators (static method).

\[O = O_1 O_2 \dots O_n.\]

Note

Operations making up the decomposition should be queued within the compute_decomposition method.

See also

decomposition().

Parameters:
  • *params (list) – trainable parameters of the operator, as stored in the parameters attribute

  • wires (Iterable[Any], Wires) – wires that the operator acts on

  • **hyperparams (dict) – non-trainable hyperparameters of the operator, as stored in the hyperparameters attribute

Returns:

decomposition of the operator

Return type:

list[Operator]

grad_method = None
property ndim_params

Number of dimensions per trainable parameter of the operator.

By default, this property returns the numbers of dimensions of the parameters used for the operator creation. If the parameter sizes for an operator subclass are fixed, this property can be overwritten to return the fixed value.

Returns:

Number of dimensions for each trainable parameter.

Return type:

tuple

property num_params

Number of trainable parameters that the operator depends on.

By default, this property returns as many parameters as were used for the operator creation. If the number of parameters for an operator subclass is fixed, this property can be overwritten to return the fixed value.

Returns:

number of parameters

Return type:

int

num_wires: int | WiresEnum = -1

Number of wires the operator acts on.

static pad_params(params)

If the number of parameters is odd, pad the parameters with zero to make it even.

Parameters:

params – The parameters to pad.

Returns:

The padded parameters.

matchcake.operations.single_particle_transition_matrices.sptm_block_diag_angle_embedding module

class matchcake.operations.single_particle_transition_matrices.sptm_block_diag_angle_embedding.SptmBlockDiagAngleEmbedding(params, wires=None, id=None)

Bases: SingleParticleTransitionMatrixOperation

Embedding operation for the block diagonal angle single-particle transition matrix. The input features will be embedded into the block diagonal of the single-particle transition matrix of size \(2N \times 2N\), where \(N\) is the number of qubits. This operation can then encode \(N\) features into the diagonal of the single-particle transition matrix. Here is the formula for the block diagonal angle embedding:

\[\begin{split}\begin{align} R = \begin{bmatrix} \cos(f_0) & -\sin(f_0) & 0 & 0 & \cdots & 0 \\ \sin(f_0) & \cos(f_0) & 0 & 0 & \cdots & 0 \\ 0 & 0 & \cos(f_1) & -\sin(f_1) & \cdots & 0 \\ 0 & 0 & \sin(f_1) & \cos(f_1) & \cdots & 0 \\ \vdots & \vdots & \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & 0 & 0 & \cdots & \cos(f_{N-1}) & -\sin(f_{N-1}) \\ 0 & 0 & 0 & 0 & \cdots & \sin(f_{N-1}) & \cos(f_{N-1}) \end{bmatrix}\end{split}\]
Parameters:

params – The parameters of the operation

__init__(params, wires=None, id=None)

Initialize an operation that applies a single-particle transition represented by the specified matrix with optional parameters for clipping angles, checking matrix and angle validity, and normalization.

Parameters:
  • matrix – A tensor-like object defining the transition matrix.

  • wires – Optional; Specifies the wires or subsystems the operation acts on. Can be a sequence of integers or a Wires object.

  • id – Optional; The operation’s unique identifier.

  • clip_angles – Boolean flag indicating whether to clip angles in the matrix. Defaults to DEFAULT_CLIP_ANGLES.

  • check_angles – Boolean flag indicating whether to validate the angles in the matrix. Defaults to DEFAULT_CHECK_ANGLES.

  • check_matrix – Boolean flag indicating whether to check if the matrix lies within the SO(4) group. Defaults to DEFAULT_CHECK_MATRIX.

  • normalize – Boolean flag indicating whether to orthonormalize the matrix prior to initialization. Defaults to DEFAULT_NORMALIZE.

  • kwargs – Additional keyword arguments passed to parent classes or methods.

Raises:

ValueError – If check_matrix is True and the provided matrix does not belong to the SO(4) group.

num_wires: int | WiresEnum = -1

Number of wires the operator acts on.

matchcake.operations.single_particle_transition_matrices.sptm_comp_hh module

class matchcake.operations.single_particle_transition_matrices.sptm_comp_hh.SptmCompHH(wires=None, id=None, **kwargs)

Bases: SingleParticleTransitionMatrixOperation

__init__(wires=None, id=None, **kwargs)

Initialize an operation that applies a single-particle transition represented by the specified matrix with optional parameters for clipping angles, checking matrix and angle validity, and normalization.

Parameters:
  • matrix – A tensor-like object defining the transition matrix.

  • wires – Optional; Specifies the wires or subsystems the operation acts on. Can be a sequence of integers or a Wires object.

  • id – Optional; The operation’s unique identifier.

  • clip_angles – Boolean flag indicating whether to clip angles in the matrix. Defaults to DEFAULT_CLIP_ANGLES.

  • check_angles – Boolean flag indicating whether to validate the angles in the matrix. Defaults to DEFAULT_CHECK_ANGLES.

  • check_matrix – Boolean flag indicating whether to check if the matrix lies within the SO(4) group. Defaults to DEFAULT_CHECK_MATRIX.

  • normalize – Boolean flag indicating whether to orthonormalize the matrix prior to initialization. Defaults to DEFAULT_NORMALIZE.

  • kwargs – Additional keyword arguments passed to parent classes or methods.

Raises:

ValueError – If check_matrix is True and the provided matrix does not belong to the SO(4) group.

adjoint() SingleParticleTransitionMatrixOperation

Create an operation that is the adjoint of this one.

Adjointed operations are the conjugated and transposed version of the original operation. Adjointed ops are equivalent to the inverted operation for unitary gates.

Returns:

The adjointed operation.

classmethod random(wires: Wires, batch_size=None, **kwargs)
to_matchgate()

matchcake.operations.single_particle_transition_matrices.sptm_comp_rxrx module

class matchcake.operations.single_particle_transition_matrices.sptm_comp_rxrx.SptmCompRxRx(params, wires=None, id=None, **kwargs)

Bases: SingleParticleTransitionMatrixOperation

This class represents the single-particle transition matrix for the composition Rx, Rx rotation gates.

This matrix is defined as

\[\begin{split}\begin{align} M(Rx(2\theta), Rx(2\phi)) = U(2\theta, 2\phi) = \begin{pmatrix} \cos(\phi - \theta) & 0 & 0 & -\sin(\phi - \theta) \\ 0 & \cos(\phi + \theta) & \sin(\phi + \theta) & 0 \\ 0 & -\sin(\phi + \theta) & \cos(\phi + \theta) & 0 \\ \sin(\phi - \theta) & 0 & 0 & \cos(\phi - \theta) \end{pmatrix}. \end{align}\end{split}\]
__init__(params, wires=None, id=None, **kwargs)

Initialize an operation that applies a single-particle transition represented by the specified matrix with optional parameters for clipping angles, checking matrix and angle validity, and normalization.

Parameters:
  • matrix – A tensor-like object defining the transition matrix.

  • wires – Optional; Specifies the wires or subsystems the operation acts on. Can be a sequence of integers or a Wires object.

  • id – Optional; The operation’s unique identifier.

  • clip_angles – Boolean flag indicating whether to clip angles in the matrix. Defaults to DEFAULT_CLIP_ANGLES.

  • check_angles – Boolean flag indicating whether to validate the angles in the matrix. Defaults to DEFAULT_CHECK_ANGLES.

  • check_matrix – Boolean flag indicating whether to check if the matrix lies within the SO(4) group. Defaults to DEFAULT_CHECK_MATRIX.

  • normalize – Boolean flag indicating whether to orthonormalize the matrix prior to initialization. Defaults to DEFAULT_NORMALIZE.

  • kwargs – Additional keyword arguments passed to parent classes or methods.

Raises:

ValueError – If check_matrix is True and the provided matrix does not belong to the SO(4) group.

classmethod random_params(batch_size=None, **kwargs)
to_matchgate()

matchcake.operations.single_particle_transition_matrices.sptm_comp_ryry module

class matchcake.operations.single_particle_transition_matrices.sptm_comp_ryry.SptmCompRyRy(params, wires=None, *, id=None, **kwargs)

Bases: SingleParticleTransitionMatrixOperation

Single Particle Transition Matrix (Sptm) Composition of rotations YY of a matchgate

\[U = M(R_Y(\theta), R_Y(\phi))\]

where M is the matchgate. The current class represent

\[R_{\mu\nu} = \frac{1}{4} \text{Tr}{\left(U c_\mu U^\dagger\right)c_\nu}\]

where R is the Sptm and c are the majoranas.

ALLOWED_ANGLES = [3.141592653589793, 9.42477796076938]
DEFAULT_CLIP_ANGLES = False
EQUAL_ALLOWED_ANGLES = [0, 3.141592653589793, 6.283185307179586, 9.42477796076938]
__init__(params, wires=None, *, id=None, **kwargs)

Initialize an operation that applies a single-particle transition represented by the specified matrix with optional parameters for clipping angles, checking matrix and angle validity, and normalization.

Parameters:
  • matrix – A tensor-like object defining the transition matrix.

  • wires – Optional; Specifies the wires or subsystems the operation acts on. Can be a sequence of integers or a Wires object.

  • id – Optional; The operation’s unique identifier.

  • clip_angles – Boolean flag indicating whether to clip angles in the matrix. Defaults to DEFAULT_CLIP_ANGLES.

  • check_angles – Boolean flag indicating whether to validate the angles in the matrix. Defaults to DEFAULT_CHECK_ANGLES.

  • check_matrix – Boolean flag indicating whether to check if the matrix lies within the SO(4) group. Defaults to DEFAULT_CHECK_MATRIX.

  • normalize – Boolean flag indicating whether to orthonormalize the matrix prior to initialization. Defaults to DEFAULT_NORMALIZE.

  • kwargs – Additional keyword arguments passed to parent classes or methods.

Raises:

ValueError – If check_matrix is True and the provided matrix does not belong to the SO(4) group.

classmethod random_params(batch_size=None, **kwargs)
to_matchgate()

matchcake.operations.single_particle_transition_matrices.sptm_comp_rzrz module

class matchcake.operations.single_particle_transition_matrices.sptm_comp_rzrz.SptmCompRzRz(params, wires=None, *, id=None, **kwargs)

Bases: SingleParticleTransitionMatrixOperation

Single Particle Transition Matrix (Sptm) Composition of rotations ZZ of a matchgate

\[U = M(R_Z(\theta), R_Z(\phi))\]

where M is the matchgate. The current class represent

\[R_{\mu\nu} = \frac{1}{4} \text{Tr}{\left(M c_\mu M^\dagger\right)c_\nu}\]

where R is the Sptm and c are the majoranas.

ALLOWED_ANGLES = None
EQUAL_ALLOWED_ANGLES = None
__init__(params, wires=None, *, id=None, **kwargs)

Initialize an operation that applies a single-particle transition represented by the specified matrix with optional parameters for clipping angles, checking matrix and angle validity, and normalization.

Parameters:
  • matrix – A tensor-like object defining the transition matrix.

  • wires – Optional; Specifies the wires or subsystems the operation acts on. Can be a sequence of integers or a Wires object.

  • id – Optional; The operation’s unique identifier.

  • clip_angles – Boolean flag indicating whether to clip angles in the matrix. Defaults to DEFAULT_CLIP_ANGLES.

  • check_angles – Boolean flag indicating whether to validate the angles in the matrix. Defaults to DEFAULT_CHECK_ANGLES.

  • check_matrix – Boolean flag indicating whether to check if the matrix lies within the SO(4) group. Defaults to DEFAULT_CHECK_MATRIX.

  • normalize – Boolean flag indicating whether to orthonormalize the matrix prior to initialization. Defaults to DEFAULT_NORMALIZE.

  • kwargs – Additional keyword arguments passed to parent classes or methods.

Raises:

ValueError – If check_matrix is True and the provided matrix does not belong to the SO(4) group.

classmethod random_params(batch_size=None, **kwargs)
to_matchgate()

matchcake.operations.single_particle_transition_matrices.sptm_fermionic_superposition module

class matchcake.operations.single_particle_transition_matrices.sptm_fermionic_superposition.SptmFermionicSuperposition(wires=None, id=None, **kwargs)

Bases: SingleParticleTransitionMatrixOperation

__init__(wires=None, id=None, **kwargs)

Initialize an operation that applies a single-particle transition represented by the specified matrix with optional parameters for clipping angles, checking matrix and angle validity, and normalization.

Parameters:
  • matrix – A tensor-like object defining the transition matrix.

  • wires – Optional; Specifies the wires or subsystems the operation acts on. Can be a sequence of integers or a Wires object.

  • id – Optional; The operation’s unique identifier.

  • clip_angles – Boolean flag indicating whether to clip angles in the matrix. Defaults to DEFAULT_CLIP_ANGLES.

  • check_angles – Boolean flag indicating whether to validate the angles in the matrix. Defaults to DEFAULT_CHECK_ANGLES.

  • check_matrix – Boolean flag indicating whether to check if the matrix lies within the SO(4) group. Defaults to DEFAULT_CHECK_MATRIX.

  • normalize – Boolean flag indicating whether to orthonormalize the matrix prior to initialization. Defaults to DEFAULT_NORMALIZE.

  • kwargs – Additional keyword arguments passed to parent classes or methods.

Raises:

ValueError – If check_matrix is True and the provided matrix does not belong to the SO(4) group.

adjoint() SingleParticleTransitionMatrixOperation

Create an operation that is the adjoint of this one.

Adjointed operations are the conjugated and transposed version of the original operation. Adjointed ops are equivalent to the inverted operation for unitary gates.

Returns:

The adjointed operation.

static compute_decomposition(*params, wires=None, **hyperparameters)

Representation of the operator as a product of other operators (static method).

\[O = O_1 O_2 \dots O_n.\]

Note

Operations making up the decomposition should be queued within the compute_decomposition method.

See also

decomposition().

Parameters:
  • *params (list) – trainable parameters of the operator, as stored in the parameters attribute

  • wires (Iterable[Any], Wires) – wires that the operator acts on

  • **hyperparams (dict) – non-trainable hyperparameters of the operator, as stored in the hyperparameters attribute

Returns:

decomposition of the operator

Return type:

list[Operator]

classmethod random(wires: Wires, batch_size=None, **kwargs)
to_matchgate()

matchcake.operations.single_particle_transition_matrices.sptm_fswap module

matchcake.operations.single_particle_transition_matrices.sptm_fswap.SptmCompZX

alias of SptmCompZX

class matchcake.operations.single_particle_transition_matrices.sptm_fswap.SptmFSwap(wires=None, id=None, **kwargs)

Bases: SingleParticleTransitionMatrixOperation

__init__(wires=None, id=None, **kwargs)

Initialize an operation that applies a single-particle transition represented by the specified matrix with optional parameters for clipping angles, checking matrix and angle validity, and normalization.

Parameters:
  • matrix – A tensor-like object defining the transition matrix.

  • wires – Optional; Specifies the wires or subsystems the operation acts on. Can be a sequence of integers or a Wires object.

  • id – Optional; The operation’s unique identifier.

  • clip_angles – Boolean flag indicating whether to clip angles in the matrix. Defaults to DEFAULT_CLIP_ANGLES.

  • check_angles – Boolean flag indicating whether to validate the angles in the matrix. Defaults to DEFAULT_CHECK_ANGLES.

  • check_matrix – Boolean flag indicating whether to check if the matrix lies within the SO(4) group. Defaults to DEFAULT_CHECK_MATRIX.

  • normalize – Boolean flag indicating whether to orthonormalize the matrix prior to initialization. Defaults to DEFAULT_NORMALIZE.

  • kwargs – Additional keyword arguments passed to parent classes or methods.

Raises:

ValueError – If check_matrix is True and the provided matrix does not belong to the SO(4) group.

adjoint() SingleParticleTransitionMatrixOperation

Create an operation that is the adjoint of this one.

Adjointed operations are the conjugated and transposed version of the original operation. Adjointed ops are equivalent to the inverted operation for unitary gates.

Returns:

The adjointed operation.

classmethod random(wires: Wires, batch_size=None, **kwargs)
to_matchgate()

matchcake.operations.single_particle_transition_matrices.sptm_fswap_hh module

class matchcake.operations.single_particle_transition_matrices.sptm_fswap_hh.SptmFSwapHH(wires=None, id=None, **kwargs)

Bases: SingleParticleTransitionMatrixOperation

__init__(wires=None, id=None, **kwargs)

Initialize an operation that applies a single-particle transition represented by the specified matrix with optional parameters for clipping angles, checking matrix and angle validity, and normalization.

Parameters:
  • matrix – A tensor-like object defining the transition matrix.

  • wires – Optional; Specifies the wires or subsystems the operation acts on. Can be a sequence of integers or a Wires object.

  • id – Optional; The operation’s unique identifier.

  • clip_angles – Boolean flag indicating whether to clip angles in the matrix. Defaults to DEFAULT_CLIP_ANGLES.

  • check_angles – Boolean flag indicating whether to validate the angles in the matrix. Defaults to DEFAULT_CHECK_ANGLES.

  • check_matrix – Boolean flag indicating whether to check if the matrix lies within the SO(4) group. Defaults to DEFAULT_CHECK_MATRIX.

  • normalize – Boolean flag indicating whether to orthonormalize the matrix prior to initialization. Defaults to DEFAULT_NORMALIZE.

  • kwargs – Additional keyword arguments passed to parent classes or methods.

Raises:

ValueError – If check_matrix is True and the provided matrix does not belong to the SO(4) group.

adjoint() SingleParticleTransitionMatrixOperation

Create an operation that is the adjoint of this one.

Adjointed operations are the conjugated and transposed version of the original operation. Adjointed ops are equivalent to the inverted operation for unitary gates.

Returns:

The adjointed operation.

classmethod random(wires: Wires, batch_size=None, **kwargs)

matchcake.operations.single_particle_transition_matrices.sptm_identity module

class matchcake.operations.single_particle_transition_matrices.sptm_identity.SptmIdentity(wires, id=None, **kwargs)

Bases: SingleParticleTransitionMatrixOperation

__init__(wires, id=None, **kwargs)

Initialize an operation that applies a single-particle transition represented by the specified matrix with optional parameters for clipping angles, checking matrix and angle validity, and normalization.

Parameters:
  • matrix – A tensor-like object defining the transition matrix.

  • wires – Optional; Specifies the wires or subsystems the operation acts on. Can be a sequence of integers or a Wires object.

  • id – Optional; The operation’s unique identifier.

  • clip_angles – Boolean flag indicating whether to clip angles in the matrix. Defaults to DEFAULT_CLIP_ANGLES.

  • check_angles – Boolean flag indicating whether to validate the angles in the matrix. Defaults to DEFAULT_CHECK_ANGLES.

  • check_matrix – Boolean flag indicating whether to check if the matrix lies within the SO(4) group. Defaults to DEFAULT_CHECK_MATRIX.

  • normalize – Boolean flag indicating whether to orthonormalize the matrix prior to initialization. Defaults to DEFAULT_NORMALIZE.

  • kwargs – Additional keyword arguments passed to parent classes or methods.

Raises:

ValueError – If check_matrix is True and the provided matrix does not belong to the SO(4) group.

adjoint() SingleParticleTransitionMatrixOperation

Create an operation that is the adjoint of this one.

Adjointed operations are the conjugated and transposed version of the original operation. Adjointed ops are equivalent to the inverted operation for unitary gates.

Returns:

The adjointed operation.

classmethod random(wires: Wires, batch_size=None, **kwargs)
to_matchgate()

Module contents