📜  红宝石 |矩阵 cofactor_expansion()函数

📅  最后修改于: 2022-05-13 01:55:07.704000             🧑  作者: Mango

红宝石 |矩阵 cofactor_expansion()函数

cofactor_expansion()是 Ruby 中的一个内置方法,它沿给定行或列返回给定矩阵的 cofactor_expansion。换句话说,它返回 拉普拉斯展开

示例 1

Ruby
# 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)


Ruby
# 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)


输出

-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