braket.circuits.unitary_calculation module

braket.circuits.unitary_calculation.calculate_unitary_big_endian(instructions: Iterable[Instruction], qubits: QubitSet) ndarray[source]

Returns the unitary matrix representation for all the instruction`s on qubits `qubits.

Note

The performance of this method degrades with qubit count. It might be slow for len(qubits) > 10.

Parameters:
  • instructions (Iterable[Instruction]) – The instructions for which the unitary matrix will be calculated.

  • qubits (QubitSet) – The actual qubits used by the instructions.

Returns:

np.ndarray – A numpy array with shape (2^qubit_count, 2^qubit_count) representing the instructions as a unitary matrix.

Raises:

TypeError – If instructions is not composed only of Gate instances, i.e. a circuit with Noise operators will raise this error. Any CompilerDirective instructions will be ignored, as these should not affect the unitary representation of the circuit.