forked from Alexey/DAS_2024_1
37 lines
784 B
Go
37 lines
784 B
Go
|
package util
|
||
|
|
||
|
import "math/rand"
|
||
|
|
||
|
// GetMinor Получение минора матрицы
|
||
|
func GetMinor(matrix [][]float64, col int) [][]float64 {
|
||
|
size := len(matrix)
|
||
|
minor := make([][]float64, size-1)
|
||
|
for i := range minor {
|
||
|
minor[i] = make([]float64, size-1)
|
||
|
}
|
||
|
|
||
|
for i := 1; i < size; i++ {
|
||
|
subCol := 0
|
||
|
for j := 0; j < size; j++ {
|
||
|
if j == col {
|
||
|
continue
|
||
|
}
|
||
|
minor[i-1][subCol] = matrix[i][j]
|
||
|
subCol++
|
||
|
}
|
||
|
}
|
||
|
return minor
|
||
|
}
|
||
|
|
||
|
// GenerateMatrix Генерация случайной матрицы размера size x size
|
||
|
func GenerateMatrix(size int) [][]float64 {
|
||
|
matrix := make([][]float64, size)
|
||
|
for i := range matrix {
|
||
|
matrix[i] = make([]float64, size)
|
||
|
for j := range matrix[i] {
|
||
|
matrix[i][j] = float64(rand.Intn(6))
|
||
|
}
|
||
|
}
|
||
|
return matrix
|
||
|
}
|