github.com/jingcheng-WU/gonum@v0.9.1-0.20210323123734-f1a2a11a8f7b/internal/asm/f32/stubs_noasm.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  // +build !amd64 noasm gccgo safe
     6  
     7  package f32
     8  
     9  // AxpyUnitary is
    10  //  for i, v := range x {
    11  //  	y[i] += alpha * v
    12  //  }
    13  func AxpyUnitary(alpha float32, x, y []float32) {
    14  	for i, v := range x {
    15  		y[i] += alpha * v
    16  	}
    17  }
    18  
    19  // AxpyUnitaryTo is
    20  //  for i, v := range x {
    21  //  	dst[i] = alpha*v + y[i]
    22  //  }
    23  func AxpyUnitaryTo(dst []float32, alpha float32, x, y []float32) {
    24  	for i, v := range x {
    25  		dst[i] = alpha*v + y[i]
    26  	}
    27  }
    28  
    29  // AxpyInc is
    30  //  for i := 0; i < int(n); i++ {
    31  //  	y[iy] += alpha * x[ix]
    32  //  	ix += incX
    33  //  	iy += incY
    34  //  }
    35  func AxpyInc(alpha float32, x, y []float32, n, incX, incY, ix, iy uintptr) {
    36  	for i := 0; i < int(n); i++ {
    37  		y[iy] += alpha * x[ix]
    38  		ix += incX
    39  		iy += incY
    40  	}
    41  }
    42  
    43  // AxpyIncTo is
    44  //  for i := 0; i < int(n); i++ {
    45  //  	dst[idst] = alpha*x[ix] + y[iy]
    46  //  	ix += incX
    47  //  	iy += incY
    48  //  	idst += incDst
    49  //  }
    50  func AxpyIncTo(dst []float32, incDst, idst uintptr, alpha float32, x, y []float32, n, incX, incY, ix, iy uintptr) {
    51  	for i := 0; i < int(n); i++ {
    52  		dst[idst] = alpha*x[ix] + y[iy]
    53  		ix += incX
    54  		iy += incY
    55  		idst += incDst
    56  	}
    57  }
    58  
    59  // DotUnitary is
    60  //  for i, v := range x {
    61  //  	sum += y[i] * v
    62  //  }
    63  //  return sum
    64  func DotUnitary(x, y []float32) (sum float32) {
    65  	for i, v := range x {
    66  		sum += y[i] * v
    67  	}
    68  	return sum
    69  }
    70  
    71  // DotInc is
    72  //  for i := 0; i < int(n); i++ {
    73  //  	sum += y[iy] * x[ix]
    74  //  	ix += incX
    75  //  	iy += incY
    76  //  }
    77  //  return sum
    78  func DotInc(x, y []float32, n, incX, incY, ix, iy uintptr) (sum float32) {
    79  	for i := 0; i < int(n); i++ {
    80  		sum += y[iy] * x[ix]
    81  		ix += incX
    82  		iy += incY
    83  	}
    84  	return sum
    85  }
    86  
    87  // DdotUnitary is
    88  //  for i, v := range x {
    89  //  	sum += float64(y[i]) * float64(v)
    90  //  }
    91  //  return
    92  func DdotUnitary(x, y []float32) (sum float64) {
    93  	for i, v := range x {
    94  		sum += float64(y[i]) * float64(v)
    95  	}
    96  	return
    97  }
    98  
    99  // DdotInc is
   100  //  for i := 0; i < int(n); i++ {
   101  //  	sum += float64(y[iy]) * float64(x[ix])
   102  //  	ix += incX
   103  //  	iy += incY
   104  //  }
   105  //  return
   106  func DdotInc(x, y []float32, n, incX, incY, ix, iy uintptr) (sum float64) {
   107  	for i := 0; i < int(n); i++ {
   108  		sum += float64(y[iy]) * float64(x[ix])
   109  		ix += incX
   110  		iy += incY
   111  	}
   112  	return
   113  }