Ruby 2.0.0p353(2013-11-22revision43784)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

Macros | Functions | Variables
math.c File Reference
`#include "ruby/ruby.h"`
`#include "internal.h"`
`#include <math.h>`
`#include <errno.h>`
Include dependency graph for math.c:

Go to the source code of this file.

## Macros
#define | numberof(array) (int)(sizeof(array) / sizeof((array)[0]))
#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)

Definition at line 33 of file math.c.

Referenced by math_acos(), math_acosh(), math_asin(), math_atan2(), math_atanh(), math_gamma(), math_lgamma(), math_log(), math_log10(), math_log2(), and math_sqrt().

#define exp1 | ( |  | n | ) |

Value:
VALUE \
rb_math_##n(VALUE x)\
{\
return math_##n(rb_mMath, x);\
}
n
ssize_t n
Definition: bigdecimal.c:5655
return
return
Definition: bigdecimal.c:5800
rb_mMath
RUBY_EXTERN VALUE rb_mMath
Definition: ripper.y:1420
VALUE
unsigned long VALUE
Definition: ripper.y:104

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);\
}
n
ssize_t n
Definition: bigdecimal.c:5655
return
return
Definition: bigdecimal.c:5800
rb_mMath
RUBY_EXTERN VALUE rb_mMath
Definition: ripper.y:1420
VALUE
unsigned long VALUE
Definition: ripper.y:104

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 (!RB_TYPE_P(x, T_FLOAT)) {(x) = rb_to_float(x);}} while(0)

Definition at line 27 of file math.c.

Referenced by math_acos(), math_acosh(), math_asin(), math_asinh(), math_atan(), math_atanh(), math_cbrt(), math_cos(), math_cosh(), math_erf(), math_erfc(), math_exp(), math_frexp(), math_gamma(), math_ldexp(), math_lgamma(), math_log(), math_log10(), math_log2(), math_sin(), math_sinh(), math_sqrt(), math_tan(), and math_tanh().

#define Need_Float2 | ( |  | x,
|  |  | y
| ) |  |

Value:
do {\
Need_Float(x);\
Need_Float(y);\
} while (0)
Need_Float
#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 |  | ) |

Definition at line 778 of file math.c.

References DBL2NUM, M_PI, math_acos(), math_acosh(), math_asin(), math_asinh(), math_atan(), math_atan2(), math_atanh(), math_cbrt(), math_cos(), math_cosh(), math_erf(), math_erfc(), math_exp(), math_frexp(), math_gamma(), math_hypot(), math_ldexp(), math_lgamma(), math_log(), math_log10(), math_log2(), math_sin(), math_sinh(), math_sqrt(), math_tan(), math_tanh(), rb_define_class_under(), rb_define_const(), rb_define_module(), rb_define_module_function(), rb_eMathDomainError, rb_eStandardError, and rb_mMath.

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.