-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_matvec.cpp
52 lines (40 loc) · 1.1 KB
/
test_matvec.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "matvec.hpp"
#include "tensor.hpp"
void check(bool condition, const std::string& msg)
{
if (!condition)
{
std::cout << "FAILED: " << msg << "\n";
}
else
{
std::cout << "PASSED: " << msg << "\n";
}
}
void test_matvec(std::vector< std::pair< bool, std::string > >& results)
{
Matrix< int > A("data/matrix");
Vector< int > x("data/vector_in");
Vector< int > y_read("data/vector_out");
std::cout << A.tensor() << std::endl;
std::cout << x.tensor() << std::endl;
std::cout << y_read.tensor() << std::endl;
auto y_comp = matvec(A, x);
results.push_back({y_comp.tensor() == y_read.tensor(), "test_matvec: result equal to file"});
}
int main()
{
std::vector< std::pair< bool, std::string > > results;
test_matvec(results);
size_t passed = 0;
for (auto [condition, msg] : results)
{
check(condition, msg);
if (condition)
{
passed++;
}
}
std::cout << "--- " << passed << "/" << results.size() << " checks passed ---" << std::endl;
return passed != results.size();
}