comparison armadillo-3.900.4/include/armadillo_bits/operator_cube_plus.hpp @ 49:1ec0e2823891

Switch to using subrepo copies of qm-dsp, nnls-chroma, vamp-plugin-sdk; update Armadillo version; assume build without external BLAS/LAPACK
author Chris Cannam
date Thu, 13 Jun 2013 10:25:24 +0100
parents
children
comparison
equal deleted inserted replaced
48:69251e11a913 49:1ec0e2823891
1 // Copyright (C) 2008-2010 NICTA (www.nicta.com.au)
2 // Copyright (C) 2008-2010 Conrad Sanderson
3 //
4 // This Source Code Form is subject to the terms of the Mozilla Public
5 // License, v. 2.0. If a copy of the MPL was not distributed with this
6 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
8
9 //! \addtogroup operator_cube_plus
10 //! @{
11
12
13
14 //! unary plus operation (does nothing, but is required for completeness)
15 template<typename T1>
16 arma_inline
17 const BaseCube<typename T1::elem_type,T1>&
18 operator+
19 (
20 const BaseCube<typename T1::elem_type,T1>& X
21 )
22 {
23 arma_extra_debug_sigprint();
24
25 return X;
26 }
27
28
29
30 //! BaseCube + scalar
31 template<typename T1>
32 arma_inline
33 const eOpCube<T1, eop_scalar_plus>
34 operator+
35 (
36 const BaseCube<typename T1::elem_type,T1>& X,
37 const typename T1::elem_type k
38 )
39 {
40 arma_extra_debug_sigprint();
41
42 return eOpCube<T1, eop_scalar_plus>(X.get_ref(), k);
43 }
44
45
46
47 //! scalar + BaseCube
48 template<typename T1>
49 arma_inline
50 const eOpCube<T1, eop_scalar_plus>
51 operator+
52 (
53 const typename T1::elem_type k,
54 const BaseCube<typename T1::elem_type,T1>& X
55 )
56 {
57 arma_extra_debug_sigprint();
58
59 return eOpCube<T1, eop_scalar_plus>(X.get_ref(), k);
60 }
61
62
63
64 //! non-complex BaseCube + complex scalar (experimental)
65 template<typename T1>
66 arma_inline
67 const mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_plus>
68 operator+
69 (
70 const BaseCube<typename T1::pod_type, T1>& X,
71 const std::complex<typename T1::pod_type>& k
72 )
73 {
74 arma_extra_debug_sigprint();
75
76 return mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_plus>('j', X.get_ref(), k);
77 }
78
79
80
81 //! complex scalar + non-complex BaseCube (experimental)
82 template<typename T1>
83 arma_inline
84 const mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_plus>
85 operator+
86 (
87 const std::complex<typename T1::pod_type>& k,
88 const BaseCube<typename T1::pod_type, T1>& X
89 )
90 {
91 arma_extra_debug_sigprint();
92
93 return mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_plus>('j', X.get_ref(), k); // NOTE: order is swapped
94 }
95
96
97
98 //! addition of BaseCube objects with same element type
99 template<typename T1, typename T2>
100 arma_inline
101 const eGlueCube<T1, T2, eglue_plus>
102 operator+
103 (
104 const BaseCube<typename T1::elem_type,T1>& X,
105 const BaseCube<typename T1::elem_type,T2>& Y
106 )
107 {
108 arma_extra_debug_sigprint();
109
110 return eGlueCube<T1, T2, eglue_plus>(X.get_ref(), Y.get_ref());
111 }
112
113
114
115 //! addition of BaseCube objects with different element types
116 template<typename T1, typename T2>
117 inline
118 const mtGlueCube<typename promote_type<typename T1::elem_type, typename T2::elem_type>::result, T1, T2, glue_mixed_plus>
119 operator+
120 (
121 const BaseCube< typename force_different_type<typename T1::elem_type, typename T2::elem_type>::T1_result, T1>& X,
122 const BaseCube< typename force_different_type<typename T1::elem_type, typename T2::elem_type>::T2_result, T2>& Y
123 )
124 {
125 arma_extra_debug_sigprint();
126
127 typedef typename T1::elem_type eT1;
128 typedef typename T2::elem_type eT2;
129
130 typedef typename promote_type<eT1,eT2>::result out_eT;
131
132 promote_type<eT1,eT2>::check();
133
134 return mtGlueCube<out_eT, T1, T2, glue_mixed_plus>( X.get_ref(), Y.get_ref() );
135 }
136
137
138
139 //! @}