diff options
Diffstat (limited to 'p-spin.hpp')
-rw-r--r-- | p-spin.hpp | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -89,3 +89,18 @@ std::tuple<Real, Vector<Scalar>> WdW(const Tensor<Scalar, p>& J, const Vector<Sc return {W, dW}; } + +template <class Scalar> +Matrix<Scalar> dzDot(const Vector<Scalar>& z, const Vector<Scalar>& dH) { + Real z² = z.squaredNorm(); + return (dH.conjugate() - (dH.dot(z) / z²) * z.conjugate()) * z.adjoint() / z²; +} + +template <class Scalar> +Matrix<Scalar> dzDotConjugate(const Vector<Scalar>& z, const Vector<Scalar>& dH, const Matrix<Scalar>& ddH) { + Real z² = z.squaredNorm(); + return -ddH + (ddH * z.conjugate()) * z.transpose() / z² + + (z.dot(dH) / z²) * ( + Matrix<Scalar>::Identity(ddH.rows(), ddH.cols()) - z.conjugate() * z.transpose() / z² + ); +} |