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