Ruby | Matrix upper_triangular?() function
Last Updated :
07 Jan, 2020
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:
require "matrix"
mat1 = Matrix[[ 1 , 21 ], [ 31 , 18 ]]
puts mat1.upper_triangular?()
|
Output:
false
Example 2:
require "matrix"
mat1 = Matrix[[ 31 , 18 , 19 ], [ 0 , 3 , 2 ], [ 0 , 0 , 1 ]]
puts mat1.upper_triangular?()
|
Output:
true
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...