fourier: change direction int to bool
MODIFY
fourier/cfft.go
fourier/cfft.go
@@ -158,7 +158,7 @@ func cfftf(n int, r, work []float64, ifac []int) {
func cfftf1(n int, c, ch, wa []float64, ifac []int) {
nf := ifac[1]
- na := 0
+ na := false
l1 := 1
iw := 0
@@ -173,46 +173,46 @@ func cfftf1(n int, c, ch, wa []float64, ifac []int) {
case 4:
ix2 := iw + idot
ix3 := ix2 + idot
- if na == 0 {
- passf4(idot, l1, c, ch, wa[iw:], wa[ix2:], wa[ix3:])
- } else {
+ if na {
passf4(idot, l1, ch, c, wa[iw:], wa[ix2:], wa[ix3:])
+ } else {
+ passf4(idot, l1, c, ch, wa[iw:], wa[ix2:], wa[ix3:])
}
- na = 1 - na
+ na = !na
case 2:
- if na == 0 {
- passf2(idot, l1, c, ch, wa[iw:])
- } else {
+ if na {
passf2(idot, l1, ch, c, wa[iw:])
+ } else {
+ passf2(idot, l1, c, ch, wa[iw:])
}
- na = 1 - na
+ na = !na
case 3:
ix2 := iw + idot
- if na == 0 {
- passf3(idot, l1, c, ch, wa[iw:], wa[ix2:])
- } else {
+ if na {
passf3(idot, l1, ch, c, wa[iw:], wa[ix2:])
+ } else {
+ passf3(idot, l1, c, ch, wa[iw:], wa[ix2:])
}
- na = 1 - na
+ na = !na
case 5:
ix2 := iw + idot
ix3 := ix2 + idot
ix4 := ix3 + idot
- if na == 0 {
- passf5(idot, l1, c, ch, wa[iw:], wa[ix2:], wa[ix3:], wa[ix4:])
- } else {
+ if na {
passf5(idot, l1, ch, c, wa[iw:], wa[ix2:], wa[ix3:], wa[ix4:])
+ } else {
+ passf5(idot, l1, c, ch, wa[iw:], wa[ix2:], wa[ix3:], wa[ix4:])
}
- na = 1 - na
+ na = !na
default:
var nac bool
- if na == 0 {
- nac = passf(idot, ip, l1, idl1, c, c, c, ch, ch, wa[iw:])
- } else {
+ if na {
nac = passf(idot, ip, l1, idl1, ch, ch, ch, c, c, wa[iw:])
+ } else {
+ nac = passf(idot, ip, l1, idl1, c, c, c, ch, ch, wa[iw:])
}
if nac {
- na = 1 - na
+ na = !na
}
}
@@ -220,13 +220,12 @@ func cfftf1(n int, c, ch, wa []float64, ifac []int) {
iw += (ip - 1) * idot
}
- if na == 0 {
- return
- }
+ if na {
for i := 0; i < 2*n; i++ {
c[i] = ch[i]
}
}
+}
func passf2(ido, l1 int, cc, ch []float64, wa1 oneArray) {
cc3 := newThreeArray(ido, 2, l1, cc)
@@ -623,7 +622,7 @@ func cfftb(n int, r, work []float64, ifac []int) {
func cfftb1(n int, c, ch, wa []float64, ifac []int) {
nf := ifac[1]
- na := 0
+ na := false
l1 := 1
iw := 0
@@ -638,46 +637,46 @@ func cfftb1(n int, c, ch, wa []float64, ifac []int) {
case 4:
ix2 := iw + idot
ix3 := ix2 + idot
- if na == 0 {
- passb4(idot, l1, c, ch, wa[iw:], wa[ix2:], wa[ix3:])
- } else {
+ if na {
passb4(idot, l1, ch, c, wa[iw:], wa[ix2:], wa[ix3:])
+ } else {
+ passb4(idot, l1, c, ch, wa[iw:], wa[ix2:], wa[ix3:])
}
- na = 1 - na
+ na = !na
case 2:
- if na == 0 {
- passb2(idot, l1, c, ch, wa[iw:])
- } else {
+ if na {
passb2(idot, l1, ch, c, wa[iw:])
+ } else {
+ passb2(idot, l1, c, ch, wa[iw:])
}
- na = 1 - na
+ na = !na
case 3:
ix2 := iw + idot
- if na == 0 {
- passb3(idot, l1, c, ch, wa[iw:], wa[ix2:])
- } else {
+ if na {
passb3(idot, l1, ch, c, wa[iw:], wa[ix2:])
+ } else {
+ passb3(idot, l1, c, ch, wa[iw:], wa[ix2:])
}
- na = 1 - na
+ na = !na
case 5:
ix2 := iw + idot
ix3 := ix2 + idot
ix4 := ix3 + idot
- if na == 0 {
- passb5(idot, l1, c, ch, wa[iw:], wa[ix2:], wa[ix3:], wa[ix4:])
- } else {
+ if na {
passb5(idot, l1, ch, c, wa[iw:], wa[ix2:], wa[ix3:], wa[ix4:])
+ } else {
+ passb5(idot, l1, c, ch, wa[iw:], wa[ix2:], wa[ix3:], wa[ix4:])
}
- na = 1 - na
+ na = !na
default:
var nac bool
- if na == 0 {
- nac = passb(idot, ip, l1, idl1, c, c, c, ch, ch, wa[iw:])
- } else {
+ if na {
nac = passb(idot, ip, l1, idl1, ch, ch, ch, c, c, wa[iw:])
+ } else {
+ nac = passb(idot, ip, l1, idl1, c, c, c, ch, ch, wa[iw:])
}
if nac {
- na = 1 - na
+ na = !na
}
}
@@ -685,13 +684,12 @@ func cfftb1(n int, c, ch, wa []float64, ifac []int) {
iw += (ip - 1) * idot
}
- if na == 0 {
- return
- }
+ if na {
for i := 0; i < 2*n; i++ {
c[i] = ch[i]
}
}
+}
func passb2(ido, l1 int, cc, ch []float64, wa1 oneArray) {
cc3 := newThreeArray(ido, 2, l1, cc)

MODIFY
fourier/rfft.go
fourier/rfft.go
@@ -161,7 +161,7 @@ func rfftf(n int, r, work []float64, ifac []int) {
func rfftf1(n int, c, ch, wa []float64, ifac []int) {
nf := ifac[1]
- na := 1
+ na := true
l2 := n
iw := n - 1
@@ -172,56 +172,56 @@ func rfftf1(n int, c, ch, wa []float64, ifac []int) {
ido := n / l2
idl1 := ido * l1
iw -= (ip - 1) * ido
- na = 1 - na
+ na = !na
switch ip {
case 4:
ix2 := iw + ido
ix3 := ix2 + ido
- if na == 0 {
- radf4(ido, l1, c, ch, wa[iw:], wa[ix2:], wa[ix3:])
- } else {
+ if na {
radf4(ido, l1, ch, c, wa[iw:], wa[ix2:], wa[ix3:])
+ } else {
+ radf4(ido, l1, c, ch, wa[iw:], wa[ix2:], wa[ix3:])
}
case 2:
- if na == 0 {
- radf2(ido, l1, c, ch, wa[iw:])
- } else {
+ if na {
radf2(ido, l1, ch, c, wa[iw:])
+ } else {
+ radf2(ido, l1, c, ch, wa[iw:])
}
case 3:
ix2 := iw + ido
- if na == 0 {
- radf3(ido, l1, c, ch, wa[iw:], wa[ix2:])
- } else {
+ if na {
radf3(ido, l1, ch, c, wa[iw:], wa[ix2:])
+ } else {
+ radf3(ido, l1, c, ch, wa[iw:], wa[ix2:])
}
case 5:
ix2 := iw + ido
ix3 := ix2 + ido
ix4 := ix3 + ido
- if na == 0 {
- radf5(ido, l1, c, ch, wa[iw:], wa[ix2:], wa[ix3:], wa[ix4:])
- } else {
+ if na {
radf5(ido, l1, ch, c, wa[iw:], wa[ix2:], wa[ix3:], wa[ix4:])
+ } else {
+ radf5(ido, l1, c, ch, wa[iw:], wa[ix2:], wa[ix3:], wa[ix4:])
}
default:
if ido == 1 {
- na = 1 - na
+ na = !na
}
- if na == 0 {
- radfg(ido, ip, l1, idl1, c, c, c, ch, ch, wa[iw:])
- na = 1
- } else {
+ if na {
radfg(ido, ip, l1, idl1, ch, ch, ch, c, c, wa[iw:])
- na = 0
+ na = false
+ } else {
+ radfg(ido, ip, l1, idl1, c, c, c, ch, ch, wa[iw:])
+ na = true
}
}
l2 = l1
}
- if na == 1 {
+ if na {
return
}
for i := 0; i < n; i++ {
@@ -666,7 +666,7 @@ func rfftb(n int, r, work []float64, ifac []int) {
func rfftb1(n int, c, ch, wa []float64, ifac []int) {
nf := ifac[1]
- na := 0
+ na := false
l1 := 1
iw := 0
@@ -680,45 +680,45 @@ func rfftb1(n int, c, ch, wa []float64, ifac []int) {
case 4:
ix2 := iw + ido
ix3 := ix2 + ido
- if na == 0 {
- radb4(ido, l1, c, ch, wa[iw:], wa[ix2:], wa[ix3:])
- } else {
+ if na {
radb4(ido, l1, ch, c, wa[iw:], wa[ix2:], wa[ix3:])
+ } else {
+ radb4(ido, l1, c, ch, wa[iw:], wa[ix2:], wa[ix3:])
}
- na = 1 - na
+ na = !na
case 2:
- if na == 0 {
- radb2(ido, l1, c, ch, wa[iw:])
- } else {
+ if na {
radb2(ido, l1, ch, c, wa[iw:])
+ } else {
+ radb2(ido, l1, c, ch, wa[iw:])
}
- na = 1 - na
+ na = !na
case 3:
ix2 := iw + ido
- if na == 0 {
- radb3(ido, l1, c, ch, wa[iw:], wa[ix2:])
- } else {
+ if na {
radb3(ido, l1, ch, c, wa[iw:], wa[ix2:])
+ } else {
+ radb3(ido, l1, c, ch, wa[iw:], wa[ix2:])
}
- na = 1 - na
+ na = !na
case 5:
ix2 := iw + ido
ix3 := ix2 + ido
ix4 := ix3 + ido
- if na == 0 {
- radb5(ido, l1, c, ch, wa[iw:], wa[ix2:], wa[ix3:], wa[ix4:])
- } else {
+ if na {
radb5(ido, l1, ch, c, wa[iw:], wa[ix2:], wa[ix3:], wa[ix4:])
+ } else {
+ radb5(ido, l1, c, ch, wa[iw:], wa[ix2:], wa[ix3:], wa[ix4:])
}
- na = 1 - na
+ na = !na
default:
- if na == 0 {
- radbg(ido, ip, l1, idl1, c, c, c, ch, ch, wa[iw:])
- } else {
+ if na {
radbg(ido, ip, l1, idl1, ch, ch, ch, c, c, wa[iw:])
+ } else {
+ radbg(ido, ip, l1, idl1, c, c, c, ch, ch, wa[iw:])
}
if ido == 1 {
- na = 1 - na
+ na = !na
}
}
@@ -726,13 +726,12 @@ func rfftb1(n int, c, ch, wa []float64, ifac []int) {
iw += (ip - 1) * ido
}
- if na == 0 {
- return
- }
+ if na {
for i := 0; i < n; i++ {
c[i] = ch[i]
}
}
+}
func radb2(ido, l1 int, cc, ch []float64, wa1 oneArray) {
cc3 := newThreeArray(ido, 2, l1, cc)

fourier: change direction int to bool