Bug #3271

BigMath.power が遅い

Added by Kenta Murata almost 4 years ago. Updated almost 3 years ago.

Status:Closed
Priority:Normal
Assignee:Kenta Murata
Category:lib
Target version:1.9.3
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

Related to ruby-trunk - Bug #3267: BigDecimal/mathでatan()に1.08を入れると戻り値の有効桁数が足りない Closed 05/11/2010
Related to ruby-trunk - Bug #3270: BigMath.exp が絶対値が大きな引数で遅い Assigned 05/11/2010
Duplicated by ruby-trunk - Bug #3272: BigDecimal#** が実用的な速度ではない Closed 05/11/2010

Associated revisions

Revision 32485
Added by Kenta Murata almost 3 years ago

  • ext/bigdecimal/bigdecimal.c (BigDecimal_power): support non-integral exponent. fixes #3271
  • ext/bigdecimal/bigdecimal.c (rmpdpowerbybigdecimal): ditto.
  • ext/bigdecimal/bigdecimal.c (BigDecimalpowerop): 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.

History

#1 Updated by Kenta Murata almost 4 years ago

  • Status changed from Open to Assigned

=begin

=end

#2 Updated by Hiroshi Nakamura almost 3 years ago

  • Target version changed from 2.0.0 to 1.9.3

#3 Updated by Kenta Murata almost 3 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 (rmpdpowerbybigdecimal): ditto.
  • ext/bigdecimal/bigdecimal.c (BigDecimalpowerop): 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.

Also available in: Atom PDF