-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathsdsdot.go
More file actions
34 lines (29 loc) · 715 Bytes
/
sdsdot.go
File metadata and controls
34 lines (29 loc) · 715 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package blas
// \alpha + X^T Y computed using float64
func Sdsdot(N int, alpha float32, X []float32, incX int, Y []float32, incY int) float32
func sdsdot(N int, alpha float32, X []float32, incX int, Y []float32, incY int) float32 {
var (
a, b, c, d float64
xi, yi int
)
for ; N >= 4; N -= 4 {
a += float64(X[xi]) * float64(Y[yi])
xi += incX
yi += incY
b += float64(X[xi]) * float64(Y[yi])
xi += incX
yi += incY
c += float64(X[xi]) * float64(Y[yi])
xi += incX
yi += incY
d += float64(X[xi]) * float64(Y[yi])
xi += incX
yi += incY
}
for ; N > 0; N-- {
a += float64(X[xi]) * float64(Y[yi])
xi += incX
yi += incY
}
return float32(float64(alpha) + (b + c) + (d + a))
}