Logo ROOT   6.14/05
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 #include "Math/Expression.h"
24 
25 namespace ROOT {
26 
27  namespace Math {
28 
29 
30 
31 template <class T, unsigned int D> class SVector;
32 template <class T, unsigned int D1, unsigned int D2, class R> class SMatrix;
33 
34 
35 /**
36  Unary Minus Operation Class
37 
38  @ingroup Expression
39  */
40 //==============================================================================
41 // Minus
42 //==============================================================================
43 template <class T>
44 class Minus {
45 public:
46  static inline T apply(const T& rhs) {
47  return -(rhs);
48  }
49 };
50 
51 //==============================================================================
52 // operator- (Expr, unary)
53 //==============================================================================
54 template <class A, class T, unsigned int D>
56  operator-(const VecExpr<A,T,D>& rhs) {
57  typedef UnaryOp<Minus<T>, VecExpr<A,T,D>, T> MinusUnaryOp;
58 
59  return VecExpr<MinusUnaryOp,T,D>(MinusUnaryOp(Minus<T>(),rhs));
60 }
61 
62 
63 /**
64  Unary - operator v2 = -v1 .
65  returning a vector expression
66 
67  @ingroup VectFunction
68 */
69 //==============================================================================
70 // operator- (SVector, unary)
71 //==============================================================================
72 template <class T, unsigned int D>
73 inline VecExpr<UnaryOp<Minus<T>, SVector<T,D>, T>, T, D>
74  operator-(const SVector<T,D>& rhs) {
75  typedef UnaryOp<Minus<T>, SVector<T,D>, T> MinusUnaryOp;
76 
77  return VecExpr<MinusUnaryOp,T,D>(MinusUnaryOp(Minus<T>(),rhs));
78 }
79 
80 //==============================================================================
81 // operator- (MatrixExpr, unary)
82 //==============================================================================
83 template <class A, class T, unsigned int D, unsigned int D2, class R>
84 inline Expr<UnaryOp<Minus<T>, Expr<A,T,D,D2,R>, T>, T, D, D2,R>
85  operator-(const Expr<A,T,D,D2,R>& rhs) {
86  typedef UnaryOp<Minus<T>, Expr<A,T,D,D2,R>, T> MinusUnaryOp;
87 
88  return Expr<MinusUnaryOp,T,D,D2,R>(MinusUnaryOp(Minus<T>(),rhs));
89 }
90 
91 
92 /**
93  Unary - operator B = - A
94  returning a matrix expression
95 
96  @ingroup MatrixFunctions
97 */
98 //==============================================================================
99 // operator- (SMatrix, unary)
100 //==============================================================================
101 template <class T, unsigned int D, unsigned int D2, class R>
102 inline Expr<UnaryOp<Minus<T>, SMatrix<T,D,D2,R>, T>, T, D, D2,R>
103  operator-(const SMatrix<T,D,D2,R>& rhs) {
104  typedef UnaryOp<Minus<T>, SMatrix<T,D,D2,R>, T> MinusUnaryOp;
105 
106  return Expr<MinusUnaryOp,T,D,D2,R>(MinusUnaryOp(Minus<T>(),rhs));
107 }
108 
109 
110 //==============================================================================
111 // Fabs
112 //==============================================================================
113 /**
114  Unary abs Operation Class
115 
116  @ingroup Expression
117  */
118 template <class T>
119 class Fabs {
120 public:
121  static inline T apply(const T& rhs) {
122  return std::abs(rhs);
123  }
124 };
125 
126 //==============================================================================
127 // fabs (Expr, unary)
128 //==============================================================================
129 template <class A, class T, unsigned int D>
130 inline VecExpr<UnaryOp<Fabs<T>, VecExpr<A,T,D>, T>, T, D>
131  fabs(const VecExpr<A,T,D>& rhs) {
132  typedef UnaryOp<Fabs<T>, VecExpr<A,T,D>, T> FabsUnaryOp;
133 
134  return VecExpr<FabsUnaryOp,T,D>(FabsUnaryOp(Fabs<T>(),rhs));
135 }
136 
137 
138 /**
139  abs of a vector : v2(i) = | v1(i) |
140  returning a vector expression
141 
142  @ingroup VectFunction
143 */
144 //==============================================================================
145 // fabs (SVector, unary)
146 //==============================================================================
147 template <class T, unsigned int D>
148 inline VecExpr<UnaryOp<Fabs<T>, SVector<T,D>, T>, T, D>
149  fabs(const SVector<T,D>& rhs) {
150  typedef UnaryOp<Fabs<T>, SVector<T,D>, T> FabsUnaryOp;
151 
152  return VecExpr<FabsUnaryOp,T,D>(FabsUnaryOp(Fabs<T>(),rhs));
153 }
154 
155 //==============================================================================
156 // fabs (MatrixExpr, unary)
157 //==============================================================================
158 template <class A, class T, unsigned int D, unsigned int D2, class R>
159 inline Expr<UnaryOp<Fabs<T>, Expr<A,T,D,D2,R>, T>, T, D, D2, R>
160  fabs(const Expr<A,T,D,D2,R>& rhs) {
161  typedef UnaryOp<Fabs<T>, Expr<A,T,D,D2,R>, T> FabsUnaryOp;
162 
163  return Expr<FabsUnaryOp,T,D,D2,R>(FabsUnaryOp(Fabs<T>(),rhs));
164 }
165 
166 
167 /**
168  abs of a matrix m2(i,j) = | m1(i,j) |
169  returning a matrix epression
170 
171  @ingroup MatrixFunctions
172 */
173 //==============================================================================
174 // fabs (SMatrix, unary)
175 //==============================================================================
176 template <class T, unsigned int D, unsigned int D2, class R>
177 inline Expr<UnaryOp<Fabs<T>, SMatrix<T,D,D2,R>, T>, T, D, D2, R>
178  fabs(const SMatrix<T,D,D2,R>& rhs) {
179  typedef UnaryOp<Fabs<T>, SMatrix<T,D,D2,R>, T> FabsUnaryOp;
180 
181  return Expr<FabsUnaryOp,T,D,D2,R>(FabsUnaryOp(Fabs<T>(),rhs));
182 }
183 
184 
185 /**
186  Unary Square Operation Class
187 
188  @ingroup Expression
189  */
190 //==============================================================================
191 // Sqr
192 //==============================================================================
193 template <class T>
194 class Sqr {
195 public:
196  static inline T apply(const T& rhs) {
197  return square(rhs);
198  }
199 };
200 
201 //==============================================================================
202 // sqr (Expr, unary)
203 //==============================================================================
204 template <class A, class T, unsigned int D>
205 inline VecExpr<UnaryOp<Sqr<T>, VecExpr<A,T,D>, T>, T, D>
206  sqr(const VecExpr<A,T,D>& rhs) {
207  typedef UnaryOp<Sqr<T>, VecExpr<A,T,D>, T> SqrUnaryOp;
208 
209  return VecExpr<SqrUnaryOp,T,D>(SqrUnaryOp(Sqr<T>(),rhs));
210 }
211 
212 
213 /**
214  square of a vector v2(i) = v1(i)*v1(i) .
215  returning a vector expression
216 
217  @ingroup VectFunction
218 */
219 //==============================================================================
220 // sqr (SVector, unary)
221 //==============================================================================
222 template <class T, unsigned int D>
223 inline VecExpr<UnaryOp<Sqr<T>, SVector<T,D>, T>, T, D>
224  sqr(const SVector<T,D>& rhs) {
225  typedef UnaryOp<Sqr<T>, SVector<T,D>, T> SqrUnaryOp;
226 
227  return VecExpr<SqrUnaryOp,T,D>(SqrUnaryOp(Sqr<T>(),rhs));
228 }
229 
230 //==============================================================================
231 // sqr (MatrixExpr, unary)
232 //==============================================================================
233 template <class A, class T, unsigned int D, unsigned int D2, class R>
234 inline Expr<UnaryOp<Sqr<T>, Expr<A,T,D,D2,R>, T>, T, D, D2, R>
235  sqr(const Expr<A,T,D,D2,R>& rhs) {
236  typedef UnaryOp<Sqr<T>, Expr<A,T,D,D2,R>, T> SqrUnaryOp;
237 
238  return Expr<SqrUnaryOp,T,D,D2,R>(SqrUnaryOp(Sqr<T>(),rhs));
239 }
240 
241 
242 /**
243  square of a matrix B(i,j) = A(i,j)*A(i,j)
244  returning a matrix expression
245 
246  @ingroup MatrixFunctions
247 */
248 //==============================================================================
249 // sqr (SMatrix, unary)
250 //==============================================================================
251 template <class T, unsigned int D, unsigned int D2, class R>
252 inline Expr<UnaryOp<Sqr<T>, SMatrix<T,D,D2,R>, T>, T, D, D2, R>
253  sqr(const SMatrix<T,D,D2,R>& rhs) {
254  typedef UnaryOp<Sqr<T>, SMatrix<T,D,D2,R>, T> SqrUnaryOp;
255 
256  return Expr<SqrUnaryOp,T,D,D2,R>(SqrUnaryOp(Sqr<T>(),rhs));
257 }
258 
259 
260 //==============================================================================
261 // Sqrt
262 //==============================================================================
263 /**
264  Unary Square Root Operation Class
265 
266  @ingroup Expression
267  */
268 template <class T>
269 class Sqrt {
270 public:
271  static inline T apply(const T& rhs) {
272  return std::sqrt(rhs);
273  }
274 };
275 
276 //==============================================================================
277 // sqrt (VecExpr, unary)
278 //==============================================================================
279 template <class A, class T, unsigned int D>
280 inline VecExpr<UnaryOp<Sqrt<T>, VecExpr<A,T,D>, T>, T, D>
281  sqrt(const VecExpr<A,T,D>& rhs) {
282  typedef UnaryOp<Sqrt<T>, VecExpr<A,T,D>, T> SqrtUnaryOp;
283 
284  return VecExpr<SqrtUnaryOp,T,D>(SqrtUnaryOp(Sqrt<T>(),rhs));
285 }
286 
287 
288 /**
289  square root of a vector (element by element) v2(i) = sqrt( v1(i) )
290  returning a vector expression
291 
292  @ingroup VectFunction
293 */
294 //==============================================================================
295 // sqrt (SVector, unary)
296 //==============================================================================
297 template <class T, unsigned int D>
298 inline VecExpr<UnaryOp<Sqrt<T>, SVector<T,D>, T>, T, D>
299  sqrt(const SVector<T,D>& rhs) {
300  typedef UnaryOp<Sqrt<T>, SVector<T,D>, T> SqrtUnaryOp;
301 
302  return VecExpr<SqrtUnaryOp,T,D>(SqrtUnaryOp(Sqrt<T>(),rhs));
303 }
304 
305 //==============================================================================
306 // sqrt (MatrixExpr, unary)
307 //==============================================================================
308 template <class A, class T, unsigned int D, unsigned int D2, class R>
309 inline Expr<UnaryOp<Sqrt<T>, Expr<A,T,D,D2,R>, T>, T, D, D2, R>
310  sqrt(const Expr<A,T,D,D2,R>& rhs) {
311  typedef UnaryOp<Sqrt<T>, Expr<A,T,D,D2,R>, T> SqrtUnaryOp;
312 
313  return Expr<SqrtUnaryOp,T,D,D2,R>(SqrtUnaryOp(Sqrt<T>(),rhs));
314 }
315 
316 /**
317  square root of a matrix (element by element) m2(i,j) = sqrt ( m1(i,j) )
318  returning a matrix expression
319 
320  @ingroup MatrixFunctions
321 */
322 //==============================================================================
323 // sqrt (SMatrix, unary)
324 //==============================================================================
325 template <class T, unsigned int D, unsigned int D2, class R>
326 inline Expr<UnaryOp<Sqrt<T>, SMatrix<T,D,D2,R>, T>, T, D, D2, R>
327  sqrt(const SMatrix<T,D,D2,R>& rhs) {
328  typedef UnaryOp<Sqrt<T>, SMatrix<T,D,D2,R>, T> SqrtUnaryOp;
329 
330  return Expr<SqrtUnaryOp,T,D,D2,R>(SqrtUnaryOp(Sqrt<T>(),rhs));
331 }
332 
333 
334  } // namespace Math
335 
336 } // namespace ROOT
337 
338 
339 
340 #endif /* ROOT_Math_UnaryOperators */
static T apply(const T &rhs)
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
double T(double x)
Definition: ChebyshevPol.h:34
Unary Square Operation Class.
Unary abs Operation Class.
#define R(a, b, c, d, e, f, g, h, i)
Definition: RSha256.hxx:110
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.
SMatrix: a generic fixed size D1 x D2 Matrix class.
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)
static T apply(const T &rhs)
SVector: a generic fixed size Vector class.