|
|
@ -27,8 +27,25 @@ func checkMat(mat [][]int) {
|
|
|
|
func getDet(mat [][]int) int {
|
|
|
|
func getDet(mat [][]int) int {
|
|
|
|
if len(mat) > 1 {
|
|
|
|
if len(mat) > 1 {
|
|
|
|
erg := 0
|
|
|
|
erg := 0
|
|
|
|
neg := 0
|
|
|
|
neg := false
|
|
|
|
|
|
|
|
var ch = make(chan int)
|
|
|
|
for i := 0; i < len(mat); i++ {
|
|
|
|
for i := 0; i < len(mat); i++ {
|
|
|
|
|
|
|
|
go singleDet(mat, neg, i, ch)
|
|
|
|
|
|
|
|
neg = !neg
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for i := 0; i < len(mat); i++ {
|
|
|
|
|
|
|
|
zw := <-ch
|
|
|
|
|
|
|
|
erg = erg + zw
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return erg
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return mat[0][0]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func singleDet(mat [][]int, neg bool, i int, ch chan int) {
|
|
|
|
|
|
|
|
erg := 0
|
|
|
|
mat1 := [][]int{}
|
|
|
|
mat1 := [][]int{}
|
|
|
|
for j := 0; j < len(mat); j++ {
|
|
|
|
for j := 0; j < len(mat); j++ {
|
|
|
|
if j == i {
|
|
|
|
if j == i {
|
|
|
@ -44,19 +61,12 @@ func getDet(mat [][]int) int {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if neg == 0 {
|
|
|
|
if !neg {
|
|
|
|
erg = erg + mat[i][0]*getDet(mat1)
|
|
|
|
erg = erg + mat[i][0]*getDet(mat1)
|
|
|
|
neg = 1
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
erg = erg - mat[i][0]*getDet(mat1)
|
|
|
|
erg = erg - mat[i][0]*getDet(mat1)
|
|
|
|
neg = 0
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return erg
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return mat[0][0]
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ch <- erg
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func outMat(mat [][]int) {
|
|
|
|
func outMat(mat [][]int) {
|
|
|
|