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 // Dtrcon estimates the reciprocal of the condition number of a triangular matrix A.
16 // The condition number computed may be based on the 1-norm or the ∞-norm.
18 // work is a temporary data slice of length at least 3*n and Dtrcon will panic otherwise.
20 // iwork is a temporary data slice of length at least n and Dtrcon will panic otherwise.
21 func (impl Implementation) Dtrcon(norm lapack.MatrixNorm, uplo blas.Uplo, diag blas.Diag, n int, a []float64, lda int, work []float64, iwork []int) float64 {
22 if norm != lapack.MaxColumnSum && norm != lapack.MaxRowSum {
25 if uplo != blas.Upper && uplo != blas.Lower {
28 if diag != blas.NonUnit && diag != blas.Unit {
40 bi := blas64.Implementation()
43 smlnum := dlamchS * float64(n)
45 anorm := impl.Dlantr(norm, uplo, diag, n, n, a, lda, work)
53 if norm == lapack.MaxColumnSum {
60 ainvnm, kase = impl.Dlacn2(n, work[n:], work, iwork, ainvnm, kase, isave)
63 rcond = (1 / anorm) / ainvnm
68 scale = impl.Dlatrs(uplo, blas.NoTrans, diag, normin, n, a, lda, work, work[2*n:])
70 scale = impl.Dlatrs(uplo, blas.Trans, diag, normin, n, a, lda, work, work[2*n:])
74 ix := bi.Idamax(n, work, 1)
75 xnorm := math.Abs(work[ix])
76 if scale == 0 || scale < xnorm*smlnum {
79 impl.Drscl(n, scale, work, 1)