first_minor()是Ruby中的內置方法,在刪除指定的行和列後,它會返回子矩陣。
用法: mat1.first_minor(row_num, col_num)
參數:該函數需要刪除的行號和列號
返回值:刪除後返回子矩陣。
例子1:
# Ruby program for first_minor method in Matrix
# Include matrix
require "matrix"
# Initilizes the matrix
mat1 = Matrix[[12, 21], [31, 12]]
# Prints the submatrix after removing
puts mat1.first_minor(1, 1)
輸出:
Matrix[[12]]
例子2:
# Ruby program for first_minor method in Matrix
# Include matrix
require "matrix"
# Initilizes the matrix
mat1 = Matrix[[6, 7], [9, 10], [12, 4]]
# Prints the submatrix after removing
puts mat1.first_minor(0, 1)
輸出:
Matrix[[9], [12]]
相關用法
- Ruby Matrix inv()用法及代碼示例
- Ruby Matrix det()用法及代碼示例
- Ruby Matrix tr()用法及代碼示例
- Ruby Matrix lup()用法及代碼示例
- Ruby Matrix t()用法及代碼示例
- Ruby Matrix row()用法及代碼示例
- Ruby Matrix eql?用法及代碼示例
- Ruby Matrix I()用法及代碼示例
- Ruby Matrix zero?()用法及代碼示例
- Ruby Matrix zero()用法及代碼示例
- Ruby Matrix to_a()用法及代碼示例
- Ruby Matrix scalar()用法及代碼示例
- Ruby Matrix column_size()用法及代碼示例
- Ruby Matrix round()用法及代碼示例
- Ruby Matrix unit()用法及代碼示例
注:本文由純淨天空篩選整理自gopaldave大神的英文原創作品 Ruby | Matrix first_minor() function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。