Open In App

Ruby | Matrix orthogonal? function

Last Updated : 07 Jan, 2020
Improve
Improve
Like Article
Like
Save
Share
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:




#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:




#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

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads