12 #ifndef MLPACK_TESTS_TEST_CATCH_TOOLS_HPP 13 #define MLPACK_TESTS_TEST_CATCH_TOOLS_HPP 21 #define REQUIRE_RELATIVE_ERR(L, R, E) \ 22 REQUIRE(std::abs((R) - (L)) <= (E) * std::abs(R)) 27 double tolerance = 1e-5)
29 REQUIRE(a.n_rows == b.n_rows);
30 REQUIRE(a.n_cols == b.n_cols);
32 for (
size_t i = 0; i < a.n_elem; ++i)
34 if (std::abs(a[i]) < tolerance / 2)
35 REQUIRE(b[i] == Approx(0.0).margin(tolerance / 2));
37 REQUIRE(a[i] == Approx(b[i]).epsilon(tolerance / 100));
43 const arma::Mat<size_t>& b)
45 REQUIRE(a.n_rows == b.n_rows);
46 REQUIRE(a.n_cols == b.n_cols);
48 for (
size_t i = 0; i < a.n_elem; ++i)
49 REQUIRE(a[i] == b[i]);
52 template <
typename FieldType,
54 arma::is_arma_type<typename FieldType::object_type>::value>>
59 REQUIRE(a.n_rows == b.n_rows);
60 REQUIRE(a.n_cols == b.n_cols);
62 for (
size_t i = 0; i < a.n_slices; ++i)
69 double tolerance = 1e-5)
71 REQUIRE(a.n_rows == b.n_rows);
72 REQUIRE(a.n_cols == b.n_cols);
73 REQUIRE(a.n_slices == b.n_slices);
75 for (
size_t i = 0; i < a.n_elem; ++i)
77 if (std::abs(a[i]) < tolerance / 2)
78 REQUIRE(b[i] == Approx(0.0).margin(tolerance / 2));
80 REQUIRE(a[i] == Approx(b[i]).epsilon(tolerance / 100));
87 double tolerance = 1e-5)
89 bool areDifferent =
false;
92 if (a.n_rows == b.n_rows && a.n_cols == b.n_cols)
94 for (
size_t i = 0; i < a.n_elem; ++i)
96 if (std::abs(a[i]) < tolerance / 2 &&
102 else if (std::abs(a[i] - b[i]) > tolerance)
113 FAIL(
"The matrices are equal.");
118 const arma::Mat<size_t>& b)
120 bool areDifferent =
false;
123 if (a.n_rows == b.n_rows && a.n_cols == b.n_cols)
125 for (
size_t i = 0; i < a.n_elem; ++i)
138 FAIL(
"The matrices are equal.");
144 double tolerance = 1e-5)
146 bool areDifferent =
false;
149 if (a.n_rows == b.n_rows && a.n_cols == b.n_cols &&
150 a.n_slices == b.n_slices)
152 for (
size_t i = 0; i < a.n_elem; ++i)
154 if (std::abs(a[i]) < tolerance / 2 &&
155 b[i] > tolerance / 2)
160 else if (std::abs(a[i] - b[i]) > tolerance)
171 FAIL(
"The matrices are equal.");
178 std::string fileName;
179 for (
auto it = inputString.rbegin(); it != inputString.rend() &&
180 fileName.size() != 32; ++it)
182 if (std::isalnum(*it))
183 fileName.push_back(*it);
typename enable_if< B, T >::type enable_if_t
Include all of the base components required to write mlpack methods, and the main mlpack Doxygen docu...