1 // SPDX-License-Identifier: Apache-2.0
2 //
3 // Copyright 2008-2016 Conrad Sanderson (http://conradsanderson.id.au)
4 // Copyright 2008-2016 National ICT Australia (NICTA)
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 // ------------------------------------------------------------------------
17
18
19 //! \addtogroup eGlueCube
20 //! @{
21
22
23
24 template<typename T1, typename T2, typename eglue_type>
25 arma_inline
~eGlueCube()26 eGlueCube<T1,T2,eglue_type>::~eGlueCube()
27 {
28 arma_extra_debug_sigprint();
29 }
30
31
32
33 template<typename T1, typename T2, typename eglue_type>
34 arma_inline
eGlueCube(const T1 & in_A,const T2 & in_B)35 eGlueCube<T1,T2,eglue_type>::eGlueCube(const T1& in_A, const T2& in_B)
36 : P1(in_A)
37 , P2(in_B)
38 {
39 arma_extra_debug_sigprint();
40
41 arma_debug_assert_same_size
42 (
43 P1.get_n_rows(), P1.get_n_cols(), P1.get_n_slices(),
44 P2.get_n_rows(), P2.get_n_cols(), P2.get_n_slices(),
45 eglue_type::text()
46 );
47 }
48
49
50
51 template<typename T1, typename T2, typename eglue_type>
52 arma_inline
53 uword
get_n_rows() const54 eGlueCube<T1,T2,eglue_type>::get_n_rows() const
55 {
56 return P1.get_n_rows();
57 }
58
59
60
61 template<typename T1, typename T2, typename eglue_type>
62 arma_inline
63 uword
get_n_cols() const64 eGlueCube<T1,T2,eglue_type>::get_n_cols() const
65 {
66 return P1.get_n_cols();
67 }
68
69
70
71 template<typename T1, typename T2, typename eglue_type>
72 arma_inline
73 uword
get_n_slices() const74 eGlueCube<T1,T2,eglue_type>::get_n_slices() const
75 {
76 return P1.get_n_slices();
77 }
78
79
80
81 template<typename T1, typename T2, typename eglue_type>
82 arma_inline
83 uword
get_n_elem_slice() const84 eGlueCube<T1,T2,eglue_type>::get_n_elem_slice() const
85 {
86 return P1.get_n_elem_slice();
87 }
88
89
90
91 template<typename T1, typename T2, typename eglue_type>
92 arma_inline
93 uword
get_n_elem() const94 eGlueCube<T1,T2,eglue_type>::get_n_elem() const
95 {
96 return P1.get_n_elem();
97 }
98
99
100
101 template<typename T1, typename T2, typename eglue_type>
102 arma_inline
103 typename T1::elem_type
operator [](const uword i) const104 eGlueCube<T1,T2,eglue_type>::operator[] (const uword i) const
105 {
106 // the optimiser will keep only one return statement
107
108 typedef typename T1::elem_type eT;
109
110 if(is_same_type<eglue_type, eglue_plus >::yes) { return P1[i] + P2[i]; }
111 else if(is_same_type<eglue_type, eglue_minus>::yes) { return P1[i] - P2[i]; }
112 else if(is_same_type<eglue_type, eglue_div >::yes) { return P1[i] / P2[i]; }
113 else if(is_same_type<eglue_type, eglue_schur>::yes) { return P1[i] * P2[i]; }
114 else return eT(0);
115 }
116
117
118 template<typename T1, typename T2, typename eglue_type>
119 arma_inline
120 typename T1::elem_type
at(const uword row,const uword col,const uword slice) const121 eGlueCube<T1,T2,eglue_type>::at(const uword row, const uword col, const uword slice) const
122 {
123 // the optimiser will keep only one return statement
124
125 typedef typename T1::elem_type eT;
126
127 if(is_same_type<eglue_type, eglue_plus >::yes) { return P1.at(row,col,slice) + P2.at(row,col,slice); }
128 else if(is_same_type<eglue_type, eglue_minus>::yes) { return P1.at(row,col,slice) - P2.at(row,col,slice); }
129 else if(is_same_type<eglue_type, eglue_div >::yes) { return P1.at(row,col,slice) / P2.at(row,col,slice); }
130 else if(is_same_type<eglue_type, eglue_schur>::yes) { return P1.at(row,col,slice) * P2.at(row,col,slice); }
131 else return eT(0);
132 }
133
134
135
136 template<typename T1, typename T2, typename eglue_type>
137 arma_inline
138 typename T1::elem_type
at_alt(const uword i) const139 eGlueCube<T1,T2,eglue_type>::at_alt(const uword i) const
140 {
141 // the optimiser will keep only one return statement
142
143 typedef typename T1::elem_type eT;
144
145 if(is_same_type<eglue_type, eglue_plus >::yes) { return P1.at_alt(i) + P2.at_alt(i); }
146 else if(is_same_type<eglue_type, eglue_minus>::yes) { return P1.at_alt(i) - P2.at_alt(i); }
147 else if(is_same_type<eglue_type, eglue_div >::yes) { return P1.at_alt(i) / P2.at_alt(i); }
148 else if(is_same_type<eglue_type, eglue_schur>::yes) { return P1.at_alt(i) * P2.at_alt(i); }
149 else return eT(0);
150 }
151
152
153 //! @}
154