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