summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2021-01-05 11:41:24 +0100
committerJaron Kent-Dobias <jaron@kent-dobias.com>2021-01-05 11:41:24 +0100
commit29f28945a5de06d88b65865e932a0a53ada0ff2f (patch)
tree2b5fc0b4634d3aab280bf249f6c260aef700f394
parent541243f05f0830fab7dd874ce047bfe3bbe5cc4b (diff)
downloadcode-29f28945a5de06d88b65865e932a0a53ada0ff2f.tar.gz
code-29f28945a5de06d88b65865e932a0a53ada0ff2f.tar.bz2
code-29f28945a5de06d88b65865e932a0a53ada0ff2f.zip
Some helpful comments.
-rw-r--r--langevin.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/langevin.cpp b/langevin.cpp
index 119a64b..1a0e104 100644
--- a/langevin.cpp
+++ b/langevin.cpp
@@ -23,21 +23,21 @@ using Tensor = Eigen::Tensor<Scalar, PSPIN_P>;
using Rng = randutils::random_generator<pcg32>;
-Vector initializeVector(unsigned N, Rng& r) {
+Vector initializeVector(unsigned N, double a, Rng& r) {
Vector z(N);
- complex_normal_distribution<> dist(0, 1, 0);
+ complex_normal_distribution<> dist(0, a, 0);
for (unsigned i = 0; i < N; i++) {
z(i) = dist(r.engine());
}
- z *= sqrt(N) / sqrt(z.dot(z));
+ z *= sqrt(N) / sqrt(z.dot(z)); // Normalize.
return z;
}
std::tuple<Scalar, Vector, Matrix> hamGradHess(const Tensor& J, const Vector& z) {
- Matrix Jz = contractDown(J, z);
+ Matrix Jz = contractDown(J, z); // Contracts J into p - 2 copies of z.
Vector Jzz = Jz * z;
double f = factorial(p);
@@ -145,7 +145,7 @@ int main(int argc, char* argv[]) {
complex_normal_distribution<> d(0, σ, κ);
Tensor J = generateCouplings<Scalar, PSPIN_P>(N, d, r.engine());
- Vector z = initializeVector(N, r);
+ Vector z = initializeVector(N, 100, r);
std::function<bool(double, unsigned)> findSaddle = [δ](double W, unsigned) {
std::cout << W << std::endl;
@@ -161,6 +161,5 @@ int main(int argc, char* argv[]) {
Vector constraint = dH - ((double)p * H / (double)N) * zm;
- std::cout << std::endl << zm.dot(zm) << std::endl;
- std::cout << constraint.cwiseAbs2().sum() << std::endl;
+ std::cout << H / (double)N << std::endl;
}