mirror of
https://github.com/gonum/gonum.git
synced 2025-10-21 14:19:35 +08:00
Add Dgetrs (compute a solution based on LU factorization) and test.
Responded to PR comments
This commit is contained in:
@@ -136,3 +136,27 @@ func (impl Implementation) Dgetrf(m, n int, a []float64, lda int, ipiv []int) (o
|
||||
}
|
||||
return ok
|
||||
}
|
||||
|
||||
// Dgetrs solves a system of equations using an LU factorization.
|
||||
// The system of equations solved is
|
||||
// A * X = B if trans == blas.Trans
|
||||
// A^T * X = B if trans == blas.NoTrans
|
||||
// A is a general n×n matrix with stride lda. B is a general matrix of size n×nrhs.
|
||||
//
|
||||
// On entry b contains the elements of the matrix B. On exit, b contains the
|
||||
// elements of X, the solution to the system of equations.
|
||||
//
|
||||
// a and ipiv contain the LU factorization of A and the permutation indices as
|
||||
// computed by Dgetrf. ipiv is zero-indexed.
|
||||
func (impl Implementation) Dgetrs(trans blas.Transpose, n, nrhs int, a []float64, lda int, ipiv []int, b []float64, ldb int) {
|
||||
checkMatrix(n, n, a, lda)
|
||||
checkMatrix(n, nrhs, b, ldb)
|
||||
if len(ipiv) < n {
|
||||
panic(badIpiv)
|
||||
}
|
||||
ipiv32 := make([]int32, len(ipiv))
|
||||
for i, v := range ipiv {
|
||||
ipiv32[i] = int32(v) + 1 // Transform to one-indexed.
|
||||
}
|
||||
clapack.Dgetrs(trans, n, nrhs, a, lda, ipiv32, b, ldb)
|
||||
}
|
||||
|
Reference in New Issue
Block a user