gonum.org/v1/gonum@v0.14.0/lapack/gonum/dlauu2.go (about) 1 // Copyright ©2018 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 // Dlauu2 computes the product 13 // 14 // U * Uᵀ if uplo is blas.Upper 15 // Lᵀ * L if uplo is blas.Lower 16 // 17 // where U or L is stored in the upper or lower triangular part of A. 18 // Only the upper or lower triangle of the result is stored, overwriting 19 // the corresponding factor in A. 20 func (impl Implementation) Dlauu2(uplo blas.Uplo, n int, a []float64, lda int) { 21 switch { 22 case uplo != blas.Upper && uplo != blas.Lower: 23 panic(badUplo) 24 case n < 0: 25 panic(nLT0) 26 case lda < max(1, n): 27 panic(badLdA) 28 } 29 30 // Quick return if possible. 31 if n == 0 { 32 return 33 } 34 35 if len(a) < (n-1)*lda+n { 36 panic(shortA) 37 } 38 39 bi := blas64.Implementation() 40 41 if uplo == blas.Upper { 42 // Compute the product U*Uᵀ. 43 for i := 0; i < n; i++ { 44 aii := a[i*lda+i] 45 if i < n-1 { 46 a[i*lda+i] = bi.Ddot(n-i, a[i*lda+i:], 1, a[i*lda+i:], 1) 47 bi.Dgemv(blas.NoTrans, i, n-i-1, 1, a[i+1:], lda, a[i*lda+i+1:], 1, 48 aii, a[i:], lda) 49 } else { 50 bi.Dscal(i+1, aii, a[i:], lda) 51 } 52 } 53 } else { 54 // Compute the product Lᵀ*L. 55 for i := 0; i < n; i++ { 56 aii := a[i*lda+i] 57 if i < n-1 { 58 a[i*lda+i] = bi.Ddot(n-i, a[i*lda+i:], lda, a[i*lda+i:], lda) 59 bi.Dgemv(blas.Trans, n-i-1, i, 1, a[(i+1)*lda:], lda, a[(i+1)*lda+i:], lda, 60 aii, a[i*lda:], 1) 61 } else { 62 bi.Dscal(i+1, aii, a[i*lda:], 1) 63 } 64 } 65 } 66 }