Complex Kraus channels fail with a real output accumulator
apply_kraus_ops_2_state cannot currently apply a channel when either the state or a Kraus operator has complex entries. The output accumulator is initialized with NumPy's real default dtype, so the first complex contribution raises UFuncOutputCastingError.
A phase rotation of a real coherent state is enough to reproduce it:
import numpy as np
from forest.benchmarking.operator_tools import apply_kraus_ops_2_state
rho = np.array([[0.5, 0.5], [0.5, 0.5]])
s = np.diag([1, 1j])
apply_kraus_ops_2_state([s], rho)
Expected density matrix:
[[0.5+0.j, 0.0-0.5j],
[0.0+0.5j, 0.5+0.j]]
Observed on aa288ffbf28179c5e5b4f184201f5bc2abcea25b, Python 3.12.10 / NumPy 2.5.4:
numpy._core._exceptions._UFuncOutputCastingError:
Cannot cast ufunc 'add' output from dtype('complex128') to dtype('float64')
with casting rule 'same_kind'
The same failure occurs for real Kraus operators acting on a state with imaginary coherence. Using a complex accumulator preserves the supported rectangular Kraus output shape and is consistent with the other channel utilities. I have a small fix and phase-sensitive regression ready.