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/trunk@12096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
33163ad123
commit
de3770d158
2 changed files with 18 additions and 6 deletions
|
@ -1,3 +1,9 @@
|
|||
Mon Mar 19 14:12:25 2007 Yukihiro Matsumoto <matz@ruby-lang.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 12:13:36 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* regparse.c, etc.: K&R to ANSI code cleanup patch from Stefan
|
||||
|
|
|
@ -599,15 +599,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
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue