fourier: remove oneIntArray
MODIFY
fourier/array.go
fourier/array.go
@@ -13,24 +13,6 @@ import "fmt"
// TODO(kortschak): Make a bounds-checking and non-bounds-checking version
// for testing/production.
-type oneIntArray []int
-
-func (a oneIntArray) at(i int) int {
- i--
- if i < 0 || len(a) <= i {
- panic(fmt.Sprintf("out of bounds at(%d): bounds i=%d", i, len(a)))
- }
- return a[i]
-}
-
-func (a oneIntArray) set(i, v int) {
- i--
- if i < 0 || len(a) <= i {
- panic(fmt.Sprintf("out of bounds set(%d): bounds i=%d", i, len(a)))
- }
- a[i] = v
-}
-
type oneArray []float64
func (a oneArray) sliceFrom(i int) oneArray {

MODIFY
fourier/cfft.go
fourier/cfft.go
@@ -156,14 +156,14 @@ func cfftf(n int, r, work []float64, ifac []int) {
cfftf1(n, r, work, work[2*n:], ifac)
}
-func cfftf1(n int, c, ch []float64, wa oneArray, ifac oneIntArray) {
- nf := ifac.at(2)
+func cfftf1(n int, c, ch []float64, wa oneArray, ifac []int) {
+ nf := ifac[1]
na := 0
l1 := 1
iw := 1
for k1 := 1; k1 <= nf; k1++ {
- ip := ifac.at(k1 + 2)
+ ip := ifac[k1+1]
l2 := ip * l1
ido := n / l2
idot := 2 * ido
@@ -621,14 +621,14 @@ func cfftb(n int, r, work []float64, ifac []int) {
cfftb1(n, r, work, work[2*n:], ifac)
}
-func cfftb1(n int, c, ch []float64, wa oneArray, ifac oneIntArray) {
- nf := ifac.at(2)
+func cfftb1(n int, c, ch []float64, wa oneArray, ifac []int) {
+ nf := ifac[1]
na := 0
l1 := 1
iw := 1
for k1 := 1; k1 <= nf; k1++ {
- ip := ifac.at(k1 + 2)
+ ip := ifac[k1+1]
l2 := ip * l1
ido := n / l2
idot := 2 * ido

MODIFY
fourier/rfft.go
fourier/rfft.go
@@ -159,15 +159,15 @@ func rfftf(n int, r, work []float64, ifac []int) {
rfftf1(n, r, work, work[n:], ifac)
}
-func rfftf1(n int, c, ch []float64, wa oneArray, ifac oneIntArray) {
- nf := ifac.at(2)
+func rfftf1(n int, c, ch []float64, wa oneArray, ifac []int) {
+ nf := ifac[1]
na := 1
l2 := n
iw := n
for k1 := 1; k1 <= nf; k1++ {
kh := nf - k1
- ip := ifac.at(kh + 3)
+ ip := ifac[kh+2]
l1 := l2 / ip
ido := n / l2
idl1 := ido * l1
@@ -664,14 +664,14 @@ func rfftb(n int, r, work []float64, ifac []int) {
rfftb1(n, r, work, work[n:], ifac)
}
-func rfftb1(n int, c, ch []float64, wa oneArray, ifac oneIntArray) {
- nf := ifac.at(2)
+func rfftb1(n int, c, ch []float64, wa oneArray, ifac []int) {
+ nf := ifac[1]
na := 0
l1 := 1
iw := 1
for k1 := 1; k1 <= nf; k1++ {
- ip := ifac.at(k1 + 2)
+ ip := ifac[k1+1]
l2 := ip * l1
ido := n / l2
idl1 := ido * l1

fourier: remove oneIntArray