cvariance overload for guaranteed hermitian operators
e.g.
template<class O, class Psi, class = std::enable_if_t<internal::isCompatibleOperator_v<O, Psi> && internal::isLabelledAs_GuaranteedHermitian_v>> complex cVariance(const O& op, const Psi& psi) { qengine_assert(std::abs(psi.norm() - 1) < 1e-10, "state must be normalized to calculate variance"); auto oPsi = op*psi; return overlap(oPsi, oPsi) - overlap(psi, oPsi); }
this should work for e.g. GpeHamiltonian, which is nonlinear but guaranteed hermitian. I think this one is more efficiant as well, so the linear overload should be constrained to act only when the operator is not guaranteed to be hermitian.