* lib/matrix/lup_decomposition: Fix bugs with LUP Decomposition of

rectangular matrices. [rubyspec:ba849801a85]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38807 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
marcandre 2013-01-13 22:13:12 +00:00
parent d5b62c3aa1
commit 1f4c792072
2 changed files with 9 additions and 4 deletions

View File

@ -1,3 +1,8 @@
Mon Jan 14 07:12:52 2013 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
* lib/matrix/lup_decomposition: Fix bugs with LUP Decomposition of
rectangular matrices. [rubyspec:ba849801a85]
Mon Jan 14 06:46:53 2013 NARUSE, Yui <naruse@ruby-lang.org> Mon Jan 14 06:46:53 2013 NARUSE, Yui <naruse@ruby-lang.org>
* regparse.c (add_ctype_to_cc): don't check dup warn on adding * regparse.c (add_ctype_to_cc): don't check dup warn on adding

View File

@ -19,7 +19,7 @@ class Matrix
include Matrix::ConversionHelper include Matrix::ConversionHelper
def l def l
Matrix.build(@row_count, @column_count) do |i, j| Matrix.build(@row_count, [@column_count, @row_count].min) do |i, j|
if (i > j) if (i > j)
@lu[i][j] @lu[i][j]
elsif (i == j) elsif (i == j)
@ -33,7 +33,7 @@ class Matrix
# Returns the upper triangular factor +U+ # Returns the upper triangular factor +U+
def u def u
Matrix.build(@column_count, @column_count) do |i, j| Matrix.build([@column_count, @row_count].min, @column_count) do |i, j|
if (i <= j) if (i <= j)
@lu[i][j] @lu[i][j]
else else
@ -45,9 +45,9 @@ class Matrix
# Returns the permutation matrix +P+ # Returns the permutation matrix +P+
def p def p
rows = Array.new(@row_count){Array.new(@column_count, 0)} rows = Array.new(@row_count){Array.new(@row_count, 0)}
@pivots.each_with_index{|p, i| rows[i][p] = 1} @pivots.each_with_index{|p, i| rows[i][p] = 1}
Matrix.send :new, rows, @column_count Matrix.send :new, rows, @row_count
end end
# Returns +L+, +U+, +P+ in an array # Returns +L+, +U+, +P+ in an array