diff options
Diffstat (limited to 'topology.cpp')
-rw-r--r-- | topology.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/topology.cpp b/topology.cpp index e89e3eb..6650ea6 100644 --- a/topology.cpp +++ b/topology.cpp @@ -60,7 +60,7 @@ public: virtual std::tuple<Vector, Matrix, Tensor> H_∂H_∂∂H(const Vector& x) const { Tensor t(M, N, N); - Tensor ∂∂H = t.setConstant(0); + Tensor ∂∂H = t.setZero(); Matrix ∂H = Matrix::Zero(M, N); Vector H = Vector::Zero(M); return {H, ∂H, ∂∂H}; @@ -143,6 +143,26 @@ public: } }; +class ExtensiveLinear : public ConstraintModel { +private: + Matrix A; + +public: + ExtensiveLinear(unsigned N, unsigned M, Real E, Rng& r) : ConstraintModel(N, M, E, r), A(M, N) { + for (Real& Aij : A.reshaped()) { + Aij = r.variate<Real, std::normal_distribution>(0, sqrt(1.0 / N)); + } + } + + std::tuple<Vector, Matrix, Tensor> H_∂H_∂∂H(const Vector& x) const override { + Tensor ∂∂H(M, N, N); + ∂∂H.setZero(); + Matrix ∂H = A; + Vector H = A * x; + return {H, ∂H, ∂∂H}; + } +}; + class ExtensiveQuadratic : public ConstraintModel { private: Tensor J; |