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