Method: Matrix.empty
- Defined in:
- lib/y_support/stdlib_ext/matrix/misc.rb
.empty(row_size = 0, column_size = 0) ⇒ Object
Creates a empty matrix of row_size x column_size. At least one of row_size or column_size must be 0.
m = Matrix.empty(2, 0)
m == Matrix[ [], [] ]
=> true
n = Matrix.empty(0, 3)
n == Matrix.columns([ [], [], [] ])
=> true
m * n
=> Matrix[[0, 0, 0], [0, 0, 0]]
96 97 98 99 100 101 |
# File 'lib/y_support/stdlib_ext/matrix/misc.rb', line 96 def Matrix.empty(row_size = 0, column_size = 0) Matrix.Raise ArgumentError, "One size must be 0" if column_size != 0 && row_size != 0 Matrix.Raise ArgumentError, "Negative size" if column_size < 0 || row_size < 0 new([[]]*row_size, column_size) end |