[mlpack-svn] r11340 - mlpack/trunk/src/mlpack/tests
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Wed Feb 1 19:53:18 EST 2012
Author: rcurtin
Date: 2012-02-01 19:53:17 -0500 (Wed, 01 Feb 2012)
New Revision: 11340
Modified:
mlpack/trunk/src/mlpack/tests/nca_test.cpp
Log:
Apparently, when I wrote this, I did not understand how floating point numbers
worked.
Modified: mlpack/trunk/src/mlpack/tests/nca_test.cpp
===================================================================
--- mlpack/trunk/src/mlpack/tests/nca_test.cpp 2012-02-01 23:21:17 UTC (rev 11339)
+++ mlpack/trunk/src/mlpack/tests/nca_test.cpp 2012-02-02 00:53:17 UTC (rev 11340)
@@ -44,7 +44,7 @@
if (row == col)
BOOST_REQUIRE_CLOSE(initialPoint(row, col), 1.0, 1e-5);
else
- BOOST_REQUIRE(initialPoint(row, col) == 0.0);
+ BOOST_REQUIRE_SMALL(initialPoint(row, col), 1e-5);
}
}
}
@@ -84,14 +84,15 @@
SoftmaxErrorFunction<SquaredEuclideanDistance> sef(data, labels);
arma::mat gradient;
- sef.Gradient(arma::eye<arma::mat>(2, 2), gradient);
+ arma::mat coordinates = arma::eye<arma::mat>(2, 2);
+ sef.Gradient(coordinates, gradient);
// Results painstakingly calculated by hand by rcurtin (recorded forever in
// his notebook). As a result of lack of precision of the by-hand result, the
// tolerance is fairly high.
BOOST_REQUIRE_CLOSE(gradient(0, 0), -0.089766, 0.05);
- BOOST_REQUIRE(gradient(1, 0) == 0.0);
- BOOST_REQUIRE(gradient(0, 1) == 0.0);
+ BOOST_REQUIRE_SMALL(gradient(1, 0), 1e-5);
+ BOOST_REQUIRE_SMALL(gradient(0, 1), 1e-5);
BOOST_REQUIRE_CLOSE(gradient(1, 1), 1.63823, 0.01);
}
@@ -130,10 +131,10 @@
arma::mat gradient;
sef.Gradient(arma::eye<arma::mat>(2, 2), gradient);
- BOOST_REQUIRE(gradient(0, 0) == 0.0);
- BOOST_REQUIRE(gradient(0, 1) == 0.0);
- BOOST_REQUIRE(gradient(1, 0) == 0.0);
- BOOST_REQUIRE(gradient(1, 1) == 0.0);
+ BOOST_REQUIRE_SMALL(gradient(0, 0), 1e-5);
+ BOOST_REQUIRE_SMALL(gradient(0, 1), 1e-5);
+ BOOST_REQUIRE_SMALL(gradient(1, 0), 1e-5);
+ BOOST_REQUIRE_SMALL(gradient(1, 1), 1e-5);
}
//
More information about the mlpack-svn
mailing list