MatrixProductInitializer

class mpsprep.mpsstatepreparation.MatrixProductInitializer(MPS)[source]

Bases: object

Generate the unitaries needed to prepare the desired state given the desired Matrix Product State (MPS).

__init__(MPS)[source]

Initializes the MatrixProductInitializer (MPI) class.

Parameters
MPSMatrixProductState

The MPS to initialize.

Methods

__init__(MPS)

Initializes the MatrixProductInitializer (MPI) class.

gate_unitaries([full_space])

Returns a list of unitaries \([U_1, U_2, ..., U_N]\) such that :math:`|MPS> = U_N .

is_unitary(matrix[, rtol, atol, equal_nan])

Returns True if the matrix is a unitary matrix within the specified tolerance.

Attributes

gate_unitary

The full gate unitary of the MPS.

num_qubits

The number of qubits in the MPS.

gate_unitaries(full_space=True)[source]

Returns a list of unitaries \([U_1, U_2, ..., U_N]\) such that \(|MPS> = U_N ... U_2 U_1 |0>\).

Parameters
full_spacebool, optional

If True, all of the unitaries are returned in the full Hilbert space of the MPS. Otherwise, they are returned in their native space and will either be 4x4 matrices or 2x2 matrices.

Returns
gate_unitarieslist

A list of unitaries.

property gate_unitary

The full gate unitary of the MPS.

Type

np.ndarray

static is_unitary(matrix, rtol=1e-05, atol=1e-08, equal_nan=False)[source]

Returns True if the matrix is a unitary matrix within the specified tolerance.

Parameters
matrixnp.ndarray

The matrix to check.

rtolfloat, optional

The relative tolerance. Default is 1e-5.

atolfloat, optional

The absolute tolerance. Default is 1e-8.

equal_nanbool, optional

Whether to treat NaN as equal. Default is False.

Returns
is_unitarybool

Whether the matrix is a unitary matrix.

property num_qubits

The number of qubits in the MPS.

Type

int