diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | ext/bigdecimal/lib/bigdecimal/jacobian.rb | 3 |
2 files changed, 9 insertions, 1 deletions
@@ -1,3 +1,10 @@ +Wed May 30 16:20:00 2012 Kenta Murata <mrkn@cookpad.com> + + * ext/bigdecimal/lib/bigdecimal/jacobian.rb (Jacobian#dfdxi): + fix jacobian to get stuck in an infinite loop when a solution is not + found due to forget to increment nRetry counter. + Patch by alperakgun from github.com/shyouhei/ruby/pull/8 + Wed May 30 10:58:31 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> * time.c (utc_offset_arg): utc offset can be precision in seconds. diff --git a/ext/bigdecimal/lib/bigdecimal/jacobian.rb b/ext/bigdecimal/lib/bigdecimal/jacobian.rb index 8ab836259a..f53e5b1437 100644 --- a/ext/bigdecimal/lib/bigdecimal/jacobian.rb +++ b/ext/bigdecimal/lib/bigdecimal/jacobian.rb @@ -53,7 +53,8 @@ module Jacobian until ok>0 do s = f.zero deriv = [] - if(nRetry>100) then + nRetry += 1 + if nRetry > 100 raise "Singular Jacobian matrix. No change at x[" + i.to_s + "]" end dx = dx*f.two |