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