asm/c128: Fixes to dscal algorithm implementation.
MODIFY
internal/asm/c128/stubs_amd64.go
internal/asm/c128/stubs_amd64.go
@@ -37,7 +37,7 @@ func AxpyIncTo(dst []complex128, incDst, idst uintptr, alpha complex128, x, y []
// DscalUnitary is
// for i, v := range x {
-// x[i] = complex(real(v)*alpha, imag(v))
+// x[i] = complex(real(v)*alpha, imag(v)*alpha)
// }
func DscalUnitary(alpha float64, x []complex128)

MODIFY
internal/asm/c128/stubs_noasm.go
internal/asm/c128/stubs_noasm.go
@@ -58,11 +58,11 @@ func AxpyIncTo(dst []complex128, incDst, idst uintptr, alpha complex128, x, y []
// DscalUnitary is
// for i, v := range x {
-// x[i] = complex(real(v)*alpha, imag(v))
+// x[i] = complex(real(v)*alpha, imag(v)*alpha)
// }
func DscalUnitary(alpha float64, x []complex128) {
for i, v := range x {
- x[i] = complex(real(v)*alpha, imag(v))
+ x[i] = complex(real(v)*alpha, imag(v)*alpha)
}
}
@@ -72,7 +72,7 @@ func DscalUnitary(alpha float64, x []complex128) {
// }
func DscalInc(alpha float64, x []complex128, n, inc int) {
for i := 0; i < n; i++ {
- x[i*inc] = complex(real(x[i*inc])*alpha, imag(x[i*inc]))
+ x[i*inc] = complex(real(x[i*inc])*alpha, imag(x[i*inc])*alpha)
}
}

MODIFY
internal/asm/c128/stubs_test.go
internal/asm/c128/stubs_test.go
@@ -188,22 +188,22 @@ var dscalTests = []struct {
{
alpha: 2,
x: []complex128{1 + 2i},
- want: []complex128{2 + 2i},
+ want: []complex128{2 + 4i},
},
{
alpha: 2,
x: []complex128{1 + 2i},
- want: []complex128{2 + 2i},
+ want: []complex128{2 + 4i},
},
{
alpha: 3,
x: []complex128{1 + 2i, 5 + 4i, 3 + 6i, 8 + 12i, -3 - 2i, -5 + 5i},
- want: []complex128{3 + 2i, 15 + 4i, 9 + 6i, 24 + 12i, -9 - 2i, -15 + 5i},
+ want: []complex128{3 + 6i, 15 + 12i, 9 + 18i, 24 + 36i, -9 - 6i, -15 + 15i},
},
{
alpha: 5,
x: []complex128{1 + 2i, 5 + 4i, 3 + 6i, 8 + 12i, -3 - 2i, -5 + 5i, 1 + 2i, 5 + 4i, 3 + 6i, 8 + 12i, -3 - 2i, -5 + 5i},
- want: []complex128{5 + 2i, 25 + 4i, 15 + 6i, 40 + 12i, -15 - 2i, -25 + 5i, 5 + 2i, 25 + 4i, 15 + 6i, 40 + 12i, -15 - 2i, -25 + 5i},
+ want: []complex128{5 + 10i, 25 + 20i, 15 + 30i, 40 + 60i, -15 - 10i, -25 + 25i, 5 + 10i, 25 + 20i, 15 + 30i, 40 + 60i, -15 - 10i, -25 + 25i},
},
}

asm/c128: Fixes to dscal algorithm implementation.