* complex.c (rb_complex_infinite_p): get rid of overflow and
unnecessary multiplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c (rb_complex_finite_p): get rid of overflow and
unnecessary multiplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c (f_gt_p): optimize f_gt_p for specific types of arguments.
* internal.h (rb_int_gt, rb_float_gt, rb_rational_cmp): exported.
* numeric.c (rb_float_gt): rename from flo_gt and be exported.
* numeric.c (rb_int_gt): rename from int_gt and be exported.
* rational.c (rb_rational_cmp): rename from nurat_cmp and be exported.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c (f_negate): optimize for special numeric types.
* complex.c (nucomp_expt): use rb_int_uminus instead of f_negate for
fixnum value.
* internal.h (rb_float_uminus, rb_rational_uminus): exported.
* numeric.c (rb_float_uminus): rename from flo_uminus.
* rational.c (rb_rational_uminus): rename from nurat_negate, and add
assertion for the parameter.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56830 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c (numeric_polar): optimize for Integer, Float, and Rational.
* complex.c (numeric_arg): directly create the value of pi.
* complex.c (f_negative_p): optimize for Integer, Float, and Rational.
* rational.c (INT_NEGATIVE_P): move the definition into internal.h.
* internal.h (INT_NEGATIVE_P): ditto.
* numeric.c (rb_float_abs): rename from flo_abs and export to be used
from other source files..
* internal.h (rb_float_abs): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c (f_eqeq_p): use rb_equal.
* complex.c (nucomp_eqeq_p): limit return value to true or false,
instead of the result of the other as-is.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56797 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c (f_negative_p): use rb_num_negative_p instead of funcall.
* complex.c (f_kind_of_p, f_numeric_p): cast down to int because
rb_obj_is_kind_of is safe.
* complex.c (f_signbit, f_tpositive_p): remove f_boolcast.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c (nucomp_expt): optimize the access to the numerator and
denominator of a rational number.
* complex.c (k_rational_p): removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c: refactor to use some specific macros and
to reduce needless conversion by FIX2LONG.
* complex.c (k_fixnum_p, k_bignum_p): removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c (Init_Complex): undefine methods inherited from
Comparable, because Complex does not have <=> method.
[Bug #12866]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c (Init_Complex): undefine Complex#clamp, which does not
work like other Comparable methods, because Complex does not
have <=> method. patched by Tim Peters <zomg.tim AT gmail.com>
in [ruby-core:77720]. [Bug #12866]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56479 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* *.c: rename rb_funcall2 to rb_funcallv, except for extensions
which are/will be/may be gems. [Fix GH-1406]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h (RB_INTEGER_TYPE_P): new macro and
underlying inline function to check if the object is an
Integer (Fixnum or Bignum).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c (get_dat1, get_dat2): turn into pure variable
declarations only, not mixed code and declarations.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54446 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* error.c (rb_assert_failure): assertion with stack dump.
* ruby_assert.h (RUBY_ASSERT): new header for the assertion.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53615 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
because it defines _LARGE_FILES on AIX and _LARGE_FILES
must be defined before sys/types.h is included from math.h.
[Bug #11483]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c (safe_mul): get rid of assignments in a macro.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c (rb_nucomp_mul): preserve sign of zeros without NaN by
regularized values.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49757 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c (rb_nucomp_mul): specialize real numbers and purely
imaginary numbers, and get rid of multiplication by zero.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49754 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c (_USE_MATH_DEFINES): needed for M_PI in Microsoft
Visual C.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49732 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c (nucomp_mul): calculate as rotation in complex plane
if matrix calculation resulted in NaN.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c (nucomp_to_s): use rb_String.
* complex.c (nucomp_inspect): use rb_inspect.
* complex.c: use PRIsVALUE flag not to use an intermediate string
which can be collected by GC.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c, rational.c: remove unused functions, which are warned
by clang 5.1, and also variables only used by removed functions.
* ext/date/date_core.c: ditto.
* enc/utf_16be.c, enc/utf_16le.c: comment out constants only used
by commented out functions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* rational.c (numeric_quo): variable 'canonicalization' is defined
conditionally by CANON (and CANONICALIZATION_FOR_MATHN).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42904 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c, rational.c: use RB_TYPE_P() for special classes instead
of switch with TYPE().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
RComplex::(real,imag).
Add macro to set these values:
* RRATIONAL_SET_NUM()
* RRATIONAL_SET_DEN()
* RCOMPLEX_SET_REAL()
* RCOMPLEX_SET_IMAG()
This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
TODO: API design. RRATIONAL_SET(rat,num,den) is enough?
TODO: Setting constify variable with cast has same issue of r40691.
* complex.c, rational.c: use above macros.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40698 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* marshal.c (w_object): dump instance varialbes of the result of
marshal_dump not the original object. [ruby-core:51163] [Bug #7627]
* complex.c (nucomp_marshal_dump): need to copy instance variables.
* rational.c (nurat_marshal_dump): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Keep the simple definition, mathematics define the result.
Based on patch by Robin Dupret. Fixes#188 on github.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37010 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
But now disabled. [experimental]
* complex.c: followed the above.
* rational.c: ditto.
* include/rub/intern.h: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35886 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
disabled (due to compatibility) [experimental].
* rational.c: wrote Rational#_dump and Rational::load. ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e