From 4e0b46a727f6ea727b9e7920150609c58ce65fce Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Sat, 30 May 2015 02:00:08 -0300 Subject: Added tSNE. Code improvements. --- lamp.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lamp.cpp') diff --git a/lamp.cpp b/lamp.cpp index 90be140..b7a1027 100644 --- a/lamp.cpp +++ b/lamp.cpp @@ -2,6 +2,8 @@ #include +static const double EPSILON = 1e-3; + arma::mat mp::lamp(const arma::mat &X, const arma::uvec &sampleIndices, const arma::mat &Ys) { arma::mat projection(X.n_rows, 2); @@ -22,7 +24,7 @@ void mp::lamp(const arma::mat &X, const arma::uvec &sampleIndices, const arma::m arma::rowvec alphas(sampleSize); for (arma::uword j = 0; j < sampleSize; j++) { double dist = arma::accu(arma::square(Xs.row(j) - point)); - alphas[j] = 1. / std::max(dist, mp::EPSILON); + alphas[j] = 1. / std::max(dist, EPSILON); } double alphas_sum = arma::accu(alphas); -- cgit v1.2.3