diff options
author | Gael Guennebaud <g.gael@free.fr> | 2011-02-03 14:45:21 +0100 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2011-02-03 14:45:21 +0100 |
commit | 2f712771059624d2c948e71fa1fb7f88888493cb (patch) | |
tree | 6e0999f5865e8a7db6c23fb29fa06389e7a4f113 /Eigen | |
parent | d028262e060b295b8aa7299cdef91f66409fd1f5 (diff) |
add global tan function
Diffstat (limited to 'Eigen')
-rw-r--r-- | Eigen/src/Core/GlobalFunctions.h | 2 | ||||
-rw-r--r-- | Eigen/src/Core/MathFunctions.h | 38 |
2 files changed, 40 insertions, 0 deletions
diff --git a/Eigen/src/Core/GlobalFunctions.h b/Eigen/src/Core/GlobalFunctions.h index c94b578dd..f049bff42 100644 --- a/Eigen/src/Core/GlobalFunctions.h +++ b/Eigen/src/Core/GlobalFunctions.h @@ -56,6 +56,7 @@ namespace std EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(imag,scalar_imag_op) EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(sin,scalar_sin_op) EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(cos,scalar_cos_op) + EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(tan,scalar_tan_op) EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(exp,scalar_exp_op) EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(log,scalar_log_op) EIGEN_ARRAY_DECLARE_GLOBAL_STD_UNARY(abs,scalar_abs_op) @@ -76,6 +77,7 @@ namespace Eigen EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(imag,scalar_imag_op) EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(sin,scalar_sin_op) EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(cos,scalar_cos_op) + EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(tan,scalar_tan_op) EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(exp,scalar_exp_op) EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(log,scalar_log_op) EIGEN_ARRAY_DECLARE_GLOBAL_EIGEN_UNARY(abs,scalar_abs_op) diff --git a/Eigen/src/Core/MathFunctions.h b/Eigen/src/Core/MathFunctions.h index 8e7def187..4138ab436 100644 --- a/Eigen/src/Core/MathFunctions.h +++ b/Eigen/src/Core/MathFunctions.h @@ -568,6 +568,44 @@ inline EIGEN_MATHFUNC_RETVAL(sin, Scalar) sin(const Scalar& x) } /**************************************************************************** +* Implementation of tan * +****************************************************************************/ + +template<typename Scalar, bool IsInteger> +struct tan_default_impl +{ + static inline Scalar run(const Scalar& x) + { + return std::tan(x); + } +}; + +template<typename Scalar> +struct tan_default_impl<Scalar, true> +{ + static inline Scalar run(const Scalar&) + { + EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar) + return Scalar(0); + } +}; + +template<typename Scalar> +struct tan_impl : tan_default_impl<Scalar, NumTraits<Scalar>::IsInteger> {}; + +template<typename Scalar> +struct tan_retval +{ + typedef Scalar type; +}; + +template<typename Scalar> +inline EIGEN_MATHFUNC_RETVAL(tan, Scalar) tan(const Scalar& x) +{ + return EIGEN_MATHFUNC_IMPL(tan, Scalar)::run(x); +} + +/**************************************************************************** * Implementation of log * ****************************************************************************/ |