Chris@49
|
1 // Copyright (C) 2010-2013 NICTA (www.nicta.com.au)
|
Chris@49
|
2 // Copyright (C) 2010-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 eGlueCube
|
Chris@49
|
10 //! @{
|
Chris@49
|
11
|
Chris@49
|
12
|
Chris@49
|
13
|
Chris@49
|
14 template<typename T1, typename T2, typename eglue_type>
|
Chris@49
|
15 arma_inline
|
Chris@49
|
16 eGlueCube<T1,T2,eglue_type>::~eGlueCube()
|
Chris@49
|
17 {
|
Chris@49
|
18 arma_extra_debug_sigprint();
|
Chris@49
|
19 }
|
Chris@49
|
20
|
Chris@49
|
21
|
Chris@49
|
22
|
Chris@49
|
23 template<typename T1, typename T2, typename eglue_type>
|
Chris@49
|
24 arma_inline
|
Chris@49
|
25 eGlueCube<T1,T2,eglue_type>::eGlueCube(const T1& in_A, const T2& in_B)
|
Chris@49
|
26 : P1(in_A)
|
Chris@49
|
27 , P2(in_B)
|
Chris@49
|
28 {
|
Chris@49
|
29 arma_extra_debug_sigprint();
|
Chris@49
|
30
|
Chris@49
|
31 arma_debug_assert_same_size
|
Chris@49
|
32 (
|
Chris@49
|
33 P1.get_n_rows(), P1.get_n_cols(), P1.get_n_slices(),
|
Chris@49
|
34 P2.get_n_rows(), P2.get_n_cols(), P2.get_n_slices(),
|
Chris@49
|
35 eglue_type::text()
|
Chris@49
|
36 );
|
Chris@49
|
37 }
|
Chris@49
|
38
|
Chris@49
|
39
|
Chris@49
|
40
|
Chris@49
|
41 template<typename T1, typename T2, typename eglue_type>
|
Chris@49
|
42 arma_inline
|
Chris@49
|
43 uword
|
Chris@49
|
44 eGlueCube<T1,T2,eglue_type>::get_n_rows() const
|
Chris@49
|
45 {
|
Chris@49
|
46 return P1.get_n_rows();
|
Chris@49
|
47 }
|
Chris@49
|
48
|
Chris@49
|
49
|
Chris@49
|
50
|
Chris@49
|
51 template<typename T1, typename T2, typename eglue_type>
|
Chris@49
|
52 arma_inline
|
Chris@49
|
53 uword
|
Chris@49
|
54 eGlueCube<T1,T2,eglue_type>::get_n_cols() const
|
Chris@49
|
55 {
|
Chris@49
|
56 return P1.get_n_cols();
|
Chris@49
|
57 }
|
Chris@49
|
58
|
Chris@49
|
59
|
Chris@49
|
60
|
Chris@49
|
61 template<typename T1, typename T2, typename eglue_type>
|
Chris@49
|
62 arma_inline
|
Chris@49
|
63 uword
|
Chris@49
|
64 eGlueCube<T1,T2,eglue_type>::get_n_slices() const
|
Chris@49
|
65 {
|
Chris@49
|
66 return P1.get_n_slices();
|
Chris@49
|
67 }
|
Chris@49
|
68
|
Chris@49
|
69
|
Chris@49
|
70
|
Chris@49
|
71 template<typename T1, typename T2, typename eglue_type>
|
Chris@49
|
72 arma_inline
|
Chris@49
|
73 uword
|
Chris@49
|
74 eGlueCube<T1,T2,eglue_type>::get_n_elem_slice() const
|
Chris@49
|
75 {
|
Chris@49
|
76 return P1.get_n_elem_slice();
|
Chris@49
|
77 }
|
Chris@49
|
78
|
Chris@49
|
79
|
Chris@49
|
80
|
Chris@49
|
81 template<typename T1, typename T2, typename eglue_type>
|
Chris@49
|
82 arma_inline
|
Chris@49
|
83 uword
|
Chris@49
|
84 eGlueCube<T1,T2,eglue_type>::get_n_elem() const
|
Chris@49
|
85 {
|
Chris@49
|
86 return P1.get_n_elem();
|
Chris@49
|
87 }
|
Chris@49
|
88
|
Chris@49
|
89
|
Chris@49
|
90
|
Chris@49
|
91 template<typename T1, typename T2, typename eglue_type>
|
Chris@49
|
92 arma_inline
|
Chris@49
|
93 typename T1::elem_type
|
Chris@49
|
94 eGlueCube<T1,T2,eglue_type>::operator[] (const uword i) const
|
Chris@49
|
95 {
|
Chris@49
|
96 // the optimiser will keep only one return statement
|
Chris@49
|
97
|
Chris@49
|
98 typedef typename T1::elem_type eT;
|
Chris@49
|
99
|
Chris@49
|
100 if(is_same_type<eglue_type, eglue_plus >::value == true) { return P1[i] + P2[i]; }
|
Chris@49
|
101 else if(is_same_type<eglue_type, eglue_minus>::value == true) { return P1[i] - P2[i]; }
|
Chris@49
|
102 else if(is_same_type<eglue_type, eglue_div >::value == true) { return P1[i] / P2[i]; }
|
Chris@49
|
103 else if(is_same_type<eglue_type, eglue_schur>::value == true) { return P1[i] * P2[i]; }
|
Chris@49
|
104 else return eT(0);
|
Chris@49
|
105 }
|
Chris@49
|
106
|
Chris@49
|
107
|
Chris@49
|
108 template<typename T1, typename T2, typename eglue_type>
|
Chris@49
|
109 arma_inline
|
Chris@49
|
110 typename T1::elem_type
|
Chris@49
|
111 eGlueCube<T1,T2,eglue_type>::at(const uword row, const uword col, const uword slice) const
|
Chris@49
|
112 {
|
Chris@49
|
113 // the optimiser will keep only one return statement
|
Chris@49
|
114
|
Chris@49
|
115 typedef typename T1::elem_type eT;
|
Chris@49
|
116
|
Chris@49
|
117 if(is_same_type<eglue_type, eglue_plus >::value == true) { return P1.at(row,col,slice) + P2.at(row,col,slice); }
|
Chris@49
|
118 else if(is_same_type<eglue_type, eglue_minus>::value == true) { return P1.at(row,col,slice) - P2.at(row,col,slice); }
|
Chris@49
|
119 else if(is_same_type<eglue_type, eglue_div >::value == true) { return P1.at(row,col,slice) / P2.at(row,col,slice); }
|
Chris@49
|
120 else if(is_same_type<eglue_type, eglue_schur>::value == true) { return P1.at(row,col,slice) * P2.at(row,col,slice); }
|
Chris@49
|
121 else return eT(0);
|
Chris@49
|
122 }
|
Chris@49
|
123
|
Chris@49
|
124
|
Chris@49
|
125
|
Chris@49
|
126 template<typename T1, typename T2, typename eglue_type>
|
Chris@49
|
127 arma_inline
|
Chris@49
|
128 typename T1::elem_type
|
Chris@49
|
129 eGlueCube<T1,T2,eglue_type>::at_alt(const uword i) const
|
Chris@49
|
130 {
|
Chris@49
|
131 // the optimiser will keep only one return statement
|
Chris@49
|
132
|
Chris@49
|
133 typedef typename T1::elem_type eT;
|
Chris@49
|
134
|
Chris@49
|
135 if(is_same_type<eglue_type, eglue_plus >::value == true) { return P1.at_alt(i) + P2.at_alt(i); }
|
Chris@49
|
136 else if(is_same_type<eglue_type, eglue_minus>::value == true) { return P1.at_alt(i) - P2.at_alt(i); }
|
Chris@49
|
137 else if(is_same_type<eglue_type, eglue_div >::value == true) { return P1.at_alt(i) / P2.at_alt(i); }
|
Chris@49
|
138 else if(is_same_type<eglue_type, eglue_schur>::value == true) { return P1.at_alt(i) * P2.at_alt(i); }
|
Chris@49
|
139 else return eT(0);
|
Chris@49
|
140 }
|
Chris@49
|
141
|
Chris@49
|
142
|
Chris@49
|
143 //! @}
|