1 //Copyright (c) 2008-2016 Emil Dotchevski and Reverge Studios, Inc.
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)
6 #ifndef BOOST_QVM_FA3ED0DCA17911DEA6BBA09955D89593
7 #define BOOST_QVM_FA3ED0DCA17911DEA6BBA09955D89593
9 #include <boost/qvm/inline.hpp>
10 #include <boost/qvm/deduce_mat.hpp>
11 #include <boost/qvm/detail/remove_const.hpp>
12 #include <boost/qvm/assert.hpp>
20 template <class T,int R,int Q,int C>
22 mat_traits<T[R][Q][C]>
24 static int const rows=0;
25 static int const cols=0;
26 typedef void scalar_type;
29 template <class T,int Rows,int Cols>
31 mat_traits<T[Rows][Cols]>
33 typedef T this_matrix[Rows][Cols];
34 typedef typename qvm_detail::remove_const<T>::type scalar_type;
35 static int const rows=Rows;
36 static int const cols=Cols;
38 template <int Row,int Col>
40 BOOST_QVM_INLINE_CRITICAL
42 read_element( this_matrix const & x )
44 BOOST_QVM_STATIC_ASSERT(Row>=0);
45 BOOST_QVM_STATIC_ASSERT(Row<Rows);
46 BOOST_QVM_STATIC_ASSERT(Col>=0);
47 BOOST_QVM_STATIC_ASSERT(Col<Cols);
51 template <int Row,int Col>
53 BOOST_QVM_INLINE_CRITICAL
55 write_element( this_matrix & x )
57 BOOST_QVM_STATIC_ASSERT(Row>=0);
58 BOOST_QVM_STATIC_ASSERT(Row<Rows);
59 BOOST_QVM_STATIC_ASSERT(Col>=0);
60 BOOST_QVM_STATIC_ASSERT(Col<Cols);
65 BOOST_QVM_INLINE_CRITICAL
67 read_element_idx( int row, int col, this_matrix const & x )
69 BOOST_QVM_ASSERT(row>=0);
70 BOOST_QVM_ASSERT(row<Rows);
71 BOOST_QVM_ASSERT(col>=0);
72 BOOST_QVM_ASSERT(col<Cols);
77 BOOST_QVM_INLINE_CRITICAL
79 write_element_idx( int row, int col, this_matrix & x )
81 BOOST_QVM_ASSERT(row>=0);
82 BOOST_QVM_ASSERT(row<Rows);
83 BOOST_QVM_ASSERT(col>=0);
84 BOOST_QVM_ASSERT(col<Cols);
89 template <class T,int Rows,int Cols,int R,int C>
91 deduce_mat<T[Rows][Cols],R,C>
93 typedef mat<T,R,C> type;
96 template <class T,int Rows,int Cols,int R,int C>
98 deduce_mat<T const[Rows][Cols],R,C>
100 typedef mat<T,R,C> type;
103 template <class T1,class T2,int Rows,int Cols,int R,int C>
105 deduce_mat2<T1[Rows][Cols],T2[Rows][Cols],R,C>
107 typedef mat<typename deduce_scalar<T1,T2>::type,R,C> type;
110 template <int Rows,int Cols,class T>
111 T (&ptr_mref( T * ptr ))[Rows][Cols]
113 return *reinterpret_cast<T (*)[Rows][Cols]>(ptr);