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 UUID_90273D9C0E5911E281B7981F6288709B
7 #define UUID_90273D9C0E5911E281B7981F6288709B
9 #include <boost/qvm/mat_traits.hpp>
10 #include <boost/qvm/inline.hpp>
11 #include <boost/qvm/assert.hpp>
12 #include <boost/qvm/enable_if.hpp>
13 #include <boost/qvm/error.hpp>
14 #include <boost/exception/info.hpp>
22 ////////////////////////////////////////////////
27 template <int R,int C>
29 mat_index_read_defined
31 static bool const value=false;
34 template <int I,int N>
40 BOOST_QVM_INLINE_CRITICAL
41 typename mat_traits<A>::scalar_type
42 read_element_idx( A const & a, int r, int c )
44 return (I/mat_traits<A>::cols)==r && (I%mat_traits<A>::cols)==c?
45 mat_traits<A>::template read_element<I/mat_traits<A>::cols,I%mat_traits<A>::cols>(a) :
46 matrix_r<I+1,N>::read_element_idx(a,r,c);
56 BOOST_QVM_INLINE_TRIVIAL
57 typename mat_traits<A>::scalar_type
58 read_element_idx( A const & a, int, int )
61 return mat_traits<A>::template read_element<0,0>(a);
67 BOOST_QVM_INLINE_TRIVIAL
68 typename boost::enable_if_c<
70 !qvm_detail::mat_index_read_defined<mat_traits<A>::rows,mat_traits<A>::cols>::value,
71 typename mat_traits<A>::scalar_type>::type
72 mat_index_read( A const & a, int r, int c )
74 return qvm_detail::matrix_r<0,mat_traits<A>::rows*mat_traits<A>::cols>::read_element_idx(a,r,c);
77 ////////////////////////////////////////////////
82 template <int R,int C>
84 mat_index_write_defined
86 static bool const value=false;
89 template <int I,int N>
95 BOOST_QVM_INLINE_CRITICAL
96 typename mat_traits<A>::scalar_type &
97 write_element_idx( A & a, int r, int c )
99 return (I/mat_traits<A>::cols)==r && (I%mat_traits<A>::cols)==c?
100 mat_traits<A>::template write_element<I/mat_traits<A>::cols,I%mat_traits<A>::cols>(a) :
101 matrix_w<I+1,N>::write_element_idx(a,r,c);
111 BOOST_QVM_INLINE_TRIVIAL
112 typename mat_traits<A>::scalar_type &
113 write_element_idx( A & a, int, int )
116 return mat_traits<A>::template write_element<0,0>(a);
122 BOOST_QVM_INLINE_TRIVIAL
123 typename boost::enable_if_c<
125 !qvm_detail::mat_index_write_defined<mat_traits<A>::rows,mat_traits<A>::cols>::value,
126 typename mat_traits<A>::scalar_type &>::type
127 mat_index_write( A & a, int r, int c )
129 return qvm_detail::matrix_w<0,mat_traits<A>::rows*mat_traits<A>::cols>::write_element_idx(a,r,c);
132 ////////////////////////////////////////////////
137 using ::boost::qvm::mat_index_read;
138 using ::boost::qvm::mat_index_write;
141 ////////////////////////////////////////////////