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.
8 "gonum.org/v1/gonum/blas"
9 "gonum.org/v1/gonum/blas/blas64"
12 // Dgetrs solves a system of equations using an LU factorization.
13 // The system of equations solved is
14 // A * X = B if trans == blas.Trans
15 // A^T * X = B if trans == blas.NoTrans
16 // A is a general n×n matrix with stride lda. B is a general matrix of size n×nrhs.
18 // On entry b contains the elements of the matrix B. On exit, b contains the
19 // elements of X, the solution to the system of equations.
21 // a and ipiv contain the LU factorization of A and the permutation indices as
22 // computed by Dgetrf. ipiv is zero-indexed.
23 func (impl Implementation) Dgetrs(trans blas.Transpose, n, nrhs int, a []float64, lda int, ipiv []int, b []float64, ldb int) {
24 checkMatrix(n, n, a, lda)
25 checkMatrix(n, nrhs, b, ldb)
29 if n == 0 || nrhs == 0 {
32 if trans != blas.Trans && trans != blas.NoTrans {
35 bi := blas64.Implementation()
36 if trans == blas.NoTrans {
38 impl.Dlaswp(nrhs, b, ldb, 0, n-1, ipiv, 1)
39 // Solve L * X = B, updating b.
40 bi.Dtrsm(blas.Left, blas.Lower, blas.NoTrans, blas.Unit,
41 n, nrhs, 1, a, lda, b, ldb)
42 // Solve U * X = B, updating b.
43 bi.Dtrsm(blas.Left, blas.Upper, blas.NoTrans, blas.NonUnit,
44 n, nrhs, 1, a, lda, b, ldb)
48 // Solve U^T * X = B, updating b.
49 bi.Dtrsm(blas.Left, blas.Upper, blas.Trans, blas.NonUnit,
50 n, nrhs, 1, a, lda, b, ldb)
51 // Solve L^T * X = B, updating b.
52 bi.Dtrsm(blas.Left, blas.Lower, blas.Trans, blas.Unit,
53 n, nrhs, 1, a, lda, b, ldb)
54 impl.Dlaswp(nrhs, b, ldb, 0, n-1, ipiv, -1)