-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.cpp
More file actions
101 lines (101 loc) · 3.15 KB
/
Copy pathtest.cpp
File metadata and controls
101 lines (101 loc) · 3.15 KB
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
#include "ols.h"
#include <iostream>
#include <vector>
int main()
{
if (0)
{
// std::vector<std::vector<int>> OA = {{1, 1, 1, 2, 2, 2, 3, 3, 3},
// {1, 2, 3, 1, 2, 3, 1, 2, 3},
// {1, 2, 3, 3, 1, 2, 2, 3, 1},
// {1, 2, 3, 2, 3, 1, 3, 1, 2}};
std::vector<std::vector<int>> OA = {{1, 2, 3, 2, 3, 1, 3, 1, 2},
{1, 2, 3, 3, 1, 2, 2, 3, 1},
{1, 1, 1, 2, 2, 2, 3, 3, 3},
{1, 2, 3, 1, 2, 3, 1, 2, 3}};
auto nOA = OLS::formatOA(OA);
for (int i = 0; i < nOA.size(); i++)
{
for (int j = 0; j < nOA[i].size(); j++)
printf("%d ", nOA[i][j]);
printf("\n");
}
printf("\n");
auto [L1, L2] = OLS::genOLSbyOA(OA);
for (int i = 0; i < L1.size(); i++)
{
for (int j = 0; j < L1[i].size(); j++)
printf("%d ", L1[i][j]);
printf("\n");
}
printf("\n");
for (int i = 0; i < L2.size(); i++)
{
for (int j = 0; j < L2[i].size(); j++)
printf("%d ", L2[i][j]);
printf("\n");
}
printf("\n");
}
if (0)
{
auto OLS_3_check = [&](int n)
{
auto [L1, L2, L3] = OLS::constructOLS3(n);
assert(OLS::checkOLS(L1, L2, n));
assert(OLS::checkOLS(L1, L3, n));
assert(OLS::checkOLS(L2, L3, n));
for (int i = 0; i < L1.size(); i++)
{
for (int j = 0; j < L1[i].size(); j++)
printf("%d ", L1[i][j]);
printf("\n");
}
printf("\n");
for (int i = 0; i < L2.size(); i++)
{
for (int j = 0; j < L2[i].size(); j++)
printf("%d ", L2[i][j]);
printf("\n");
}
printf("\n");
for (int i = 0; i < L3.size(); i++)
{
for (int j = 0; j < L3[i].size(); j++)
printf("%d ", L3[i][j]);
printf("\n");
}
printf("\n");
};
OLS_3_check(4);
OLS_3_check(5);
OLS_3_check(8);
OLS_3_check(9);
OLS_3_check(12);
OLS_3_check(24);
}
if (1)
{
std::vector<int> failTests;
for (int n = 1; n <= 500; n++)
{
if (n == 2 || n == 6) // n = 2 and n = 6 are not orthogonal
continue;
auto [L1, L2] = OLS::constructOLS(n);
if (OLS::checkOLS(L1, L2, n))
printf("n = %d: orthogonal passed\n", n);
else
printf("n = %d: orthogonal failed\n", n), failTests.emplace_back(n);
}
if (failTests.empty())
printf("All tests passed\n");
else
{
printf("Failed tests: ");
for (int n : failTests)
printf("%d ", n);
printf("\n");
}
}
return 0;
}