Ruby | Matrix upper_triangular?() function Last Updated : 07 Jan, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report The upper_triangular?() is an inbuilt method in Ruby returns a boolean value. It returns true if it is a lower-triangular matrix, else it returns false. Syntax: mat1.upper_triangular?() Parameters: The function needs the matrix to be checked for lower-triangular. Return Value: It returns true if it is a lower-triangular matrix, else it returns false. Example 1: Ruby # Ruby program for upper_triangular?() method in Matrix # Include matrix require "matrix" # Initialize a matrix mat1 = Matrix[[1, 21], [31, 18]] # Prints if upper_triangular or not puts mat1.upper_triangular?() Output: false Example 2: Ruby # Ruby program for upper_triangular?() method in Matrix # Include matrix require "matrix" # Initialize a matrix mat1 = Matrix[[31, 18, 19], [0, 3, 2], [0, 0, 1]] # Prints if upper_triangular or not puts mat1.upper_triangular?() Output: true Comment More infoAdvertise with us Next Article Ruby | Matrix upper_triangular?() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Matrix-class Similar Reads Ruby | Matrix singular?() function The singular?() is an inbuilt method in Ruby returns a boolean value. It returns true if it is a singular matrix, else it returns false. It returns error if anything other than square matrix is used. Syntax: mat1.singular?() Parameters: The function needs the matrix to be checked for singular matrix 1 min read Ruby | Matrix lower_triangular? function The lower_triangular?() is an inbuilt method in Ruby returns a boolean value. It returns true if it is a lower-triangular matrix, else it returns false. Syntax: mat1.lower_triangular?() Parameters: The function needs the matrix to be checked for lower-triangular. Return Value: It returns true if it 1 min read Ruby | Matrix transpose() function The transpose() is an inbuilt method in Ruby returns the transpose of the matrix. Syntax: mat1.transpose() Parameters: The function needs the matrix to be transposed. Return Value: It returns the transposed matrix. Example 1: Ruby # Ruby program for transpose() method in Matrix # Include matrix requ 1 min read Ruby | Matrix trace() function The trace() is an inbuilt method in Ruby returns the trace i.e., sum of diagonal elements of the matrix. Syntax: mat1.trace() Parameters: The function needs the matrix whose trace is to be returned. Return Value: It returns the trace. Example 1: Ruby # Ruby program for trace() method in Matrix # Inc 1 min read Ruby | Matrix square?() function The square?() is an inbuilt method in Ruby returns a boolean value. It returns true if it is a square matrix, else it returns false. Syntax: mat1.square?() Parameters: The function needs the matrix to be checked for square matrix or not. Return Value: It returns true if it is a square matrix, else i 1 min read Like