File indexing completed on 2025-01-18 10:10:14
0001
0002
0003
0004 #ifndef ROOT_Math_BinaryOperators
0005 #define ROOT_Math_BinaryOperators
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #include "Math/BinaryOpPolicy.h"
0022 #include "Math/Expression.h"
0023
0024 namespace ROOT {
0025
0026 namespace Math {
0027
0028
0029
0030 template <class T, unsigned int D> class SVector;
0031 template <class T, unsigned int D1, unsigned int D2, class R> class SMatrix;
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042 template <class T>
0043 class AddOp {
0044 public:
0045 static inline T apply(const T& lhs, const T& rhs) {
0046 return lhs + rhs;
0047 }
0048 };
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060 template < class T, unsigned int D>
0061 inline VecExpr<BinaryOp<AddOp<T>, SVector<T,D>, SVector<T,D>, T>, T, D>
0062 operator+(const SVector<T,D>& lhs, const SVector<T,D>& rhs) {
0063 typedef BinaryOp<AddOp<T>, SVector<T,D>, SVector<T,D>, T> AddOpBinOp;
0064
0065 return VecExpr<AddOpBinOp,T,D>(AddOpBinOp(AddOp<T>(),lhs,rhs));
0066 }
0067
0068
0069
0070
0071
0072 template <class A, class T, unsigned int D>
0073 inline VecExpr<BinaryOp<AddOp<T>, VecExpr<A,T,D>, SVector<T,D>, T>, T, D>
0074 operator+(const VecExpr<A,T,D>& lhs, const SVector<T,D>& rhs) {
0075 typedef BinaryOp<AddOp<T>, VecExpr<A,T,D>, SVector<T,D>, T> AddOpBinOp;
0076
0077 return VecExpr<AddOpBinOp,T,D>(AddOpBinOp(AddOp<T>(),lhs,rhs));
0078 }
0079
0080
0081
0082
0083
0084 template < class A, class T, unsigned int D>
0085 inline VecExpr<BinaryOp<AddOp<T>, SVector<T,D>, VecExpr<A,T,D>, T>, T, D>
0086 operator+(const SVector<T,D>& lhs, const VecExpr<A,T,D>& rhs) {
0087 typedef BinaryOp<AddOp<T>, SVector<T,D>, VecExpr<A,T,D>, T> AddOpBinOp;
0088
0089 return VecExpr<AddOpBinOp,T,D>(AddOpBinOp(AddOp<T>(),lhs,rhs));
0090 }
0091
0092
0093
0094
0095
0096 template <class A, class B, class T, unsigned int D>
0097 inline VecExpr<BinaryOp<AddOp<T>, VecExpr<A,T,D>, VecExpr<B,T,D>, T>, T, D>
0098 operator+(const VecExpr<A,T,D>& lhs, const VecExpr<B,T,D>& rhs) {
0099 typedef BinaryOp<AddOp<T>, VecExpr<A,T,D>, VecExpr<B,T,D>, T> AddOpBinOp;
0100
0101 return VecExpr<AddOpBinOp,T,D>(AddOpBinOp(AddOp<T>(),lhs,rhs));
0102 }
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114 template <class A, class T, unsigned int D>
0115 inline VecExpr<BinaryOpCopyR<AddOp<T>, SVector<T,D>, Constant<A>, T>, T, D>
0116 operator+(const SVector<T,D>& lhs, const A& rhs) {
0117 typedef BinaryOpCopyR<AddOp<T>, SVector<T,D>, Constant<A>, T> AddOpBinOp;
0118
0119 return VecExpr<AddOpBinOp,T,D>(AddOpBinOp(AddOp<T>(),lhs,Constant<A>(rhs)));
0120 }
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131 template <class A, class T, unsigned int D>
0132 inline VecExpr<BinaryOpCopyL<AddOp<T>, Constant<A>, SVector<T,D>, T>, T, D>
0133 operator+(const A& lhs, const SVector<T,D>& rhs) {
0134 typedef BinaryOpCopyL<AddOp<T>, Constant<A>, SVector<T,D>, T> AddOpBinOp;
0135
0136 return VecExpr<AddOpBinOp,T,D>(AddOpBinOp(AddOp<T>(),Constant<A>(lhs),rhs));
0137 }
0138
0139
0140
0141
0142
0143 template <class A, class B, class T, unsigned int D>
0144 inline VecExpr<BinaryOpCopyR<AddOp<T>, VecExpr<B,T,D>, Constant<A>, T>, T, D>
0145 operator+(const VecExpr<B,T,D>& lhs, const A& rhs) {
0146 typedef BinaryOpCopyR<AddOp<T>, VecExpr<B,T,D>, Constant<A>, T> AddOpBinOp;
0147
0148 return VecExpr<AddOpBinOp,T,D>(AddOpBinOp(AddOp<T>(),lhs,Constant<A>(rhs)));
0149 }
0150
0151
0152
0153
0154 template <class A, class B, class T, unsigned int D>
0155 inline VecExpr<BinaryOpCopyL<AddOp<T>, Constant<A>, VecExpr<B,T,D>, T>, T, D>
0156 operator+(const A& lhs, const VecExpr<B,T,D>& rhs) {
0157 typedef BinaryOpCopyL<AddOp<T>, Constant<A>, VecExpr<B,T,D>, T> AddOpBinOp;
0158
0159 return VecExpr<AddOpBinOp,T,D>(AddOpBinOp(AddOp<T>(),Constant<A>(lhs),rhs));
0160 }
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172 template < class T, unsigned int D, unsigned int D2, class R1, class R2>
0173 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 >
0174 operator+(const SMatrix<T,D,D2,R1>& lhs, const SMatrix<T,D,D2,R2>& rhs) {
0175 typedef BinaryOp<AddOp<T>, SMatrix<T,D,D2,R1>, SMatrix<T,D,D2,R2>, T> AddOpBinOp;
0176
0177 return Expr<AddOpBinOp,T,D,D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>(AddOpBinOp(AddOp<T>(),lhs,rhs));
0178 }
0179
0180
0181
0182
0183
0184 template <class A, class T, unsigned int D, unsigned int D2, class R1, class R2>
0185 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>
0186 operator+(const Expr<A,T,D,D2,R1>& lhs, const SMatrix<T,D,D2,R2>& rhs) {
0187 typedef BinaryOp<AddOp<T>, Expr<A,T,D,D2,R1>, SMatrix<T,D,D2,R2>, T> AddOpBinOp;
0188
0189 return Expr<AddOpBinOp,T,D,D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>(AddOpBinOp(AddOp<T>(),lhs,rhs));
0190 }
0191
0192
0193
0194
0195
0196 template < class A, class T, unsigned int D, unsigned int D2, class R1, class R2>
0197 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>
0198 operator+(const SMatrix<T,D,D2,R1>& lhs, const Expr<A,T,D,D2,R2>& rhs) {
0199 typedef BinaryOp<AddOp<T>, SMatrix<T,D,D2,R1>, Expr<A,T,D,D2,R2>, T> AddOpBinOp;
0200
0201 return Expr<AddOpBinOp,T,D,D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>(AddOpBinOp(AddOp<T>(),lhs,rhs));
0202 }
0203
0204
0205
0206
0207
0208 template <class A, class B, class T, unsigned int D, unsigned int D2, class R1, class R2>
0209 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 >
0210 operator+(const Expr<A,T,D,D2,R1>& lhs, const Expr<B,T,D,D2,R2>& rhs) {
0211 typedef BinaryOp<AddOp<T>, Expr<A,T,D,D2,R1>, Expr<B,T,D,D2,R2>, T> AddOpBinOp;
0212
0213 return Expr<AddOpBinOp,T,D,D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>(AddOpBinOp(AddOp<T>(),lhs,rhs));
0214 }
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226 template <class A, class T, unsigned int D, unsigned int D2, class R>
0227 inline Expr<BinaryOpCopyR<AddOp<T>, SMatrix<T,D,D2,R>, Constant<A>, T>, T, D, D2, R>
0228 operator+(const SMatrix<T,D,D2,R>& lhs, const A& rhs) {
0229 typedef BinaryOpCopyR<AddOp<T>, SMatrix<T,D,D2,R>, Constant<A>, T> AddOpBinOp;
0230
0231 return Expr<AddOpBinOp,T,D,D2,R>(AddOpBinOp(AddOp<T>(),lhs,Constant<A>(rhs)));
0232 }
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243 template <class A, class T, unsigned int D, unsigned int D2, class R>
0244 inline Expr<BinaryOpCopyL<AddOp<T>, Constant<A>, SMatrix<T,D,D2,R>, T>, T, D, D2, R>
0245 operator+(const A& lhs, const SMatrix<T,D,D2,R>& rhs) {
0246 typedef BinaryOpCopyL<AddOp<T>, Constant<A>, SMatrix<T,D,D2,R>, T> AddOpBinOp;
0247
0248 return Expr<AddOpBinOp,T,D,D2,R>(AddOpBinOp(AddOp<T>(),
0249 Constant<A>(lhs),rhs));
0250 }
0251
0252
0253
0254
0255
0256 template <class A, class B, class T, unsigned int D, unsigned int D2, class R>
0257 inline Expr<BinaryOpCopyR<AddOp<T>, Expr<B,T,D,D2,R>, Constant<A>, T>, T, D, D2, R>
0258 operator+(const Expr<B,T,D,D2,R>& lhs, const A& rhs) {
0259 typedef BinaryOpCopyR<AddOp<T>, Expr<B,T,D,D2,R>, Constant<A>, T> AddOpBinOp;
0260
0261 return Expr<AddOpBinOp,T,D,D2,R>(AddOpBinOp(AddOp<T>(),
0262 lhs,Constant<A>(rhs)));
0263 }
0264
0265
0266
0267
0268 template <class A, class B, class T, unsigned int D, unsigned int D2, class R>
0269 inline Expr<BinaryOpCopyL<AddOp<T>, Constant<A>, Expr<B,T,D,D2,R>, T>, T, D, D2, R>
0270 operator+(const A& lhs, const Expr<B,T,D,D2,R>& rhs) {
0271 typedef BinaryOpCopyL<AddOp<T>, Constant<A>, Expr<B,T,D,D2,R>, T> AddOpBinOp;
0272
0273 return Expr<AddOpBinOp,T,D,D2,R>(AddOpBinOp(AddOp<T>(),
0274 Constant<A>(lhs),rhs));
0275 }
0276
0277
0278
0279
0280
0281
0282
0283
0284
0285
0286 template <class T>
0287 class MinOp {
0288 public:
0289 static inline T apply(const T& lhs, const T& rhs) {
0290 return lhs - rhs;
0291 }
0292 };
0293
0294
0295
0296
0297
0298
0299
0300
0301
0302
0303
0304 template < class T, unsigned int D>
0305 inline VecExpr<BinaryOp<MinOp<T>, SVector<T,D>, SVector<T,D>, T>, T, D>
0306 operator-(const SVector<T,D>& lhs, const SVector<T,D>& rhs) {
0307 typedef BinaryOp<MinOp<T>, SVector<T,D>, SVector<T,D>, T> MinOpBinOp;
0308
0309 return VecExpr<MinOpBinOp,T,D>(MinOpBinOp(MinOp<T>(),lhs,rhs));
0310 }
0311
0312
0313
0314
0315
0316 template <class A, class T, unsigned int D>
0317 inline VecExpr<BinaryOp<MinOp<T>, VecExpr<A,T,D>, SVector<T,D>, T>, T, D>
0318 operator-(const VecExpr<A,T,D>& lhs, const SVector<T,D>& rhs) {
0319 typedef BinaryOp<MinOp<T>, VecExpr<A,T,D>, SVector<T,D>, T> MinOpBinOp;
0320
0321 return VecExpr<MinOpBinOp,T,D>(MinOpBinOp(MinOp<T>(),lhs,rhs));
0322 }
0323
0324
0325
0326
0327
0328 template < class A, class T, unsigned int D>
0329 inline VecExpr<BinaryOp<MinOp<T>, SVector<T,D>, VecExpr<A,T,D>, T>, T, D>
0330 operator-(const SVector<T,D>& lhs, const VecExpr<A,T,D>& rhs) {
0331 typedef BinaryOp<MinOp<T>, SVector<T,D>, VecExpr<A,T,D>, T> MinOpBinOp;
0332
0333 return VecExpr<MinOpBinOp,T,D>(MinOpBinOp(MinOp<T>(),lhs,rhs));
0334 }
0335
0336
0337
0338
0339
0340 template <class A, class B, class T, unsigned int D>
0341 inline VecExpr<BinaryOp<MinOp<T>, VecExpr<A,T,D>, VecExpr<B,T,D>, T>, T, D>
0342 operator-(const VecExpr<A,T,D>& lhs, const VecExpr<B,T,D>& rhs) {
0343 typedef BinaryOp<MinOp<T>, VecExpr<A,T,D>, VecExpr<B,T,D>, T> MinOpBinOp;
0344
0345 return VecExpr<MinOpBinOp,T,D>(MinOpBinOp(MinOp<T>(),lhs,rhs));
0346 }
0347
0348
0349
0350
0351
0352
0353
0354
0355
0356
0357
0358 template <class A, class T, unsigned int D>
0359 inline VecExpr<BinaryOpCopyR<MinOp<T>, SVector<T,D>, Constant<A>, T>, T, D>
0360 operator-(const SVector<T,D>& lhs, const A& rhs) {
0361 typedef BinaryOpCopyR<MinOp<T>, SVector<T,D>, Constant<A>, T> MinOpBinOp;
0362
0363 return VecExpr<MinOpBinOp,T,D>(MinOpBinOp(MinOp<T>(),lhs,Constant<A>(rhs)));
0364 }
0365
0366
0367
0368
0369
0370
0371
0372
0373
0374
0375 template <class A, class T, unsigned int D>
0376 inline VecExpr<BinaryOpCopyL<MinOp<T>, Constant<A>, SVector<T,D>, T>, T, D>
0377 operator-(const A& lhs, const SVector<T,D>& rhs) {
0378 typedef BinaryOpCopyL<MinOp<T>, Constant<A>, SVector<T,D>, T> MinOpBinOp;
0379
0380 return VecExpr<MinOpBinOp,T,D>(MinOpBinOp(MinOp<T>(),Constant<A>(lhs),rhs));
0381 }
0382
0383
0384
0385
0386
0387 template <class A, class B, class T, unsigned int D>
0388 inline VecExpr<BinaryOpCopyR<MinOp<T>, VecExpr<B,T,D>, Constant<A>, T>, T, D>
0389 operator-(const VecExpr<B,T,D>& lhs, const A& rhs) {
0390 typedef BinaryOpCopyR<MinOp<T>, VecExpr<B,T,D>, Constant<A>, T> MinOpBinOp;
0391
0392 return VecExpr<MinOpBinOp,T,D>(MinOpBinOp(MinOp<T>(),lhs,Constant<A>(rhs)));
0393 }
0394
0395
0396
0397
0398 template <class A, class B, class T, unsigned int D>
0399 inline VecExpr<BinaryOpCopyL<MinOp<T>, Constant<A>, VecExpr<B,T,D>, T>, T, D>
0400 operator-(const A& lhs, const VecExpr<B,T,D>& rhs) {
0401 typedef BinaryOpCopyL<MinOp<T>, Constant<A>, VecExpr<B,T,D>, T> MinOpBinOp;
0402
0403 return VecExpr<MinOpBinOp,T,D>(MinOpBinOp(MinOp<T>(),Constant<A>(lhs),rhs));
0404 }
0405
0406
0407
0408
0409
0410
0411
0412
0413
0414
0415
0416 template < class T, unsigned int D, unsigned int D2, class R1, class R2>
0417 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>
0418 operator-(const SMatrix<T,D,D2,R1>& lhs, const SMatrix<T,D,D2,R2>& rhs) {
0419 typedef BinaryOp<MinOp<T>, SMatrix<T,D,D2,R1>, SMatrix<T,D,D2,R2>, T> MinOpBinOp;
0420
0421 return Expr<MinOpBinOp,T,D,D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>(MinOpBinOp(MinOp<T>(),lhs,rhs));
0422 }
0423
0424
0425
0426
0427
0428 template <class A, class T, unsigned int D, unsigned int D2, class R1, class R2>
0429 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>
0430 operator-(const Expr<A,T,D,D2,R1>& lhs, const SMatrix<T,D,D2,R2>& rhs) {
0431 typedef BinaryOp<MinOp<T>, Expr<A,T,D,D2,R1>, SMatrix<T,D,D2,R2>, T> MinOpBinOp;
0432
0433 return Expr<MinOpBinOp,T,D,D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>(MinOpBinOp(MinOp<T>(),lhs,rhs));
0434 }
0435
0436
0437
0438
0439
0440 template < class A, class T, unsigned int D, unsigned int D2, class R1, class R2>
0441 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>
0442 operator-(const SMatrix<T,D,D2,R1>& lhs, const Expr<A,T,D,D2,R2>& rhs) {
0443 typedef BinaryOp<MinOp<T>, SMatrix<T,D,D2,R1>, Expr<A,T,D,D2,R2>, T> MinOpBinOp;
0444
0445 return Expr<MinOpBinOp,T,D,D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>(MinOpBinOp(MinOp<T>(),lhs,rhs));
0446 }
0447
0448
0449
0450
0451
0452 template <class A, class B, class T, unsigned int D, unsigned int D2, class R1, class R2>
0453 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>
0454 operator-(const Expr<A,T,D,D2,R1>& lhs, const Expr<B,T,D,D2,R2>& rhs) {
0455 typedef BinaryOp<MinOp<T>, Expr<A,T,D,D2,R1>, Expr<B,T,D,D2,R2>, T> MinOpBinOp;
0456
0457 return Expr<MinOpBinOp,T,D,D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>(MinOpBinOp(MinOp<T>(),lhs,rhs));
0458 }
0459
0460
0461
0462
0463
0464
0465
0466
0467
0468
0469
0470 template <class A, class T, unsigned int D, unsigned int D2, class R>
0471 inline Expr<BinaryOpCopyR<MinOp<T>, SMatrix<T,D,D2,R>, Constant<A>, T>, T, D, D2, R>
0472 operator-(const SMatrix<T,D,D2,R>& lhs, const A& rhs) {
0473 typedef BinaryOpCopyR<MinOp<T>, SMatrix<T,D,D2,R>, Constant<A>, T> MinOpBinOp;
0474
0475 return Expr<MinOpBinOp,T,D,D2,R>(MinOpBinOp(MinOp<T>(),
0476 lhs,Constant<A>(rhs)));
0477 }
0478
0479
0480
0481
0482
0483
0484
0485
0486
0487
0488 template <class A, class T, unsigned int D, unsigned int D2, class R>
0489 inline Expr<BinaryOpCopyL<MinOp<T>, Constant<A>, SMatrix<T,D,D2,R>, T>, T, D, D2, R>
0490 operator-(const A& lhs, const SMatrix<T,D,D2,R>& rhs) {
0491 typedef BinaryOpCopyL<MinOp<T>, Constant<A>, SMatrix<T,D,D2,R>, T> MinOpBinOp;
0492
0493 return Expr<MinOpBinOp,T,D,D2,R>(MinOpBinOp(MinOp<T>(),Constant<A>(lhs),rhs));
0494 }
0495
0496
0497
0498
0499 template <class A, class B, class T, unsigned int D, unsigned int D2, class R>
0500 inline Expr<BinaryOpCopyR<MinOp<T>, Expr<B,T,D,D2,R>, Constant<A>, T>, T, D, D2, R>
0501 operator-(const Expr<B,T,D,D2,R>& lhs, const A& rhs) {
0502 typedef BinaryOpCopyR<MinOp<T>, Expr<B,T,D,D2,R>, Constant<A>, T> MinOpBinOp;
0503
0504 return Expr<MinOpBinOp,T,D,D2,R>(MinOpBinOp(MinOp<T>(),lhs,Constant<A>(rhs)));
0505 }
0506
0507
0508
0509
0510 template <class A, class B, class T, unsigned int D, unsigned int D2, class R>
0511 inline Expr<BinaryOpCopyL<MinOp<T>, Constant<A>, Expr<B,T,D,D2,R>, T>, T, D, D2, R>
0512 operator-(const A& lhs, const Expr<B,T,D,D2,R>& rhs) {
0513 typedef BinaryOpCopyL<MinOp<T>, Constant<A>, Expr<B,T,D,D2,R>, T> MinOpBinOp;
0514
0515 return Expr<MinOpBinOp,T,D,D2,R>(MinOpBinOp(MinOp<T>(),
0516 Constant<A>(lhs),rhs));
0517 }
0518
0519
0520
0521
0522
0523
0524
0525
0526
0527
0528 template <class T>
0529 class MulOp {
0530 public:
0531 static inline T apply(const T& lhs, const T& rhs) {
0532 return lhs * rhs;
0533 }
0534 };
0535
0536
0537
0538
0539
0540
0541
0542
0543
0544
0545
0546 template < class T, unsigned int D>
0547 inline VecExpr<BinaryOp<MulOp<T>, SVector<T,D>, SVector<T,D>, T>, T, D>
0548 operator*(const SVector<T,D>& lhs, const SVector<T,D>& rhs) {
0549 typedef BinaryOp<MulOp<T>, SVector<T,D>, SVector<T,D>, T> MulOpBinOp;
0550
0551 return VecExpr<MulOpBinOp,T,D>(MulOpBinOp(MulOp<T>(),lhs,rhs));
0552 }
0553
0554
0555
0556
0557
0558
0559
0560
0561
0562
0563
0564 template <class A, class T, unsigned int D>
0565 inline VecExpr<BinaryOp<MulOp<T>, Expr<A,T,D>, SVector<T,D>, T>, T, D>
0566 operator*(const VecExpr<A,T,D>& lhs, const SVector<T,D>& rhs) {
0567 typedef BinaryOp<MulOp<T>, VecExpr<A,T,D>, SVector<T,D>, T> MulOpBinOp;
0568 return VecExpr<MulOpBinOp,T,D>(MulOpBinOp(MulOp<T>(),lhs,rhs));
0569 }
0570
0571
0572
0573
0574
0575 template < class A, class T, unsigned int D>
0576 inline VecExpr<BinaryOp<MulOp<T>, SVector<T,D>, VecExpr<A,T,D>, T>, T, D>
0577 operator*(const SVector<T,D>& lhs, const VecExpr<A,T,D>& rhs) {
0578 typedef BinaryOp<MulOp<T>, SVector<T,D>, VecExpr<A,T,D>, T> MulOpBinOp;
0579 return VecExpr<MulOpBinOp,T,D>(MulOpBinOp(MulOp<T>(),lhs,rhs));
0580 }
0581
0582
0583
0584
0585
0586 template <class A, class B, class T, unsigned int D>
0587 inline VecExpr<BinaryOp<MulOp<T>, VecExpr<A,T,D>, VecExpr<B,T,D>, T>, T, D>
0588 operator*(const VecExpr<A,T,D>& lhs, const VecExpr<B,T,D>& rhs) {
0589 typedef BinaryOp<MulOp<T>, VecExpr<A,T,D>, VecExpr<B,T,D>, T> MulOpBinOp;
0590 return VecExpr<MulOpBinOp,T,D>(MulOpBinOp(MulOp<T>(),lhs,rhs));
0591 }
0592
0593
0594
0595
0596
0597 template <class A, class T, unsigned int D>
0598 inline VecExpr<BinaryOpCopyR<MulOp<T>, SVector<T,D>, Constant<A>, T>, T, D>
0599 operator*(const SVector<T,D>& lhs, const A& rhs) {
0600 typedef BinaryOpCopyR<MulOp<T>, SVector<T,D>, Constant<A>, T> MulOpBinOp;
0601
0602 return VecExpr<MulOpBinOp,T,D>(MulOpBinOp(MulOp<T>(),lhs,Constant<A>(rhs)));
0603 }
0604
0605
0606
0607
0608 template <class A, class T, unsigned int D>
0609 inline VecExpr<BinaryOpCopyL<MulOp<T>, Constant<A>, SVector<T,D>, T>, T, D>
0610 operator*(const A& lhs, const SVector<T,D>& rhs) {
0611 typedef BinaryOpCopyL<MulOp<T>, Constant<A>, SVector<T,D>, T> MulOpBinOp;
0612
0613 return VecExpr<MulOpBinOp,T,D>(MulOpBinOp(MulOp<T>(),Constant<A>(lhs),rhs));
0614 }
0615
0616
0617
0618
0619
0620 template <class A, class B, class T, unsigned int D>
0621 inline VecExpr<BinaryOpCopyR<MulOp<T>, VecExpr<B,T,D>, Constant<A>, T>, T, D>
0622 operator*(const VecExpr<B,T,D>& lhs, const A& rhs) {
0623 typedef BinaryOpCopyR<MulOp<T>, VecExpr<B,T,D>, Constant<A>, T> MulOpBinOp;
0624
0625 return VecExpr<MulOpBinOp,T,D>(MulOpBinOp(MulOp<T>(),lhs,Constant<A>(rhs)));
0626 }
0627
0628
0629
0630
0631 template <class A, class B, class T, unsigned int D>
0632 inline VecExpr<BinaryOpCopyL<MulOp<T>, Constant<A>, VecExpr<B,T,D>, T>, T, D>
0633 operator*(const A& lhs, const VecExpr<B,T,D>& rhs) {
0634 typedef BinaryOpCopyL<MulOp<T>, Constant<A>, VecExpr<B,T,D>, T> MulOpBinOp;
0635
0636 return VecExpr<MulOpBinOp,T,D>(MulOpBinOp(MulOp<T>(),Constant<A>(lhs),rhs));
0637 }
0638
0639
0640
0641
0642
0643
0644
0645
0646
0647
0648
0649
0650 template < class T, unsigned int D, unsigned int D2, class R1, class R2>
0651 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>
0652 Times(const SMatrix<T,D,D2,R1>& lhs, const SMatrix<T,D,D2,R2>& rhs) {
0653 typedef BinaryOp<MulOp<T>, SMatrix<T,D,D2,R1>, SMatrix<T,D,D2,R2>, T> MulOpBinOp;
0654
0655 return Expr<MulOpBinOp,T,D,D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>(MulOpBinOp(MulOp<T>(),lhs,rhs));
0656 }
0657
0658
0659
0660
0661
0662 template <class A, class T, unsigned int D, unsigned int D2, class R1, class R2>
0663 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>
0664 Times(const Expr<A,T,D,D2,R1>& lhs, const SMatrix<T,D,D2,R2>& rhs) {
0665 typedef BinaryOp<MulOp<T>, Expr<A,T,D,D2,R1>, SMatrix<T,D,D2,R2>, T> MulOpBinOp;
0666
0667 return Expr<MulOpBinOp,T,D,D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>(MulOpBinOp(MulOp<T>(),lhs,rhs));
0668 }
0669
0670
0671
0672
0673
0674 template < class A, class T, unsigned int D, unsigned int D2, class R1, class R2>
0675 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>
0676 Times(const SMatrix<T,D,D2,R1>& lhs, const Expr<A,T,D,D2,R2>& rhs) {
0677 typedef BinaryOp<MulOp<T>, SMatrix<T,D,D2,R1>, Expr<A,T,D,D2,R2>, T> MulOpBinOp;
0678
0679 return Expr<MulOpBinOp,T,D,D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>(MulOpBinOp(MulOp<T>(),lhs,rhs));
0680 }
0681
0682
0683
0684
0685
0686 template <class A, class B, class T, unsigned int D, unsigned int D2, class R1, class R2>
0687 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>
0688 Times(const Expr<A,T,D,D2,R1>& lhs, const Expr<B,T,D,D2,R2>& rhs) {
0689 typedef BinaryOp<MulOp<T>, Expr<A,T,D,D2,R1>, Expr<B,T,D,D2,R2>, T> MulOpBinOp;
0690
0691 return Expr<MulOpBinOp,T,D,D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>(MulOpBinOp(MulOp<T>(),lhs,rhs));
0692 }
0693
0694
0695
0696
0697
0698
0699
0700
0701
0702
0703
0704 template <class A, class T, unsigned int D, unsigned int D2, class R>
0705 inline Expr<BinaryOpCopyR<MulOp<T>, SMatrix<T,D,D2,R>, Constant<A>, T>, T, D, D2, R>
0706 operator*(const SMatrix<T,D,D2,R>& lhs, const A& rhs) {
0707 typedef BinaryOpCopyR<MulOp<T>, SMatrix<T,D,D2,R>, Constant<A>, T> MulOpBinOp;
0708
0709 return Expr<MulOpBinOp,T,D,D2,R>(MulOpBinOp(MulOp<T>(),
0710 lhs,Constant<A>(rhs)));
0711 }
0712
0713
0714
0715
0716
0717
0718
0719
0720
0721
0722 template <class A, class T, unsigned int D, unsigned int D2, class R>
0723 inline Expr<BinaryOpCopyL<MulOp<T>, Constant<A>, SMatrix<T,D,D2,R>, T>, T, D, D2, R>
0724 operator*(const A& lhs, const SMatrix<T,D,D2,R>& rhs) {
0725 typedef BinaryOpCopyL<MulOp<T>, Constant<A>, SMatrix<T,D,D2,R>, T> MulOpBinOp;
0726
0727 return Expr<MulOpBinOp,T,D,D2,R>(MulOpBinOp(MulOp<T>(),
0728 Constant<A>(lhs),rhs));
0729 }
0730
0731
0732
0733
0734
0735 template <class A, class B, class T, unsigned int D, unsigned int D2, class R>
0736 inline Expr<BinaryOpCopyR<MulOp<T>, Expr<B,T,D,D2,R>, Constant<A>, T>, T, D, D2, R>
0737 operator*(const Expr<B,T,D,D2,R>& lhs, const A& rhs) {
0738 typedef BinaryOpCopyR<MulOp<T>, Expr<B,T,D,D2,R>, Constant<A>, T> MulOpBinOp;
0739
0740 return Expr<MulOpBinOp,T,D,D2,R>(MulOpBinOp(MulOp<T>(),
0741 lhs,Constant<A>(rhs)));
0742 }
0743
0744
0745
0746
0747 template <class A, class B, class T, unsigned int D, unsigned int D2, class R>
0748 inline Expr<BinaryOpCopyL<MulOp<T>, Constant<A>, Expr<B,T,D,D2,R>, T>, T, D, D2, R>
0749 operator*(const A& lhs, const Expr<B,T,D,D2,R>& rhs) {
0750 typedef BinaryOpCopyL<MulOp<T>, Constant<A>, Expr<B,T,D,D2,R>, T> MulOpBinOp;
0751
0752 return Expr<MulOpBinOp,T,D,D2,R>(MulOpBinOp(MulOp<T>(),
0753 Constant<A>(lhs),rhs));
0754 }
0755
0756
0757
0758
0759
0760
0761
0762
0763
0764
0765 template <class T>
0766 class DivOp {
0767 public:
0768 static inline T apply(const T& lhs, const T& rhs) {
0769 return lhs / rhs;
0770 }
0771 };
0772
0773
0774
0775
0776
0777
0778
0779
0780
0781
0782 template < class T, unsigned int D>
0783 inline VecExpr<BinaryOp<DivOp<T>, SVector<T,D>, SVector<T,D>, T>, T, D>
0784 operator/(const SVector<T,D>& lhs, const SVector<T,D>& rhs) {
0785 typedef BinaryOp<DivOp<T>, SVector<T,D>, SVector<T,D>, T> DivOpBinOp;
0786
0787 return VecExpr<DivOpBinOp,T,D>(DivOpBinOp(DivOp<T>(),lhs,rhs));
0788 }
0789
0790
0791
0792
0793
0794 template <class A, class T, unsigned int D>
0795 inline VecExpr<BinaryOp<DivOp<T>, VecExpr<A,T,D>, SVector<T,D>, T>, T, D>
0796 operator/(const VecExpr<A,T,D>& lhs, const SVector<T,D>& rhs) {
0797 typedef BinaryOp<DivOp<T>, VecExpr<A,T,D>, SVector<T,D>, T> DivOpBinOp;
0798 return VecExpr<DivOpBinOp,T,D>(DivOpBinOp(DivOp<T>(),lhs,rhs));
0799 }
0800
0801
0802
0803
0804
0805 template < class A, class T, unsigned int D>
0806 inline VecExpr<BinaryOp<DivOp<T>, SVector<T,D>, VecExpr<A,T,D>, T>, T, D>
0807 operator/(const SVector<T,D>& lhs, const VecExpr<A,T,D>& rhs) {
0808 typedef BinaryOp<DivOp<T>, SVector<T,D>, VecExpr<A,T,D>, T> DivOpBinOp;
0809
0810 return VecExpr<DivOpBinOp,T,D>(DivOpBinOp(DivOp<T>(),lhs,rhs));
0811 }
0812
0813
0814
0815
0816
0817 template <class A, class B, class T, unsigned int D>
0818 inline VecExpr<BinaryOp<DivOp<T>, VecExpr<A,T,D>, VecExpr<B,T,D>, T>, T, D>
0819 operator/(const VecExpr<A,T,D>& lhs, const VecExpr<B,T,D>& rhs) {
0820 typedef BinaryOp<DivOp<T>, VecExpr<A,T,D>, VecExpr<B,T,D>, T> DivOpBinOp;
0821
0822 return VecExpr<DivOpBinOp,T,D>(DivOpBinOp(DivOp<T>(),lhs,rhs));
0823 }
0824
0825
0826
0827
0828
0829
0830
0831
0832
0833
0834
0835 template <class A, class T, unsigned int D>
0836 inline VecExpr<BinaryOpCopyR<DivOp<T>, SVector<T,D>, Constant<A>, T>, T, D>
0837 operator/(const SVector<T,D>& lhs, const A& rhs) {
0838 typedef BinaryOpCopyR<DivOp<T>, SVector<T,D>, Constant<A>, T> DivOpBinOp;
0839
0840 return VecExpr<DivOpBinOp,T,D>(DivOpBinOp(DivOp<T>(),lhs,Constant<A>(rhs)));
0841 }
0842
0843
0844
0845
0846
0847
0848
0849
0850
0851
0852 template <class A, class T, unsigned int D>
0853 inline VecExpr<BinaryOpCopyL<DivOp<T>, Constant<A>, SVector<T,D>, T>, T, D>
0854 operator/(const A& lhs, const SVector<T,D>& rhs) {
0855 typedef BinaryOpCopyL<DivOp<T>, Constant<A>, SVector<T,D>, T> DivOpBinOp;
0856
0857 return VecExpr<DivOpBinOp,T,D>(DivOpBinOp(DivOp<T>(),Constant<A>(lhs),rhs));
0858 }
0859
0860
0861
0862
0863
0864 template <class A, class B, class T, unsigned int D>
0865 inline VecExpr<BinaryOpCopyR<DivOp<T>, VecExpr<B,T,D>, Constant<A>, T>, T, D>
0866 operator/(const VecExpr<B,T,D>& lhs, const A& rhs) {
0867 typedef BinaryOpCopyR<DivOp<T>, VecExpr<B,T,D>, Constant<A>, T> DivOpBinOp;
0868
0869 return VecExpr<DivOpBinOp,T,D>(DivOpBinOp(DivOp<T>(),lhs,Constant<A>(rhs)));
0870 }
0871
0872
0873
0874
0875 template <class A, class B, class T, unsigned int D>
0876 inline VecExpr<BinaryOpCopyL<DivOp<T>, Constant<A>, VecExpr<B,T,D>, T>, T, D>
0877 operator/(const A& lhs, const VecExpr<B,T,D>& rhs) {
0878 typedef BinaryOpCopyL<DivOp<T>, Constant<A>, VecExpr<B,T,D>, T> DivOpBinOp;
0879
0880 return VecExpr<DivOpBinOp,T,D>(DivOpBinOp(DivOp<T>(),Constant<A>(lhs),rhs));
0881 }
0882
0883
0884
0885
0886
0887
0888
0889
0890
0891
0892
0893 template < class T, unsigned int D, unsigned int D2, class R1, class R2>
0894 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>
0895 Div(const SMatrix<T,D,D2,R1>& lhs, const SMatrix<T,D,D2,R2>& rhs) {
0896 typedef BinaryOp<DivOp<T>, SMatrix<T,D,D2,R1>, SMatrix<T,D,D2,R2>, T> DivOpBinOp;
0897
0898 return Expr<DivOpBinOp,T,D,D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>(DivOpBinOp(DivOp<T>(),lhs,rhs));
0899 }
0900
0901
0902
0903
0904
0905 template <class A, class T, unsigned int D, unsigned int D2, class R1, class R2>
0906 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>
0907 Div(const Expr<A,T,D,D2,R1>& lhs, const SMatrix<T,D,D2,R2>& rhs) {
0908 typedef BinaryOp<DivOp<T>, Expr<A,T,D,D2,R1>, SMatrix<T,D,D2,R2>, T> DivOpBinOp;
0909
0910 return Expr<DivOpBinOp,T,D,D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>(DivOpBinOp(DivOp<T>(),lhs,rhs));
0911 }
0912
0913
0914
0915
0916
0917 template < class A, class T, unsigned int D, unsigned int D2, class R1, class R2>
0918 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>
0919 Div(const SMatrix<T,D,D2,R1>& lhs, const Expr<A,T,D,D2,R2>& rhs) {
0920 typedef BinaryOp<DivOp<T>, SMatrix<T,D,D2,R1>, Expr<A,T,D,D2,R2>, T> DivOpBinOp;
0921
0922 return Expr<DivOpBinOp,T,D,D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>(DivOpBinOp(DivOp<T>(),lhs,rhs));
0923 }
0924
0925
0926
0927
0928
0929 template <class A, class B, class T, unsigned int D, unsigned int D2, class R1, class R2>
0930 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>
0931 Div(const Expr<A,T,D,D2,R1>& lhs, const Expr<B,T,D,D2,R2>& rhs) {
0932 typedef BinaryOp<DivOp<T>, Expr<A,T,D,D2,R1>, Expr<B,T,D,D2,R2>, T> DivOpBinOp;
0933
0934 return Expr<DivOpBinOp,T,D,D2,typename AddPolicy<T,D,D2,R1,R2>::RepType>(DivOpBinOp(DivOp<T>(),lhs,rhs));
0935 }
0936
0937
0938
0939
0940
0941
0942
0943
0944
0945
0946
0947 template <class A, class T, unsigned int D, unsigned int D2, class R>
0948 inline Expr<BinaryOpCopyR<DivOp<T>, SMatrix<T,D,D2,R>, Constant<A>, T>, T, D, D2, R>
0949 operator/(const SMatrix<T,D,D2,R>& lhs, const A& rhs) {
0950 typedef BinaryOpCopyR<DivOp<T>, SMatrix<T,D,D2,R>, Constant<A>, T> DivOpBinOp;
0951
0952 return Expr<DivOpBinOp,T,D,D2,R>(DivOpBinOp(DivOp<T>(),
0953 lhs,Constant<A>(rhs)));
0954 }
0955
0956
0957
0958
0959
0960
0961
0962
0963
0964
0965 template <class A, class T, unsigned int D, unsigned int D2, class R>
0966 inline Expr<BinaryOpCopyL<DivOp<T>, Constant<A>, SMatrix<T,D,D2,R>, T>, T, D, D2, R>
0967 operator/(const A& lhs, const SMatrix<T,D,D2,R>& rhs) {
0968 typedef BinaryOpCopyL<DivOp<T>, Constant<A>, SMatrix<T,D,D2,R>, T> DivOpBinOp;
0969
0970 return Expr<DivOpBinOp,T,D,D2,R>(DivOpBinOp(DivOp<T>(),
0971 Constant<A>(lhs),rhs));
0972 }
0973
0974
0975
0976
0977
0978 template <class A, class B, class T, unsigned int D, unsigned int D2, class R>
0979 inline Expr<BinaryOpCopyR<DivOp<T>, Expr<B,T,D,D2,R>, Constant<A>, T>, T, D, D2, R>
0980 operator/(const Expr<B,T,D,D2,R>& lhs, const A& rhs) {
0981 typedef BinaryOpCopyR<DivOp<T>, Expr<B,T,D,D2,R>, Constant<A>, T> DivOpBinOp;
0982
0983 return Expr<DivOpBinOp,T,D,D2,R>(DivOpBinOp(DivOp<T>(),
0984 lhs,Constant<A>(rhs)));
0985 }
0986
0987
0988
0989
0990 template <class A, class B, class T, unsigned int D, unsigned int D2, class R>
0991 inline Expr<BinaryOpCopyL<DivOp<T>, Constant<A>, Expr<B,T,D,D2,R>, T>, T, D, D2,R>
0992 operator/(const A& lhs, const Expr<B,T,D,D2,R>& rhs) {
0993 typedef BinaryOpCopyL<DivOp<T>, Constant<A>, Expr<B,T,D,D2,R>, T> DivOpBinOp;
0994
0995 return Expr<DivOpBinOp,T,D,D2,R>(DivOpBinOp(DivOp<T>(),Constant<A>(lhs),rhs));
0996 }
0997
0998
0999
1000 }
1001
1002 }
1003
1004
1005 #endif