Skip to content
Related Articles

Related Articles

Ruby | Matrix column_vectors() function
  • Last Updated : 07 Jan, 2020

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 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 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]
My Personal Notes arrow_drop_up
Recommended Articles
Page :