mirror of
https://github.com/gonum/gonum.git
synced 2025-10-20 21:59:25 +08:00
internal/asm/...: add documentation
This documentation is intended to allow gonum developers to see exactly what an asm function is intended to do. They are not for external code consumers.
This commit is contained in:
6
asm/c128/doc.go
Normal file
6
asm/c128/doc.go
Normal file
@@ -0,0 +1,6 @@
|
||||
// Copyright ©2017 The gonum Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package c128 provides complex128 vector primitives.
|
||||
package c128
|
@@ -6,18 +6,30 @@ package c128
|
||||
|
||||
import "math/cmplx"
|
||||
|
||||
// DotcUnitary is
|
||||
// for i, v := range x {
|
||||
// sum += y[i] * cmplx.Conj(v)
|
||||
// }
|
||||
// return sum
|
||||
func DotcUnitary(x, y []complex128) (sum complex128) {
|
||||
for i, v := range x {
|
||||
sum += y[i] * cmplx.Conj(v)
|
||||
}
|
||||
return
|
||||
return sum
|
||||
}
|
||||
|
||||
// DotcInc is
|
||||
// for i := 0; i < int(n); i++ {
|
||||
// sum += y[iy] * cmplx.Conj(x[ix])
|
||||
// ix += incX
|
||||
// iy += incY
|
||||
// }
|
||||
// return sum
|
||||
func DotcInc(x, y []complex128, n, incX, incY, ix, iy uintptr) (sum complex128) {
|
||||
for i := 0; i < int(n); i++ {
|
||||
sum += y[iy] * cmplx.Conj(x[ix])
|
||||
ix += incX
|
||||
iy += incY
|
||||
}
|
||||
return
|
||||
return sum
|
||||
}
|
||||
|
@@ -4,18 +4,30 @@
|
||||
|
||||
package c128
|
||||
|
||||
// DotuUnitary is
|
||||
// for i, v := range x {
|
||||
// sum += y[i] * v
|
||||
// }
|
||||
// return sum
|
||||
func DotuUnitary(x, y []complex128) (sum complex128) {
|
||||
for i, v := range x {
|
||||
sum += y[i] * v
|
||||
}
|
||||
return
|
||||
return sum
|
||||
}
|
||||
|
||||
// DotuInc is
|
||||
// for i := 0; i < int(n); i++ {
|
||||
// sum += y[iy] * x[ix]
|
||||
// ix += incX
|
||||
// iy += incY
|
||||
// }
|
||||
// return sum
|
||||
func DotuInc(x, y []complex128, n, incX, incY, ix, iy uintptr) (sum complex128) {
|
||||
for i := 0; i < int(n); i++ {
|
||||
sum += y[iy] * x[ix]
|
||||
ix += incX
|
||||
iy += incY
|
||||
}
|
||||
return
|
||||
return sum
|
||||
}
|
||||
|
@@ -4,18 +4,32 @@
|
||||
|
||||
package c128
|
||||
|
||||
// ScalUnitary is
|
||||
// for i := range x {
|
||||
// x[i] *= alpha
|
||||
// }
|
||||
func ScalUnitary(alpha complex128, x []complex128) {
|
||||
for i := range x {
|
||||
x[i] *= alpha
|
||||
}
|
||||
}
|
||||
|
||||
// ScalUnitaryTo is
|
||||
// for i, v := range x {
|
||||
// dst[i] = alpha * v
|
||||
// }
|
||||
func ScalUnitaryTo(dst []complex128, alpha complex128, x []complex128) {
|
||||
for i, v := range x {
|
||||
dst[i] = alpha * v
|
||||
}
|
||||
}
|
||||
|
||||
// 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++ {
|
||||
@@ -24,6 +38,13 @@ func ScalInc(alpha complex128, x []complex128, n, incX uintptr) {
|
||||
}
|
||||
}
|
||||
|
||||
// ScalIncTo is
|
||||
// var idst, ix uintptr
|
||||
// for i := 0; i < int(n); i++ {
|
||||
// dst[idst] = alpha * x[ix]
|
||||
// ix += incX
|
||||
// idst += incDst
|
||||
// }
|
||||
func ScalIncTo(dst []complex128, incDst uintptr, alpha complex128, x []complex128, n, incX uintptr) {
|
||||
var idst, ix uintptr
|
||||
for i := 0; i < int(n); i++ {
|
||||
|
@@ -6,10 +6,31 @@
|
||||
|
||||
package c128
|
||||
|
||||
// AxpyUnitary is
|
||||
// for i, v := range x {
|
||||
// y[i] += alpha * v
|
||||
// }
|
||||
func AxpyUnitary(alpha complex128, x, y []complex128)
|
||||
|
||||
// AxpyUnitaryTo is
|
||||
// for i, v := range x {
|
||||
// dst[i] = alpha*v + y[i]
|
||||
// }
|
||||
func AxpyUnitaryTo(dst []complex128, alpha complex128, x, y []complex128)
|
||||
|
||||
// AxpyInc is
|
||||
// for i := 0; i < int(n); i++ {
|
||||
// y[iy] += alpha * x[ix]
|
||||
// ix += incX
|
||||
// iy += incY
|
||||
// }
|
||||
func AxpyInc(alpha complex128, x, y []complex128, n, incX, incY, ix, iy uintptr)
|
||||
|
||||
// AxpyIncTo is
|
||||
// for i := 0; i < int(n); i++ {
|
||||
// dst[idst] = alpha*x[ix] + y[iy]
|
||||
// ix += incX
|
||||
// iy += incY
|
||||
// idst += incDst
|
||||
// }
|
||||
func AxpyIncTo(dst []complex128, incDst, idst uintptr, alpha complex128, x, y []complex128, n, incX, incY, ix, iy uintptr)
|
||||
|
@@ -6,18 +6,32 @@
|
||||
|
||||
package c128
|
||||
|
||||
// AxpyUnitary is
|
||||
// for i, v := range x {
|
||||
// y[i] += alpha * v
|
||||
// }
|
||||
func AxpyUnitary(alpha complex128, x, y []complex128) {
|
||||
for i, v := range x {
|
||||
y[i] += alpha * v
|
||||
}
|
||||
}
|
||||
|
||||
// AxpyUnitaryTo is
|
||||
// for i, v := range x {
|
||||
// dst[i] = alpha*v + y[i]
|
||||
// }
|
||||
func AxpyUnitaryTo(dst []complex128, alpha complex128, x, y []complex128) {
|
||||
for i, v := range x {
|
||||
dst[i] = alpha*v + y[i]
|
||||
}
|
||||
}
|
||||
|
||||
// AxpyInc is
|
||||
// for i := 0; i < int(n); i++ {
|
||||
// y[iy] += alpha * x[ix]
|
||||
// ix += incX
|
||||
// iy += incY
|
||||
// }
|
||||
func AxpyInc(alpha complex128, x, y []complex128, n, incX, incY, ix, iy uintptr) {
|
||||
for i := 0; i < int(n); i++ {
|
||||
y[iy] += alpha * x[ix]
|
||||
@@ -26,6 +40,13 @@ func AxpyInc(alpha complex128, x, y []complex128, n, incX, incY, ix, iy uintptr)
|
||||
}
|
||||
}
|
||||
|
||||
// AxpyIncTo is
|
||||
// for i := 0; i < int(n); i++ {
|
||||
// dst[idst] = alpha*x[ix] + y[iy]
|
||||
// ix += incX
|
||||
// iy += incY
|
||||
// idst += incDst
|
||||
// }
|
||||
func AxpyIncTo(dst []complex128, incDst, idst uintptr, alpha complex128, x, y []complex128, n, incX, incY, ix, iy uintptr) {
|
||||
for i := 0; i < int(n); i++ {
|
||||
dst[idst] = alpha*x[ix] + y[iy]
|
||||
|
6
asm/c64/doc.go
Normal file
6
asm/c64/doc.go
Normal file
@@ -0,0 +1,6 @@
|
||||
// Copyright ©2017 The gonum Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package c64 provides complex64 vector primitives.
|
||||
package c64
|
@@ -4,18 +4,30 @@
|
||||
|
||||
package c64
|
||||
|
||||
// DotcUnitary is
|
||||
// for i, v := range x {
|
||||
// sum += y[i] * conj(v)
|
||||
// }
|
||||
// return sum
|
||||
func DotcUnitary(x, y []complex64) (sum complex64) {
|
||||
for i, v := range x {
|
||||
sum += y[i] * conj(v)
|
||||
}
|
||||
return
|
||||
return sum
|
||||
}
|
||||
|
||||
// DotcInc is
|
||||
// for i := 0; i < int(n); i++ {
|
||||
// sum += y[iy] * conj(x[ix])
|
||||
// ix += incX
|
||||
// iy += incY
|
||||
// }
|
||||
// return sum
|
||||
func DotcInc(x, y []complex64, n, incX, incY, ix, iy uintptr) (sum complex64) {
|
||||
for i := 0; i < int(n); i++ {
|
||||
sum += y[iy] * conj(x[ix])
|
||||
ix += incX
|
||||
iy += incY
|
||||
}
|
||||
return
|
||||
return sum
|
||||
}
|
||||
|
@@ -4,18 +4,30 @@
|
||||
|
||||
package c64
|
||||
|
||||
// DotuUnitary is
|
||||
// for i, v := range x {
|
||||
// sum += y[i] * v
|
||||
// }
|
||||
// return sum
|
||||
func DotuUnitary(x, y []complex64) (sum complex64) {
|
||||
for i, v := range x {
|
||||
sum += y[i] * v
|
||||
}
|
||||
return
|
||||
return sum
|
||||
}
|
||||
|
||||
// DotuInc is
|
||||
// for i := 0; i < int(n); i++ {
|
||||
// sum += y[iy] * x[ix]
|
||||
// ix += incX
|
||||
// iy += incY
|
||||
// }
|
||||
// return sum
|
||||
func DotuInc(x, y []complex64, n, incX, incY, ix, iy uintptr) (sum complex64) {
|
||||
for i := 0; i < int(n); i++ {
|
||||
sum += y[iy] * x[ix]
|
||||
ix += incX
|
||||
iy += incY
|
||||
}
|
||||
return
|
||||
return sum
|
||||
}
|
||||
|
@@ -4,18 +4,32 @@
|
||||
|
||||
package c64
|
||||
|
||||
// ScalUnitary is
|
||||
// for i := range x {
|
||||
// x[i] *= alpha
|
||||
// }
|
||||
func ScalUnitary(alpha complex64, x []complex64) {
|
||||
for i := range x {
|
||||
x[i] *= alpha
|
||||
}
|
||||
}
|
||||
|
||||
// ScalUnitaryTo is
|
||||
// for i, v := range x {
|
||||
// dst[i] = alpha * v
|
||||
// }
|
||||
func ScalUnitaryTo(dst []complex64, alpha complex64, x []complex64) {
|
||||
for i, v := range x {
|
||||
dst[i] = alpha * v
|
||||
}
|
||||
}
|
||||
|
||||
// ScalInc is
|
||||
// var ix uintptr
|
||||
// for i := 0; i < int(n); i++ {
|
||||
// x[ix] *= alpha
|
||||
// ix += incX
|
||||
// }
|
||||
func ScalInc(alpha complex64, x []complex64, n, incX uintptr) {
|
||||
var ix uintptr
|
||||
for i := 0; i < int(n); i++ {
|
||||
@@ -24,6 +38,13 @@ func ScalInc(alpha complex64, x []complex64, n, incX uintptr) {
|
||||
}
|
||||
}
|
||||
|
||||
// ScalIncTo is
|
||||
// var idst, ix uintptr
|
||||
// for i := 0; i < int(n); i++ {
|
||||
// dst[idst] = alpha * x[ix]
|
||||
// ix += incX
|
||||
// idst += incDst
|
||||
// }
|
||||
func ScalIncTo(dst []complex64, incDst uintptr, alpha complex64, x []complex64, n, incX uintptr) {
|
||||
var idst, ix uintptr
|
||||
for i := 0; i < int(n); i++ {
|
||||
|
@@ -6,10 +6,31 @@
|
||||
|
||||
package c64
|
||||
|
||||
// AxpyUnitary is
|
||||
// for i, v := range x {
|
||||
// y[i] += alpha * v
|
||||
// }
|
||||
func AxpyUnitary(alpha complex64, x, y []complex64)
|
||||
|
||||
// AxpyUnitaryTo is
|
||||
// for i, v := range x {
|
||||
// dst[i] = alpha*v + y[i]
|
||||
// }
|
||||
func AxpyUnitaryTo(dst []complex64, alpha complex64, x, y []complex64)
|
||||
|
||||
// AxpyInc is
|
||||
// for i := 0; i < int(n); i++ {
|
||||
// y[iy] += alpha * x[ix]
|
||||
// ix += incX
|
||||
// iy += incY
|
||||
// }
|
||||
func AxpyInc(alpha complex64, x, y []complex64, n, incX, incY, ix, iy uintptr)
|
||||
|
||||
// AxpyIncTo is
|
||||
// for i := 0; i < int(n); i++ {
|
||||
// dst[idst] = alpha*x[ix] + y[iy]
|
||||
// ix += incX
|
||||
// iy += incY
|
||||
// idst += incDst
|
||||
// }
|
||||
func AxpyIncTo(dst []complex64, incDst, idst uintptr, alpha complex64, x, y []complex64, n, incX, incY, ix, iy uintptr)
|
||||
|
@@ -6,18 +6,32 @@
|
||||
|
||||
package c64
|
||||
|
||||
// AxpyUnitary is
|
||||
// for i, v := range x {
|
||||
// y[i] += alpha * v
|
||||
// }
|
||||
func AxpyUnitary(alpha complex64, x, y []complex64) {
|
||||
for i, v := range x {
|
||||
y[i] += alpha * v
|
||||
}
|
||||
}
|
||||
|
||||
// AxpyUnitaryTo is
|
||||
// for i, v := range x {
|
||||
// dst[i] = alpha*v + y[i]
|
||||
// }
|
||||
func AxpyUnitaryTo(dst []complex64, alpha complex64, x, y []complex64) {
|
||||
for i, v := range x {
|
||||
dst[i] = alpha*v + y[i]
|
||||
}
|
||||
}
|
||||
|
||||
// AxpyInc is
|
||||
// for i := 0; i < int(n); i++ {
|
||||
// y[iy] += alpha * x[ix]
|
||||
// ix += incX
|
||||
// iy += incY
|
||||
// }
|
||||
func AxpyInc(alpha complex64, x, y []complex64, n, incX, incY, ix, iy uintptr) {
|
||||
for i := 0; i < int(n); i++ {
|
||||
y[iy] += alpha * x[ix]
|
||||
@@ -26,6 +40,13 @@ func AxpyInc(alpha complex64, x, y []complex64, n, incX, incY, ix, iy uintptr) {
|
||||
}
|
||||
}
|
||||
|
||||
// AxpyIncTo is
|
||||
// for i := 0; i < int(n); i++ {
|
||||
// dst[idst] = alpha*x[ix] + y[iy]
|
||||
// ix += incX
|
||||
// iy += incY
|
||||
// idst += incDst
|
||||
// }
|
||||
func AxpyIncTo(dst []complex64, incDst, idst uintptr, alpha complex64, x, y []complex64, n, incX, incY, ix, iy uintptr) {
|
||||
for i := 0; i < int(n); i++ {
|
||||
dst[idst] = alpha*x[ix] + y[iy]
|
||||
|
@@ -4,6 +4,11 @@
|
||||
|
||||
package f32
|
||||
|
||||
// DdotUnitary is
|
||||
// for i, v := range x {
|
||||
// sum += float64(y[i]) * float64(v)
|
||||
// }
|
||||
// return
|
||||
func DdotUnitary(x, y []float32) (sum float64) {
|
||||
for i, v := range x {
|
||||
sum += float64(y[i]) * float64(v)
|
||||
@@ -11,6 +16,13 @@ func DdotUnitary(x, y []float32) (sum float64) {
|
||||
return
|
||||
}
|
||||
|
||||
// DdotInc is
|
||||
// for i := 0; i < int(n); i++ {
|
||||
// sum += float64(y[iy]) * float64(x[ix])
|
||||
// ix += incX
|
||||
// iy += incY
|
||||
// }
|
||||
// return
|
||||
func DdotInc(x, y []float32, n, incX, incY, ix, iy uintptr) (sum float64) {
|
||||
for i := 0; i < int(n); i++ {
|
||||
sum += float64(y[iy]) * float64(x[ix])
|
||||
|
6
asm/f32/doc.go
Normal file
6
asm/f32/doc.go
Normal file
@@ -0,0 +1,6 @@
|
||||
// Copyright ©2017 The gonum Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package f32 provides float32 vector primitives.
|
||||
package f32
|
@@ -4,18 +4,30 @@
|
||||
|
||||
package f32
|
||||
|
||||
// DotUnitary is
|
||||
// for i, v := range x {
|
||||
// sum += y[i] * v
|
||||
// }
|
||||
// return sum
|
||||
func DotUnitary(x, y []float32) (sum float32) {
|
||||
for i, v := range x {
|
||||
sum += y[i] * v
|
||||
}
|
||||
return
|
||||
return sum
|
||||
}
|
||||
|
||||
// DotInc is
|
||||
// for i := 0; i < int(n); i++ {
|
||||
// sum += y[iy] * x[ix]
|
||||
// ix += incX
|
||||
// iy += incY
|
||||
// }
|
||||
// return sum
|
||||
func DotInc(x, y []float32, n, incX, incY, ix, iy uintptr) (sum float32) {
|
||||
for i := 0; i < int(n); i++ {
|
||||
sum += y[iy] * x[ix]
|
||||
ix += incX
|
||||
iy += incY
|
||||
}
|
||||
return
|
||||
return sum
|
||||
}
|
||||
|
@@ -4,18 +4,32 @@
|
||||
|
||||
package f32
|
||||
|
||||
// ScalUnitary is
|
||||
// for i := range x {
|
||||
// x[i] *= alpha
|
||||
// }
|
||||
func ScalUnitary(alpha float32, x []float32) {
|
||||
for i := range x {
|
||||
x[i] *= alpha
|
||||
}
|
||||
}
|
||||
|
||||
// ScalUnitaryTo is
|
||||
// for i, v := range x {
|
||||
// dst[i] = alpha * v
|
||||
// }
|
||||
func ScalUnitaryTo(dst []float32, alpha float32, x []float32) {
|
||||
for i, v := range x {
|
||||
dst[i] = alpha * v
|
||||
}
|
||||
}
|
||||
|
||||
// ScalInc is
|
||||
// var ix uintptr
|
||||
// for i := 0; i < int(n); i++ {
|
||||
// x[ix] *= alpha
|
||||
// ix += incX
|
||||
// }
|
||||
func ScalInc(alpha float32, x []float32, n, incX uintptr) {
|
||||
var ix uintptr
|
||||
for i := 0; i < int(n); i++ {
|
||||
@@ -24,6 +38,13 @@ func ScalInc(alpha float32, x []float32, n, incX uintptr) {
|
||||
}
|
||||
}
|
||||
|
||||
// ScalIncTo is
|
||||
// var idst, ix uintptr
|
||||
// for i := 0; i < int(n); i++ {
|
||||
// dst[idst] = alpha * x[ix]
|
||||
// ix += incX
|
||||
// idst += incDst
|
||||
// }
|
||||
func ScalIncTo(dst []float32, incDst uintptr, alpha float32, x []float32, n, incX uintptr) {
|
||||
var idst, ix uintptr
|
||||
for i := 0; i < int(n); i++ {
|
||||
|
@@ -6,10 +6,31 @@
|
||||
|
||||
package f32
|
||||
|
||||
// AxpyUnitary is
|
||||
// for i, v := range x {
|
||||
// y[i] += alpha * v
|
||||
// }
|
||||
func AxpyUnitary(alpha float32, x, y []float32)
|
||||
|
||||
// AxpyUnitaryTo is
|
||||
// for i, v := range x {
|
||||
// dst[i] = alpha*v + y[i]
|
||||
// }
|
||||
func AxpyUnitaryTo(dst []float32, alpha float32, x, y []float32)
|
||||
|
||||
// AxpyInc is
|
||||
// for i := 0; i < int(n); i++ {
|
||||
// y[iy] += alpha * x[ix]
|
||||
// ix += incX
|
||||
// iy += incY
|
||||
// }
|
||||
func AxpyInc(alpha float32, x, y []float32, n, incX, incY, ix, iy uintptr)
|
||||
|
||||
// AxpyIncTo is
|
||||
// for i := 0; i < int(n); i++ {
|
||||
// dst[idst] = alpha*x[ix] + y[iy]
|
||||
// ix += incX
|
||||
// iy += incY
|
||||
// idst += incDst
|
||||
// }
|
||||
func AxpyIncTo(dst []float32, incDst, idst uintptr, alpha float32, x, y []float32, n, incX, incY, ix, iy uintptr)
|
||||
|
@@ -6,18 +6,32 @@
|
||||
|
||||
package f32
|
||||
|
||||
// AxpyUnitary is
|
||||
// for i, v := range x {
|
||||
// y[i] += alpha * v
|
||||
// }
|
||||
func AxpyUnitary(alpha float32, x, y []float32) {
|
||||
for i, v := range x {
|
||||
y[i] += alpha * v
|
||||
}
|
||||
}
|
||||
|
||||
// AxpyUnitaryTo is
|
||||
// for i, v := range x {
|
||||
// dst[i] = alpha*v + y[i]
|
||||
// }
|
||||
func AxpyUnitaryTo(dst []float32, alpha float32, x, y []float32) {
|
||||
for i, v := range x {
|
||||
dst[i] = alpha*v + y[i]
|
||||
}
|
||||
}
|
||||
|
||||
// AxpyInc is
|
||||
// for i := 0; i < int(n); i++ {
|
||||
// y[iy] += alpha * x[ix]
|
||||
// ix += incX
|
||||
// iy += incY
|
||||
// }
|
||||
func AxpyInc(alpha float32, x, y []float32, n, incX, incY, ix, iy uintptr) {
|
||||
for i := 0; i < int(n); i++ {
|
||||
y[iy] += alpha * x[ix]
|
||||
@@ -26,6 +40,13 @@ func AxpyInc(alpha float32, x, y []float32, n, incX, incY, ix, iy uintptr) {
|
||||
}
|
||||
}
|
||||
|
||||
// AxpyIncTo is
|
||||
// for i := 0; i < int(n); i++ {
|
||||
// dst[idst] = alpha*x[ix] + y[iy]
|
||||
// ix += incX
|
||||
// iy += incY
|
||||
// idst += incDst
|
||||
// }
|
||||
func AxpyIncTo(dst []float32, incDst, idst uintptr, alpha float32, x, y []float32, n, incX, incY, ix, iy uintptr) {
|
||||
for i := 0; i < int(n); i++ {
|
||||
dst[idst] = alpha*x[ix] + y[iy]
|
||||
|
@@ -6,18 +6,32 @@
|
||||
|
||||
package f64
|
||||
|
||||
// AxpyUnitary is
|
||||
// for i, v := range x {
|
||||
// y[i] += alpha * v
|
||||
// }
|
||||
func AxpyUnitary(alpha float64, x, y []float64) {
|
||||
for i, v := range x {
|
||||
y[i] += alpha * v
|
||||
}
|
||||
}
|
||||
|
||||
// AxpyUnitaryTo is
|
||||
// for i, v := range x {
|
||||
// dst[i] = alpha*v + y[i]
|
||||
// }
|
||||
func AxpyUnitaryTo(dst []float64, alpha float64, x, y []float64) {
|
||||
for i, v := range x {
|
||||
dst[i] = alpha*v + y[i]
|
||||
}
|
||||
}
|
||||
|
||||
// AxpyInc is
|
||||
// for i := 0; i < int(n); i++ {
|
||||
// y[iy] += alpha * x[ix]
|
||||
// ix += incX
|
||||
// iy += incY
|
||||
// }
|
||||
func AxpyInc(alpha float64, x, y []float64, n, incX, incY, ix, iy uintptr) {
|
||||
for i := 0; i < int(n); i++ {
|
||||
y[iy] += alpha * x[ix]
|
||||
@@ -26,6 +40,13 @@ func AxpyInc(alpha float64, x, y []float64, n, incX, incY, ix, iy uintptr) {
|
||||
}
|
||||
}
|
||||
|
||||
// AxpyIncTo is
|
||||
// for i := 0; i < int(n); i++ {
|
||||
// dst[idst] = alpha*x[ix] + y[iy]
|
||||
// ix += incX
|
||||
// iy += incY
|
||||
// idst += incDst
|
||||
// }
|
||||
func AxpyIncTo(dst []float64, incDst, idst uintptr, alpha float64, x, y []float64, n, incX, incY, ix, iy uintptr) {
|
||||
for i := 0; i < int(n); i++ {
|
||||
dst[idst] = alpha*x[ix] + y[iy]
|
||||
|
6
asm/f64/doc.go
Normal file
6
asm/f64/doc.go
Normal file
@@ -0,0 +1,6 @@
|
||||
// Copyright ©2017 The gonum Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package f64 provides float64 vector primitives.
|
||||
package f64
|
@@ -6,18 +6,30 @@
|
||||
|
||||
package f64
|
||||
|
||||
// DotUnitary is
|
||||
// for i, v := range x {
|
||||
// sum += y[i] * v
|
||||
// }
|
||||
// return sum
|
||||
func DotUnitary(x, y []float64) (sum float64) {
|
||||
for i, v := range x {
|
||||
sum += y[i] * v
|
||||
}
|
||||
return
|
||||
return sum
|
||||
}
|
||||
|
||||
// DotInc is
|
||||
// for i := 0; i < int(n); i++ {
|
||||
// sum += y[iy] * x[ix]
|
||||
// ix += incX
|
||||
// iy += incY
|
||||
// }
|
||||
// return sum
|
||||
func DotInc(x, y []float64, n, incX, incY, ix, iy uintptr) (sum float64) {
|
||||
for i := 0; i < int(n); i++ {
|
||||
sum += y[iy] * x[ix]
|
||||
ix += incX
|
||||
iy += incY
|
||||
}
|
||||
return
|
||||
return sum
|
||||
}
|
||||
|
@@ -6,18 +6,32 @@
|
||||
|
||||
package f64
|
||||
|
||||
// ScalUnitary is
|
||||
// for i := range x {
|
||||
// x[i] *= alpha
|
||||
// }
|
||||
func ScalUnitary(alpha float64, x []float64) {
|
||||
for i := range x {
|
||||
x[i] *= alpha
|
||||
}
|
||||
}
|
||||
|
||||
// ScalUnitaryTo is
|
||||
// for i, v := range x {
|
||||
// dst[i] = alpha * v
|
||||
// }
|
||||
func ScalUnitaryTo(dst []float64, alpha float64, x []float64) {
|
||||
for i, v := range x {
|
||||
dst[i] = alpha * v
|
||||
}
|
||||
}
|
||||
|
||||
// ScalInc is
|
||||
// var ix uintptr
|
||||
// for i := 0; i < int(n); i++ {
|
||||
// x[ix] *= alpha
|
||||
// ix += incX
|
||||
// }
|
||||
func ScalInc(alpha float64, x []float64, n, incX uintptr) {
|
||||
var ix uintptr
|
||||
for i := 0; i < int(n); i++ {
|
||||
@@ -26,6 +40,13 @@ func ScalInc(alpha float64, x []float64, n, incX uintptr) {
|
||||
}
|
||||
}
|
||||
|
||||
// ScalIncTo is
|
||||
// var idst, ix uintptr
|
||||
// for i := 0; i < int(n); i++ {
|
||||
// dst[idst] = alpha * x[ix]
|
||||
// ix += incX
|
||||
// idst += incDst
|
||||
// }
|
||||
func ScalIncTo(dst []float64, incDst uintptr, alpha float64, x []float64, n, incX uintptr) {
|
||||
var idst, ix uintptr
|
||||
for i := 0; i < int(n); i++ {
|
||||
|
@@ -6,42 +6,160 @@
|
||||
|
||||
package f64
|
||||
|
||||
// AbsSum is
|
||||
// for _, v := range x {
|
||||
// sum += math.Abs(v)
|
||||
// }
|
||||
// return sum
|
||||
func AbsSum(x []float64) (sum float64)
|
||||
|
||||
// AbsSumInc is
|
||||
// for i := 0; i < n*incX; i += incX {
|
||||
// sum += math.Abs(x[i])
|
||||
// }
|
||||
// return sum
|
||||
func AbsSumInc(x []float64, n, incX int) (sum float64)
|
||||
|
||||
// AddConst is
|
||||
// for i := range x {
|
||||
// x[i] += alpha
|
||||
// }
|
||||
func AddConst(alpha float64, x []float64)
|
||||
|
||||
// Add is
|
||||
// for i, v := range s {
|
||||
// dst[i] += v
|
||||
// }
|
||||
func Add(dst, s []float64)
|
||||
|
||||
// AxpyUnitary is
|
||||
// for i, v := range x {
|
||||
// y[i] += alpha * v
|
||||
// }
|
||||
func AxpyUnitary(alpha float64, x, y []float64)
|
||||
|
||||
// AxpyUnitaryTo is
|
||||
// for i, v := range x {
|
||||
// dst[i] = alpha*v + y[i]
|
||||
// }
|
||||
func AxpyUnitaryTo(dst []float64, alpha float64, x, y []float64)
|
||||
|
||||
// AxpyInc is
|
||||
// for i := 0; i < int(n); i++ {
|
||||
// y[iy] += alpha * x[ix]
|
||||
// ix += incX
|
||||
// iy += incY
|
||||
// }
|
||||
func AxpyInc(alpha float64, x, y []float64, n, incX, incY, ix, iy uintptr)
|
||||
|
||||
// AxpyIncTo is
|
||||
// for i := 0; i < int(n); i++ {
|
||||
// dst[idst] = alpha*x[ix] + y[iy]
|
||||
// ix += incX
|
||||
// iy += incY
|
||||
// idst += incDst
|
||||
// }
|
||||
func AxpyIncTo(dst []float64, incDst, idst uintptr, alpha float64, x, y []float64, n, incX, incY, ix, iy uintptr)
|
||||
|
||||
// CumSum is
|
||||
// if len(s) == 0 {
|
||||
// return dst
|
||||
// }
|
||||
// dst[0] = s[0]
|
||||
// for i, v := range s[1:] {
|
||||
// dst[i+1] = dst[i] + v
|
||||
// }
|
||||
// return dst
|
||||
func CumSum(dst, s []float64) []float64
|
||||
|
||||
// CumProd is
|
||||
// if len(s) == 0 {
|
||||
// return dst
|
||||
// }
|
||||
// dst[0] = s[0]
|
||||
// for i, v := range s[1:] {
|
||||
// dst[i+1] = dst[i] * v
|
||||
// }
|
||||
// return dst
|
||||
func CumProd(dst, s []float64) []float64
|
||||
|
||||
// Div is
|
||||
// for i, v := range s {
|
||||
// dst[i] /= v
|
||||
// }
|
||||
func Div(dst, s []float64)
|
||||
|
||||
// DivTo is
|
||||
// for i, v := range s {
|
||||
// dst[i] = v / t[i]
|
||||
// }
|
||||
// return dst
|
||||
func DivTo(dst, x, y []float64) []float64
|
||||
|
||||
// DotUnitary is
|
||||
// for i, v := range x {
|
||||
// sum += y[i] * v
|
||||
// }
|
||||
// return sum
|
||||
func DotUnitary(x, y []float64) (sum float64)
|
||||
|
||||
// DotInc is
|
||||
// for i := 0; i < int(n); i++ {
|
||||
// sum += y[iy] * x[ix]
|
||||
// ix += incX
|
||||
// iy += incY
|
||||
// }
|
||||
// return sum
|
||||
func DotInc(x, y []float64, n, incX, incY, ix, iy uintptr) (sum float64)
|
||||
|
||||
// L1Norm is
|
||||
// var norm float64
|
||||
// for i, v := range s {
|
||||
// norm += math.Abs(t[i] - v)
|
||||
// }
|
||||
// return norm
|
||||
func L1Norm(s, t []float64) float64
|
||||
|
||||
// LinfNorm is
|
||||
// var norm float64
|
||||
// if len(s) == 0 {
|
||||
// return 0
|
||||
// }
|
||||
// norm = math.Abs(t[0] - s[0])
|
||||
// for i, v := range s[1:] {
|
||||
// absDiff := math.Abs(t[i+1] - v)
|
||||
// if absDiff > norm || math.IsNaN(norm) {
|
||||
// norm = absDiff
|
||||
// }
|
||||
// }
|
||||
// return norm
|
||||
func LinfNorm(s, t []float64) float64
|
||||
|
||||
// ScalUnitary is
|
||||
// for i := range x {
|
||||
// x[i] *= alpha
|
||||
// }
|
||||
func ScalUnitary(alpha float64, x []float64)
|
||||
|
||||
// ScalUnitaryTo is
|
||||
// for i, v := range x {
|
||||
// dst[i] = alpha * v
|
||||
// }
|
||||
func ScalUnitaryTo(dst []float64, alpha float64, x []float64)
|
||||
|
||||
// ScalInc is
|
||||
// var ix uintptr
|
||||
// for i := 0; i < int(n); i++ {
|
||||
// x[ix] *= alpha
|
||||
// ix += incX
|
||||
// }
|
||||
func ScalInc(alpha float64, x []float64, n, incX uintptr)
|
||||
|
||||
// ScalIncTo is
|
||||
// var idst, ix uintptr
|
||||
// for i := 0; i < int(n); i++ {
|
||||
// dst[idst] = alpha * x[ix]
|
||||
// ix += incX
|
||||
// idst += incDst
|
||||
// }
|
||||
func ScalIncTo(dst []float64, incDst uintptr, alpha float64, x []float64, n, incX uintptr)
|
||||
|
@@ -8,6 +8,11 @@ package f64
|
||||
|
||||
import "math"
|
||||
|
||||
// AbsSum is
|
||||
// for _, v := range x {
|
||||
// sum += math.Abs(v)
|
||||
// }
|
||||
// return sum
|
||||
func AbsSum(x []float64) (sum float64) {
|
||||
for _, v := range x {
|
||||
sum += math.Abs(v)
|
||||
@@ -15,6 +20,11 @@ func AbsSum(x []float64) (sum float64) {
|
||||
return sum
|
||||
}
|
||||
|
||||
// AbsSumInc is
|
||||
// for i := 0; i < n*incX; i += incX {
|
||||
// sum += math.Abs(x[i])
|
||||
// }
|
||||
// return sum
|
||||
func AbsSumInc(x []float64, n, incX int) (sum float64) {
|
||||
for i := 0; i < n*incX; i += incX {
|
||||
sum += math.Abs(x[i])
|
||||
@@ -22,18 +32,35 @@ func AbsSumInc(x []float64, n, incX int) (sum float64) {
|
||||
return sum
|
||||
}
|
||||
|
||||
// Add is
|
||||
// for i, v := range s {
|
||||
// dst[i] += v
|
||||
// }
|
||||
func Add(dst, s []float64) {
|
||||
for i, v := range s {
|
||||
dst[i] += v
|
||||
}
|
||||
}
|
||||
|
||||
// AddConst is
|
||||
// for i := range x {
|
||||
// x[i] += alpha
|
||||
// }
|
||||
func AddConst(alpha float64, x []float64) {
|
||||
for i := range x {
|
||||
x[i] += alpha
|
||||
}
|
||||
}
|
||||
|
||||
// CumSum is
|
||||
// if len(s) == 0 {
|
||||
// return dst
|
||||
// }
|
||||
// dst[0] = s[0]
|
||||
// for i, v := range s[1:] {
|
||||
// dst[i+1] = dst[i] + v
|
||||
// }
|
||||
// return dst
|
||||
func CumSum(dst, s []float64) []float64 {
|
||||
if len(s) == 0 {
|
||||
return dst
|
||||
@@ -45,6 +72,15 @@ func CumSum(dst, s []float64) []float64 {
|
||||
return dst
|
||||
}
|
||||
|
||||
// CumProd is
|
||||
// if len(s) == 0 {
|
||||
// return dst
|
||||
// }
|
||||
// dst[0] = s[0]
|
||||
// for i, v := range s[1:] {
|
||||
// dst[i+1] = dst[i] * v
|
||||
// }
|
||||
// return dst
|
||||
func CumProd(dst, s []float64) []float64 {
|
||||
if len(s) == 0 {
|
||||
return dst
|
||||
@@ -56,12 +92,21 @@ func CumProd(dst, s []float64) []float64 {
|
||||
return dst
|
||||
}
|
||||
|
||||
// Div is
|
||||
// for i, v := range s {
|
||||
// dst[i] /= v
|
||||
// }
|
||||
func Div(dst, s []float64) {
|
||||
for i, v := range s {
|
||||
dst[i] /= v
|
||||
}
|
||||
}
|
||||
|
||||
// DivTo is
|
||||
// for i, v := range s {
|
||||
// dst[i] = v / t[i]
|
||||
// }
|
||||
// return dst
|
||||
func DivTo(dst, s, t []float64) []float64 {
|
||||
for i, v := range s {
|
||||
dst[i] = v / t[i]
|
||||
@@ -69,6 +114,12 @@ func DivTo(dst, s, t []float64) []float64 {
|
||||
return dst
|
||||
}
|
||||
|
||||
// L1Norm is
|
||||
// var norm float64
|
||||
// for i, v := range s {
|
||||
// norm += math.Abs(t[i] - v)
|
||||
// }
|
||||
// return norm
|
||||
func L1Norm(s, t []float64) float64 {
|
||||
var norm float64
|
||||
for i, v := range s {
|
||||
@@ -77,6 +128,19 @@ func L1Norm(s, t []float64) float64 {
|
||||
return norm
|
||||
}
|
||||
|
||||
// LinfNorm is
|
||||
// var norm float64
|
||||
// if len(s) == 0 {
|
||||
// return 0
|
||||
// }
|
||||
// norm = math.Abs(t[0] - s[0])
|
||||
// for i, v := range s[1:] {
|
||||
// absDiff := math.Abs(t[i+1] - v)
|
||||
// if absDiff > norm || math.IsNaN(norm) {
|
||||
// norm = absDiff
|
||||
// }
|
||||
// }
|
||||
// return norm
|
||||
func LinfNorm(s, t []float64) float64 {
|
||||
var norm float64
|
||||
if len(s) == 0 {
|
||||
|
Reference in New Issue
Block a user