00001 #ifndef FUNCTORSADDONS_H
00002 #define FUNCTORSADDONS_H
00003
00004
00005
00006
00007
00008
00009
00010 template<typename Scalar> struct ei_scalar_angle_op EIGEN_EMPTY_STRUCT {
00011 typedef typename NumTraits<Scalar>::Real result_type;
00012 inline const result_type operator() (const Scalar& a) const { return atan2(a.imag(), a.real()); }
00013 };
00014
00015 template<typename Scalar>
00016 struct ei_functor_traits<ei_scalar_angle_op<Scalar> >
00017 { enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false }; };
00018
00019
00020
00021
00022
00023
00024 template<typename Scalar> struct ei_scalar_ceil_op EIGEN_EMPTY_STRUCT {
00025 inline const Scalar operator() (const Scalar& a) const { return std::ceil(a); }
00026 };
00027
00028 template<typename Scalar>
00029 struct ei_functor_traits<ei_scalar_ceil_op<Scalar> >
00030 { enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false }; };
00031
00032
00033
00034
00035
00036
00037 template<typename Scalar> struct ei_scalar_floor_op EIGEN_EMPTY_STRUCT {
00038 inline const Scalar operator() (const Scalar& a) const { return std::floor(a); }
00039 };
00040
00041 template<typename Scalar>
00042 struct ei_functor_traits<ei_scalar_floor_op<Scalar> >
00043 { enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false }; };
00044
00045
00046
00047
00048
00049
00050
00051 template<typename Scalar> struct ei_scalar_isnan_op EIGEN_EMPTY_STRUCT {
00052 inline const Scalar operator() (const Scalar& a) const { return std::isnan(a); }
00053 };
00054
00055 template<typename Scalar>
00056 struct ei_functor_traits<ei_scalar_isnan_op<Scalar> >
00057 { enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false }; };
00058
00059
00060
00061
00062
00063
00064
00065 template<typename Scalar> struct ei_scalar_mod_n_op {
00066
00067 inline ei_scalar_mod_n_op(const ei_scalar_mod_n_op& other) : m_divisor(other.m_divisor) { }
00068 inline ei_scalar_mod_n_op(const Scalar& divisor) : m_divisor(divisor) {}
00069 inline Scalar operator() (const Scalar& a) const {
00070 Scalar div = a/m_divisor;
00071 return (div - floor(div)) * m_divisor;
00072 }
00073 const Scalar m_divisor;
00074 };
00075 template<typename Scalar>
00076 struct ei_functor_traits<ei_scalar_mod_n_op<Scalar> >
00077 { enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false }; };
00078
00079
00080
00081
00082
00083
00084
00085 template<typename Scalar> struct ei_scalar_exp_n_op {
00086
00087 inline ei_scalar_exp_n_op(const ei_scalar_exp_n_op& other) : m_base(other.m_base) { }
00088 inline ei_scalar_exp_n_op(const Scalar& base) : m_base(base) {}
00089 inline Scalar operator() (const Scalar& a) const {
00090 return ei_pow(m_base, a);
00091 }
00092 const Scalar m_base;
00093 };
00094 template<typename Scalar>
00095 struct ei_functor_traits<ei_scalar_exp_n_op<Scalar> >
00096 { enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false }; };
00097
00098
00099
00100
00101
00102
00103
00104 template<typename Scalar> struct ei_scalar_log_n_op {
00105
00106 inline ei_scalar_log_n_op(const ei_scalar_log_n_op& other) : m_log_base(other.m_log_base) { }
00107 inline ei_scalar_log_n_op(const Scalar& base) : m_log_base(ei_log(base)) {}
00108 inline Scalar operator() (const Scalar& a) const {
00109 return ei_log(a) / m_log_base;
00110 }
00111 const Scalar m_log_base;
00112 };
00113 template<typename Scalar>
00114 struct ei_functor_traits<ei_scalar_log_n_op<Scalar> >
00115 { enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false }; };
00116
00117
00118
00119
00120
00121
00122
00123 template<typename Scalar> struct ei_scalar_clip_under_op {
00124
00125 inline ei_scalar_clip_under_op(const ei_scalar_clip_under_op& other) : m_under(other.m_under) { }
00126 inline ei_scalar_clip_under_op(const Scalar& under) : m_under(under) {}
00127 inline Scalar operator() (const Scalar& a) const {
00128 return a < m_under ? m_under : a;
00129 }
00130 const Scalar m_under;
00131 };
00132 template<typename Scalar>
00133 struct ei_functor_traits<ei_scalar_clip_under_op<Scalar> >
00134 { enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false }; };
00135
00136
00137
00138
00139
00140
00141
00142 template<typename Scalar> struct ei_scalar_clip_over_op {
00143
00144 inline ei_scalar_clip_over_op(const ei_scalar_clip_over_op& other) : m_over(other.m_over) { }
00145 inline ei_scalar_clip_over_op(const Scalar& over) : m_over(over) {}
00146 inline Scalar operator() (const Scalar& a) const {
00147 return a > m_over ? m_over : a;
00148 }
00149 const Scalar m_over;
00150 };
00151 template<typename Scalar>
00152 struct ei_functor_traits<ei_scalar_clip_over_op<Scalar> >
00153 { enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false }; };
00154
00155
00156
00157
00158
00159
00160
00161 template<typename Scalar> struct ei_scalar_clip_op {
00162
00163 inline ei_scalar_clip_op(const ei_scalar_clip_op& other) : m_under(other.m_under), m_over(other.m_over) { }
00164 inline ei_scalar_clip_op(const Scalar& under, const Scalar& over) : m_under(under), m_over(over) {}
00165 inline Scalar operator() (const Scalar& a) const {
00166 return (a < m_under ? m_under : (a > m_over ? m_over : a));
00167 }
00168 const Scalar m_under;
00169 const Scalar m_over;
00170 };
00171 template<typename Scalar>
00172 struct ei_functor_traits<ei_scalar_clip_op<Scalar> >
00173 { enum { Cost = 5 * NumTraits<Scalar>::MulCost, PacketAccess = false }; };
00174
00175
00176 #endif // FUNCTORSADDONS_H