gonum.org/v1/gonum@v0.14.0/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  //go:build !amd64 || noasm || gccgo || safe
     6  // +build !amd64 noasm gccgo safe
     7  
     8  package f32
     9  
    10  // AxpyUnitary is
    11  //
    12  //	for i, v := range x {
    13  //		y[i] += alpha * v
    14  //	}
    15  func AxpyUnitary(alpha float32, x, y []float32) {
    16  	for i, v := range x {
    17  		y[i] += alpha * v
    18  	}
    19  }
    20  
    21  // AxpyUnitaryTo is
    22  //
    23  //	for i, v := range x {
    24  //		dst[i] = alpha*v + y[i]
    25  //	}
    26  func AxpyUnitaryTo(dst []float32, alpha float32, x, y []float32) {
    27  	for i, v := range x {
    28  		dst[i] = alpha*v + y[i]
    29  	}
    30  }
    31  
    32  // AxpyInc is
    33  //
    34  //	for i := 0; i < int(n); i++ {
    35  //		y[iy] += alpha * x[ix]
    36  //		ix += incX
    37  //		iy += incY
    38  //	}
    39  func AxpyInc(alpha float32, x, y []float32, n, incX, incY, ix, iy uintptr) {
    40  	for i := 0; i < int(n); i++ {
    41  		y[iy] += alpha * x[ix]
    42  		ix += incX
    43  		iy += incY
    44  	}
    45  }
    46  
    47  // AxpyIncTo is
    48  //
    49  //	for i := 0; i < int(n); i++ {
    50  //		dst[idst] = alpha*x[ix] + y[iy]
    51  //		ix += incX
    52  //		iy += incY
    53  //		idst += incDst
    54  //	}
    55  func AxpyIncTo(dst []float32, incDst, idst uintptr, alpha float32, x, y []float32, n, incX, incY, ix, iy uintptr) {
    56  	for i := 0; i < int(n); i++ {
    57  		dst[idst] = alpha*x[ix] + y[iy]
    58  		ix += incX
    59  		iy += incY
    60  		idst += incDst
    61  	}
    62  }
    63  
    64  // DotUnitary is
    65  //
    66  //	for i, v := range x {
    67  //		sum += y[i] * v
    68  //	}
    69  //	return sum
    70  func DotUnitary(x, y []float32) (sum float32) {
    71  	for i, v := range x {
    72  		sum += y[i] * v
    73  	}
    74  	return sum
    75  }
    76  
    77  // DotInc is
    78  //
    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  func DotInc(x, y []float32, n, incX, incY, ix, iy uintptr) (sum float32) {
    86  	for i := 0; i < int(n); i++ {
    87  		sum += y[iy] * x[ix]
    88  		ix += incX
    89  		iy += incY
    90  	}
    91  	return sum
    92  }
    93  
    94  // DdotUnitary is
    95  //
    96  //	for i, v := range x {
    97  //		sum += float64(y[i]) * float64(v)
    98  //	}
    99  //	return
   100  func DdotUnitary(x, y []float32) (sum float64) {
   101  	for i, v := range x {
   102  		sum += float64(y[i]) * float64(v)
   103  	}
   104  	return
   105  }
   106  
   107  // DdotInc is
   108  //
   109  //	for i := 0; i < int(n); i++ {
   110  //		sum += float64(y[iy]) * float64(x[ix])
   111  //		ix += incX
   112  //		iy += incY
   113  //	}
   114  //	return
   115  func DdotInc(x, y []float32, n, incX, incY, ix, iy uintptr) (sum float64) {
   116  	for i := 0; i < int(n); i++ {
   117  		sum += float64(y[iy]) * float64(x[ix])
   118  		ix += incX
   119  		iy += incY
   120  	}
   121  	return
   122  }
   123  
   124  // Sum is
   125  //
   126  //	var sum float32
   127  //	for _, v := range x {
   128  //		sum += v
   129  //	}
   130  //	return sum
   131  func Sum(x []float32) float32 {
   132  	var sum float32
   133  	for _, v := range x {
   134  		sum += v
   135  	}
   136  	return sum
   137  }