aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Fadel <samuelfadel@gmail.com>2016-01-29 10:46:18 +0100
committerSamuel Fadel <samuelfadel@gmail.com>2016-01-29 10:46:18 +0100
commit9b3c79e34d543b78ff200d14e67d2bc96cb0995f (patch)
tree30b182bb83ba34bf4480967b0acd2d6ba4e2fe5d
parent6dabb067733e0d27d71e56b9542a13b197e2065c (diff)
Fixed issue #18.
-rw-r--r--main.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/main.cpp b/main.cpp
index 3631061..77cce74 100644
--- a/main.cpp
+++ b/main.cpp
@@ -1,6 +1,7 @@
#include <cmath>
#include <iostream>
#include <numeric>
+#include <random>
#include <string>
#include <QApplication>
@@ -21,6 +22,8 @@
#include "brushinghandler.h"
#include "projectionobserver.h"
+static const int RNG_SEED = 1;
+
static QObject *mainProvider(QQmlEngine *engine, QJSEngine *scriptEngine)
{
Q_UNUSED(engine)
@@ -32,7 +35,12 @@ static QObject *mainProvider(QQmlEngine *engine, QJSEngine *scriptEngine)
arma::uvec extractCPs(const arma::mat &X)
{
int numCPs = (int) (3 * sqrt(X.n_rows));
- return arma::randi<arma::uvec>(numCPs, arma::distr_param(0, X.n_rows - 1));
+ arma::uvec cpIndices(numCPs);
+ std::iota(cpIndices.begin(), cpIndices.end(), 0);
+ std::shuffle(cpIndices.begin(),
+ cpIndices.end(),
+ std::default_random_engine(RNG_SEED));
+ return cpIndices;
}
int main(int argc, char **argv)