blas/gonum: call internal/asm functions directly
MODIFY
blas/gonum/level2float32.go
blas/gonum/level2float32.go
@@ -130,11 +130,31 @@ func (Implementation) Sgbmv(tA blas.Transpose, m, n, kL, kU int, alpha float32,
ky = -(lenY - 1) * incY
}
- // First form y = beta * y
+ // Form y = beta * y.
+ if beta != 1 {
+ if incY == 1 {
+ if beta == 0 {
+ for i := range y[:lenY] {
+ y[i] = 0
+ }
+ } else {
+ f32.ScalUnitary(beta, y[:lenY])
+ }
+ } else {
+ iy := ky
+ if beta == 0 {
+ for i := 0; i < lenY; i++ {
+ y[iy] = 0
+ iy += incY
+ }
+ } else {
if incY > 0 {
- Implementation{}.Sscal(lenY, beta, y, incY)
+ f32.ScalInc(beta, y, uintptr(lenY), uintptr(incY))
} else {
- Implementation{}.Sscal(lenY, beta, y, -incY)
+ f32.ScalInc(beta, y, uintptr(lenY), uintptr(-incY))
+ }
+ }
+ }
}
if alpha == 0 {
@@ -601,10 +621,28 @@ func (Implementation) Ssymv(ul blas.Uplo, n int, alpha float32, a []float32, lda
// Form y = beta * y
if beta != 1 {
+ if incY == 1 {
+ if beta == 0 {
+ for i := range y[:n] {
+ y[i] = 0
+ }
+ } else {
+ f32.ScalUnitary(beta, y[:n])
+ }
+ } else {
+ iy := ky
+ if beta == 0 {
+ for i := 0; i < n; i++ {
+ y[iy] = 0
+ iy += incY
+ }
+ } else {
if incY > 0 {
- Implementation{}.Sscal(n, beta, y, incY)
+ f32.ScalInc(beta, y, uintptr(n), uintptr(incY))
} else {
- Implementation{}.Sscal(n, beta, y, -incY)
+ f32.ScalInc(beta, y, uintptr(n), uintptr(-incY))
+ }
+ }
}
}
@@ -1372,11 +1410,31 @@ func (Implementation) Ssbmv(ul blas.Uplo, n, k int, alpha float32, a []float32,
ky = -(lenY - 1) * incY
}
- // First form y = beta * y
+ // Form y = beta * y.
+ if beta != 1 {
+ if incY == 1 {
+ if beta == 0 {
+ for i := range y[:n] {
+ y[i] = 0
+ }
+ } else {
+ f32.ScalUnitary(beta, y[:n])
+ }
+ } else {
+ iy := ky
+ if beta == 0 {
+ for i := 0; i < n; i++ {
+ y[iy] = 0
+ iy += incY
+ }
+ } else {
if incY > 0 {
- Implementation{}.Sscal(lenY, beta, y, incY)
+ f32.ScalInc(beta, y, uintptr(n), uintptr(incY))
} else {
- Implementation{}.Sscal(lenY, beta, y, -incY)
+ f32.ScalInc(beta, y, uintptr(n), uintptr(-incY))
+ }
+ }
+ }
}
if alpha == 0 {
@@ -1911,12 +1969,30 @@ func (Implementation) Sspmv(ul blas.Uplo, n int, alpha float32, ap []float32, x
ky = -(n - 1) * incY
}
- // Form y = beta * y
+ // Form y = beta * y.
if beta != 1 {
+ if incY == 1 {
+ if beta == 0 {
+ for i := range y[:n] {
+ y[i] = 0
+ }
+ } else {
+ f32.ScalUnitary(beta, y[:n])
+ }
+ } else {
+ iy := ky
+ if beta == 0 {
+ for i := 0; i < n; i++ {
+ y[iy] = 0
+ iy += incY
+ }
+ } else {
if incY > 0 {
- Implementation{}.Sscal(n, beta, y, incY)
+ f32.ScalInc(beta, y, uintptr(n), uintptr(incY))
} else {
- Implementation{}.Sscal(n, beta, y, -incY)
+ f32.ScalInc(beta, y, uintptr(n), uintptr(-incY))
+ }
+ }
}
}

MODIFY
blas/gonum/level2float64.go
blas/gonum/level2float64.go
@@ -124,11 +124,31 @@ func (Implementation) Dgbmv(tA blas.Transpose, m, n, kL, kU int, alpha float64,
ky = -(lenY - 1) * incY
}
- // First form y = beta * y
+ // Form y = beta * y.
+ if beta != 1 {
+ if incY == 1 {
+ if beta == 0 {
+ for i := range y[:lenY] {
+ y[i] = 0
+ }
+ } else {
+ f64.ScalUnitary(beta, y[:lenY])
+ }
+ } else {
+ iy := ky
+ if beta == 0 {
+ for i := 0; i < lenY; i++ {
+ y[iy] = 0
+ iy += incY
+ }
+ } else {
if incY > 0 {
- Implementation{}.Dscal(lenY, beta, y, incY)
+ f64.ScalInc(beta, y, uintptr(lenY), uintptr(incY))
} else {
- Implementation{}.Dscal(lenY, beta, y, -incY)
+ f64.ScalInc(beta, y, uintptr(lenY), uintptr(-incY))
+ }
+ }
+ }
}
if alpha == 0 {
@@ -589,10 +609,28 @@ func (Implementation) Dsymv(ul blas.Uplo, n int, alpha float64, a []float64, lda
// Form y = beta * y
if beta != 1 {
+ if incY == 1 {
+ if beta == 0 {
+ for i := range y[:n] {
+ y[i] = 0
+ }
+ } else {
+ f64.ScalUnitary(beta, y[:n])
+ }
+ } else {
+ iy := ky
+ if beta == 0 {
+ for i := 0; i < n; i++ {
+ y[iy] = 0
+ iy += incY
+ }
+ } else {
if incY > 0 {
- Implementation{}.Dscal(n, beta, y, incY)
+ f64.ScalInc(beta, y, uintptr(n), uintptr(incY))
} else {
- Implementation{}.Dscal(n, beta, y, -incY)
+ f64.ScalInc(beta, y, uintptr(n), uintptr(-incY))
+ }
+ }
}
}
@@ -1352,11 +1390,31 @@ func (Implementation) Dsbmv(ul blas.Uplo, n, k int, alpha float64, a []float64,
ky = -(lenY - 1) * incY
}
- // First form y = beta * y
+ // Form y = beta * y.
+ if beta != 1 {
+ if incY == 1 {
+ if beta == 0 {
+ for i := range y[:n] {
+ y[i] = 0
+ }
+ } else {
+ f64.ScalUnitary(beta, y[:n])
+ }
+ } else {
+ iy := ky
+ if beta == 0 {
+ for i := 0; i < n; i++ {
+ y[iy] = 0
+ iy += incY
+ }
+ } else {
if incY > 0 {
- Implementation{}.Dscal(lenY, beta, y, incY)
+ f64.ScalInc(beta, y, uintptr(n), uintptr(incY))
} else {
- Implementation{}.Dscal(lenY, beta, y, -incY)
+ f64.ScalInc(beta, y, uintptr(n), uintptr(-incY))
+ }
+ }
+ }
}
if alpha == 0 {
@@ -1883,12 +1941,30 @@ func (Implementation) Dspmv(ul blas.Uplo, n int, alpha float64, ap []float64, x
ky = -(n - 1) * incY
}
- // Form y = beta * y
+ // Form y = beta * y.
if beta != 1 {
+ if incY == 1 {
+ if beta == 0 {
+ for i := range y[:n] {
+ y[i] = 0
+ }
+ } else {
+ f64.ScalUnitary(beta, y[:n])
+ }
+ } else {
+ iy := ky
+ if beta == 0 {
+ for i := 0; i < n; i++ {
+ y[iy] = 0
+ iy += incY
+ }
+ } else {
if incY > 0 {
- Implementation{}.Dscal(n, beta, y, incY)
+ f64.ScalInc(beta, y, uintptr(n), uintptr(incY))
} else {
- Implementation{}.Dscal(n, beta, y, -incY)
+ f64.ScalInc(beta, y, uintptr(n), uintptr(-incY))
+ }
+ }
}
}

MODIFY
blas/gonum/single_precision.bash
blas/gonum/single_precision.bash
@@ -118,14 +118,14 @@ cat level2float64.go \
\
| gofmt -r 'float64 -> float32' \
\
-| gofmt -r 'Dscal -> Sscal' \
-\
| gofmt -r 'f64.AxpyInc -> f32.AxpyInc' \
| gofmt -r 'f64.AxpyIncTo -> f32.AxpyIncTo' \
| gofmt -r 'f64.AxpyUnitary -> f32.AxpyUnitary' \
| gofmt -r 'f64.AxpyUnitaryTo -> f32.AxpyUnitaryTo' \
| gofmt -r 'f64.DotInc -> f32.DotInc' \
| gofmt -r 'f64.DotUnitary -> f32.DotUnitary' \
+| gofmt -r 'f64.ScalInc -> f32.ScalInc' \
+| gofmt -r 'f64.ScalUnitary -> f32.ScalUnitary' \
| gofmt -r 'f64.Ger -> f32.Ger' \
\
| sed -e "s_^\(func (Implementation) \)D\(.*\)\$_$WARNINGF32\1S\2_" \

MODIFY
internal/asm/c64/scal.go
internal/asm/c64/scal.go
@@ -53,3 +53,27 @@ func ScalIncTo(dst []complex64, incDst uintptr, alpha complex64, x []complex64,
idst += incDst
}
}
+
+// SscalUnitary is
+// for i, v := range x {
+// x[i] = complex(real(v)*alpha, imag(v)*alpha)
+// }
+func SscalUnitary(alpha float32, x []complex64) {
+ for i, v := range x {
+ x[i] = complex(real(v)*alpha, imag(v)*alpha)
+ }
+}
+
+// SscalInc is
+// var ix uintptr
+// for i := 0; i < int(n); i++ {
+// x[ix] = complex(real(x[ix])*alpha, imag(x[ix])*alpha)
+// ix += inc
+// }
+func SscalInc(alpha float32, x []complex64, n, inc uintptr) {
+ var ix uintptr
+ for i := 0; i < int(n); i++ {
+ x[ix] = complex(real(x[ix])*alpha, imag(x[ix])*alpha)
+ ix += inc
+ }
+}

blas/gonum: call internal/asm functions directly