asm/c128: ScalInc stubs and tests.
MODIFY
internal/asm/c128/scal.go
internal/asm/c128/scal.go
@@ -14,20 +14,6 @@ func ScalUnitaryTo(dst []complex128, alpha complex128, x []complex128) {
}
}
-// ScalInc is
-// var ix uintptr
-// for i := 0; i < int(n); i++ {
-// x[ix] *= alpha
-// ix += incX
-// }
-func ScalInc(alpha complex128, x []complex128, n, incX uintptr) {
- var ix uintptr
- for i := 0; i < int(n); i++ {
- x[ix] *= alpha
- ix += incX
- }
-}
-
// ScalIncTo is
// var idst, ix uintptr
// for i := 0; i < int(n); i++ {

MODIFY
internal/asm/c128/stubs_amd64.go
internal/asm/c128/stubs_amd64.go
@@ -45,7 +45,15 @@ func DscalUnitary(alpha float64, x []complex128)
// for i := 0; i < n; i++ {
// x[i*inc] = complex(real(x[i*inc])*alpha, imag(x[i*inc]))
// }
-func DscalInc(n int, alpha float64, x []complex128, inc int)
+func DscalInc(alpha float64, x []complex128, n, inc int)
+
+// ScalInc is
+// var ix uintptr
+// for i := 0; i < int(n); i++ {
+// x[ix] *= alpha
+// ix += incX
+// }
+func ScalInc(alpha complex128, x []complex128, n, inc int)
// ScalUnitary is
// for i := range x {

MODIFY
internal/asm/c128/stubs_noasm.go
internal/asm/c128/stubs_noasm.go
@@ -70,12 +70,26 @@ func DscalUnitary(alpha float64, x []complex128) {
// for i := 0; i < n; i++ {
// x[i*inc] = complex(real(x[i*inc])*alpha, imag(x[i*inc]))
// }
-func DscalInc(n int, alpha float64, x []complex128, inc int) {
+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]))
}
}
+// ScalInc is
+// var ix uintptr
+// for i := 0; i < int(n); i++ {
+// x[ix] *= alpha
+// ix += incX
+// }
+func ScalInc(alpha complex128, x []complex128, n, inc int) {
+ var ix int
+ for i := 0; i < int(n); i++ {
+ x[ix] *= alpha
+ ix += inc
+ }
+}
+
// ScalUnitary is
// for i := range x {
// x[i] *= alpha

MODIFY
internal/asm/c128/stubs_test.go
internal/asm/c128/stubs_test.go
@@ -240,7 +240,7 @@ func TestDscalInc(t *testing.T) {
xg := guardIncVector(test.x, xGdVal, incX, gdLn)
x := xg[gdLn : len(xg)-gdLn]
- DscalInc(n, test.alpha, x, incX)
+ DscalInc(test.alpha, x, n, incX)
for i := range test.want {
if !same(x[i*incX], test.want[i]) {
@@ -308,9 +308,28 @@ func TestScalUnitary(t *testing.T) {
if !isValidGuard(xg, xGdVal, xgLn) {
t.Errorf(msgGuard, prefix, "x", xg[:xgLn], xg[len(xg)-xgLn:])
}
- if t.Failed() {
- //t.FailNow()
}
}
}
+
+func TestScalInc(t *testing.T) {
+ const xGdVal = -0.5
+ gdLn := 4
+ for i, test := range scalTests {
+ n := len(test.x)
+ for _, inc := range []int{1, 2, 3, 4, 7, 10} {
+ prefix := fmt.Sprintf("Test %v (x:%v)", i, inc)
+ xg := guardIncVector(test.x, xGdVal, inc, gdLn)
+ x := xg[gdLn : len(xg)-gdLn]
+
+ ScalInc(test.alpha, x, n, inc)
+
+ for i := range test.want {
+ if !same(x[i*inc], test.want[i]) {
+ t.Errorf(msgVal, prefix, i, x[i*inc], test.want[i])
+ }
+ }
+ checkValidIncGuard(t, xg, xGdVal, inc, gdLn)
+ }
+ }
}

asm/c128: ScalInc stubs and tests.