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

170 Коммитов

Автор SHA1 Сообщение Дата
Nobuyoshi Nakada 50520cc193
[DOC] Missing comment markers 2023-09-27 16:18:05 +09:00
Yusuke Endoh a0e6687305 Use log2(b) instead of (log(b) / M_LN2)
Co-Authored-By: Nobuyoshi Nakada <nobu@ruby-lang.org>
2023-09-13 21:40:05 +09:00
Yusuke Endoh 411572661a math.c: Fix Math.log against huge bignum [Bug #19878] 2023-09-13 21:40:05 +09:00
Nobuyoshi Nakada 105bdba899
Fix logarithm of 0 with base 2023-07-17 23:57:11 +09:00
Nobuyoshi Nakada da39936ce1
Prefer integer as base of intermediate logarithms
As long as "floating point numbers" cannot accurately represent an
irrational number, the result of the natural logarithm cannot be
accurate.  Logarithms with an integer base may have the possibility to
represent more accurately.
2023-07-16 01:24:44 +09:00
S-H-GAMELINKS 38ef5f7b35 Introduce math_arc macro 2023-05-13 14:54:18 +09:00
Takashi Kokubun 5b21e94beb Expand tabs [ci skip]
[Misc #18891]
2022-07-21 09:42:04 -07:00
Burdette Lamar 69c1145fa8
[DOC] Enhanced RDoc for Math module (#5837)
Revises intro.
    Adds "What's Here".
    Revises methods doc.
2022-04-25 10:07:21 -05:00
S-H-GAMELINKS 83a5e2bb5c Using RB_FLOAT_TYPE_P macro 2021-09-12 11:16:31 +09:00
S-H-GAMELINKS 032534dbdf Using RB_BIGNUM_TYPE_P macro 2021-09-11 09:13:24 +09:00
Nobuyoshi Nakada 80c1faf076
Use C99-defined signbit macro 2021-08-27 12:42:23 +09:00
S.H 58bd943436
Replace f_boolcast with RBOOL macro
* Move f_boolcast definination

* Remove f_boolcast macro defination

* to
2021-08-18 02:25:19 +09:00
Nobuyoshi Nakada 0a32cefabd
Add domain check macros 2021-07-04 22:15:59 +09:00
Nobuyoshi Nakada 2488589b2f
Removed extra double quotes from domain error messages 2021-07-04 15:28:25 +09:00
Jeremy Evans 406ae7fb03 Fix Math.cbrt(0.0) on glibc
This should return 0, but on glibc it returned NaN.

Fixes [Bug #17804]
2021-05-08 14:45:30 -07:00
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