Upper_triangular ?() ist eine eingebaute Methode in Ruby , die einen booleschen Wert zurückgibt. Es gibt true zurück, wenn es sich um eine untere Dreiecksmatrix handelt, andernfalls gibt es false zurück.

Syntax : mat1.upper_triangular?()

Parameter : Die Funktion benötigt die zu prüfende Matrix auf untere Dreiecke.

Rückgabewert : Gibt „true“ zurück, wenn es sich um eine untere Dreiecksmatrix handelt, ansonsten „false“.

Beispiel 1 :

# 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?()

Ausgang :

false

Beispiel 2 :

# 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?()

Ausgang :

true