Ruby  1.9.3p551(2014-11-13revision48407)
Macros | Functions | Variables
math.c File Reference
#include "ruby/ruby.h"
#include "internal.h"
#include <math.h>
#include <errno.h>

Go to the source code of this file.

Macros

#define numberof(array)   (int)(sizeof(array) / sizeof((array)[0]))
 
#define Need_Float(x)   do {if (TYPE(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);\
}
ssize_t n
Definition: bigdecimal.c:5519
unsigned long VALUE
Definition: ruby.h:88
RUBY_EXTERN VALUE rb_mMath
Definition: ruby.h:1240
return
Definition: name2ctype.h:23857

Definition at line 720 of file math.c.

#define exp2 (   n)
Value:
VALUE \
rb_math_##n(VALUE x, VALUE y)\
{\
return math_##n(rb_mMath, x, y);\
}
ssize_t n
Definition: bigdecimal.c:5519
unsigned long VALUE
Definition: ruby.h:88
RUBY_EXTERN VALUE rb_mMath
Definition: ruby.h:1240
return
Definition: name2ctype.h:23857

Definition at line 727 of file math.c.

#define M_PI   3.14159265358979323846

Referenced by Init_Math(), and math_atan2().

#define Need_Float (   x)    do {if (TYPE(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:27

Definition at line 28 of file math.c.

Referenced by math_atan2(), and math_hypot().

#define numberof (   array)    (int)(sizeof(array) / sizeof((array)[0]))

Definition at line 22 of file math.c.

Referenced by math_gamma().

Function Documentation

double cosh ( double  x)

Definition at line 181 of file math.c.

Referenced by math_cosh(), and tanh().

void Init_Math ( void  )
double log2 ( double  x)

Definition at line 373 of file math.c.

Referenced by math_log2().

static VALUE math_acos ( VALUE  obj,
VALUE  x 
)
static

Definition at line 133 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 256 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 153 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 276 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 173 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 57 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 290 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 508 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 87 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 195 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 580 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 594 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 318 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 527 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 641 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 566 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 549 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 702 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

Definition at line 350 of file math.c.

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

Referenced by Init_Math(), and rb_math_log().

static VALUE math_log10 ( VALUE  obj,
VALUE  x 
)
static

Definition at line 423 of file math.c.

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

Referenced by Init_Math().

static VALUE math_log2 ( VALUE  obj,
VALUE  x 
)
static

Definition at line 396 of file math.c.

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

Referenced by Init_Math().

static VALUE math_sin ( VALUE  obj,
VALUE  x 
)
static

Definition at line 102 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 219 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 462 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 118 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 242 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 741 of file math.c.

References math_log().

Referenced by m_log_bang().

double sinh ( double  x)

Definition at line 204 of file math.c.

Referenced by math_sinh(), and tanh().

double tanh ( double  x)

Definition at line 227 of file math.c.

References cosh(), and sinh().

Referenced by math_tanh().

Variable Documentation

VALUE rb_eMathDomainError

Definition at line 25 of file math.c.

VALUE rb_mMath

Definition at line 24 of file math.c.