本文整理汇总了Golang中github.com/gonum/blas/blas64.General.Rows方法的典型用法代码示例。如果您正苦于以下问题:Golang General.Rows方法的具体用法?Golang General.Rows怎么用?Golang General.Rows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/gonum/blas/blas64.General
的用法示例。
在下文中一共展示了General.Rows方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: svdCheck
// svdCheck checks that the singular value decomposition correctly multiplies back
// to the original matrix.
func svdCheck(t *testing.T, thin bool, errStr string, m, n int, s, a, u []float64, ldu int, vt []float64, ldvt int, aCopy []float64, lda int) {
sigma := blas64.General{
Rows: m,
Cols: n,
Stride: n,
Data: make([]float64, m*n),
}
for i := 0; i < min(m, n); i++ {
sigma.Data[i*sigma.Stride+i] = s[i]
}
uMat := blas64.General{
Rows: m,
Cols: m,
Stride: ldu,
Data: u,
}
vTMat := blas64.General{
Rows: n,
Cols: n,
Stride: ldvt,
Data: vt,
}
if thin {
sigma.Rows = min(m, n)
sigma.Cols = min(m, n)
uMat.Cols = min(m, n)
vTMat.Rows = min(m, n)
}
tmp := blas64.General{
Rows: m,
Cols: n,
Stride: n,
Data: make([]float64, m*n),
}
ans := blas64.General{
Rows: m,
Cols: n,
Stride: lda,
Data: make([]float64, m*lda),
}
copy(ans.Data, a)
blas64.Gemm(blas.NoTrans, blas.NoTrans, 1, uMat, sigma, 0, tmp)
blas64.Gemm(blas.NoTrans, blas.NoTrans, 1, tmp, vTMat, 0, ans)
if !floats.EqualApprox(ans.Data, aCopy, 1e-8) {
t.Errorf("Decomposition mismatch. Trim = %v, %s", thin, errStr)
}
if !thin {
// Check that U and V are orthogonal.
for i := 0; i < uMat.Rows; i++ {
for j := i + 1; j < uMat.Rows; j++ {
dot := blas64.Dot(uMat.Cols,
blas64.Vector{Inc: 1, Data: uMat.Data[i*uMat.Stride:]},
blas64.Vector{Inc: 1, Data: uMat.Data[j*uMat.Stride:]},
)
if dot > 1e-8 {
t.Errorf("U not orthogonal %s", errStr)
}
}
}
for i := 0; i < vTMat.Rows; i++ {
for j := i + 1; j < vTMat.Rows; j++ {
dot := blas64.Dot(vTMat.Cols,
blas64.Vector{Inc: 1, Data: vTMat.Data[i*vTMat.Stride:]},
blas64.Vector{Inc: 1, Data: vTMat.Data[j*vTMat.Stride:]},
)
if dot > 1e-8 {
t.Errorf("V not orthogonal %s", errStr)
}
}
}
}
}