hermitian?()是Ruby中的內置方法,返回布爾值。如果矩陣是埃爾米特矩陣,則返回true,否則返回false。如果檢查的不是方矩陣,則拋出錯誤。
用法:mat1.hermitian?()
參數:該函數需要一個矩陣,以檢查其厄米特數。
返回值:如果矩陣是埃爾米特矩陣,則返回true,否則返回false。
例子1:
# Ruby program for hermitian?() method in Matrix
# Include matrix
require "matrix"
# Initialize a matrix
mat1 = Matrix[[1, 21], [31, 18]]
# Prints the value of mat1.hermitian?()
puts mat1.hermitian?()
輸出:
false
例子2:
# Ruby program for hermitian?() method in Matrix
# Include matrix
require "matrix"
# Initialize a matrix
mat1 = Matrix[[2, Complex(2, 1), 4], [Complex(2, -1),
3, Complex(0,1)], [4, Complex(0,-1), 1]]
# Prints the value of mat1.hermitian?()
puts mat1.hermitian?()
輸出:
true
相關用法
- Ruby Matrix zero?()用法及代碼示例
- Ruby Matrix inv()用法及代碼示例
- Ruby Matrix tr()用法及代碼示例
- Ruby Matrix det()用法及代碼示例
- Ruby Matrix row()用法及代碼示例
- Ruby Matrix lup()用法及代碼示例
- Ruby Matrix t()用法及代碼示例
- Ruby Matrix I()用法及代碼示例
- Ruby Matrix zero()用法及代碼示例
- Ruby Matrix eql?用法及代碼示例
- Ruby Matrix diagonal?()用法及代碼示例
- Ruby Matrix round()用法及代碼示例
- Ruby Matrix square?()用法及代碼示例
- Ruby Matrix column()用法及代碼示例
- Ruby Matrix eigen()用法及代碼示例
注:本文由純淨天空篩選整理自gopaldave大神的英文原創作品 Ruby | Matrix hermitian?() function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。