1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- #include "ra/test.hh"
- using std::cout, std::endl, ra::TestRecorder;
- int main()
- {
- int N = 4;
- ra::Big<float, 3> A({N, N, N}, ra::_2 + ra::_1*4 + ra::_0*16);
- ra::Big<float, 2> B({N, N}, ra::_1 + ra::_0*4);
- ra::Big<float, 1> C({N}, ra::_0);
- cout << "A: " << N << endl;
- cout << "B: " << N << endl;
- cout << "C: " << N << endl;
- auto i = ra::iota(2, 1);
- auto j = ra::map([](int i) { return i; }, i);
- ra::Small<int, 2> k { 1, 2 };
- auto l = std::array<int, 2> { 1, 2 };
- auto ll = ra::ptr(l);
-
- cout << "X0: " << ra::from([](int i, int j, int k) { return ra::Small<int, 3>{i, j, k}; }, i, i, i) << endl;
- cout << "X1: " << ra::from([](int i, int j, int k) { return ra::Small<int, 3>{i, j, k}; }, j, j, j) << endl;
- cout << "X2: " << ra::from([](int i, int j, int k) { return ra::Small<int, 3>{i, j, k}; }, k, k, k) << endl;
- cout << "X3: " << ra::from([](int i, int j, int k) { return ra::Small<int, 3>{i, j, k}; }, ra::ptr(l), ra::ptr(l), ra::ptr(l)) << endl;
- cout << "X4: " << ra::from([](int i, int j, int k) { return ra::Small<int, 3>{i, j, k}; }, l, l, l) << endl;
- cout << "X5: " << ra::from([](int i, int j, int k) { return ra::Small<int, 3>{i, j, k}; }, ll, ll, ll) << endl;
- cout << endl;
- cout << "Y0: " << ra::from(A, i, i, i) << endl;
- cout << "Y1: " << ra::from(A, j, j, j) << endl;
- cout << "Y2: " << ra::from(A, k, k, k) << endl;
- cout << "Y3: " << ra::from(A, ra::ptr(l), ra::ptr(l), ra::ptr(l)) << endl;
- cout << "Y4: " << ra::from(A, l, l, l) << endl;
- cout << "Y5: " << ra::from(A, ll, ll, ll) << endl;
- cout << B(i, i) << endl;
- TestRecorder tr(std::cout);
- tr.section("subs 1");
- {
- ra::Small<int, 2> ref1 {1, 2};
- tr.test_eq(ref1, C(i));
- tr.test_eq(ref1, C(j));
- tr.test_eq(ref1, C(k));
- tr.test_eq(ref1, C(ra::ptr(l)));
- tr.info("ll").test_eq(ref1, C(ll));
- }
- tr.section("subs 2");
- {
- ra::Small<int, 2, 2> ref2 {5, 6, 9, 10};
- tr.test_eq(ref2, B(i, i));
- tr.test_eq(ref2, B(j, j));
- tr.test_eq(ref2, B(k, k));
- tr.test_eq(ref2, B(ra::ptr(l), ra::ptr(l)));
- tr.test_eq(ref2, B(l, l));
- tr.info("ll").test_eq(ref2, B(ll, ll));
- }
- tr.section("subs 3");
- {
- ra::Small<int, 2, 2, 2> ref3 {21, 22, 25, 26, 37, 38, 41, 42};
- tr.test_eq(ref3, A(i, i, i));
- tr.test_eq(ref3, A(j, j, j));
- tr.test_eq(ref3, A(k, k, k));
- tr.test_eq(ref3, A(ra::ptr(l), ra::ptr(l), ra::ptr(l)));
- tr.test_eq(ref3, A(l, l, l));
- tr.info("ll").test_eq(ref3, A(ll, ll, ll));
- }
- return tr.summary();
- }
|