Chris@49
|
1 // Copyright (C) 2008-2010 NICTA (www.nicta.com.au)
|
Chris@49
|
2 // Copyright (C) 2008-2010 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 operator_cube_minus
|
Chris@49
|
10 //! @{
|
Chris@49
|
11
|
Chris@49
|
12
|
Chris@49
|
13
|
Chris@49
|
14 //! unary -
|
Chris@49
|
15 template<typename T1>
|
Chris@49
|
16 arma_inline
|
Chris@49
|
17 const eOpCube<T1, eop_neg>
|
Chris@49
|
18 operator-
|
Chris@49
|
19 (
|
Chris@49
|
20 const BaseCube<typename T1::elem_type,T1>& X
|
Chris@49
|
21 )
|
Chris@49
|
22 {
|
Chris@49
|
23 arma_extra_debug_sigprint();
|
Chris@49
|
24
|
Chris@49
|
25 return eOpCube<T1, eop_neg>(X.get_ref());
|
Chris@49
|
26 }
|
Chris@49
|
27
|
Chris@49
|
28
|
Chris@49
|
29
|
Chris@49
|
30 //! cancellation of two consecutive negations: -(-T1)
|
Chris@49
|
31 template<typename T1>
|
Chris@49
|
32 arma_inline
|
Chris@49
|
33 const T1&
|
Chris@49
|
34 operator-
|
Chris@49
|
35 (
|
Chris@49
|
36 const eOpCube<T1, eop_neg>& X
|
Chris@49
|
37 )
|
Chris@49
|
38 {
|
Chris@49
|
39 arma_extra_debug_sigprint();
|
Chris@49
|
40
|
Chris@49
|
41 return X.m;
|
Chris@49
|
42 }
|
Chris@49
|
43
|
Chris@49
|
44
|
Chris@49
|
45
|
Chris@49
|
46 //! BaseCube - scalar
|
Chris@49
|
47 template<typename T1>
|
Chris@49
|
48 arma_inline
|
Chris@49
|
49 const eOpCube<T1, eop_scalar_minus_post>
|
Chris@49
|
50 operator-
|
Chris@49
|
51 (
|
Chris@49
|
52 const BaseCube<typename T1::elem_type,T1>& X,
|
Chris@49
|
53 const typename T1::elem_type k
|
Chris@49
|
54 )
|
Chris@49
|
55 {
|
Chris@49
|
56 arma_extra_debug_sigprint();
|
Chris@49
|
57
|
Chris@49
|
58 return eOpCube<T1, eop_scalar_minus_post>(X.get_ref(), k);
|
Chris@49
|
59 }
|
Chris@49
|
60
|
Chris@49
|
61
|
Chris@49
|
62
|
Chris@49
|
63 //! scalar - BaseCube
|
Chris@49
|
64 template<typename T1>
|
Chris@49
|
65 arma_inline
|
Chris@49
|
66 const eOpCube<T1, eop_scalar_minus_pre>
|
Chris@49
|
67 operator-
|
Chris@49
|
68 (
|
Chris@49
|
69 const typename T1::elem_type k,
|
Chris@49
|
70 const BaseCube<typename T1::elem_type,T1>& X
|
Chris@49
|
71 )
|
Chris@49
|
72 {
|
Chris@49
|
73 arma_extra_debug_sigprint();
|
Chris@49
|
74
|
Chris@49
|
75 return eOpCube<T1, eop_scalar_minus_pre>(X.get_ref(), k);
|
Chris@49
|
76 }
|
Chris@49
|
77
|
Chris@49
|
78
|
Chris@49
|
79
|
Chris@49
|
80 //! complex scalar - non-complex BaseCube (experimental)
|
Chris@49
|
81 template<typename T1>
|
Chris@49
|
82 arma_inline
|
Chris@49
|
83 const mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_minus_pre>
|
Chris@49
|
84 operator-
|
Chris@49
|
85 (
|
Chris@49
|
86 const std::complex<typename T1::pod_type>& k,
|
Chris@49
|
87 const BaseCube<typename T1::pod_type, T1>& X
|
Chris@49
|
88 )
|
Chris@49
|
89 {
|
Chris@49
|
90 arma_extra_debug_sigprint();
|
Chris@49
|
91
|
Chris@49
|
92 return mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_minus_pre>('j', X.get_ref(), k);
|
Chris@49
|
93 }
|
Chris@49
|
94
|
Chris@49
|
95
|
Chris@49
|
96
|
Chris@49
|
97 //! non-complex BaseCube - complex scalar (experimental)
|
Chris@49
|
98 template<typename T1>
|
Chris@49
|
99 arma_inline
|
Chris@49
|
100 const mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_minus_post>
|
Chris@49
|
101 operator-
|
Chris@49
|
102 (
|
Chris@49
|
103 const BaseCube<typename T1::pod_type, T1>& X,
|
Chris@49
|
104 const std::complex<typename T1::pod_type>& k
|
Chris@49
|
105 )
|
Chris@49
|
106 {
|
Chris@49
|
107 arma_extra_debug_sigprint();
|
Chris@49
|
108
|
Chris@49
|
109 return mtOpCube<typename std::complex<typename T1::pod_type>, T1, op_cx_scalar_minus_post>('j', X.get_ref(), k);
|
Chris@49
|
110 }
|
Chris@49
|
111
|
Chris@49
|
112
|
Chris@49
|
113
|
Chris@49
|
114 //! subtraction of BaseCube objects with same element type
|
Chris@49
|
115 template<typename T1, typename T2>
|
Chris@49
|
116 arma_inline
|
Chris@49
|
117 const eGlueCube<T1, T2, eglue_minus>
|
Chris@49
|
118 operator-
|
Chris@49
|
119 (
|
Chris@49
|
120 const BaseCube<typename T1::elem_type,T1>& X,
|
Chris@49
|
121 const BaseCube<typename T1::elem_type,T2>& Y
|
Chris@49
|
122 )
|
Chris@49
|
123 {
|
Chris@49
|
124 arma_extra_debug_sigprint();
|
Chris@49
|
125
|
Chris@49
|
126 return eGlueCube<T1, T2, eglue_minus>(X.get_ref(), Y.get_ref());
|
Chris@49
|
127 }
|
Chris@49
|
128
|
Chris@49
|
129
|
Chris@49
|
130
|
Chris@49
|
131 //! subtraction of BaseCube objects with different element types
|
Chris@49
|
132 template<typename T1, typename T2>
|
Chris@49
|
133 inline
|
Chris@49
|
134 const mtGlueCube<typename promote_type<typename T1::elem_type, typename T2::elem_type>::result, T1, T2, glue_mixed_minus>
|
Chris@49
|
135 operator-
|
Chris@49
|
136 (
|
Chris@49
|
137 const BaseCube< typename force_different_type<typename T1::elem_type, typename T2::elem_type>::T1_result, T1>& X,
|
Chris@49
|
138 const BaseCube< typename force_different_type<typename T1::elem_type, typename T2::elem_type>::T2_result, T2>& Y
|
Chris@49
|
139 )
|
Chris@49
|
140 {
|
Chris@49
|
141 arma_extra_debug_sigprint();
|
Chris@49
|
142
|
Chris@49
|
143 typedef typename T1::elem_type eT1;
|
Chris@49
|
144 typedef typename T2::elem_type eT2;
|
Chris@49
|
145
|
Chris@49
|
146 typedef typename promote_type<eT1,eT2>::result out_eT;
|
Chris@49
|
147
|
Chris@49
|
148 promote_type<eT1,eT2>::check();
|
Chris@49
|
149
|
Chris@49
|
150 return mtGlueCube<out_eT, T1, T2, glue_mixed_minus>( X.get_ref(), Y.get_ref() );
|
Chris@49
|
151 }
|
Chris@49
|
152
|
Chris@49
|
153
|
Chris@49
|
154
|
Chris@49
|
155 //! @}
|