ruby-changes:23792
From: mrkn <ko1@a...>
Date: Wed, 30 May 2012 16:27:02 +0900 (JST)
Subject: [ruby-changes:23792] mrkn:r35843 (trunk): * ext/bigdecimal/lib/bigdecimal/jacobian.rb (Jacobian#dfdxi):
mrkn 2012-05-30 16:26:51 +0900 (Wed, 30 May 2012) New Revision: 35843 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35843 Log: * 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 Modified files: trunk/ChangeLog trunk/ext/bigdecimal/lib/bigdecimal/jacobian.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 35842) +++ ChangeLog (revision 35843) @@ -1,3 +1,10 @@ +Wed May 30 16:20:00 2012 Kenta Murata <mrkn@c...> + + * 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@r...> * time.c (utc_offset_arg): utc offset can be precision in seconds. Index: ext/bigdecimal/lib/bigdecimal/jacobian.rb =================================================================== --- ext/bigdecimal/lib/bigdecimal/jacobian.rb (revision 35842) +++ ext/bigdecimal/lib/bigdecimal/jacobian.rb (revision 35843) @@ -53,7 +53,8 @@ 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/