Defines | Functions | Variables

math.c File Reference

#include "ruby/ruby.h"
#include <math.h>
#include <errno.h>
Include dependency graph for math.c:

Go to the source code of this file.

Defines

#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 exp1(n)
#define exp2(n)

Functions

VALUE rb_to_float (VALUE val)
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)
 exp2 (atan2)
 exp1 (sin)

Variables

VALUE rb_mMath
VALUE rb_eMathDomainError

Define 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);\
}

Definition at line 706 of file math.c.

#define exp2 (   n  ) 
Value:
VALUE \
rb_math_##n(VALUE x, VALUE y)\
{\
    return math_##n(rb_mMath, x, y);\
}

Definition at line 713 of file math.c.

#define Need_Float (   x  )     do {if (TYPE(x) != T_FLOAT) {(x) = rb_to_float(x);}} while(0)
#define Need_Float2 (   x,
  y 
)
Value:
do {\
    Need_Float(x);\
    Need_Float(y);\
} while (0)

Definition at line 23 of file math.c.

Referenced by math_atan2(), and math_hypot().

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

Definition at line 16 of file math.c.

Referenced by math_gamma().


Function Documentation

double cosh ( double  x  ) 

Definition at line 167 of file math.c.

Referenced by math_cosh(), and tanh().

exp1 ( sin   ) 
exp2 ( atan2   ) 

Definition at line 720 of file math.c.

References math_log().

double log2 ( double  x  ) 

Definition at line 359 of file math.c.

Referenced by math_log2().

static VALUE math_acos ( VALUE  obj,
VALUE  x 
) [static]

Definition at line 119 of file math.c.

References DBL2NUM, domain_error, Need_Float, and RFLOAT_VALUE.

Referenced by exp1().

static VALUE math_acosh ( VALUE  obj,
VALUE  x 
) [static]

Definition at line 242 of file math.c.

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

Referenced by exp1().

static VALUE math_asin ( VALUE  obj,
VALUE  x 
) [static]

Definition at line 139 of file math.c.

References DBL2NUM, domain_error, Need_Float, and RFLOAT_VALUE.

Referenced by exp1().

static VALUE math_asinh ( VALUE  obj,
VALUE  x 
) [static]

Definition at line 262 of file math.c.

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

Referenced by exp1().

static VALUE math_atan ( VALUE  obj,
VALUE  x 
) [static]

Definition at line 159 of file math.c.

References DBL2NUM, Need_Float, and RFLOAT_VALUE.

Referenced by exp1().

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

Definition at line 52 of file math.c.

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

Referenced by exp1().

static VALUE math_atanh ( VALUE  obj,
VALUE  x 
) [static]

Definition at line 276 of file math.c.

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

Referenced by exp1().

static VALUE math_cbrt ( VALUE  obj,
VALUE  x 
) [static]

Definition at line 494 of file math.c.

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

Referenced by exp1().

static VALUE math_cos ( VALUE  obj,
VALUE  x 
) [static]

Definition at line 73 of file math.c.

References DBL2NUM, Need_Float, and RFLOAT_VALUE.

Referenced by exp1().

static VALUE math_cosh ( VALUE  obj,
VALUE  x 
) [static]

Definition at line 181 of file math.c.

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

Referenced by exp1().

static VALUE math_erf ( VALUE  obj,
VALUE  x 
) [static]

Definition at line 566 of file math.c.

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

Referenced by exp1().

static VALUE math_erfc ( VALUE  obj,
VALUE  x 
) [static]

Definition at line 580 of file math.c.

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

Referenced by exp1().

static VALUE math_exp ( VALUE  obj,
VALUE  x 
) [static]

Definition at line 304 of file math.c.

References DBL2NUM, Need_Float, and RFLOAT_VALUE.

Referenced by exp1().

static VALUE math_frexp ( VALUE  obj,
VALUE  x 
) [static]

Definition at line 513 of file math.c.

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

Referenced by exp1().

static VALUE math_gamma ( VALUE  obj,
VALUE  x 
) [static]

Definition at line 627 of file math.c.

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

Referenced by exp1().

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

Definition at line 552 of file math.c.

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

Referenced by exp1().

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

Definition at line 535 of file math.c.

References DBL2NUM, Need_Float, NUM2INT, and RFLOAT_VALUE.

Referenced by exp1().

static VALUE math_lgamma ( VALUE  obj,
VALUE  x 
) [static]

Definition at line 688 of file math.c.

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

Referenced by exp1().

static VALUE math_log ( int  argc,
VALUE argv 
) [static]

Definition at line 336 of file math.c.

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

Referenced by exp1(), and exp2().

static VALUE math_log10 ( VALUE  obj,
VALUE  x 
) [static]

Definition at line 409 of file math.c.

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

Referenced by exp1().

static VALUE math_log2 ( VALUE  obj,
VALUE  x 
) [static]

Definition at line 382 of file math.c.

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

Referenced by exp1().

static VALUE math_sin ( VALUE  obj,
VALUE  x 
) [static]

Definition at line 88 of file math.c.

References DBL2NUM, Need_Float, and RFLOAT_VALUE.

Referenced by exp1().

static VALUE math_sinh ( VALUE  obj,
VALUE  x 
) [static]

Definition at line 205 of file math.c.

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

Referenced by exp1().

static VALUE math_sqrt ( VALUE  obj,
VALUE  x 
) [static]

Definition at line 448 of file math.c.

References DBL2NUM, domain_error, Need_Float, and RFLOAT_VALUE.

Referenced by exp1().

static VALUE math_tan ( VALUE  obj,
VALUE  x 
) [static]

Definition at line 104 of file math.c.

References DBL2NUM, Need_Float, and RFLOAT_VALUE.

Referenced by exp1().

static VALUE math_tanh ( VALUE  obj,
VALUE  x 
) [static]

Definition at line 228 of file math.c.

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

Referenced by exp1().

VALUE rb_to_float ( VALUE  val  ) 
double sinh ( double  x  ) 

Definition at line 190 of file math.c.

Referenced by math_sinh(), and tanh().

double tanh ( double  x  ) 

Definition at line 213 of file math.c.

References cosh(), and sinh().

Referenced by math_tanh().


Variable Documentation

Definition at line 19 of file math.c.

Definition at line 18 of file math.c.