File indexing completed on 2025-01-18 09:50:42
0001 #ifndef BOOST_QVM_DETAIL_MAT_ASSIGN_HPP_INCLUDED
0002 #define BOOST_QVM_DETAIL_MAT_ASSIGN_HPP_INCLUDED
0003
0004
0005
0006
0007
0008
0009 #include <boost/qvm/gen/mat_assign2.hpp>
0010 #include <boost/qvm/gen/mat_assign3.hpp>
0011 #include <boost/qvm/gen/mat_assign4.hpp>
0012
0013 namespace boost { namespace qvm {
0014
0015 namespace
0016 qvm_detail
0017 {
0018 template <int M,int N>
0019 struct
0020 assign_mm_defined
0021 {
0022 static bool const value=false;
0023 };
0024
0025 template <int I,int N>
0026 struct
0027 copy_matrix_elements
0028 {
0029 template <class A,class B>
0030 static
0031 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0032 typename enable_if_c<
0033 mat_write_element_ref<A>::value,
0034 void>::type
0035 f( A & a, B const & b )
0036 {
0037 mat_traits<A>::template write_element<I/mat_traits<A>::cols,I%mat_traits<A>::cols>(a) =
0038 mat_traits<B>::template read_element<I/mat_traits<B>::cols,I%mat_traits<B>::cols>(b);
0039 copy_matrix_elements<I+1,N>::f(a,b);
0040 }
0041
0042 template <class A,class B>
0043 static
0044 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0045 typename enable_if_c<
0046 !mat_write_element_ref<A>::value,
0047 void>::type
0048 f( A & a, B const & b )
0049 {
0050 mat_traits<A>::template write_element<I/mat_traits<A>::cols,I%mat_traits<A>::cols>(a,
0051 mat_traits<B>::template read_element<I/mat_traits<B>::cols,I%mat_traits<B>::cols>(b));
0052 copy_matrix_elements<I+1,N>::f(a,b);
0053 }
0054 };
0055
0056 template <int N>
0057 struct
0058 copy_matrix_elements<N,N>
0059 {
0060 template <class A,class B>
0061 static
0062 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0063 void
0064 f( A &, B const & )
0065 {
0066 }
0067 };
0068 }
0069
0070 template <class A,class B>
0071 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL
0072 typename enable_if_c<
0073 is_mat<A>::value && is_mat<B>::value &&
0074 mat_traits<A>::rows==mat_traits<B>::rows &&
0075 mat_traits<A>::cols==mat_traits<B>::cols &&
0076 !qvm_detail::assign_mm_defined<mat_traits<A>::rows,mat_traits<A>::cols>::value,
0077 A &>::type
0078 assign( A & a, B const & b )
0079 {
0080 qvm_detail::copy_matrix_elements<0,mat_traits<A>::rows*mat_traits<A>::cols>::f(a,b);
0081 return a;
0082 }
0083
0084 } }
0085
0086 #endif