Chris@49
|
1 // Copyright (C) 2008-2013 NICTA (www.nicta.com.au)
|
Chris@49
|
2 // Copyright (C) 2008-2013 Conrad Sanderson
|
Chris@49
|
3 //
|
Chris@49
|
4 // This Source Code Form is subject to the terms of the Mozilla Public
|
Chris@49
|
5 // License, v. 2.0. If a copy of the MPL was not distributed with this
|
Chris@49
|
6 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
Chris@49
|
7
|
Chris@49
|
8
|
Chris@49
|
9 //! \addtogroup glue_times
|
Chris@49
|
10 //! @{
|
Chris@49
|
11
|
Chris@49
|
12
|
Chris@49
|
13
|
Chris@49
|
14 //! \brief
|
Chris@49
|
15 //! Template metaprogram depth_lhs
|
Chris@49
|
16 //! calculates the number of Glue<Tx,Ty, glue_type> instances on the left hand side argument of Glue<Tx,Ty, glue_type>
|
Chris@49
|
17 //! i.e. it recursively expands each Tx, until the type of Tx is not "Glue<..,.., glue_type>" (i.e the "glue_type" changes)
|
Chris@49
|
18
|
Chris@49
|
19 template<typename glue_type, typename T1>
|
Chris@49
|
20 struct depth_lhs
|
Chris@49
|
21 {
|
Chris@49
|
22 static const uword num = 0;
|
Chris@49
|
23 };
|
Chris@49
|
24
|
Chris@49
|
25 template<typename glue_type, typename T1, typename T2>
|
Chris@49
|
26 struct depth_lhs< glue_type, Glue<T1,T2,glue_type> >
|
Chris@49
|
27 {
|
Chris@49
|
28 static const uword num = 1 + depth_lhs<glue_type, T1>::num;
|
Chris@49
|
29 };
|
Chris@49
|
30
|
Chris@49
|
31
|
Chris@49
|
32
|
Chris@49
|
33 template<bool is_eT_blas_type>
|
Chris@49
|
34 struct glue_times_redirect2_helper
|
Chris@49
|
35 {
|
Chris@49
|
36 template<typename T1, typename T2>
|
Chris@49
|
37 arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X);
|
Chris@49
|
38 };
|
Chris@49
|
39
|
Chris@49
|
40
|
Chris@49
|
41 template<>
|
Chris@49
|
42 struct glue_times_redirect2_helper<true>
|
Chris@49
|
43 {
|
Chris@49
|
44 template<typename T1, typename T2>
|
Chris@49
|
45 arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X);
|
Chris@49
|
46 };
|
Chris@49
|
47
|
Chris@49
|
48
|
Chris@49
|
49
|
Chris@49
|
50 template<uword N>
|
Chris@49
|
51 struct glue_times_redirect
|
Chris@49
|
52 {
|
Chris@49
|
53 template<typename T1, typename T2>
|
Chris@49
|
54 arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X);
|
Chris@49
|
55 };
|
Chris@49
|
56
|
Chris@49
|
57
|
Chris@49
|
58 template<>
|
Chris@49
|
59 struct glue_times_redirect<2>
|
Chris@49
|
60 {
|
Chris@49
|
61 template<typename T1, typename T2>
|
Chris@49
|
62 arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X);
|
Chris@49
|
63 };
|
Chris@49
|
64
|
Chris@49
|
65
|
Chris@49
|
66 template<>
|
Chris@49
|
67 struct glue_times_redirect<3>
|
Chris@49
|
68 {
|
Chris@49
|
69 template<typename T1, typename T2, typename T3>
|
Chris@49
|
70 arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Glue< Glue<T1,T2,glue_times>,T3,glue_times>& X);
|
Chris@49
|
71 };
|
Chris@49
|
72
|
Chris@49
|
73
|
Chris@49
|
74 template<>
|
Chris@49
|
75 struct glue_times_redirect<4>
|
Chris@49
|
76 {
|
Chris@49
|
77 template<typename T1, typename T2, typename T3, typename T4>
|
Chris@49
|
78 arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Glue< Glue< Glue<T1,T2,glue_times>, T3, glue_times>, T4, glue_times>& X);
|
Chris@49
|
79 };
|
Chris@49
|
80
|
Chris@49
|
81
|
Chris@49
|
82
|
Chris@49
|
83 //! Class which implements the immediate multiplication of two or more matrices
|
Chris@49
|
84 class glue_times
|
Chris@49
|
85 {
|
Chris@49
|
86 public:
|
Chris@49
|
87
|
Chris@49
|
88
|
Chris@49
|
89 template<typename T1, typename T2>
|
Chris@49
|
90 arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1,T2,glue_times>& X);
|
Chris@49
|
91
|
Chris@49
|
92
|
Chris@49
|
93 template<typename T1>
|
Chris@49
|
94 arma_hot inline static void apply_inplace(Mat<typename T1::elem_type>& out, const T1& X);
|
Chris@49
|
95
|
Chris@49
|
96 template<typename T1, typename T2>
|
Chris@49
|
97 arma_hot inline static void apply_inplace_plus(Mat<typename T1::elem_type>& out, const Glue<T1, T2, glue_times>& X, const sword sign);
|
Chris@49
|
98
|
Chris@49
|
99 template<typename eT1, typename eT2>
|
Chris@49
|
100 inline static void apply_mixed(Mat<typename promote_type<eT1,eT2>::result>& out, const Mat<eT1>& X, const Mat<eT2>& Y);
|
Chris@49
|
101
|
Chris@49
|
102 //
|
Chris@49
|
103
|
Chris@49
|
104 template<typename eT, const bool do_trans_A, const bool do_trans_B, typename TA, typename TB>
|
Chris@49
|
105 arma_inline static uword mul_storage_cost(const TA& A, const TB& B);
|
Chris@49
|
106
|
Chris@49
|
107 template<typename eT, const bool do_trans_A, const bool do_trans_B, const bool do_scalar_times, typename TA, typename TB>
|
Chris@49
|
108 arma_hot inline static void apply(Mat<eT>& out, const TA& A, const TB& B, const eT val);
|
Chris@49
|
109
|
Chris@49
|
110 template<typename eT, const bool do_trans_A, const bool do_trans_B, const bool do_trans_C, const bool do_scalar_times, typename TA, typename TB, typename TC>
|
Chris@49
|
111 arma_hot inline static void apply(Mat<eT>& out, const TA& A, const TB& B, const TC& C, const eT val);
|
Chris@49
|
112
|
Chris@49
|
113 template<typename eT, const bool do_trans_A, const bool do_trans_B, const bool do_trans_C, const bool do_trans_D, const bool do_scalar_times, typename TA, typename TB, typename TC, typename TD>
|
Chris@49
|
114 arma_hot inline static void apply(Mat<eT>& out, const TA& A, const TB& B, const TC& C, const TD& D, const eT val);
|
Chris@49
|
115 };
|
Chris@49
|
116
|
Chris@49
|
117
|
Chris@49
|
118
|
Chris@49
|
119 class glue_times_diag
|
Chris@49
|
120 {
|
Chris@49
|
121 public:
|
Chris@49
|
122
|
Chris@49
|
123 template<typename T1, typename T2>
|
Chris@49
|
124 arma_hot inline static void apply(Mat<typename T1::elem_type>& out, const Glue<T1, T2, glue_times_diag>& X);
|
Chris@49
|
125
|
Chris@49
|
126 };
|
Chris@49
|
127
|
Chris@49
|
128
|
Chris@49
|
129
|
Chris@49
|
130 //! @}
|
Chris@49
|
131
|