Logo ROOT   6.16/01
Reference Guide
BinaryOperators.h
Go to the documentation of this file.
1// @(#)root/smatrix:$Id$
2// Authors: T. Glebe, L. Moneta 2005
3
4#ifndef ROOT_Math_BinaryOperators
5#define ROOT_Math_BinaryOperators
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 "Math/BinaryOpPolicy.h"
22#include "Math/Expression.h"
23
24namespace ROOT {
25
26 namespace Math {
27
28
29
30template <class T, unsigned int D> class SVector;
31template <class T, unsigned int D1, unsigned int D2, class R> class SMatrix;
32
33
34//==============================================================================
35// AddOp
36//==============================================================================
37/**
38 Addition Operation Class
39
40 @ingroup Expression
41 */
42template <class T>
43class AddOp {
44public:
45 static inline T apply(const T& lhs, const T& rhs) {
46 return lhs + rhs;
47 }
48};
49
50
51/**
52 Addition of two vectors v3 = v1+v2
53 returning a vector expression
54
55 @ingroup VectFunction
56*/
57//==============================================================================
58// operator+ (SVector, binary)
59//==============================================================================
60template < class T, unsigned int D>
61inline VecExpr<BinaryOp<AddOp<T>, SVector<T,D>, SVector<T,D>, T>, T, D>
62 operator+(const SVector<T,D>& lhs, const SVector<T,D>& rhs) {
63 typedef BinaryOp<AddOp<T>, SVector<T,D>, SVector<T,D>, T> AddOpBinOp;
64
65 return VecExpr<AddOpBinOp,T,D>(AddOpBinOp(AddOp<T>(),lhs,rhs));
66}
67
68
69//==============================================================================
70// operator+ (SVector, binary)
71//==============================================================================
72template <class A, class T, unsigned int D>
73inline VecExpr<BinaryOp<AddOp<T>, VecExpr<A,T,D>, SVector<T,D>, T>, T, D>
74 operator+(const VecExpr<A,T,D>& lhs, const SVector<T,D>& rhs) {
75 typedef BinaryOp<AddOp<T>, VecExpr<A,T,D>, SVector<T,D>, T> AddOpBinOp;
76
77 return VecExpr<AddOpBinOp,T,D>(AddOpBinOp(AddOp<T>(),lhs,rhs));
78}
79
80
81//==============================================================================
82// operator+ (SVector, binary)
83//==============================================================================
84template < class A, class T, unsigned int D>
85inline VecExpr<BinaryOp<AddOp<T>, SVector<T,D>, VecExpr<A,T,D>, T>, T, D>
86 operator+(const SVector<T,D>& lhs, const VecExpr<A,T,D>& rhs) {
87 typedef BinaryOp<AddOp<T>, SVector<T,D>, VecExpr<A,T,D>, T> AddOpBinOp;
88
89 return VecExpr<AddOpBinOp,T,D>(AddOpBinOp(AddOp<T>(),lhs,rhs));
90}
91
92
93//==============================================================================
94// operator+ (SVector, binary)
95//==============================================================================
96template <class A, class B, class T, unsigned int D>
97inline VecExpr<BinaryOp<AddOp<T>, VecExpr<A,T,D>, VecExpr<B,T,D>, T>, T, D>
98 operator+(const VecExpr<A,T,D>& lhs, const VecExpr<B,T,D>& rhs) {
99 typedef BinaryOp<AddOp<T>, VecExpr<A,T,D>, VecExpr<B,T,D>, T> AddOpBinOp;
100
101 return VecExpr<AddOpBinOp,T,D>(AddOpBinOp(AddOp<T>(),lhs,rhs));
102}
103
104
105/**
106 Addition of a scalar to a each vector element: v2(i) = v1(i) + a
107 returning a vector expression
108
109 @ingroup VectFunction
110*/
111//==============================================================================
112// operator+ (SVector, binary, Constant)
113//==============================================================================
114template <class A, class T, unsigned int D>
115inline VecExpr<BinaryOpCopyR<AddOp<T>, SVector<T,D>, Constant<A>, T>, T, D>
116 operator+(const SVector<T,D>& lhs, const A& rhs) {
117 typedef BinaryOpCopyR<AddOp<T>, SVector<T,D>, Constant<A>, T> AddOpBinOp;
118
119 return VecExpr<AddOpBinOp,T,D>(AddOpBinOp(AddOp<T>(),lhs,Constant<A>(rhs)));
120}
121
122/**
123 Addition of a scalar to each vector element v2(i) = a + v1(i)
124 returning a vector expression
125
126 @ingroup VectFunction
127*/
128//==============================================================================
129// operator+ (SVector, binary, Constant)
130//==============================================================================
131template <class A, class T, unsigned int D>
132inline VecExpr<BinaryOpCopyL<AddOp<T>, Constant<A>, SVector<T,D>, T>, T, D>
133 operator+(const A& lhs, const SVector<T,D>& rhs) {
134 typedef BinaryOpCopyL<AddOp<T>, Constant<A>, SVector<T,D>, T> AddOpBinOp;
135
136 return VecExpr<AddOpBinOp,T,D>(AddOpBinOp(AddOp<T>(),Constant<A>(lhs),rhs));
137}
138
139
140//==============================================================================
141// operator+ (SVector, binary, Constant)
142//==============================================================================
143template <class A, class B, class T, unsigned int D>
144inline VecExpr<BinaryOpCopyR<AddOp<T>, VecExpr<B,T,D>, Constant<A>, T>, T, D>
145 operator+(const VecExpr<B,T,D>& lhs, const A& rhs) {
146 typedef BinaryOpCopyR<AddOp<T>, VecExpr<B,T,D>, Constant<A>, T> AddOpBinOp;
147
148 return VecExpr<AddOpBinOp,T,D>(AddOpBinOp(AddOp<T>(),lhs,Constant<A>(rhs)));
149}
150
151//==============================================================================
152// operator+ (SVector, binary, Constant)
153//==============================================================================
154template <class A, class B, class T, unsigned int D>
155inline VecExpr<BinaryOpCopyL<AddOp<T>, Constant<A>, VecExpr<B,T,D>, T>, T, D>
156 operator+(const A& lhs, const VecExpr<B,T,D>& rhs) {
157 typedef BinaryOpCopyL<AddOp<T>, Constant<A>, VecExpr<B,T,D>, T> AddOpBinOp;
158
159 return VecExpr<AddOpBinOp,T,D>(AddOpBinOp(AddOp<T>(),Constant<A>(lhs),rhs));
160}
161
162
163/**
164 Addition of two matrices C = A+B
165 returning a matrix expression
166
167 @ingroup MatrixFunctions
168*/
169//==============================================================================
170// operator+ (SMatrix, binary)
171//==============================================================================
172template < class T, unsigned int D, unsigned int D2, class R1, class R2>
173inline Expr<BinaryOp<AddOp<T>, SMatrix<T,D,D2,R1>, SMatrix<T,D,D2,R2>, T>, T, D, D2, typename AddPolicy<T,D,D2,R1,R2>::RepType >
176
178}
179
180
181//==============================================================================
182// operator+ (SMatrix, binary)
183//==============================================================================
184template <class A, class T, unsigned int D, unsigned int D2, class R1, class R2>
185inline Expr<BinaryOp<AddOp<T>, Expr<A,T,D,D2,R1>, SMatrix<T,D,D2,R2>, T>, T, D, D2, typename AddPolicy<T,D,D2,R1,R2>::RepType>
188
190}
191
192
193//==============================================================================
194// operator+ (SMatrix, binary)
195//==============================================================================
196template < class A, class T, unsigned int D, unsigned int D2, class R1, class R2>
197inline Expr<BinaryOp<AddOp<T>, SMatrix<T,D,D2,R1>, Expr<A,T,D,D2,R2>, T>, T, D, D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>
200
202}
203
204
205//==============================================================================
206// operator+ (SMatrix, binary)
207//==============================================================================
208template <class A, class B, class T, unsigned int D, unsigned int D2, class R1, class R2>
209inline Expr<BinaryOp<AddOp<T>, Expr<A,T,D,D2,R1>, Expr<B,T,D,D2,R2>, T>, T, D, D2, typename AddPolicy<T,D,D2,R1,R2>::RepType >
212
214}
215
216
217/**
218 Addition element by element of matrix and a scalar C(i,j) = A(i,j) + s
219 returning a matrix expression
220
221 @ingroup MatrixFunctions
222*/
223//=============================================================================
224// operator+ (SMatrix, binary, Constant)
225//=============================================================================
226template <class A, class T, unsigned int D, unsigned int D2, class R>
227inline Expr<BinaryOpCopyR<AddOp<T>, SMatrix<T,D,D2,R>, Constant<A>, T>, T, D, D2, R>
228 operator+(const SMatrix<T,D,D2,R>& lhs, const A& rhs) {
230
231 return Expr<AddOpBinOp,T,D,D2,R>(AddOpBinOp(AddOp<T>(),lhs,Constant<A>(rhs)));
232}
233
234/**
235 Addition element by element of matrix and a scalar C(i,j) = s + A(i,j)
236 returning a matrix expression
237
238 @ingroup MatrixFunctions
239*/
240//==============================================================================
241// operator+ (SMatrix, binary, Constant)
242//==============================================================================
243template <class A, class T, unsigned int D, unsigned int D2, class R>
244inline Expr<BinaryOpCopyL<AddOp<T>, Constant<A>, SMatrix<T,D,D2,R>, T>, T, D, D2, R>
245 operator+(const A& lhs, const SMatrix<T,D,D2,R>& rhs) {
247
248 return Expr<AddOpBinOp,T,D,D2,R>(AddOpBinOp(AddOp<T>(),
249 Constant<A>(lhs),rhs));
250}
251
252
253//==============================================================================
254// operator+ (SMatrix, binary, Constant)
255//==============================================================================
256template <class A, class B, class T, unsigned int D, unsigned int D2, class R>
257inline Expr<BinaryOpCopyR<AddOp<T>, Expr<B,T,D,D2,R>, Constant<A>, T>, T, D, D2, R>
258 operator+(const Expr<B,T,D,D2,R>& lhs, const A& rhs) {
260
261 return Expr<AddOpBinOp,T,D,D2,R>(AddOpBinOp(AddOp<T>(),
262 lhs,Constant<A>(rhs)));
263}
264
265//==============================================================================
266// operator+ (SMatrix, binary, Constant)
267//==============================================================================
268template <class A, class B, class T, unsigned int D, unsigned int D2, class R>
269inline Expr<BinaryOpCopyL<AddOp<T>, Constant<A>, Expr<B,T,D,D2,R>, T>, T, D, D2, R>
270 operator+(const A& lhs, const Expr<B,T,D,D2,R>& rhs) {
272
273 return Expr<AddOpBinOp,T,D,D2,R>(AddOpBinOp(AddOp<T>(),
274 Constant<A>(lhs),rhs));
275}
276
277
278//==============================================================================
279// MinOp
280//==============================================================================
281/**
282 Subtraction Operation Class
283
284 @ingroup Expression
285 */
286template <class T>
287class MinOp {
288public:
289 static inline T apply(const T& lhs, const T& rhs) {
290 return lhs - rhs;
291 }
292};
293
294
295/**
296 Vector Subtraction: v3 = v1 - v2
297 returning a vector expression
298
299 @ingroup VectFunction
300*/
301//==============================================================================
302// operator- (SVector, binary)
303//==============================================================================
304template < class T, unsigned int D>
305inline VecExpr<BinaryOp<MinOp<T>, SVector<T,D>, SVector<T,D>, T>, T, D>
306 operator-(const SVector<T,D>& lhs, const SVector<T,D>& rhs) {
307 typedef BinaryOp<MinOp<T>, SVector<T,D>, SVector<T,D>, T> MinOpBinOp;
308
309 return VecExpr<MinOpBinOp,T,D>(MinOpBinOp(MinOp<T>(),lhs,rhs));
310}
311
312
313//==============================================================================
314// operator- (SVector, binary)
315//==============================================================================
316template <class A, class T, unsigned int D>
317inline VecExpr<BinaryOp<MinOp<T>, VecExpr<A,T,D>, SVector<T,D>, T>, T, D>
318 operator-(const VecExpr<A,T,D>& lhs, const SVector<T,D>& rhs) {
319 typedef BinaryOp<MinOp<T>, VecExpr<A,T,D>, SVector<T,D>, T> MinOpBinOp;
320
321 return VecExpr<MinOpBinOp,T,D>(MinOpBinOp(MinOp<T>(),lhs,rhs));
322}
323
324
325//==============================================================================
326// operator- (SVector, binary)
327//==============================================================================
328template < class A, class T, unsigned int D>
329inline VecExpr<BinaryOp<MinOp<T>, SVector<T,D>, VecExpr<A,T,D>, T>, T, D>
330 operator-(const SVector<T,D>& lhs, const VecExpr<A,T,D>& rhs) {
331 typedef BinaryOp<MinOp<T>, SVector<T,D>, VecExpr<A,T,D>, T> MinOpBinOp;
332
333 return VecExpr<MinOpBinOp,T,D>(MinOpBinOp(MinOp<T>(),lhs,rhs));
334}
335
336
337//==============================================================================
338// operator- (SVector, binary)
339//==============================================================================
340template <class A, class B, class T, unsigned int D>
341inline VecExpr<BinaryOp<MinOp<T>, VecExpr<A,T,D>, VecExpr<B,T,D>, T>, T, D>
342 operator-(const VecExpr<A,T,D>& lhs, const VecExpr<B,T,D>& rhs) {
343 typedef BinaryOp<MinOp<T>, VecExpr<A,T,D>, VecExpr<B,T,D>, T> MinOpBinOp;
344
345 return VecExpr<MinOpBinOp,T,D>(MinOpBinOp(MinOp<T>(),lhs,rhs));
346}
347
348
349/**
350 Subtraction of a scalar from each vector element: v2(i) = v1(i) - a
351 returning a vector expression
352
353 @ingroup VectFunction
354*/
355//==============================================================================
356// operator- (SVector, binary, Constant)
357//==============================================================================
358template <class A, class T, unsigned int D>
359inline VecExpr<BinaryOpCopyR<MinOp<T>, SVector<T,D>, Constant<A>, T>, T, D>
360 operator-(const SVector<T,D>& lhs, const A& rhs) {
361 typedef BinaryOpCopyR<MinOp<T>, SVector<T,D>, Constant<A>, T> MinOpBinOp;
362
363 return VecExpr<MinOpBinOp,T,D>(MinOpBinOp(MinOp<T>(),lhs,Constant<A>(rhs)));
364}
365
366/**
367 Subtraction scalar vector (for each vector element) v2(i) = a - v1(i)
368 returning a vector expression
369
370 @ingroup VectFunction
371*/
372//==============================================================================
373// operator- (SVector, binary, Constant)
374//==============================================================================
375template <class A, class T, unsigned int D>
376inline VecExpr<BinaryOpCopyL<MinOp<T>, Constant<A>, SVector<T,D>, T>, T, D>
377 operator-(const A& lhs, const SVector<T,D>& rhs) {
378 typedef BinaryOpCopyL<MinOp<T>, Constant<A>, SVector<T,D>, T> MinOpBinOp;
379
380 return VecExpr<MinOpBinOp,T,D>(MinOpBinOp(MinOp<T>(),Constant<A>(lhs),rhs));
381}
382
383
384//==============================================================================
385// operator- (SVector, binary, Constant)
386//==============================================================================
387template <class A, class B, class T, unsigned int D>
388inline VecExpr<BinaryOpCopyR<MinOp<T>, VecExpr<B,T,D>, Constant<A>, T>, T, D>
389 operator-(const VecExpr<B,T,D>& lhs, const A& rhs) {
390 typedef BinaryOpCopyR<MinOp<T>, VecExpr<B,T,D>, Constant<A>, T> MinOpBinOp;
391
392 return VecExpr<MinOpBinOp,T,D>(MinOpBinOp(MinOp<T>(),lhs,Constant<A>(rhs)));
393}
394
395//==============================================================================
396// operator- (SVector, binary, Constant)
397//==============================================================================
398template <class A, class B, class T, unsigned int D>
399inline VecExpr<BinaryOpCopyL<MinOp<T>, Constant<A>, VecExpr<B,T,D>, T>, T, D>
400 operator-(const A& lhs, const VecExpr<B,T,D>& rhs) {
401 typedef BinaryOpCopyL<MinOp<T>, Constant<A>, VecExpr<B,T,D>, T> MinOpBinOp;
402
403 return VecExpr<MinOpBinOp,T,D>(MinOpBinOp(MinOp<T>(),Constant<A>(lhs),rhs));
404}
405
406
407/**
408 Subtraction of two matrices C = A-B
409 returning a matrix expression
410
411 @ingroup MatrixFunctions
412*/
413//==============================================================================
414// operator- (SMatrix, binary)
415//==============================================================================
416template < class T, unsigned int D, unsigned int D2, class R1, class R2>
417inline Expr<BinaryOp<MinOp<T>, SMatrix<T,D,D2,R1>, SMatrix<T,D,D2,R2>, T>, T, D, D2, typename AddPolicy<T,D,D2,R1,R2>::RepType>
420
422}
423
424
425//==============================================================================
426// operator- (SMatrix, binary)
427//==============================================================================
428template <class A, class T, unsigned int D, unsigned int D2, class R1, class R2>
429inline Expr<BinaryOp<MinOp<T>, Expr<A,T,D,D2,R1>, SMatrix<T,D,D2,R2>, T>, T, D, D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>
432
434}
435
436
437//==============================================================================
438// operator- (SMatrix, binary)
439//==============================================================================
440template < class A, class T, unsigned int D, unsigned int D2, class R1, class R2>
441inline Expr<BinaryOp<MinOp<T>, SMatrix<T,D,D2,R1>, Expr<A,T,D,D2,R2>, T>, T, D, D2, typename AddPolicy<T,D,D2,R1,R2>::RepType>
444
446}
447
448
449//==============================================================================
450// operator- (SMatrix, binary)
451//==============================================================================
452template <class A, class B, class T, unsigned int D, unsigned int D2, class R1, class R2>
453inline Expr<BinaryOp<MinOp<T>, Expr<A,T,D,D2,R1>, Expr<B,T,D,D2,R2>, T>, T, D, D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>
456
458}
459
460
461/**
462 Subtraction of a scalar and a matrix (element wise) B(i,j) = A(i,j) - s
463 returning a matrix expression
464
465 @ingroup MatrixFunctions
466*/
467//==============================================================================
468// operator- (SMatrix, binary, Constant)
469//==============================================================================
470template <class A, class T, unsigned int D, unsigned int D2, class R>
471inline Expr<BinaryOpCopyR<MinOp<T>, SMatrix<T,D,D2,R>, Constant<A>, T>, T, D, D2, R>
472 operator-(const SMatrix<T,D,D2,R>& lhs, const A& rhs) {
474
475 return Expr<MinOpBinOp,T,D,D2,R>(MinOpBinOp(MinOp<T>(),
476 lhs,Constant<A>(rhs)));
477}
478
479/**
480 Subtraction of a scalar and a matrix (element wise) B(i,j) = s - A(i,j)
481 returning a matrix expression
482
483 @ingroup MatrixFunctions
484*/
485//==============================================================================
486// operator- (SMatrix, binary, Constant)
487//==============================================================================
488template <class A, class T, unsigned int D, unsigned int D2, class R>
489inline Expr<BinaryOpCopyL<MinOp<T>, Constant<A>, SMatrix<T,D,D2,R>, T>, T, D, D2, R>
490 operator-(const A& lhs, const SMatrix<T,D,D2,R>& rhs) {
492
493 return Expr<MinOpBinOp,T,D,D2,R>(MinOpBinOp(MinOp<T>(),Constant<A>(lhs),rhs));
494}
495
496//==============================================================================
497// operator- (SMatrix, binary, Constant)
498//==============================================================================
499template <class A, class B, class T, unsigned int D, unsigned int D2, class R>
500inline Expr<BinaryOpCopyR<MinOp<T>, Expr<B,T,D,D2,R>, Constant<A>, T>, T, D, D2, R>
501 operator-(const Expr<B,T,D,D2,R>& lhs, const A& rhs) {
503
504 return Expr<MinOpBinOp,T,D,D2,R>(MinOpBinOp(MinOp<T>(),lhs,Constant<A>(rhs)));
505}
506
507//==============================================================================
508// operator- (SMatrix, binary, Constant)
509//==============================================================================
510template <class A, class B, class T, unsigned int D, unsigned int D2, class R>
511inline Expr<BinaryOpCopyL<MinOp<T>, Constant<A>, Expr<B,T,D,D2,R>, T>, T, D, D2, R>
512 operator-(const A& lhs, const Expr<B,T,D,D2,R>& rhs) {
514
515 return Expr<MinOpBinOp,T,D,D2,R>(MinOpBinOp(MinOp<T>(),
516 Constant<A>(lhs),rhs));
517}
518
519
520/**
521 Multiplication (element-wise) Operation Class
522
523 @ingroup Expression
524 */
525//==============================================================================
526// MulOp
527//==============================================================================
528template <class T>
529class MulOp {
530public:
531 static inline T apply(const T& lhs, const T& rhs) {
532 return lhs * rhs;
533 }
534};
535
536/**
537 Element by element vector product v3(i) = v1(i)*v2(i)
538 returning a vector expression.
539 Note this is NOT the Dot, Cross or Tensor product.
540
541 @ingroup VectFunction
542*/
543//==============================================================================
544// operator* (SVector, binary)
545//==============================================================================
546template < class T, unsigned int D>
547inline VecExpr<BinaryOp<MulOp<T>, SVector<T,D>, SVector<T,D>, T>, T, D>
548 operator*(const SVector<T,D>& lhs, const SVector<T,D>& rhs) {
549 typedef BinaryOp<MulOp<T>, SVector<T,D>, SVector<T,D>, T> MulOpBinOp;
550
551 return VecExpr<MulOpBinOp,T,D>(MulOpBinOp(MulOp<T>(),lhs,rhs));
552}
553
554
555//==============================================================================
556// operator* (SVector, binary)
557//==============================================================================
558// template <class A, class T, unsigned int D, class R>
559// inline VecExpr<BinaryOp<MulOp<T>, VecExpr<A,T,D>, SVector<T,D>, T>, T, D>
560// operator*(const VecExpr<A,T,D,1,R>& lhs, const SVector<T,D>& rhs) {
561// typedef BinaryOp<MulOp<T>, VecExpr<A,T,D,1,R>, SVector<T,D>, T> MulOpBinOp;
562// return VecExpr<MulOpBinOp,T,D>(MulOpBinOp(MulOp<T>(),lhs,rhs));
563// }
564template <class A, class T, unsigned int D>
565inline VecExpr<BinaryOp<MulOp<T>, Expr<A,T,D>, SVector<T,D>, T>, T, D>
566 operator*(const VecExpr<A,T,D>& lhs, const SVector<T,D>& rhs) {
567 typedef BinaryOp<MulOp<T>, VecExpr<A,T,D>, SVector<T,D>, T> MulOpBinOp;
568 return VecExpr<MulOpBinOp,T,D>(MulOpBinOp(MulOp<T>(),lhs,rhs));
569}
570
571
572//==============================================================================
573// operator* (SVector, binary)
574//==============================================================================
575template < class A, class T, unsigned int D>
576inline VecExpr<BinaryOp<MulOp<T>, SVector<T,D>, VecExpr<A,T,D>, T>, T, D>
577 operator*(const SVector<T,D>& lhs, const VecExpr<A,T,D>& rhs) {
578 typedef BinaryOp<MulOp<T>, SVector<T,D>, VecExpr<A,T,D>, T> MulOpBinOp;
579 return VecExpr<MulOpBinOp,T,D>(MulOpBinOp(MulOp<T>(),lhs,rhs));
580}
581
582
583//==============================================================================
584// operator* (SVector, binary)
585//==============================================================================
586template <class A, class B, class T, unsigned int D>
587inline VecExpr<BinaryOp<MulOp<T>, VecExpr<A,T,D>, VecExpr<B,T,D>, T>, T, D>
588 operator*(const VecExpr<A,T,D>& lhs, const VecExpr<B,T,D>& rhs) {
589 typedef BinaryOp<MulOp<T>, VecExpr<A,T,D>, VecExpr<B,T,D>, T> MulOpBinOp;
590 return VecExpr<MulOpBinOp,T,D>(MulOpBinOp(MulOp<T>(),lhs,rhs));
591}
592
593
594//==============================================================================
595// operator* (SVector, binary, Constant)
596//==============================================================================
597template <class A, class T, unsigned int D>
598inline VecExpr<BinaryOpCopyR<MulOp<T>, SVector<T,D>, Constant<A>, T>, T, D>
599 operator*(const SVector<T,D>& lhs, const A& rhs) {
600 typedef BinaryOpCopyR<MulOp<T>, SVector<T,D>, Constant<A>, T> MulOpBinOp;
601
602 return VecExpr<MulOpBinOp,T,D>(MulOpBinOp(MulOp<T>(),lhs,Constant<A>(rhs)));
603}
604
605//==============================================================================
606// operator* (SVector, binary, Constant)
607//==============================================================================
608template <class A, class T, unsigned int D>
609inline VecExpr<BinaryOpCopyL<MulOp<T>, Constant<A>, SVector<T,D>, T>, T, D>
610 operator*(const A& lhs, const SVector<T,D>& rhs) {
611 typedef BinaryOpCopyL<MulOp<T>, Constant<A>, SVector<T,D>, T> MulOpBinOp;
612
613 return VecExpr<MulOpBinOp,T,D>(MulOpBinOp(MulOp<T>(),Constant<A>(lhs),rhs));
614}
615
616
617//==============================================================================
618// operator* (SVector, binary, Constant)
619//==============================================================================
620template <class A, class B, class T, unsigned int D>
621inline VecExpr<BinaryOpCopyR<MulOp<T>, VecExpr<B,T,D>, Constant<A>, T>, T, D>
622 operator*(const VecExpr<B,T,D>& lhs, const A& rhs) {
623 typedef BinaryOpCopyR<MulOp<T>, VecExpr<B,T,D>, Constant<A>, T> MulOpBinOp;
624
625 return VecExpr<MulOpBinOp,T,D>(MulOpBinOp(MulOp<T>(),lhs,Constant<A>(rhs)));
626}
627
628//==============================================================================
629// operator* (SVector, binary, Constant)
630//==============================================================================
631template <class A, class B, class T, unsigned int D>
632inline VecExpr<BinaryOpCopyL<MulOp<T>, Constant<A>, VecExpr<B,T,D>, T>, T, D>
633 operator*(const A& lhs, const VecExpr<B,T,D>& rhs) {
634 typedef BinaryOpCopyL<MulOp<T>, Constant<A>, VecExpr<B,T,D>, T> MulOpBinOp;
635
636 return VecExpr<MulOpBinOp,T,D>(MulOpBinOp(MulOp<T>(),Constant<A>(lhs),rhs));
637}
638
639/**
640 Element by element matrix multiplication C(i,j) = A(i,j)*B(i,j)
641 returning a matrix expression. This is not a matrix-matrix multiplication and works only
642 for matrices of the same dimensions.
643
644 @ingroup MatrixFunctions
645*/
646// Times: Function for element - wise multiplication
647//==============================================================================
648// Times (SMatrix, binary)
649//==============================================================================
650template < class T, unsigned int D, unsigned int D2, class R1, class R2>
651inline Expr<BinaryOp<MulOp<T>, SMatrix<T,D,D2,R1>, SMatrix<T,D,D2,R2>, T>, T, D, D2, typename AddPolicy<T,D,D2,R1,R2>::RepType>
654
656}
657
658
659//==============================================================================
660// Times (SMatrix, binary)
661//==============================================================================
662template <class A, class T, unsigned int D, unsigned int D2, class R1, class R2>
663inline Expr<BinaryOp<MulOp<T>, Expr<A,T,D,D2,R1>, SMatrix<T,D,D2,R2>, T>, T, D, D2, typename AddPolicy<T,D,D2,R1,R2>::RepType>
666
668}
669
670
671//==============================================================================
672// Times (SMatrix, binary)
673//==============================================================================
674template < class A, class T, unsigned int D, unsigned int D2, class R1, class R2>
675inline Expr<BinaryOp<MulOp<T>, SMatrix<T,D,D2,R1>, Expr<A,T,D,D2,R2>, T>, T, D, D2, typename AddPolicy<T,D,D2,R1,R2>::RepType>
678
680}
681
682
683//==============================================================================
684// Times (SMatrix, binary)
685//==============================================================================
686template <class A, class B, class T, unsigned int D, unsigned int D2, class R1, class R2>
687inline Expr<BinaryOp<MulOp<T>, Expr<A,T,D,D2,R1>, Expr<B,T,D,D2,R2>, T>, T, D, D2, typename AddPolicy<T,D,D2,R1,R2>::RepType>
688 Times(const Expr<A,T,D,D2,R1>& lhs, const Expr<B,T,D,D2,R2>& rhs) {
690
692}
693
694
695/**
696 Multiplication (element wise) of a matrix and a scalar, B(i,j) = A(i,j) * s
697 returning a matrix expression
698
699 @ingroup MatrixFunctions
700*/
701//=============================================================================
702// operator* (SMatrix, binary, Constant)
703//=============================================================================
704template <class A, class T, unsigned int D, unsigned int D2, class R>
705inline Expr<BinaryOpCopyR<MulOp<T>, SMatrix<T,D,D2,R>, Constant<A>, T>, T, D, D2, R>
706 operator*(const SMatrix<T,D,D2,R>& lhs, const A& rhs) {
708
709 return Expr<MulOpBinOp,T,D,D2,R>(MulOpBinOp(MulOp<T>(),
710 lhs,Constant<A>(rhs)));
711}
712
713/**
714 Multiplication (element wise) of a matrix and a scalar, B(i,j) = s * A(i,j)
715 returning a matrix expression
716
717 @ingroup MatrixFunctions
718*/
719//=============================================================================
720// operator* (SMatrix, binary, Constant)
721//=============================================================================
722template <class A, class T, unsigned int D, unsigned int D2, class R>
723inline Expr<BinaryOpCopyL<MulOp<T>, Constant<A>, SMatrix<T,D,D2,R>, T>, T, D, D2, R>
724 operator*(const A& lhs, const SMatrix<T,D,D2,R>& rhs) {
726
727 return Expr<MulOpBinOp,T,D,D2,R>(MulOpBinOp(MulOp<T>(),
728 Constant<A>(lhs),rhs));
729}
730
731
732//==============================================================================
733// operator* (SMatrix, binary, Constant)
734//==============================================================================
735template <class A, class B, class T, unsigned int D, unsigned int D2, class R>
736inline Expr<BinaryOpCopyR<MulOp<T>, Expr<B,T,D,D2,R>, Constant<A>, T>, T, D, D2, R>
737 operator*(const Expr<B,T,D,D2,R>& lhs, const A& rhs) {
739
740 return Expr<MulOpBinOp,T,D,D2,R>(MulOpBinOp(MulOp<T>(),
741 lhs,Constant<A>(rhs)));
742}
743
744//==============================================================================
745// operator* (SMatrix, binary, Constant)
746//==============================================================================
747template <class A, class B, class T, unsigned int D, unsigned int D2, class R>
748inline Expr<BinaryOpCopyL<MulOp<T>, Constant<A>, Expr<B,T,D,D2,R>, T>, T, D, D2, R>
749 operator*(const A& lhs, const Expr<B,T,D,D2,R>& rhs) {
751
752 return Expr<MulOpBinOp,T,D,D2,R>(MulOpBinOp(MulOp<T>(),
753 Constant<A>(lhs),rhs));
754}
755
756
757//=============================================================================
758// DivOp
759//=============================================================================
760/**
761 Division (element-wise) Operation Class
762
763 @ingroup Expression
764 */
765template <class T>
766class DivOp {
767public:
768 static inline T apply(const T& lhs, const T& rhs) {
769 return lhs / rhs;
770 }
771};
772
773/**
774 Element by element division of vectors of the same dimension: v3(i) = v1(i)/v2(i)
775 returning a vector expression
776
777 @ingroup VectFunction
778 */
779//==============================================================================
780// operator/ (SVector, binary)
781//==============================================================================
782template < class T, unsigned int D>
783inline VecExpr<BinaryOp<DivOp<T>, SVector<T,D>, SVector<T,D>, T>, T, D>
784 operator/(const SVector<T,D>& lhs, const SVector<T,D>& rhs) {
785 typedef BinaryOp<DivOp<T>, SVector<T,D>, SVector<T,D>, T> DivOpBinOp;
786
787 return VecExpr<DivOpBinOp,T,D>(DivOpBinOp(DivOp<T>(),lhs,rhs));
788}
789
790
791//==============================================================================
792// operator/ (SVector, binary)
793//==============================================================================
794template <class A, class T, unsigned int D>
795inline VecExpr<BinaryOp<DivOp<T>, VecExpr<A,T,D>, SVector<T,D>, T>, T, D>
796 operator/(const VecExpr<A,T,D>& lhs, const SVector<T,D>& rhs) {
797 typedef BinaryOp<DivOp<T>, VecExpr<A,T,D>, SVector<T,D>, T> DivOpBinOp;
798 return VecExpr<DivOpBinOp,T,D>(DivOpBinOp(DivOp<T>(),lhs,rhs));
799}
800
801
802//==============================================================================
803// operator/ (SVector, binary)
804//==============================================================================
805template < class A, class T, unsigned int D>
806inline VecExpr<BinaryOp<DivOp<T>, SVector<T,D>, VecExpr<A,T,D>, T>, T, D>
807 operator/(const SVector<T,D>& lhs, const VecExpr<A,T,D>& rhs) {
808 typedef BinaryOp<DivOp<T>, SVector<T,D>, VecExpr<A,T,D>, T> DivOpBinOp;
809
810 return VecExpr<DivOpBinOp,T,D>(DivOpBinOp(DivOp<T>(),lhs,rhs));
811}
812
813
814//=============================================================================
815// operator/ (SVector, binary)
816//=============================================================================
817template <class A, class B, class T, unsigned int D>
818inline VecExpr<BinaryOp<DivOp<T>, VecExpr<A,T,D>, VecExpr<B,T,D>, T>, T, D>
819 operator/(const VecExpr<A,T,D>& lhs, const VecExpr<B,T,D>& rhs) {
820 typedef BinaryOp<DivOp<T>, VecExpr<A,T,D>, VecExpr<B,T,D>, T> DivOpBinOp;
821
822 return VecExpr<DivOpBinOp,T,D>(DivOpBinOp(DivOp<T>(),lhs,rhs));
823}
824
825
826/**
827 Division of the vector element by a scalar value: v2(i) = v1(i)/a
828 returning a vector expression
829
830 @ingroup VectFunction
831*/
832//==============================================================================
833// operator/ (SVector, binary, Constant)
834//==============================================================================
835template <class A, class T, unsigned int D>
836inline VecExpr<BinaryOpCopyR<DivOp<T>, SVector<T,D>, Constant<A>, T>, T, D>
837 operator/(const SVector<T,D>& lhs, const A& rhs) {
838 typedef BinaryOpCopyR<DivOp<T>, SVector<T,D>, Constant<A>, T> DivOpBinOp;
839
840 return VecExpr<DivOpBinOp,T,D>(DivOpBinOp(DivOp<T>(),lhs,Constant<A>(rhs)));
841}
842
843/**
844 Division of a scalar value by the vector element: v2(i) = a/v1(i)
845 returning a vector expression
846
847 @ingroup VectFunction
848*/
849//==============================================================================
850// operator/ (SVector, binary, Constant)
851//==============================================================================
852template <class A, class T, unsigned int D>
853inline VecExpr<BinaryOpCopyL<DivOp<T>, Constant<A>, SVector<T,D>, T>, T, D>
854 operator/(const A& lhs, const SVector<T,D>& rhs) {
855 typedef BinaryOpCopyL<DivOp<T>, Constant<A>, SVector<T,D>, T> DivOpBinOp;
856
857 return VecExpr<DivOpBinOp,T,D>(DivOpBinOp(DivOp<T>(),Constant<A>(lhs),rhs));
858}
859
860
861//==============================================================================
862// operator/ (SVector, binary, Constant)
863//==============================================================================
864template <class A, class B, class T, unsigned int D>
865inline VecExpr<BinaryOpCopyR<DivOp<T>, VecExpr<B,T,D>, Constant<A>, T>, T, D>
866 operator/(const VecExpr<B,T,D>& lhs, const A& rhs) {
867 typedef BinaryOpCopyR<DivOp<T>, VecExpr<B,T,D>, Constant<A>, T> DivOpBinOp;
868
869 return VecExpr<DivOpBinOp,T,D>(DivOpBinOp(DivOp<T>(),lhs,Constant<A>(rhs)));
870}
871
872//==============================================================================
873// operator/ (SVector, binary, Constant)
874//==============================================================================
875template <class A, class B, class T, unsigned int D>
876inline VecExpr<BinaryOpCopyL<DivOp<T>, Constant<A>, VecExpr<B,T,D>, T>, T, D>
877 operator/(const A& lhs, const VecExpr<B,T,D>& rhs) {
878 typedef BinaryOpCopyL<DivOp<T>, Constant<A>, VecExpr<B,T,D>, T> DivOpBinOp;
879
880 return VecExpr<DivOpBinOp,T,D>(DivOpBinOp(DivOp<T>(),Constant<A>(lhs),rhs));
881}
882
883
884/**
885 Division (element wise) of two matrices of the same dimensions: C(i,j) = A(i,j) / B(i,j)
886 returning a matrix expression
887
888 @ingroup MatrixFunctions
889*/
890//==============================================================================
891// Div (SMatrix, binary)
892//==============================================================================
893template < class T, unsigned int D, unsigned int D2, class R1, class R2>
894inline Expr<BinaryOp<DivOp<T>, SMatrix<T,D,D2,R1>, SMatrix<T,D,D2,R2>, T>, T, D, D2, typename AddPolicy<T,D,D2,R1,R2>::RepType>
895 Div(const SMatrix<T,D,D2,R1>& lhs, const SMatrix<T,D,D2,R2>& rhs) {
897
899}
900
901
902//==============================================================================
903// Div (SMatrix, binary)
904//==============================================================================
905template <class A, class T, unsigned int D, unsigned int D2, class R1, class R2>
906inline Expr<BinaryOp<DivOp<T>, Expr<A,T,D,D2,R1>, SMatrix<T,D,D2,R2>, T>, T, D, D2, typename AddPolicy<T,D,D2,R1,R2>::RepType>
907 Div(const Expr<A,T,D,D2,R1>& lhs, const SMatrix<T,D,D2,R2>& rhs) {
909
911}
912
913
914//==============================================================================
915// Div (SMatrix, binary)
916//==============================================================================
917template < class A, class T, unsigned int D, unsigned int D2, class R1, class R2>
918inline Expr<BinaryOp<DivOp<T>, SMatrix<T,D,D2,R1>, Expr<A,T,D,D2,R2>, T>, T, D, D2, typename AddPolicy<T,D,D2,R1,R2>::RepType>
919 Div(const SMatrix<T,D,D2,R1>& lhs, const Expr<A,T,D,D2,R2>& rhs) {
921
923}
924
925
926//==============================================================================
927// Div (SMatrix, binary)
928//==============================================================================
929template <class A, class B, class T, unsigned int D, unsigned int D2, class R1, class R2>
930inline Expr<BinaryOp<DivOp<T>, Expr<A,T,D,D2,R1>, Expr<B,T,D,D2,R2>, T>, T, D, D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>
931 Div(const Expr<A,T,D,D2,R1>& lhs, const Expr<B,T,D,D2,R2>& rhs) {
933
935}
936
937
938/**
939 Division (element wise) of a matrix and a scalar, B(i,j) = A(i,j) / s
940 returning a matrix expression
941
942 @ingroup MatrixFunctions
943*/
944//=============================================================================
945// operator/ (SMatrix, binary, Constant)
946//=============================================================================
947template <class A, class T, unsigned int D, unsigned int D2, class R>
948inline Expr<BinaryOpCopyR<DivOp<T>, SMatrix<T,D,D2,R>, Constant<A>, T>, T, D, D2, R>
949 operator/(const SMatrix<T,D,D2,R>& lhs, const A& rhs) {
951
952 return Expr<DivOpBinOp,T,D,D2,R>(DivOpBinOp(DivOp<T>(),
953 lhs,Constant<A>(rhs)));
954}
955
956/**
957 Division (element wise) of a matrix and a scalar, B(i,j) = s / A(i,j)
958 returning a matrix expression
959
960 @ingroup MatrixFunctions
961*/
962//==============================================================================
963// operator/ (SMatrix, binary, Constant)
964//==============================================================================
965template <class A, class T, unsigned int D, unsigned int D2, class R>
966inline Expr<BinaryOpCopyL<DivOp<T>, Constant<A>, SMatrix<T,D,D2,R>, T>, T, D, D2, R>
967 operator/(const A& lhs, const SMatrix<T,D,D2,R>& rhs) {
969
970 return Expr<DivOpBinOp,T,D,D2,R>(DivOpBinOp(DivOp<T>(),
971 Constant<A>(lhs),rhs));
972}
973
974
975//==============================================================================
976// operator/ (SMatrix, binary, Constant)
977//==============================================================================
978template <class A, class B, class T, unsigned int D, unsigned int D2, class R>
979inline Expr<BinaryOpCopyR<DivOp<T>, Expr<B,T,D,D2,R>, Constant<A>, T>, T, D, D2, R>
980 operator/(const Expr<B,T,D,D2,R>& lhs, const A& rhs) {
982
983 return Expr<DivOpBinOp,T,D,D2,R>(DivOpBinOp(DivOp<T>(),
984 lhs,Constant<A>(rhs)));
985}
986
987//==============================================================================
988// operator/ (SMatrix, binary, Constant)
989//==============================================================================
990template <class A, class B, class T, unsigned int D, unsigned int D2, class R>
991inline Expr<BinaryOpCopyL<DivOp<T>, Constant<A>, Expr<B,T,D,D2,R>, T>, T, D, D2,R>
992 operator/(const A& lhs, const Expr<B,T,D,D2,R>& rhs) {
994
995 return Expr<DivOpBinOp,T,D,D2,R>(DivOpBinOp(DivOp<T>(),Constant<A>(lhs),rhs));
996}
997
998
999
1000 } // namespace Math
1001
1002} // namespace ROOT
1003
1004
1005#endif /*ROOT_Math_BinaryOperators */
#define R(a, b, c, d, e, f, g, h, i)
Definition: RSha256.hxx:110
Addition Operation Class.
static T apply(const T &lhs, const T &rhs)
Binary Operation class with value storage for the left argument.
Definition: Expression.h:277
Binary Operation class with value storage for the right argument.
Definition: Expression.h:318
BinaryOperation class A class representing binary operators in the parse tree.
Definition: Expression.h:234
Constant expression class A class representing constant expressions (literals) in the parse tree.
Definition: Expression.h:400
Division (element-wise) Operation Class.
static T apply(const T &lhs, const T &rhs)
Subtraction Operation Class.
static T apply(const T &lhs, const T &rhs)
Multiplication (element-wise) Operation Class.
static T apply(const T &lhs, 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
Expression wrapper class for Vector objects.
Definition: Expression.h:64
Expr< BinaryOp< DivOp< T >, SMatrix< T, D, D2, R1 >, SMatrix< T, D, D2, R2 >, T >, T, D, D2, typename AddPolicy< T, D, D2, R1, R2 >::RepType > Div(const SMatrix< T, D, D2, R1 > &lhs, const SMatrix< T, D, D2, R2 > &rhs)
Division (element wise) of two matrices of the same dimensions: C(i,j) = A(i,j) / B(i,...
Expr< BinaryOp< MulOp< T >, SMatrix< T, D, D2, R1 >, SMatrix< T, D, D2, R2 >, T >, T, D, D2, typename AddPolicy< T, D, D2, R1, R2 >::RepType > Times(const SMatrix< T, D, D2, R1 > &lhs, const SMatrix< T, D, D2, R2 > &rhs)
Element by element matrix multiplication C(i,j) = A(i,j)*B(i,j) returning a matrix expression.
VecExpr< BinaryOp< DivOp< T >, SVector< T, D >, SVector< T, D >, T >, T, D > operator/(const SVector< T, D > &lhs, const SVector< T, D > &rhs)
Element by element division of vectors of the same dimension: v3(i) = v1(i)/v2(i) returning a vector ...
Namespace for new Math classes and functions.
static double A[]
double T(double x)
Definition: ChebyshevPol.h:34
DisplacementVector2D< CoordSystem1, U > operator+(DisplacementVector2D< CoordSystem1, U > v1, const DisplacementVector2D< CoordSystem2, U > &v2)
Addition of DisplacementVector2D vectors.
DisplacementVector2D< CoordSystem1, U > operator-(DisplacementVector2D< CoordSystem1, U > v1, DisplacementVector2D< CoordSystem2, U > const &v2)
Difference between two DisplacementVector2D vectors.
AxisAngle operator*(RotationX const &r1, AxisAngle const &r2)
Multiplication of an axial rotation by an AxisAngle.
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
MatRepStd< typename R1::value_type, N1, N2 > RepType