OSDN Git Service

new repo
[bytom/vapor.git] / vendor / gonum.org / v1 / gonum / lapack / gonum / dtrtrs.go
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.
4
5 package gonum
6
7 import (
8         "gonum.org/v1/gonum/blas"
9         "gonum.org/v1/gonum/blas/blas64"
10 )
11
12 // Dtrtrs solves a triangular system of the form A * X = B or A^T * X = B. Dtrtrs
13 // returns whether the solve completed successfully. If A is singular, no solve is performed.
14 func (impl Implementation) Dtrtrs(uplo blas.Uplo, trans blas.Transpose, diag blas.Diag, n, nrhs int, a []float64, lda int, b []float64, ldb int) (ok bool) {
15         nounit := diag == blas.NonUnit
16         if n == 0 {
17                 return false
18         }
19         // Check for singularity.
20         if nounit {
21                 for i := 0; i < n; i++ {
22                         if a[i*lda+i] == 0 {
23                                 return false
24                         }
25                 }
26         }
27         bi := blas64.Implementation()
28         bi.Dtrsm(blas.Left, uplo, trans, diag, n, nrhs, 1, a, lda, b, ldb)
29         return true
30 }