Ruby | Matrix to_matrix() function
Last Updated :
07 Jan, 2020
The to_matrix() is an inbuilt method in Ruby returns a matrix which is self only.
Syntax: mat1.to_matrix()
Parameters: The function needs the matrix which is to be returned.
Return Value: It returns an matrix, or self.
Example 1:
require "matrix"
mat1 = Matrix[[ 3 , 12 ], [ 2 , 8 ]]
puts mat1.to_matrix()
|
Output:
Matrix[[3, 12], [2, 8]]
Example 2:
require "matrix"
mat1 = Matrix[[ 1 , 0 ], [ 6 , 1 ], [ 1 , 2 ]]
puts mat1.to_matrix()
|
Output:
Matrix[[1, 0], [6, 1], [1, 2]]
Share your thoughts in the comments
Please Login to comment...