Ruby | Matrix eigen() function Last Updated : 12 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The eigen() is an inbuilt method in Ruby returns the Eigensystem of the matrix. Syntax: mat1.eigen() Parameters: The function does not accepts any parameter. Return Value: It returns the Eigensystem of the matrix. Example 1: Ruby # Ruby program for eigen() method in Matrix # Include matrix require "matrix" # Initialize a matrix mat1 = Matrix[[1, 0], [0, 2]] # prints the eigensystem puts mat1.eigen() Output: Matrix[[1.0, 0.0], [0.0, 1.0]] Matrix[[1.0, 0], [0, 2.0]] Matrix[[1.0, 0.0], [0.0, 1.0]] Example 2: Ruby # Ruby program for eigen() method in Matrix # Include matrix require "matrix" # Initialize a matrix mat1 = Matrix[[1, 1, 5], [4, 1, 5], [11, 2, 12]] # prints the eigensystem puts mat1.eigen() Output: Matrix[[0.3051508362231803, 0.8432205915902499, -0.04211389264475984], [0.36021591185448126, -0.07469426749056905, -1.0068644256268935], [0.881548333331269, -0.6184679554209885, 0.20869263449203795]] Matrix[[16.624920572145022, 0, 0], [0, -2.7558784453101666, 0], [0, 0, 0.13095787316514576]] Matrix[[0.6383015261676529, 0.14992783363808046, 0.8521544829905635], [0.9627740639327973, -0.10080816379994396, -0.2920754272026449], [0.15693539149903699, -0.9320657209209471, 0.3265344924799822]] Comment More infoAdvertise with us Next Article Ruby | Matrix element() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Matrix-class Similar Reads Ruby | Matrix eigensystem() function The eigensystem() is an inbuilt method in Ruby returns the Eigensystem of the matrix. Syntax: mat1.eigensystem() Parameters: The function does not accepts any parameter. Return Value: It returns the Eigensystem of the matrix. Example 1: Ruby # Ruby program for eigensystem() method in Matrix # Includ 1 min read Ruby | Matrix element() function The element() is an inbuilt method in Ruby returns the element present at the intersection of i-th row and j-th column. Syntax: mat1.element(i, j) Parameters: The function accepts two parameters i and j which signifies the row_number and column_number. Return Value: It returns the element at mat[i][ 1 min read Ruby | Matrix eql? function The eql? is an inbuilt method in Ruby returns a boolean value. It returns true if both the matrix are equal or else it returns false.. Syntax: mat1.eql?(mat2)Parameters: The function need two matrix mat1 and mat2 which are to be compared.Return Value: It returns true if both the matrix are equal or 1 min read Ruby | Matrix det() function The det() is an inbuilt method in Ruby returns the determinant of the given matrix Syntax: mat1.det() Parameters: The function does not accepts any parameter. Return Value: It returns the determinant of the given matrix. Example 1: Ruby # Ruby program for det() method in Matrix # Include matrix requ 1 min read Ruby | Matrix diagonal() function The diagonal is an inbuilt method in Ruby returns a matrix with diagonal elements as the given values. Syntax: mat1.diagonal(val1, val2, val3 ...) Parameters: The function accepts the values which are to be placed in the diagonal of the matrix. Return Value: It returns matrix with values val1, val2, 1 min read Ruby | Matrix diagonal() function The diagonal() is an inbuilt method in Ruby returns true if the given matrix is diagonal, else it returns false. A diagonal matrix is a matrix in which the entries outside the main diagonal are all zero. Syntax: mat1.diagonal() Parameters: The function does not accepts any parameter. Return Value: I 1 min read Like