Open In App

Ruby | Matrix orthogonal? function

Last Updated : 12 Jul, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

The

orthogonal?()

is an inbuilt method in

Ruby

returns a boolean value. It returns true if it is a orthogonal matrix, else it returns false. It returns error if anything other than square matrix is used.

Syntax: mat1.orthogonal?() Parameters: The function needs the matrix to be checked for orthogonal matrix or not. Return Value: It returns true if it is a orthogonal matrix, else it returns false.

Example 1

:

CPP
#Ruby program for orthogonal ? () method in Matrix

#Include matrix
require "matrix"

#Initialize a matrix
    mat1
    = Matrix[[ 1, 21 ], [ 31, 18 ]]

#Prints if orthogonal ? or not
      puts mat1.orthogonal
    ? ()

Output

:

false

Example 2

:

CPP
#Ruby program for orthogonal ? () method in Matrix

#Include matrix
require "matrix"

#Initialize a matrix
    mat1
    = Matrix[[ 1, 0 ], [ 0, 1 ]]

#Prints if orthogonal ? or not
      puts mat1.orthogonal
    ? ()

Output

:

true

Explore