Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)
|
#include "ruby/internal/config.h"
#include <ctype.h>
#include <math.h>
#include "id.h"
#include "internal.h"
#include "internal/array.h"
#include "internal/class.h"
#include "internal/complex.h"
#include "internal/numeric.h"
#include "internal/object.h"
#include "internal/rational.h"
#include "ruby_assert.h"
Go to the source code of this file.
Macros | |
#define | _USE_MATH_DEFINES 1 |
#define | NDEBUG |
#define | ZERO INT2FIX(0) |
#define | ONE INT2FIX(1) |
#define | TWO INT2FIX(2) |
#define | id_to_i idTo_i |
#define | id_to_r idTo_r |
#define | id_negate idUMinus |
#define | id_expt idPow |
#define | id_to_f idTo_f |
#define | id_quo idQuo |
#define | id_fdiv idFdiv |
#define | f_boolcast(x) ((x) ? Qtrue : Qfalse) |
#define | fun1(n) |
#define | fun2(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 | imp1(n) |
#define | cospi(x) cos((x) * M_PI) |
#define | sinpi(x) sin((x) * M_PI) |
#define | rb_raise_zerodiv() rb_raise(rb_eZeroDivError, "divided by 0") |
#define | nucomp_quo rb_complex_div |
#define | FINITE_TYPE_P(v) (RB_INTEGER_TYPE_P(v) || RB_TYPE_P(v, T_RATIONAL)) |
Functions | |
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_dbl_complex_new_polar_pi (double abs, double ang) |
VALUE | rb_complex_real (VALUE self) |
VALUE | rb_complex_imag (VALUE self) |
VALUE | rb_complex_uminus (VALUE self) |
VALUE | rb_complex_plus (VALUE self, VALUE other) |
VALUE | rb_complex_minus (VALUE self, VALUE other) |
VALUE | rb_complex_mul (VALUE self, VALUE other) |
VALUE | rb_complex_div (VALUE self, VALUE other) |
VALUE | rb_complex_pow (VALUE self, VALUE other) |
VALUE | rb_complex_abs (VALUE self) |
VALUE | rb_complex_arg (VALUE self) |
VALUE | rb_complex_conjugate (VALUE self) |
st_index_t | rb_complex_hash (VALUE self) |
VALUE | rb_complex_raw (VALUE x, VALUE y) |
VALUE | rb_complex_new (VALUE x, VALUE y) |
VALUE | rb_complex_new_polar (VALUE x, VALUE y) |
VALUE | rb_complex_polar (VALUE x, VALUE y) |
VALUE | rb_Complex (VALUE x, VALUE y) |
VALUE | rb_dbl_complex_new (double real, double imag) |
Creates a Complex object. More... | |
void | Init_Complex (void) |
Variables | |
VALUE | rb_cComplex |
#define FINITE_TYPE_P | ( | v | ) | (RB_INTEGER_TYPE_P(v) || RB_TYPE_P(v, T_RATIONAL)) |
#define fun1 | ( | n | ) |
#define fun2 | ( | n | ) |
#define imp1 | ( | n | ) |
#define nucomp_quo rb_complex_div |
#define rb_raise_zerodiv | ( | ) | rb_raise(rb_eZeroDivError, "divided by 0") |
fun1 | ( | to_r | ) |
Definition at line 285 of file complex.c.
References FIXNUM_P, NUM2DBL, and rb_equal().
fun2 | ( | expt | ) |
Definition at line 297 of file complex.c.
References id_quo, rb_float_div(), rb_funcallv, RB_INTEGER_TYPE_P, rb_numeric_quo(), and T_RATIONAL.
imp1 | ( | cos | ) |
Definition at line 574 of file complex.c.
References rb_math_log().
imp1 | ( | sin | ) |
void Init_Complex | ( | void | ) |
Definition at line 2322 of file complex.c.
References CLASS_OF, DBL2NUM, id_denominator, id_numerator, nucomp_quo, ONE, rb_cComplex, rb_cFloat, rb_cNilClass, rb_cNumeric, rb_cObject, rb_complex_abs(), rb_complex_arg(), rb_complex_conjugate(), rb_complex_div(), rb_complex_imag(), rb_complex_minus(), rb_complex_mul(), rb_complex_plus(), rb_complex_pow(), rb_complex_real(), rb_complex_uminus(), 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_gc_register_mark_object(), rb_marshal_define_compat(), rb_mComparable, rb_provide(), rb_undef_method(), rb_undef_methods_from(), RCLASS_ORIGIN, and ZERO.
Definition at line 1560 of file complex.c.
References rb_cComplex.
Definition at line 1170 of file complex.c.
References f_abs, get_dat1, and rb_math_hypot().
Referenced by Init_Complex().
Definition at line 1217 of file complex.c.
References get_dat1, and rb_math_atan2().
Referenced by Init_Complex().
Definition at line 957 of file complex.c.
Referenced by Init_Complex(), and rb_numeric_quo().
st_index_t rb_complex_hash | ( | VALUE | self | ) |
Definition at line 821 of file complex.c.
References CLASS_OF, f_sub, get_dat1, get_dat2, rb_num_coerce_bin(), and T_COMPLEX.
Referenced by Init_Complex().
Definition at line 881 of file complex.c.
References CLASS_OF, f_mul, get_dat1, get_dat2, rb_num_coerce_bin(), and T_COMPLEX.
Referenced by Init_Complex().
Definition at line 1542 of file complex.c.
References rb_cComplex.
Referenced by rb_dbl_complex_new_polar_pi().
Definition at line 1548 of file complex.c.
References rb_cComplex.
Referenced by rb_complex_polar().
Definition at line 787 of file complex.c.
References CLASS_OF, f_add, get_dat1, get_dat2, rb_num_coerce_bin(), and T_COMPLEX.
Referenced by Init_Complex().
Definition at line 1554 of file complex.c.
References rb_complex_new_polar().
Definition at line 994 of file complex.c.
References CLASS_OF, f_abs, f_add, f_expt, f_mul, f_negate, f_reciprocal, f_sub, FIX2LONG, FIXNUM_P, get_dat1, id_expt, k_exact_zero_p, LONG2FIX, ONE, rb_int_uminus(), rb_num_coerce_bin(), rb_num_pow(), rb_warn(), RRATIONAL, T_BIGNUM, T_COMPLEX, T_RATIONAL, TWO, and ZERO.
Referenced by Init_Complex(), and rb_num_pow().
Definition at line 1536 of file complex.c.
References rb_cComplex.
Referenced by rb_dbl_complex_new().
VALUE rb_dbl_complex_new | ( | double | real, |
double | imag | ||
) |
Creates a Complex object.
real | real part value |
imag | imaginary part value |
Definition at line 1576 of file complex.c.
References DBL2NUM, and rb_complex_raw().
VALUE rb_dbl_complex_new_polar_pi | ( | double | abs, |
double | ang | ||
) |
Definition at line 669 of file complex.c.
References cospi, DBL2NUM, rb_complex_new(), and sinpi.
Referenced by rb_big_pow(), and rb_float_pow().
Definition at line 1804 of file numeric.c.
References isfinite, isinf(), isnan, num, Qfalse, Qtrue, and RFLOAT_VALUE.
Referenced by Init_Numeric().
Definition at line 1784 of file numeric.c.
References INT2FIX, isinf(), num, Qnil, and RFLOAT_VALUE.
Referenced by Init_Numeric().
VALUE rb_cComplex |
Definition at line 44 of file complex.c.
Referenced by imp1(), Init_Complex(), rb_Complex(), rb_complex_new(), rb_complex_new_polar(), and rb_complex_raw().