Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/qvm/mat.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 #ifndef BOOST_QVM_MAT_HPP_INCLUDED
0002 #define BOOST_QVM_MAT_HPP_INCLUDED
0003 
0004 // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc.
0005 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0006 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 
0008 #include <boost/qvm/detail/mat_assign.hpp>
0009 #include <boost/qvm/assert.hpp>
0010 #include <boost/qvm/static_assert.hpp>
0011 
0012 namespace boost { namespace qvm {
0013 
0014 template <class T,int Rows,int Cols>
0015 struct
0016 mat
0017     {
0018     T a[Rows][Cols];
0019     template <class R
0020 #if __cplusplus >= 201103L
0021         , class = typename enable_if<is_mat<R> >::type
0022 #endif
0023     >
0024     operator R() const
0025         {
0026         R r;
0027         assign(r,*this);
0028         return r;
0029         }
0030     };
0031 
0032 template <class M>
0033 struct mat_traits;
0034 
0035 template <class T,int Rows,int Cols>
0036 struct
0037 mat_traits< mat<T,Rows,Cols> >
0038     {
0039     typedef mat<T,Rows,Cols> this_matrix;
0040     typedef T scalar_type;
0041     static int const rows=Rows;
0042     static int const cols=Cols;
0043 
0044     template <int Row,int Col>
0045     static
0046     BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0047     scalar_type
0048     read_element( this_matrix const & x )
0049         {
0050         BOOST_QVM_STATIC_ASSERT(Row>=0);
0051         BOOST_QVM_STATIC_ASSERT(Row<rows);
0052         BOOST_QVM_STATIC_ASSERT(Col>=0);
0053         BOOST_QVM_STATIC_ASSERT(Col<cols);
0054         return x.a[Row][Col];
0055         }
0056 
0057     template <int Row,int Col>
0058     static
0059     BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0060     scalar_type &
0061     write_element( this_matrix & x )
0062         {
0063         BOOST_QVM_STATIC_ASSERT(Row>=0);
0064         BOOST_QVM_STATIC_ASSERT(Row<rows);
0065         BOOST_QVM_STATIC_ASSERT(Col>=0);
0066         BOOST_QVM_STATIC_ASSERT(Col<cols);
0067         return x.a[Row][Col];
0068         }
0069 
0070     static
0071     BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0072     scalar_type
0073     read_element_idx( int row, int col, this_matrix const & x )
0074         {
0075         BOOST_QVM_ASSERT(row>=0);
0076         BOOST_QVM_ASSERT(row<Rows);
0077         BOOST_QVM_ASSERT(col>=0);
0078         BOOST_QVM_ASSERT(col<Cols);
0079         return x.a[row][col];
0080         }
0081 
0082     static
0083     BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0084     scalar_type &
0085     write_element_idx( int row, int col, this_matrix & x )
0086         {
0087         BOOST_QVM_ASSERT(row>=0);
0088         BOOST_QVM_ASSERT(row<Rows);
0089         BOOST_QVM_ASSERT(col>=0);
0090         BOOST_QVM_ASSERT(col<Cols);
0091         return x.a[row][col];
0092         }
0093     };
0094 
0095 } }
0096 
0097 #endif