12#ifndef MLPACK_TESTS_TEST_TOOLS_HPP
13#define MLPACK_TESTS_TEST_TOOLS_HPP
16#include <boost/version.hpp>
20#define REQUIRE_RELATIVE_ERR(L, R, E) \
21 BOOST_REQUIRE_LE(std::abs((R) - (L)), (E) * std::abs(R))
26 double tolerance = 1e-5)
28 BOOST_REQUIRE_EQUAL(a.n_rows, b.n_rows);
29 BOOST_REQUIRE_EQUAL(a.n_cols, b.n_cols);
31 for (
size_t i = 0; i < a.n_elem; ++i)
33 if (std::abs(a[i]) < tolerance / 2)
34 BOOST_REQUIRE_SMALL(b[i], tolerance / 2);
36 BOOST_REQUIRE_CLOSE(a[i], b[i], tolerance);
42 const arma::Mat<size_t>& b)
44 BOOST_REQUIRE_EQUAL(a.n_rows, b.n_rows);
45 BOOST_REQUIRE_EQUAL(a.n_cols, b.n_cols);
47 for (
size_t i = 0; i < a.n_elem; ++i)
48 BOOST_REQUIRE_EQUAL(a[i], b[i]);
54 double tolerance = 1e-5)
56 BOOST_REQUIRE_EQUAL(a.n_rows, b.n_rows);
57 BOOST_REQUIRE_EQUAL(a.n_cols, b.n_cols);
58 BOOST_REQUIRE_EQUAL(a.n_slices, b.n_slices);
60 for (
size_t i = 0; i < a.n_elem; ++i)
62 if (std::abs(a[i]) < tolerance / 2)
63 BOOST_REQUIRE_SMALL(b[i], tolerance / 2);
65 BOOST_REQUIRE_CLOSE(a[i], b[i], tolerance);
72 double tolerance = 1e-5)
74 bool areDifferent =
false;
77 if (a.n_rows == b.n_rows && a.n_cols == b.n_cols)
79 for (
size_t i = 0; i < a.n_elem; ++i)
81 if (std::abs(a[i]) < tolerance / 2 &&
87 else if (std::abs(a[i] - b[i]) > tolerance)
98 BOOST_ERROR(
"The matrices are equal.");
103 const arma::Mat<size_t>& b)
105 bool areDifferent =
false;
108 if (a.n_rows == b.n_rows && a.n_cols == b.n_cols)
110 for (
size_t i = 0; i < a.n_elem; ++i)
123 BOOST_ERROR(
"The matrices are equal.");
129 double tolerance = 1e-5)
131 bool areDifferent =
false;
134 if (a.n_rows == b.n_rows && a.n_cols == b.n_cols &&
135 a.n_slices == b.n_slices)
137 for (
size_t i = 0; i < a.n_elem; ++i)
139 if (std::abs(a[i]) < tolerance / 2 &&
140 b[i] > tolerance / 2)
145 else if (std::abs(a[i] - b[i]) > tolerance)
156 BOOST_ERROR(
"The matrices are equal.");
163 std::string fileName;
164 for (
auto it = inputString.rbegin(); it != inputString.rend() &&
165 fileName.size() != 32; ++it)
167 if (std::isalnum(*it))
168 fileName.push_back(*it);
Include all of the base components required to write mlpack methods, and the main mlpack Doxygen docu...