Граф коммитов

219 Коммитов

Автор SHA1 Сообщение Дата
nobu f4c2b33eac complex.c: remove deprecated functions
* 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
2017-02-21 06:07:21 +00:00
mrkn b920d9545c complex.c: optimize f_gt_p some cases
* 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
2016-11-22 05:21:12 +00:00
mrkn 5a5cc211f4 complex.c: optimize Kernel#Complex
* 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
2016-11-22 04:54:57 +00:00
mrkn c151aa88a9 complex.c: optimize f_negate
* 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
2016-11-18 15:17:19 +00:00
mrkn a94b625ff2 complex.c: refactoring
* 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
2016-11-18 14:24:15 +00:00
mrkn affa0f845c complex.c: optimize Numeric#polar and Numeric#arg
* 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
2016-11-16 04:25:35 +00:00
nobu c4e660457f complex.c: purge id_eqeq_p and limit return value
* 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
2016-11-15 06:28:05 +00:00
nobu c0af2a1641 complex.c: optimize
* 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
2016-11-14 04:06:15 +00:00
mrkn 975e0ef858 complex.c: refactoring
* 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
2016-11-13 16:43:43 +00:00
mrkn 7c451099f5 complex.c: refactoring
* complex.c (f_one_p): removed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56771 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-13 16:22:26 +00:00
mrkn 912857340b complex.c: refactoring and small optimization
* 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
2016-11-13 16:22:08 +00:00
mrkn 9e20ee9081 complex.c: refactoring
* 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
2016-11-13 16:21:54 +00:00
mrkn b027b019ef complex.c: refactoring
* 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
2016-11-12 18:42:30 +00:00
nobu b03a92c4ce complex.c: static IDs
* 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
2016-10-28 06:20:19 +00:00
nobu 2226372268 complex.c: FINITE_TYPE_P
* 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
2016-10-28 06:19:00 +00:00
nobu 052690309a complex.c: undefine Comparable methods
* 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
2016-10-24 01:51:10 +00:00
nobu 7a9812209d complex.c: undefine clamp
* 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
2016-10-24 01:19:46 +00:00
nobu c463366dfd rb_funcallv
* *.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
2016-07-29 11:57:14 +00:00
mrkn 94468b4ea5 numeric.c, complex.c: Add finite? and infinite? consistent with Float
* 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
2016-07-17 14:53:00 +00:00
nobu 745a2aac69 math.c: Complex sqrt
* 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
2016-07-12 14:13:46 +00:00
nobu 89ed4f41a3 complex.c: rb_complex prefix
* 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
2016-07-12 13:17:04 +00:00
nobu 4a9705d6e3 ruby.h: RB_INTEGER_TYPE_P
* 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
2016-05-18 01:17:43 +00:00
yui-knk c949686d02 * complex.c (rb_complex_set_imag): Fix to properly set imag
of complex.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-03 13:54:19 +00:00
akr f1183cb910 complex.c don't refer rb_cFixnum and rb_cBignum.
* 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
2016-05-01 21:59:41 +00:00
nobu 7d5b9cd3f6 complex.c: pure declarations
* 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
2016-03-31 03:02:35 +00:00
nobu 439224a590 RUBY_ASSERT
* 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
2016-01-22 08:33:55 +00:00
nobu 4191a6b90d preserve encodings in error messages
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-28 02:40:46 +00:00
odaira c3b02d572c complex.c: ruby/config.h must be included before math.h
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
2015-09-23 15:08:47 +00:00
nobu 42e36319bd ruby/missing.h: M_PI fallback definition
* include/ruby/missing.h (M_PI, M_PI_2): fallback definitions for
  VC6.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-21 10:51:40 +00:00
usa b53d547f38 * complex.c (f_complex_polar): simple bug reproduced only when y is
a float but x is not a float.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50601 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-22 11:57:43 +00:00
nobu 932e916b9e numeric.c: Numeric#positive? and Numeric#negative?
* numeric.c (num_positive_p, num_negative_p): add methods
  Numeric#positive? and Numeric#negative?.
  [ruby-core:69173] [Feature #11151]
* numeric.c (flo_positive_p, flo_negative_p): specialiazed
  functions for Float.
* complex.c (Init_Complex): Complex do not have positive? and
  negative? methods

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-17 06:01:47 +00:00
gogotanaka cf204a8943 * complex.c (k_exact_one_p): remove unused macro k_exact_one_p.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-24 21:59:55 +00:00
gogotanaka c959238445 * complex.c (k_inexact_p, k_exact_zero_p): use k_exact_zero_p macro
to remove k_inexact_p macro.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-24 21:59:36 +00:00
gogotanaka 9f2922bdcd complex.c: [DOC] mention about Complex literal.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-21 12:32:09 +00:00
nobu f8a82e1583 complex.c: suppress warnings on FreeBSD
* 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
2015-03-09 05:48:09 +00:00
nobu 41b2f1ada4 complex.c: sign of zeros
* 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
2015-02-25 17:05:26 +00:00
nobu 909c4c0fd7 complex.c: specialize
* 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
2015-02-25 14:16:05 +00:00
nobu ca3f71b8b5 complex.c: move optimization
* complex.c (f_complex_polar): move optimization for orthogonal
  cases from rb_nucomp_mul.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-25 06:48:55 +00:00
nobu 7b65fb292a complex.c: M_PI in VC
* 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
2015-02-25 02:25:22 +00:00
nobu ed00379c79 numeric.c: calculate complex numbers
* numeric.c (fix_plus, fix_mul): calculate complex numbers for
  commutative operations.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-24 13:59:06 +00:00
nobu 3bcb10ad2a complex.c: multiply as rotation
* 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
2015-02-24 13:58:52 +00:00
hsbt 847461260f * complex.c: removed commented-out code.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-10 01:58:59 +00:00
akr 2b9191e557 * internal.h: Gather declarations in non-header files.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-18 15:13:05 +00:00
akr 7cd76ab0c5 * internal.h: Include ruby.h and ruby/encoding.h to be
includable without prior inclusion.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15 11:49:06 +00:00
nobu 9261f25e0f provide backward compatibilities
* complex.c (Init_Complex): provide the feature for backward
  compatibility.

* rational.c (Init_Rational): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47249 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-22 08:01:42 +00:00
nobu aa3b506270 add some documents [ci skip]
* bignum.c (Init_Bignum): [DOC] Bignum::GMP_VERSION.

* complex.c (Init_Complex): [DOC] ignore an internal class.

* dir.c (Init_Dir): [DOC] File::FNM_SYSCASE.

* file.c (rb_file_exists_p): [DOC] File.exists? is deprecated.

* object.c (rb_mod_initialize_clone): [DOC] ignore implementation
  detail.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-28 11:28:55 +00:00
shyouhei 62bfc4f24e * include/ruby/ruby.h (struct RComplex): no longer. [Feature #9888]
* include/ruby/ruby.h (RCOMPLEX): ditto.

	* include/ruby/ruby.h (RCOMPLEX_SET_REAL): deprecated.  Will be deleted later.

	* include/ruby/ruby.h (RCOMPLEX_SET_IMAG): ditto.

	* internal.h (struct RFloat): moved here.

	* internal.h (RCOMPLEX): ditto.

	* complex.c (rb_complex_set_real): do not use this.

	* complex.c (rb_complex_set_imag): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46506 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-23 04:41:27 +00:00
normal a9befcdb08 avoid large alloca on Complex/Rational calls
* complex.c (parse_comp): replace ALLOCA_N with ALLOCV_N/ALLOCV_END
  [Bug #9608]
* rational.c (read_digits): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45793 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-02 19:21:18 +00:00
hsbt cbf4eca61e * complax.c: [DOC] Document number conversion of `nil` by @skade [fix GH-570] [ci skip]
* object.c, rational.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45375 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-21 00:45:52 +00:00
nobu 77f3da02a0 complex.c: remove f_inspect and f_to_s
* 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
2014-03-17 04:57:17 +00:00