StateVector

class StateVector(*args, **kwargs)[source]

Bases: NDArrayOperatorsMixin

A vector representing a pure quantum state.

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

Constructs a StateVector from the supplied vector.

Parameters:
  • input (StateLike) – The state vector input.

  • radixes (Sequence[int]) – A sequence with its length equal to the number of qudits this StateVector represents. Each element specifies the base, number of orthogonal states, for the corresponding qudit. By default, the constructor will attempt to calculate radixes from input.

  • check_arguments (bool) – If true, check arguments for type and value errors.

Raises:
  • ValueError – If input is not a pure quantum state.

  • ValueError – If the dimension of input does not match the expected dimension from radixes.

  • RuntimeError – If radixes is not specified and the constructor cannot infer it.

Attributes

dim

The vector dimension for this state.

dtype

The NumPy data type of the vector.

num_qudits

The number of qudits in the state.

numpy

The NumPy array holding the vector.

radixes

The number of orthogonal states for each qudit.

shape

The one-dimensional shape of the vector.

Methods

apply(utry, location[, inverse, check_arguments])

Apply the specified unitary on the right of this StateVector.

get_distance_from(other)

Return the distance between self and other.

get_probs()

Return the probabilities for each classical outcome.

is_pure_state(V[, tol])

Check if V is a pure state vector.

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.

random(num_qudits[, radixes])

Sample a random pure state.

zero(num_qudits[, radixes])

Prepares the zero state.