Ruby  2.4.2p198(2017-09-14revision59899)
Macros | Functions | Variables
complex.c File Reference
#include "ruby/config.h"
#include <math.h>
#include "internal.h"
#include "ruby_assert.h"
#include <ctype.h>
Include dependency graph for complex.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define ZERO   INT2FIX(0)
 
#define ONE   INT2FIX(1)
 
#define TWO   INT2FIX(2)
 
#define RFLOAT_0   DBL2NUM(0)
 
#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)   (!RB_FLOAT_TYPE_P(x))
 
#define k_exact_zero_p(x)   (k_exact_p(x) && f_zero_p(x))
 
#define get_dat1(x)   struct RComplex *dat = RCOMPLEX(x)
 
#define get_dat2(x, y)   struct RComplex *adat = RCOMPLEX(x), *bdat = RCOMPLEX(y)
 
#define canonicalization   0
 
#define imp1(n)
 
#define nucomp_mul   rb_complex_mul
 
#define rb_raise_zerodiv()   rb_raise(rb_eZeroDivError, "divided by 0")
 
#define nucomp_quo   nucomp_div
 
#define FINITE_TYPE_P(v)   (RB_INTEGER_TYPE_P(v) || RB_TYPE_P(v, T_RATIONAL))
 
#define rb_intern(str)   rb_intern_const(str)
 

Functions

static VALUE nucomp_abs (VALUE self)
 
static VALUE nucomp_arg (VALUE self)
 
static VALUE f_add (VALUE x, VALUE y)
 
static VALUE f_div (VALUE x, VALUE y)
 
static int f_gt_p (VALUE x, VALUE y)
 
static VALUE f_mul (VALUE x, VALUE y)
 
static VALUE f_sub (VALUE x, VALUE y)
 
 fun1 (abs)
 
 fun1 (numerator)
 
static VALUE f_to_f (VALUE x)
 
 fun1 (to_r)
 
 fun2 (expt)
 
static int f_zero_p (VALUE x)
 
static int f_kind_of_p (VALUE x, VALUE c)
 
static int k_numeric_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_new2 (VALUE klass, VALUE x, VALUE y)
 
static VALUE nucomp_s_convert (int argc, VALUE *argv, VALUE klass)
 
static VALUE nucomp_f_complex (int argc, VALUE *argv, VALUE klass)
 
 imp1 (cos)
 
 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)
 
VALUE rb_complex_plus (VALUE self, VALUE other)
 
static VALUE nucomp_sub (VALUE self, VALUE other)
 
static VALUE safe_mul (VALUE a, VALUE b, int az, int bz)
 
VALUE rb_complex_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_abs2 (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)
 
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 int f_signbit (VALUE x)
 
static int 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 rb_complex_finite_p (VALUE self)
 
static VALUE rb_complex_infinite_p (VALUE self)
 
static VALUE nucomp_dumper (VALUE self)
 
static VALUE nucomp_loader (VALUE self, VALUE a)
 
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)
 
VALUE rb_Complex (VALUE x, VALUE y)
 
VALUE rb_complex_set_real (VALUE cmp, VALUE r)
 
VALUE rb_complex_set_imag (VALUE cmp, VALUE i)
 
VALUE rb_complex_abs (VALUE cmp)
 
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 nucomp_to_c (VALUE self)
 
static VALUE nilclass_to_c (VALUE self)
 
static VALUE numeric_to_c (VALUE self)
 
static int issign (int c)
 
static int read_sign (const char **s, char **b)
 
static int isdecimal (int c)
 
static int read_digits (const char **s, int strict, char **b)
 
static int islettere (int c)
 
static int read_num (const char **s, int strict, char **b)
 
static int read_den (const char **s, int strict, char **b)
 
static int read_rat_nos (const char **s, int strict, char **b)
 
static int read_rat (const char **s, int strict, char **b)
 
static int isimagunit (int c)
 
static VALUE str2num (char *s)
 
static int read_comp (const char **s, int strict, VALUE *ret, char **b)
 
static void skip_ws (const char **s)
 
static int parse_comp (const char *s, int strict, VALUE *num)
 
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 float_arg (VALUE self)
 
static VALUE numeric_polar (VALUE self)
 
static VALUE numeric_conj (VALUE self)
 
void Init_Complex (void)
 

Variables

VALUE rb_cComplex
 
static ID id_abs
 
static ID id_arg
 
static ID id_denominator
 
static ID id_expt
 
static ID id_fdiv
 
static ID id_negate
 
static ID id_numerator
 
static ID id_quo
 
static ID id_real_p
 
static ID id_to_f
 
static ID id_to_i
 
static ID id_to_r
 
static ID id_i_real
 
static ID id_i_imag
 
static ID id_finite_p
 
static ID id_infinite_p
 
static ID id_rationalize
 
static ID id_PI
 

Macro Definition Documentation

◆ binop

#define binop (   n,
  op 
)
Value:
inline static VALUE \
f_##n(VALUE x, VALUE y)\
{\
return rb_funcall(x, (op), 1, y);\
}
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
Definition: vm_eval.c:821
unsigned long VALUE
Definition: ruby.h:85

Definition at line 43 of file complex.c.

◆ canonicalization

#define canonicalization   0

Definition at line 331 of file complex.c.

Referenced by f_complex_new_bang2(), and f_rational_new_bang1().

◆ f_boolcast

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

Definition at line 41 of file complex.c.

Referenced by nucomp_eqeq_p(), nucomp_eql_p(), and nucomp_false().

◆ f_nonzero_p

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

Definition at line 238 of file complex.c.

◆ f_positive_p

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

Definition at line 223 of file complex.c.

Referenced by m_sin(), and numeric_arg().

◆ FINITE_TYPE_P

#define FINITE_TYPE_P (   v)    (RB_INTEGER_TYPE_P(v) || RB_TYPE_P(v, T_RATIONAL))

Definition at line 1317 of file complex.c.

Referenced by rb_complex_finite_p(), and rb_complex_infinite_p().

◆ fun1

#define fun1 (   n)
Value:
inline static VALUE \
f_##n(VALUE x)\
{\
return rb_funcall(x, id_##n, 0);\
}
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
Definition: vm_eval.c:821
unsigned long VALUE
Definition: ruby.h:85

Definition at line 50 of file complex.c.

◆ fun2

#define fun2 (   n)
Value:
inline static VALUE \
f_##n(VALUE x, VALUE y)\
{\
return rb_funcall(x, id_##n, 1, y);\
}
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
Definition: vm_eval.c:821
unsigned long VALUE
Definition: ruby.h:85

Definition at line 57 of file complex.c.

◆ get_dat1

#define get_dat1 (   x)    struct RComplex *dat = RCOMPLEX(x)

◆ get_dat2

#define get_dat2 (   x,
 
)    struct RComplex *adat = RCOMPLEX(x), *bdat = RCOMPLEX(y)

◆ imp1

#define imp1 (   n)
Value:
inline static VALUE \
m_##n##_bang(VALUE x)\
{\
return rb_math_##n(x);\
}
unsigned long VALUE
Definition: ruby.h:85

Definition at line 459 of file complex.c.

Referenced by m_sin().

◆ k_exact_p

#define k_exact_p (   x)    (!RB_FLOAT_TYPE_P(x))

Definition at line 252 of file complex.c.

Referenced by nucomp_false().

◆ k_exact_zero_p

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

◆ math1

#define math1 (   n)
Value:
inline static VALUE \
m_##n(VALUE x)\
{\
return rb_funcall(rb_mMath, id_##n, 1, x);\
}
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
Definition: vm_eval.c:821
RUBY_EXTERN VALUE rb_mMath
Definition: ruby.h:1866
unsigned long VALUE
Definition: ruby.h:85

Definition at line 64 of file complex.c.

◆ math2

#define math2 (   n)
Value:
inline static VALUE \
m_##n(VALUE x, VALUE y)\
{\
return rb_funcall(rb_mMath, id_##n, 2, x, y);\
}
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
Definition: vm_eval.c:821
RUBY_EXTERN VALUE rb_mMath
Definition: ruby.h:1866
unsigned long VALUE
Definition: ruby.h:85

Definition at line 71 of file complex.c.

◆ NDEBUG

#define NDEBUG

Definition at line 16 of file complex.c.

◆ nucomp_mul

#define nucomp_mul   rb_complex_mul

Definition at line 783 of file complex.c.

Referenced by Init_Complex().

◆ nucomp_quo

#define nucomp_quo   nucomp_div

Definition at line 858 of file complex.c.

Referenced by Init_Complex().

◆ ONE

#define ONE   INT2FIX(1)

Definition at line 20 of file complex.c.

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

◆ PRESERVE_SIGNEDZERO

#define PRESERVE_SIGNEDZERO

Definition at line 78 of file complex.c.

◆ rb_intern

#define rb_intern (   str)    rb_intern_const(str)

Referenced by Init_Complex().

◆ rb_raise_zerodiv

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

Definition at line 837 of file complex.c.

◆ RFLOAT_0

#define RFLOAT_0   DBL2NUM(0)

Definition at line 22 of file complex.c.

Referenced by f_complex_polar().

◆ TWO

#define TWO   INT2FIX(2)

Definition at line 21 of file complex.c.

Referenced by m_sin(), and nucomp_expt().

◆ ZERO

#define ZERO   INT2FIX(0)

Function Documentation

◆ f_add()

static VALUE f_add ( VALUE  x,
VALUE  y 
)
inlinestatic

◆ f_complex_new2()

static VALUE f_complex_new2 ( VALUE  klass,
VALUE  x,
VALUE  y 
)
inlinestatic

◆ f_complex_new_bang1()

static VALUE f_complex_new_bang1 ( VALUE  klass,
VALUE  x 
)
inlinestatic

Definition at line 304 of file complex.c.

References assert, nucomp_s_new_internal(), RB_TYPE_P, T_COMPLEX, and ZERO.

Referenced by nucomp_coerce(), and nucomp_expt().

◆ f_complex_new_bang2()

static VALUE f_complex_new_bang2 ( VALUE  klass,
VALUE  x,
VALUE  y 
)
inlinestatic

◆ f_complex_polar()

static VALUE f_complex_polar ( VALUE  klass,
VALUE  x,
VALUE  y 
)
static

◆ f_div()

static VALUE f_div ( VALUE  x,
VALUE  y 
)
inlinestatic

Definition at line 93 of file complex.c.

References FIX2LONG, FIXNUM_P, and rb_funcall().

Referenced by m_sin(), and nucomp_numerator().

◆ f_divide()

static VALUE f_divide ( VALUE  self,
VALUE  other,
VALUE(*)(VALUE, VALUE func,
ID  id 
)
inlinestatic

◆ f_format()

static VALUE f_format ( VALUE  self,
VALUE(*)(VALUE func 
)
static

◆ f_gt_p()

static int f_gt_p ( VALUE  x,
VALUE  y 
)
inlinestatic

◆ f_kind_of_p()

static int f_kind_of_p ( VALUE  x,
VALUE  c 
)
inlinestatic

Definition at line 241 of file complex.c.

References rb_obj_is_kind_of().

Referenced by k_numeric_p().

◆ f_mul()

static VALUE f_mul ( VALUE  x,
VALUE  y 
)
inlinestatic

◆ f_reciprocal()

static VALUE f_reciprocal ( VALUE  x)
inlinestatic

Definition at line 875 of file complex.c.

References f_quo, and ONE.

Referenced by nucomp_expt().

◆ f_signbit()

static int f_signbit ( VALUE  x)
inlinestatic

Definition at line 1239 of file complex.c.

References f_negative_p(), isnan, RB_FLOAT_TYPE_P, RFLOAT_VALUE, and signbit().

Referenced by f_tpositive_p().

◆ f_sub()

static VALUE f_sub ( VALUE  x,
VALUE  y 
)
inlinestatic

◆ f_to_f()

static VALUE f_to_f ( VALUE  x)
inlinestatic

Definition at line 188 of file complex.c.

References DBL2NUM, id_to_f, rb_funcall(), rb_str_to_dbl(), RB_TYPE_P, and T_STRING.

Referenced by nucomp_abs(), and nucomp_to_f().

◆ f_tpositive_p()

static int f_tpositive_p ( VALUE  x)
inlinestatic

Definition at line 1249 of file complex.c.

References f_signbit().

Referenced by f_format(), and float_arg().

◆ f_zero_p()

static int f_zero_p ( VALUE  x)
inlinestatic

◆ float_arg()

static VALUE float_arg ( VALUE  self)
static

Definition at line 2141 of file complex.c.

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

Referenced by numeric_polar(), and numeric_rect().

◆ fun1() [1/3]

fun1 ( abs  )

Definition at line 153 of file complex.c.

◆ fun1() [2/3]

fun1 ( numerator  )

Definition at line 177 of file complex.c.

References id_to_i, rb_funcall(), rb_str_to_inum(), RB_TYPE_P, and T_STRING.

◆ fun1() [3/3]

fun1 ( to_r  )

Definition at line 195 of file complex.c.

References FIXNUM_P, NUM2DBL, rb_equal(), and RB_FLOAT_TYPE_P.

◆ fun2()

fun2 ( expt  )

◆ imp1() [1/2]

imp1 ( cos  )

Definition at line 466 of file complex.c.

References rb_math_log().

◆ imp1() [2/2]

imp1 ( sin  )

Definition at line 476 of file complex.c.

References f_complex_new2(), f_mul(), f_negate, get_dat1, and rb_cComplex.

◆ Init_Complex()

void Init_Complex ( void  )

Definition at line 2184 of file complex.c.

References assert, CLASS_OF, f_complex_new_bang2(), id_abs, id_arg, id_denominator, id_expt, id_fdiv, id_finite_p, id_i_imag, id_i_real, id_infinite_p, id_negate, id_numerator, id_PI, id_quo, id_rationalize, id_real_p, id_to_f, id_to_i, id_to_r, nilclass_to_c(), nucomp_abs(), nucomp_abs2(), nucomp_arg(), nucomp_coerce(), nucomp_conj(), nucomp_denominator(), nucomp_div(), nucomp_dumper(), nucomp_eqeq_p(), nucomp_eql_p(), nucomp_expt(), nucomp_f_complex(), nucomp_false(), nucomp_fdiv(), nucomp_hash(), nucomp_imag(), nucomp_inspect(), nucomp_loader(), 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_new(), nucomp_s_polar(), nucomp_sub(), nucomp_to_c(), 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_cObject, rb_complex_finite_p(), rb_complex_infinite_p(), rb_complex_plus(), rb_cString, rb_define_alloc_func(), rb_define_class(), rb_define_class_under(), rb_define_const(), rb_define_global_function(), rb_define_method(), rb_define_private_method(), rb_define_singleton_method(), rb_intern, rb_marshal_define_compat(), rb_mComparable, rb_provide(), rb_undef_method(), rb_undef_methods_from(), string_to_c(), and ZERO.

◆ isdecimal()

static int isdecimal ( int  c)
inlinestatic

Definition at line 1629 of file complex.c.

Referenced by read_comp(), and read_digits().

◆ isimagunit()

static int isimagunit ( int  c)
inlinestatic

Definition at line 1741 of file complex.c.

Referenced by read_comp().

◆ islettere()

static int islettere ( int  c)
inlinestatic

Definition at line 1666 of file complex.c.

Referenced by read_num().

◆ issign()

static int issign ( int  c)
inlinestatic

Definition at line 1609 of file complex.c.

Referenced by read_comp(), and read_sign().

◆ k_numeric_p()

static int k_numeric_p ( VALUE  x)
inlinestatic

◆ m_sin()

static VALUE m_sin ( VALUE  x)
static

◆ nilclass_to_c()

static VALUE nilclass_to_c ( VALUE  self)
static

Definition at line 1589 of file complex.c.

References INT2FIX, and rb_complex_new1.

Referenced by Init_Complex().

◆ nucomp_abs()

static VALUE nucomp_abs ( VALUE  self)
static

◆ nucomp_abs2()

static VALUE nucomp_abs2 ( VALUE  self)
static

Definition at line 1051 of file complex.c.

References f_add(), f_mul(), and get_dat1.

Referenced by Init_Complex().

◆ nucomp_arg()

static VALUE nucomp_arg ( VALUE  self)
static

Definition at line 1069 of file complex.c.

References get_dat1, and rb_math_atan2().

Referenced by Init_Complex().

◆ nucomp_coerce()

static VALUE nucomp_coerce ( VALUE  self,
VALUE  other 
)
static

◆ nucomp_conj()

static VALUE nucomp_conj ( VALUE  self)
static

Definition at line 1115 of file complex.c.

References CLASS_OF, f_complex_new2(), f_negate, get_dat1, and Qtrue.

Referenced by Init_Complex().

◆ nucomp_denominator()

static VALUE nucomp_denominator ( VALUE  self)
static

Definition at line 1168 of file complex.c.

References f_denominator, get_dat1, and rb_lcm().

Referenced by Init_Complex().

◆ nucomp_div()

static VALUE nucomp_div ( VALUE  self,
VALUE  other 
)
static

Definition at line 853 of file complex.c.

References f_divide(), f_quo, and id_quo.

Referenced by Init_Complex().

◆ nucomp_dumper()

static VALUE nucomp_dumper ( VALUE  self)
static

Definition at line 1379 of file complex.c.

Referenced by Init_Complex().

◆ nucomp_eqeq_p()

static VALUE nucomp_eqeq_p ( VALUE  self,
VALUE  other 
)
static

Definition at line 981 of file complex.c.

References f_boolcast, f_eqeq_p(), f_zero_p(), get_dat1, get_dat2, k_numeric_p(), RB_TYPE_P, and T_COMPLEX.

Referenced by Init_Complex().

◆ nucomp_eql_p()

static VALUE nucomp_eql_p ( VALUE  self,
VALUE  other 
)
static

Definition at line 1225 of file complex.c.

References CLASS_OF, f_boolcast, f_eqeq_p(), get_dat2, Qfalse, RB_TYPE_P, and T_COMPLEX.

Referenced by Init_Complex().

◆ nucomp_expt()

static VALUE nucomp_expt ( VALUE  self,
VALUE  other 
)
static

◆ nucomp_f_complex()

static VALUE nucomp_f_complex ( int  argc,
VALUE argv,
VALUE  klass 
)
static

Definition at line 454 of file complex.c.

References nucomp_s_convert(), and rb_cComplex.

Referenced by Init_Complex().

◆ nucomp_false()

static VALUE nucomp_false ( VALUE  self)
static

Definition at line 1137 of file complex.c.

References f_boolcast, get_dat1, k_exact_p, and Qfalse.

Referenced by Init_Complex().

◆ nucomp_fdiv()

static VALUE nucomp_fdiv ( VALUE  self,
VALUE  other 
)
static

Definition at line 869 of file complex.c.

References f_divide(), and id_fdiv.

Referenced by Init_Complex().

◆ nucomp_hash()

static VALUE nucomp_hash ( VALUE  self)
static

Definition at line 1209 of file complex.c.

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

Referenced by Init_Complex().

◆ nucomp_imag()

static VALUE nucomp_imag ( VALUE  self)
static

Definition at line 638 of file complex.c.

References get_dat1.

Referenced by Init_Complex().

◆ nucomp_inspect()

static VALUE nucomp_inspect ( VALUE  self)
static

Definition at line 1306 of file complex.c.

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

Referenced by Init_Complex().

◆ nucomp_loader()

static VALUE nucomp_loader ( VALUE  self,
VALUE  a 
)
static

Definition at line 1386 of file complex.c.

References get_dat1, id_i_imag, id_i_real, rb_ivar_get(), RCOMPLEX_SET_IMAG, and RCOMPLEX_SET_REAL.

Referenced by Init_Complex().

◆ nucomp_marshal_dump()

static VALUE nucomp_marshal_dump ( VALUE  self)
static

Definition at line 1398 of file complex.c.

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

Referenced by Init_Complex().

◆ nucomp_marshal_load()

static VALUE nucomp_marshal_load ( VALUE  self,
VALUE  a 
)
static

Definition at line 1410 of file complex.c.

References Check_Type, id_i_imag, id_i_real, RARRAY_AREF, RARRAY_LEN, rb_eArgError, rb_ivar_set(), rb_raise(), and T_ARRAY.

Referenced by Init_Complex().

◆ nucomp_negate()

static VALUE nucomp_negate ( VALUE  self)
static

Definition at line 653 of file complex.c.

References CLASS_OF, f_complex_new2(), f_negate, and get_dat1.

Referenced by Init_Complex().

◆ nucomp_numerator()

static VALUE nucomp_numerator ( VALUE  self)
static

Definition at line 1193 of file complex.c.

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

Referenced by Init_Complex().

◆ nucomp_polar()

static VALUE nucomp_polar ( VALUE  self)
static

Definition at line 1100 of file complex.c.

References f_abs, and rb_assoc_new().

Referenced by Init_Complex().

◆ nucomp_rationalize()

static VALUE nucomp_rationalize ( int  argc,
VALUE argv,
VALUE  self 
)
static

◆ nucomp_real()

static VALUE nucomp_real ( VALUE  self)
static

Definition at line 621 of file complex.c.

References get_dat1.

Referenced by Init_Complex().

◆ nucomp_real_check()

static void nucomp_real_check ( VALUE  num)
inlinestatic

◆ nucomp_rect()

static VALUE nucomp_rect ( VALUE  self)
static

Definition at line 1085 of file complex.c.

References get_dat1, and rb_assoc_new().

Referenced by Init_Complex().

◆ nucomp_s_alloc()

static VALUE nucomp_s_alloc ( VALUE  klass)
static

Definition at line 274 of file complex.c.

References argc, argv, f_to_i, k_numeric_p(), nucomp_s_new_internal(), rb_scan_args(), and ZERO.

Referenced by Init_Complex().

◆ nucomp_s_canonicalize_internal()

static VALUE nucomp_s_canonicalize_internal ( VALUE  klass,
VALUE  real,
VALUE  imag 
)
inlinestatic

◆ nucomp_s_convert()

static VALUE nucomp_s_convert ( int  argc,
VALUE argv,
VALUE  klass 
)
static

◆ nucomp_s_new()

static VALUE nucomp_s_new ( int  argc,
VALUE argv,
VALUE  klass 
)
static

Definition at line 393 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().

◆ nucomp_s_new_internal()

static VALUE nucomp_s_new_internal ( VALUE  klass,
VALUE  real,
VALUE  imag 
)
inlinestatic

◆ nucomp_s_polar()

static VALUE nucomp_s_polar ( int  argc,
VALUE argv,
VALUE  klass 
)
static

Definition at line 594 of file complex.c.

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

Referenced by Init_Complex().

◆ nucomp_sub()

static VALUE nucomp_sub ( VALUE  self,
VALUE  other 
)
static

◆ nucomp_to_c()

static VALUE nucomp_to_c ( VALUE  self)
static

Definition at line 1577 of file complex.c.

Referenced by Init_Complex().

◆ nucomp_to_f()

static VALUE nucomp_to_f ( VALUE  self)
static

Definition at line 1504 of file complex.c.

References f_to_f(), get_dat1, k_exact_zero_p, PRIsVALUE, rb_eRangeError, and rb_raise().

Referenced by Init_Complex().

◆ nucomp_to_i()

static VALUE nucomp_to_i ( VALUE  self)
static

Definition at line 1481 of file complex.c.

References f_to_i, get_dat1, k_exact_zero_p, PRIsVALUE, rb_eRangeError, and rb_raise().

Referenced by Init_Complex().

◆ nucomp_to_r()

static VALUE nucomp_to_r ( VALUE  self)
static

Definition at line 1529 of file complex.c.

References f_to_r, get_dat1, k_exact_zero_p, PRIsVALUE, rb_eRangeError, and rb_raise().

Referenced by Init_Complex().

◆ nucomp_to_s()

static VALUE nucomp_to_s ( VALUE  self)
static

Definition at line 1288 of file complex.c.

References f_format(), and rb_String().

Referenced by Init_Complex().

◆ numeric_abs2()

static VALUE numeric_abs2 ( VALUE  self)
static

Definition at line 2053 of file complex.c.

References f_mul().

Referenced by Init_Complex().

◆ numeric_arg()

static VALUE numeric_arg ( VALUE  self)
static

Definition at line 2067 of file complex.c.

References DBL2NUM, f_positive_p, INT2FIX, and M_PI.

Referenced by Init_Complex(), and numeric_polar().

◆ numeric_conj()

static VALUE numeric_conj ( VALUE  self)
static

Definition at line 2127 of file complex.c.

Referenced by Init_Complex().

◆ numeric_imag()

static VALUE numeric_imag ( VALUE  self)
static

Definition at line 2041 of file complex.c.

References INT2FIX.

Referenced by Init_Complex().

◆ numeric_polar()

static VALUE numeric_polar ( VALUE  self)
static

◆ numeric_real()

static VALUE numeric_real ( VALUE  self)
static

Definition at line 2028 of file complex.c.

Referenced by Init_Complex().

◆ numeric_rect()

static VALUE numeric_rect ( VALUE  self)
static

Definition at line 2082 of file complex.c.

References float_arg(), INT2FIX, and rb_assoc_new().

Referenced by Init_Complex().

◆ numeric_to_c()

static VALUE numeric_to_c ( VALUE  self)
static

Definition at line 1601 of file complex.c.

References rb_complex_new1.

Referenced by Init_Complex().

◆ parse_comp()

static int parse_comp ( const char *  s,
int  strict,
VALUE num 
)
static

Definition at line 1847 of file complex.c.

References ALLOCV_END, ALLOCV_N, buf, read_comp(), skip_ws(), and strlen().

Referenced by string_to_c(), and string_to_c_strict().

◆ rb_Complex()

VALUE rb_Complex ( VALUE  x,
VALUE  y 
)

Definition at line 1441 of file complex.c.

References nucomp_s_convert(), and rb_cComplex.

Referenced by nurat_coerce().

◆ rb_complex_abs()

VALUE rb_complex_abs ( VALUE  cmp)

Definition at line 1464 of file complex.c.

References nucomp_abs().

Referenced by rb_math_sqrt().

◆ rb_complex_finite_p()

static VALUE rb_complex_finite_p ( VALUE  self)
static

Definition at line 1327 of file complex.c.

References FINITE_TYPE_P, id_finite_p, isinf(), nucomp_abs(), Qfalse, Qtrue, RB_FLOAT_TYPE_P, rb_funcall(), and RFLOAT_VALUE.

Referenced by Init_Complex().

◆ rb_complex_infinite_p()

static VALUE rb_complex_infinite_p ( VALUE  self)
static

◆ rb_complex_mul()

VALUE rb_complex_mul ( VALUE  self,
VALUE  other 
)

◆ rb_complex_new()

VALUE rb_complex_new ( VALUE  x,
VALUE  y 
)

◆ rb_complex_plus()

VALUE rb_complex_plus ( VALUE  self,
VALUE  other 
)

◆ rb_complex_polar()

VALUE rb_complex_polar ( VALUE  x,
VALUE  y 
)

Definition at line 1435 of file complex.c.

References f_complex_polar(), and rb_cComplex.

Referenced by read_comp().

◆ rb_complex_raw()

VALUE rb_complex_raw ( VALUE  x,
VALUE  y 
)

Definition at line 1423 of file complex.c.

References nucomp_s_new_internal(), and rb_cComplex.

Referenced by parser_set_number_literal().

◆ rb_complex_set_imag()

VALUE rb_complex_set_imag ( VALUE  cmp,
VALUE  i 
)

Definition at line 1457 of file complex.c.

References cmp(), and RCOMPLEX_SET_IMAG.

◆ rb_complex_set_real()

VALUE rb_complex_set_real ( VALUE  cmp,
VALUE  r 
)

Definition at line 1450 of file complex.c.

References cmp(), and RCOMPLEX_SET_REAL.

◆ read_comp()

static int read_comp ( const char **  s,
int  strict,
VALUE ret,
char **  b 
)
static

◆ read_den()

static int read_den ( const char **  s,
int  strict,
char **  b 
)
inlinestatic

Definition at line 1704 of file complex.c.

References read_digits().

Referenced by read_rat_nos().

◆ read_digits()

static int read_digits ( const char **  s,
int  strict,
char **  b 
)
static

Definition at line 1635 of file complex.c.

References isdecimal().

Referenced by read_den(), and read_num().

◆ read_num()

static int read_num ( const char **  s,
int  strict,
char **  b 
)
static

Definition at line 1672 of file complex.c.

References islettere(), read_digits(), and read_sign().

Referenced by read_rat_nos().

◆ read_rat()

static int read_rat ( const char **  s,
int  strict,
char **  b 
)
static

Definition at line 1731 of file complex.c.

References read_rat_nos(), and read_sign().

Referenced by read_comp().

◆ read_rat_nos()

static int read_rat_nos ( const char **  s,
int  strict,
char **  b 
)
static

Definition at line 1713 of file complex.c.

References read_den(), and read_num().

Referenced by read_comp(), and read_rat().

◆ read_sign()

static int read_sign ( const char **  s,
char **  b 
)
static

Definition at line 1615 of file complex.c.

References issign().

Referenced by read_comp(), read_num(), and read_rat().

◆ safe_mul()

static VALUE safe_mul ( VALUE  a,
VALUE  b,
int  az,
int  bz 
)
static

Definition at line 729 of file complex.c.

References DBL2NUM, f_mul(), isnan, RB_FLOAT_TYPE_P, RFLOAT_VALUE, and signbit().

Referenced by rb_complex_mul().

◆ skip_ws()

static void skip_ws ( const char **  s)
inlinestatic

Definition at line 1840 of file complex.c.

Referenced by parse_comp().

◆ str2num()

static VALUE str2num ( char *  s)
static

Definition at line 1748 of file complex.c.

References DBL2NUM, rb_cstr_to_dbl(), rb_cstr_to_inum(), rb_cstr_to_rat(), and strchr().

Referenced by read_comp().

◆ string_to_c()

static VALUE string_to_c ( VALUE  self)
static

Definition at line 1927 of file complex.c.

References parse_comp(), rb_must_asciicompat(), rb_str_modify(), RSTRING_LEN, and RSTRING_PTR.

Referenced by Init_Complex().

◆ string_to_c_strict()

static VALUE string_to_c_strict ( VALUE  self)
static

Variable Documentation

◆ id_abs

ID id_abs
static

Definition at line 33 of file complex.c.

Referenced by Init_Complex().

◆ id_arg

ID id_arg
static

Definition at line 33 of file complex.c.

Referenced by Init_Complex().

◆ id_denominator

ID id_denominator
static

Definition at line 33 of file complex.c.

Referenced by Init_Complex().

◆ id_expt

ID id_expt
static

Definition at line 33 of file complex.c.

Referenced by Init_Complex(), and nucomp_expt().

◆ id_fdiv

ID id_fdiv
static

Definition at line 33 of file complex.c.

Referenced by Init_Complex(), and nucomp_fdiv().

◆ id_finite_p

ID id_finite_p
static

Definition at line 33 of file complex.c.

Referenced by Init_Complex(), and rb_complex_finite_p().

◆ id_i_imag

ID id_i_imag
static

Definition at line 33 of file complex.c.

Referenced by Init_Complex(), nucomp_loader(), and nucomp_marshal_load().

◆ id_i_real

ID id_i_real
static

Definition at line 33 of file complex.c.

Referenced by Init_Complex(), nucomp_loader(), and nucomp_marshal_load().

◆ id_infinite_p

ID id_infinite_p
static

Definition at line 33 of file complex.c.

Referenced by Init_Complex(), and rb_complex_infinite_p().

◆ id_negate

ID id_negate
static

Definition at line 33 of file complex.c.

Referenced by Init_Complex().

◆ id_numerator

ID id_numerator
static

Definition at line 33 of file complex.c.

Referenced by Init_Complex().

◆ id_PI

ID id_PI
static

Definition at line 33 of file complex.c.

Referenced by float_arg(), and Init_Complex().

◆ id_quo

ID id_quo
static

Definition at line 33 of file complex.c.

Referenced by Init_Complex(), and nucomp_div().

◆ id_rationalize

ID id_rationalize
static

Definition at line 33 of file complex.c.

Referenced by Init_Complex(), and nucomp_rationalize().

◆ id_real_p

ID id_real_p
static

Definition at line 33 of file complex.c.

Referenced by Init_Complex().

◆ id_to_f

ID id_to_f
static

Definition at line 33 of file complex.c.

Referenced by f_to_f(), and Init_Complex().

◆ id_to_i

ID id_to_i
static

Definition at line 33 of file complex.c.

Referenced by fun1(), and Init_Complex().

◆ id_to_r

ID id_to_r
static

Definition at line 33 of file complex.c.

Referenced by Init_Complex().

◆ rb_cComplex

VALUE rb_cComplex