Bug #7777 ยป matrix.rb.raise.patch
lib/matrix.rb (working copy) | ||
---|---|---|
end
|
||
size = (rows[0] || []).size
|
||
rows.each do |row|
|
||
Matrix.Raise ErrDimensionMismatch, "row size differs (#{row.size} should be #{size})" unless row.size == size
|
||
raise ErrDimensionMismatch, "row size differs (#{row.size} should be #{size})" unless row.size == size
|
||
end
|
||
new rows, size
|
||
end
|
||
... | ... | |
# => Matrix[[0, 0, 0], [0, 0, 0]]
|
||
#
|
||
def Matrix.empty(row_count = 0, column_count = 0)
|
||
Matrix.Raise ArgumentError, "One size must be 0" if column_count != 0 && row_count != 0
|
||
Matrix.Raise ArgumentError, "Negative size" if column_count < 0 || row_count < 0
|
||
raise ArgumentError, "One size must be 0" if column_count != 0 && row_count != 0
|
||
raise ArgumentError, "Negative size" if column_count < 0 || row_count < 0
|
||
new([[]]*row_count, column_count)
|
||
end
|
||
... | ... | |
end
|
||
end
|
||
else
|
||
Matrix.Raise ArgumentError, "expected #{which.inspect} to be one of :all, :diagonal, :off_diagonal, :lower, :strict_lower, :strict_upper or :upper"
|
||
raise ArgumentError, "expected #{which.inspect} to be one of :all, :diagonal, :off_diagonal, :lower, :strict_lower, :strict_upper or :upper"
|
||
end
|
||
self
|
||
end
|
||
... | ... | |
end
|
||
end
|
||
else
|
||
Matrix.Raise ArgumentError, "expected #{which.inspect} to be one of :all, :diagonal, :off_diagonal, :lower, :strict_lower, :strict_upper or :upper"
|
||
raise ArgumentError, "expected #{which.inspect} to be one of :all, :diagonal, :off_diagonal, :lower, :strict_lower, :strict_upper or :upper"
|
||
end
|
||
self
|
||
end
|
||
... | ... | |
from_row += row_count if from_row < 0
|
||
from_col += column_count if from_col < 0
|
||
else
|
||
Matrix.Raise ArgumentError, param.inspect
|
||
raise ArgumentError, param.inspect
|
||
end
|
||
return nil if from_row > row_count || from_col > column_count || from_row < 0 || from_col < 0
|