gonum.org/v1/gonum@v0.14.0/internal/asm/f32/scal.go (about)

     1  // Copyright ©2016 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 f32
     6  
     7  // ScalUnitary is
     8  //
     9  //	for i := range x {
    10  //		x[i] *= alpha
    11  //	}
    12  func ScalUnitary(alpha float32, x []float32) {
    13  	for i := range x {
    14  		x[i] *= alpha
    15  	}
    16  }
    17  
    18  // ScalUnitaryTo is
    19  //
    20  //	for i, v := range x {
    21  //		dst[i] = alpha * v
    22  //	}
    23  func ScalUnitaryTo(dst []float32, alpha float32, x []float32) {
    24  	for i, v := range x {
    25  		dst[i] = alpha * v
    26  	}
    27  }
    28  
    29  // ScalInc is
    30  //
    31  //	var ix uintptr
    32  //	for i := 0; i < int(n); i++ {
    33  //		x[ix] *= alpha
    34  //		ix += incX
    35  //	}
    36  func ScalInc(alpha float32, x []float32, n, incX uintptr) {
    37  	var ix uintptr
    38  	for i := 0; i < int(n); i++ {
    39  		x[ix] *= alpha
    40  		ix += incX
    41  	}
    42  }
    43  
    44  // ScalIncTo is
    45  //
    46  //	var idst, ix uintptr
    47  //	for i := 0; i < int(n); i++ {
    48  //		dst[idst] = alpha * x[ix]
    49  //		ix += incX
    50  //		idst += incDst
    51  //	}
    52  func ScalIncTo(dst []float32, incDst uintptr, alpha float32, x []float32, n, incX uintptr) {
    53  	var idst, ix uintptr
    54  	for i := 0; i < int(n); i++ {
    55  		dst[idst] = alpha * x[ix]
    56  		ix += incX
    57  		idst += incDst
    58  	}
    59  }