aboutsummaryrefslogtreecommitdiff
path: root/forceScheme.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'forceScheme.cpp')
-rw-r--r--forceScheme.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/forceScheme.cpp b/forceScheme.cpp
index 0dc7e34..22ab293 100644
--- a/forceScheme.cpp
+++ b/forceScheme.cpp
@@ -1,7 +1,6 @@
#include "mp.h"
#include <algorithm>
-#include <vector>
static const double EPSILON = 1e-3;
@@ -15,8 +14,9 @@ arma::mat mp::forceScheme(const arma::mat &D,
{
arma::uword n = Y.n_rows;
V i(n), j(n);
- for (arma::uword k = 0; k < n; k++)
+ for (arma::uword k = 0; k < n; k++) {
i[k] = j[k] = k;
+ }
double prevDeltaSum = 1. / 0.;
for (size_t iter = 0; iter < maxIter; iter++) {
@@ -26,8 +26,9 @@ arma::mat mp::forceScheme(const arma::mat &D,
for (V::iterator a = i.begin(); a != i.end(); a++) {
arma::shuffle(j);
for (V::iterator b = j.begin(); b != j.end(); b++) {
- if (*a == *b)
+ if (*a == *b) {
continue;
+ }
arma::rowvec direction(Y.row(*b) - Y.row(*a));
double d2 = std::max(arma::norm(direction, 2), EPSILON);
@@ -37,8 +38,9 @@ arma::mat mp::forceScheme(const arma::mat &D,
}
}
- if (fabs(prevDeltaSum - deltaSum) < tol)
+ if (fabs(prevDeltaSum - deltaSum) < tol) {
break;
+ }
prevDeltaSum = deltaSum;
}