PermutationMatrix

class PermutationMatrix(input, radixes=[], check_arguments=True)[source]

Bases: UnitaryMatrix

A binary, unitary matrix with a single 1 in each row and column.

__init__(input, radixes=[], check_arguments=True)[source]

Constructs a PermutationMatrix from the supplied matrix.

See UnitaryMatrix for more info.

Attributes

T

The transpose of the unitary.

dagger

The conjugate transpose of the unitary.

dim

The matrix dimension for this unitary.

dtype

The NumPy data type of the unitary.

num_params

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

num_qudits

The number of qudits this unitary can act on.

numpy

The NumPy array holding the unitary.

radixes

The number of orthogonal states for each qudit.

shape

The two-dimensional square shape of the unitary.

Methods

check_parameters(params)

Check parameters are valid and match the unitary.

closest_to(M[, radixes])

Calculate and return the closest unitary to a given matrix.

conj()

Return the complex conjugate unitary matrix.

from_file(filename)

Load a unitary from a file.

from_qubit_location(num_qubits, location)

Creates a qubit permutation matrix.

from_qudit_location(num_qudits, radix, location)

Creates the permutation matrix specified by arguments.

gen_swap_unitary([radix])

Generate a unitary matrix that swaps the state of two qudits.

get_distance_from(other[, degree])

Return the distance between self and other.

get_statevector(in_state)

Calculate the output state after applying this unitary to in_state.

get_unitary([params])

Return the same object, satisfies the Unitary API.

identity(dim[, radixes])

Construct an identity UnitaryMatrix.

is_constant()

Return true if this unitary doesn't take parameters.

is_parameterized()

Return true if this unitary is parameterized.

is_permutation(P[, tol])

Check if P is a permutation matrix.

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.

is_special()

Return true if this unitary is special.

is_unitary(U[, tol])

Check if U is a unitary matrix.

otimes(*utrys)

Calculate the tensor or kroneckor product with other unitaries.

random(num_qudits[, radixes])

Sample a random unitary from the haar distribution.

save(filename)

Save the unitary to a file.

to_special()

Return a special unitary matrix verson of this one.