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