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_FB4D5BEAC71B11E68D0EEF1707624D53
7 #define BOOST_QVM_FB4D5BEAC71B11E68D0EEF1707624D53
9 #include <boost/qvm/inline.hpp>
10 #include <boost/qvm/assert.hpp>
24 template <int I,int N>
30 BOOST_QVM_INLINE_CRITICAL
31 typename mat_traits<A>::scalar_type &
32 write_element_idx( int r, int c, A & a )
34 return (I/mat_traits<A>::cols)==r && (I%mat_traits<A>::cols)==c?
35 mat_traits<A>::template write_element<I/mat_traits<A>::cols,I%mat_traits<A>::cols>(a) :
36 matrix_w<I+1,N>::write_element_idx(r,c,a);
46 BOOST_QVM_INLINE_TRIVIAL
47 typename mat_traits<A>::scalar_type &
48 write_element_idx( int, int, A & a )
51 return mat_traits<A>::template write_element<0,0>(a);
56 template <class MatType,class ScalarType,int Rows,int Cols>
60 typedef MatType mat_type;
61 typedef ScalarType scalar_type;
62 static int const rows=Rows;
63 static int const cols=Cols;
65 template <int Row,int Col>
67 BOOST_QVM_INLINE_CRITICAL
69 read_element( mat_type const & x )
71 return mat_traits<mat_type>::template write_element<Row,Col>(const_cast<mat_type &>(x));
75 BOOST_QVM_INLINE_CRITICAL
77 read_element_idx( int r, int c, mat_type const & x )
79 return mat_traits<mat_type>::write_element_idx(r,c,const_cast<mat_type &>(x));
85 BOOST_QVM_INLINE_TRIVIAL
87 write_element_idx( int r, int c, mat_type & m )
89 return qvm_detail::matrix_w<0,mat_traits<mat_type>::rows*mat_traits<mat_type>::cols>::write_element_idx(r,c,m);