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