24 #ifndef USML_UBLAS_VECTOR_MATH_H
25 #define USML_UBLAS_VECTOR_MATH_H
27 #include <usml/ublas/scalar_math.h>
39 template<
class E1,
class T2> BOOST_UBLAS_INLINE
40 typename boost::enable_if< boost::is_convertible< T2, typename E1::value_type >,
41 typename vector_binary_scalar2_traits<E1, const T2, scalar_plus<typename E1::value_type, T2> >::result_type
43 operator + (
const vector_expression<E1> &e1,
const T2 &e2) {
44 typedef typename vector_binary_scalar2_traits<E1, const T2, scalar_plus<typename E1::value_type, T2> >::expression_type expression_type;
45 return expression_type (e1 (), e2);
52 template<
class T1,
class E2> BOOST_UBLAS_INLINE
53 typename boost::enable_if< boost::is_convertible<T1, typename E2::value_type >,
54 typename vector_binary_scalar1_traits<const T1, E2, scalar_plus<T1, typename E2::value_type> >::result_type
56 operator + (
const T1 &e1,
const vector_expression<E2> &e2) {
57 typedef typename vector_binary_scalar1_traits<const T1, E2, scalar_plus<T1, typename E2::value_type> >::expression_type expression_type;
58 return expression_type (e1, e2 ());
65 template<
class E1,
class T2> BOOST_UBLAS_INLINE
66 typename boost::enable_if< boost::is_convertible< T2, typename E1::value_type >,
67 typename vector_binary_scalar2_traits<E1, const T2, scalar_minus<typename E1::value_type, T2> >::result_type
69 operator - (
const vector_expression<E1> &e1,
const T2 &e2) {
70 typedef typename vector_binary_scalar2_traits<E1, const T2, scalar_minus<typename E1::value_type, T2> >::expression_type expression_type;
71 return expression_type (e1 (), e2);
78 template<
class T1,
class E2> BOOST_UBLAS_INLINE
79 typename boost::enable_if< boost::is_convertible<T1, typename E2::value_type >,
80 typename vector_binary_scalar1_traits<const T1, E2, scalar_minus<T1, typename E2::value_type> >::result_type
82 operator - (
const T1 &e1,
const vector_expression<E2> &e2) {
83 typedef typename vector_binary_scalar1_traits<const T1, E2, scalar_minus<T1, typename E2::value_type> >::expression_type expression_type;
84 return expression_type (e1, e2 ());
94 template<
class T1,
class E2> BOOST_UBLAS_INLINE
95 typename boost::enable_if< boost::is_convertible<T1, typename E2::value_type >,
96 typename vector_binary_scalar1_traits<const T1, E2, scalar_divides<T1, typename E2::value_type> >::result_type
98 operator / (
const T1 &e1,
const vector_expression<E2> &e2) {
99 typedef typename vector_binary_scalar1_traits<const T1, E2, scalar_divides<T1, typename E2::value_type> >::expression_type expression_type;
100 return expression_type (e1, e2 ());
109 template<
class E1,
class E2> BOOST_UBLAS_INLINE
110 typename boost::enable_if< boost::is_convertible< E1, E2 >,
111 typename vector_binary_traits<E1, E2, scalar_multiplies<
112 typename E1::value_type,
typename E2::value_type> >::result_type
114 operator * (
const vector_expression<E1> &u,
const vector_expression<E2> &v ) {
115 return element_prod( u(), v() ) ;
121 template<
class E1,
class E2> BOOST_UBLAS_INLINE
122 typename boost::enable_if< boost::is_convertible< E1, E2 >,
123 typename vector_binary_traits<E1, E2, scalar_divides<
124 typename E1::value_type,
typename E2::value_type> >::result_type
126 operator / (
const vector_expression<E1> &u,
const vector_expression<E2> &v ) {
127 return element_div( u(), v() ) ;
139 template<
class E1,
class T2> BOOST_UBLAS_INLINE
140 typename boost::enable_if< boost::is_convertible< T2, typename E1::value_type >,
141 typename vector_binary_scalar2_traits<E1, const T2, scalar_max<typename E1::value_type, T2> >::result_type
143 max (
const vector_expression<E1> &e1,
const T2 &e2) {
144 typedef typename vector_binary_scalar2_traits<E1, const T2, scalar_max<typename E1::value_type, T2> >::expression_type expression_type;
145 return expression_type (e1 (), e2);
154 template<
class E1,
class T2> BOOST_UBLAS_INLINE
155 typename boost::enable_if< boost::is_convertible< T2, typename E1::value_type >,
156 typename vector_binary_scalar2_traits<E1, const T2, scalar_min<typename E1::value_type, T2> >::result_type
158 min (
const vector_expression<E1> &e1,
const T2 &e2) {
159 typedef typename vector_binary_scalar2_traits<E1, const T2, scalar_min<typename E1::value_type, T2> >::expression_type expression_type;
160 return expression_type (e1 (), e2);
167 template<
class E> BOOST_UBLAS_INLINE
168 typename vector_unary_traits<E,
169 scalar_floor<typename E::value_type> >::result_type
170 floor(
const vector_expression<E> &e) {
171 typedef typename vector_unary_traits<E,
174 return expression_type( e() );
181 template<
class E> BOOST_UBLAS_INLINE
182 typename vector_unary_traits<E,
183 scalar_ceil<typename E::value_type> >::result_type
184 ceil(
const vector_expression<E> &e) {
185 typedef typename vector_unary_traits<E,
188 return expression_type( e() );
197 template<
class E> BOOST_UBLAS_INLINE
198 typename vector_unary_traits<E,
199 scalar_to_degrees<typename E::value_type> >::result_type
201 typedef typename vector_unary_traits<E,
204 return expression_type( e() );
210 template<
class E> BOOST_UBLAS_INLINE
211 typename vector_unary_traits<E,
212 scalar_to_radians<typename E::value_type> >::result_type
214 typedef typename vector_unary_traits<E,
217 return expression_type( e() );
224 template<
class E> BOOST_UBLAS_INLINE
225 typename vector_unary_traits<E,
226 scalar_to_latitude<typename E::value_type> >::result_type
228 typedef typename vector_unary_traits<E,
231 return expression_type( e() );
238 template<
class E> BOOST_UBLAS_INLINE
239 typename vector_unary_traits<E,
240 scalar_to_colatitude<typename E::value_type> >::result_type
242 typedef typename vector_unary_traits<E,
245 return expression_type( e() );
254 template<
class E> BOOST_UBLAS_INLINE
255 typename vector_unary_traits<E,
256 scalar_abs<typename E::value_type> >::result_type
257 abs(
const vector_expression<E> &e) {
258 typedef typename vector_unary_traits<E,
261 return expression_type( e() );
267 template<
class E> BOOST_UBLAS_INLINE
268 typename vector_unary_traits<E,
269 scalar_abs2<typename E::value_type> >::result_type
270 abs2(
const vector_expression<E> &e) {
271 typedef typename vector_unary_traits<E,
274 return expression_type( e() );
280 template<
class E> BOOST_UBLAS_INLINE
281 typename vector_unary_traits<E,
282 scalar_arg<typename E::value_type> >::result_type
283 arg(
const vector_expression<E> &e) {
284 typedef typename vector_unary_traits<E,
287 return expression_type( e() );
293 template<
class E> BOOST_UBLAS_INLINE
294 typename vector_unary_traits<E,
295 scalar_sqrt<typename E::value_type> >::result_type
296 sqrt(
const vector_expression<E> &e) {
297 typedef typename vector_unary_traits<E,
300 return expression_type( e() );
308 template<
class E1,
class E2> BOOST_UBLAS_INLINE
309 typename vector_binary_traits<E1, E2, scalar_copysign<
310 typename E1::value_type,
typename E2::value_type> >::result_type
311 copysign(
const vector_expression<E1> &u,
const vector_expression<E2> &v ) {
312 typedef typename vector_binary_traits<E1, E2,
314 >::expression_type expression_type;
315 return expression_type( u(), v() );
324 template<
class E> BOOST_UBLAS_INLINE
325 typename vector_unary_traits<E,
326 scalar_cos<typename E::value_type> >::result_type
327 cos(
const vector_expression<E> &e) {
328 typedef typename vector_unary_traits<E,
331 return expression_type( e() );
337 template<
class E> BOOST_UBLAS_INLINE
338 typename vector_unary_traits<E,
339 scalar_cosh<typename E::value_type> >::result_type
340 cosh(
const vector_expression<E> &e) {
341 typedef typename vector_unary_traits<E,
344 return expression_type( e() );
350 template<
class E> BOOST_UBLAS_INLINE
351 typename vector_unary_traits<E,
352 scalar_sin<typename E::value_type> >::result_type
353 sin(
const vector_expression<E> &e) {
354 typedef typename vector_unary_traits<E,
357 return expression_type( e() );
363 template<
class E> BOOST_UBLAS_INLINE
364 typename vector_unary_traits<E,
365 scalar_sinh<typename E::value_type> >::result_type
366 sinh(
const vector_expression<E> &e) {
367 typedef typename vector_unary_traits<E,
370 return expression_type( e() );
376 template<
class E> BOOST_UBLAS_INLINE
377 typename vector_unary_traits<E,
378 scalar_tan<typename E::value_type> >::result_type
379 tan(
const vector_expression<E> &e) {
380 typedef typename vector_unary_traits<E,
383 return expression_type( e() );
389 template<
class E> BOOST_UBLAS_INLINE
390 typename vector_unary_traits<E,
391 scalar_tanh<typename E::value_type> >::result_type
392 tanh(
const vector_expression<E> &e) {
393 typedef typename vector_unary_traits<E,
396 return expression_type( e() );
405 template<
class E> BOOST_UBLAS_INLINE
406 typename vector_unary_traits<E,
407 scalar_acos<typename E::value_type> >::result_type
408 acos(
const vector_expression<E> &e) {
409 typedef typename vector_unary_traits<E,
412 return expression_type( e() );
418 template<
class E> BOOST_UBLAS_INLINE
419 typename vector_unary_traits<E,
420 scalar_acosh<typename E::value_type> >::result_type
421 acosh(
const vector_expression<E> &e) {
422 typedef typename vector_unary_traits<E,
425 return expression_type( e() );
431 template<
class E> BOOST_UBLAS_INLINE
432 typename vector_unary_traits<E,
433 scalar_asin<typename E::value_type> >::result_type
434 asin(
const vector_expression<E> &e) {
435 typedef typename vector_unary_traits<E,
438 return expression_type( e() );
444 template<
class E> BOOST_UBLAS_INLINE
445 typename vector_unary_traits<E,
446 scalar_asinh<typename E::value_type> >::result_type
447 asinh(
const vector_expression<E> &e) {
448 typedef typename vector_unary_traits<E,
451 return expression_type( e() );
457 template<
class E> BOOST_UBLAS_INLINE
458 typename vector_unary_traits<E,
459 scalar_atan<typename E::value_type> >::result_type
460 atan(
const vector_expression<E> &e) {
461 typedef typename vector_unary_traits<E,
464 return expression_type( e() );
470 template<
class E1,
class E2> BOOST_UBLAS_INLINE
471 typename vector_binary_traits<E1, E2, scalar_atan2<
472 typename E1::value_type,
typename E2::value_type> >::result_type
473 atan2(
const vector_expression<E1> &y,
const vector_expression<E2> &x ) {
474 typedef typename vector_binary_traits<E1, E2,
476 >::expression_type expression_type;
477 return expression_type( y(), x() );
483 template<
class E> BOOST_UBLAS_INLINE
484 typename vector_unary_traits<E,
485 scalar_atanh<typename E::value_type> >::result_type
486 atanh(
const vector_expression<E> &e) {
487 typedef typename vector_unary_traits<E,
490 return expression_type( e() );
499 template<
class E> BOOST_UBLAS_INLINE
500 typename vector_unary_traits<E,
501 scalar_exp<typename E::value_type> >::result_type
502 exp(
const vector_expression<E> &e) {
503 typedef typename vector_unary_traits<E,
506 return expression_type( e() );
512 template<
class E> BOOST_UBLAS_INLINE
513 typename vector_unary_traits<E,
514 scalar_log<typename E::value_type> >::result_type
515 log(
const vector_expression<E> &e) {
516 typedef typename vector_unary_traits<E,
519 return expression_type( e() );
525 template<
class E> BOOST_UBLAS_INLINE
526 typename vector_unary_traits<E,
527 scalar_log10<typename E::value_type> >::result_type
528 log10(
const vector_expression<E> &e) {
529 typedef typename vector_unary_traits<E,
532 return expression_type( e() );
539 template<
class E1,
class T2> BOOST_UBLAS_INLINE
540 typename boost::enable_if< boost::is_convertible< T2, typename E1::value_type >,
541 typename vector_binary_scalar2_traits<E1, const T2, scalar_pow<typename E1::value_type, T2> >::result_type
543 pow (
const vector_expression<E1> &e1,
const T2 &e2) {
544 typedef typename vector_binary_scalar2_traits<E1, const T2, scalar_pow<typename E1::value_type, T2> >::expression_type expression_type;
545 return expression_type (e1 (), e2);
552 template<
class T1,
class E2> BOOST_UBLAS_INLINE
553 typename boost::enable_if< boost::is_convertible<T1, typename E2::value_type >,
554 typename vector_binary_scalar1_traits<const T1, E2, scalar_pow<T1, typename E2::value_type> >::result_type
556 pow (
const T1 &e1,
const vector_expression<E2> &e2) {
557 typedef typename vector_binary_scalar1_traits<const T1, E2, scalar_pow<T1, typename E2::value_type> >::expression_type expression_type;
558 return expression_type (e1, e2 ());
565 template<
class E1,
class E2> BOOST_UBLAS_INLINE
566 typename vector_binary_traits<E1, E2, scalar_pow<
567 typename E1::value_type,
typename E2::value_type> >::result_type
568 pow(
const vector_expression<E1> &u,
const vector_expression<E2> &v ) {
569 typedef typename vector_binary_traits<E1, E2,
571 >::expression_type expression_type;
572 return expression_type( u(), v() );
582 template<
class E> BOOST_UBLAS_INLINE
583 typename vector_unary_traits<E,
584 scalar_signal<typename E::value_type> >::result_type
586 typedef typename vector_unary_traits<E,
589 return expression_type( e() );
596 template<
class E> BOOST_UBLAS_INLINE
597 typename vector_unary_traits<E,
598 scalar_asignal<typename E::value_type> >::result_type
600 typedef typename vector_unary_traits<E,
603 return expression_type( e() );
BOOST_UBLAS_INLINE matrix_unary1_traits< E, scalar_cos< typename E::value_type > >::result_type cos(const matrix_expression< E > &e)
Cosine of a matrix.
Definition: matrix_math.h:328
BOOST_UBLAS_INLINE boost::enable_if< boost::is_convertible< T2, typename E1::value_type >, typename matrix_binary_scalar2_traits< E1, const T2, scalar_max< typename E1::value_type, T2 > >::result_type >::type max(const matrix_expression< E1 > &e1, const T2 &e2)
Maximum between a matrix and a scalar.
Definition: matrix_math.h:143
BOOST_UBLAS_INLINE matrix_unary1_traits< E, scalar_cosh< typename E::value_type > >::result_type cosh(const matrix_expression< E > &e)
Hyperbolic cosine of a matrix.
Definition: matrix_math.h:341
Definition: scalar_math.h:188
Definition: scalar_math.h:321
math_traits< double >::value_type to_colatitude(math_traits< double >::const_reference t)
Definition: math_traits.h:761
BOOST_UBLAS_INLINE matrix_binary_traits< E1, E2, scalar_atan2< typename E1::value_type, typename E2::value_type > >::result_type atan2(const matrix_expression< E1 > &y, const matrix_expression< E2 > &x)
Inverse tangent of matrix y / matrix x.
Definition: matrix_math.h:474
BOOST_UBLAS_INLINE matrix_unary1_traits< E, scalar_ceil< typename E::value_type > >::result_type ceil(const matrix_expression< E > &e)
Rounding elements of a matrix up to the nearest integer.
Definition: matrix_math.h:184
Definition: scalar_math.h:254
Definition: scalar_math.h:463
Definition: scalar_math.h:276
Definition: scalar_math.h:414
Definition: scalar_math.h:351
BOOST_UBLAS_INLINE matrix_unary1_traits< E, scalar_asinh< typename E::value_type > >::result_type asinh(const matrix_expression< E > &e)
Inverse hyperbolic sine of a matrix.
Definition: matrix_math.h:448
math_traits< double >::value_type to_latitude(math_traits< double >::const_reference t)
Definition: math_traits.h:755
Definition: scalar_math.h:549
BOOST_UBLAS_INLINE matrix_unary1_traits< E, scalar_floor< typename E::value_type > >::result_type floor(const matrix_expression< E > &e)
Rounding elements of a matrix down to the nearest integer.
Definition: matrix_math.h:170
BOOST_UBLAS_INLINE matrix_unary1_traits< E, scalar_abs2< typename E::value_type > >::result_type abs2(const matrix_expression< E > &e)
Magnitude squared of a complex matrix.
Definition: matrix_math.h:270
Definition: scalar_math.h:567
BOOST_UBLAS_INLINE boost::enable_if< boost::is_convertible< T2, typename E1::value_type >, typename matrix_binary_scalar2_traits< E1, const T2, scalar_min< typename E1::value_type, T2 > >::result_type >::type min(const matrix_expression< E1 > &e1, const T2 &e2)
Minimum between a matrix and a scalar.
Definition: matrix_math.h:158
BOOST_UBLAS_INLINE matrix_unary1_traits< E, scalar_exp< typename E::value_type > >::result_type exp(const matrix_expression< E > &e)
Exponential of a matrix.
Definition: matrix_math.h:503
Definition: scalar_math.h:496
Definition: scalar_math.h:511
Definition: scalar_math.h:205
BOOST_UBLAS_INLINE matrix_binary_traits< E1, E2, scalar_copysign< typename E1::value_type, typename E2::value_type > >::result_type copysign(const matrix_expression< E1 > &u, const matrix_expression< E2 > &v)
Copy sign of matrix elements.
Definition: matrix_math.h:311
BOOST_UBLAS_INLINE matrix_unary1_traits< E, scalar_tan< typename E::value_type > >::result_type tan(const matrix_expression< E > &e)
Tangent of a matrix.
Definition: matrix_math.h:380
BOOST_UBLAS_INLINE boost::enable_if< boost::is_convertible< E1, E2 >, typename matrix_binary_traits< E1, E2, scalar_multiplies< typename E1::value_type, typename E2::value_type > >::result_type >::type operator*(const matrix_expression< E1 > &u, const matrix_expression< E2 > &v)
Define operator*() as an alias for element_prod().
Definition: matrix_math.h:114
BOOST_UBLAS_INLINE matrix_unary1_traits< E, scalar_abs< typename E::value_type > >::result_type abs(const matrix_expression< E > &e)
Magnitude of a complex matrix.
Definition: matrix_math.h:257
BOOST_UBLAS_INLINE boost::enable_if< boost::is_convertible< T2, typename E1::value_type >, typename matrix_binary_scalar2_traits< E1, const T2, scalar_minus< typename E1::value_type, T2 > >::result_type >::type operator-(const matrix_expression< E1 > &e1, const T2 &e2)
Subtract matrix (v) and scalar (t) such that (v-t)[i] = v[i] - t.
Definition: matrix_math.h:69
BOOST_UBLAS_INLINE matrix_unary1_traits< E, scalar_signal< typename E::value_type > >::result_type signal(const matrix_expression< E > &e)
Converts a real phase angle into a real valued signal.
Definition: matrix_math.h:586
BOOST_UBLAS_INLINE matrix_unary1_traits< E, scalar_sinh< typename E::value_type > >::result_type sinh(const matrix_expression< E > &e)
Hyperbolic sine of a matrix.
Definition: matrix_math.h:367
BOOST_UBLAS_INLINE boost::enable_if< boost::is_convertible< T2, typename E1::value_type >, typename matrix_binary_scalar2_traits< E1, const T2, scalar_pow< typename E1::value_type, T2 > >::result_type >::type pow(const matrix_expression< E1 > &e1, const T2 &e2)
Raise matrix (v) to a scalar (t) power such that (v^t)[i] = v[i] ^ t.
Definition: matrix_math.h:544
BOOST_UBLAS_INLINE matrix_unary1_traits< E, scalar_atan< typename E::value_type > >::result_type atan(const matrix_expression< E > &e)
Inverse tangent of a matrix.
Definition: matrix_math.h:461
Definition: scalar_math.h:168
Definition: scalar_math.h:399
Definition: scalar_math.h:222
BOOST_UBLAS_INLINE matrix_unary1_traits< E, scalar_acos< typename E::value_type > >::result_type acos(const matrix_expression< E > &e)
Inverse cosine of a matrix.
Definition: matrix_math.h:409
Definition: scalar_math.h:369
BOOST_UBLAS_INLINE matrix_unary1_traits< E, scalar_asignal< typename E::value_type > >::result_type asignal(const matrix_expression< E > &e)
Converts a real phase angle into a complex analytic signal.
Definition: matrix_math.h:600
Definition: scalar_math.h:336
BOOST_UBLAS_INLINE boost::enable_if< boost::is_convertible< T2, typename E1::value_type >, typename matrix_binary_scalar2_traits< E1, const T2, scalar_plus< typename E1::value_type, T2 > >::result_type >::type operator+(const matrix_expression< E1 > &e1, const T2 &e2)
Add matrix (v) and scalar (t) such that (v+t)[i] = v[i] + t.
Definition: matrix_math.h:43
Definition: scalar_math.h:444
BOOST_UBLAS_INLINE matrix_unary1_traits< E, scalar_asin< typename E::value_type > >::result_type asin(const matrix_expression< E > &e)
Inverse sine of a matrix.
Definition: matrix_math.h:435
BOOST_UBLAS_INLINE matrix_unary1_traits< E, scalar_tanh< typename E::value_type > >::result_type tanh(const matrix_expression< E > &e)
Hyperbolic tangent of a matrix.
Definition: matrix_math.h:393
BOOST_UBLAS_INLINE matrix_unary1_traits< E, scalar_arg< typename E::value_type > >::result_type arg(const matrix_expression< E > &e)
Phase of a complex matrix.
Definition: matrix_math.h:283
BOOST_UBLAS_INLINE matrix_unary1_traits< E, scalar_acosh< typename E::value_type > >::result_type acosh(const matrix_expression< E > &e)
Inverse hyperbolic cosine of a matrix.
Definition: matrix_math.h:422
Definition: scalar_math.h:239
Definition: scalar_math.h:150
BOOST_UBLAS_INLINE boost::enable_if< boost::is_convertible< T1, typename E2::value_type >, typename matrix_binary_scalar1_traits< const T1, E2, scalar_divides< T1, typename E2::value_type > >::result_type >::type operator/(const T1 &e1, const matrix_expression< E2 > &e2)
Divide scalar (t) and matrix (v) such that (t/v)[i] = t / v[i].
Definition: matrix_math.h:98
Definition: scalar_math.h:115
BOOST_UBLAS_INLINE matrix_unary1_traits< E, scalar_sin< typename E::value_type > >::result_type sin(const matrix_expression< E > &e)
Sine of a matrix.
Definition: matrix_math.h:354
BOOST_UBLAS_INLINE matrix_unary1_traits< E, scalar_log10< typename E::value_type > >::result_type log10(const matrix_expression< E > &e)
Base 10 logarithm of a matrix.
Definition: matrix_math.h:529
Definition: scalar_math.h:132
Definition: scalar_math.h:429
Definition: scalar_math.h:291
Definition: scalar_math.h:481
BOOST_UBLAS_INLINE matrix_unary1_traits< E, scalar_log< typename E::value_type > >::result_type log(const matrix_expression< E > &e)
Natural logarithm of a matrix.
Definition: matrix_math.h:516
math_traits< double >::value_type to_degrees(math_traits< double >::const_reference t)
Definition: math_traits.h:743
Definition: scalar_math.h:384
Definition: scalar_math.h:82
BOOST_UBLAS_INLINE matrix_unary1_traits< E, scalar_atanh< typename E::value_type > >::result_type atanh(const matrix_expression< E > &e)
Inverse hyperbolic tangent of a matrix.
Definition: matrix_math.h:487
Definition: scalar_math.h:526
Definition: scalar_math.h:306
Definition: scalar_math.h:97
math_traits< double >::value_type to_radians(math_traits< double >::const_reference t)
Definition: math_traits.h:749
BOOST_UBLAS_INLINE matrix_unary1_traits< E, scalar_sqrt< typename E::value_type > >::result_type sqrt(const matrix_expression< E > &e)
Square root of a matrix.
Definition: matrix_math.h:296