lapack/gonum: add Dpotrs

This commit is contained in:
Vladimir Chalupecky
2018-06-29 18:50:30 +02:00
committed by Vladimír Chalupecký
parent cebdade430
commit 989b440016
3 changed files with 56 additions and 0 deletions

46
lapack/gonum/dpotrs.go Normal file
View File

@@ -0,0 +1,46 @@
// Copyright ©2018 The Gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package gonum
import (
"gonum.org/v1/gonum/blas"
"gonum.org/v1/gonum/blas/blas64"
)
// Dpotrs solves a system of n linear equations A*X = B where A is an n×n
// symmetric positive definite matrix and B is an n×nrhs matrix. The matrix A is
// represented by its Cholesky factorization
// A = U^T*U if uplo == blas.Upper
// A = L*L^T if uplo == blas.Lower
// as computed by Dpotrf. On entry, B contains the right-hand side matrix B, on
// return it contains the solution matrix X.
func (Implementation) Dpotrs(uplo blas.Uplo, n, nrhs int, a []float64, lda int, b []float64, ldb int) {
if uplo != blas.Upper && uplo != blas.Lower {
panic(badUplo)
}
checkMatrix(n, n, a, lda)
checkMatrix(n, nrhs, b, ldb)
if n == 0 || nrhs == 0 {
return
}
bi := blas64.Implementation()
if uplo == blas.Upper {
// Solve U^T * U * X = B where U is stored in the upper triangle of A.
// Solve U^T * X = B, overwriting B with X.
bi.Dtrsm(blas.Left, blas.Upper, blas.Trans, blas.NonUnit, n, nrhs, 1, a, lda, b, ldb)
// Solve U * X = B, overwriting B with X.
bi.Dtrsm(blas.Left, blas.Upper, blas.NoTrans, blas.NonUnit, n, nrhs, 1, a, lda, b, ldb)
} else {
// Solve L * L^T * X = B where L is stored in the lower triangle of A.
// Solve L * X = B, overwriting B with X.
bi.Dtrsm(blas.Left, blas.Lower, blas.NoTrans, blas.NonUnit, n, nrhs, 1, a, lda, b, ldb)
// Solve L^T * X = B, overwriting B with X.
bi.Dtrsm(blas.Left, blas.Lower, blas.Trans, blas.NonUnit, n, nrhs, 1, a, lda, b, ldb)
}
}

View File

@@ -35,6 +35,7 @@ type Float64 interface {
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)
Dpotrs(ul blas.Uplo, n, nrhs int, a []float64, lda int, b []float64, ldb int)
Dsyev(jobz EVJob, uplo blas.Uplo, n int, a []float64, lda int, w, work []float64, lwork int) (ok bool)
Dtrcon(norm MatrixNorm, uplo blas.Uplo, diag blas.Diag, n int, a []float64, lda int, work []float64, iwork []int) float64
Dtrtri(uplo blas.Uplo, diag blas.Diag, n int, a []float64, lda int) (ok bool)

View File

@@ -37,6 +37,15 @@ func Potrf(a blas64.Symmetric) (t blas64.Triangular, ok bool) {
return
}
// Potrs solves a system of n linear equations A*X = B where A is an n×n
// symmetric positive definite matrix and B is an n×nrhs matrix, using the
// Cholesky factorization A = U^T*U or A = L*L^T. t contains the corresponding
// triangular factor as returned by Potrf. On entry, B contains the right-hand
// side matrix B, on return it contains the solution matrix X.
func Potrs(t blas64.Triangular, b blas64.General) {
lapack64.Dpotrs(t.Uplo, t.N, b.Cols, t.Data, t.Stride, b.Data, b.Stride)
}
// 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.