12 #define domain_error(msg) \
13 mrb_raise(mrb, E_RANGE_ERROR, "Numerical argument is out of domain - " #msg)
16 #if defined _MSC_VER && _MSC_VER < 1800
18 #define MATH_TOLERANCE 1E-12
20 #define asinh(x) log(x + sqrt(pow(x,2.0) + 1))
21 #define acosh(x) log(x + sqrt(pow(x,2.0) - 1))
22 #define atanh(x) (log(1+x) - log(1-x))/2.0
23 #define cbrt(x) pow(x,1.0/3.0)
38 static const double two_sqrtpi = 1.128379167095512574;
53 }
while (fabs(term/sum) > MATH_TOLERANCE);
54 return two_sqrtpi*sum;
61 static const double one_sqrtpi= 0.564189583547756287;
74 return 2.0 - erfc(-x);
86 }
while (fabs(q1-q2)/q2 > MATH_TOLERANCE);
87 return one_sqrtpi*exp(-x*x)*q2;
92 #if (defined _MSC_VER && _MSC_VER < 1800) || defined __ANDROID__
97 return log10(x)/log10(2.0);
121 return mrb_float_value(mrb, x);
139 return mrb_float_value(mrb, x);
156 return mrb_float_value(mrb, x);
177 return mrb_float_value(mrb, x);
194 return mrb_float_value(mrb, x);
211 return mrb_float_value(mrb, x);
241 return mrb_float_value(mrb, x);
264 return mrb_float_value(mrb, x);
281 return mrb_float_value(mrb, x);
299 return mrb_float_value(mrb, x);
322 return mrb_float_value(mrb, x);
339 return mrb_float_value(mrb, x);
356 return mrb_float_value(mrb, x);
362 #if defined __CYGWIN__
363 # include <cygwin/version.h>
364 # if CYGWIN_VERSION_DLL_MAJOR < 1005
365 # define nan(x) nan()
367 # define log(x) ((x) < 0.0 ? nan("") : log(x))
368 # define log10(x) ((x) < 0.0 ? nan("") : log10(x))
390 return mrb_float_value(mrb, x);
419 return mrb_float_value(mrb, x);
442 return mrb_float_value(mrb, x);
464 return mrb_float_value(mrb, x);
482 return mrb_float_value(mrb, x);
525 return mrb_float_value(mrb, x);
549 return mrb_assoc_new(mrb, mrb_float_value(mrb, x), mrb_fixnum_value(exp));
570 return mrb_float_value(mrb, x);
590 return mrb_float_value(mrb, x);
607 return mrb_float_value(mrb, x);
625 return mrb_float_value(mrb, x);