Mercurial > hg > segmenter-vamp-plugin
comparison armadillo-2.4.4/include/armadillo_bits/operator_cube_plus.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) 2008-2010 NICTA (www.nicta.com.au) | |
2 // Copyright (C) 2008-2010 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 operator_cube_plus | |
15 //! @{ | |
16 | |
17 | |
18 | |
19 //! unary plus operation (does nothing, but is required for completeness) | |
20 template<typename T1> | |
21 arma_inline | |
22 const BaseCube<typename T1::elem_type,T1>& | |
23 operator+ | |
24 ( | |
25 const BaseCube<typename T1::elem_type,T1>& X | |
26 ) | |
27 { | |
28 arma_extra_debug_sigprint(); | |
29 | |
30 return X; | |
31 } | |
32 | |
33 | |
34 | |
35 //! BaseCube + scalar | |
36 template<typename T1> | |
37 arma_inline | |
38 const eOpCube<T1, eop_scalar_plus> | |
39 operator+ | |
40 ( | |
41 const BaseCube<typename T1::elem_type,T1>& X, | |
42 const typename T1::elem_type k | |
43 ) | |
44 { | |
45 arma_extra_debug_sigprint(); | |
46 | |
47 return eOpCube<T1, eop_scalar_plus>(X.get_ref(), k); | |
48 } | |
49 | |
50 | |
51 | |
52 //! scalar + BaseCube | |
53 template<typename T1> | |
54 arma_inline | |
55 const eOpCube<T1, eop_scalar_plus> | |
56 operator+ | |
57 ( | |
58 const typename T1::elem_type k, | |
59 const BaseCube<typename T1::elem_type,T1>& X | |
60 ) | |
61 { | |
62 arma_extra_debug_sigprint(); | |
63 | |
64 return eOpCube<T1, eop_scalar_plus>(X.get_ref(), k); | |
65 } | |
66 | |
67 | |
68 | |
69 //! non-complex BaseCube + complex scalar (experimental) | |
70 template<typename T1> | |
71 arma_inline | |
72 const mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_plus> | |
73 operator+ | |
74 ( | |
75 const BaseCube<typename T1::pod_type, T1>& X, | |
76 const std::complex<typename T1::pod_type>& k | |
77 ) | |
78 { | |
79 arma_extra_debug_sigprint(); | |
80 | |
81 return mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_plus>('j', X.get_ref(), k); | |
82 } | |
83 | |
84 | |
85 | |
86 //! complex scalar + non-complex BaseCube (experimental) | |
87 template<typename T1> | |
88 arma_inline | |
89 const mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_plus> | |
90 operator+ | |
91 ( | |
92 const std::complex<typename T1::pod_type>& k, | |
93 const BaseCube<typename T1::pod_type, T1>& X | |
94 ) | |
95 { | |
96 arma_extra_debug_sigprint(); | |
97 | |
98 return mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_plus>('j', X.get_ref(), k); // NOTE: order is swapped | |
99 } | |
100 | |
101 | |
102 | |
103 //! addition of BaseCube objects with same element type | |
104 template<typename T1, typename T2> | |
105 arma_inline | |
106 const eGlueCube<T1, T2, eglue_plus> | |
107 operator+ | |
108 ( | |
109 const BaseCube<typename T1::elem_type,T1>& X, | |
110 const BaseCube<typename T1::elem_type,T2>& Y | |
111 ) | |
112 { | |
113 arma_extra_debug_sigprint(); | |
114 | |
115 return eGlueCube<T1, T2, eglue_plus>(X.get_ref(), Y.get_ref()); | |
116 } | |
117 | |
118 | |
119 | |
120 //! addition of BaseCube objects with different element types | |
121 template<typename T1, typename T2> | |
122 inline | |
123 const mtGlueCube<typename promote_type<typename T1::elem_type, typename T2::elem_type>::result, T1, T2, glue_mixed_plus> | |
124 operator+ | |
125 ( | |
126 const BaseCube< typename force_different_type<typename T1::elem_type, typename T2::elem_type>::T1_result, T1>& X, | |
127 const BaseCube< typename force_different_type<typename T1::elem_type, typename T2::elem_type>::T2_result, T2>& Y | |
128 ) | |
129 { | |
130 arma_extra_debug_sigprint(); | |
131 | |
132 typedef typename T1::elem_type eT1; | |
133 typedef typename T2::elem_type eT2; | |
134 | |
135 typedef typename promote_type<eT1,eT2>::result out_eT; | |
136 | |
137 promote_type<eT1,eT2>::check(); | |
138 | |
139 return mtGlueCube<out_eT, T1, T2, glue_mixed_plus>( X.get_ref(), Y.get_ref() ); | |
140 } | |
141 | |
142 | |
143 | |
144 //! @} |