1#ifndef BOOST_QVM_DETAIL_MAT_ASSIGN_HPP_INCLUDED
2#define BOOST_QVM_DETAIL_MAT_ASSIGN_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/gen/mat_assign2.hpp>
10#include <boost/qvm/gen/mat_assign3.hpp>
11#include <boost/qvm/gen/mat_assign4.hpp>
12
13namespace boost { namespace qvm {
14
15namespace
16qvm_detail
17 {
18 template <int M,int N>
19 struct
20 assign_mm_defined
21 {
22 static bool const value=false;
23 };
24
25 template <int I,int N>
26 struct
27 copy_matrix_elements
28 {
29 template <class A,class B>
30 static
31 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
32 typename enable_if_c<
33 mat_write_element_ref<A>::value,
34 void>::type
35 f( A & a, B const & b )
36 {
37 mat_traits<A>::template write_element<I/mat_traits<A>::cols,I%mat_traits<A>::cols>(a) =
38 mat_traits<B>::template read_element<I/mat_traits<B>::cols,I%mat_traits<B>::cols>(b);
39 copy_matrix_elements<I+1,N>::f(a,b);
40 }
41
42 template <class A,class B>
43 static
44 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
45 typename enable_if_c<
46 !mat_write_element_ref<A>::value,
47 void>::type
48 f( A & a, B const & b )
49 {
50 mat_traits<A>::template write_element<I/mat_traits<A>::cols,I%mat_traits<A>::cols>(a,
51 mat_traits<B>::template read_element<I/mat_traits<B>::cols,I%mat_traits<B>::cols>(b));
52 copy_matrix_elements<I+1,N>::f(a,b);
53 }
54 };
55
56 template <int N>
57 struct
58 copy_matrix_elements<N,N>
59 {
60 template <class A,class B>
61 static
62 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
63 void
64 f( A &, B const & )
65 {
66 }
67 };
68 }
69
70template <class A,class B>
71BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL
72typename enable_if_c<
73 is_mat<A>::value && is_mat<B>::value &&
74 mat_traits<A>::rows==mat_traits<B>::rows &&
75 mat_traits<A>::cols==mat_traits<B>::cols &&
76 !qvm_detail::assign_mm_defined<mat_traits<A>::rows,mat_traits<A>::cols>::value,
77 A &>::type
78assign( A & a, B const & b )
79 {
80 qvm_detail::copy_matrix_elements<0,mat_traits<A>::rows*mat_traits<A>::cols>::f(a,b);
81 return a;
82 }
83
84} }
85
86#endif
87

source code of boost/libs/qvm/include/boost/qvm/detail/mat_assign.hpp