Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-14 08:47:16

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