12#ifndef MLPACK_TESTS_MAIN_TESTS_RANGE_SEARCH_TEST_UTILS_HPP
13#define MLPACK_TESTS_MAIN_TESTS_RANGE_SEARCH_TEST_UTILS_HPP
18#include "../catch.hpp"
27 std::ostringstream oss;
28 boost::archive::text_oarchive oa(oss);
42 std::vector<std::vector<double>>& vec2,
43 const double tolerance = 1e-3)
45 REQUIRE(vec1.size() == vec2.size());
46 for (
size_t i = 0; i < vec1.size(); ++i)
48 REQUIRE(vec1[i].size() == vec2[i].size());
49 std::sort(vec1[i].begin(), vec1[i].end());
50 std::sort(vec2[i].begin(), vec2[i].end());
51 for (
size_t j = 0 ; j < vec1[i].size(); ++j)
53 REQUIRE(vec1[i][j] == Approx(vec2[i][j]).epsilon(tolerance));
65 std::vector<std::vector<size_t>>& vec2)
67 REQUIRE(vec1.size() == vec2.size());
68 for (
size_t i = 0; i < vec1.size(); ++i)
70 REQUIRE(vec1[i].size() == vec2[i].size());
71 std::sort(vec1[i].begin(), vec1[i].end());
72 std::sort(vec2[i].begin(), vec2[i].end());
73 for (
size_t j = 0; j < vec1[i].size(); ++j)
75 REQUIRE(vec1[i][j] == vec2[i][j]);
88std::vector<std::vector<T>>
ReadData(
const std::string& filename)
90 std::ifstream ifs(filename);
91 std::vector<std::vector<T>> table;
93 while (std::getline(ifs, line))
95 std::vector<T> numbers;
97 std::replace(line.begin(), line.end(),
',',
' ');
98 std::istringstream stm(line);
100 numbers.push_back(n);
101 table.push_back(numbers);
Include all of the base components required to write mlpack methods, and the main mlpack Doxygen docu...
std::string ModelToString(RSModel *model)
Convert a model to a string using the text_oarchive of boost::serialization.
std::vector< std::vector< T > > ReadData(const std::string &filename)
Load a CSV file into a vector of vector with a templated datatype.
void CheckMatrices(std::vector< std::vector< double > > &vec1, std::vector< std::vector< double > > &vec2, const double tolerance=1e-3)
Check that 2 matrices of type vector<vector<double>> are close to equal, using the given tolerance.