dq.trace
trace(x: QArrayLike) -> Array
Returns the trace of a qarray along its last two dimensions.
Parameters:
-
x(qarray-like of shape (..., n, n)) –Qarray-like.
Returns:
-
(array of shape (...))
–
Trace of
x.
Examples:
>>> x = jnp.ones((3, 3))
>>> dq.trace(x)
Array(3., dtype=float32)