| 1 | //Copyright (c) 2008-2016 Emil Dotchevski and Reverge Studios, Inc.
|
| 2 |
|
| 3 | //Distributed under the Boost Software License, Version 1.0. (See accompanying
|
| 4 | //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
| 5 |
|
| 6 | #ifndef UUID_47136D2C385411E7BA27D3B681262D2E
|
| 7 | #define UUID_47136D2C385411E7BA27D3B681262D2E
|
| 8 |
|
| 9 | #include <boost/qvm/gen/mat_assign2.hpp>
|
| 10 | #include <boost/qvm/gen/mat_assign3.hpp>
|
| 11 | #include <boost/qvm/gen/mat_assign4.hpp>
|
| 12 |
|
| 13 | namespace
|
| 14 | boost
|
| 15 | {
|
| 16 | namespace
|
| 17 | qvm
|
| 18 | {
|
| 19 | namespace
|
| 20 | qvm_detail
|
| 21 | {
|
| 22 | template <int M,int N>
|
| 23 | struct
|
| 24 | assign_mm_defined
|
| 25 | {
|
| 26 | static bool const value=false;
|
| 27 | };
|
| 28 |
|
| 29 | template <int I,int N>
|
| 30 | struct
|
| 31 | copy_matrix_elements
|
| 32 | {
|
| 33 | template <class A,class B>
|
| 34 | static
|
| 35 | BOOST_QVM_INLINE_CRITICAL
|
| 36 | void
|
| 37 | f( A & a, B const & b )
|
| 38 | {
|
| 39 | mat_traits<A>::template write_element<I/mat_traits<A>::cols,I%mat_traits<A>::cols>(a) =
|
| 40 | mat_traits<B>::template read_element<I/mat_traits<B>::cols,I%mat_traits<B>::cols>(b);
|
| 41 | copy_matrix_elements<I+1,N>::f(a,b);
|
| 42 | }
|
| 43 | };
|
| 44 |
|
| 45 | template <int N>
|
| 46 | struct
|
| 47 | copy_matrix_elements<N,N>
|
| 48 | {
|
| 49 | template <class A,class B>
|
| 50 | static
|
| 51 | BOOST_QVM_INLINE_CRITICAL
|
| 52 | void
|
| 53 | f( A &, B const & )
|
| 54 | {
|
| 55 | }
|
| 56 | };
|
| 57 | }
|
| 58 |
|
| 59 | template <class A,class B>
|
| 60 | BOOST_QVM_INLINE_TRIVIAL
|
| 61 | typename boost::enable_if_c<
|
| 62 | is_mat<A>::value && is_mat<B>::value &&
|
| 63 | mat_traits<A>::rows==mat_traits<B>::rows &&
|
| 64 | mat_traits<A>::cols==mat_traits<B>::cols &&
|
| 65 | !qvm_detail::assign_mm_defined<mat_traits<A>::rows,mat_traits<A>::cols>::value,
|
| 66 | A &>::type
|
| 67 | assign( A & a, B const & b )
|
| 68 | {
|
| 69 | qvm_detail::copy_matrix_elements<0,mat_traits<A>::rows*mat_traits<A>::cols>::f(a,b);
|
| 70 | return a;
|
| 71 | }
|
| 72 | }
|
| 73 | }
|
| 74 |
|
| 75 | #endif
|
| 76 | |