Logo ROOT  
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
25namespace ROOT {
26
27 namespace Math {
28
29
30
31template <class T, unsigned int D> class SVector;
32template <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//==============================================================================
43template <class T>
44class Minus {
45public:
46 static inline T apply(const T& rhs) {
47 return -(rhs);
48 }
49};
50
51//==============================================================================
52// operator- (Expr, unary)
53//==============================================================================
54template <class A, class T, unsigned int D>
55inline VecExpr<UnaryOp<Minus<T>, VecExpr<A,T,D>, T>, T, D>
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//==============================================================================
72template <class T, unsigned int D>
73inline 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//==============================================================================
83template <class A, class T, unsigned int D, unsigned int D2, class R>
84inline Expr<UnaryOp<Minus<T>, Expr<A,T,D,D2,R>, T>, T, D, D2,R>
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//==============================================================================
101template <class T, unsigned int D, unsigned int D2, class R>
102inline Expr<UnaryOp<Minus<T>, SMatrix<T,D,D2,R>, T>, T, D, D2,R>
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 */
118template <class T>
119class Fabs {
120public:
121 static inline T apply(const T& rhs) {
122 return std::abs(rhs);
123 }
124};
125
126//==============================================================================
127// fabs (Expr, unary)
128//==============================================================================
129template <class A, class T, unsigned int D>
130inline 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//==============================================================================
147template <class T, unsigned int D>
148inline 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//==============================================================================
158template <class A, class T, unsigned int D, unsigned int D2, class R>
159inline 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//==============================================================================
176template <class T, unsigned int D, unsigned int D2, class R>
177inline Expr<UnaryOp<Fabs<T>, SMatrix<T,D,D2,R>, T>, T, D, D2, R>
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//==============================================================================
193template <class T>
194class Sqr {
195public:
196 static inline T apply(const T& rhs) {
197 return square(rhs);
198 }
199};
200
201//==============================================================================
202// sqr (Expr, unary)
203//==============================================================================
204template <class A, class T, unsigned int D>
205inline 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//==============================================================================
222template <class T, unsigned int D>
223inline 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//==============================================================================
233template <class A, class T, unsigned int D, unsigned int D2, class R>
234inline 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//==============================================================================
251template <class T, unsigned int D, unsigned int D2, class R>
252inline 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 */
268template <class T>
269class Sqrt {
270public:
271 static inline T apply(const T& rhs) {
272 return std::sqrt(rhs);
273 }
274};
275
276//==============================================================================
277// sqrt (VecExpr, unary)
278//==============================================================================
279template <class A, class T, unsigned int D>
280inline 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//==============================================================================
297template <class T, unsigned int D>
298inline 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//==============================================================================
308template <class A, class T, unsigned int D, unsigned int D2, class R>
309inline 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//==============================================================================
325template <class T, unsigned int D, unsigned int D2, class R>
326inline Expr<UnaryOp<Sqrt<T>, SMatrix<T,D,D2,R>, T>, T, D, D2, R>
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 */
#define R(a, b, c, d, e, f, g, h, i)
Definition: RSha256.hxx:110
double sqrt(double)
Unary abs Operation Class.
static T apply(const T &rhs)
Unary Minus Operation Class.
static T apply(const T &rhs)
SMatrix: a generic fixed size D1 x D2 Matrix class.
Definition: SMatrix.h:124
SVector: a generic fixed size Vector class.
Definition: SVector.h:75
Unary Square Operation Class.
static T apply(const T &rhs)
Unary Square Root Operation Class.
static T apply(const T &rhs)
UnaryOperation class A class representing unary operators in the parse tree.
Definition: Expression.h:361
Expression wrapper class for Vector objects.
Definition: Expression.h:64
Namespace for new Math classes and functions.
double T(double x)
Definition: ChebyshevPol.h:34
VecExpr< UnaryOp< Sqr< T >, VecExpr< A, T, D >, T >, T, D > sqr(const VecExpr< A, T, D > &rhs)
DisplacementVector2D< CoordSystem1, U > operator-(DisplacementVector2D< CoordSystem1, U > v1, DisplacementVector2D< CoordSystem2, U > const &v2)
Difference between two DisplacementVector2D vectors.
VecExpr< UnaryOp< Sqrt< T >, VecExpr< A, T, D >, T >, T, D > sqrt(const VecExpr< A, T, D > &rhs)
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
VSD Structures.
Definition: StringConv.hxx:21