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

155 Коммитов

Автор SHA1 Сообщение Дата
Marcus Stollsteimer 3108ad7bf3 [DOC] Fix grammar: "is same as" -> "is the same as" 2021-01-05 15:13:53 +01:00
卜部昌平 9e41a75255 sed -i 's|ruby/impl|ruby/internal|'
To fix build failures.
2020-05-11 09:24:08 +09:00
卜部昌平 d7f4d732c1 sed -i s|ruby/3|ruby/impl|g
This shall fix compile errors.
2020-05-11 09:24:08 +09:00
卜部昌平 9e6e39c351
Merge pull request #2991 from shyouhei/ruby.h
Split ruby.h
2020-04-08 13:28:13 +09:00
卜部昌平 5e22f873ed decouple 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).
2019-12-26 20:45:12 +09:00
Marcus Stollsteimer 0231661939 [DOC] Fix wording in Math::E documentation 2019-12-24 00:13:46 +01:00
卜部昌平 0e8219f591 make functions static
These functions are used from within a compilation unit so we can
make them static, for better binary size.  This changeset reduces
the size of generated ruby binary from 26,590,128 bytes to
26,584,472 bytes on my macihne.
2019-11-19 12:36:19 +09:00
schneems 94b79bffb1 Add word "Euler's number" to Math::E docs
When searching for this constant, I landed on the correct page https://ruby-doc.org/core-2.6.4/Math.html however I was using CMD+f to search for "Euler" and did not find it. If we add the full name for this constant then it will be easier to search for and find.
2019-08-29 11:57:23 -07:00
nobu c995315153 math.c: adjust cbrt
* math.c (math_cbrt): refine the approximation result on boundary
  values by an iteration of Newton-Raphson method.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63592 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-06 14:01:43 +00:00
nobu 61a85f91a2 math.c: calling order
* math.c (math_log, rb_math_log): inverted calling order, to
  remove unused argument.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-09 03:57:34 +00:00
shyouhei 3ca0948f68 INFINITY is float. That of double is HUGE_VAL.
It seems HUGE_VAL is already used. Why not eliminate INTINITY.
NAN is also float. That of double is called nan(). This is also
fixed.

Signed-off-by: Urabe, Shyouhei <shyouhei@ruby-lang.org>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-19 01:45:36 +00:00
nobu d3ca0b29a6 math.c: check argument to lgamma_r
* math.c (math_lgamma): check the argument before calling math
  function `lgamma_r` for edge cases.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58698 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-13 01:05:30 +00:00
nobu 1a4a536247 math.c: check argument to tgamma
* math.c (math_gamma): check the argument before calling math
  function `tgamma` for edge cases.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58697 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-13 00:50:20 +00:00
nobu 126aba8587 fix tgamma for inifity
* configure.in: do not use buggy tgamma() of mingw.

* missing/tgamma.c (tgamma): merge fix for inifity from
  ruby_tgamma.  since msvcr120.dll and later have tgamma, this
  implementation will not be used.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-12 16:12:46 +00:00
usa 0c16051114 Math.gamma(Float::INFINITY) should return +INF
* math.c (tgamma): it seems that the implementaion of mswin has similar problem
  with mingw.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-12 10:31:52 +00:00
nobu 7573452099 math.c (ruby_lgamma_r): reduce duplicate code
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-10 00:20:02 +00:00
stomar 4b5a2b5272 math.c: improve docs for Math.sqrt
* math.c: [DOC] mention Integer.sqrt in docs for Math.sqrt.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58582 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-06 07:28:40 +00:00
stomar 9638295527 math.c: improve docs for Math.sqrt
* math.c: [DOC] mention possibly surprising behavior of Math.sqrt
  due to floating point arithmetic; also refer to BigDecimal#sqrt.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58291 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-09 13:30:31 +00:00
nobu 01fb669423 math.c: more accuracy
* math.c (math_log10): calculate log10(2) for more accuracy.
  [ruby-core:79907] [Bug #13279]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57779 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-05 01:46:20 +00:00
nobu 378d0e6aca math.c: unused_obj
* math.c (exp1, exp2): use immediate 0 instead of rb_mMath, which
  is never used.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56833 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-19 01:55:34 +00:00
mrkn 558c362f60 math.c: remove needless ifdef clause
* math.c (ifdef M_PI): M_PI is eventually defined in missing.h even if math.h
  doesn't supply it.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-16 04:25:37 +00:00
nobu 4e44f6ef86 [DOC] replace Fixnum with Integer [ci skip]
* numeric.c: [DOC] update document for Integer class.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-26 06:11:23 +00:00
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