15 #define TYPE_TAG_(UNIVERSAL_TYPE) UNIVERSAL_TYPE ## _type_tag
16 #define TYPE_TAG(UNIVERSAL_TYPE) TYPE_TAG_(UNIVERSAL_TYPE)
17 #define UNIVERSAL_TYPE_TAG TYPE_TAG(UNIVERSAL_TYPE)
27 struct UNIVERSAL_TYPE_TAG {};
29 template<>
struct number_type<UNIVERSAL_TYPE> {
typedef UNIVERSAL_TYPE_TAG type; };
32 struct epsilon_type<UNIVERSAL_TYPE>
34 static inline UNIVERSAL_TYPE value()
36 static const UNIVERSAL_TYPE epsilon =
37 std::numeric_limits<UNIVERSAL_TYPE>::epsilon();
42 inline bool is_nan_impl(
const UNIVERSAL_TYPE& v, UNIVERSAL_TYPE_TAG)
48 inline int to_int32_impl(
const T& v, UNIVERSAL_TYPE_TAG)
50 return static_cast<int>(v);
55 inline long long to_int64_impl(
const T& v, UNIVERSAL_TYPE_TAG)
57 return static_cast<long long int>(v);
61 template <
typename T>
inline T abs_impl(
const T& v, UNIVERSAL_TYPE_TAG) {
return sw::universal::abs (v); }
62 template <
typename T>
inline T acos_impl(
const T& v, UNIVERSAL_TYPE_TAG) {
return sw::universal::acos (v); }
63 template <
typename T>
inline T acosh_impl(
const T& v, UNIVERSAL_TYPE_TAG) {
return sw::universal::acosh(v); }
64 template <
typename T>
inline T asin_impl(
const T& v, UNIVERSAL_TYPE_TAG) {
return sw::universal::asin (v); }
65 template <
typename T>
inline T asinh_impl(
const T& v, UNIVERSAL_TYPE_TAG) {
return sw::universal::asinh(v); }
66 template <
typename T>
inline T atan_impl(
const T& v, UNIVERSAL_TYPE_TAG) {
return sw::universal::atan (v); }
67 template <
typename T>
inline T atanh_impl(
const T& v, UNIVERSAL_TYPE_TAG) {
return sw::universal::atanh(v); }
68 template <
typename T>
inline T ceil_impl(
const T& v, UNIVERSAL_TYPE_TAG) {
return sw::universal::ceil (v); }
69 template <
typename T>
inline T cos_impl(
const T& v, UNIVERSAL_TYPE_TAG) {
return sw::universal::cos (v); }
70 template <
typename T>
inline T cosh_impl(
const T& v, UNIVERSAL_TYPE_TAG) {
return sw::universal::cosh (v); }
71 template <
typename T>
inline T exp_impl(
const T& v, UNIVERSAL_TYPE_TAG) {
return sw::universal::exp (v); }
72 template <
typename T>
inline T floor_impl(
const T& v, UNIVERSAL_TYPE_TAG) {
return sw::universal::floor(v); }
73 template <
typename T>
inline T log_impl(
const T& v, UNIVERSAL_TYPE_TAG) {
return sw::universal::log (v); }
74 template <
typename T>
inline T log10_impl(
const T& v, UNIVERSAL_TYPE_TAG) {
return sw::universal::log10(v); }
75 template <
typename T>
inline T log2_impl(
const T& v, UNIVERSAL_TYPE_TAG) {
return sw::universal::log2 (v); }
76 template <
typename T>
inline T neg_impl(
const T& v, UNIVERSAL_TYPE_TAG) {
return -v; }
77 template <
typename T>
inline T pos_impl(
const T& v, UNIVERSAL_TYPE_TAG) {
return v; }
78 template <
typename T>
inline T sin_impl(
const T& v, UNIVERSAL_TYPE_TAG) {
return sw::universal::sin (v); }
79 template <
typename T>
inline T sinh_impl(
const T& v, UNIVERSAL_TYPE_TAG) {
return sw::universal::sinh (v); }
80 template <
typename T>
inline T sqrt_impl(
const T& v, UNIVERSAL_TYPE_TAG) {
return sw::universal::sqrt (v); }
81 template <
typename T>
inline T tan_impl(
const T& v, UNIVERSAL_TYPE_TAG) {
return sw::universal::tan (v); }
82 template <
typename T>
inline T tanh_impl(
const T& v, UNIVERSAL_TYPE_TAG) {
return sw::universal::tanh (v); }
83 template <
typename T>
inline T cot_impl(
const T& v, UNIVERSAL_TYPE_TAG) {
return sw::universal::cot (v); }
84 template <
typename T>
inline T sec_impl(
const T& v, UNIVERSAL_TYPE_TAG) {
return sw::universal::sec (v); }
85 template <
typename T>
inline T csc_impl(
const T& v, UNIVERSAL_TYPE_TAG) {
return sw::universal::csc (v); }
86 template <
typename T>
inline T r2d_impl(
const T& v, UNIVERSAL_TYPE_TAG) {
return (v * exprtk::details::constant_universal::_180_pi); }
87 template <
typename T>
inline T d2r_impl(
const T& v, UNIVERSAL_TYPE_TAG) {
return (v * exprtk::details::constant_universal::pi_180 ); }
88 template <
typename T>
inline T d2g_impl(
const T& v, UNIVERSAL_TYPE_TAG) {
return (v * UNIVERSAL_TYPE(20.0/9.0)); }
89 template <
typename T>
inline T g2d_impl(
const T& v, UNIVERSAL_TYPE_TAG) {
return (v * UNIVERSAL_TYPE(9.0/20.0)); }
90 template <
typename T>
inline T notl_impl(
const T& v, UNIVERSAL_TYPE_TAG) {
return (v != UNIVERSAL_TYPE(0) ? UNIVERSAL_TYPE(0) : UNIVERSAL_TYPE(1)); }
91 template <
typename T>
inline T frac_impl(
const T& v, UNIVERSAL_TYPE_TAG) {
return sw::universal::frac (v); }
92 template <
typename T>
inline T trunc_impl(
const T& v, UNIVERSAL_TYPE_TAG) {
return sw::universal::trunc(v); }
94 template <
typename T>
inline T const_pi_impl(UNIVERSAL_TYPE_TAG) {
return UNIVERSAL_TYPE(exprtk::details::constant_universal::pi); }
95 template <
typename T>
inline T const_e_impl (UNIVERSAL_TYPE_TAG) {
return UNIVERSAL_TYPE(exprtk::details::constant_universal::e ); }
97 inline bool is_true_impl (
const UNIVERSAL_TYPE& v)
103 inline bool is_false_impl(
const UNIVERSAL_TYPE& v)
105 return !is_true_impl(v);
108 template <
typename T>
109 inline T expm1_impl(
const T& v, UNIVERSAL_TYPE_TAG)
111 return sw::universal::expm1(v);
114 template <
typename T>
115 inline T min_impl(
const T& v0,
const T& v1, UNIVERSAL_TYPE_TAG)
117 return sw::universal::min(v0,v1);
120 template <
typename T>
121 inline T max_impl(
const T& v0,
const T& v1, UNIVERSAL_TYPE_TAG)
123 return sw::universal::max(v0,v1);
126 template <
typename T>
127 inline T nequal_impl(
const T& v0,
const T& v1, UNIVERSAL_TYPE_TAG)
129 const T epsilon = epsilon_type<T>::value();
134 template <
typename T>
135 inline T sgn_impl(
const T& v, UNIVERSAL_TYPE_TAG)
137 if (v > T(0))
return T(+1);
138 else if (v < T(0))
return T(-1);
142 template <
typename T>
143 inline T log1p_impl(
const T& v, UNIVERSAL_TYPE_TAG)
145 return sw::universal::log1p(v);
148 template <
typename T>
149 inline T erf_impl(
const T& v, UNIVERSAL_TYPE_TAG)
151 return sw::universal::erf(v);
154 template <
typename T>
155 inline T erfc_impl(
const T& v, UNIVERSAL_TYPE_TAG)
157 return sw::universal::erfc(v);
160 template <
typename T>
161 inline T ncdf_impl(
const T& v, UNIVERSAL_TYPE_TAG)
163 T cnd = T(0.5) * (T(1) + erf_impl(
165 T(exprtk::details::constant_universal::sqrt2), UNIVERSAL_TYPE_TAG()));
166 return (v < T(0)) ? (T(1) - cnd) : cnd;
169 template <
typename T>
170 inline T modulus_impl(
const T& v0,
const T& v1, UNIVERSAL_TYPE_TAG)
172 std::cerr<<
"modulus is not derivated\n";
173 return T(sw::universal::fmod(v0,v1));
177 template <
typename T>
178 inline T pow_impl(
const T& v0,
const T& v1, UNIVERSAL_TYPE_TAG)
180 return sw::universal::pow(v0, v1 );
184 template <
typename T>
185 inline T logn_impl(
const T& v0,
const T& v1, UNIVERSAL_TYPE_TAG)
187 return sw::universal::log(v0) / sw::universal::log(v1);
190 template <
typename T>
191 inline T sinc_impl(
const T& v, UNIVERSAL_TYPE_TAG)
194 return(sw::universal::sin(v) / v);
199 template <
typename T>
200 inline T xor_impl(
const T& v0,
const T& v1, UNIVERSAL_TYPE_TAG)
202 return (is_false_impl(v0) != is_false_impl(v1)) ? T(1) : T(0);
205 template <
typename T>
206 inline T xnor_impl(
const T& v0,
const T& v1, UNIVERSAL_TYPE_TAG)
208 const bool v0_true = is_true_impl(v0);
209 const bool v1_true = is_true_impl(v1);
210 if ((v0_true && v1_true) || (!v0_true && !v1_true))
216 template <
typename T>
217 inline T equal_impl(
const T& v0,
const T& v1, UNIVERSAL_TYPE_TAG)
219 const T epsilon = epsilon_type<T>::value();
224 template <
typename T>
225 inline T round_impl(
const T& v, UNIVERSAL_TYPE_TAG)
227 return sw::universal::round(v);
230 template <
typename T>
231 inline T roundn_impl(
const T& v0,
const T& v1, UNIVERSAL_TYPE_TAG)
233 const T p10 = pow(T(10),floor(v1));
235 return T(sw::universal::ceil (T((v0 * p10) - T(0.5))) / p10);
237 return T(sw::universal::floor(T((v0 * p10) + T(0.5))) / p10);
240 template <
typename T>
241 inline bool is_integer_impl(
const T& v, UNIVERSAL_TYPE_TAG)
243 return sw::universal::ceil(v) == v;
247 template <
typename T>
248 inline T root_impl(
const T& v0,
const T& v1, UNIVERSAL_TYPE_TAG)
250 return sw::universal::pow(v0,T(1) / v1);
253 template <
typename T>
254 inline T hypot_impl(
const T& v0,
const T& v1, UNIVERSAL_TYPE_TAG)
256 return sw::universal::hypot(v0,v1);
259 template <
typename T>
260 inline T atan2_impl(
const T& v0,
const T& v1, UNIVERSAL_TYPE_TAG)
262 return sw::universal::atan2(v0,v1);
265 template <
typename T>
266 inline T shr_impl(
const T& v0,
const T& v1, UNIVERSAL_TYPE_TAG)
268 return v0 * (T(1) / sw::universal::pow(T(2.0),v1));
271 template <
typename T>
272 inline T shl_impl(
const T& v0,
const T& v1, UNIVERSAL_TYPE_TAG)
274 return v0 * sw::universal::pow(T(2.0),v1);
277 template <
typename T>
278 inline T and_impl(
const T& v0,
const T& v1, UNIVERSAL_TYPE_TAG)
280 return (is_true_impl(v0) && is_true_impl(v1)) ? T(1) : T(0);
283 template <
typename T>
284 inline T nand_impl(
const T& v0,
const T& v1, UNIVERSAL_TYPE_TAG)
286 return (is_false_impl(v0) || is_false_impl(v1)) ? T(1) : T(0);
289 template <
typename T>
290 inline T or_impl(
const T& v0,
const T& v1, UNIVERSAL_TYPE_TAG)
292 return (is_true_impl(v0) || is_true_impl(v1)) ? T(1) : T(0);
295 template <
typename T>
296 inline T nor_impl(
const T& v0,
const T& v1, UNIVERSAL_TYPE_TAG)
298 return (is_false_impl(v0) && is_false_impl(v1)) ? T(1) : T(0);
303 template <
typename Iterator>
304 inline bool string_to_real(Iterator& itr_external,
305 const Iterator end, UNIVERSAL_TYPE& t,
306 numeric::details::UNIVERSAL_TYPE_TAG)
308 const std::string num(itr_external,end);
309 t = ::atof(num.c_str());
313 inline bool is_true (
const UNIVERSAL_TYPE& v)
314 {
return details::numeric::details::is_true_impl (v); }
316 inline bool is_false(
const UNIVERSAL_TYPE& v)
317 {
return details::numeric::details::is_false_impl(v); }
324 inline void print_type(
const std::string&,
const UNIVERSAL_TYPE& v,
325 exprtk::details::numeric::details::UNIVERSAL_TYPE_TAG)
327 std::cout << pretty_print(v) <<
"\n";
EIGEN_STRONG_INLINE abs_expr< E > abs(const E &u)
Absolute value.
Definition: gsExpressions.h:4486