Ruby | Matrix row_vectors() function Last Updated : 07 Jan, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report The row_vectors() is an inbuilt method in Ruby returns vectors which represents each row in the matrix. Syntax: mat1.row_vectors() Parameters: The function does not takes any mandatory parameter. Return Value: It returns vectors representing the rows. Example 1: Ruby # Ruby program for row_vectors() method in Matrix # Include matrix require "matrix" # Initialize a matrix mat1 = Matrix[[6, 432], [54, 323]] # Prints the rows in vectors puts mat1.row_vectors() Output: Vector[6, 432] Vector[54, 323] Example 2: Ruby # Ruby program for row_vectors() method in Matrix # Include matrix require "matrix" # Initialize a matrix mat1 = Matrix[[1, 1, 1],[2, 2, 2],[3, 5, 6]] # Prints the rows in vectors puts mat1.row_vectors() Output: Vector[1, 1, 1] Vector[2, 2, 2] Vector[3, 5, 6] Comment More infoAdvertise with us Next Article Ruby | Matrix row() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Matrix-class Similar Reads Ruby | Vector to_matrix() function The to_matrix() is an inbuilt method in Ruby returns the matrix of single column with elements of vector. Syntax: vec1.to_matrix() Parameters: The function accepts no parameter Return Value: It returns the matrix of single column with elements of vector Example 1: Ruby # Ruby program for to_matrix() 1 min read Ruby | Matrix row() function The row() is an inbuilt method in Ruby returns a vector that contains all the elements in the given row-number. Syntax: mat1.row(num) Parameters: The function takes a mandatory parameter row, whose elements are to be returned in a vector. Return Value: It returns a vector containing all the elements 1 min read Ruby | Matrix row_size() function The row_size() is an inbuilt method in Ruby returns the number of rows in the given matrix. Syntax: mat1.row_size() Parameters: The function does not takes any mandatory parameter. Return Value: It returns the number of rows in the matrix. Example 1: Ruby # Ruby program for row_size() method in Matr 1 min read Ruby | Matrix column_vectors() function The column_vectors() is an inbuilt method in Ruby returns an array of vectors containing the columns. Syntax: mat1.column_vectors() Parameters: The function does not accepts any parameter. Return Value: It returns an array of vectors containing all the columns. Example 1: Ruby # Ruby program for col 1 min read Ruby | Matrix tr() function The tr() is an inbuilt method in Ruby returns the trace i.e., sum of diagonal elements of the matrix. Syntax: mat1.tr() Parameters: The function needs the matrix whose trace is to be returned. Return Value: It returns the trace. Example 1: Ruby # Ruby program for tr() method in Matrix # Include matr 1 min read Ruby | Matrix to_a() function The to_a() is an inbuilt method in Ruby returns an array which has all the elements of the matrix row-wise. Syntax: mat1.to_a() Parameters: The function needs the matrix which is to be converted to an array. Return Value: It returns an array. Example 1: Ruby # Ruby program for to_a() method in Matri 1 min read Like