| 1 | // Copyright 2008-2022 Emil Dotchevski and Reverge Studios, Inc. |
| 2 | |
| 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying |
| 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 5 | |
| 6 | #ifdef BOOST_QVM_TEST_SINGLE_HEADER |
| 7 | # include BOOST_QVM_TEST_SINGLE_HEADER |
| 8 | #else |
| 9 | # include <boost/qvm/map_mat_mat.hpp> |
| 10 | # include <boost/qvm/mat_operations.hpp> |
| 11 | # include <boost/qvm/mat.hpp> |
| 12 | #endif |
| 13 | |
| 14 | #include <boost/qvm/mat_traits_array.hpp> |
| 15 | #include "test_qvm.hpp" |
| 16 | #include "test_qvm_matrix.hpp" |
| 17 | #include "gold.hpp" |
| 18 | |
| 19 | namespace |
| 20 | { |
| 21 | template <int Rows,int Cols,int R1,int R2> |
| 22 | void |
| 23 | test() |
| 24 | { |
| 25 | using namespace boost::qvm; |
| 26 | test_qvm::matrix<M1,Rows,Cols> x(42,1); |
| 27 | float r1[Rows][Cols]; |
| 28 | for( int i=0; i!=Rows; ++i ) |
| 29 | for( int j=0; j!=Cols; ++j ) |
| 30 | r1[i][j]=x.a[i==R1?R2:i==R2?R1:i][j]; |
| 31 | float r2[Rows][Cols]; |
| 32 | assign(r2,swap_rows<R1,R2>(x)); |
| 33 | BOOST_QVM_TEST_EQ(r1,r2); |
| 34 | swap_rows<R1,R2>(x) *= 2; |
| 35 | for( int i=0; i!=Rows; ++i ) |
| 36 | for( int j=0; j!=Cols; ++j ) |
| 37 | r1[i][j]=x.a[i==R1?R2:i==R2?R1:i][j]; |
| 38 | assign(r2,swap_rows<R1,R2>(x)); |
| 39 | BOOST_QVM_TEST_EQ(r1,r2); |
| 40 | swap_rows<R1,R2>(x)+swap_rows<R1,R2>(x); |
| 41 | -swap_rows<R1,R2>(x); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | int |
| 46 | main() |
| 47 | { |
| 48 | test<2,2,0,0>(); |
| 49 | test<2,2,0,1>(); |
| 50 | test<2,2,1,0>(); |
| 51 | test<2,2,1,1>(); |
| 52 | |
| 53 | test<3,3,0,0>(); |
| 54 | test<3,3,0,1>(); |
| 55 | test<3,3,0,2>(); |
| 56 | test<3,3,1,0>(); |
| 57 | test<3,3,1,1>(); |
| 58 | test<3,3,1,2>(); |
| 59 | test<3,3,2,0>(); |
| 60 | test<3,3,2,1>(); |
| 61 | test<3,3,2,2>(); |
| 62 | |
| 63 | test<4,4,0,0>(); |
| 64 | test<4,4,0,1>(); |
| 65 | test<4,4,0,2>(); |
| 66 | test<4,4,0,3>(); |
| 67 | test<4,4,1,0>(); |
| 68 | test<4,4,1,1>(); |
| 69 | test<4,4,1,2>(); |
| 70 | test<4,4,1,3>(); |
| 71 | test<4,4,2,0>(); |
| 72 | test<4,4,2,1>(); |
| 73 | test<4,4,2,2>(); |
| 74 | test<4,4,2,3>(); |
| 75 | test<4,4,3,0>(); |
| 76 | test<4,4,3,1>(); |
| 77 | test<4,4,3,2>(); |
| 78 | test<4,4,3,3>(); |
| 79 | |
| 80 | test<5,5,0,0>(); |
| 81 | test<5,5,0,1>(); |
| 82 | test<5,5,0,2>(); |
| 83 | test<5,5,0,3>(); |
| 84 | test<5,5,0,4>(); |
| 85 | test<5,5,1,0>(); |
| 86 | test<5,5,1,1>(); |
| 87 | test<5,5,1,2>(); |
| 88 | test<5,5,1,3>(); |
| 89 | test<5,5,1,4>(); |
| 90 | test<5,5,2,0>(); |
| 91 | test<5,5,2,1>(); |
| 92 | test<5,5,2,2>(); |
| 93 | test<5,5,2,3>(); |
| 94 | test<5,5,2,4>(); |
| 95 | test<5,5,3,0>(); |
| 96 | test<5,5,3,1>(); |
| 97 | test<5,5,3,2>(); |
| 98 | test<5,5,3,3>(); |
| 99 | test<5,5,3,4>(); |
| 100 | test<5,5,4,0>(); |
| 101 | test<5,5,4,1>(); |
| 102 | test<5,5,4,2>(); |
| 103 | test<5,5,4,3>(); |
| 104 | test<5,5,4,4>(); |
| 105 | return boost::report_errors(); |
| 106 | } |
| 107 | |