Ruby
2.7.2p137(2020-10-01revision5445e0435260b449decf2ac16f9d09bae3cafe72)
|
Go to the documentation of this file.
13 # define _USE_MATH_DEFINES 1
20 #if defined(HAVE_SIGNBIT) && defined(__GNUC__) && defined(__sun) && \
25 #define RB_BIGNUM_TYPE_P(x) RB_TYPE_P((x), T_BIGNUM)
30 #define Get_Double(x) rb_num_to_dbl(x)
32 #define domain_error(msg) \
33 rb_raise(rb_eMathDomainError, "Numerical argument is out of domain - " #msg)
71 if (dx == 0.0 && dy == 0.0) {
82 const double dz = (3.0 *
M_PI / 4.0);
86 const double dz = (
M_PI / 4.0);
230 return (
exp(x) +
exp(-x)) / 2;
258 return (
exp(x) -
exp(-x)) / 2;
286 # if defined(HAVE_SINH) && defined(HAVE_COSH)
287 const double c =
cosh(x);
290 const double e =
exp(x+x);
291 if (!
isinf(e))
return (e - 1) / (e + 1);
293 return x > 0 ? 1.0 : -1.0;
412 #if defined __CYGWIN__
413 # include <cygwin/version.h>
414 # if CYGWIN_VERSION_DLL_MAJOR < 1005
415 # define nan(x) nan()
417 # define log(x) ((x) < 0.0 ? nan("") : log(x))
418 # define log10(x) ((x) < 0.0 ? nan("") : log10(x))
422 # define M_LN2 0.693147180559945309417232121458176568
425 # define M_LN10 2.30258509299404568401799145468436421
428 static double math_log1(
VALUE x);
467 d /= math_log1(base);
473 get_double_rshift(
VALUE x,
size_t *pnumbits)
493 double d = get_double_rshift(x, &numbits);
511 extern double log2(
double);
536 double d = get_double_rshift(x, &numbits);
566 double d = get_double_rshift(x, &numbits);
614 return rb_math_sqrt(x);
617 #define f_boolcast(x) ((x) ? Qtrue : Qfalse)
619 f_negative_p(
VALUE x)
632 return f_negative_p(x);
636 rb_math_sqrt(
VALUE x)
644 im =
sqrt((d - re) / 2.0);
645 re =
sqrt((d + re) / 2.0);
652 if (d == 0.0)
return DBL2NUM(0.0);
696 #if defined __GLIBC__
698 r = (2.0 * r + (
f / r / r)) / 3.0;
840 static const double fact_table[] = {
860 121645100408832000.0,
861 2432902008176640000.0,
862 51090942171709440000.0,
863 1124000727777607680000.0,
868 enum {NFACT_TABLE =
numberof(fact_table)};
881 if (1.0 <= d && d <= (
double)NFACT_TABLE) {
882 return DBL2NUM(fact_table[(
int)d - 1]);
925 rb_math_##n(VALUE x)\
927 return math_##n(0, x);\
932 rb_math_##n(VALUE x, VALUE y)\
934 return math_##n(0, x, y);\
VALUE rb_assoc_new(VALUE car, VALUE cdr)
#define RB_TYPE_P(obj, type)
VALUE rb_define_module(const char *name)
VALUE rb_math_log(int argc, const VALUE *argv)
FUNC_MINIMIZED(static VALUE math_log(int, const VALUE *, VALUE))
RUBY_EXTERN double erfc(double)
#define BIGNUM_POSITIVE_P(b)
VALUE rb_complex_new(VALUE x, VALUE y)
RUBY_EXTERN double lgamma_r(double, int *)
VALUE rb_eMathDomainError
RUBY_EXTERN double erf(double)
VALUE rb_big_rshift(VALUE x, VALUE y)
void rb_define_module_function(VALUE module, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a module function for module.
RUBY_EXTERN double hypot(double, double)
size_t rb_absint_numwords(VALUE val, size_t word_numbits, size_t *nlz_bits_ret)
void rb_define_const(VALUE, const char *, VALUE)
RUBY_SYMBOL_EXPORT_BEGIN RUBY_EXTERN double acosh(double)
VALUE rb_complex_abs(VALUE self)
#define domain_error(msg)
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
RUBY_EXTERN double asinh(double)
RUBY_EXTERN double cbrt(double)
#define RB_BIGNUM_TYPE_P(x)
RUBY_EXTERN double atanh(double)
RUBY_EXTERN double tgamma(double)