summaryrefslogtreecommitdiff
path: root/topology.cpp
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2024-08-18 13:43:42 +0200
committerJaron Kent-Dobias <jaron@kent-dobias.com>2024-08-18 13:43:42 +0200
commit0b5c9d6993caa78bf9a8e63f0e562aca7019d378 (patch)
tree05c26af144e536a4ce46aae08c5bac2da445cbf3 /topology.cpp
parente60253db53b0e4f98309a5293be00aa44a52c6db (diff)
downloadcode-0b5c9d6993caa78bf9a8e63f0e562aca7019d378.tar.gz
code-0b5c9d6993caa78bf9a8e63f0e562aca7019d378.tar.bz2
code-0b5c9d6993caa78bf9a8e63f0e562aca7019d378.zip
Added linear model.
Diffstat (limited to 'topology.cpp')
-rw-r--r--topology.cpp22
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;