Ruby  2.1.10p492(2016-04-01revision54464)
Macros | Functions | Variables
math.c File Reference
#include "ruby/ruby.h"
#include "internal.h"
#include <float.h>
#include <math.h>
#include <errno.h>

Go to the source code of this file.

Macros

#define RB_BIGNUM_TYPE_P(x)   RB_TYPE_P((x), T_BIGNUM)
 
#define Need_Float(x)   do {if (!RB_TYPE_P(x, T_FLOAT)) {(x) = rb_to_float(x);}} while(0)
 
#define Need_Float2(x, y)
 
#define domain_error(msg)   rb_raise(rb_eMathDomainError, "Numerical argument is out of domain - " #msg)
 
#define M_PI   3.14159265358979323846
 
#define exp1(n)
 
#define exp2(n)
 

Functions

static VALUE math_atan2 (VALUE obj, VALUE y, VALUE x)
 
static VALUE math_cos (VALUE obj, VALUE x)
 
static VALUE math_sin (VALUE obj, VALUE x)
 
static VALUE math_tan (VALUE obj, VALUE x)
 
static VALUE math_acos (VALUE obj, VALUE x)
 
static VALUE math_asin (VALUE obj, VALUE x)
 
static VALUE math_atan (VALUE obj, VALUE x)
 
double cosh (double x)
 
static VALUE math_cosh (VALUE obj, VALUE x)
 
double sinh (double x)
 
static VALUE math_sinh (VALUE obj, VALUE x)
 
double tanh (double x)
 
static VALUE math_tanh (VALUE obj, VALUE x)
 
static VALUE math_acosh (VALUE obj, VALUE x)
 
static VALUE math_asinh (VALUE obj, VALUE x)
 
static VALUE math_atanh (VALUE obj, VALUE x)
 
static VALUE math_exp (VALUE obj, VALUE x)
 
static VALUE math_log (int argc, VALUE *argv)
 
double log2 (double x)
 
static VALUE math_log2 (VALUE obj, VALUE x)
 
static VALUE math_log10 (VALUE obj, VALUE x)
 
static VALUE math_sqrt (VALUE obj, VALUE x)
 
static VALUE math_cbrt (VALUE obj, VALUE x)
 
static VALUE math_frexp (VALUE obj, VALUE x)
 
static VALUE math_ldexp (VALUE obj, VALUE x, VALUE n)
 
static VALUE math_hypot (VALUE obj, VALUE x, VALUE y)
 
static VALUE math_erf (VALUE obj, VALUE x)
 
static VALUE math_erfc (VALUE obj, VALUE x)
 
static VALUE math_gamma (VALUE obj, VALUE x)
 
static VALUE math_lgamma (VALUE obj, VALUE x)
 
VALUE rb_math_log (int argc, VALUE *argv)
 
void Init_Math (void)
 

Variables

VALUE rb_mMath
 
VALUE rb_eMathDomainError
 

Macro Definition Documentation

#define domain_error (   msg)    rb_raise(rb_eMathDomainError, "Numerical argument is out of domain - " #msg)
#define exp1 (   n)
Value:
VALUE \
rb_math_##n(VALUE x)\
{\
return math_##n(rb_mMath, x);\
}
return
Definition: bigdecimal.c:5946
RUBY_EXTERN VALUE rb_mMath
Definition: ripper.y:1555
data n
Definition: enum.c:860
unsigned long VALUE
Definition: ripper.y:88

Definition at line 875 of file math.c.

#define exp2 (   n)
Value:
VALUE \
rb_math_##n(VALUE x, VALUE y)\
{\
return math_##n(rb_mMath, x, y);\
}
return
Definition: bigdecimal.c:5946
RUBY_EXTERN VALUE rb_mMath
Definition: ripper.y:1555
data n
Definition: enum.c:860
unsigned long VALUE
Definition: ripper.y:88

Definition at line 882 of file math.c.

#define M_PI   3.14159265358979323846

Referenced by Init_Math(), and math_atan2().

#define Need_Float (   x)    do {if (!RB_TYPE_P(x, T_FLOAT)) {(x) = rb_to_float(x);}} while(0)
#define Need_Float2 (   x,
 
)
Value:
do {\
} while (0)
#define Need_Float(x)
Definition: math.c:28

Definition at line 29 of file math.c.

Referenced by math_atan2(), and math_hypot().

#define RB_BIGNUM_TYPE_P (   x)    RB_TYPE_P((x), T_BIGNUM)

Definition at line 23 of file math.c.

Referenced by math_log(), math_log10(), and math_log2().

Function Documentation

double cosh ( double  x)

Definition at line 224 of file math.c.

Referenced by math_cosh(), and tanh().

void Init_Math ( void  )
double log2 ( double  x)

Definition at line 477 of file math.c.

Referenced by math_log2().

static VALUE math_acos ( VALUE  obj,
VALUE  x 
)
static

Definition at line 164 of file math.c.

References d, d0, DBL2NUM, domain_error, Need_Float, and RFLOAT_VALUE.

Referenced by Init_Math().

static VALUE math_acosh ( VALUE  obj,
VALUE  x 
)
static

Definition at line 324 of file math.c.

References acosh(), d, d0, DBL2NUM, domain_error, Need_Float, and RFLOAT_VALUE.

Referenced by Init_Math().

static VALUE math_asin ( VALUE  obj,
VALUE  x 
)
static

Definition at line 190 of file math.c.

References d, d0, DBL2NUM, domain_error, Need_Float, and RFLOAT_VALUE.

Referenced by Init_Math().

static VALUE math_asinh ( VALUE  obj,
VALUE  x 
)
static

Definition at line 351 of file math.c.

References asinh(), DBL2NUM, Need_Float, and RFLOAT_VALUE.

Referenced by Init_Math().

static VALUE math_atan ( VALUE  obj,
VALUE  x 
)
static

Definition at line 216 of file math.c.

References DBL2NUM, Need_Float, and RFLOAT_VALUE.

Referenced by Init_Math().

static VALUE math_atan2 ( VALUE  obj,
VALUE  y,
VALUE  x 
)
static

Definition at line 62 of file math.c.

References DBL2NUM, domain_error, isinf(), M_PI, Need_Float2, RFLOAT_VALUE, and signbit().

Referenced by Init_Math().

static VALUE math_atanh ( VALUE  obj,
VALUE  x 
)
static

Definition at line 372 of file math.c.

References atanh(), d, d0, DBL2NUM, domain_error, INFINITY, Need_Float, and RFLOAT_VALUE.

Referenced by Init_Math().

static VALUE math_cbrt ( VALUE  obj,
VALUE  x 
)
static

Definition at line 648 of file math.c.

References cbrt(), DBL2NUM, Need_Float, and RFLOAT_VALUE.

Referenced by Init_Math().

static VALUE math_cos ( VALUE  obj,
VALUE  x 
)
static

Definition at line 99 of file math.c.

References DBL2NUM, Need_Float, and RFLOAT_VALUE.

Referenced by Init_Math().

static VALUE math_cosh ( VALUE  obj,
VALUE  x 
)
static

Definition at line 245 of file math.c.

References cosh(), DBL2NUM, Need_Float, and RFLOAT_VALUE.

Referenced by Init_Math().

static VALUE math_erf ( VALUE  obj,
VALUE  x 
)
static

Definition at line 726 of file math.c.

References DBL2NUM, erf(), Need_Float, and RFLOAT_VALUE.

Referenced by Init_Math().

static VALUE math_erfc ( VALUE  obj,
VALUE  x 
)
static

Definition at line 747 of file math.c.

References DBL2NUM, erfc(), Need_Float, and RFLOAT_VALUE.

Referenced by Init_Math().

static VALUE math_exp ( VALUE  obj,
VALUE  x 
)
static

Definition at line 404 of file math.c.

References DBL2NUM, Need_Float, and RFLOAT_VALUE.

Referenced by Init_Math().

static VALUE math_frexp ( VALUE  obj,
VALUE  x 
)
static

Definition at line 666 of file math.c.

References d, DBL2NUM, INT2NUM, Need_Float, rb_assoc_new(), and RFLOAT_VALUE.

Referenced by Init_Math().

static VALUE math_gamma ( VALUE  obj,
VALUE  x 
)
static

Definition at line 794 of file math.c.

References d, d0, DBL2NUM, domain_error, isinf(), Need_Float, numberof, RFLOAT_VALUE, signbit(), and tgamma().

Referenced by Init_Math().

static VALUE math_hypot ( VALUE  obj,
VALUE  x,
VALUE  y 
)
static

Definition at line 705 of file math.c.

References DBL2NUM, hypot(), Need_Float2, and RFLOAT_VALUE.

Referenced by Init_Math().

static VALUE math_ldexp ( VALUE  obj,
VALUE  x,
VALUE  n 
)
static

Definition at line 688 of file math.c.

References DBL2NUM, Need_Float, NUM2INT, and RFLOAT_VALUE.

Referenced by Init_Math().

static VALUE math_lgamma ( VALUE  obj,
VALUE  x 
)
static

Definition at line 857 of file math.c.

References d, d0, DBL2NUM, domain_error, INFINITY, INT2FIX, isinf(), lgamma_r(), Need_Float, rb_assoc_new(), RFLOAT_VALUE, signbit(), and v.

Referenced by Init_Math().

static VALUE math_log ( int  argc,
VALUE argv 
)
static
static VALUE math_log10 ( VALUE  obj,
VALUE  x 
)
static
static VALUE math_log2 ( VALUE  obj,
VALUE  x 
)
static
static VALUE math_sin ( VALUE  obj,
VALUE  x 
)
static

Definition at line 121 of file math.c.

References DBL2NUM, Need_Float, and RFLOAT_VALUE.

Referenced by Init_Math().

static VALUE math_sinh ( VALUE  obj,
VALUE  x 
)
static

Definition at line 274 of file math.c.

References DBL2NUM, Need_Float, RFLOAT_VALUE, and sinh().

Referenced by Init_Math().

static VALUE math_sqrt ( VALUE  obj,
VALUE  x 
)
static

Definition at line 599 of file math.c.

References d, d0, DBL2NUM, domain_error, Need_Float, and RFLOAT_VALUE.

Referenced by Init_Math().

static VALUE math_tan ( VALUE  obj,
VALUE  x 
)
static

Definition at line 143 of file math.c.

References DBL2NUM, Need_Float, and RFLOAT_VALUE.

Referenced by Init_Math().

static VALUE math_tanh ( VALUE  obj,
VALUE  x 
)
static

Definition at line 303 of file math.c.

References DBL2NUM, Need_Float, RFLOAT_VALUE, and tanh().

Referenced by Init_Math().

VALUE rb_math_log ( int  argc,
VALUE argv 
)

Definition at line 896 of file math.c.

References math_log().

Referenced by m_log_bang().

double sinh ( double  x)

Definition at line 253 of file math.c.

Referenced by math_sinh(), and tanh().

double tanh ( double  x)

Definition at line 282 of file math.c.

References cosh(), and sinh().

Referenced by math_tanh().

Variable Documentation

VALUE rb_eMathDomainError

Definition at line 26 of file math.c.

VALUE rb_mMath

Definition at line 25 of file math.c.