Ruby | Matrix real?() function
The real?() is an inbuilt method in Ruby returns a boolean value. It returns true if all values in the matrix are real, else it returns false.
Syntax: mat1.real?()
Parameters: The function needs the matrix which is to be checked for real values
Return Value: It returns true if it all values are real, else it returns false.
Example 1:
#Ruby program for real ? () method in Matrix #Include matrixrequire "matrix" #Initialize a matrix mat1 = Matrix[[ 1, 21 ], [ 31, 18 ]] #Prints if all values are real or not puts mat1.real ? () |
Output:
true
Example 2:
#Ruby program for real ? () method in Matrix #Include matrixrequire "matrix" #Initialize a matrix mat1 = Matrix[[ 1, 21 ], [ 31, 18 ], [ Complex(1, 9), 1 ]] #Prints if real ? or not puts mat1.real ? () |
Output:
false


