Project

General

Profile

Actions

Bug #3271

closed

BigMath.power が遅い

Added by mrkn (Kenta Murata) over 14 years ago. Updated over 13 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 1.9.3dev (2010-05-11 trunk 27729) [x86_64-darwin10.3.0]
Backport:

Description

=begin
Rubyについて Part 40
http://pc12.2ch.net/test/read.cgi/tech/1272248179/121-122

んで、powerも全部の桁を計算してご苦労さんなんだが、integerではないのだから、そんなに気張らなくても..
とは、思います。
expと同じ要領でやると、実行速度がずいぶん速くなります。
(Rubyのコードからpowerをcallするんだが、それでもとても速い。
ソースを書き換える手もあるのだけど、コンパイルするのがめんどくさい。
そもそも、その手の労力を厭わない人は、こっちに来なくて良いでしょ)
=end


Related issues 3 (0 open3 closed)

Related to Ruby master - Bug #3267: BigDecimal/mathでatan()に1.08を入れると戻り値の有効桁数が足りないClosedmrkn (Kenta Murata)05/11/2010Actions
Related to Ruby master - Bug #3270: BigMath.exp が絶対値が大きな引数で遅いClosedmrkn (Kenta Murata)Actions
Has duplicate Ruby master - Bug #3272: BigDecimal#** が実用的な速度ではないClosedmrkn (Kenta Murata)05/11/2010Actions
Actions #1

Updated by mrkn (Kenta Murata) over 14 years ago

  • Status changed from Open to Assigned

=begin

=end

Updated by nahi (Hiroshi Nakamura) over 13 years ago

  • Target version changed from 2.0.0 to 1.9.3
Actions #3

Updated by mrkn (Kenta Murata) over 13 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r32485.
Kenta, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • ext/bigdecimal/bigdecimal.c (BigDecimal_power): support non-integral
    exponent. fixes #3271
  • ext/bigdecimal/bigdecimal.c (rmpd_power_by_big_decimal): ditto.
  • ext/bigdecimal/bigdecimal.c (BigDecimal_power_op): add a function to
    only use for "**" operator.
  • test/bigdecimal/test_bigdecimal.rb: add a bunch of tests for the
    above changes.
  • ext/bigdecimal/bigdecimal.c (is_integer): add an utility function.
  • ext/bigdecimal/bigdecimal.c (is_negative): ditto.
  • ext/bigdecimal/bigdecimal.c (is_positive): ditto.
  • ext/bigdecimal/bigdecimal.c (is_zero): ditto.
  • ext/bigdecimal/bigdecimal.c (is_one): ditto.
  • ext/bigdecimal/bigdecimal.c (is_even): ditto.
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0