Skip to content

dq.eye

eye(*dims: int) -> Array

Returns the identity operator.

If multiple dimensions are provided \(\mathtt{dims}=(n_1,\dots,n_N)\), it returns the identity operator of the composite Hilbert space of dimension \(n=\prod n_k\): $$ I_n = I_{n_1}\otimes\dots\otimes I_{n_N}. $$

Parameters

  • *dims –

    Hilbert space dimension of each subsystem.

Returns

(array of shape (n, n)) Identity operator, with n = prod(dims).

Examples

Single-mode \(I_4\):

>>> dq.eye(4)
Array([[1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j],
       [0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j],
       [0.+0.j, 0.+0.j, 1.+0.j, 0.+0.j],
       [0.+0.j, 0.+0.j, 0.+0.j, 1.+0.j]], dtype=complex64)

Multi-mode \(I_2 \otimes I_3\):

>>> dq.eye(2, 3)
Array([[1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j],
       [0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j],
       [0.+0.j, 0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j],
       [0.+0.j, 0.+0.j, 0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j],
       [0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 1.+0.j, 0.+0.j],
       [0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 1.+0.j]], dtype=complex64)