ROOT  6.06/09
Reference Guide
UnaryOperators.h
Go to the documentation of this file.
1 // @(#)root/smatrix:$Id$
2 // Authors: T. Glebe, L. Moneta 2005
3 
4 #ifndef ROOT_Math_UnaryOperators
5 #define ROOT_Math_UnaryOperators
6 //======================================================
7 //
8 // ATTENTION: This file was automatically generated,
9 // do not edit!
10 //
11 // author: Thorsten Glebe
12 // HERA-B Collaboration
13 // Max-Planck-Institut fuer Kernphysik
14 // Saupfercheckweg 1
15 // 69117 Heidelberg
16 // Germany
17 // E-mail: T.Glebe@mpi-hd.mpg.de
18 //
19 //======================================================
20 
21 #include <cmath>
22 
23 #ifndef ROOT_Math_Expression
24 #include "Math/Expression.h"
25 #endif
26 
27 namespace ROOT {
28 
29  namespace Math {
30 
31 
32 
33 template <class T, unsigned int D> class SVector;
34 template <class T, unsigned int D1, unsigned int D2, class R> class SMatrix;
35 
36 
37 /**
38  Unary Minus Operation Class
39 
40  @ingroup Expression
41  */
42 //==============================================================================
43 // Minus
44 //==============================================================================
45 template <class T>
46 class Minus {
47 public:
48  static inline T apply(const T& rhs) {
49  return -(rhs);
50  }
51 };
52 
53 //==============================================================================
54 // operator- (Expr, unary)
55 //==============================================================================
56 template <class A, class T, unsigned int D>
57 inline VecExpr<UnaryOp<Minus<T>, VecExpr<A,T,D>, T>, T, D>
58  operator-(const VecExpr<A,T,D>& rhs) {
59  typedef UnaryOp<Minus<T>, VecExpr<A,T,D>, T> MinusUnaryOp;
60 
61  return VecExpr<MinusUnaryOp,T,D>(MinusUnaryOp(Minus<T>(),rhs));
62 }
63 
64 
65 /**
66  Unary - operator v2 = -v1 .
67  returning a vector expression
68 
69  @ingroup VectFunction
70 */
71 //==============================================================================
72 // operator- (SVector, unary)
73 //==============================================================================
74 template <class T, unsigned int D>
75 inline VecExpr<UnaryOp<Minus<T>, SVector<T,D>, T>, T, D>
76  operator-(const SVector<T,D>& rhs) {
77  typedef UnaryOp<Minus<T>, SVector<T,D>, T> MinusUnaryOp;
78 
79  return VecExpr<MinusUnaryOp,T,D>(MinusUnaryOp(Minus<T>(),rhs));
80 }
81 
82 //==============================================================================
83 // operator- (MatrixExpr, unary)
84 //==============================================================================
85 template <class A, class T, unsigned int D, unsigned int D2, class R>
86 inline Expr<UnaryOp<Minus<T>, Expr<A,T,D,D2,R>, T>, T, D, D2,R>
87  operator-(const Expr<A,T,D,D2,R>& rhs) {
88  typedef UnaryOp<Minus<T>, Expr<A,T,D,D2,R>, T> MinusUnaryOp;
89 
90  return Expr<MinusUnaryOp,T,D,D2,R>(MinusUnaryOp(Minus<T>(),rhs));
91 }
92 
93 
94 /**
95  Unary - operator B = - A
96  returning a matrix expression
97 
98  @ingroup MatrixFunctions
99 */
100 //==============================================================================
101 // operator- (SMatrix, unary)
102 //==============================================================================
103 template <class T, unsigned int D, unsigned int D2, class R>
104 inline Expr<UnaryOp<Minus<T>, SMatrix<T,D,D2,R>, T>, T, D, D2,R>
105  operator-(const SMatrix<T,D,D2,R>& rhs) {
106  typedef UnaryOp<Minus<T>, SMatrix<T,D,D2,R>, T> MinusUnaryOp;
107 
108  return Expr<MinusUnaryOp,T,D,D2,R>(MinusUnaryOp(Minus<T>(),rhs));
109 }
110 
111 
112 //==============================================================================
113 // Fabs
114 //==============================================================================
115 /**
116  Unary abs Operation Class
117 
118  @ingroup Expression
119  */
120 template <class T>
121 class Fabs {
122 public:
123  static inline T apply(const T& rhs) {
124  return std::abs(rhs);
125  }
126 };
127 
128 //==============================================================================
129 // fabs (Expr, unary)
130 //==============================================================================
131 template <class A, class T, unsigned int D>
132 inline VecExpr<UnaryOp<Fabs<T>, VecExpr<A,T,D>, T>, T, D>
133  fabs(const VecExpr<A,T,D>& rhs) {
134  typedef UnaryOp<Fabs<T>, VecExpr<A,T,D>, T> FabsUnaryOp;
135 
136  return VecExpr<FabsUnaryOp,T,D>(FabsUnaryOp(Fabs<T>(),rhs));
137 }
138 
139 
140 /**
141  abs of a vector : v2(i) = | v1(i) |
142  returning a vector expression
143 
144  @ingroup VectFunction
145 */
146 //==============================================================================
147 // fabs (SVector, unary)
148 //==============================================================================
149 template <class T, unsigned int D>
150 inline VecExpr<UnaryOp<Fabs<T>, SVector<T,D>, T>, T, D>
151  fabs(const SVector<T,D>& rhs) {
152  typedef UnaryOp<Fabs<T>, SVector<T,D>, T> FabsUnaryOp;
153 
154  return VecExpr<FabsUnaryOp,T,D>(FabsUnaryOp(Fabs<T>(),rhs));
155 }
156 
157 //==============================================================================
158 // fabs (MatrixExpr, unary)
159 //==============================================================================
160 template <class A, class T, unsigned int D, unsigned int D2, class R>
161 inline Expr<UnaryOp<Fabs<T>, Expr<A,T,D,D2,R>, T>, T, D, D2, R>
162  fabs(const Expr<A,T,D,D2,R>& rhs) {
163  typedef UnaryOp<Fabs<T>, Expr<A,T,D,D2,R>, T> FabsUnaryOp;
164 
165  return Expr<FabsUnaryOp,T,D,D2,R>(FabsUnaryOp(Fabs<T>(),rhs));
166 }
167 
168 
169 /**
170  abs of a matrix m2(i,j) = | m1(i,j) |
171  returning a matrix epression
172 
173  @ingroup MatrixFunctions
174 */
175 //==============================================================================
176 // fabs (SMatrix, unary)
177 //==============================================================================
178 template <class T, unsigned int D, unsigned int D2, class R>
179 inline Expr<UnaryOp<Fabs<T>, SMatrix<T,D,D2,R>, T>, T, D, D2, R>
180  fabs(const SMatrix<T,D,D2,R>& rhs) {
181  typedef UnaryOp<Fabs<T>, SMatrix<T,D,D2,R>, T> FabsUnaryOp;
182 
183  return Expr<FabsUnaryOp,T,D,D2,R>(FabsUnaryOp(Fabs<T>(),rhs));
184 }
185 
186 
187 /**
188  Unary Square Operation Class
189 
190  @ingroup Expression
191  */
192 //==============================================================================
193 // Sqr
194 //==============================================================================
195 template <class T>
196 class Sqr {
197 public:
198  static inline T apply(const T& rhs) {
199  return square(rhs);
200  }
201 };
202 
203 //==============================================================================
204 // sqr (Expr, unary)
205 //==============================================================================
206 template <class A, class T, unsigned int D>
207 inline VecExpr<UnaryOp<Sqr<T>, VecExpr<A,T,D>, T>, T, D>
208  sqr(const VecExpr<A,T,D>& rhs) {
209  typedef UnaryOp<Sqr<T>, VecExpr<A,T,D>, T> SqrUnaryOp;
210 
211  return VecExpr<SqrUnaryOp,T,D>(SqrUnaryOp(Sqr<T>(),rhs));
212 }
213 
214 
215 /**
216  square of a vector v2(i) = v1(i)*v1(i) .
217  returning a vector expression
218 
219  @ingroup VectFunction
220 */
221 //==============================================================================
222 // sqr (SVector, unary)
223 //==============================================================================
224 template <class T, unsigned int D>
225 inline VecExpr<UnaryOp<Sqr<T>, SVector<T,D>, T>, T, D>
226  sqr(const SVector<T,D>& rhs) {
227  typedef UnaryOp<Sqr<T>, SVector<T,D>, T> SqrUnaryOp;
228 
229  return VecExpr<SqrUnaryOp,T,D>(SqrUnaryOp(Sqr<T>(),rhs));
230 }
231 
232 //==============================================================================
233 // sqr (MatrixExpr, unary)
234 //==============================================================================
235 template <class A, class T, unsigned int D, unsigned int D2, class R>
236 inline Expr<UnaryOp<Sqr<T>, Expr<A,T,D,D2,R>, T>, T, D, D2, R>
237  sqr(const Expr<A,T,D,D2,R>& rhs) {
238  typedef UnaryOp<Sqr<T>, Expr<A,T,D,D2,R>, T> SqrUnaryOp;
239 
240  return Expr<SqrUnaryOp,T,D,D2,R>(SqrUnaryOp(Sqr<T>(),rhs));
241 }
242 
243 
244 /**
245  square of a matrix B(i,j) = A(i,j)*A(i,j)
246  returning a matrix expression
247 
248  @ingroup MatrixFunctions
249 */
250 //==============================================================================
251 // sqr (SMatrix, unary)
252 //==============================================================================
253 template <class T, unsigned int D, unsigned int D2, class R>
254 inline Expr<UnaryOp<Sqr<T>, SMatrix<T,D,D2,R>, T>, T, D, D2, R>
255  sqr(const SMatrix<T,D,D2,R>& rhs) {
256  typedef UnaryOp<Sqr<T>, SMatrix<T,D,D2,R>, T> SqrUnaryOp;
257 
258  return Expr<SqrUnaryOp,T,D,D2,R>(SqrUnaryOp(Sqr<T>(),rhs));
259 }
260 
261 
262 //==============================================================================
263 // Sqrt
264 //==============================================================================
265 /**
266  Unary Square Root Operation Class
267 
268  @ingroup Expression
269  */
270 template <class T>
271 class Sqrt {
272 public:
273  static inline T apply(const T& rhs) {
274  return std::sqrt(rhs);
275  }
276 };
277 
278 //==============================================================================
279 // sqrt (VecExpr, unary)
280 //==============================================================================
281 template <class A, class T, unsigned int D>
282 inline VecExpr<UnaryOp<Sqrt<T>, VecExpr<A,T,D>, T>, T, D>
283  sqrt(const VecExpr<A,T,D>& rhs) {
284  typedef UnaryOp<Sqrt<T>, VecExpr<A,T,D>, T> SqrtUnaryOp;
285 
286  return VecExpr<SqrtUnaryOp,T,D>(SqrtUnaryOp(Sqrt<T>(),rhs));
287 }
288 
289 
290 /**
291  square root of a vector (element by element) v2(i) = sqrt( v1(i) )
292  returning a vector expression
293 
294  @ingroup VectFunction
295 */
296 //==============================================================================
297 // sqrt (SVector, unary)
298 //==============================================================================
299 template <class T, unsigned int D>
300 inline VecExpr<UnaryOp<Sqrt<T>, SVector<T,D>, T>, T, D>
301  sqrt(const SVector<T,D>& rhs) {
302  typedef UnaryOp<Sqrt<T>, SVector<T,D>, T> SqrtUnaryOp;
303 
304  return VecExpr<SqrtUnaryOp,T,D>(SqrtUnaryOp(Sqrt<T>(),rhs));
305 }
306 
307 //==============================================================================
308 // sqrt (MatrixExpr, unary)
309 //==============================================================================
310 template <class A, class T, unsigned int D, unsigned int D2, class R>
311 inline Expr<UnaryOp<Sqrt<T>, Expr<A,T,D,D2,R>, T>, T, D, D2, R>
312  sqrt(const Expr<A,T,D,D2,R>& rhs) {
313  typedef UnaryOp<Sqrt<T>, Expr<A,T,D,D2,R>, T> SqrtUnaryOp;
314 
315  return Expr<SqrtUnaryOp,T,D,D2,R>(SqrtUnaryOp(Sqrt<T>(),rhs));
316 }
317 
318 /**
319  square root of a matrix (element by element) m2(i,j) = sqrt ( m1(i,j) )
320  returning a matrix expression
321 
322  @ingroup MatrixFunctions
323 */
324 //==============================================================================
325 // sqrt (SMatrix, unary)
326 //==============================================================================
327 template <class T, unsigned int D, unsigned int D2, class R>
328 inline Expr<UnaryOp<Sqrt<T>, SMatrix<T,D,D2,R>, T>, T, D, D2, R>
329  sqrt(const SMatrix<T,D,D2,R>& rhs) {
330  typedef UnaryOp<Sqrt<T>, SMatrix<T,D,D2,R>, T> SqrtUnaryOp;
331 
332  return Expr<SqrtUnaryOp,T,D,D2,R>(SqrtUnaryOp(Sqrt<T>(),rhs));
333 }
334 
335 
336  } // namespace Math
337 
338 } // namespace ROOT
339 
340 
341 
342 #endif /* ROOT_Math_UnaryOperators */
static T apply(const T &rhs)
Namespace for new ROOT classes and functions.
Definition: ROOT.py:1
double T(double x)
Definition: ChebyshevPol.h:34
Unary Square Operation Class.
Unary abs Operation Class.
static T square(T a)
Definition: main.cpp:132
VecExpr< UnaryOp< Sqrt< T >, VecExpr< A, T, D >, T >, T, D > sqrt(const VecExpr< A, T, D > &rhs)
double sqrt(double)
DisplacementVector2D< CoordSystem1, U > operator-(DisplacementVector2D< CoordSystem1, U > v1, DisplacementVector2D< CoordSystem2, U > const &v2)
Difference between two DisplacementVector2D vectors.
static Vc_ALWAYS_INLINE Vector< T > abs(const Vector< T > &x)
Definition: vector.h:450
Unary Square Root Operation Class.
Unary Minus Operation Class.
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
static T apply(const T &rhs)
UnaryOperation class A class representing unary operators in the parse tree.
Definition: Expression.h:361
Namespace for new Math classes and functions.
static T apply(const T &rhs)
Expression wrapper class for Vector objects.
Definition: Expression.h:64
VecExpr< UnaryOp< Sqr< T >, VecExpr< A, T, D >, T >, T, D > sqr(const VecExpr< A, T, D > &rhs)
TRandom3 R
a TMatrixD.
Definition: testIO.cxx:28
static T apply(const T &rhs)