github.com/gonum/lapack@v0.0.0-20181123203213-e4cdc5a0bff9/native/dlaset.go (about) 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 native 6 7 import "github.com/gonum/blas" 8 9 // Dlaset sets the off-diagonal elements of A to alpha, and the diagonal 10 // elements to beta. If uplo == blas.Upper, only the elements in the upper 11 // triangular part are set. If uplo == blas.Lower, only the elements in the 12 // lower triangular part are set. If uplo is otherwise, all of the elements of A 13 // are set. 14 // 15 // Dlaset is an internal routine. It is exported for testing purposes. 16 func (impl Implementation) Dlaset(uplo blas.Uplo, m, n int, alpha, beta float64, a []float64, lda int) { 17 checkMatrix(m, n, a, lda) 18 if uplo == blas.Upper { 19 for i := 0; i < m; i++ { 20 for j := i + 1; j < n; j++ { 21 a[i*lda+j] = alpha 22 } 23 } 24 } else if uplo == blas.Lower { 25 for i := 0; i < m; i++ { 26 for j := 0; j < min(i+1, n); j++ { 27 a[i*lda+j] = alpha 28 } 29 } 30 } else { 31 for i := 0; i < m; i++ { 32 for j := 0; j < n; j++ { 33 a[i*lda+j] = alpha 34 } 35 } 36 } 37 for i := 0; i < min(m, n); i++ { 38 a[i*lda+i] = beta 39 } 40 }