summaryrefslogtreecommitdiff
path: root/p-spin.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'p-spin.hpp')
-rw-r--r--p-spin.hpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/p-spin.hpp b/p-spin.hpp
index b2bdf07..e5cd195 100644
--- a/p-spin.hpp
+++ b/p-spin.hpp
@@ -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²
+ );
+}