Ruby  2.5.0dev(2017-10-22revision60238)
Macros | Functions | Variables
complex.c File Reference
#include "ruby/config.h"
#include <math.h>
#include "internal.h"
#include "ruby_assert.h"
#include <ctype.h>

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

 fun1 (abs)
 
 fun1 (numerator)
 
 fun1 (to_r)
 
 fun2 (expt)
 
VALUE rb_flo_is_finite_p (VALUE num)
 
VALUE rb_flo_is_infinite_p (VALUE num)
 
 imp1 (cos)
 
 imp1 (sin)
 
VALUE rb_complex_plus (VALUE self, VALUE other)
 
VALUE rb_complex_mul (VALUE self, VALUE other)
 
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_abs (VALUE cmp)
 
void Init_Complex (void)
 

Variables

VALUE rb_cComplex
 

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:774
unsigned long VALUE
Definition: ruby.h:85

Definition at line 43 of file complex.c.

◆ canonicalization

#define canonicalization   0

Definition at line 364 of file complex.c.

◆ f_boolcast

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

Definition at line 41 of file complex.c.

◆ 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.

◆ FINITE_TYPE_P

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

Definition at line 1350 of file complex.c.

◆ 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:774
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:774
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)

Definition at line 288 of file complex.c.

Referenced by imp1().

◆ get_dat2

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

Definition at line 291 of file complex.c.

Referenced by rb_complex_mul(), and rb_complex_plus().

◆ 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 492 of file complex.c.

◆ k_exact_p

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

Definition at line 284 of file complex.c.

◆ k_exact_zero_p

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

Definition at line 286 of file complex.c.

◆ 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:774
RUBY_EXTERN VALUE rb_mMath
Definition: ruby.h:1887
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:774
RUBY_EXTERN VALUE rb_mMath
Definition: ruby.h:1887
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 816 of file complex.c.

◆ nucomp_quo

#define nucomp_quo   nucomp_div

Definition at line 891 of file complex.c.

◆ ONE

#define ONE   INT2FIX(1)

Definition at line 20 of file complex.c.

◆ PRESERVE_SIGNEDZERO

#define PRESERVE_SIGNEDZERO

Definition at line 78 of file complex.c.

◆ rb_intern

#define rb_intern (   str)    rb_intern_const(str)

◆ rb_raise_zerodiv

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

Definition at line 870 of file complex.c.

◆ RFLOAT_0

#define RFLOAT_0   DBL2NUM(0)

Definition at line 22 of file complex.c.

◆ TWO

#define TWO   INT2FIX(2)

Definition at line 21 of file complex.c.

◆ ZERO

#define ZERO   INT2FIX(0)

Definition at line 19 of file complex.c.

Function Documentation

◆ 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.

◆ fun2()

fun2 ( expt  )

Definition at line 207 of file complex.c.

◆ imp1() [1/2]

imp1 ( cos  )

Definition at line 499 of file complex.c.

References rb_math_log().

◆ imp1() [2/2]

imp1 ( sin  )

Definition at line 509 of file complex.c.

References get_dat1.

◆ Init_Complex()

void Init_Complex ( void  )

Definition at line 2189 of file complex.c.

References assert.

◆ rb_Complex()

VALUE rb_Complex ( VALUE  x,
VALUE  y 
)

Definition at line 1460 of file complex.c.

◆ rb_complex_abs()

VALUE rb_complex_abs ( VALUE  cmp)

Definition at line 1469 of file complex.c.

◆ rb_complex_mul()

VALUE rb_complex_mul ( VALUE  self,
VALUE  other 
)

Definition at line 787 of file complex.c.

References get_dat2, RB_TYPE_P, and T_COMPLEX.

◆ rb_complex_new()

VALUE rb_complex_new ( VALUE  x,
VALUE  y 
)

Definition at line 1448 of file complex.c.

◆ rb_complex_plus()

VALUE rb_complex_plus ( VALUE  self,
VALUE  other 
)

Definition at line 706 of file complex.c.

References get_dat2, RB_TYPE_P, and T_COMPLEX.

◆ rb_complex_polar()

VALUE rb_complex_polar ( VALUE  x,
VALUE  y 
)

Definition at line 1454 of file complex.c.

◆ rb_complex_raw()

VALUE rb_complex_raw ( VALUE  x,
VALUE  y 
)

Definition at line 1442 of file complex.c.

◆ rb_flo_is_finite_p()

VALUE rb_flo_is_finite_p ( VALUE  num)

Definition at line 1767 of file numeric.c.

References isfinite, isinf(), isnan, Qfalse, Qtrue, and RFLOAT_VALUE.

◆ rb_flo_is_infinite_p()

VALUE rb_flo_is_infinite_p ( VALUE  num)

Definition at line 1747 of file numeric.c.

References INT2FIX, isinf(), Qnil, and RFLOAT_VALUE.

Variable Documentation

◆ rb_cComplex

VALUE rb_cComplex

Definition at line 28 of file complex.c.