comparison armadillo-2.4.4/include/armadillo_bits/eGlueCube_meat.hpp @ 0:8b6102e2a9b0

Armadillo Library
author maxzanoni76 <max.zanoni@eecs.qmul.ac.uk>
date Wed, 11 Apr 2012 09:27:06 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:8b6102e2a9b0
1 // Copyright (C) 2010-2011 NICTA (www.nicta.com.au)
2 // Copyright (C) 2010-2011 Conrad Sanderson
3 //
4 // This file is part of the Armadillo C++ library.
5 // It is provided without any warranty of fitness
6 // for any purpose. You can redistribute this file
7 // and/or modify it under the terms of the GNU
8 // Lesser General Public License (LGPL) as published
9 // by the Free Software Foundation, either version 3
10 // of the License or (at your option) any later version.
11 // (see http://www.opensource.org/licenses for more info)
12
13
14 //! \addtogroup eGlueCube
15 //! @{
16
17
18
19 template<typename T1, typename T2, typename eglue_type>
20 arma_inline
21 eGlueCube<T1,T2,eglue_type>::~eGlueCube()
22 {
23 arma_extra_debug_sigprint();
24 }
25
26
27
28 template<typename T1, typename T2, typename eglue_type>
29 arma_inline
30 eGlueCube<T1,T2,eglue_type>::eGlueCube(const T1& in_A, const T2& in_B)
31 : P1(in_A)
32 , P2(in_B)
33 {
34 arma_extra_debug_sigprint();
35
36 arma_assert_same_size
37 (
38 P1.get_n_rows(), P1.get_n_cols(), P1.get_n_slices(),
39 P2.get_n_rows(), P2.get_n_cols(), P2.get_n_slices(),
40 eglue_type::text()
41 );
42 }
43
44
45
46 template<typename T1, typename T2, typename eglue_type>
47 arma_inline
48 uword
49 eGlueCube<T1,T2,eglue_type>::get_n_rows() const
50 {
51 return P1.get_n_rows();
52 }
53
54
55
56 template<typename T1, typename T2, typename eglue_type>
57 arma_inline
58 uword
59 eGlueCube<T1,T2,eglue_type>::get_n_cols() const
60 {
61 return P1.get_n_cols();
62 }
63
64
65
66 template<typename T1, typename T2, typename eglue_type>
67 arma_inline
68 uword
69 eGlueCube<T1,T2,eglue_type>::get_n_slices() const
70 {
71 return P1.get_n_slices();
72 }
73
74
75
76 template<typename T1, typename T2, typename eglue_type>
77 arma_inline
78 uword
79 eGlueCube<T1,T2,eglue_type>::get_n_elem_slice() const
80 {
81 return P1.get_n_elem_slice();
82 }
83
84
85
86 template<typename T1, typename T2, typename eglue_type>
87 arma_inline
88 uword
89 eGlueCube<T1,T2,eglue_type>::get_n_elem() const
90 {
91 return P1.get_n_elem();
92 }
93
94
95
96 template<typename T1, typename T2, typename eglue_type>
97 arma_inline
98 typename T1::elem_type
99 eGlueCube<T1,T2,eglue_type>::operator[] (const uword i) const
100 {
101 typedef typename T1::elem_type eT;
102
103 // the optimiser will keep only one return statement
104
105 if(is_same_type<eglue_type, eglue_plus >::value == true) { return P1[i] + P2[i]; }
106 else if(is_same_type<eglue_type, eglue_minus>::value == true) { return P1[i] - P2[i]; }
107 else if(is_same_type<eglue_type, eglue_div >::value == true) { return P1[i] / P2[i]; }
108 else if(is_same_type<eglue_type, eglue_schur>::value == true) { return P1[i] * P2[i]; }
109 }
110
111
112 template<typename T1, typename T2, typename eglue_type>
113 arma_inline
114 typename T1::elem_type
115 eGlueCube<T1,T2,eglue_type>::at(const uword row, const uword col, const uword slice) const
116 {
117 typedef typename T1::elem_type eT;
118
119 // the optimiser will keep only one return statement
120
121 if(is_same_type<eglue_type, eglue_plus >::value == true) { return P1.at(row,col,slice) + P2.at(row,col,slice); }
122 else if(is_same_type<eglue_type, eglue_minus>::value == true) { return P1.at(row,col,slice) - P2.at(row,col,slice); }
123 else if(is_same_type<eglue_type, eglue_div >::value == true) { return P1.at(row,col,slice) / P2.at(row,col,slice); }
124 else if(is_same_type<eglue_type, eglue_schur>::value == true) { return P1.at(row,col,slice) * P2.at(row,col,slice); }
125 }
126
127
128
129 //! @}