github.com/gopherd/gonum@v0.0.4/internal/asm/c128/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 c128
     9  
    10  import "math/cmplx"
    11  
    12  // AxpyUnitary is
    13  //  for i, v := range x {
    14  //  	y[i] += alpha * v
    15  //  }
    16  func AxpyUnitary(alpha complex128, x, y []complex128) {
    17  	for i, v := range x {
    18  		y[i] += alpha * v
    19  	}
    20  }
    21  
    22  // AxpyUnitaryTo is
    23  //  for i, v := range x {
    24  //  	dst[i] = alpha*v + y[i]
    25  //  }
    26  func AxpyUnitaryTo(dst []complex128, alpha complex128, x, y []complex128) {
    27  	for i, v := range x {
    28  		dst[i] = alpha*v + y[i]
    29  	}
    30  }
    31  
    32  // AxpyInc is
    33  //  for i := 0; i < int(n); i++ {
    34  //  	y[iy] += alpha * x[ix]
    35  //  	ix += incX
    36  //  	iy += incY
    37  //  }
    38  func AxpyInc(alpha complex128, x, y []complex128, n, incX, incY, ix, iy uintptr) {
    39  	for i := 0; i < int(n); i++ {
    40  		y[iy] += alpha * x[ix]
    41  		ix += incX
    42  		iy += incY
    43  	}
    44  }
    45  
    46  // AxpyIncTo is
    47  //  for i := 0; i < int(n); i++ {
    48  //  	dst[idst] = alpha*x[ix] + y[iy]
    49  //  	ix += incX
    50  //  	iy += incY
    51  //  	idst += incDst
    52  //  }
    53  func AxpyIncTo(dst []complex128, incDst, idst uintptr, alpha complex128, x, y []complex128, n, incX, incY, ix, iy uintptr) {
    54  	for i := 0; i < int(n); i++ {
    55  		dst[idst] = alpha*x[ix] + y[iy]
    56  		ix += incX
    57  		iy += incY
    58  		idst += incDst
    59  	}
    60  }
    61  
    62  // DscalUnitary is
    63  //  for i, v := range x {
    64  //  	x[i] = complex(real(v)*alpha, imag(v)*alpha)
    65  //  }
    66  func DscalUnitary(alpha float64, x []complex128) {
    67  	for i, v := range x {
    68  		x[i] = complex(real(v)*alpha, imag(v)*alpha)
    69  	}
    70  }
    71  
    72  // DscalInc is
    73  //  var ix uintptr
    74  //  for i := 0; i < int(n); i++ {
    75  //  	x[ix] = complex(real(x[ix])*alpha, imag(x[ix])*alpha)
    76  //  	ix += inc
    77  //  }
    78  func DscalInc(alpha float64, x []complex128, n, inc uintptr) {
    79  	var ix uintptr
    80  	for i := 0; i < int(n); i++ {
    81  		x[ix] = complex(real(x[ix])*alpha, imag(x[ix])*alpha)
    82  		ix += inc
    83  	}
    84  }
    85  
    86  // ScalInc is
    87  //  var ix uintptr
    88  //  for i := 0; i < int(n); i++ {
    89  //  	x[ix] *= alpha
    90  //  	ix += incX
    91  //  }
    92  func ScalInc(alpha complex128, x []complex128, n, inc uintptr) {
    93  	var ix uintptr
    94  	for i := 0; i < int(n); i++ {
    95  		x[ix] *= alpha
    96  		ix += inc
    97  	}
    98  }
    99  
   100  // ScalUnitary is
   101  //  for i := range x {
   102  //  	x[i] *= alpha
   103  //  }
   104  func ScalUnitary(alpha complex128, x []complex128) {
   105  	for i := range x {
   106  		x[i] *= alpha
   107  	}
   108  }
   109  
   110  // DotcUnitary is
   111  //  for i, v := range x {
   112  //  	sum += y[i] * cmplx.Conj(v)
   113  //  }
   114  //  return sum
   115  func DotcUnitary(x, y []complex128) (sum complex128) {
   116  	for i, v := range x {
   117  		sum += y[i] * cmplx.Conj(v)
   118  	}
   119  	return sum
   120  }
   121  
   122  // DotcInc is
   123  //  for i := 0; i < int(n); i++ {
   124  //  	sum += y[iy] * cmplx.Conj(x[ix])
   125  //  	ix += incX
   126  //  	iy += incY
   127  //  }
   128  //  return sum
   129  func DotcInc(x, y []complex128, n, incX, incY, ix, iy uintptr) (sum complex128) {
   130  	for i := 0; i < int(n); i++ {
   131  		sum += y[iy] * cmplx.Conj(x[ix])
   132  		ix += incX
   133  		iy += incY
   134  	}
   135  	return sum
   136  }
   137  
   138  // DotuUnitary is
   139  //  for i, v := range x {
   140  //  	sum += y[i] * v
   141  //  }
   142  //  return sum
   143  func DotuUnitary(x, y []complex128) (sum complex128) {
   144  	for i, v := range x {
   145  		sum += y[i] * v
   146  	}
   147  	return sum
   148  }
   149  
   150  // DotuInc is
   151  //  for i := 0; i < int(n); i++ {
   152  //  	sum += y[iy] * x[ix]
   153  //  	ix += incX
   154  //  	iy += incY
   155  //  }
   156  //  return sum
   157  func DotuInc(x, y []complex128, n, incX, incY, ix, iy uintptr) (sum complex128) {
   158  	for i := 0; i < int(n); i++ {
   159  		sum += y[iy] * x[ix]
   160  		ix += incX
   161  		iy += incY
   162  	}
   163  	return sum
   164  }