[前][次][番号順一覧][スレッド一覧]

ruby-changes:26755

From: marcandre <ko1@a...>
Date: Mon, 14 Jan 2013 07:13:30 +0900 (JST)
Subject: [ruby-changes:26755] marcandRe: r38807 (trunk): * lib/matrix/lup_decomposition: Fix bugs with LUP Decomposition of

marcandre	2013-01-14 07:13:12 +0900 (Mon, 14 Jan 2013)

  New Revision: 38807

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38807

  Log:
    * lib/matrix/lup_decomposition: Fix bugs with LUP Decomposition of
      rectangular matrices. [rubyspec:ba849801a85]

  Modified files:
    trunk/ChangeLog
    trunk/lib/matrix/lup_decomposition.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38806)
+++ ChangeLog	(revision 38807)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Jan 14 07:12:52 2013  Marc-Andre Lafortune  <ruby-core@m...>
+
+	* lib/matrix/lup_decomposition: Fix bugs with LUP Decomposition of
+	  rectangular matrices. [rubyspec:ba849801a85]
+
 Mon Jan 14 06:46:53 2013  NARUSE, Yui  <naruse@r...>
 
 	* regparse.c (add_ctype_to_cc): don't check dup warn on adding
Index: lib/matrix/lup_decomposition.rb
===================================================================
--- lib/matrix/lup_decomposition.rb	(revision 38806)
+++ lib/matrix/lup_decomposition.rb	(revision 38807)
@@ -19,7 +19,7 @@ class Matrix https://github.com/ruby/ruby/blob/trunk/lib/matrix/lup_decomposition.rb#L19
     include Matrix::ConversionHelper
 
     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)
           @lu[i][j]
         elsif (i == j)
@@ -33,7 +33,7 @@ class Matrix https://github.com/ruby/ruby/blob/trunk/lib/matrix/lup_decomposition.rb#L33
     # Returns the upper triangular factor +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)
           @lu[i][j]
         else
@@ -45,9 +45,9 @@ class Matrix https://github.com/ruby/ruby/blob/trunk/lib/matrix/lup_decomposition.rb#L45
     # Returns the permutation matrix +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}
-      Matrix.send :new, rows, @column_count
+      Matrix.send :new, rows, @row_count
     end
 
     # Returns +L+, +U+, +P+ in an array

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]