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:
require "matrix"
mat1 = Matrix[[ 1 , 21 ], [ 31 , 18 ]]
puts mat1.column_vectors
|
Output:
Vector[1, 31]
Vector[21, 18]
Example 2:
require "matrix"
mat1 = Matrix[[ 13 , 1 , 5 ], [ 12 , 1 , 5 ], [ 11 , 2 , 5 ]]
puts mat1.column_vectors
|
Output:
Vector[13, 12, 11]
Vector[1, 1, 2]
Vector[5, 5, 5]
Share your thoughts in the comments
Please Login to comment...