Add Dgetrs (compute a solution based on LU factorization) and test.

Responded to PR comments
This commit is contained in:
btracey
2015-08-01 23:30:43 -06:00
parent c87abc8302
commit 32bdb776ef
5 changed files with 199 additions and 0 deletions

View File

@@ -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)
}