红宝石 |矩阵 laplace_expansion()函数
laplace_expansion()是 Ruby 中的一个内置方法,它沿给定的行或列返回给定矩阵的 laplace_expansion。换句话说,它返回 拉普拉斯展开。
Syntax: mat1.laplace_expansion(row: num or col:num)
Parameters: The function accepts one mandatory parameter row or column whose laplace_expansion is returned.
Return Value: It returns the laplace-expansion of the given matrix along the given row or column.
示例 1 :
CPP
#Ruby program for laplace_expansion() method in Matrix
#Include matrix
require "matrix"
#Initialize a matrix
mat1
= Matrix[[ 1, 21 ], [ 31, 18 ]]
#Prints the value of mat1.laplace_expansion
#first row
puts mat1.laplace_expansion(row : 1)
CPP
#Ruby program for laplace_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.laplace_expansion
#first row
puts mat1.laplace_expansion(column : 0)
输出:
-633
示例 2 :
CPP
#Ruby program for laplace_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.laplace_expansion
#first row
puts mat1.laplace_expansion(column : 0)
输出:
-5