Method: Matrix.vstack
- Defined in:
- lib/matrix.rb
.vstack(x, *matrices) ⇒ Object
241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/matrix.rb', line 241 def Matrix.vstack(x, *matrices) x = CoercionHelper.coerce_to_matrix(x) result = x.send(:rows).map(&:dup) matrices.each do |m| m = CoercionHelper.coerce_to_matrix(m) if m.column_count != x.column_count raise ErrDimensionMismatch, "The given matrices must have #{x.column_count} columns, but one has #{m.column_count}" end result.concat(m.send(:rows)) end new result, x.column_count end |