summaryrefslogtreecommitdiff
path: root/lib/matrix.rb
diff options
context:
space:
mode:
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-04-06 17:45:07 +0000
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-04-06 17:45:07 +0000
commitbcf8dd1096bc3660b2f56b0c70d00c33c79c995d (patch)
treeea2e910f0f35d0d79313cf4ad0ef25a260ff55c5 /lib/matrix.rb
parenta237db5cbc3e3093330c20b26a97320262ee7b16 (diff)
* lib/matrix: Handle empty diagonal matrix case [fix GH-576]
Patch by gogotanaka git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45524 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/matrix.rb')
-rw-r--r--lib/matrix.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/matrix.rb b/lib/matrix.rb
index f82ed65..e0995c3 100644
--- a/lib/matrix.rb
+++ b/lib/matrix.rb
@@ -204,6 +204,7 @@ class Matrix
#
def Matrix.diagonal(*values)
size = values.size
+ return Matrix.empty if size == 0
rows = Array.new(size) {|j|
row = Array.new(size, 0)
row[j] = values[j]