Ruby 1.9.2p136(2010-12-25revision30365)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

Defines | Functions | Variables

# complex.c File Reference

`#include "ruby.h"`
`#include <math.h>`
`#include <assert.h>`
Include dependency graph for complex.c:

Go to the source code of this file.

## Defines
#define | NDEBUG
#define | ZERO INT2FIX(0)
#define | ONE INT2FIX(1)
#define | TWO INT2FIX(2)
#define | f_boolcast(x) ((x) ? Qtrue : Qfalse)
#define | binop(n, op)
#define | fun1(n)
#define | fun2(n)
#define | math1(n)
#define | math2(n)
#define | PRESERVE_SIGNEDZERO
#define | f_positive_p(x) (!f_negative_p(x))
#define | f_nonzero_p(x) (!f_zero_p(x))
#define | k_exact_p(x) (!k_float_p(x))
#define | k_inexact_p(x) k_float_p(x)
#define | k_exact_zero_p(x) (k_exact_p(x) && f_zero_p(x))
#define | k_exact_one_p(x) (k_exact_p(x) && f_one_p(x))
#define | get_dat1(x)
#define | get_dat2(x, y)
#define | imp1(n)
#define | imp2(n)
#define | m_hypot(x, y) m_hypot_bang(x,y)
#define | rb_raise_zerodiv() rb_raise(rb_eZeroDivError, "divided by 0")
#define | nucomp_quo nucomp_div
#define | WS "\\s*"
#define | DIGITS "(?:[0-9](?:_[0-9]|[0-9])*)"
#define | NUMERATOR "(?:" DIGITS "?\\.)?" DIGITS "(?:[eE][-+]?" DIGITS ")?"
#define | DENOMINATOR DIGITS
#define | NUMBER "[-+]?" NUMERATOR "(?:\\/" DENOMINATOR ")?"
#define | NUMBERNOS NUMERATOR "(?:\\/" DENOMINATOR ")?"
#define | PATTERN0 "\\A" WS "(" NUMBER ")@(" NUMBER ")" WS
#define | PATTERN1 "\\A" WS "([-+])?(" NUMBER ")?[iIjJ]" WS
#define | PATTERN2 "\\A" WS "(" NUMBER ")(([-+])(" NUMBERNOS ")?[iIjJ])?" WS
#define | id_match rb_intern("match")
#define | f_match(x, y) rb_funcall(x, id_match, 1, y)
#define | id_aref rb_intern("[]")
#define | f_aref(x, y) rb_funcall(x, id_aref, 1, y)
#define | id_post_match rb_intern("post_match")
#define | f_post_match(x) rb_funcall(x, id_post_match, 0)
#define | id_split rb_intern("split")
#define | f_split(x, y) rb_funcall(x, id_split, 1, y)
#define | id_include_p rb_intern("include?")
#define | f_include_p(x, y) rb_funcall(x, id_include_p, 1, y)
#define | id_count rb_intern("count")
#define | f_count(x, y) rb_funcall(x, id_count, 1, y)
#define | id_gsub_bang rb_intern("gsub!")
#define | f_gsub_bang(x, y, z) rb_funcall(x, id_gsub_bang, 2, y, z)
#define | id_gsub rb_intern("gsub")
#define | f_gsub(x, y, z) rb_funcall(x, id_gsub, 2, y, z)
#define | id_PI rb_intern("PI")
#define | rb_intern(str) rb_intern_const(str)
## Functions
static VALUE | f_add (VALUE x, VALUE y)
static VALUE | f_cmp (VALUE x, VALUE y)
static VALUE | f_div (VALUE x, VALUE y)
static VALUE | f_gt_p (VALUE x, VALUE y)
static VALUE | f_lt_p (VALUE x, VALUE y)
| binop (mod, '%')
static VALUE | f_sub (VALUE x, VALUE y)
| fun1 (abs)
| fun2 (expt)
static VALUE | f_zero_p (VALUE x)
static VALUE | f_one_p (VALUE x)
static VALUE | f_kind_of_p (VALUE x, VALUE c)
static VALUE | k_numeric_p (VALUE x)
static VALUE | k_integer_p (VALUE x)
static VALUE | k_fixnum_p (VALUE x)
static VALUE | k_bignum_p (VALUE x)
static VALUE | k_float_p (VALUE x)
static VALUE | k_rational_p (VALUE x)
static VALUE | k_complex_p (VALUE x)
static VALUE | nucomp_s_new_internal (VALUE klass, VALUE real, VALUE imag)
static VALUE | nucomp_s_alloc (VALUE klass)
static VALUE | f_complex_new_bang1 (VALUE klass, VALUE x)
static VALUE | f_complex_new_bang2 (VALUE klass, VALUE x, VALUE y)
static void | nucomp_real_check (VALUE num)
static VALUE | nucomp_s_canonicalize_internal (VALUE klass, VALUE real, VALUE imag)
static VALUE | nucomp_s_new (int argc, VALUE *argv, VALUE klass)
static VALUE | f_complex_new1 (VALUE klass, VALUE x)
static VALUE | f_complex_new2 (VALUE klass, VALUE x, VALUE y)
static VALUE | nucomp_f_complex (int argc, VALUE *argv, VALUE klass)
| imp2 (atan2)
| imp1 (sin)
static VALUE | m_sin (VALUE x)
static VALUE | f_complex_polar (VALUE klass, VALUE x, VALUE y)
static VALUE | nucomp_s_polar (int argc, VALUE *argv, VALUE klass)
static VALUE | nucomp_real (VALUE self)
static VALUE | nucomp_imag (VALUE self)
static VALUE | nucomp_negate (VALUE self)
static VALUE | f_addsub (VALUE self, VALUE other, VALUE(*func)(VALUE, VALUE), ID id)
static VALUE | nucomp_add (VALUE self, VALUE other)
static VALUE | nucomp_sub (VALUE self, VALUE other)
static VALUE | nucomp_mul (VALUE self, VALUE other)
static VALUE | f_divide (VALUE self, VALUE other, VALUE(*func)(VALUE, VALUE), ID id)
static VALUE | nucomp_div (VALUE self, VALUE other)
static VALUE | nucomp_fdiv (VALUE self, VALUE other)
static VALUE | f_reciprocal (VALUE x)
static VALUE | nucomp_expt (VALUE self, VALUE other)
static VALUE | nucomp_eqeq_p (VALUE self, VALUE other)
static VALUE | nucomp_coerce (VALUE self, VALUE other)
static VALUE | nucomp_abs (VALUE self)
static VALUE | nucomp_abs2 (VALUE self)
static VALUE | nucomp_arg (VALUE self)
static VALUE | nucomp_rect (VALUE self)
static VALUE | nucomp_polar (VALUE self)
static VALUE | nucomp_conj (VALUE self)
static VALUE | nucomp_false (VALUE self)
VALUE | rb_lcm (VALUE x, VALUE y)
static VALUE | nucomp_denominator (VALUE self)
static VALUE | nucomp_numerator (VALUE self)
static VALUE | nucomp_hash (VALUE self)
static VALUE | nucomp_eql_p (VALUE self, VALUE other)
static VALUE | f_signbit (VALUE x)
static VALUE | f_tpositive_p (VALUE x)
static VALUE | f_format (VALUE self, VALUE(*func)(VALUE))
static VALUE | nucomp_to_s (VALUE self)
static VALUE | nucomp_inspect (VALUE self)
static VALUE | nucomp_marshal_dump (VALUE self)
static VALUE | nucomp_marshal_load (VALUE self, VALUE a)
VALUE | rb_complex_raw (VALUE x, VALUE y)
VALUE | rb_complex_new (VALUE x, VALUE y)
VALUE | rb_complex_polar (VALUE x, VALUE y)
static VALUE | nucomp_s_convert (int argc, VALUE *argv, VALUE klass)
VALUE | rb_Complex (VALUE x, VALUE y)
static VALUE | nucomp_to_i (VALUE self)
static VALUE | nucomp_to_f (VALUE self)
static VALUE | nucomp_to_r (VALUE self)
static VALUE | nucomp_rationalize (int argc, VALUE *argv, VALUE self)
static VALUE | nilclass_to_c (VALUE self)
static VALUE | numeric_to_c (VALUE self)
static void | make_patterns (void)
static VALUE | string_to_c_internal (VALUE self)
static VALUE | string_to_c_strict (VALUE self)
static VALUE | string_to_c (VALUE self)
static VALUE | numeric_real (VALUE self)
static VALUE | numeric_imag (VALUE self)
static VALUE | numeric_abs2 (VALUE self)
static VALUE | numeric_arg (VALUE self)
static VALUE | numeric_rect (VALUE self)
static VALUE | numeric_polar (VALUE self)
static VALUE | numeric_conj (VALUE self)
static VALUE | float_arg (VALUE self)
void | Init_Complex (void)
## Variables
VALUE | rb_cComplex
static ID | id_abs
static ID | id_abs2
static ID | id_arg
static ID | id_cmp
static ID | id_conj
static ID | id_convert
static ID | id_denominator
static ID | id_divmod
static ID | id_eqeq_p
static ID | id_expt
static ID | id_fdiv
static ID | id_floor
static ID | id_idiv
static ID | id_imag
static ID | id_inspect
static ID | id_negate
static ID | id_numerator
static ID | id_quo
static ID | id_real
static ID | id_real_p
static ID | id_to_f
static ID | id_to_i
static ID | id_to_r
static ID | id_to_s
static VALUE | comp_pat0
static VALUE | comp_pat1
static VALUE | comp_pat2
static VALUE | a_slash
static VALUE | a_dot_and_an_e
static VALUE | null_string
static VALUE | underscores_pat
static VALUE | an_underscore

## Define Documentation

#define binop | ( |  | n,
|  |  | op
| ) |  |

Value:

    inline static VALUE \
    f_##n(VALUE x, VALUE y)\
    {\
        return rb_funcall(x, op, 1, y);\
    }

Definition at line 27 of file complex.c.

#define DENOMINATOR DIGITS

Definition at line 1381 of file complex.c.

#define DIGITS "(?:[0-9](?:_[0-9]|[0-9])*)"

Definition at line 1379 of file complex.c.

#define f_aref | ( |  | x,
|  |  | y
| ) |  | rb_funcall(x, id_aref, 1, y)

Definition at line 1428 of file complex.c.

Referenced by string_to_c_internal().

#define f_boolcast | ( |  | x | ) | ((x) ? Qtrue : Qfalse)

Definition at line 25 of file complex.c.

Referenced by f_gt_p(), f_lt_p(), f_one_p(), f_signbit(), f_tpositive_p(), f_zero_p(), fun1(), fun2(), nucomp_eqeq_p(), and nucomp_eql_p().

#define f_count | ( |  | x,
|  |  | y
| ) |  | rb_funcall(x, id_count, 1, y)

Definition at line 1440 of file complex.c.

Referenced by string_to_c_internal().

#define f_gsub | ( |  | x,
|  |  | y,
|  |  | z
| ) |  | rb_funcall(x, id_gsub, 2, y, z)

Definition at line 1542 of file complex.c.

Referenced by string_to_c().

#define f_gsub_bang | ( |  | x,
|  |  | y,
|  |  | z
| ) |  | rb_funcall(x, id_gsub_bang, 2, y, z)

Definition at line 1443 of file complex.c.

#define f_include_p | ( |  | x,
|  |  | y
| ) |  | rb_funcall(x, id_include_p, 1, y)

Definition at line 1437 of file complex.c.

Referenced by string_to_c_internal().

#define f_match | ( |  | x,
|  |  | y
| ) |  | rb_funcall(x, id_match, 1, y)

Definition at line 1425 of file complex.c.

Referenced by string_to_c_internal().

#define f_nonzero_p | ( |  | x | ) | (!f_zero_p(x))

Definition at line 213 of file complex.c.

Referenced by nucomp_to_f(), nucomp_to_i(), and nucomp_to_r().

#define f_positive_p | ( |  | x | ) | (!f_negative_p(x))

Definition at line 193 of file complex.c.

Referenced by numeric_arg().

#define f_post_match | ( |  | x | ) | rb_funcall(x, id_post_match, 0)

Definition at line 1431 of file complex.c.

Referenced by string_to_c_internal().

#define f_split | ( |  | x,
|  |  | y
| ) |  | rb_funcall(x, id_split, 1, y)

Definition at line 1434 of file complex.c.

#define fun1 | ( |  | n | ) |

Value:

    inline static VALUE \
    f_##n(VALUE x)\
    {\
        return rb_funcall(x, id_##n, 0);\
    }

Definition at line 34 of file complex.c.

#define fun2 | ( |  | n | ) |

Value:

    inline static VALUE \
    f_##n(VALUE x, VALUE y)\
    {\
        return rb_funcall(x, id_##n, 1, y);\
    }

Definition at line 41 of file complex.c.

#define get_dat1 | ( |  | x | ) |

Value:

    struct RComplex *dat;\
        dat = ((struct RComplex *)(x))

Definition at line 289 of file complex.c.

Referenced by f_addsub(), f_divide(), f_format(), imp1(), m_sin(), nucomp_abs(), nucomp_abs2(), nucomp_arg(), nucomp_conj(), nucomp_denominator(), nucomp_eqeq_p(), nucomp_expt(), nucomp_hash(), nucomp_imag(), nucomp_marshal_dump(), nucomp_marshal_load(), nucomp_mul(), nucomp_negate(), nucomp_numerator(), nucomp_real(), nucomp_rect(), nucomp_s_canonicalize_internal(), nucomp_s_convert(), nucomp_to_f(), nucomp_to_i(), and nucomp_to_r().

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

Value:

    struct RComplex *adat, *bdat;\
        adat = ((struct RComplex *)(x));\
        bdat = ((struct RComplex *)(y))

Definition at line 293 of file complex.c.

Referenced by f_addsub(), f_divide(), nucomp_eqeq_p(), nucomp_eql_p(), nucomp_mul(), and nucomp_s_canonicalize_internal().

#define id_aref rb_intern("[]")

Definition at line 1427 of file complex.c.

#define id_count rb_intern("count")

Definition at line 1439 of file complex.c.

#define id_gsub rb_intern("gsub")

Definition at line 1541 of file complex.c.

#define id_gsub_bang rb_intern("gsub!")

Definition at line 1442 of file complex.c.

#define id_include_p rb_intern("include?")

Definition at line 1436 of file complex.c.

#define id_match rb_intern("match")

Definition at line 1424 of file complex.c.

#define id_PI rb_intern("PI")

Definition at line 1708 of file complex.c.

Referenced by float_arg(), and numeric_arg().

#define id_post_match rb_intern("post_match")

Definition at line 1430 of file complex.c.

#define id_split rb_intern("split")

Definition at line 1433 of file complex.c.

#define imp1 | ( |  | n | ) |

Value:

    extern VALUE rb_math_##n(VALUE x);\
    inline static VALUE \
    m_##n##_bang(VALUE x)\
    {\
        return rb_math_##n(x);\
    }

Definition at line 474 of file complex.c.

#define imp2 | ( |  | n | ) |

Value:

    extern VALUE rb_math_##n(VALUE x, VALUE y);\
    inline static VALUE \
    m_##n##_bang(VALUE x, VALUE y)\
    {\
        return rb_math_##n(x, y);\
    }

Definition at line 482 of file complex.c.

#define k_exact_one_p | ( |  | x | ) | (k_exact_p(x) && f_one_p(x))

Definition at line 287 of file complex.c.

#define k_exact_p | ( |  | x | ) | (!k_float_p(x))

Definition at line 283 of file complex.c.

#define k_exact_zero_p | ( |  | x | ) | (k_exact_p(x) && f_zero_p(x))

Definition at line 286 of file complex.c.

Referenced by nucomp_expt(), nucomp_s_canonicalize_internal(), and nucomp_s_convert().

#define k_inexact_p | ( |  | x | ) | k_float_p(x)

Definition at line 284 of file complex.c.

Referenced by nucomp_to_f(), nucomp_to_i(), and nucomp_to_r().

#define m_hypot | ( |  | x,
|  |  | y
| ) |  | m_hypot_bang(x,y)

Referenced by nucomp_abs().

#define math1 | ( |  | n | ) |

Value:

    inline static VALUE \
    m_##n(VALUE x)\
    {\
        return rb_funcall(rb_mMath, id_##n, 1, x);\
    }

Definition at line 48 of file complex.c.

#define math2 | ( |  | n | ) |

Value:

    inline static VALUE \
    m_##n(VALUE x, VALUE y)\
    {\
        return rb_funcall(rb_mMath, id_##n, 2, x, y);\
    }

Definition at line 55 of file complex.c.

#define NDEBUG

Definition at line 11 of file complex.c.

#define nucomp_quo nucomp_div

Definition at line 789 of file complex.c.

Referenced by Init_Complex().

#define NUMBER "[-+]?" NUMERATOR "(?:\\/" DENOMINATOR ")?"

Definition at line 1382 of file complex.c.

#define NUMBERNOS NUMERATOR "(?:\\/" DENOMINATOR ")?"

Definition at line 1383 of file complex.c.

#define NUMERATOR "(?:" DIGITS "?\\.)?" DIGITS "(?:[eE][-+]?" DIGITS ")?"

Definition at line 1380 of file complex.c.

#define ONE INT2FIX(1)

Definition at line 15 of file complex.c.

Referenced by f_divide(), f_one_p(), f_reciprocal(), Init_Complex(), nucomp_expt(), and nucomp_s_convert().

#define PATTERN0 "\\A" WS "(" NUMBER ")@(" NUMBER ")" WS

Definition at line 1384 of file complex.c.

Referenced by make_patterns().

#define PATTERN1 "\\A" WS "([-+])?(" NUMBER ")?[iIjJ]" WS

Definition at line 1385 of file complex.c.

Referenced by make_patterns().

#define PATTERN2 "\\A" WS "(" NUMBER ")(([-+])(" NUMBERNOS ")?[iIjJ])?" WS

Definition at line 1386 of file complex.c.

Referenced by make_patterns().

#define PRESERVE_SIGNEDZERO

Definition at line 62 of file complex.c.

#define rb_intern | ( |  | str | ) | rb_intern_const(str)

#define rb_raise_zerodiv | ( |  | ) | rb_raise(rb_eZeroDivError, "divided by 0")

Definition at line 769 of file complex.c.

#define TWO INT2FIX(2)

Definition at line 16 of file complex.c.

Referenced by nucomp_expt().

#define WS "\\s*"

Definition at line 1378 of file complex.c.

#define ZERO INT2FIX(0)

Definition at line 14 of file complex.c.

Referenced by binop(), f_complex_new1(), f_complex_new_bang1(), f_zero_p(), fun2(), Init_Complex(), nucomp_expt(), nucomp_s_alloc(), nucomp_s_canonicalize_internal(), nucomp_s_convert(), nucomp_s_new(), and nucomp_s_polar().

## Function Documentation

binop | ( | mod | ,
|  | '%' |
| ) |  |

Definition at line 114 of file complex.c.

References FIX2LONG, FIXNUM_P, rb_funcall(), T_BIGNUM, TYPE, and ZERO.

static VALUE f_add | ( | VALUE | x,
|  | VALUE | y
| ) |  | `[inline, static]`

Definition at line 65 of file complex.c.

References FIX2LONG, FIXNUM_P, and rb_funcall().

Referenced by f_divide(), nucomp_abs2(), nucomp_add(), nucomp_expt(), nucomp_mul(), nucomp_s_canonicalize_internal(), and nucomp_s_convert().

static VALUE f_addsub | ( | VALUE | self,
|  | VALUE | other,
|  | VALUE(*)(VALUE, VALUE) | func,
|  | ID | id
| ) |  | `[inline, static]`

Definition at line 640 of file complex.c.

References CLASS_OF, f_complex_new2(), func, get_dat1, get_dat2, k_complex_p(), k_numeric_p(), and rb_num_coerce_bin().

Referenced by nucomp_add(), and nucomp_sub().

static VALUE f_cmp | ( | VALUE | x,
|  | VALUE | y
| ) |  | `[inline, static]`

Definition at line 77 of file complex.c.

References FIX2LONG, FIXNUM_P, id_cmp, INT2FIX, and rb_funcall().

static VALUE f_complex_new1 | ( | VALUE | klass,
|  | VALUE | x
| ) |  | `[inline, static]`

Definition at line 449 of file complex.c.

References assert, k_complex_p(), nucomp_s_canonicalize_internal(), and ZERO.

static VALUE f_complex_new2 | ( | VALUE | klass,
|  | VALUE | x,
|  | VALUE | y
| ) |  | `[inline, static]`

Definition at line 456 of file complex.c.

References assert, k_complex_p(), and nucomp_s_canonicalize_internal().

Referenced by f_addsub(), f_divide(), imp1(), m_sin(), nucomp_conj(), nucomp_expt(), nucomp_mul(), nucomp_negate(), and nucomp_numerator().

static VALUE f_complex_new_bang1 | ( | VALUE | klass,
|  | VALUE | x
| ) |  | `[inline, static]`

Definition at line 341 of file complex.c.

References assert, k_complex_p(), nucomp_s_new_internal(), and ZERO.

Referenced by nucomp_coerce(), and nucomp_expt().

static VALUE f_complex_new_bang2 | ( | VALUE | klass,
|  | VALUE | x,
|  | VALUE | y
| ) |  | `[inline, static]`

Definition at line 348 of file complex.c.

References assert, k_complex_p(), and nucomp_s_new_internal().

Referenced by Init_Complex(), and nucomp_s_convert().

static VALUE f_complex_polar | ( | VALUE | klass,
|  | VALUE | x,
|  | VALUE | y
| ) |  | `[inline, static]`

Definition at line 565 of file complex.c.

References assert, k_complex_p(), m_sin(), and nucomp_s_canonicalize_internal().

Referenced by nucomp_expt(), nucomp_s_polar(), and rb_complex_polar().

static VALUE f_div | ( | VALUE | x,
|  | VALUE | y
| ) |  | `[inline, static]`

Definition at line 91 of file complex.c.

References FIX2LONG, FIXNUM_P, and rb_funcall().

Referenced by nucomp_numerator().

static VALUE f_divide | ( | VALUE | self,
|  | VALUE | other,
|  | VALUE(*)(VALUE, VALUE) | func,
|  | ID | id
| ) |  | `[inline, static]`

Definition at line 718 of file complex.c.

References CLASS_OF, f_add(), f_complex_new2(), f_gt_p(), f_sub(), func, get_dat1, get_dat2, k_complex_p(), k_float_p(), k_numeric_p(), ONE, and rb_num_coerce_bin().

Referenced by nucomp_div(), and nucomp_fdiv().

static VALUE f_format | ( | VALUE | self,
|  | VALUE(*)(VALUE) | func
| ) |  | `[static]`

Definition at line 1176 of file complex.c.

References f_tpositive_p(), func, get_dat1, rb_isdigit(), rb_str_cat2(), rb_str_concat(), RSTRING_LEN, and RSTRING_PTR.

Referenced by nucomp_inspect(), and nucomp_to_s().

static VALUE f_gt_p | ( | VALUE | x,
|  | VALUE | y
| ) |  | `[inline, static]`

Definition at line 99 of file complex.c.

References f_boolcast, FIX2LONG, FIXNUM_P, and rb_funcall().

Referenced by f_divide(), nucomp_expt(), and string_to_c_internal().

static VALUE f_kind_of_p | ( | VALUE | x,
|  | VALUE | c
| ) |  | `[inline, static]`

Definition at line 236 of file complex.c.

References rb_obj_is_kind_of().

Referenced by k_bignum_p(), k_complex_p(), k_fixnum_p(), k_float_p(), k_integer_p(), k_numeric_p(), and k_rational_p().

static VALUE f_lt_p | ( | VALUE | x,
|  | VALUE | y
| ) |  | `[inline, static]`

Definition at line 107 of file complex.c.

References f_boolcast, FIX2LONG, FIXNUM_P, and rb_funcall().

static VALUE f_one_p | ( | VALUE | x | ) | `[inline, static]`

Definition at line 216 of file complex.c.

References f_boolcast, FIX2LONG, FIXNUM_P, id_eqeq_p, ONE, Qfalse, rb_funcall(), RRATIONAL, T_BIGNUM, T_FIXNUM, T_RATIONAL, and TYPE.

Referenced by nucomp_expt().

static VALUE f_reciprocal | ( | VALUE | x | ) | `[inline, static]`

Definition at line 808 of file complex.c.

References f_quo, and ONE.

Referenced by nucomp_expt().

static VALUE f_signbit | ( | VALUE | x | ) | `[inline, static]`

Definition at line 1158 of file complex.c.

References f_boolcast, isnan, RFLOAT_VALUE, signbit(), T_FLOAT, and TYPE.

Referenced by f_tpositive_p().

static VALUE f_sub | ( | VALUE | x,
|  | VALUE | y
| ) |  | `[inline, static]`

Definition at line 143 of file complex.c.

References FIX2LONG, FIXNUM_P, and rb_funcall().

Referenced by f_divide(), nucomp_expt(), nucomp_mul(), nucomp_s_canonicalize_internal(), and nucomp_sub().

static VALUE f_tpositive_p | ( | VALUE | x | ) | `[inline, static]`

Definition at line 1170 of file complex.c.

References f_boolcast, and f_signbit().

Referenced by f_format(), and float_arg().

static VALUE f_zero_p | ( | VALUE | x | ) | `[inline, static]`

Definition at line 196 of file complex.c.

References f_boolcast, FIX2LONG, FIXNUM_P, id_eqeq_p, Qfalse, rb_funcall(), RRATIONAL, T_BIGNUM, T_FIXNUM, T_RATIONAL, TYPE, and ZERO.

Referenced by nucomp_abs(), nucomp_eqeq_p(), and nucomp_s_canonicalize_internal().

static VALUE float_arg | ( | VALUE | self | ) | `[static]`

Definition at line 1772 of file complex.c.

References f_tpositive_p(), id_PI, INT2FIX, isnan, rb_const_get(), rb_mMath, and RFLOAT_VALUE.

Referenced by Init_Complex().

fun1 | ( | abs |  | ) |

Definition at line 152 of file complex.c.

References f_boolcast, FIX2LONG, FIXNUM_P, id_eqeq_p, and rb_funcall().

fun2 | ( | expt |  | ) |

Definition at line 180 of file complex.c.

References f_boolcast, FIX2LONG, FIXNUM_P, rb_funcall(), and ZERO.

imp1 | ( | sin |  | ) |

Definition at line 506 of file complex.c.

References f_complex_new2(), get_dat1, and rb_cComplex.

imp2 | ( | atan2 |  | ) |

Definition at line 490 of file complex.c.

void Init_Complex | ( | void |  | ) |

Definition at line 1814 of file complex.c.

References assert, CLASS_OF, f_complex_new_bang2(), float_arg(), id_abs, id_abs2, id_arg, id_cmp, id_conj, id_convert, id_denominator, id_divmod, id_eqeq_p, id_expt, id_fdiv, id_floor, id_idiv, id_imag, id_inspect, id_negate, id_numerator, id_quo, id_real, id_real_p, id_to_f, id_to_i, id_to_r, id_to_s, make_patterns(), nilclass_to_c(), nucomp_abs(), nucomp_abs2(), nucomp_add(), nucomp_arg(), nucomp_coerce(), nucomp_conj(), nucomp_denominator(), nucomp_div(), nucomp_eqeq_p(), nucomp_eql_p(), nucomp_expt(), nucomp_f_complex(), nucomp_false(), nucomp_fdiv(), nucomp_hash(), nucomp_imag(), nucomp_inspect(), nucomp_marshal_dump(), nucomp_marshal_load(), nucomp_mul(), nucomp_negate(), nucomp_numerator(), nucomp_polar(), nucomp_quo, nucomp_rationalize(), nucomp_real(), nucomp_rect(), nucomp_s_alloc(), nucomp_s_convert(), nucomp_s_new(), nucomp_s_polar(), nucomp_sub(), nucomp_to_f(), nucomp_to_i(), nucomp_to_r(), nucomp_to_s(), numeric_abs2(), numeric_arg(), numeric_conj(), numeric_imag(), numeric_polar(), numeric_real(), numeric_rect(), numeric_to_c(), ONE, rb_cComplex, rb_cFloat, rb_cNilClass, rb_cNumeric, rb_cString, rb_define_alloc_func(), rb_define_class(), rb_define_const(), rb_define_global_function(), rb_define_method(), rb_define_private_method(), rb_define_singleton_method(), rb_intern, rb_undef_method(), string_to_c(), and ZERO.

static VALUE k_bignum_p | ( | VALUE | x | ) | `[inline, static]`

Definition at line 260 of file complex.c.

References f_kind_of_p(), and rb_cBignum.

Referenced by nucomp_expt().

static VALUE k_complex_p | ( | VALUE | x | ) | `[inline, static]`

Definition at line 278 of file complex.c.

References f_kind_of_p(), and rb_cComplex.

Referenced by f_addsub(), f_complex_new1(), f_complex_new2(), f_complex_new_bang1(), f_complex_new_bang2(), f_complex_polar(), f_divide(), nucomp_eqeq_p(), nucomp_eql_p(), nucomp_expt(), and nucomp_mul().

static VALUE k_fixnum_p | ( | VALUE | x | ) | `[inline, static]`

Definition at line 254 of file complex.c.

References f_kind_of_p(), and rb_cFixnum.

Referenced by nucomp_expt().

static VALUE k_float_p | ( | VALUE | x | ) | `[inline, static]`

Definition at line 266 of file complex.c.

References f_kind_of_p(), and rb_cFloat.

Referenced by f_divide(), and nucomp_abs().

static VALUE k_integer_p | ( | VALUE | x | ) | `[inline, static]`

Definition at line 248 of file complex.c.

References f_kind_of_p(), and rb_cInteger.

static VALUE k_numeric_p | ( | VALUE | x | ) | `[inline, static]`

Definition at line 242 of file complex.c.

References f_kind_of_p(), and rb_cNumeric.

Referenced by f_addsub(), f_divide(), nucomp_coerce(), nucomp_eqeq_p(), nucomp_expt(), nucomp_mul(), nucomp_real_check(), and nucomp_s_convert().

static VALUE k_rational_p | ( | VALUE | x | ) | `[inline, static]`

Definition at line 272 of file complex.c.

References f_kind_of_p(), and rb_cRational.

Referenced by nucomp_expt().

static VALUE m_sin | ( | VALUE | x | ) | `[static]`

Definition at line 526 of file complex.c.

References f_complex_new2(), get_dat1, and rb_cComplex.

Referenced by f_complex_polar().

static void make_patterns | ( | void |  | ) | `[static]`

Definition at line 1389 of file complex.c.

References PATTERN0, PATTERN1, PATTERN2, rb_gc_register_mark_object(), rb_reg_new(), and rb_usascii_str_new2().

Referenced by Init_Complex().

static VALUE nilclass_to_c | ( | VALUE | self | ) | `[static]`

Definition at line 1358 of file complex.c.

References INT2FIX, and rb_complex_new1.

Referenced by Init_Complex().

static VALUE nucomp_abs | ( | VALUE | self | ) | `[static]`

Definition at line 948 of file complex.c.

References f_zero_p(), get_dat1, k_float_p(), and m_hypot.

Referenced by Init_Complex().

static VALUE nucomp_abs2 | ( | VALUE | self | ) | `[static]`

Definition at line 974 of file complex.c.

References f_add(), and get_dat1.

Referenced by Init_Complex().

static VALUE nucomp_add | ( | VALUE | self,
|  | VALUE | other
| ) |  | `[static]`

Definition at line 669 of file complex.c.

References f_add(), and f_addsub().

Referenced by Init_Complex().

static VALUE nucomp_arg | ( | VALUE | self | ) | `[static]`

Definition at line 990 of file complex.c.

References get_dat1.

Referenced by Init_Complex().

static VALUE nucomp_coerce | ( | VALUE | self,
|  | VALUE | other
| ) |  | `[static]`

Definition at line 928 of file complex.c.

References CLASS_OF, f_complex_new_bang1(), k_numeric_p(), Qnil, rb_assoc_new(), rb_eTypeError, rb_obj_classname(), rb_raise(), T_COMPLEX, and TYPE.

Referenced by Init_Complex().

static VALUE nucomp_conj | ( | VALUE | self | ) | `[static]`

Definition at line 1030 of file complex.c.

References CLASS_OF, f_complex_new2(), and get_dat1.

Referenced by Init_Complex().

static VALUE nucomp_denominator | ( | VALUE | self | ) | `[static]`

Definition at line 1085 of file complex.c.

References f_denominator, get_dat1, and rb_lcm().

Referenced by Init_Complex().

static VALUE nucomp_div | ( | VALUE | self,
|  | VALUE | other
| ) |  | `[static]`

Definition at line 784 of file complex.c.

References f_divide(), f_quo, and id_quo.

Referenced by Init_Complex().

static VALUE nucomp_eqeq_p | ( | VALUE | self,
|  | VALUE | other
| ) |  | `[static]`

Definition at line 910 of file complex.c.

References f_boolcast, f_zero_p(), get_dat1, get_dat2, k_complex_p(), and k_numeric_p().

Referenced by Init_Complex().

static VALUE nucomp_eql_p | ( | VALUE | self,
|  | VALUE | other
| ) |  | `[static]`

Definition at line 1144 of file complex.c.

References CLASS_OF, f_boolcast, get_dat2, k_complex_p(), and Qfalse.

Referenced by Init_Complex().

static VALUE nucomp_expt | ( | VALUE | self,
|  | VALUE | other
| ) |  | `[static]`

Definition at line 825 of file complex.c.

References CLASS_OF, f_add(), f_complex_new2(), f_complex_new_bang1(), f_complex_polar(), f_denominator, f_gt_p(), f_numerator, f_one_p(), f_reciprocal(), f_sub(), FIX2LONG, get_dat1, id_expt, k_bignum_p(), k_complex_p(), k_exact_zero_p, k_fixnum_p(), k_numeric_p(), k_rational_p(), ONE, rb_num_coerce_bin(), rb_warn(), TWO, and ZERO.

Referenced by Init_Complex().

static VALUE nucomp_f_complex | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | klass
| ) |  | `[static]`

Definition at line 469 of file complex.c.

References id_convert, rb_cComplex, and rb_funcall2().

Referenced by Init_Complex().

static VALUE nucomp_false | ( | VALUE | self | ) | `[static]`

Definition at line 1052 of file complex.c.

References Qfalse.

Referenced by Init_Complex().

static VALUE nucomp_fdiv | ( | VALUE | self,
|  | VALUE | other
| ) |  | `[static]`

Definition at line 802 of file complex.c.

References f_divide(), and id_fdiv.

Referenced by Init_Complex().

static VALUE nucomp_hash | ( | VALUE | self | ) | `[static]`

Definition at line 1128 of file complex.c.

References get_dat1, LONG2FIX, NUM2LONG(), rb_hash(), and rb_memhash().

Referenced by Init_Complex().

static VALUE nucomp_imag | ( | VALUE | self | ) | `[static]`

Definition at line 619 of file complex.c.

References get_dat1.

Referenced by Init_Complex().

static VALUE nucomp_inspect | ( | VALUE | self | ) | `[static]`

Definition at line 1214 of file complex.c.

References f_format(), rb_str_cat2(), rb_str_concat(), and rb_usascii_str_new2().

Referenced by Init_Complex().

static VALUE nucomp_marshal_dump | ( | VALUE | self | ) | `[static]`

Definition at line 1227 of file complex.c.

References get_dat1, rb_assoc_new(), and rb_copy_generic_ivar().

Referenced by Init_Complex().

static VALUE nucomp_marshal_load | ( | VALUE | self,
|  | VALUE | a
| ) |  | `[static]`

Definition at line 1239 of file complex.c.

References Check_Type, get_dat1, RARRAY_PTR, rb_copy_generic_ivar(), and T_ARRAY.

Referenced by Init_Complex().

static VALUE nucomp_mul | ( | VALUE | self,
|  | VALUE | other
| ) |  | `[static]`

Definition at line 693 of file complex.c.

References CLASS_OF, f_add(), f_complex_new2(), f_sub(), get_dat1, get_dat2, k_complex_p(), k_numeric_p(), and rb_num_coerce_bin().

Referenced by Init_Complex().

static VALUE nucomp_negate | ( | VALUE | self | ) | `[static]`

Definition at line 632 of file complex.c.

References CLASS_OF, f_complex_new2(), and get_dat1.

Referenced by Init_Complex().

static VALUE nucomp_numerator | ( | VALUE | self | ) | `[static]`

Definition at line 1112 of file complex.c.

References CLASS_OF, f_complex_new2(), f_denominator, f_div(), f_numerator, and get_dat1.

Referenced by Init_Complex().

static VALUE nucomp_polar | ( | VALUE | self | ) | `[static]`

Definition at line 1017 of file complex.c.

References rb_assoc_new().

Referenced by Init_Complex().

static VALUE nucomp_rationalize | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  | `[static]`

Definition at line 1345 of file complex.c.

References nucomp_to_r(), NULL, and rb_scan_args().

Referenced by Init_Complex().

static VALUE nucomp_real | ( | VALUE | self | ) | `[static]`

Definition at line 605 of file complex.c.

References get_dat1.

Referenced by Init_Complex().

static void nucomp_real_check | ( | VALUE | num | ) | `[inline, static]`

Definition at line 370 of file complex.c.

References k_numeric_p(), rb_eTypeError, rb_raise(), T_BIGNUM, T_FIXNUM, T_FLOAT, T_RATIONAL, and TYPE.

Referenced by nucomp_s_new(), and nucomp_s_polar().

static VALUE nucomp_rect | ( | VALUE | self | ) | `[static]`

Definition at line 1004 of file complex.c.

References get_dat1, and rb_assoc_new().

Referenced by Init_Complex().

static VALUE nucomp_s_alloc | ( | VALUE | klass | ) | `[static]`

Definition at line 311 of file complex.c.

References nucomp_s_new_internal(), and ZERO.

Referenced by Init_Complex().

static VALUE nucomp_s_canonicalize_internal | ( | VALUE | klass,
|  | VALUE | real,
|  | VALUE | imag
| ) |  | `[inline, static]`

Definition at line 385 of file complex.c.

References f_add(), f_sub(), f_zero_p(), get_dat1, get_dat2, k_exact_zero_p, nucomp_s_new_internal(), and ZERO.

Referenced by f_complex_new1(), f_complex_new2(), f_complex_polar(), nucomp_s_new(), and rb_complex_new().

static VALUE nucomp_s_convert | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | klass
| ) |  | `[static]`

Definition at line 1586 of file complex.c.

References f_add(), f_complex_new_bang2(), get_dat1, k_exact_zero_p, k_numeric_p(), NIL_P, nucomp_s_new(), ONE, rb_backref_get(), rb_backref_set(), rb_cComplex, rb_convert_type(), rb_eTypeError, rb_match_busy(), rb_raise(), rb_scan_args(), string_to_c_strict(), T_BIGNUM, T_COMPLEX, T_FIXNUM, T_FLOAT, T_STRING, TYPE, and ZERO.

Referenced by Init_Complex(), and rb_Complex().

static VALUE nucomp_s_new | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | klass
| ) |  | `[static]`

Definition at line 430 of file complex.c.

References nucomp_real_check(), nucomp_s_canonicalize_internal(), rb_scan_args(), and ZERO.

Referenced by Init_Complex(), and nucomp_s_convert().

static VALUE nucomp_s_new_internal | ( | VALUE | klass,
|  | VALUE | real,
|  | VALUE | imag
| ) |  | `[inline, static]`

Definition at line 299 of file complex.c.

References NEWOBJ, OBJSETUP, and T_COMPLEX.

Referenced by f_complex_new_bang1(), f_complex_new_bang2(), nucomp_s_alloc(), nucomp_s_canonicalize_internal(), and rb_complex_raw().

static VALUE nucomp_s_polar | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | klass
| ) |  | `[static]`

Definition at line 581 of file complex.c.

References f_complex_polar(), nucomp_real_check(), rb_scan_args(), and ZERO.

Referenced by Init_Complex().

static VALUE nucomp_sub | ( | VALUE | self,
|  | VALUE | other
| ) |  | `[static]`

Definition at line 681 of file complex.c.

References f_addsub(), and f_sub().

Referenced by Init_Complex().

static VALUE nucomp_to_f | ( | VALUE | self | ) | `[static]`

Definition at line 1306 of file complex.c.

References f_nonzero_p, get_dat1, k_inexact_p, rb_eRangeError, rb_raise(), and StringValuePtr.

Referenced by Init_Complex().

static VALUE nucomp_to_i | ( | VALUE | self | ) | `[static]`

Definition at line 1287 of file complex.c.

References f_nonzero_p, get_dat1, k_inexact_p, rb_eRangeError, rb_raise(), and StringValuePtr.

Referenced by Init_Complex().

static VALUE nucomp_to_r | ( | VALUE | self | ) | `[static]`

Definition at line 1325 of file complex.c.

References f_nonzero_p, f_to_r, get_dat1, k_inexact_p, rb_eRangeError, rb_raise(), and StringValuePtr.

Referenced by Init_Complex(), and nucomp_rationalize().

static VALUE nucomp_to_s | ( | VALUE | self | ) | `[static]`

Definition at line 1202 of file complex.c.

References f_format().

Referenced by Init_Complex().

static VALUE numeric_abs2 | ( | VALUE | self | ) | `[static]`

Definition at line 1703 of file complex.c.

Referenced by Init_Complex().

static VALUE numeric_arg | ( | VALUE | self | ) | `[static]`

Definition at line 1719 of file complex.c.

References f_positive_p, id_PI, INT2FIX, rb_const_get(), and rb_mMath.

Referenced by Init_Complex().

static VALUE numeric_conj | ( | VALUE | self | ) | `[static]`

Definition at line 1758 of file complex.c.

Referenced by Init_Complex().

static VALUE numeric_imag | ( | VALUE | self | ) | `[static]`

Definition at line 1691 of file complex.c.

References INT2FIX.

Referenced by Init_Complex().

static VALUE numeric_polar | ( | VALUE | self | ) | `[static]`

Definition at line 1745 of file complex.c.

References rb_assoc_new().

Referenced by Init_Complex().

static VALUE numeric_real | ( | VALUE | self | ) | `[static]`

Definition at line 1678 of file complex.c.

Referenced by Init_Complex().

static VALUE numeric_rect | ( | VALUE | self | ) | `[static]`

Definition at line 1733 of file complex.c.

References INT2FIX, and rb_assoc_new().

Referenced by Init_Complex().

static VALUE numeric_to_c | ( | VALUE | self | ) | `[static]`

Definition at line 1370 of file complex.c.

References rb_complex_new1.

Referenced by Init_Complex().

VALUE rb_Complex | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 1272 of file complex.c.

References nucomp_s_convert(), and rb_cComplex.

VALUE rb_complex_new | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 1258 of file complex.c.

References nucomp_s_canonicalize_internal(), and rb_cComplex.

Referenced by num_imaginary().

VALUE rb_complex_polar | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 1264 of file complex.c.

References f_complex_polar(), and rb_cComplex.

Referenced by string_to_c_internal().

VALUE rb_complex_raw | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 1252 of file complex.c.

References nucomp_s_new_internal(), and rb_cComplex.

VALUE rb_lcm | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 1634 of file rational.c.

References f_lcm(), and nurat_int_value().

Referenced by Init_Rational(), and nucomp_denominator().

static VALUE string_to_c | ( | VALUE | self | ) | `[static]`

Definition at line 1568 of file complex.c.

References f_gsub, INT2FIX, NIL_P, RARRAY_PTR, rb_backref_get(), rb_backref_set(), rb_complex_new1, rb_match_busy(), and string_to_c_internal().

Referenced by Init_Complex().

static VALUE string_to_c_internal | ( | VALUE | self | ) | `[static]`

Definition at line 1446 of file complex.c.

References f_aref, f_count, f_gt_p(), f_include_p, f_match, f_post_match, f_to_r, INT2FIX, NIL_P, Qnil, rb_assoc_new(), rb_complex_new2, rb_complex_polar(), rb_str_concat(), rb_usascii_str_new2(), and RSTRING_LEN.

Referenced by string_to_c(), and string_to_c_strict().

static VALUE string_to_c_strict | ( | VALUE | self | ) | `[static]`

Definition at line 1530 of file complex.c.

References NIL_P, RARRAY_PTR, rb_eArgError, rb_raise(), RSTRING_LEN, string_to_c_internal(), and StringValuePtr.

Referenced by nucomp_s_convert().

## Variable Documentation

VALUE a_dot_and_an_e

Definition at line 1375 of file complex.c.

VALUE a_slash

Definition at line 1375 of file complex.c.

VALUE an_underscore

Definition at line 1375 of file complex.c.

VALUE comp_pat0`[static]`

Definition at line 1375 of file complex.c.

VALUE comp_pat1

Definition at line 1375 of file complex.c.

VALUE comp_pat2

Definition at line 1375 of file complex.c.

ID id_abs`[static]`

Definition at line 20 of file complex.c.

Referenced by Init_Complex().

ID id_abs2

Definition at line 20 of file complex.c.

Referenced by Init_Complex().

ID id_arg

Definition at line 20 of file complex.c.

Referenced by Init_Complex().

ID id_cmp

Definition at line 20 of file complex.c.

ID id_conj

Definition at line 20 of file complex.c.

Referenced by Init_Complex().

ID id_convert

Definition at line 20 of file complex.c.

Referenced by Init_Complex(), Init_Rational(), nucomp_f_complex(), and nurat_f_rational().

ID id_denominator

Definition at line 20 of file complex.c.

Referenced by Init_Complex().

ID id_divmod

Definition at line 20 of file complex.c.

Referenced by divmodv(), Init_Complex(), Init_Time(), time_timespec(), and wdivmod().

ID id_eqeq_p

Definition at line 20 of file complex.c.

Referenced by f_one_p(), f_zero_p(), fun1(), Init_Complex(), and Init_Rational().

ID id_expt

Definition at line 20 of file complex.c.

Referenced by Init_Complex(), Init_Rational(), nucomp_expt(), and nurat_expt().

ID id_fdiv

Definition at line 20 of file complex.c.

Referenced by Init_Complex(), Init_Rational(), and nucomp_fdiv().

ID id_floor

Definition at line 20 of file complex.c.

Referenced by Init_Complex(), and Init_Rational().

ID id_idiv

Definition at line 20 of file complex.c.

Referenced by Init_Complex(), and Init_Rational().

ID id_imag

Definition at line 20 of file complex.c.

Referenced by Init_Complex().

ID id_inspect

Definition at line 20 of file complex.c.

Referenced by Init_Complex(), Init_Object(), Init_Rational(), and rb_inspect().

ID id_negate

Definition at line 20 of file complex.c.

Referenced by Init_Complex(), and Init_Rational().

ID id_numerator

Definition at line 20 of file complex.c.

Referenced by Init_Complex().

ID id_quo

Definition at line 20 of file complex.c.

ID id_real

Definition at line 20 of file complex.c.

Referenced by Init_Complex().

ID id_real_p

Definition at line 20 of file complex.c.

Referenced by Init_Complex().

ID id_to_f

Definition at line 20 of file complex.c.

Referenced by Init_Complex(), and Init_Rational().

ID id_to_i

Definition at line 20 of file complex.c.

Referenced by Init_Complex(), Init_Numeric(), Init_Rational(), and num_to_int().

ID id_to_r

Definition at line 20 of file complex.c.

Referenced by Init_Complex().

ID id_to_s

Definition at line 20 of file complex.c.

Referenced by Init_Complex(), and Init_Rational().

VALUE null_string

Definition at line 1375 of file complex.c.

VALUE rb_cComplex

Definition at line 18 of file complex.c.

Referenced by imp1(), Init_Complex(), k_complex_p(), m_sin(), nucomp_f_complex(), nucomp_s_convert(), rb_Complex(), rb_complex_new(), rb_complex_polar(), and rb_complex_raw().

VALUE underscores_pat

Definition at line 1375 of file complex.c.