mirror of
https://github.com/gonum/gonum.git
synced 2025-10-20 21:59:25 +08:00
Add the Dxxcon routines to lapack64.The condition number routines
are used to check the condition number of a matrix before attempting a linear solve
This commit is contained in:
@@ -4,7 +4,10 @@
|
|||||||
|
|
||||||
package lapack
|
package lapack
|
||||||
|
|
||||||
import "github.com/gonum/blas"
|
import (
|
||||||
|
"github.com/gonum/blas"
|
||||||
|
"github.com/gonum/lapack"
|
||||||
|
)
|
||||||
|
|
||||||
const None = 'N'
|
const None = 'N'
|
||||||
|
|
||||||
@@ -23,6 +26,7 @@ type Complex128 interface{}
|
|||||||
|
|
||||||
// Float64 defines the public float64 LAPACK API supported by gonum/lapack.
|
// Float64 defines the public float64 LAPACK API supported by gonum/lapack.
|
||||||
type Float64 interface {
|
type Float64 interface {
|
||||||
|
Dgecon(norm lapack.MatrixNorm, n int, a []float64, lda int, anorm float64, work []float64, iwork []int) float64
|
||||||
Dgels(trans blas.Transpose, m, n, nrhs int, a []float64, lda int, b []float64, ldb int, work []float64, lwork int) bool
|
Dgels(trans blas.Transpose, m, n, nrhs int, a []float64, lda int, b []float64, ldb int, work []float64, lwork int) bool
|
||||||
Dgelqf(m, n int, a []float64, lda int, tau, work []float64, lwork int)
|
Dgelqf(m, n int, a []float64, lda int, tau, work []float64, lwork int)
|
||||||
Dgeqrf(m, n int, a []float64, lda int, tau, work []float64, lwork int)
|
Dgeqrf(m, n int, a []float64, lda int, tau, work []float64, lwork int)
|
||||||
@@ -30,7 +34,9 @@ type Float64 interface {
|
|||||||
Dgetrs(trans blas.Transpose, n, nrhs int, a []float64, lda int, ipiv []int, b []float64, ldb int)
|
Dgetrs(trans blas.Transpose, n, nrhs int, a []float64, lda int, ipiv []int, b []float64, ldb int)
|
||||||
Dormqr(side blas.Side, trans blas.Transpose, m, n, k int, a []float64, lda int, tau, c []float64, ldc int, work []float64, lwork int)
|
Dormqr(side blas.Side, trans blas.Transpose, m, n, k int, a []float64, lda int, tau, c []float64, ldc int, work []float64, lwork int)
|
||||||
Dormlq(side blas.Side, trans blas.Transpose, m, n, k int, a []float64, lda int, tau, c []float64, ldc int, work []float64, lwork int)
|
Dormlq(side blas.Side, trans blas.Transpose, m, n, k int, a []float64, lda int, tau, c []float64, ldc int, work []float64, lwork int)
|
||||||
|
Dpocon(uplo blas.Uplo, n int, a []float64, lda int, anorm float64, work []float64, iwork []int) float64
|
||||||
Dpotrf(ul blas.Uplo, n int, a []float64, lda int) (ok bool)
|
Dpotrf(ul blas.Uplo, n int, a []float64, lda int) (ok bool)
|
||||||
|
Dtrcon(norm lapack.MatrixNorm, uplo blas.Uplo, diag blas.Diag, n int, a []float64, lda int, work []float64, iwork []int) float64
|
||||||
Dtrtrs(uplo blas.Uplo, trans blas.Transpose, diag blas.Diag, n, nrhs int, a []float64, lda int, b []float64, ldb int) (ok bool)
|
Dtrtrs(uplo blas.Uplo, trans blas.Transpose, diag blas.Diag, n, nrhs int, a []float64, lda int, b []float64, ldb int) (ok bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -48,6 +48,21 @@ func Potrf(a blas64.Symmetric) (t blas64.Triangular, ok bool) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Gecon estimates the reciprocal of the condition number of the n×n matrix A
|
||||||
|
// given the LU decomposition of the matrix. The condition number computed may
|
||||||
|
// be based on the 1-norm or the ∞-norm.
|
||||||
|
//
|
||||||
|
// The slice a contains the result of the LU decomposition of A as computed by Dgetrf.
|
||||||
|
//
|
||||||
|
// anorm is the corresponding 1-norm or ∞-norm of the original matrix A.
|
||||||
|
//
|
||||||
|
// work is a temporary data slice of length at least 4*n and Gecon will panic otherwise.
|
||||||
|
//
|
||||||
|
// iwork is a temporary data slice of length at least n and Gecon will panic otherwise.
|
||||||
|
func Gecon(norm lapack.MatrixNorm, a blas64.General, anorm float64, work []float64, iwork []int) float64 {
|
||||||
|
return lapack64.Dgecon(norm, a.Cols, a.Data, a.Stride, anorm, work, iwork)
|
||||||
|
}
|
||||||
|
|
||||||
// Gels finds a minimum-norm solution based on the matrices A and B using the
|
// Gels finds a minimum-norm solution based on the matrices A and B using the
|
||||||
// QR or LQ factorization. Dgels returns false if the matrix
|
// QR or LQ factorization. Dgels returns false if the matrix
|
||||||
// A is singular, and true if this solution was successfully found.
|
// A is singular, and true if this solution was successfully found.
|
||||||
@@ -207,6 +222,29 @@ func Ormqr(side blas.Side, trans blas.Transpose, a blas64.General, tau []float64
|
|||||||
lapack64.Dormqr(side, trans, c.Rows, c.Cols, a.Cols, a.Data, a.Stride, tau, c.Data, c.Stride, work, lwork)
|
lapack64.Dormqr(side, trans, c.Rows, c.Cols, a.Cols, a.Data, a.Stride, tau, c.Data, c.Stride, work, lwork)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pocon estimates the reciprocal of the condition number of a positive-definite
|
||||||
|
// matrix A given the Cholesky decmposition of A. The condition number computed
|
||||||
|
// is based on the 1-norm and the ∞-norm.
|
||||||
|
//
|
||||||
|
// anorm is the 1-norm and the ∞-norm of the original matrix A.
|
||||||
|
//
|
||||||
|
// work is a temporary data slice of length at least 3*n and Pocon will panic otherwise.
|
||||||
|
//
|
||||||
|
// iwork is a temporary data slice of length at least n and Pocon will panic otherwise.
|
||||||
|
func Pocon(a blas64.Symmetric, anorm float64, work []float64, iwork []int) float64 {
|
||||||
|
return lapack64.Dpocon(a.Uplo, a.N, a.Data, a.Stride, anorm, work, iwork)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Trcon estimates the reciprocal of the condition number of a triangular matrix A.
|
||||||
|
// The condition number computed may be based on the 1-norm or the ∞-norm.
|
||||||
|
//
|
||||||
|
// work is a temporary data slice of length at least 3*n and Trcon will panic otherwise.
|
||||||
|
//
|
||||||
|
// iwork is a temporary data slice of length at least n and Trcon will panic otherwise.
|
||||||
|
func Trcon(norm lapack.MatrixNorm, a blas64.Triangular, work []float64, iwork []int) float64 {
|
||||||
|
return lapack64.Dtrcon(norm, a.Uplo, a.Diag, a.N, a.Data, a.Stride, work, iwork)
|
||||||
|
}
|
||||||
|
|
||||||
// Trtrs solves a triangular system of the form A * X = B or A^T * X = B. Trtrs
|
// Trtrs solves a triangular system of the form A * X = B or A^T * X = B. Trtrs
|
||||||
// returns whether the solve completed successfully. If A is singular, no solve is performed.
|
// returns whether the solve completed successfully. If A is singular, no solve is performed.
|
||||||
func Trtrs(trans blas.Transpose, a blas64.Triangular, b blas64.General) (ok bool) {
|
func Trtrs(trans blas.Transpose, a blas64.Triangular, b blas64.General) (ok bool) {
|
||||||
|
@@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/gonum/blas/blas64"
|
"github.com/gonum/blas/blas64"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Dtrcon estimates the reciprocal of the condition number of a positive-definite
|
// Dpocon estimates the reciprocal of the condition number of a positive-definite
|
||||||
// matrix A given the Cholesky decmposition of A. The condition number computed
|
// matrix A given the Cholesky decmposition of A. The condition number computed
|
||||||
// is based on the 1-norm and the ∞-norm.
|
// is based on the 1-norm and the ∞-norm.
|
||||||
//
|
//
|
||||||
|
Reference in New Issue
Block a user