12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- #include <iostream>
- #include <iterator>
- #include "ra/test.hh"
- #include "mpdebug.hh"
- using std::cout, std::endl, std::flush, std::tuple, ra::TestRecorder;
- using real = double;
- template <int rank=ra::ANY> using Ureal = ra::Unique<real, rank>;
- template <int rank=ra::ANY> using Uint = ra::Unique<int, rank>;
- int main()
- {
- TestRecorder tr(std::cout);
- tr.section("gcc 6.1 B");
- {
- Ureal<1> a {1, 4, 2, 3};
- Ureal<1> b({4}, 0.);
- b(3-ra::_0) = a;
- tr.test_eq(Ureal<1> {3, 2, 4, 1}, b);
- }
- tr.section("gcc 6.1 C");
- {
- Ureal<1> a = {1, 2, 3, 4};
- Uint<1> i = {3, 1, 2};
- a(i) = ra::Unique<real, 1> {7, 8, 9};
- tr.test_eq(a, Ureal<1> {1, 8, 9, 7});
- }
- tr.section("gcc 6.1 D");
- {
- ra::Big<int, 2> A({4, 4}, 0), B({4, 4}, 10*ra::_0 + ra::_1);
- using coord = ra::Small<int, 2>;
- ra::Big<coord, 1> I = { coord{1, 1}, coord{2, 2} };
- map([&A](auto && c) -> decltype(auto) { return A.at(c); }, I)
- = map([&B](auto && c) { return B.at(c); }, I);
- tr.test_eq(Ureal<2>({4, 4}, {0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 22, 0, 0, 0, 0, 0}), A);
- }
- return tr.summary();
- }
|