Files
sjy01-image-proc/vendor/github.com/nuknal/goNum/E_Mat.go
2024-10-24 15:46:01 +08:00

51 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// E_Mat
/*
------------------------------------------------------
作者 : Black Ghost
日期 : 2018-11-20
版本 : 0.0.0
------------------------------------------------------
返回n阶单位矩阵
------------------------------------------------------
输入 :
n 阶数
输出 :
sol 解值
err 解出标志false-未解出或达到步数上限;
true-全部解出
------------------------------------------------------
*/
package goNum
// E_Mat 返回n阶单位矩阵
func E_Mat(n int) ([][]float64, bool) {
/*
返回n阶单位矩阵
输入 :
n 阶数
输出 :
sol 解值
err 解出标志false-未解出或达到步数上限;
true-全部解出
*/
sol := make([][]float64, n)
for i := 0; i < n; i++ {
sol[i] = make([]float64, n)
}
var err bool = false
//判断阶数
if n < 1 {
return nil, err
}
//分配元素
for i := 0; i < n; i++ {
sol[i][i] = 1.0
}
err = true
return sol, err
}