mirror of
https://github.com/gonum/gonum.git
synced 2025-11-01 19:12:45 +08:00
Make generated complex drop-ins
Again this is to allow simpler code generation of other BLAS routines.
This commit is contained in:
22
asm/caxpy.go
Normal file
22
asm/caxpy.go
Normal file
@@ -0,0 +1,22 @@
|
||||
// Generated code do not edit. Run `go generate`.
|
||||
|
||||
// Copyright ©2015 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 asm
|
||||
|
||||
// The extra z parameter is needed because of floats.AddScaledTo
|
||||
func CaxpyUnitary(alpha complex64, x, y, z []complex64) {
|
||||
for i, v := range x {
|
||||
z[i] = alpha*v + y[i]
|
||||
}
|
||||
}
|
||||
|
||||
func CaxpyInc(alpha complex64, x, y []complex64, n, incX, incY, ix, iy uintptr) {
|
||||
for i := 0; i < int(n); i++ {
|
||||
y[iy] += alpha * x[ix]
|
||||
ix += incX
|
||||
iy += incY
|
||||
}
|
||||
}
|
||||
23
asm/cdotc.go
Normal file
23
asm/cdotc.go
Normal file
@@ -0,0 +1,23 @@
|
||||
// Generated code do not edit. Run `go generate`.
|
||||
|
||||
// Copyright ©2015 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 asm
|
||||
|
||||
func CdotcUnitary(x, y []complex64) (sum complex64) {
|
||||
for i, v := range x {
|
||||
sum += y[i] * conj(v)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func CdotcInc(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
|
||||
}
|
||||
23
asm/cdotu.go
Normal file
23
asm/cdotu.go
Normal file
@@ -0,0 +1,23 @@
|
||||
// Generated code do not edit. Run `go generate`.
|
||||
|
||||
// Copyright ©2015 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 asm
|
||||
|
||||
func CdotuUnitary(x, y []complex64) (sum complex64) {
|
||||
for i, v := range x {
|
||||
sum += y[i] * v
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func CdotuInc(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
|
||||
}
|
||||
58
asm/complex
Executable file
58
asm/complex
Executable file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright ©2015 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.
|
||||
|
||||
echo Generating zdotu.go
|
||||
echo -e '// Generated code do not edit. Run `go generate`.\n' > zdotu.go
|
||||
cat ddot.go \
|
||||
| grep -v '//+build' \
|
||||
| gofmt -r 'float64 -> complex128' \
|
||||
| sed 's/Ddot/Zdotu/' \
|
||||
>> zdotu.go
|
||||
|
||||
echo Generating zdotc.go
|
||||
echo -e '// Generated code do not edit. Run `go generate`.\n' > zdotc.go
|
||||
cat ddot.go \
|
||||
| grep -v '//+build' \
|
||||
| gofmt -r 'float64 -> complex128' \
|
||||
| gofmt -r 'y[i] * v -> y[i] * cmplx.Conj(v)' \
|
||||
| sed 's/Ddot/Zdotc/' \
|
||||
| goimports \
|
||||
>> zdotc.go
|
||||
|
||||
echo Generating zaxpy.go
|
||||
echo -e '// Generated code do not edit. Run `go generate`.\n' > zaxpy.go
|
||||
cat daxpy.go \
|
||||
| grep -v '//+build' \
|
||||
| gofmt -r 'float64 -> complex128' \
|
||||
| sed 's/Daxpy/Zaxpy/' \
|
||||
>> zaxpy.go
|
||||
|
||||
echo Generating cdotu.go
|
||||
echo -e '// Generated code do not edit. Run `go generate`.\n' > cdotu.go
|
||||
cat ddot.go \
|
||||
| grep -v '//+build' \
|
||||
| gofmt -r 'float64 -> complex64' \
|
||||
| sed 's/Ddot/Cdotu/' \
|
||||
>> cdotu.go
|
||||
|
||||
echo Generating cdotc.go
|
||||
echo -e '// Generated code do not edit. Run `go generate`.\n' > cdotc.go
|
||||
cat ddot.go \
|
||||
| grep -v '//+build' \
|
||||
| gofmt -r 'float64 -> complex64' \
|
||||
| gofmt -r 'y[i] * v -> y[i] * conj(v)' \
|
||||
| sed 's/Ddot/Cdotc/' \
|
||||
| goimports \
|
||||
>> cdotc.go
|
||||
|
||||
echo Generating caxpy.go
|
||||
echo -e '// Generated code do not edit. Run `go generate`.\n' > caxpy.go
|
||||
cat daxpy.go \
|
||||
| grep -v '//+build' \
|
||||
| gofmt -r 'float64 -> complex64' \
|
||||
| sed 's/Daxpy/Caxpy/' \
|
||||
>> caxpy.go
|
||||
|
||||
7
asm/conj.go
Normal file
7
asm/conj.go
Normal file
@@ -0,0 +1,7 @@
|
||||
// Copyright ©2015 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 asm
|
||||
|
||||
func conj(c complex64) complex64 { return complex(real(c), -imag(c)) }
|
||||
@@ -3,5 +3,6 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:generate ./single_precision
|
||||
//go:generate ./complex
|
||||
|
||||
package asm
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright ©2015 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.
|
||||
|
||||
echo Generating dsdot.go
|
||||
echo -e '// Generated code do not edit. Run `go generate`.\n' > dsdot.go
|
||||
cat ddot.go \
|
||||
|
||||
22
asm/zaxpy.go
Normal file
22
asm/zaxpy.go
Normal file
@@ -0,0 +1,22 @@
|
||||
// Generated code do not edit. Run `go generate`.
|
||||
|
||||
// Copyright ©2015 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 asm
|
||||
|
||||
// The extra z parameter is needed because of floats.AddScaledTo
|
||||
func ZaxpyUnitary(alpha complex128, x, y, z []complex128) {
|
||||
for i, v := range x {
|
||||
z[i] = alpha*v + y[i]
|
||||
}
|
||||
}
|
||||
|
||||
func ZaxpyInc(alpha complex128, x, y []complex128, n, incX, incY, ix, iy uintptr) {
|
||||
for i := 0; i < int(n); i++ {
|
||||
y[iy] += alpha * x[ix]
|
||||
ix += incX
|
||||
iy += incY
|
||||
}
|
||||
}
|
||||
25
asm/zdotc.go
Normal file
25
asm/zdotc.go
Normal file
@@ -0,0 +1,25 @@
|
||||
// Generated code do not edit. Run `go generate`.
|
||||
|
||||
// Copyright ©2015 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 asm
|
||||
|
||||
import "math/cmplx"
|
||||
|
||||
func ZdotcUnitary(x, y []complex128) (sum complex128) {
|
||||
for i, v := range x {
|
||||
sum += y[i] * cmplx.Conj(v)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func ZdotcInc(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
|
||||
}
|
||||
23
asm/zdotu.go
Normal file
23
asm/zdotu.go
Normal file
@@ -0,0 +1,23 @@
|
||||
// Generated code do not edit. Run `go generate`.
|
||||
|
||||
// Copyright ©2015 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 asm
|
||||
|
||||
func ZdotuUnitary(x, y []complex128) (sum complex128) {
|
||||
for i, v := range x {
|
||||
sum += y[i] * v
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func ZdotuInc(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
|
||||
}
|
||||
Reference in New Issue
Block a user