當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Ruby Matrix cofactor_expansion()用法及代碼示例

cofactor_expansion()是Ruby中的內置方法,它沿著給定的行或列返回給定矩陣的cofactor_expansion。換句話說,它返回Laplace展開。

用法: mat1.cofactor_expansion(row: num or col:num)

參數:該函數接受一個必填參數行或列,其返回的是cofactor_expansion。


返回值:它沿著給定的行或列返回給定矩陣的cofactor-expansion。

例子1

# Ruby program for cofactor_expansion() method in Matrix 
  
# Include matrix  
require "matrix"
  
# Initialize a matrix  
mat1 = Matrix[[1, 21], [31, 18]]   
  
# Prints the value of mat1.cofactor_expansion 
# first row  
puts  mat1.cofactor_expansion(row:1)

輸出

-633

例子2

# Ruby program for cofactor_expansion() method in Matrix 
  
# Include matrix  
require "matrix"
  
# Initialize a matrix  
mat1 =  Matrix[[13, 1, 5], [12, 1, 5], [11, 2, 5]]  
  
# Prints the value of mat1.cofactor_expansion 
# first row  
puts  mat1.cofactor_expansion(column:0)

輸出

-5


相關用法


注:本文由純淨天空篩選整理自gopaldave大神的英文原創作品 Ruby | Matrix cofactor_expansion() function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。