1 // Copyright ©2015 The Gonum Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
10 "gonum.org/v1/gonum/blas"
11 "gonum.org/v1/gonum/blas/blas64"
12 "gonum.org/v1/gonum/lapack"
15 // Dgecon estimates the reciprocal of the condition number of the n×n matrix A
16 // given the LU decomposition of the matrix. The condition number computed may
17 // be based on the 1-norm or the ∞-norm.
19 // The slice a contains the result of the LU decomposition of A as computed by Dgetrf.
21 // anorm is the corresponding 1-norm or ∞-norm of the original matrix A.
23 // work is a temporary data slice of length at least 4*n and Dgecon will panic otherwise.
25 // iwork is a temporary data slice of length at least n and Dgecon will panic otherwise.
26 func (impl Implementation) Dgecon(norm lapack.MatrixNorm, n int, a []float64, lda int, anorm float64, work []float64, iwork []int) float64 {
27 checkMatrix(n, n, a, lda)
28 if norm != lapack.MaxColumnSum && norm != lapack.MaxRowSum {
40 } else if anorm == 0 {
44 bi := blas64.Implementation()
45 var rcond, ainvnm float64
49 onenrm := norm == lapack.MaxColumnSum
56 ainvnm, kase = impl.Dlacn2(n, work[n:], work, iwork, ainvnm, kase, isave)
59 rcond = (1 / ainvnm) / anorm
65 sl = impl.Dlatrs(blas.Lower, blas.NoTrans, blas.Unit, normin, n, a, lda, work, work[2*n:])
66 su = impl.Dlatrs(blas.Upper, blas.NoTrans, blas.NonUnit, normin, n, a, lda, work, work[3*n:])
68 su = impl.Dlatrs(blas.Upper, blas.Trans, blas.NonUnit, normin, n, a, lda, work, work[3*n:])
69 sl = impl.Dlatrs(blas.Lower, blas.Trans, blas.Unit, normin, n, a, lda, work, work[2*n:])
74 ix := bi.Idamax(n, work, 1)
75 if scale == 0 || scale < math.Abs(work[ix])*smlnum {
78 impl.Drscl(n, scale, work, 1)