1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/matrix.rb (Matrix::inverse_from): adding partial pivoting to

the Gauss-Jordan algorithm, making it stable.  a patch from
  Peter Vanbroekhoven.  [ruby-core:10641]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@12105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
knu 2007-03-20 02:29:09 +00:00
parent d4fb0b1f6d
commit fd08f3ac6b
2 changed files with 18 additions and 6 deletions

View file

@ -1,3 +1,9 @@
Tue Mar 20 11:28:41 2007 Akinori MUSHA <knu@iDaemons.org>
* lib/matrix.rb (Matrix::inverse_from): adding partial pivoting to
the Gauss-Jordan algorithm, making it stable. a patch from
Peter Vanbroekhoven. [ruby-core:10641]
Mon Mar 19 11:39:29 2007 Minero Aoki <aamine@loveruby.net>
* lib/net/protocol.rb (rbuf_read): extend buffer size for speed.

View file

@ -590,15 +590,21 @@ class Matrix
a = src.to_a
for k in 0..size
if (akk = a[k][k]) == 0
i = k
begin
Matrix.Raise ErrNotRegular if (i += 1) > size
end while a[i][k] == 0
i = k
akk = a[k][k].abs
for j in (k+1)..size
v = a[j][k].abs
if v > akk
i = j
akk = v
end
end
Matrix.Raise ErrNotRegular if akk == 0
if i != k
a[i], a[k] = a[k], a[i]
@rows[i], @rows[k] = @rows[k], @rows[i]
akk = a[k][k]
end
akk = a[k][k]
for i in 0 .. size
next if i == k