Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef EIGEN_GLOBAL_FUNCTIONS_H
00027 #define EIGEN_GLOBAL_FUNCTIONS_H
00028
00029 #define EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(NAME,FUNCTOR) \
00030 template<typename Derived> \
00031 inline const Eigen::CwiseUnaryOp<Eigen::internal::FUNCTOR<typename Derived::Scalar>, const Derived> \
00032 NAME(const Eigen::ArrayBase<Derived>& x) { \
00033 return x.derived(); \
00034 }
00035
00036 #define EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(NAME,FUNCTOR) \
00037 \
00038 template<typename Derived> \
00039 struct NAME##_retval<ArrayBase<Derived> > \
00040 { \
00041 typedef const Eigen::CwiseUnaryOp<Eigen::internal::FUNCTOR<typename Derived::Scalar>, const Derived> type; \
00042 }; \
00043 template<typename Derived> \
00044 struct NAME##_impl<ArrayBase<Derived> > \
00045 { \
00046 static inline typename NAME##_retval<ArrayBase<Derived> >::type run(const Eigen::ArrayBase<Derived>& x) \
00047 { \
00048 return x.derived(); \
00049 } \
00050 };
00051
00052
00053 namespace std
00054 {
00055 EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(real,scalar_real_op)
00056 EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(imag,scalar_imag_op)
00057 EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(sin,scalar_sin_op)
00058 EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(cos,scalar_cos_op)
00059 EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(asin,scalar_asin_op)
00060 EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(acos,scalar_acos_op)
00061 EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(tan,scalar_tan_op)
00062 EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(exp,scalar_exp_op)
00063 EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(log,scalar_log_op)
00064 EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(abs,scalar_abs_op)
00065 EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(sqrt,scalar_sqrt_op)
00066
00067 template<typename Derived>
00068 inline const Eigen::CwiseUnaryOp<Eigen::internal::scalar_pow_op<typename Derived::Scalar>, const Derived>
00069 pow(const Eigen::ArrayBase<Derived>& x, const typename Derived::Scalar& exponent) {
00070 return x.derived().pow(exponent);
00071 }
00072
00073 template<typename Derived>
00074 inline const Eigen::CwiseBinaryOp<Eigen::internal::scalar_binary_pow_op<typename Derived::Scalar, typename Derived::Scalar>, const Derived, const Derived>
00075 pow(const Eigen::ArrayBase<Derived>& x, const Eigen::ArrayBase<Derived>& exponents)
00076 {
00077 return Eigen::CwiseBinaryOp<Eigen::internal::scalar_binary_pow_op<typename Derived::Scalar, typename Derived::Scalar>, const Derived, const Derived>(
00078 x.derived(),
00079 exponents.derived()
00080 );
00081 }
00082 }
00083
00084 namespace Eigen
00085 {
00089 template <typename Derived>
00090 inline const Eigen::CwiseUnaryOp<Eigen::internal::scalar_inverse_mult_op<typename Derived::Scalar>, const Derived>
00091 operator/(typename Derived::Scalar s, const Eigen::ArrayBase<Derived>& a)
00092 {
00093 return Eigen::CwiseUnaryOp<Eigen::internal::scalar_inverse_mult_op<typename Derived::Scalar>, const Derived>(
00094 a.derived(),
00095 Eigen::internal::scalar_inverse_mult_op<typename Derived::Scalar>(s)
00096 );
00097 }
00098
00099 namespace internal
00100 {
00101 EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(real,scalar_real_op)
00102 EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(imag,scalar_imag_op)
00103 EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(sin,scalar_sin_op)
00104 EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(cos,scalar_cos_op)
00105 EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(asin,scalar_asin_op)
00106 EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(acos,scalar_acos_op)
00107 EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(tan,scalar_tan_op)
00108 EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(exp,scalar_exp_op)
00109 EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(log,scalar_log_op)
00110 EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(abs,scalar_abs_op)
00111 EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(abs2,scalar_abs2_op)
00112 EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(sqrt,scalar_sqrt_op)
00113 }
00114 }
00115
00116
00117
00118 #endif // EIGEN_GLOBAL_FUNCTIONS_H