Open In App

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]

Similar Reads