]>
Commit | Line | Data |
---|---|---|
b32b8144 FG |
1 | //Copyright (c) 2008-2016 Emil Dotchevski and Reverge Studios, Inc.\r |
2 | \r | |
3 | //Distributed under the Boost Software License, Version 1.0. (See accompanying\r | |
4 | //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\r | |
5 | \r | |
6 | #ifndef UUID_67E67D68A32F11DEA56FD18556D89593\r | |
7 | #define UUID_67E67D68A32F11DEA56FD18556D89593\r | |
8 | \r | |
9 | #include <boost/qvm/detail/mat_assign.hpp>\r | |
10 | #include <boost/qvm/assert.hpp>\r | |
11 | #include <boost/qvm/static_assert.hpp>\r | |
12 | \r | |
13 | namespace\r | |
14 | boost\r | |
15 | {\r | |
16 | namespace\r | |
17 | qvm\r | |
18 | {\r | |
19 | template <class T,int Rows,int Cols>\r | |
20 | struct\r | |
21 | mat\r | |
22 | {\r | |
23 | T a[Rows][Cols];\r | |
24 | template <class R>\r | |
25 | operator R() const\r | |
26 | {\r | |
27 | R r;\r | |
28 | assign(r,*this);\r | |
29 | return r;\r | |
30 | }\r | |
31 | };\r | |
32 | \r | |
33 | template <class M>\r | |
34 | struct mat_traits;\r | |
35 | \r | |
36 | template <class T,int Rows,int Cols>\r | |
37 | struct\r | |
38 | mat_traits< mat<T,Rows,Cols> >\r | |
39 | {\r | |
40 | typedef mat<T,Rows,Cols> this_matrix;\r | |
41 | typedef T scalar_type;\r | |
42 | static int const rows=Rows;\r | |
43 | static int const cols=Cols;\r | |
44 | \r | |
45 | template <int Row,int Col>\r | |
46 | static\r | |
47 | BOOST_QVM_INLINE_CRITICAL\r | |
48 | scalar_type\r | |
49 | read_element( this_matrix const & x )\r | |
50 | {\r | |
51 | BOOST_QVM_STATIC_ASSERT(Row>=0);\r | |
52 | BOOST_QVM_STATIC_ASSERT(Row<Rows);\r | |
53 | BOOST_QVM_STATIC_ASSERT(Col>=0);\r | |
54 | BOOST_QVM_STATIC_ASSERT(Col<Cols);\r | |
55 | return x.a[Row][Col];\r | |
56 | }\r | |
57 | \r | |
58 | template <int Row,int Col>\r | |
59 | static\r | |
60 | BOOST_QVM_INLINE_CRITICAL\r | |
61 | scalar_type &\r | |
62 | write_element( this_matrix & x )\r | |
63 | {\r | |
64 | BOOST_QVM_STATIC_ASSERT(Row>=0);\r | |
65 | BOOST_QVM_STATIC_ASSERT(Row<Rows);\r | |
66 | BOOST_QVM_STATIC_ASSERT(Col>=0);\r | |
67 | BOOST_QVM_STATIC_ASSERT(Col<Cols);\r | |
68 | return x.a[Row][Col];\r | |
69 | }\r | |
70 | \r | |
71 | static\r | |
72 | BOOST_QVM_INLINE_CRITICAL\r | |
73 | scalar_type\r | |
74 | read_element_idx( int row, int col, this_matrix const & x )\r | |
75 | {\r | |
76 | BOOST_QVM_ASSERT(row>=0);\r | |
77 | BOOST_QVM_ASSERT(row<Rows);\r | |
78 | BOOST_QVM_ASSERT(col>=0);\r | |
79 | BOOST_QVM_ASSERT(col<Cols);\r | |
80 | return x.a[row][col];\r | |
81 | }\r | |
82 | \r | |
83 | static\r | |
84 | BOOST_QVM_INLINE_CRITICAL\r | |
85 | scalar_type &\r | |
86 | write_element_idx( int row, int col, this_matrix & x )\r | |
87 | {\r | |
88 | BOOST_QVM_ASSERT(row>=0);\r | |
89 | BOOST_QVM_ASSERT(row<Rows);\r | |
90 | BOOST_QVM_ASSERT(col>=0);\r | |
91 | BOOST_QVM_ASSERT(col<Cols);\r | |
92 | return x.a[row][col];\r | |
93 | }\r | |
94 | };\r | |
95 | }\r | |
96 | }\r | |
97 | \r | |
98 | #endif\r |