00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef TVMET_MATRIX_BINARY_FUNCTIONS_H
00025 #define TVMET_MATRIX_BINARY_FUNCTIONS_H
00026
00027 namespace tvmet {
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #define TVMET_DECLARE_MACRO(NAME) \
00039 template<class T1, class T2, std::size_t Rows, std::size_t Cols> \
00040 XprMatrix< \
00041 XprBinOp< \
00042 Fcnl_##NAME<T1, T2>, \
00043 MatrixConstReference<T1, Rows, Cols>, \
00044 MatrixConstReference<T2, Rows, Cols> \
00045 >, \
00046 Rows, Cols \
00047 > \
00048 NAME(const Matrix<T1, Rows, Cols>& lhs, \
00049 const Matrix<T2, Cols, Cols>& rhs) TVMET_CXX_ALWAYS_INLINE; \
00050 \
00051 template<class E, class T, std::size_t Rows, std::size_t Cols> \
00052 XprMatrix< \
00053 XprBinOp< \
00054 Fcnl_##NAME<typename E::value_type, T>, \
00055 MatrixConstReference<T, Rows, Cols>, \
00056 XprMatrix<E, Rows, Cols> \
00057 >, \
00058 Rows, Cols \
00059 > \
00060 NAME(const XprMatrix<E, Rows, Cols>& lhs, \
00061 const Matrix<T, Rows, Cols>& rhs) TVMET_CXX_ALWAYS_INLINE; \
00062 \
00063 template<class E, class T, std::size_t Rows, std::size_t Cols> \
00064 XprMatrix< \
00065 XprBinOp< \
00066 Fcnl_##NAME<T, typename E::value_type>, \
00067 MatrixConstReference<T, Rows, Cols>, \
00068 XprMatrix<E, Rows, Cols> \
00069 >, \
00070 Rows, Cols \
00071 > \
00072 NAME(const Matrix<T, Rows, Cols>& lhs, \
00073 const XprMatrix<E, Rows, Cols>& rhs) TVMET_CXX_ALWAYS_INLINE;
00074
00075 TVMET_DECLARE_MACRO(atan2)
00076 TVMET_DECLARE_MACRO(fmod)
00077 TVMET_DECLARE_MACRO(pow)
00078 #if defined(TVMET_HAVE_DREM)
00079 TVMET_DECLARE_MACRO(drem)
00080 #endif
00081 #if defined(TVMET_HAVE_HYPOT)
00082 TVMET_DECLARE_MACRO(hypot)
00083 #endif
00084 #if defined(TVMET_HAVE_JN)
00085 TVMET_DECLARE_MACRO(jn)
00086 #endif
00087 #if defined(TVMET_HAVE_YN)
00088 TVMET_DECLARE_MACRO(yn)
00089 #endif
00090
00091 #undef TVMET_DECLARE_MACRO
00092
00093
00094
00095
00096
00097 #define TVMET_DECLARE_MACRO(NAME, TP) \
00098 template<class T, std::size_t Rows, std::size_t Cols> \
00099 XprMatrix< \
00100 XprBinOp< \
00101 Fcnl_##NAME<T, TP >, \
00102 MatrixConstReference<T, Rows, Cols>, \
00103 XprLiteral< TP > \
00104 >, \
00105 Rows, Cols \
00106 > \
00107 NAME(const Matrix<T, Rows, Cols>& lhs, TP rhs) TVMET_CXX_ALWAYS_INLINE;
00108
00109 TVMET_DECLARE_MACRO(atan2, int)
00110 TVMET_DECLARE_MACRO(fmod, int)
00111 TVMET_DECLARE_MACRO(pow, int)
00112 #if defined(TVMET_HAVE_DREM)
00113 TVMET_DECLARE_MACRO(drem, int)
00114 #endif
00115 #if defined(TVMET_HAVE_HYPOT)
00116 TVMET_DECLARE_MACRO(hypot, int)
00117 #endif
00118 #if defined(TVMET_HAVE_JN)
00119 TVMET_DECLARE_MACRO(jn, int)
00120 #endif
00121 #if defined(TVMET_HAVE_YN)
00122 TVMET_DECLARE_MACRO(yn, int)
00123 #endif
00124
00125
00126 #if defined(TVMET_HAVE_LONG_LONG)
00127 TVMET_DECLARE_MACRO(atan2, long long int)
00128 TVMET_DECLARE_MACRO(fmod, long long int)
00129 TVMET_DECLARE_MACRO(pow, long long int)
00130 #if defined(TVMET_HAVE_DREM)
00131 TVMET_DECLARE_MACRO(drem, long long int)
00132 #endif
00133 #if defined(TVMET_HAVE_HYPOT)
00134 TVMET_DECLARE_MACRO(hypot, long long int)
00135 #endif
00136 #if defined(TVMET_HAVE_JN)
00137 TVMET_DECLARE_MACRO(jn, long long int)
00138 #endif
00139 #if defined(TVMET_HAVE_YN)
00140 TVMET_DECLARE_MACRO(yn, long long int)
00141 #endif
00142 #endif // defined(TVMET_HAVE_LONG_LONG)
00143
00144
00145 TVMET_DECLARE_MACRO(atan2, float)
00146 TVMET_DECLARE_MACRO(fmod, float)
00147 TVMET_DECLARE_MACRO(pow, float)
00148 #if defined(TVMET_HAVE_DREM)
00149 TVMET_DECLARE_MACRO(drem, float)
00150 #endif
00151 #if defined(TVMET_HAVE_HYPOT)
00152 TVMET_DECLARE_MACRO(hypot, float)
00153 #endif
00154 #if defined(TVMET_HAVE_JN)
00155 TVMET_DECLARE_MACRO(jn, float)
00156 #endif
00157 #if defined(TVMET_HAVE_YN)
00158 TVMET_DECLARE_MACRO(yn, float)
00159 #endif
00160
00161
00162 TVMET_DECLARE_MACRO(atan2, double)
00163 TVMET_DECLARE_MACRO(fmod, double)
00164 TVMET_DECLARE_MACRO(pow, double)
00165 #if defined(TVMET_HAVE_DREM)
00166 TVMET_DECLARE_MACRO(drem, double)
00167 #endif
00168 #if defined(TVMET_HAVE_HYPOT)
00169 TVMET_DECLARE_MACRO(hypot, double)
00170 #endif
00171 #if defined(TVMET_HAVE_JN)
00172 TVMET_DECLARE_MACRO(jn, double)
00173 #endif
00174 #if defined(TVMET_HAVE_YN)
00175 TVMET_DECLARE_MACRO(yn, double)
00176 #endif
00177
00178
00179 #if defined(TVMET_HAVE_LONG_DOUBLE)
00180 TVMET_DECLARE_MACRO(atan2, long double)
00181 TVMET_DECLARE_MACRO(fmod, long double)
00182 TVMET_DECLARE_MACRO(pow, long double)
00183 #if defined(TVMET_HAVE_DREM)
00184 TVMET_DECLARE_MACRO(drem, long double)
00185 #endif
00186 #if defined(TVMET_HAVE_HYPOT)
00187 TVMET_DECLARE_MACRO(hypot, long double)
00188 #endif
00189 #if defined(TVMET_HAVE_JN)
00190 TVMET_DECLARE_MACRO(jn, long double)
00191 #endif
00192 #if defined(TVMET_HAVE_YN)
00193 TVMET_DECLARE_MACRO(yn, long double)
00194 #endif
00195 #endif // defined(TVMET_HAVE_LONG_DOUBLE)
00196
00197 #undef TVMET_DECLARE_MACRO
00198
00199
00200
00201
00202
00203
00204 #if defined(TVMET_HAVE_COMPLEX) && defined(TVMET_HAVE_COMPLEX_MATH1)
00205 template<class T, std::size_t Rows, std::size_t Cols>
00206 XprMatrix<
00207 XprBinOp<
00208 Fcnl_pow<T, std::complex<T> >,
00209 MatrixConstReference<T, Rows, Cols>,
00210 XprLiteral< std::complex<T> >
00211 >,
00212 Rows, Cols
00213 >
00214 pow(const Matrix<T, Rows, Cols>& lhs,
00215 const std::complex<T>& rhs) TVMET_CXX_ALWAYS_INLINE;
00216
00217
00218 template<class T, std::size_t Rows, std::size_t Cols>
00219 XprMatrix<
00220 XprBinOp<
00221 Fcnl_pow< std::complex<T>, std::complex<T> >,
00222 MatrixConstReference<std::complex<T>, Rows, Cols>,
00223 XprLiteral< std::complex<T> >
00224 >,
00225 Rows, Cols
00226 >
00227 pow(const Matrix<std::complex<T>, Rows, Cols>& lhs,
00228 const std::complex<T>& rhs) TVMET_CXX_ALWAYS_INLINE;
00229
00230
00235 template<class T, std::size_t Rows, std::size_t Cols>
00236 XprMatrix<
00237 XprBinOp<
00238 Fcnl_pow<std::complex<T>, T>,
00239 MatrixConstReference<std::complex<T>, Rows, Cols>,
00240 XprLiteral<T>
00241 >,
00242 Rows, Cols
00243 >
00244 pow(const Matrix<std::complex<T>, Rows, Cols>& lhs,
00245 const T& rhs) TVMET_CXX_ALWAYS_INLINE;
00246
00247
00252 template<class T, std::size_t Rows, std::size_t Cols>
00253 XprMatrix<
00254 XprBinOp<
00255 Fcnl_pow<std::complex<T>, int>,
00256 MatrixConstReference<std::complex<T>, Rows, Cols>,
00257 XprLiteral<int>
00258 >,
00259 Rows, Cols
00260 >
00261 pow(const Matrix<std::complex<T>, Rows, Cols>& lhs,
00262 int rhs) TVMET_CXX_ALWAYS_INLINE;
00263
00264
00265 template<class T, std::size_t Rows, std::size_t Cols>
00266 XprMatrix<
00267 XprBinOp<
00268 Fcnl_polar<T, T>,
00269 MatrixConstReference<T, Rows, Cols>,
00270 XprLiteral<T>
00271 >,
00272 Rows, Cols
00273 >
00274 polar(const Matrix<T, Rows, Cols>& lhs,
00275 const T& rhs) TVMET_CXX_ALWAYS_INLINE;
00276
00277 #endif // defined(TVMET_HAVE_COMPLEX) && defined(TVMET_HAVE_COMPLEX_MATH1)
00278
00279
00280 #if defined(TVMET_HAVE_COMPLEX) && defined(TVMET_HAVE_COMPLEX_MATH2)
00281
00282 #endif // defined(TVMET_HAVE_COMPLEX) && defined(TVMET_HAVE_COMPLEX_MATH2)
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294 #define TVMET_IMPLEMENT_MACRO(NAME) \
00295 template<class T1, class T2, std::size_t Rows, std::size_t Cols> \
00296 inline \
00297 XprMatrix< \
00298 XprBinOp< \
00299 Fcnl_##NAME<T1, T2>, \
00300 MatrixConstReference<T1, Rows, Cols>, \
00301 MatrixConstReference<T2, Rows, Cols> \
00302 >, \
00303 Rows, Cols \
00304 > \
00305 NAME(const Matrix<T1, Rows, Cols>& lhs, const Matrix<T2, Cols, Cols>& rhs) { \
00306 typedef XprBinOp < \
00307 Fcnl_##NAME<T1, T2>, \
00308 MatrixConstReference<T1, Rows, Cols>, \
00309 MatrixConstReference<T2, Rows, Cols> \
00310 > expr_type; \
00311 return XprMatrix<expr_type, Rows, Cols>( \
00312 expr_type(lhs.const_ref(), rhs.const_ref())); \
00313 } \
00314 \
00315 template<class E, class T, std::size_t Rows, std::size_t Cols> \
00316 inline \
00317 XprMatrix< \
00318 XprBinOp< \
00319 Fcnl_##NAME<typename E::value_type, T>, \
00320 MatrixConstReference<T, Rows, Cols>, \
00321 XprMatrix<E, Rows, Cols> \
00322 >, \
00323 Rows, Cols \
00324 > \
00325 NAME(const XprMatrix<E, Rows, Cols>& lhs, const Matrix<T, Rows, Cols>& rhs) { \
00326 typedef XprBinOp< \
00327 Fcnl_##NAME<typename E::value_type, T>, \
00328 XprMatrix<E, Rows, Cols>, \
00329 MatrixConstReference<T, Rows, Cols> \
00330 > expr_type; \
00331 return XprMatrix<expr_type, Rows, Cols>( \
00332 expr_type(lhs, rhs.const_ref())); \
00333 } \
00334 \
00335 template<class E, class T, std::size_t Rows, std::size_t Cols> \
00336 inline \
00337 XprMatrix< \
00338 XprBinOp< \
00339 Fcnl_##NAME<T, typename E::value_type>, \
00340 MatrixConstReference<T, Rows, Cols>, \
00341 XprMatrix<E, Rows, Cols> \
00342 >, \
00343 Rows, Cols \
00344 > \
00345 NAME(const Matrix<T, Rows, Cols>& lhs, const XprMatrix<E, Rows, Cols>& rhs) { \
00346 typedef XprBinOp< \
00347 Fcnl_##NAME<T, typename E::value_type>, \
00348 MatrixConstReference<T, Rows, Cols>, \
00349 XprMatrix<E, Rows, Cols> \
00350 > expr_type; \
00351 return XprMatrix<expr_type, Rows, Cols>( \
00352 expr_type(lhs.const_ref(), rhs)); \
00353 }
00354
00355 TVMET_IMPLEMENT_MACRO(atan2)
00356 TVMET_IMPLEMENT_MACRO(fmod)
00357 TVMET_IMPLEMENT_MACRO(pow)
00358 #if defined(TVMET_HAVE_DREM)
00359 TVMET_IMPLEMENT_MACRO(drem)
00360 #endif
00361 #if defined(TVMET_HAVE_HYPOT)
00362 TVMET_IMPLEMENT_MACRO(hypot)
00363 #endif
00364 #if defined(TVMET_HAVE_JN)
00365 TVMET_IMPLEMENT_MACRO(jn)
00366 #endif
00367 #if defined(TVMET_HAVE_YN)
00368 TVMET_IMPLEMENT_MACRO(yn)
00369 #endif
00370
00371 #undef TVMET_IMPLEMENT_MACRO
00372
00373
00374
00375
00376
00377 #define TVMET_IMPLEMENT_MACRO(NAME, TP) \
00378 template<class T, std::size_t Rows, std::size_t Cols> \
00379 inline \
00380 XprMatrix< \
00381 XprBinOp< \
00382 Fcnl_##NAME<T, TP >, \
00383 MatrixConstReference<T, Rows, Cols>, \
00384 XprLiteral< TP > \
00385 >, \
00386 Rows, Cols \
00387 > \
00388 NAME(const Matrix<T, Rows, Cols>& lhs, TP rhs) { \
00389 typedef XprBinOp< \
00390 Fcnl_##NAME<T, TP >, \
00391 MatrixConstReference<T, Rows, Cols>, \
00392 XprLiteral< TP > \
00393 > expr_type; \
00394 return XprMatrix<expr_type, Rows, Cols>( \
00395 expr_type(lhs.const_ref(), XprLiteral< TP >(rhs))); \
00396 }
00397
00398 TVMET_IMPLEMENT_MACRO(atan2, int)
00399 TVMET_IMPLEMENT_MACRO(fmod, int)
00400 TVMET_IMPLEMENT_MACRO(pow, int)
00401 #if defined(TVMET_HAVE_DREM)
00402 TVMET_IMPLEMENT_MACRO(drem, int)
00403 #endif
00404 #if defined(TVMET_HAVE_HYPOT)
00405 TVMET_IMPLEMENT_MACRO(hypot, int)
00406 #endif
00407 #if defined(TVMET_HAVE_JN)
00408 TVMET_IMPLEMENT_MACRO(jn, int)
00409 #endif
00410 #if defined(TVMET_HAVE_YN)
00411 TVMET_IMPLEMENT_MACRO(yn, int)
00412 #endif
00413
00414
00415 #if defined(TVMET_HAVE_LONG_LONG)
00416 TVMET_IMPLEMENT_MACRO(atan2, long long int)
00417 TVMET_IMPLEMENT_MACRO(fmod, long long int)
00418 TVMET_IMPLEMENT_MACRO(pow, long long int)
00419 #if defined(TVMET_HAVE_DREM)
00420 TVMET_IMPLEMENT_MACRO(drem, long long int)
00421 #endif
00422 #if defined(TVMET_HAVE_HYPOT)
00423 TVMET_IMPLEMENT_MACRO(hypot, long long int)
00424 #endif
00425 #if defined(TVMET_HAVE_JN)
00426 TVMET_IMPLEMENT_MACRO(jn, long long int)
00427 #endif
00428 #if defined(TVMET_HAVE_YN)
00429 TVMET_IMPLEMENT_MACRO(yn, long long int)
00430 #endif
00431 #endif // defined(TVMET_HAVE_LONG_LONG)
00432
00433
00434 TVMET_IMPLEMENT_MACRO(atan2, float)
00435 TVMET_IMPLEMENT_MACRO(fmod, float)
00436 TVMET_IMPLEMENT_MACRO(pow, float)
00437 #if defined(TVMET_HAVE_DREM)
00438 TVMET_IMPLEMENT_MACRO(drem, float)
00439 #endif
00440 #if defined(TVMET_HAVE_HYPOT)
00441 TVMET_IMPLEMENT_MACRO(hypot, float)
00442 #endif
00443 #if defined(TVMET_HAVE_JN)
00444 TVMET_IMPLEMENT_MACRO(jn, float)
00445 #endif
00446 #if defined(TVMET_HAVE_YN)
00447 TVMET_IMPLEMENT_MACRO(yn, float)
00448 #endif
00449
00450
00451 TVMET_IMPLEMENT_MACRO(atan2, double)
00452 TVMET_IMPLEMENT_MACRO(fmod, double)
00453 TVMET_IMPLEMENT_MACRO(pow, double)
00454 #if defined(TVMET_HAVE_DREM)
00455 TVMET_IMPLEMENT_MACRO(drem, double)
00456 #endif
00457 #if defined(TVMET_HAVE_HYPOT)
00458 TVMET_IMPLEMENT_MACRO(hypot, double)
00459 #endif
00460 #if defined(TVMET_HAVE_JN)
00461 TVMET_IMPLEMENT_MACRO(jn, double)
00462 #endif
00463 #if defined(TVMET_HAVE_YN)
00464 TVMET_IMPLEMENT_MACRO(yn, double)
00465 #endif
00466
00467
00468 #if defined(TVMET_HAVE_LONG_DOUBLE)
00469 TVMET_IMPLEMENT_MACRO(atan2, long double)
00470 TVMET_IMPLEMENT_MACRO(fmod, long double)
00471 TVMET_IMPLEMENT_MACRO(pow, long double)
00472 #if defined(TVMET_HAVE_DREM)
00473 TVMET_IMPLEMENT_MACRO(drem, long double)
00474 #endif
00475 #if defined(TVMET_HAVE_HYPOT)
00476 TVMET_IMPLEMENT_MACRO(hypot, long double)
00477 #endif
00478 #if defined(TVMET_HAVE_JN)
00479 TVMET_IMPLEMENT_MACRO(jn, long double)
00480 #endif
00481 #if defined(TVMET_HAVE_YN)
00482 TVMET_IMPLEMENT_MACRO(yn, long double)
00483 #endif
00484 #endif // defined(TVMET_HAVE_LONG_DOUBLE)
00485
00486 #undef TVMET_IMPLEMENT_MACRO
00487
00488
00489
00490
00491
00492
00493 #if defined(TVMET_HAVE_COMPLEX) && defined(TVMET_HAVE_COMPLEX_MATH1)
00494
00498 template<class T, std::size_t Rows, std::size_t Cols>
00499 inline
00500 XprMatrix<
00501 XprBinOp<
00502 Fcnl_pow<T, std::complex<T> >,
00503 MatrixConstReference<T, Rows, Cols>,
00504 XprLiteral< std::complex<T> >
00505 >,
00506 Rows, Cols
00507 >
00508 pow(const Matrix<T, Rows, Cols>& lhs, const std::complex<T>& rhs) {
00509 typedef XprBinOp<
00510 Fcnl_pow<T, std::complex<T> >,
00511 MatrixConstReference<T, Rows, Cols>,
00512 XprLiteral< std::complex<T> >
00513 > expr_type;
00514 return XprMatrix<expr_type, Rows, Cols>(
00515 expr_type(lhs.const_ref(), XprLiteral< std::complex<T> >(rhs)));
00516 }
00517
00518
00523 template<class T, std::size_t Rows, std::size_t Cols>
00524 inline
00525 XprMatrix<
00526 XprBinOp<
00527 Fcnl_pow< std::complex<T>, std::complex<T> >,
00528 MatrixConstReference<std::complex<T>, Rows, Cols>,
00529 XprLiteral< std::complex<T> >
00530 >,
00531 Rows, Cols
00532 >
00533 pow(const Matrix<std::complex<T>, Rows, Cols>& lhs, const std::complex<T>& rhs) {
00534 typedef XprBinOp<
00535 Fcnl_pow< std::complex<T>, std::complex<T> >,
00536 MatrixConstReference<std::complex<T>, Rows, Cols>,
00537 XprLiteral< std::complex<T> >
00538 > expr_type;
00539 return XprMatrix<expr_type, Rows, Cols>(
00540 expr_type(lhs.const_ref(), XprLiteral< std::complex<T> >(rhs)));
00541 }
00542
00543
00548 template<class T, std::size_t Rows, std::size_t Cols>
00549 inline
00550 XprMatrix<
00551 XprBinOp<
00552 Fcnl_pow<std::complex<T>, T>,
00553 MatrixConstReference<std::complex<T>, Rows, Cols>,
00554 XprLiteral<T>
00555 >,
00556 Rows, Cols
00557 >
00558 pow(const Matrix<std::complex<T>, Rows, Cols>& lhs, const T& rhs) {
00559 typedef XprBinOp<
00560 Fcnl_pow<std::complex<T>, T>,
00561 MatrixConstReference<std::complex<T>, Rows, Cols>,
00562 XprLiteral<T>
00563 > expr_type;
00564 return XprMatrix<expr_type, Rows, Cols>(
00565 expr_type(lhs.const_ref(), XprLiteral<T>(rhs)));
00566 }
00567
00568
00573 template<class T, std::size_t Rows, std::size_t Cols>
00574 inline
00575 XprMatrix<
00576 XprBinOp<
00577 Fcnl_pow<std::complex<T>, int>,
00578 MatrixConstReference<std::complex<T>, Rows, Cols>,
00579 XprLiteral<int>
00580 >,
00581 Rows, Cols
00582 >
00583 pow(const Matrix<std::complex<T>, Rows, Cols>& lhs, int rhs) {
00584 typedef XprBinOp<
00585 Fcnl_pow<std::complex<T>, int>,
00586 MatrixConstReference<std::complex<T>, Rows, Cols>,
00587 XprLiteral<int>
00588 > expr_type;
00589 return XprMatrix<expr_type, Rows, Cols>(
00590 expr_type(lhs.const_ref(), XprLiteral<int>(rhs)));
00591 }
00592
00593
00598 template<class T, std::size_t Rows, std::size_t Cols>
00599 inline
00600 XprMatrix<
00601 XprBinOp<
00602 Fcnl_polar<T, T>,
00603 MatrixConstReference<T, Rows, Cols>,
00604 XprLiteral<T>
00605 >,
00606 Rows, Cols
00607 >
00608 polar(const Matrix<T, Rows, Cols>& lhs, const T& rhs) {
00609 typedef XprBinOp<
00610 Fcnl_polar<T, T>,
00611 MatrixConstReference<T, Rows, Cols>,
00612 XprLiteral<T>
00613 > expr_type;
00614 return XprMatrix<expr_type, Rows, Cols>(
00615 expr_type(lhs.const_ref(), XprLiteral<T>(rhs)));
00616 }
00617
00618 #endif // defined(TVMET_HAVE_COMPLEX) && defined(TVMET_HAVE_COMPLEX_MATH1)
00619
00620 #if defined(TVMET_HAVE_COMPLEX) && defined(TVMET_HAVE_COMPLEX_MATH2)
00621
00622 #endif // defined(TVMET_HAVE_COMPLEX) && defined(TVMET_HAVE_COMPLEX_MATH2)
00623
00624
00625 }
00626
00627 #endif // TVMET_MATRIX_BINARY_FUNCTIONS_H
00628
00629
00630
00631
00632