From ecb6bd90c01edc19165ff526ef15a59693b4f12f Mon Sep 17 00:00:00 2001 From: mrkn Date: Wed, 30 May 2012 07:26:51 +0000 Subject: * 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 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35843 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/bigdecimal/lib/bigdecimal/jacobian.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'ext/bigdecimal/lib/bigdecimal') 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 -- cgit v1.2.3