Ruby | Matrix column_vectors() function Last Updated : 07 Jan, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 column_vectors() method in Matrix # Include matrix require "matrix" # Initialize a matrix mat1 = Matrix[[1, 21], [31, 18]] # prints the columns puts mat1.column_vectors Output: Vector[1, 31] Vector[21, 18] Example 2: Ruby # Ruby program for column_vectors() method in Matrix # Include matrix require "matrix" # Initialize a matrix mat1 = Matrix[[13, 1, 5], [12, 1, 5], [11, 2, 5]] # prints the columns puts mat1.column_vectors Output: Vector[13, 12, 11] Vector[1, 1, 2] Vector[5, 5, 5] Comment More infoAdvertise with us Next Article Ruby | Matrix column_vectors() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Matrix-class Similar Reads Ruby | Matrix column() function The column() is an inbuilt method in Ruby returns a vector that has all the elements in the column number col_num. Syntax: mat1.column(col_num) Parameters: The function accepts a parameter col_num which is the column number. Return Value: It returns a vector which has all the elements of column col_ 1 min read Ruby | Matrix column_size() function The column_size() is an inbuilt method in Ruby returns the number of columns in a matrix. Syntax: mat1.column_size() Parameters: The function does not accepts any parameter. Return Value: It returns the number of columns in a matrix. Example 1: Ruby # Ruby program for column_size() method in Matrix 1 min read Ruby | Matrix row_vectors() function 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() 1 min read 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 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