Skip to content

Reference: Matrix Qubricks

Contents


Matrix Class

psiqworkbench.qubricks.qbk_matrix.Matrix

Matrix(**kwargs)

Bases: Qubrick

Qubrick for injecting arbitrary matrices into a QPU.

compute

compute(matrix: ndarray, target_qubits: Qubits, condition_qubits: Qubits | None = None)

Apply matrix to the target_qubits register.

Parameters:

Name Type Description Default
matrix ndarray

Matrix to be applied to the quantum state. If target_qubits has n qubits, the matrix should have dimensions \(2^n \times 2^n\).

required
target_qubits Qubits

Qubits to apply matrix onto.

required
condition_qubits Qubits

Qubits matrix is conditioned on. Defaults to None.

None

Raises:

Type Description
ValueError

If the first dimension of matrix does not equal two raised to the power of the number of qubits in target_qubits.

Note

For more details, see Built-in Qubricks tutorial.


DiagonalMatrix Class

psiqworkbench.qubricks.qbk_matrix.DiagonalMatrix

DiagonalMatrix(**kwargs)

Bases: Qubrick

compute

compute(matrix_diagonal: ndarray, target_qubits: Qubits, ctrl: Qubits | None = None)

Apply matrix_diagonal to the target_qubits register.

Parameters:

Name Type Description Default
matrix_diagonal ndarray

Diagonal of the matrix to be applied to the quantum state. If target_qubits has n qubits, the matrix_diagonal should be an array of length \(2^n\).

required
target_qubits Qubits

Qubits to apply matrix_diagonal onto.

required
ctrl Qubits

Qubits matrix_diagonal is conditioned on. Defaults to None.

None

Raises:

Type Description
ValueError

If the length of matrix_diagonal does not equal two raised to the power of the number of qubits in target_qubits.