| 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/mat_operations.hpp> |
| 10 | # include <boost/qvm/mat.hpp> |
| 11 | #endif |
| 12 | |
| 13 | #include "test_qvm_matrix.hpp" |
| 14 | |
| 15 | namespace |
| 16 | { |
| 17 | template <class T,class U> |
| 18 | struct same_type; |
| 19 | |
| 20 | template <class T> |
| 21 | struct |
| 22 | same_type<T,T> |
| 23 | { |
| 24 | }; |
| 25 | |
| 26 | template <class T,class U> |
| 27 | void |
| 28 | check_deduction( T const &, U const & ) |
| 29 | { |
| 30 | same_type<T,typename boost::qvm::deduce_mat<U>::type>(); |
| 31 | } |
| 32 | |
| 33 | template <int Rows,int Cols> |
| 34 | void |
| 35 | test() |
| 36 | { |
| 37 | using namespace boost::qvm; |
| 38 | test_qvm::matrix<M1,Rows,Cols> m1=zero_mat<float,Rows,Cols>(); |
| 39 | for( int i=0; i!=Rows; ++i ) |
| 40 | for( int j=0; j!=Cols; ++j ) |
| 41 | BOOST_TEST(!m1.a[i][j]); |
| 42 | test_qvm::matrix<M2,Rows,Cols> m2(42,1); |
| 43 | set_zero(m2); |
| 44 | for( int i=0; i!=Rows; ++i ) |
| 45 | for( int j=0; j!=Cols; ++j ) |
| 46 | BOOST_TEST(!m2.a[i][j]); |
| 47 | check_deduction(mat<float,Rows,Cols>(),zero_mat<float,Rows,Cols>()); |
| 48 | check_deduction(mat<int,Rows,Cols>(),zero_mat<int,Rows,Cols>()); |
| 49 | } |
| 50 | |
| 51 | template <int Dim> |
| 52 | void |
| 53 | test() |
| 54 | { |
| 55 | using namespace boost::qvm; |
| 56 | test_qvm::matrix<M1,Dim,Dim> m1=zero_mat<float,Dim>(); |
| 57 | for( int i=0; i!=Dim; ++i ) |
| 58 | for( int j=0; j!=Dim; ++j ) |
| 59 | BOOST_TEST(!m1.a[i][j]); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | int |
| 64 | main() |
| 65 | { |
| 66 | test<1,2>(); |
| 67 | test<2,1>(); |
| 68 | test<2,2>(); |
| 69 | test<1,3>(); |
| 70 | test<3,1>(); |
| 71 | test<3,3>(); |
| 72 | test<1,4>(); |
| 73 | test<4,1>(); |
| 74 | test<4,4>(); |
| 75 | test<1,5>(); |
| 76 | test<5,1>(); |
| 77 | test<5,5>(); |
| 78 | test<2>(); |
| 79 | test<3>(); |
| 80 | test<4>(); |
| 81 | test<5>(); |
| 82 | return boost::report_errors(); |
| 83 | } |
| 84 | |