qics.quantum.entropy¶
- qics.quantum.entropy(x)[source]¶
Computes either the classical (Shannon) entropy
\[H(x) = -\sum_{i=1}^n x_i \log(x_i),\]for nonnegative vector \(x\), or the quantum (von Neumann) entropy
\[S(X) = -\text{tr}[X \log(X)],\]for positive semidefinite matrix \(X\).
- Parameters:
- x
ndarray
If this is a nonnegative array of size
(n,)
or(n, 1)
, we compute the classical entropy of \(x\). If this is a symmetric or Hermitian positive semidefinite array of size(n, n)
, then we compute the quantum entropy of \(X\)
- x
- Returns:
float
Classical entropy of \(x\) or quantum entropy of \(X\).