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

133 Коммитов

Автор SHA1 Сообщение Дата
nobu 4483d59fbd math.c: faster tanh
* math.c (tanh): make faster by the extract form if three
  hyperbolic functions are unavailable.  [Feature #12647]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55799 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-02 12:42:42 +00:00
nobu 83cfc94563 math.c: tanh overflow
* math.c (tanh): check overflows, and return +-1.0.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-02 12:40:51 +00:00
usa d42e547ab1 * math.c (_USE_MATH_DEFINES): it must be set before including internal.h
because internal.h includes ruby.h, ruby.h includes win32.h, and
  win32.h includes system's math.h.
  this change is to get rid of a compiler warning (redefinition of
  a macro) introduced at r55641.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-13 07:03:23 +00:00
naruse 7b653bd019 fix type
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-13 05:47:48 +00:00
naruse 7b59234aaf * math.c (rb_math_sqrt): r55646 must use f_signbit.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55657 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-13 05:29:30 +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 92b98a982b math.c: get_double_rshift
* math.c (get_double_rshift): extract bignum to double conversion
  with bit offset.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55644 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-12 13:07:51 +00:00
nobu fd2c613b1c math.c: use common constants
* math.c (math_log1, math_log10): use common math constants
  instead of math function calls.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-12 11:53:43 +00:00
odaira 7a3f794da0 * configure.in (rb_cv_lgamma_r_pm0): check if lgamma_r(+0.0)
returns positive infinity, in addition to lgamma_r(-0.0).
  AIX returns an incorrect result of negative infinity.

* math.c (ruby_lgamma_r): handle +0.0, in addition to -0.0.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-27 20:00:57 +00:00
nobu ea736d55f9 configure.in: check lgamma_r(-0.0)
* configure.in (rb_cv_lgamma_r_m0): check if lgamma_r(-0.0)
  returns negative infinity.  [Bug #12249]
* math.c (ruby_lgamma_r): define by the configured result.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-06 05:13:29 +00:00
nobu 39330d6b79 lgamma_r.c: fix at -0.0
* math.c (ruby_lgamma_r): missing/lgamma_r.c is used on Windows,
  since msvcrt does not provide it.
* missing/lgamma_r.c (lgamma_r): fix lgamma(-0.0).
  [ruby-core:74823] [Bug #12249]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54496 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-06 01:17:55 +00:00
usa bb7a4c2a00 * math.c (ruby_lgamma_r): mswin's lgamma_r also seems to be wrong.
cf. [Bug #12249]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54495 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-05 16:23:39 +00:00
nobu 542d3a071f math.c: fix lgamma
* math.c (ruby_lgamma_r): fix lgamma(-0.0) on mingw and OSX.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54494 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-05 15:53:32 +00:00
nobu 41c533446f math.c: fix tgamma
* math.c (ruby_tgamma): fix tgamma(-0.0) on mingw.
  [ruby-core:74817] [Bug #12249]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-05 15:52:02 +00:00
nobu f830ace8a8 object.c: rb_num_to_dbl
* object.c (rb_num_to_dbl): move from num2dbl_with_to_f in math.c.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-13 05:36:33 +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
gogotanaka dc37d6daba * math.c (math_log1, math_log2, math_log10): refactoring
and tests for this.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-16 08:39:29 +00:00
gogotanaka ef8537bc9e * math.c (math_cbrt): [DOC] Fix domain and codomain.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-15 11:49:30 +00:00
nobu 573772ab5b math.c: more robust
* math.c (math_gamma): make more robust against addition/removal.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49972 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-14 23:34:39 +00:00
gogotanaka 717bc13d29 * math.c (math_gamma): rename NGAMMA_TABLE to NFACT_TABLE.
specify the size of the fact_table.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-14 17:37:38 +00:00
gogotanaka 09d9d913c0 * math.c (math_gamma): explicit cast to double.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49969 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-14 11:16:05 +00:00
gogotanaka 0e749ddedc * math.c (math_gamma): optimization for passed small integer.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49968 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-14 11:07:49 +00:00
nobu 3f6fb5f72a math.c: fix tgamma on mingw
* math.c (mingw_tgamma): tgamma(3) on mingw returns a NaN for a
  big number, not infinity.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-10 04:53:46 +00:00
gogotanaka 55473aea5c * math.c: refactoring: remove unnecessary variable d0 to unify code
appearance.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-05 03:29:37 +00:00
gogotanaka 972713cee1 * math.c (num2dbl_with_to_f): direct casting from Rational to double.
[Feature #10909]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49818 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-03 05:59:28 +00:00
nobu df445b470e math.c: optimization for Bignum
* math.c (num2dbl_with_to_f): make faster when Bignum passed by
  direct conversion using rb_big2dbl().  [Feature #10800]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49449 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-30 08:28:32 +00:00
nobu a1f8fbd18d math.c: deoptimize
* math.c (Get_Double): restrict direct casting only when
  Fixnum#to_f is not redefined, and convert with rb_to_float().
  [Feature #10785]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49434 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-29 01:42:12 +00:00
nobu d77ae2c2f4 math.c: Get_Double
* math.c (Get_Double): direct casting from Fixnum to double.
  [Feature #10785]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-29 01:41:54 +00:00
hsbt 2d47bf629f * math.c (math_atan2): revive documentation before r49220.
http://d.hatena.ne.jp/nagachika/20150112/ruby_trunk_changes_49213_49226

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49325 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-18 09:32:26 +00:00
hsbt 2f56ebe8f7 * math.c (math_atan2): improve documentation.
[Feature #10323][ruby-core:65400][ci skip]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-12 04:53:23 +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 e99ee55abc constify parameters
* include/ruby/intern.h: constify `argv` parameters.

* include/ruby/ruby.h: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-18 06:16:39 +00:00
nobu f0fc13aaea configure.in: check atan2
* configure.in (rb_cv_atan2_inf_c99): check whether runtime atan2
  handles Inf as C99.  ruby-core:62536] [Bug #9831]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45930 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-12 14:57:17 +00:00
tadf a210f7c225 * math.c (rb_math_sqrt): omitted exporting an unused function,
anyway.
	* internal.h: follows the above change.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-05 08:28:56 +00:00
nobu d64eef156f * math.c (math_atan2): remove the condition for test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45806 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-04 02:41:35 +00:00
nobu 7a6ebecf9e math.c: C99-like atan2
* math.c (math_atan2): return values like as expected by C99 if
  both two arguments are infinity.  based on the patch by cremno
  phobia <cremno AT mail.ru> in [ruby-core:62310].  [Feature #9799]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-04 01:23:01 +00:00
nobu 38656e24be math.c: check domain of base argument
* math.c (math_log): check domain of base argument too.  raises
  Math::DomainError instead of returning NaN if the base is less
  than 0, and returns NaN instead of -infinity if both of two
  arguments are 0.  [ruby-core:62309] [Bug #9797]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-03 05:28:46 +00:00
nobu 1fd4c7f1f5 math.c: adjust prototype of math_log
* math.c (math_log): adjust prototype as method function.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-03 05:28:44 +00:00
akr 3c99764bcd * internal.h: Rename macro names: RBIGNUM_FOO to BIGNUM_FOO.
(BIGNUM_EMBED_LEN_NUMBITS): Renamed from RBIGNUM_EMBED_LEN_NUMBITS.
  (BIGNUM_EMBED_LEN_MAX): Renamed from RBIGNUM_EMBED_LEN_MAX.
  (BIGNUM_SIGN_BIT): Renamed from RBIGNUM_SIGN_BIT.
  (BIGNUM_SIGN): Renamed from RBIGNUM_SIGN.
  (BIGNUM_SET_SIGN): Renamed from RBIGNUM_SET_SIGN.
  (BIGNUM_POSITIVE_P): Renamed from RBIGNUM_POSITIVE_P.
  (BIGNUM_NEGATIVE_P): Renamed from RBIGNUM_NEGATIVE_P.
  (BIGNUM_EMBED_FLAG): Renamed from RBIGNUM_EMBED_FLAG.
  (BIGNUM_EMBED_LEN_MASK): Renamed from RBIGNUM_EMBED_LEN_MASK.
  (BIGNUM_EMBED_LEN_SHIFT): Renamed from RBIGNUM_EMBED_LEN_SHIFT.
  (BIGNUM_LEN): Renamed from RBIGNUM_LEN.
  (RBIGNUM_DIGITS): Renamed from RBIGNUM_DIGITS.
  (BIGNUM_LENINT): Renamed from RBIGNUM_LENINT.

* bignum.c: Follow the above change.

* gc.c: Ditto.

* marshal.c: Ditto.

* math.c: Ditto.

* numeric.c: Ditto.

* random.c: Ditto.

* rational.c: Ditto.

* sprintf.c: Ditto.

* ext/-test-/bignum/bigzero.c: Ditto.

* ext/-test-/bignum/intpack.c: Ditto.

* ext/bigdecimal/bigdecimal.c: Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-15 21:17:34 +00:00
nobu 202cc8e615 math.c: fix for Bignum argument
* math.c (math_log, math_log2, math_log10): fix for Bignum argument.
  numbits should be add only when right shifted.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43080 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-28 14:25:59 +00:00
nobu e146015272 bignum.c, math.c: RB_BIGNUM_TYPE_P
* bignum.c, math.c (RB_BIGNUM_TYPE_P): predicate macro like
  RB_FLOAT_TYPE_P.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-07 19:04:23 +00:00
nobu c26293dccf bignum.c, math.c: type predicates
* bignum.c, math.c: use type predicate macros instead of TYPE().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-07 19:04:18 +00:00
akr 0e02d92371 * math.c (math_log): Test the sign for bignums.
(math_log2): Ditto.
  (math_log10): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-07 12:34:09 +00:00
akr 08e3cb6959 * math.c (math_log): Support bignums bigger than 2**1024.
(math_log2): Ditto.
  (math_log10): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-07 11:26:52 +00:00
akr bd15d4ca78 * internal.h (numberof): Gathered from various files.
* array.c, math.c, thread_pthread.c, iseq.c, enum.c, string.c, io.c,
  load.c, compile.c, struct.c, eval.c, gc.c, parse.y, process.c,
  error.c, ruby.c: Remove the definitions of numberof.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 10:01:19 +00:00
nobu 021c2102dc math.c: ASCII minus
* math.c: use ASCII minus (-) instead of U+2212.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-02 05:59:40 +00:00
eregon 46cb75db9b * math.c: improve and fix documentation of sin, tan and log
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-20 10:35:26 +00:00
zzak c1f176974c * math.c: RDoc formatting of Math core docs with domains and codomains
Patch by @eLobato [Fixes GH-309]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-19 22:29:26 +00:00
tadf c07d295204 * include/ruby/util.h: removed extra semicolon in definition of
macro.
	* compile.c: ditto.
	* cont.c: ditto.
	* math.c: ditto.
	* node.c: ditto.
	* parse.y: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-21 12:42:11 +00:00
akr 2bb5441808 * complex.c: use "__sun" instead of "__sun__" to detect SunOS.
* math.c: ditto.

* hash.c: ditto.

* atomic.h: ditto.

* ext/io/wait/wait.c: ditto.

[ruby-dev:44693]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33521 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-24 14:57:08 +00:00