method
vstack
ruby latest stable - Class:
Matrix
vstack(x, *matrices)public
Create a matrix by stacking matrices vertically
x = Matrix [[1, 2], [3, 4]] y = Matrix [[5, 6], [7, 8]] Matrix .vstack (x, y) # => Matrix[[1, 2], [3, 4], [5, 6], [7, 8]]
# File lib/matrix.rb, line 213
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