aboutsummaryrefslogtreecommitdiffstats
path: root/complex.c
Commit message (Collapse)AuthorAgeFilesLines
* complex.c: simplify division resultnobu2018-09-011-14/+8
| | | | | | | * complex.c (f_divide): canonicalize rationals to simplify integer complex results. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* share Float 0nobu2018-06-171-0/+8
| | | | | | | * complex.c (RFLOAT_0): share the 0.0 object on non-flonum platforms. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* refine Integer#** and Float#**nobu2018-06-171-0/+22
| | | | | | | | | | | | * complex.c (rb_dbl_complex_polar): utility function, which returns more precise value in right angle cases. * bignum.c (rb_big_pow): use rb_dbl_complex_polar(). * numeric.c (rb_float_pow, fix_pow): create a Complex by polar form. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63678 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c: improve docs for Complex#{finite?,infinite?}stomar2018-04-141-2/+2
| | | | | | | * complex.c: [DOC] correct term "real value" to "real part", and same for imaginary part, in documentation for Complex#{finite?,infinite?}. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63152 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Update Complex#infinite? documenationnobu2018-03-261-4/+2
| | | | | | | | | | to state what it really does. [Fix GH-1848] From: Christian Bruckmayer <cbruckmayer@suse.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62921 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Update Complex#finite? documentationnobu2018-03-261-1/+1
| | | | | | | | | | to state what it really does. [Fix GH-1848] From: Christian Bruckmayer <cbruckmayer@suse.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add `exception:` keyword in Kernel#Complex()mrkn2018-03-151-22/+69
| | | | | | | | | | Support `exception:` keyword argument in `Kernel#Complex()`. If `exception:` is `false`, `Kernel#Complex()` returns `nil` if the given value cannot be interpreted as a complex value. The default value of `exception:` is `true`. This is part of [Feature #12732]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62760 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Removed useless assertions [ci skip]nobu2018-03-091-2/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c: removed redundant conditionsnobu2018-03-091-27/+9
| | | | | | | | Fixnums can be compared by object values themselves only. Addition/subtraction/mulplication of fixnum 0 do not affect the sign. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c: removed already unused macrosnobu2018-03-091-14/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c: check typenobu2018-03-071-2/+2
| | | | | | | * complex.c (m_cos, m_sin): determine the type by the internal type, not by a method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62689 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c: check typenobu2018-03-071-3/+7
| | | | | | | * complex.c (nucomp_s_canonicalize_internal): determine the type by the internal type, not by a method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c, rational.c: no backrefnobu2018-03-071-6/+1
| | | | | | Since r37702, parsing complex and rational do not use regexp. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62687 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c, rational.c: adjust indentnobu2018-03-071-3/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c, rational.c: simplified macro conditionsnobu2018-03-071-11/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* defs/id.def: predefine to_f IDnobu2018-02-271-3/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c: use predefined IDsnobu2018-02-271-4/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c, rational.c: remove dead codemrkn2018-02-241-93/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [DOC] nodoc internal methods/classesnobu2018-02-231-1/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62542 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* force fixablenobu2018-01-301-1/+1
| | | | | | | | | * complex.c (nucomp_hash): force hash values fixable. [ruby-core:85224] [Bug #14420] * rational.c (nurat_hash): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* use predefined IDskazu2018-01-221-3/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62008 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c: doc fixstomar2017-10-291-2/+2
| | | | | | * complex.c: [DOC] fix grammar and typo. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60569 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* freeze Complex and Rationalnobu2017-10-191-0/+2
| | | | | | | | | | * complex.c (nucomp_s_new_internal, nucomp_loader): Complex instances are always frozen now. [Feature #13983] * rational.c (nurat_s_new_internal, nurat_loader): Rational instances are always frozen now. [Feature #13983] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c: no overflownobu2017-09-271-12/+19
| | | | | | | * 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: no overflownobu2017-09-271-9/+19
| | | | | | | * 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: fix Complex#infinite? return value. Because nucomp_abs never ↵nobu2017-09-271-2/+2
| | | | | | returns negative value. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60038 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c: remove deprecated functionsnobu2017-02-211-14/+0
| | | | | | | * complex.c (rb_complex_set_real, rb_complex_set_imag): remove functions deprecated at 2.2. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c: optimize f_gt_p some casesmrkn2016-11-221-4/+13
| | | | | | | | | | | | | | * 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: optimize Kernel#Complexmrkn2016-11-221-5/+4
| | | | | | | | * complex.c (nucomp_f_complex): use nucomp_s_convert directly. * complex.c (id_convert): removed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c: optimize f_negatemrkn2016-11-181-2/+22
| | | | | | | | | | | | | | | | * 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: refactoringmrkn2016-11-181-13/+2
| | | | | | | | | | * complex.c (nucomp_abs): use rb_math_hypot directly. * complex.c (nucomp_arg): use rb_math_atan2 directly. * complex.c (imp2, m_{atan2,hypot}_bang, m_hypot): removed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c: optimize Numeric#polar and Numeric#argmrkn2016-11-161-5/+29
| | | | | | | | | | | | | | | | | | | * 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: purge id_eqeq_p and limit return valuenobu2016-11-151-6/+7
| | | | | | | | | * 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: optimizenobu2016-11-141-11/+12
| | | | | | | | | | | * 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: refactoringmrkn2016-11-131-14/+10
| | | | | | | | * complex.c (f_zero_p): return int rather than VALUE. * complex.c (rb_complex_mul): remove needless negate operations. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c: refactoringmrkn2016-11-131-19/+0
| | | | | | * complex.c (f_one_p): removed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56771 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c: refactoring and small optimizationmrkn2016-11-131-8/+2
| | | | | | | | | * 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: refactoringmrkn2016-11-131-56/+52
| | | | | | * complex.c (f_addsub, k_complex_p, k_float_p): removed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c: refactoringmrkn2016-11-121-27/+14
| | | | | | | | | * 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: static IDsnobu2016-10-281-6/+10
| | | | | | | * complex.c (id_finite_p, id_infinite_p, id_rationalize, id_PI): initialize static IDs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c: FINITE_TYPE_Pnobu2016-10-281-16/+14
| | | | | | | | * complex.c (FINITE_TYPE_P): extract predicate. * complex.c (rb_complex_finite_p, rb_complex_infinite_p): use dedicated predicates instead of switch by TYPE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c: undefine Comparable methodsnobu2016-10-241-6/+1
| | | | | | | | * 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: undefine clampnobu2016-10-241-0/+1
| | | | | | | | | * 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
* rb_funcallvnobu2016-07-291-2/+2
| | | | | | | * *.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
* numeric.c, complex.c: Add finite? and infinite? consistent with Floatmrkn2016-07-171-0/+65
| | | | | | | | | | | | | | | | | | | | | | * numeric.c (num_finite_p, num_infinite_p): Add Numeric#finite? and Numeric#infinite? [Feature #12039] [ruby-core:73618] * complex.c (rb_complex_finite_p): Add Complex#finite? * complex.c (rb_complex_infinite_p): Add Complex#infinite? * test/ruby/test_bignum.rb: Add test for Integer#finite? and Integer#infinite? * test/ruby/test_fixnum.rb: ditto. * test/ruby/test_rational.rb: Add test for Rational#finite? and Rational#infinite? * test/ruby/test_complex.rb: Add test for Complex#finite? and Complex#infinite? git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55702 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* math.c: Complex sqrtnobu2016-07-121-12/+22
| | | | | | | * math.c (rb_math_sqrt): [EXPERIMENTAL] move Complex sqrt support from mathn.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55646 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c: rb_complex prefixnobu2016-07-121-4/+4
| | | | | | | * complex.c (rb_complex_plus, rb_complex_mul): rename to rb_complex prefix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby.h: RB_INTEGER_TYPE_Pnobu2016-05-181-2/+2
| | | | | | | | * 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 (rb_complex_set_imag): Fix to properly set imagyui-knk2016-05-031-1/+1
| | | | | | of complex. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c don't refer rb_cFixnum and rb_cBignum.akr2016-05-011-2/+2
| | | | | | | | | | * complex.c: Don't refer rb_cFixnum and rb_cBignum. (k_fixnum_p): Use FIXNUM_P. (k_bignum_p): Use RB_TYPE_P. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54878 b2dd03c8-39d4-4d8f-98ff-823fe69b080e