dq.signm
signm(x: QArrayLike) -> QArray
Returns the operator sign function of a hermitian qarray.
The operator sign function \(\mathrm{sign}(A)\) of a hermitian matrix \(A\) with eigendecomposition \(A = U\, \text{diag}(\lambda_1,\dots,\lambda_n)\, U^\dagger\), with \((\lambda_1,\dots,\lambda_n)\in\R^n\) the eigenvalues of \(A\), is defined by $$ \mathrm{sign}(A) = U\,\mathrm{diag}(\mathrm{sign}(\lambda_1),\dots,\mathrm{sign}(\lambda_n))\,U^\dagger, $$ where \(\mathrm{sign}(x)\) is the sign of \(x\in\R\).
Parameters
-
x
(qarray-like of shape (..., n, n))
–
Square hermitian matrix.
Returns
(qarray of shape (..., n, n)) Operator sign function of x
.
Note
The operator sign is generally dense, and is different from the element-wise sign of the operator.
Examples
>>> dq.signm(dq.sigmax())
QArray: shape=(2, 2), dims=(2,), dtype=complex64, layout=dense
[[0.+0.j 1.+0.j]
[1.+0.j 0.+0.j]]
>>> dq.position(4)
QArray: shape=(4, 4), dims=(4,), dtype=complex64, layout=dia, ndiags=2
[[ â‹… 0.5 +0.j â‹… â‹… ]
[0.5 +0.j â‹… 0.707+0.j â‹… ]
[ â‹… 0.707+0.j â‹… 0.866+0.j]
[ â‹… â‹… 0.866+0.j â‹… ]]
>>> dq.signm(dq.position(4))
QArray: shape=(4, 4), dims=(4,), dtype=complex64, layout=dense
[[ 0. +0.j 0.888+0.j 0. +0.j -0.46 +0.j]
[ 0.888+0.j -0. +0.j 0.46 +0.j -0. +0.j]
[ 0. +0.j 0.46 +0.j -0. +0.j 0.888+0.j]
[-0.46 +0.j -0. +0.j 0.888+0.j -0. +0.j]]