4 #ifndef ROOT_Math_BinaryOperators
5 #define ROOT_Math_BinaryOperators
21 #ifndef ROOT_Math_BinaryOpPolicy
32 template <
class T,
unsigned int D>
class SVector;
33 template <
class T,
unsigned int D1,
unsigned int D2,
class R>
class SMatrix;
47 static inline T apply(
const T& lhs,
const T& rhs) {
62 template <
class T,
unsigned int D>
63 inline VecExpr<BinaryOp<AddOp<T>, SVector<T,D>, SVector<T,D>,
T>,
T, D>
74 template <
class A,
class T,
unsigned int D>
75 inline VecExpr<BinaryOp<AddOp<T>, VecExpr<A,T,D>, SVector<T,D>,
T>,
T, D>
86 template <
class A,
class T,
unsigned int D>
87 inline VecExpr<BinaryOp<AddOp<T>, SVector<T,D>, VecExpr<A,T,D>,
T>,
T, D>
98 template <
class A,
class B,
class T,
unsigned int D>
99 inline VecExpr<BinaryOp<AddOp<T>, VecExpr<A,T,D>, VecExpr<B,T,D>,
T>,
T, D>
116 template <
class A,
class T,
unsigned int D>
117 inline VecExpr<BinaryOpCopyR<AddOp<T>, SVector<T,D>, Constant<A>,
T>,
T, D>
133 template <
class A,
class T,
unsigned int D>
134 inline VecExpr<BinaryOpCopyL<AddOp<T>, Constant<A>, SVector<T,D>,
T>,
T, D>
145 template <
class A,
class B,
class T,
unsigned int D>
146 inline VecExpr<BinaryOpCopyR<AddOp<T>, VecExpr<B,T,D>, Constant<A>,
T>,
T, D>
156 template <
class A,
class B,
class T,
unsigned int D>
157 inline VecExpr<BinaryOpCopyL<AddOp<T>, Constant<A>, VecExpr<B,T,D>,
T>,
T, D>
174 template <
class T,
unsigned int D,
unsigned int D2,
class R1,
class R2>
175 inline 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 >
179 return Expr<AddOpBinOp,T,D,D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>(AddOpBinOp(
AddOp<T>(),lhs,rhs));
186 template <
class A,
class T,
unsigned int D,
unsigned int D2,
class R1,
class R2>
187 inline 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>
189 typedef BinaryOp<AddOp<T>,
Expr<A,T,D,D2,R1>,
SMatrix<T,D,D2,R2>,
T> AddOpBinOp;
191 return Expr<AddOpBinOp,T,D,D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>(AddOpBinOp(
AddOp<T>(),lhs,rhs));
198 template <
class A,
class T,
unsigned int D,
unsigned int D2,
class R1,
class R2>
199 inline 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>
201 typedef BinaryOp<AddOp<T>,
SMatrix<T,D,D2,R1>,
Expr<A,T,D,D2,R2>,
T> AddOpBinOp;
203 return Expr<AddOpBinOp,T,D,D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>(AddOpBinOp(
AddOp<T>(),lhs,rhs));
210 template <
class A,
class B,
class T,
unsigned int D,
unsigned int D2,
class R1,
class R2>
211 inline 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 >
213 typedef BinaryOp<AddOp<T>,
Expr<A,T,D,D2,R1>,
Expr<B,T,D,D2,R2>,
T> AddOpBinOp;
215 return Expr<AddOpBinOp,T,D,D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>(AddOpBinOp(
AddOp<T>(),lhs,rhs));
228 template <
class A,
class T,
unsigned int D,
unsigned int D2,
class R>
229 inline Expr<BinaryOpCopyR<AddOp<T>, SMatrix<T,D,D2,R>, Constant<A>,
T>,
T, D, D2,
R>
245 template <
class A,
class T,
unsigned int D,
unsigned int D2,
class R>
246 inline Expr<BinaryOpCopyL<AddOp<T>, Constant<A>, SMatrix<T,D,D2,R>,
T>,
T, D, D2,
R>
251 Constant<A>(lhs),rhs));
258 template <
class A,
class B,
class T,
unsigned int D,
unsigned int D2,
class R>
259 inline Expr<BinaryOpCopyR<AddOp<T>, Expr<B,T,D,D2,R>, Constant<A>,
T>,
T, D, D2,
R>
264 lhs,Constant<A>(rhs)));
270 template <
class A,
class B,
class T,
unsigned int D,
unsigned int D2,
class R>
271 inline Expr<BinaryOpCopyL<AddOp<T>, Constant<A>, Expr<B,T,D,D2,R>,
T>,
T, D, D2,
R>
276 Constant<A>(lhs),rhs));
291 static inline T apply(
const T& lhs,
const T& rhs) {
306 template <
class T,
unsigned int D>
307 inline VecExpr<BinaryOp<MinOp<T>, SVector<T,D>, SVector<T,D>,
T>,
T, D>
318 template <
class A,
class T,
unsigned int D>
319 inline VecExpr<BinaryOp<MinOp<T>, VecExpr<A,T,D>, SVector<T,D>,
T>,
T, D>
330 template <
class A,
class T,
unsigned int D>
331 inline VecExpr<BinaryOp<MinOp<T>, SVector<T,D>, VecExpr<A,T,D>,
T>,
T, D>
342 template <
class A,
class B,
class T,
unsigned int D>
343 inline VecExpr<BinaryOp<MinOp<T>, VecExpr<A,T,D>, VecExpr<B,T,D>,
T>,
T, D>
360 template <
class A,
class T,
unsigned int D>
361 inline VecExpr<BinaryOpCopyR<MinOp<T>, SVector<T,D>, Constant<A>,
T>,
T, D>
377 template <
class A,
class T,
unsigned int D>
378 inline VecExpr<BinaryOpCopyL<MinOp<T>, Constant<A>, SVector<T,D>,
T>,
T, D>
389 template <
class A,
class B,
class T,
unsigned int D>
390 inline VecExpr<BinaryOpCopyR<MinOp<T>, VecExpr<B,T,D>, Constant<A>,
T>,
T, D>
400 template <
class A,
class B,
class T,
unsigned int D>
401 inline VecExpr<BinaryOpCopyL<MinOp<T>, Constant<A>, VecExpr<B,T,D>,
T>,
T, D>
418 template <
class T,
unsigned int D,
unsigned int D2,
class R1,
class R2>
419 inline 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>
423 return Expr<MinOpBinOp,T,D,D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>(MinOpBinOp(
MinOp<T>(),lhs,rhs));
430 template <
class A,
class T,
unsigned int D,
unsigned int D2,
class R1,
class R2>
431 inline 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>
433 typedef BinaryOp<MinOp<T>,
Expr<A,T,D,D2,R1>,
SMatrix<T,D,D2,R2>,
T> MinOpBinOp;
435 return Expr<MinOpBinOp,T,D,D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>(MinOpBinOp(
MinOp<T>(),lhs,rhs));
442 template <
class A,
class T,
unsigned int D,
unsigned int D2,
class R1,
class R2>
443 inline 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>
445 typedef BinaryOp<MinOp<T>,
SMatrix<T,D,D2,R1>,
Expr<A,T,D,D2,R2>,
T> MinOpBinOp;
447 return Expr<MinOpBinOp,T,D,D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>(MinOpBinOp(
MinOp<T>(),lhs,rhs));
454 template <
class A,
class B,
class T,
unsigned int D,
unsigned int D2,
class R1,
class R2>
455 inline 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>
457 typedef BinaryOp<MinOp<T>,
Expr<A,T,D,D2,R1>,
Expr<B,T,D,D2,R2>,
T> MinOpBinOp;
459 return Expr<MinOpBinOp,T,D,D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>(MinOpBinOp(
MinOp<T>(),lhs,rhs));
472 template <
class A,
class T,
unsigned int D,
unsigned int D2,
class R>
473 inline Expr<BinaryOpCopyR<MinOp<T>, SMatrix<T,D,D2,R>, Constant<A>,
T>,
T, D, D2,
R>
478 lhs,Constant<A>(rhs)));
490 template <
class A,
class T,
unsigned int D,
unsigned int D2,
class R>
491 inline Expr<BinaryOpCopyL<MinOp<T>, Constant<A>, SMatrix<T,D,D2,R>,
T>,
T, D, D2,
R>
501 template <
class A,
class B,
class T,
unsigned int D,
unsigned int D2,
class R>
502 inline Expr<BinaryOpCopyR<MinOp<T>, Expr<B,T,D,D2,R>, Constant<A>,
T>,
T, D, D2,
R>
512 template <
class A,
class B,
class T,
unsigned int D,
unsigned int D2,
class R>
513 inline Expr<BinaryOpCopyL<MinOp<T>, Constant<A>, Expr<B,T,D,D2,R>,
T>,
T, D, D2,
R>
518 Constant<A>(lhs),rhs));
533 static inline T apply(
const T& lhs,
const T& rhs) {
548 template <
class T,
unsigned int D>
549 inline VecExpr<BinaryOp<MulOp<T>, SVector<T,D>, SVector<T,D>,
T>,
T, D>
566 template <
class A,
class T,
unsigned int D>
567 inline VecExpr<BinaryOp<MulOp<T>, Expr<A,T,D>, SVector<T,D>,
T>,
T, D>
577 template <
class A,
class T,
unsigned int D>
578 inline VecExpr<BinaryOp<MulOp<T>, SVector<T,D>, VecExpr<A,T,D>,
T>,
T, D>
588 template <
class A,
class B,
class T,
unsigned int D>
589 inline VecExpr<BinaryOp<MulOp<T>, VecExpr<A,T,D>, VecExpr<B,T,D>,
T>,
T, D>
599 template <
class A,
class T,
unsigned int D>
600 inline VecExpr<BinaryOpCopyR<MulOp<T>, SVector<T,D>, Constant<A>,
T>,
T, D>
610 template <
class A,
class T,
unsigned int D>
611 inline VecExpr<BinaryOpCopyL<MulOp<T>, Constant<A>, SVector<T,D>,
T>,
T, D>
622 template <
class A,
class B,
class T,
unsigned int D>
623 inline VecExpr<BinaryOpCopyR<MulOp<T>, VecExpr<B,T,D>, Constant<A>,
T>,
T, D>
633 template <
class A,
class B,
class T,
unsigned int D>
634 inline VecExpr<BinaryOpCopyL<MulOp<T>, Constant<A>, VecExpr<B,T,D>,
T>,
T, D>
652 template <
class T,
unsigned int D,
unsigned int D2,
class R1,
class R2>
653 inline 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>
657 return Expr<MulOpBinOp,T,D,D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>(MulOpBinOp(
MulOp<T>(),lhs,rhs));
664 template <
class A,
class T,
unsigned int D,
unsigned int D2,
class R1,
class R2>
665 inline 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>
667 typedef BinaryOp<MulOp<T>,
Expr<A,T,D,D2,R1>,
SMatrix<T,D,D2,R2>,
T> MulOpBinOp;
669 return Expr<MulOpBinOp,T,D,D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>(MulOpBinOp(
MulOp<T>(),lhs,rhs));
676 template <
class A,
class T,
unsigned int D,
unsigned int D2,
class R1,
class R2>
677 inline 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>
679 typedef BinaryOp<MulOp<T>,
SMatrix<T,D,D2,R1>,
Expr<A,T,D,D2,R2>,
T> MulOpBinOp;
681 return Expr<MulOpBinOp,T,D,D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>(MulOpBinOp(
MulOp<T>(),lhs,rhs));
688 template <
class A,
class B,
class T,
unsigned int D,
unsigned int D2,
class R1,
class R2>
689 inline 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>
691 typedef BinaryOp<MulOp<T>,
Expr<A,T,D,D2,R1>,
Expr<B,T,D,D2,R2>,
T> MulOpBinOp;
693 return Expr<MulOpBinOp,T,D,D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>(MulOpBinOp(
MulOp<T>(),lhs,rhs));
706 template <
class A,
class T,
unsigned int D,
unsigned int D2,
class R>
707 inline Expr<BinaryOpCopyR<MulOp<T>, SMatrix<T,D,D2,R>, Constant<A>,
T>,
T, D, D2,
R>
712 lhs,Constant<A>(rhs)));
724 template <
class A,
class T,
unsigned int D,
unsigned int D2,
class R>
725 inline Expr<BinaryOpCopyL<MulOp<T>, Constant<A>, SMatrix<T,D,D2,R>,
T>,
T, D, D2,
R>
730 Constant<A>(lhs),rhs));
737 template <
class A,
class B,
class T,
unsigned int D,
unsigned int D2,
class R>
738 inline Expr<BinaryOpCopyR<MulOp<T>, Expr<B,T,D,D2,R>, Constant<A>,
T>,
T, D, D2,
R>
743 lhs,Constant<A>(rhs)));
749 template <
class A,
class B,
class T,
unsigned int D,
unsigned int D2,
class R>
750 inline Expr<BinaryOpCopyL<MulOp<T>, Constant<A>, Expr<B,T,D,D2,R>,
T>,
T, D, D2,
R>
755 Constant<A>(lhs),rhs));
770 static inline T apply(
const T& lhs,
const T& rhs) {
784 template <
class T,
unsigned int D>
785 inline VecExpr<BinaryOp<DivOp<T>, SVector<T,D>, SVector<T,D>,
T>,
T, D>
796 template <
class A,
class T,
unsigned int D>
797 inline VecExpr<BinaryOp<DivOp<T>, VecExpr<A,T,D>, SVector<T,D>,
T>,
T, D>
807 template <
class A,
class T,
unsigned int D>
808 inline VecExpr<BinaryOp<DivOp<T>, SVector<T,D>, VecExpr<A,T,D>,
T>,
T, D>
819 template <
class A,
class B,
class T,
unsigned int D>
820 inline VecExpr<BinaryOp<DivOp<T>, VecExpr<A,T,D>, VecExpr<B,T,D>,
T>,
T, D>
837 template <
class A,
class T,
unsigned int D>
838 inline VecExpr<BinaryOpCopyR<DivOp<T>, SVector<T,D>, Constant<A>,
T>,
T, D>
854 template <
class A,
class T,
unsigned int D>
855 inline VecExpr<BinaryOpCopyL<DivOp<T>, Constant<A>, SVector<T,D>,
T>,
T, D>
866 template <
class A,
class B,
class T,
unsigned int D>
867 inline VecExpr<BinaryOpCopyR<DivOp<T>, VecExpr<B,T,D>, Constant<A>,
T>,
T, D>
877 template <
class A,
class B,
class T,
unsigned int D>
878 inline VecExpr<BinaryOpCopyL<DivOp<T>, Constant<A>, VecExpr<B,T,D>,
T>,
T, D>
895 template <
class T,
unsigned int D,
unsigned int D2,
class R1,
class R2>
896 inline 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>
900 return Expr<DivOpBinOp,T,D,D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>(DivOpBinOp(
DivOp<T>(),lhs,rhs));
907 template <
class A,
class T,
unsigned int D,
unsigned int D2,
class R1,
class R2>
908 inline 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>
910 typedef BinaryOp<DivOp<T>,
Expr<A,T,D,D2,R1>,
SMatrix<T,D,D2,R2>,
T> DivOpBinOp;
912 return Expr<DivOpBinOp,T,D,D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>(DivOpBinOp(
DivOp<T>(),lhs,rhs));
919 template <
class A,
class T,
unsigned int D,
unsigned int D2,
class R1,
class R2>
920 inline 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>
922 typedef BinaryOp<DivOp<T>,
SMatrix<T,D,D2,R1>,
Expr<A,T,D,D2,R2>,
T> DivOpBinOp;
924 return Expr<DivOpBinOp,T,D,D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>(DivOpBinOp(
DivOp<T>(),lhs,rhs));
931 template <
class A,
class B,
class T,
unsigned int D,
unsigned int D2,
class R1,
class R2>
932 inline 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>
934 typedef BinaryOp<DivOp<T>,
Expr<A,T,D,D2,R1>,
Expr<B,T,D,D2,R2>,
T> DivOpBinOp;
936 return Expr<DivOpBinOp,T,D,D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>(DivOpBinOp(
DivOp<T>(),lhs,rhs));
949 template <
class A,
class T,
unsigned int D,
unsigned int D2,
class R>
950 inline Expr<BinaryOpCopyR<DivOp<T>, SMatrix<T,D,D2,R>, Constant<A>,
T>,
T, D, D2,
R>
955 lhs,Constant<A>(rhs)));
967 template <
class A,
class T,
unsigned int D,
unsigned int D2,
class R>
968 inline Expr<BinaryOpCopyL<DivOp<T>, Constant<A>, SMatrix<T,D,D2,R>,
T>,
T, D, D2,
R>
973 Constant<A>(lhs),rhs));
980 template <
class A,
class B,
class T,
unsigned int D,
unsigned int D2,
class R>
981 inline Expr<BinaryOpCopyR<DivOp<T>, Expr<B,T,D,D2,R>, Constant<A>,
T>,
T, D, D2,
R>
986 lhs,Constant<A>(rhs)));
992 template <
class A,
class B,
class T,
unsigned int D,
unsigned int D2,
class R>
993 inline Expr<BinaryOpCopyL<DivOp<T>, Constant<A>, Expr<B,T,D,D2,R>,
T>,
T, D, D2,
R>
Constant expression class A class representing constant expressions (literals) in the parse tree...
Multiplication (element-wise) Operation Class.
Division (element-wise) Operation Class.
Binary Operation class with value storage for the left argument.
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...
Subtraction Operation Class.
DisplacementVector2D< CoordSystem1, U > operator+(DisplacementVector2D< CoordSystem1, U > v1, const DisplacementVector2D< CoordSystem2, U > &v2)
Addition of DisplacementVector2D vectors.
static T apply(const T &lhs, const T &rhs)
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.
Binary Operation class with value storage for the right argument.
static T apply(const T &lhs, const T &rhs)
BinaryOperation class A class representing binary operators in the parse tree.
Addition Operation Class.
static T apply(const T &lhs, const T &rhs)
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 ...
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...
static T apply(const T &lhs, const T &rhs)
Expression wrapper class for Vector objects.
AxisAngle operator*(RotationX const &r1, AxisAngle const &r2)
Multiplication of an axial rotation by an AxisAngle.
SVector: a generic fixed size Vector class.