SubSwapGate

class SubSwapGate[source]

Bases: ConstantGate, QuditGate

The two-qudit subspace SWAP gate.

The subspace SWAP gate swaps between “qudit-levels” on a two-qudit gate. For example, a |01> to |20> swap would be the identity with the |01> row and |20> rows swapped.

__init__(radix, qudit_levels)[source]

Construct a SubSwapGate.

Parameters:
  • radix (int) – The number of qudit levels (>=2).

  • qudit_levels (str) – The qudit levels that should be swapped, separated by a comma. Example: “0,1;2,0” to swap |01> to |20>

Raises:
  • ValueError – if radix < 2

  • ValueError – If any of the qudit levels integer represenation greater than or equal to radix.

  • ValueError – If the qudit_levels string is not formatted correctly.

Attributes

dim

The matrix dimension for this unitary.

name

The name of this gate.

num_params

The number of real parameters this unitary-valued function takes.

num_qudits

The number of qudits this unitary can act on.

qasm_name

The qasm identifier for this gate.

radix

The number of levels in each qudit.

radixes

The number of orthogonal states for each qudit.

Methods

calculate_level_swap_unitary(radix, level1, ...)

Calculate the unitary for a qudit level swap.

check_env_matrix(env_matrix)

Check to ensure the env_matrix is validly shaped.

check_parameters(params)

Check parameters are valid and match the unitary.

decode_qudit_level_string(string)

Decode the qudit level string into two pairs of integers.

get_grad([params])

Return the gradient for this gate.

get_inverse()

Return the gate's inverse as a gate.

get_inverse_params([params])

Return the parameters that invert the gate.

get_qasm(params, location)

Returns the qasm string for this gate.

get_qasm_gate_def()

Returns a qasm gate definition block for this gate.

get_unitary([params])

Return the unitary for this gate, see Unitary for more.

get_unitary_and_grad([params])

Return the unitary and gradient for this gate.

is_constant()

Return true if this unitary doesn't take parameters.

is_parameterized()

Return true if this unitary is parameterized.

is_qubit_only()

Return true if this unitary can only act on qubits.

is_qudit_only(radix)

Return true if this unitary can only act on radix-qudits.

is_qutrit_only()

Return true if this unitary can only act on qutrits.

is_self_inverse([params])

Checks whether the unitary is its own inverse.

optimize(env_matrix)

Return the optimal parameters with respect to an environment matrix.

with_all_frozen_params(params)

Freeze all of a gate's parameters so they don't change from optimization.

with_frozen_params(frozen_params)

Freeze some of a gate's parameters so they don't change from optimization.