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:
require "matrix"
mat1 = Matrix[[ 6 , 432 ], [ 54 , 323 ]]
puts mat1.row_vectors()
|
Output:
Vector[6, 432]
Vector[54, 323]
Example 2:
require "matrix"
mat1 = Matrix[[ 1 , 1 , 1 ],[ 2 , 2 , 2 ],[ 3 , 5 , 6 ]]
puts mat1.row_vectors()
|
Output:
Vector[1, 1, 1]
Vector[2, 2, 2]
Vector[3, 5, 6]
Last Updated :
07 Jan, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...