eql?是Ruby中的內置方法,返回布爾值。如果兩個矩陣相等,則返回true,否則返回false。
用法:mat1.eql?(mat2)
參數:該函數需要兩個要比較的矩陣mat1和mat2。
返回值:如果兩個矩陣相等,則返回true,否則返回false。
例子1:
# Ruby program for eql? method in Matrix
# Include matrix
require "matrix"
# Initialize a matrix
mat1 = Matrix[[1, 21], [31, 18]]
mat2 = Matrix[[1, 21], [31, 18]]
# Prints if both are equal or not
puts mat1.eql?(mat2)
輸出:
true
例子2:
# Ruby program for eql? method in Matrix
# Include matrix
require "matrix"
# Initilizes the matrix
mat1 = Matrix[[1, 21], [31, 18]]
mat2 = Matrix[[1, 16], [31, 28]]
# Prints if both are equal or not
puts mat1.eql?(mat2)
輸出:
false
相關用法
- Ruby Matrix I()用法及代碼示例
- Ruby Matrix zero?()用法及代碼示例
- Ruby Matrix row()用法及代碼示例
- Ruby Matrix tr()用法及代碼示例
- Ruby Matrix det()用法及代碼示例
- Ruby Matrix inv()用法及代碼示例
- Ruby Matrix zero()用法及代碼示例
- Ruby Matrix t()用法及代碼示例
- Ruby Matrix lup()用法及代碼示例
- Ruby Matrix cofactor_expansion()用法及代碼示例
- Ruby Matrix regular?()用法及代碼示例
- Ruby Matrix round()用法及代碼示例
- Ruby Matrix square?()用法及代碼示例
- Ruby Matrix collect()用法及代碼示例
- Ruby Matrix column_count()用法及代碼示例
注:本文由純淨天空篩選整理自gopaldave大神的英文原創作品 Ruby | Matrix eql? function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。