summaryrefslogtreecommitdiff
path: root/complex.c
AgeCommit message (Collapse)Author
2022-12-02[Bug #19087] Disallow successive underscores in Complex stringNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6645
2022-11-16Using UNDEF_P macroS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/6721
2022-10-27Improve performance some `Integer` and `Float` methods [Feature #19085] (#6638)S.H
* Improve some Integer and Float methods * Using alias and Remove unnecessary code * Remove commentout code Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2022-10-23Reduce type check of arguments at Complex creationNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6618
2022-10-23[Bug #19004] `Complex.polar` handles complex singular `abs` argumentStephen Ierodiaconou
`Complex.polar` accepts Complex values as arguments for the polar form as long as the value of the complex has no imaginary part (ie it is 'real'). In `f_complex_polar` this is handled by extracting the real part of the arguments. However in the case `polar` is called with only a single argument, the absolute value (abs), then the Complex is created without applying a check on the type of abs, meaning it is possible to create a Complex where the real part is itself an instance of a Complex. This change removes the short circuit for the single argument case meaning the real part extraction is performed correctly (by f_complex_polar). Also adds an example to `spec/ruby/core/complex/polar_spec.rb` to check that the real part of a complex argument is correctly extracted and used in the resulting Complex real and imaginary parts. Notes: Merged: https://github.com/ruby/ruby/pull/6568 Merged-By: nobu <nobu@ruby-lang.org>
2022-10-17[DOC] Add the polar form in String#to_cNobuyoshi Nakada
2022-09-02Consider Complex from Complex casesNobuyoshi Nakada
The assertions that "an argument of a Complex constructor must not be a Complex" may not hold for some Numeric objects. Notes: Merged: https://github.com/ruby/ruby/pull/6317
2022-09-02[Bug #18937] Coerce non-real non-Numeric into Complex at comparisonsNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6317
2022-09-02Turn `f_zero_p` to `bool`Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6317
2022-08-22[Bug #18937] Coerce non-Numeric into Complex at comparisonsNobuyoshi Nakada
2022-08-12Remove Numeric#ceildivKouhei Yanagita
Notes: Merged: https://github.com/ruby/ruby/pull/5965
2022-08-12Add Numeric#ceildiv and Integer#ceildivKouhei Yanagita
Notes: Merged: https://github.com/ruby/ruby/pull/5965
2022-07-21Expand tabs [ci skip]Takashi Kokubun
[Misc #18891] Notes: Merged: https://github.com/ruby/ruby/pull/6094
2022-02-08[DOC] Fix broken links to literals.rdocNobuyoshi Nakada
2022-02-08[DOC] Simplify links to global methodsNobuyoshi Nakada
2021-12-03Adding links to literals and Kernel (#5192)Burdette Lamar
* Adding links to literals and Kernel Notes: Merged-By: BurdetteLamar <BurdetteLamar@Yahoo.com>
2021-10-18Remove declarations unused since a95262356ef5Nobuyoshi Nakada
2021-09-15Refactor and Using RBOOL macroS.H
Notes: Merged: https://github.com/ruby/ruby/pull/4837 Merged-By: nobu <nobu@ruby-lang.org>
2021-09-11Using RB_BIGNUM_TYPE_P macroS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/4805
2021-09-10include/ruby/internal/intern/complex.h: add doxygen卜部昌平
Must not be a bad idea to improve documents. [ci skip] Notes: Merged: https://github.com/ruby/ruby/pull/4815
2021-09-03Remove unneeded commentS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/4803
2021-09-02Extract always_finite_type_p and handle flonum casesNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4801
2021-09-02Make internal predicate functions to return simple booleanNobuyoshi Nakada
2021-09-02Refactor f_infinite_p functionS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/4794
2021-08-27Use C99-defined signbit macroNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4783
2021-08-18Replace f_boolcast with RBOOL macroS.H
* Move f_boolcast definination * Remove f_boolcast macro defination * to Notes: Merged: https://github.com/ruby/ruby/pull/4748 Merged-By: nobu <nobu@ruby-lang.org>
2021-05-20Rename nucomp_false s nucomp_real_p_mNobuyoshi Nakada
2021-05-12cdhash_cmp: can also take complex卜部昌平
There are complex literals `123i`, which can also be a case condition. Notes: Merged: https://github.com/ruby/ruby/pull/4469
2021-03-19Remove duplicated float_arg definationS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/4283
2021-01-07Follow the NDEBUG given to the wholeNobuyoshi Nakada
2020-11-10Removed canonicalization for mathnNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/3691
2020-10-21Don't redefine #rb_intern over and over againStefan Stüben
Notes: Merged: https://github.com/ruby/ruby/pull/3589
2020-09-16Fix assertion failed in Complex.polar without NDEBUG (#3551)Kenta Murata
Fixes [Bug #17172]. Notes: Merged-By: mrkn <mrkn@ruby-lang.org>
2020-08-15RARRAY_AREF: convert into an inline function卜部昌平
RARRAY_AREF has been a macro for reasons. We might not be able to change that for public APIs, but why not relax the situation internally to make it an inline function. Notes: Merged: https://github.com/ruby/ruby/pull/3419
2020-06-03Ensure origins for all included, prepended, and refined modulesJeremy Evans
This fixes various issues when a module is included in or prepended to a module or class, and then refined, or refined and then included or prepended to a module or class. Implement by renaming ensure_origin to rb_ensure_origin, making it non-static, and calling it when refining a module. Fix Module#initialize_copy to handle origins correctly. Previously, Module#initialize_copy did not handle origins correctly. For example, this code: ```ruby module B; end class A def b; 2 end prepend B end a = A.dup.new class A def b; 1 end end p a.b ``` Printed 1 instead of 2. This is because the super chain for a.singleton_class was: ``` a.singleton_class A.dup B(iclass) B(iclass origin) A(origin) # not A.dup(origin) ``` The B iclasses would not be modified, so the includer entry would be still be set to A and not A.dup. This modifies things so that if the class/module has an origin, all iclasses between the class/module and the origin are duplicated and have the correct includer entry set, and the correct origin is created. This requires other changes to make sure all tests still pass: * rb_undef_methods_from doesn't automatically handle classes with origins, so pass it the origin for Comparable when undefing methods in Complex. This fixed a failure in the Complex tests. * When adding a method, the method cache was not cleared correctly if klass has an origin. Clear the method cache for the klass before switching to the origin of klass. This fixed failures in the autoload tests related to overridding require, without breaking the optimization tests. Also clear the method cache for both the module and origin when removing a method. * Module#include? is fixed to skip origin iclasses. * Refinements are fixed to use the origin class of the module that has an origin. * RCLASS_REFINED_BY_ANY is removed as it was only used in a single place and is no longer needed. * Marshal#dump is fixed to skip iclass origins. * rb_method_entry_make is fixed to handled overridden optimized methods for modules that have origins. Fixes [Bug #16852] Notes: Merged: https://github.com/ruby/ruby/pull/3140
2020-05-11sed -i 's|ruby/impl|ruby/internal|'卜部昌平
To fix build failures. Notes: Merged: https://github.com/ruby/ruby/pull/3079
2020-05-11sed -i s|ruby/3|ruby/impl|g卜部昌平
This shall fix compile errors. Notes: Merged: https://github.com/ruby/ruby/pull/3079
2020-05-03Optimize sin/cosNobuyoshi Nakada
GCC/Clang can optimize to calculate `sin(x)` and `cos(x)` at once, when the both are closely called on the same argument. Similar optimization is possible for `__sinpi(x)` and `__cospi(x)` if available, which calculate arguments in radian, i.e. `sin(x*M_PI)` and `cos(x*M_PI)` respectively.
2020-04-21reroute redefinition of NDEBUG卜部昌平
NDEBUG can be defined via a command-line argument. Should take care of such situations.
2020-04-08Merge pull request #2991 from shyouhei/ruby.h卜部昌平
Split ruby.h Notes: Merged-By: shyouhei <shyouhei@ruby-lang.org>
2019-12-26decouple internal.h headers卜部昌平
Saves comitters' daily life by avoid #include-ing everything from internal.h to make each file do so instead. This would significantly speed up incremental builds. We take the following inclusion order in this changeset: 1. "ruby/config.h", where _GNU_SOURCE is defined (must be the very first thing among everything). 2. RUBY_EXTCONF_H if any. 3. Standard C headers, sorted alphabetically. 4. Other system headers, maybe guarded by #ifdef 5. Everything else, sorted alphabetically. Exceptions are those win32-related headers, which tend not be self- containing (headers have inclusion order dependencies). Notes: Merged: https://github.com/ruby/ruby/pull/2711
2019-11-25Improve consistency of bool/true/falseKazuhiro NISHIYAMA
2019-09-21Make Kernel#{Pathname,BigDecimal,Complex} return argument if given correct typeJeremy Evans
This is how Kernel#{Array,String,Float,Integer,Hash,Rational} work. BigDecimal and Complex instances are always frozen, so this should not cause backwards compatibility issues for those. Pathname instances are not frozen, so potentially this could cause backwards compatibility issues by not returning a new object. Based on a patch from Joshua Ballanco, some minor changes by me. Fixes [Bug #7522] Notes: Merged: https://github.com/ruby/ruby/pull/2473
2019-08-10Expanded f_quoNobuyoshi Nakada
2019-08-10Expanded f_real_pNobuyoshi Nakada
2019-08-03Predefine some IDsNobuyoshi Nakada
2019-07-16Expanded f_numeratorNobuyoshi Nakada
2019-07-16Expanded f_denominatorNobuyoshi Nakada
2019-07-14Expand f_arg to use particular functions directlyNobuyoshi Nakada
2019-07-14Expand f_abs to use particular functions directlyNobuyoshi Nakada