github.com/gonum/lapack@v0.0.0-20181123203213-e4cdc5a0bff9/native/dlacpy.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  // Dlacpy copies the elements of A specified by uplo into B. Uplo can specify
    10  // a triangular portion with blas.Upper or blas.Lower, or can specify all of the
    11  // elemest with blas.All.
    12  //
    13  // Dlacpy is an internal routine. It is exported for testing purposes.
    14  func (impl Implementation) Dlacpy(uplo blas.Uplo, m, n int, a []float64, lda int, b []float64, ldb int) {
    15  	checkMatrix(m, n, a, lda)
    16  	checkMatrix(m, n, b, ldb)
    17  	switch uplo {
    18  	default:
    19  		panic(badUplo)
    20  	case blas.Upper:
    21  		for i := 0; i < m; i++ {
    22  			for j := i; j < n; j++ {
    23  				b[i*ldb+j] = a[i*lda+j]
    24  			}
    25  		}
    26  
    27  	case blas.Lower:
    28  		for i := 0; i < m; i++ {
    29  			for j := 0; j < min(i+1, n); j++ {
    30  				b[i*ldb+j] = a[i*lda+j]
    31  			}
    32  		}
    33  	case blas.All:
    34  		for i := 0; i < m; i++ {
    35  			for j := 0; j < n; j++ {
    36  				b[i*ldb+j] = a[i*lda+j]
    37  			}
    38  		}
    39  	}
    40  }