红宝石 |矩阵正交?函数
正交?()是 Ruby 中的一个内置方法,它返回一个布尔值。如果它是正交矩阵,则返回 true,否则返回 false。如果使用方阵以外的任何东西,它会返回错误。
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.
示例 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
? ()
输出:
false
示例 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
? ()
输出:
true