dq.eye
eye(*dims: int, layout: Layout | None = None) -> QArray
Returns the identity operator.
If multiple dimensions are provided , it returns the identity operator of the composite Hilbert space of dimension :
Parameters
-
*dims
–
Hilbert space dimension of each subsystem.
-
layout
–
Matrix layout (
dq.dense
,dq.dia
orNone
).
Returns
(qarray of shape (n, n)) Identity operator, with n = prod(dims).
Examples
Single-mode :
>>> dq.eye(4)
QArray: shape=(4, 4), dims=(4,), dtype=complex64, layout=dia, ndiags=1
[[1.+0.j ⋅ ⋅ ⋅ ]
[ ⋅ 1.+0.j ⋅ ⋅ ]
[ ⋅ ⋅ 1.+0.j ⋅ ]
[ ⋅ ⋅ ⋅ 1.+0.j]]
Multi-mode :
>>> dq.eye(2, 3)
QArray: shape=(6, 6), dims=(2, 3), dtype=complex64, layout=dia, ndiags=1
[[1.+0.j ⋅ ⋅ ⋅ ⋅ ⋅ ]
[ ⋅ 1.+0.j ⋅ ⋅ ⋅ ⋅ ]
[ ⋅ ⋅ 1.+0.j ⋅ ⋅ ⋅ ]
[ ⋅ ⋅ ⋅ 1.+0.j ⋅ ⋅ ]
[ ⋅ ⋅ ⋅ ⋅ 1.+0.j ⋅ ]
[ ⋅ ⋅ ⋅ ⋅ ⋅ 1.+0.j]]
See also
dq.eye_like()
: returns the identity operator in the Hilbert space of the input.