method
rows
ruby latest stable - Class:
Matrix
rows(rows, copy = true)public
Creates a matrix where rows is an array of arrays, each of which is a row of the matrix. If the optional argument copy is false, use the given arrays as the internal structure of the matrix without copying.
Matrix .rows ([[25, 93], [-1, 66]]) => 25 93 -1 66
# File lib/matrix.rb, line 62
def Matrix.rows(rows, copy = true)
rows = convert_to_array(rows, copy)
rows.map! do |row|
convert_to_array(row, copy)
end
size = (rows[0] || []).size
rows.each do |row|
raise ErrDimensionMismatch, "row size differs (#{row.size} should be #{size})" unless row.size == size
end
new rows, size
end