Ruby | Matrix permutation? function Last Updated : 12 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The permutation?() is an inbuilt method in Ruby returns a boolean value. It returns true if it is a permutation matrix, else it returns false. It returns error if anything other than square matrix is used. Syntax: mat1.permutation?() Parameters: The function needs the matrix to be checked for permutation matrix or not. Return Value: It returns true if it is a permutation matrix, else it returns false. Example 1: CPP #Ruby program for permutation ? () method in Matrix #Include matrix require "matrix" #Initialize a matrix mat1 = Matrix[[ 1, 21 ], [ 31, 18 ]] #Prints if permutation ? or not puts mat1.permutation ? () Output: false Example 2: CPP #Ruby program for permutation ? () method in Matrix #Include matrix require "matrix" #Initialize a matrix mat1 = Matrix[[ 1, 0 ], [ 0, 1 ]] #Prints if permutation ? or not puts mat1.permutation ? () Output: true Comment More infoAdvertise with us Next Article Ruby | Matrix to_matrix() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Matrix-class Similar Reads Ruby | Matrix rank() function The rank() is an inbuilt method in Ruby returns the rank of the given matrix. The float values can yield enormous results due to float precision Syntax: mat1.rank() Parameters: The function does not accepts any parameter. Return Value: It returns the rank of the current matrix. Example 1: CPP #Ruby 1 min read Ruby | Matrix minor() function The minor() is an inbuilt method in Ruby returns a section of the matrix. It either returns a matrix by taking the starting row, end row, start column, end column or by taking the range of rows and columns. Syntax: mat1.minor(start_row, end_row, start_col, end_col) or mat1.minor(row1..row2, col1..co 1 min read Ruby | Matrix row() function The row() is an inbuilt method in Ruby returns a vector that contains all the elements in the given row-number. Syntax: mat1.row(num) Parameters: The function takes a mandatory parameter row, whose elements are to be returned in a vector. Return Value: It returns a vector containing all the elements 1 min read Ruby | Matrix to_matrix() function 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: Ruby # Ruby program for to_matrix() method in Matrix # Include matrix 1 min read Ruby | Matrix regular?() function The regular?() is an inbuilt method in Ruby returns a boolean value. It returns true if it is a regular matrix, else it returns false. Syntax: mat1.regular?() Parameters: The function needs the matrix to be checked for regular matrix or not. Return Value: It returns true if it is a regular matrix, e 1 min read Ruby | Array permutation() function Array#permutation() : permutation() is a Array class method which returns all permutations of length n of the elements of the array, then return the array itself. Syntax: Array.permutation() Parameter: Array Return: all permutations of length n of the elements of the array, then return the array its 2 min read Like