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(drem)
00077 TVMET_DECLARE_MACRO(fmod)
00078 TVMET_DECLARE_MACRO(hypot)
00079 TVMET_DECLARE_MACRO(jn)
00080 TVMET_DECLARE_MACRO(yn)
00081 TVMET_DECLARE_MACRO(pow)
00082 #if defined(TVMET_HAVE_COMPLEX)
00083 TVMET_DECLARE_MACRO(polar)
00084 #endif
00085
00086 #undef TVMET_DECLARE_MACRO
00087
00088
00089
00090
00091
00092 #define TVMET_DECLARE_MACRO(NAME, TP) \
00093 template<class T, std::size_t Rows, std::size_t Cols> \
00094 XprMatrix< \
00095 XprBinOp< \
00096 Fcnl_##NAME<T, TP >, \
00097 MatrixConstReference<T, Rows, Cols>, \
00098 XprLiteral< TP > \
00099 >, \
00100 Rows, Cols \
00101 > \
00102 NAME(const Matrix<T, Rows, Cols>& lhs, TP rhs) TVMET_CXX_ALWAYS_INLINE;
00103
00104 TVMET_DECLARE_MACRO(atan2, int)
00105 TVMET_DECLARE_MACRO(drem, int)
00106 TVMET_DECLARE_MACRO(fmod, int)
00107 TVMET_DECLARE_MACRO(hypot, int)
00108 TVMET_DECLARE_MACRO(jn, int)
00109 TVMET_DECLARE_MACRO(yn, int)
00110 TVMET_DECLARE_MACRO(pow, int)
00111
00112 #if defined(TVMET_HAVE_LONG_LONG)
00113 TVMET_DECLARE_MACRO(atan2, long long int)
00114 TVMET_DECLARE_MACRO(drem, long long int)
00115 TVMET_DECLARE_MACRO(fmod, long long int)
00116 TVMET_DECLARE_MACRO(hypot, long long int)
00117 TVMET_DECLARE_MACRO(jn, long long int)
00118 TVMET_DECLARE_MACRO(yn, long long int)
00119 TVMET_DECLARE_MACRO(pow, long long int)
00120 #endif // defined(TVMET_HAVE_LONG_LONG)
00121
00122 TVMET_DECLARE_MACRO(atan2, float)
00123 TVMET_DECLARE_MACRO(drem, float)
00124 TVMET_DECLARE_MACRO(fmod, float)
00125 TVMET_DECLARE_MACRO(hypot, float)
00126 TVMET_DECLARE_MACRO(jn, float)
00127 TVMET_DECLARE_MACRO(yn, float)
00128 TVMET_DECLARE_MACRO(pow, float)
00129
00130 TVMET_DECLARE_MACRO(atan2, double)
00131 TVMET_DECLARE_MACRO(drem, double)
00132 TVMET_DECLARE_MACRO(fmod, double)
00133 TVMET_DECLARE_MACRO(hypot, double)
00134 TVMET_DECLARE_MACRO(jn, double)
00135 TVMET_DECLARE_MACRO(yn, double)
00136 TVMET_DECLARE_MACRO(pow, double)
00137
00138 #if defined(TVMET_HAVE_LONG_DOUBLE)
00139 TVMET_DECLARE_MACRO(atan2, long double)
00140 TVMET_DECLARE_MACRO(drem, long double)
00141 TVMET_DECLARE_MACRO(fmod, long double)
00142 TVMET_DECLARE_MACRO(hypot, long double)
00143 TVMET_DECLARE_MACRO(jn, long double)
00144 TVMET_DECLARE_MACRO(yn, long double)
00145 TVMET_DECLARE_MACRO(pow, long double)
00146 #endif // defined(TVMET_HAVE_LONG_DOUBLE)
00147
00148 #undef TVMET_DECLARE_MACRO
00149
00150
00151
00152
00153
00154
00155 #if defined(TVMET_HAVE_COMPLEX) && defined(TVMET_HAVE_COMPLEX_MATH1)
00156 template<class T, std::size_t Rows, std::size_t Cols>
00157 XprMatrix<
00158 XprBinOp<
00159 Fcnl_pow<T, std::complex<T> >,
00160 MatrixConstReference<T, Rows, Cols>,
00161 XprLiteral< std::complex<T> >
00162 >,
00163 Rows, Cols
00164 >
00165 pow(const Matrix<T, Rows, Cols>& lhs,
00166 const std::complex<T>& rhs) TVMET_CXX_ALWAYS_INLINE;
00167
00168
00169 template<class T, std::size_t Rows, std::size_t Cols>
00170 XprMatrix<
00171 XprBinOp<
00172 Fcnl_pow< std::complex<T>, std::complex<T> >,
00173 MatrixConstReference<std::complex<T>, Rows, Cols>,
00174 XprLiteral< std::complex<T> >
00175 >,
00176 Rows, Cols
00177 >
00178 pow(const Matrix<std::complex<T>, Rows, Cols>& lhs,
00179 const std::complex<T>& rhs) TVMET_CXX_ALWAYS_INLINE;
00180
00181
00186 template<class T, std::size_t Rows, std::size_t Cols>
00187 XprMatrix<
00188 XprBinOp<
00189 Fcnl_pow<std::complex<T>, T>,
00190 MatrixConstReference<std::complex<T>, Rows, Cols>,
00191 XprLiteral<T>
00192 >,
00193 Rows, Cols
00194 >
00195 pow(const Matrix<std::complex<T>, Rows, Cols>& lhs,
00196 const T& rhs) TVMET_CXX_ALWAYS_INLINE;
00197
00198
00203 template<class T, std::size_t Rows, std::size_t Cols>
00204 XprMatrix<
00205 XprBinOp<
00206 Fcnl_pow<std::complex<T>, int>,
00207 MatrixConstReference<std::complex<T>, Rows, Cols>,
00208 XprLiteral<int>
00209 >,
00210 Rows, Cols
00211 >
00212 pow(const Matrix<std::complex<T>, Rows, Cols>& lhs,
00213 int rhs) TVMET_CXX_ALWAYS_INLINE;
00214
00215
00216 template<class T, std::size_t Rows, std::size_t Cols>
00217 XprMatrix<
00218 XprBinOp<
00219 Fcnl_polar<T, T>,
00220 MatrixConstReference<T, Rows, Cols>,
00221 XprLiteral<T>
00222 >,
00223 Rows, Cols
00224 >
00225 polar(const Matrix<T, Rows, Cols>& lhs,
00226 const T& rhs) TVMET_CXX_ALWAYS_INLINE;
00227
00228 #endif // defined(TVMET_HAVE_COMPLEX) && defined(TVMET_HAVE_COMPLEX_MATH1)
00229
00230
00231 #if defined(TVMET_HAVE_COMPLEX) && defined(TVMET_HAVE_COMPLEX_MATH2)
00232
00233 #endif // defined(TVMET_HAVE_COMPLEX) && defined(TVMET_HAVE_COMPLEX_MATH2)
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245 #define TVMET_IMPLEMENT_MACRO(NAME) \
00246 template<class T1, class T2, std::size_t Rows, std::size_t Cols> \
00247 inline \
00248 XprMatrix< \
00249 XprBinOp< \
00250 Fcnl_##NAME<T1, T2>, \
00251 MatrixConstReference<T1, Rows, Cols>, \
00252 MatrixConstReference<T2, Rows, Cols> \
00253 >, \
00254 Rows, Cols \
00255 > \
00256 NAME(const Matrix<T1, Rows, Cols>& lhs, const Matrix<T2, Cols, Cols>& rhs) { \
00257 typedef XprBinOp < \
00258 Fcnl_##NAME<T1, T2>, \
00259 MatrixConstReference<T1, Rows, Cols>, \
00260 MatrixConstReference<T2, Rows, Cols> \
00261 > expr_type; \
00262 return XprMatrix<expr_type, Rows, Cols>( \
00263 expr_type(lhs.const_ref(), rhs.const_ref())); \
00264 } \
00265 \
00266 template<class E, class T, std::size_t Rows, std::size_t Cols> \
00267 inline \
00268 XprMatrix< \
00269 XprBinOp< \
00270 Fcnl_##NAME<typename E::value_type, T>, \
00271 MatrixConstReference<T, Rows, Cols>, \
00272 XprMatrix<E, Rows, Cols> \
00273 >, \
00274 Rows, Cols \
00275 > \
00276 NAME(const XprMatrix<E, Rows, Cols>& lhs, const Matrix<T, Rows, Cols>& rhs) { \
00277 typedef XprBinOp< \
00278 Fcnl_##NAME<typename E::value_type, T>, \
00279 XprMatrix<E, Rows, Cols>, \
00280 MatrixConstReference<T, Rows, Cols> \
00281 > expr_type; \
00282 return XprMatrix<expr_type, Rows, Cols>( \
00283 expr_type(lhs, rhs.const_ref())); \
00284 } \
00285 \
00286 template<class E, class T, std::size_t Rows, std::size_t Cols> \
00287 inline \
00288 XprMatrix< \
00289 XprBinOp< \
00290 Fcnl_##NAME<T, typename E::value_type>, \
00291 MatrixConstReference<T, Rows, Cols>, \
00292 XprMatrix<E, Rows, Cols> \
00293 >, \
00294 Rows, Cols \
00295 > \
00296 NAME(const Matrix<T, Rows, Cols>& lhs, const XprMatrix<E, Rows, Cols>& rhs) { \
00297 typedef XprBinOp< \
00298 Fcnl_##NAME<T, typename E::value_type>, \
00299 MatrixConstReference<T, Rows, Cols>, \
00300 XprMatrix<E, Rows, Cols> \
00301 > expr_type; \
00302 return XprMatrix<expr_type, Rows, Cols>( \
00303 expr_type(lhs.const_ref(), rhs)); \
00304 }
00305
00306 TVMET_IMPLEMENT_MACRO(atan2)
00307 TVMET_IMPLEMENT_MACRO(drem)
00308 TVMET_IMPLEMENT_MACRO(fmod)
00309 TVMET_IMPLEMENT_MACRO(hypot)
00310 TVMET_IMPLEMENT_MACRO(jn)
00311 TVMET_IMPLEMENT_MACRO(yn)
00312 TVMET_IMPLEMENT_MACRO(pow)
00313 #if defined(TVMET_HAVE_COMPLEX)
00314 TVMET_IMPLEMENT_MACRO(polar)
00315 #endif
00316 #undef TVMET_IMPLEMENT_MACRO
00317
00318
00319
00320
00321
00322 #define TVMET_IMPLEMENT_MACRO(NAME, TP) \
00323 template<class T, std::size_t Rows, std::size_t Cols> \
00324 inline \
00325 XprMatrix< \
00326 XprBinOp< \
00327 Fcnl_##NAME<T, TP >, \
00328 MatrixConstReference<T, Rows, Cols>, \
00329 XprLiteral< TP > \
00330 >, \
00331 Rows, Cols \
00332 > \
00333 NAME(const Matrix<T, Rows, Cols>& lhs, TP rhs) { \
00334 typedef XprBinOp< \
00335 Fcnl_##NAME<T, TP >, \
00336 MatrixConstReference<T, Rows, Cols>, \
00337 XprLiteral< TP > \
00338 > expr_type; \
00339 return XprMatrix<expr_type, Rows, Cols>( \
00340 expr_type(lhs.const_ref(), XprLiteral< TP >(rhs))); \
00341 }
00342
00343 TVMET_IMPLEMENT_MACRO(atan2, int)
00344 TVMET_IMPLEMENT_MACRO(drem, int)
00345 TVMET_IMPLEMENT_MACRO(fmod, int)
00346 TVMET_IMPLEMENT_MACRO(hypot, int)
00347 TVMET_IMPLEMENT_MACRO(jn, int)
00348 TVMET_IMPLEMENT_MACRO(yn, int)
00349 TVMET_IMPLEMENT_MACRO(pow, int)
00350
00351 #if defined(TVMET_HAVE_LONG_LONG)
00352 TVMET_IMPLEMENT_MACRO(atan2, long long int)
00353 TVMET_IMPLEMENT_MACRO(drem, long long int)
00354 TVMET_IMPLEMENT_MACRO(fmod, long long int)
00355 TVMET_IMPLEMENT_MACRO(hypot, long long int)
00356 TVMET_IMPLEMENT_MACRO(jn, long long int)
00357 TVMET_IMPLEMENT_MACRO(yn, long long int)
00358 TVMET_IMPLEMENT_MACRO(pow, long long int)
00359 #endif // defined(TVMET_HAVE_LONG_LONG)
00360
00361 TVMET_IMPLEMENT_MACRO(atan2, float)
00362 TVMET_IMPLEMENT_MACRO(drem, float)
00363 TVMET_IMPLEMENT_MACRO(fmod, float)
00364 TVMET_IMPLEMENT_MACRO(hypot, float)
00365 TVMET_IMPLEMENT_MACRO(jn, float)
00366 TVMET_IMPLEMENT_MACRO(yn, float)
00367 TVMET_IMPLEMENT_MACRO(pow, float)
00368
00369 TVMET_IMPLEMENT_MACRO(atan2, double)
00370 TVMET_IMPLEMENT_MACRO(drem, double)
00371 TVMET_IMPLEMENT_MACRO(fmod, double)
00372 TVMET_IMPLEMENT_MACRO(hypot, double)
00373 TVMET_IMPLEMENT_MACRO(jn, double)
00374 TVMET_IMPLEMENT_MACRO(yn, double)
00375 TVMET_IMPLEMENT_MACRO(pow, double)
00376
00377 #if defined(TVMET_HAVE_LONG_DOUBLE)
00378 TVMET_IMPLEMENT_MACRO(atan2, long double)
00379 TVMET_IMPLEMENT_MACRO(drem, long double)
00380 TVMET_IMPLEMENT_MACRO(fmod, long double)
00381 TVMET_IMPLEMENT_MACRO(hypot, long double)
00382 TVMET_IMPLEMENT_MACRO(jn, long double)
00383 TVMET_IMPLEMENT_MACRO(yn, long double)
00384 TVMET_IMPLEMENT_MACRO(pow, long double)
00385 #endif // defined(TVMET_HAVE_LONG_DOUBLE)
00386
00387 #undef TVMET_IMPLEMENT_MACRO
00388
00389
00390
00391
00392
00393
00394 #if defined(TVMET_HAVE_COMPLEX) && defined(TVMET_HAVE_COMPLEX_MATH1)
00395
00399 template<class T, std::size_t Rows, std::size_t Cols>
00400 inline
00401 XprMatrix<
00402 XprBinOp<
00403 Fcnl_pow<T, std::complex<T> >,
00404 MatrixConstReference<T, Rows, Cols>,
00405 XprLiteral< std::complex<T> >
00406 >,
00407 Rows, Cols
00408 >
00409 pow(const Matrix<T, Rows, Cols>& lhs, const std::complex<T>& rhs) {
00410 typedef XprBinOp<
00411 Fcnl_pow<T, std::complex<T> >,
00412 MatrixConstReference<T, Rows, Cols>,
00413 XprLiteral< std::complex<T> >
00414 > expr_type;
00415 return XprMatrix<expr_type, Rows, Cols>(
00416 expr_type(lhs.const_ref(), XprLiteral< std::complex<T> >(rhs)));
00417 }
00418
00419
00424 template<class T, std::size_t Rows, std::size_t Cols>
00425 inline
00426 XprMatrix<
00427 XprBinOp<
00428 Fcnl_pow< std::complex<T>, std::complex<T> >,
00429 MatrixConstReference<std::complex<T>, Rows, Cols>,
00430 XprLiteral< std::complex<T> >
00431 >,
00432 Rows, Cols
00433 >
00434 pow(const Matrix<std::complex<T>, Rows, Cols>& lhs, const std::complex<T>& rhs) {
00435 typedef XprBinOp<
00436 Fcnl_pow< std::complex<T>, std::complex<T> >,
00437 MatrixConstReference<std::complex<T>, Rows, Cols>,
00438 XprLiteral< std::complex<T> >
00439 > expr_type;
00440 return XprMatrix<expr_type, Rows, Cols>(
00441 expr_type(lhs.const_ref(), XprLiteral< std::complex<T> >(rhs)));
00442 }
00443
00444
00449 template<class T, std::size_t Rows, std::size_t Cols>
00450 inline
00451 XprMatrix<
00452 XprBinOp<
00453 Fcnl_pow<std::complex<T>, T>,
00454 MatrixConstReference<std::complex<T>, Rows, Cols>,
00455 XprLiteral<T>
00456 >,
00457 Rows, Cols
00458 >
00459 pow(const Matrix<std::complex<T>, Rows, Cols>& lhs, const T& rhs) {
00460 typedef XprBinOp<
00461 Fcnl_pow<std::complex<T>, T>,
00462 MatrixConstReference<std::complex<T>, Rows, Cols>,
00463 XprLiteral<T>
00464 > expr_type;
00465 return XprMatrix<expr_type, Rows, Cols>(
00466 expr_type(lhs.const_ref(), XprLiteral<T>(rhs)));
00467 }
00468
00469
00474 template<class T, std::size_t Rows, std::size_t Cols>
00475 inline
00476 XprMatrix<
00477 XprBinOp<
00478 Fcnl_pow<std::complex<T>, int>,
00479 MatrixConstReference<std::complex<T>, Rows, Cols>,
00480 XprLiteral<int>
00481 >,
00482 Rows, Cols
00483 >
00484 pow(const Matrix<std::complex<T>, Rows, Cols>& lhs, int rhs) {
00485 typedef XprBinOp<
00486 Fcnl_pow<std::complex<T>, int>,
00487 MatrixConstReference<std::complex<T>, Rows, Cols>,
00488 XprLiteral<int>
00489 > expr_type;
00490 return XprMatrix<expr_type, Rows, Cols>(
00491 expr_type(lhs.const_ref(), XprLiteral<int>(rhs)));
00492 }
00493
00494
00499 template<class T, std::size_t Rows, std::size_t Cols>
00500 inline
00501 XprMatrix<
00502 XprBinOp<
00503 Fcnl_polar<T, T>,
00504 MatrixConstReference<T, Rows, Cols>,
00505 XprLiteral<T>
00506 >,
00507 Rows, Cols
00508 >
00509 polar(const Matrix<T, Rows, Cols>& lhs, const T& rhs) {
00510 typedef XprBinOp<
00511 Fcnl_polar<T, T>,
00512 MatrixConstReference<T, Rows, Cols>,
00513 XprLiteral<T>
00514 > expr_type;
00515 return XprMatrix<expr_type, Rows, Cols>(
00516 expr_type(lhs.const_ref(), XprLiteral<T>(rhs)));
00517 }
00518
00519 #endif // defined(TVMET_HAVE_COMPLEX) && defined(TVMET_HAVE_COMPLEX_MATH1)
00520
00521 #if defined(TVMET_HAVE_COMPLEX) && defined(TVMET_HAVE_COMPLEX_MATH2)
00522
00523 #endif // defined(TVMET_HAVE_COMPLEX) && defined(TVMET_HAVE_COMPLEX_MATH2)
00524
00525
00526 }
00527
00528 #endif // TVMET_MATRIX_BINARY_FUNCTIONS_H
00529
00530
00531
00532
00533