Ruby | Matrix to_matrix()-Funktion
to_matrix () ist eine eingebaute Methode in Ruby , die eine Matrix zurückgibt, die nur self ist.
Syntax : mat1.to_matrix()
Parameter : Die Funktion benötigt die Matrix, die zurückgegeben werden soll.
Rückgabewert : Gibt eine Matrix oder ein Selbst zurück.
Beispiel 1 :
# Ruby program for to_matrix() method in Matrix # Include matrix require "matrix" # Initialize a matrix mat1 = Matrix[[3, 12], [2, 8]] # Prints the to_matrix matrix puts mat1.to_matrix()
Ausgang :
Matrix[[3, 12], [2, 8]]
Beispiel 2 :
# Ruby program for to_matrix() method in Matrix # Include matrix require "matrix" # Initialize a matrix mat1 = Matrix[[1, 0], [6, 1], [1, 2]] # Prints the to_matrix matrix puts mat1.to_matrix()
Ausgang :
Matrix[[1, 0], [6, 1], [1, 2]]