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