1 //Copyright (c) 2008-2016 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 #ifndef BOOST_QVM_9C471450B3A611DEAF56C1F155D89593 7 #define BOOST_QVM_9C471450B3A611DEAF56C1F155D89593 8 9 #include <boost/qvm/mat_traits_defaults.hpp> 10 #include <boost/qvm/deduce_mat.hpp> 11 #include <boost/qvm/assert.hpp> 12 #include "test_qvm.hpp" 13 14 namespace 15 test_qvm 16 { 17 template <class Tag,int Rows,int Cols,class T=float> 18 struct 19 matrix 20 { 21 T a[Rows][Cols]; 22 mutable T b[Rows][Cols]; 23 24 explicit matrixtest_qvm::matrix25 matrix( T start=T(0), T step=T(0) ) 26 { 27 for( int i=0; i!=Rows; ++i ) 28 for( int j=0; j!=Cols; ++j,start+=step ) 29 a[i][j]=b[i][j]=start; 30 } 31 }; 32 33 template <int Rows,int Cols,class Tag1,class T1,class Tag2,class T2> 34 void dump_ab(matrix<Tag1,Rows,Cols,T1> const & a,matrix<Tag2,Rows,Cols,T2> const & b)35 dump_ab( matrix<Tag1,Rows,Cols,T1> const & a, matrix<Tag2,Rows,Cols,T2> const & b ) 36 { 37 detail::dump_ab(a.a,b.a); 38 } 39 } 40 41 namespace 42 boost 43 { 44 namespace 45 qvm 46 { 47 template <class Tag,int Rows,int Cols,class T> 48 struct 49 mat_traits< test_qvm::matrix<Tag,Rows,Cols,T> >: 50 mat_traits_defaults<test_qvm::matrix<Tag,Rows,Cols,T>,T,Rows,Cols> 51 { 52 typedef mat_traits_defaults<test_qvm::matrix<Tag,Rows,Cols,T>,T,Rows,Cols> base; 53 54 template <int R,int C> 55 static 56 typename base::scalar_type & write_elementboost::qvm::mat_traits57 write_element( typename base::mat_type & m ) 58 { 59 BOOST_QVM_STATIC_ASSERT(R>=0); 60 BOOST_QVM_STATIC_ASSERT(R<Rows); 61 BOOST_QVM_STATIC_ASSERT(C>=0); 62 BOOST_QVM_STATIC_ASSERT(C<Cols); 63 return m.a[R][C]; 64 } 65 66 using base::write_element_idx; 67 }; 68 69 template <class Tag,class T,int R1,int C1,int R2,int C2,int Rows,int Cols> 70 struct 71 deduce_mat2<test_qvm::matrix<Tag,R1,C1,T>,test_qvm::matrix<Tag,R2,C2,T>,Rows,Cols> 72 { 73 typedef test_qvm::matrix<Tag,Rows,Cols,T> type; 74 }; 75 } 76 } 77 78 namespace 79 { 80 struct M1; 81 struct M2; 82 struct M3; 83 } 84 85 #endif 86