github.com/jingcheng-WU/gonum@v0.9.1-0.20210323123734-f1a2a11a8f7b/internal/asm/f32/ge_noasm.go (about)

     1  // Copyright ©2017 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  // +build !amd64 noasm gccgo safe
     6  
     7  package f32
     8  
     9  // Ger performs the rank-one operation
    10  //  A += alpha * x * yᵀ
    11  // where A is an m×n dense matrix, x and y are vectors, and alpha is a scalar.
    12  func Ger(m, n uintptr, alpha float32, x []float32, incX uintptr, y []float32, incY uintptr, a []float32, lda uintptr) {
    13  
    14  	if incX == 1 && incY == 1 {
    15  		x = x[:m]
    16  		y = y[:n]
    17  		for i, xv := range x {
    18  			AxpyUnitary(alpha*xv, y, a[uintptr(i)*lda:uintptr(i)*lda+n])
    19  		}
    20  		return
    21  	}
    22  
    23  	var ky, kx uintptr
    24  	if int(incY) < 0 {
    25  		ky = uintptr(-int(n-1) * int(incY))
    26  	}
    27  	if int(incX) < 0 {
    28  		kx = uintptr(-int(m-1) * int(incX))
    29  	}
    30  
    31  	ix := kx
    32  	for i := 0; i < int(m); i++ {
    33  		AxpyInc(alpha*x[ix], y, a[uintptr(i)*lda:uintptr(i)*lda+n], uintptr(n), uintptr(incY), 1, uintptr(ky), 0)
    34  		ix += incX
    35  	}
    36  }