dq.overlap
overlap(x: ArrayLike, y: ArrayLike) -> Array
Returns the overlap between two quantum states.
The overlap is computed
- as if both arguments are kets and ,
- as if one argument is a ket and the other is a density matrix ,
- as if both arguments are density matrices and .
Parameters
-
x
(array_like of shape (..., n, 1) or (..., n, n))
–
Ket or density matrix.
-
y
(array_like of shape (..., n, 1) or (..., n, n))
–
Ket or density matrix.
Returns
(array of shape (...)) Real-valued overlap.
Examples
>>> fock0 = dq.fock(3, 0)
>>> dq.overlap(fock0, fock0)
Array(1., dtype=float32)
>>> fock01_dm = 0.5 * (dq.fock_dm(3, 0) + dq.fock_dm(3, 1))
>>> dq.overlap(fock0, fock01_dm)
Array(0.5, dtype=float32)