12#ifndef MLPACK_TESTS_TEST_CATCH_TOOLS_HPP
13#define MLPACK_TESTS_TEST_CATCH_TOOLS_HPP
16#include <boost/version.hpp>
22#define REQUIRE_RELATIVE_ERR(L, R, E) \
23 REQUIRE(std::abs((R) - (L)) <= (E) * std::abs(R))
28 double tolerance = 1e-5)
30 REQUIRE(a.n_rows == b.n_rows);
31 REQUIRE(a.n_cols == b.n_cols);
33 for (
size_t i = 0; i < a.n_elem; ++i)
35 if (std::abs(a[i]) < tolerance / 2)
36 REQUIRE(b[i] == Approx(0.0).margin(tolerance / 2));
38 REQUIRE(a[i] == Approx(b[i]).epsilon(tolerance / 100));
44 const arma::Mat<size_t>& b)
46 REQUIRE(a.n_rows == b.n_rows);
47 REQUIRE(a.n_cols == b.n_cols);
49 for (
size_t i = 0; i < a.n_elem; ++i)
50 REQUIRE(a[i] == b[i]);
56 double tolerance = 1e-5)
58 REQUIRE(a.n_rows == b.n_rows);
59 REQUIRE(a.n_cols == b.n_cols);
60 REQUIRE(a.n_slices == b.n_slices);
62 for (
size_t i = 0; i < a.n_elem; ++i)
64 if (std::abs(a[i]) < tolerance / 2)
65 REQUIRE(b[i] == Approx(0.0).margin(tolerance / 2));
67 REQUIRE(a[i] == Approx(b[i]).epsilon(tolerance / 100));
74 double tolerance = 1e-5)
76 bool areDifferent =
false;
79 if (a.n_rows == b.n_rows && a.n_cols == b.n_cols)
81 for (
size_t i = 0; i < a.n_elem; ++i)
83 if (std::abs(a[i]) < tolerance / 2 &&
89 else if (std::abs(a[i] - b[i]) > tolerance)
100 FAIL(
"The matrices are equal.");
105 const arma::Mat<size_t>& b)
107 bool areDifferent =
false;
110 if (a.n_rows == b.n_rows && a.n_cols == b.n_cols)
112 for (
size_t i = 0; i < a.n_elem; ++i)
125 FAIL(
"The matrices are equal.");
131 double tolerance = 1e-5)
133 bool areDifferent =
false;
136 if (a.n_rows == b.n_rows && a.n_cols == b.n_cols &&
137 a.n_slices == b.n_slices)
139 for (
size_t i = 0; i < a.n_elem; ++i)
141 if (std::abs(a[i]) < tolerance / 2 &&
142 b[i] > tolerance / 2)
147 else if (std::abs(a[i] - b[i]) > tolerance)
158 FAIL(
"The matrices are equal.");
165 std::string fileName;
166 for (
auto it = inputString.rbegin(); it != inputString.rend() &&
167 fileName.size() != 32; ++it)
169 if (std::isalnum(*it))
170 fileName.push_back(*it);
Include all of the base components required to write mlpack methods, and the main mlpack Doxygen docu...