代码拉取完成,页面将自动刷新
package matrix
import C "gitee.com/ljfirst/algo-go-sdk/common/constant"
/**
* @author ljfirst
* @version V1.0
* @date 2023/8/1 21:02
* @author-Email ljfirst@mail.ustc.edu.cn
* @blogURL https://blog.csdn.net/ljfirst
* @description 矩阵行列式
**/
type Determinant struct {
}
func (m *Determinant) CalMethod(matrix [][]int) int {
if len(matrix) == 1 {
return matrix[0][0]
}
result, flagC := 0, 1
for i := 0; i < len(matrix); i++ {
f := 0
nextMatrix := make([][]int, len(matrix)-1)
for j := 0; j < len(matrix); j++ {
if i == j {
f = -1
continue
}
nextMatrix[j+f] = make([]int, len(matrix)-1)
c := 0
for l := 0; l < len(matrix); l++ {
if l == 0 {
c = -1
continue
}
nextMatrix[j+f][l+c] = matrix[j][l]
}
}
result += flagC * matrix[i][0] * m.CalMethod(nextMatrix)
flagC = -1 * flagC
}
return result
}
func (m *Determinant) GetAttribute() *C.Attribute {
return &C.Attribute{
Tags: []string{},
Desc: &C.Desc{
Name: "Determinant",
NameCn: "矩阵行列式",
Description: "",
ParamsDesc: map[string]string{
},
Example: map[int]string{
},
},
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。