| 1 |
. |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
package c128 |
| 9 |
|
| 10 |
import "math/cmplx" |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
func AxpyUnitary(alpha complex128, x, y []complex128) { |
| 18 |
for i, v := range x { |
| 19 |
y[i] += alpha * v |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 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 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 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 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 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 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 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 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 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 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 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 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
func ScalUnitary(alpha complex128, x []complex128) { |
| 113 |
for i := range x { |
| 114 |
x[i] *= alpha |
| 115 |
} |
| 116 |
} |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 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 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 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 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 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 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 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 |
} |