-
Notifications
You must be signed in to change notification settings - Fork 1
/
amx.test_data.h
149 lines (123 loc) · 3.38 KB
/
amx.test_data.h
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#pragma once
#include <iosfwd>
#include <iostream> //std::cout
#include <sstream>
#include <string>
#include "amx.amx_matrix.h"
#include "amx.matrix.h"
namespace amx {
template <typename T1, typename T2>
struct test_data {
Matrix<T1> src1_;
Matrix<T1> src2_;
Matrix<T2> exp_;
[[nodiscard]] std::string pretty_print(bool colour = true) const {
std::stringstream ss;
ss << "src1: " << this->src1_.pretty_print(colour) << std::endl;
ss << "src2: " << this->src2_.pretty_print(colour) << std::endl;
ss << "exp: " << this->exp_.pretty_print(colour) << std::endl;
return ss.str();
}
};
// create test data 1. used wolfram-alpha:
// {{1, 2, 3}, {3, 2, 1}, {1, 2, 3}, {1, 1, 1}, {2, 2, 2}} . {{4, 5, 6, 2}, {6, 5, 4, 1}, {3, 6, 5, 2}}
// gives {{25, 33, 29, 10}, {27, 31, 31, 10}, {25, 33, 29, 10}, {13, 16, 15, 5}, {26, 32, 30, 10}}
// but then when src2 is transposed.
template <typename T1, typename T2> [[nodiscard]]
test_data<T1, T2> createTD1()
{
test_data<T1, T2> result{};
constexpr int M = 5;
constexpr int N = 4;
constexpr int K = 3;
result.src1_ = Matrix<T1>(K, M, 0);
{
result.src1_.set(0, 0, 1);
result.src1_.set(1, 0, 2);
result.src1_.set(2, 0, 3);
result.src1_.set(0, 1, 3);
result.src1_.set(1, 1, 2);
result.src1_.set(2, 1, 1);
result.src1_.set(0, 2, 1);
result.src1_.set(1, 2, 2);
result.src1_.set(2, 2, 3);
result.src1_.set(0, 3, 1);
result.src1_.set(1, 3, 1);
result.src1_.set(2, 3, 1);
result.src1_.set(0, 4, 2);
result.src1_.set(1, 4, 2);
result.src1_.set(2, 4, 2);
}
result.src2_ = Matrix<T1>(N, K, 0);
{
result.src2_.set(0, 0, 4);
result.src2_.set(1, 0, 5);
result.src2_.set(2, 0, 6);
result.src2_.set(3, 0, 2);
result.src2_.set(0, 1, 6);
result.src2_.set(1, 1, 5);
result.src2_.set(2, 1, 4);
result.src2_.set(3, 1, 1);
result.src2_.set(0, 2, 3);
result.src2_.set(1, 2, 6);
result.src2_.set(2, 2, 5);
result.src2_.set(3, 2, 2);
}
result.exp_ = Matrix<T2>(N, M, 0);
{
result.exp_.set(0, 0, 25);
result.exp_.set(1, 0, 33);
result.exp_.set(2, 0, 29);
result.exp_.set(3, 0, 10);
result.exp_.set(0, 1, 27);
result.exp_.set(1, 1, 31);
result.exp_.set(2, 1, 31);
result.exp_.set(3, 1, 10);
result.exp_.set(0, 2, 25);
result.exp_.set(1, 2, 33);
result.exp_.set(2, 2, 29);
result.exp_.set(3, 2, 10);
result.exp_.set(0, 3, 13);
result.exp_.set(1, 3, 16);
result.exp_.set(2, 3, 15);
result.exp_.set(3, 3, 5);
result.exp_.set(0, 4, 26);
result.exp_.set(1, 4, 32);
result.exp_.set(2, 4, 30);
result.exp_.set(3, 4, 10);
}
return result;
};
template <typename T1, typename T2> [[nodiscard]]
test_data<T1, T2> createTD2()
{
test_data<T1, T2> result{};
//constexpr int M = 5;
//constexpr int N = 4;
//constexpr int K = 3;
constexpr int M = 16;
constexpr int N = 16;
constexpr int K = 64;
const int row = 0;
result.src1_ = AmxMatrix<T1>(K, M, 0);
{
result.src1_.set(8, 2, 2);//Q
}
result.src2_ = AmxMatrix<T1>(K, N, 0);
{
//result.src2_.set((0 * 16) + 8, 8, 3);
for (int j = 16; j < 64; ++j) {
result.src2_.set(j, 2, 3);
}
result.src2_.set(16, 2, 5);
//result.src2_.set((1 * 16) + 0, row+1, 5);
//result.src2_.set((2 * 16) + 0, row+1, 7);
}
result.exp_ = AmxMatrix<T2>(N, M, 0);
{
result.exp_.set(0, 0, 3);
result.exp_.set(0, 4, 3);
}
return std::move(result);
};
}