Hi
I referred to the sample code provided at
https://pkg.go.dev/gonum.org/v1/gonum/fourier
to implement FFT2D, and I found that the code example in the
documentation is incorrect. The example uses an 11x11 image as input,
but there's an error when the number of rows and columns are different. I
modified the code as follows. Is there someone specifically responsible
for maintaining this, or can I submit a PR to a particular repo?
```
func main() {
// Image is a set of diagonal lines.
image := mat.NewDense(11, 11, []float64{
0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0,
0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1,
1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0,
0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0,
0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1,
1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0,
0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0,
0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1,
1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0,
0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0,
0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1,
})
// Make appropriately sized complex FFT.
// Rows and columns are the same, so the same
// CmplxFFT can be used for both axes.
r, c := image.Dims()
cfftCol := fourier.NewCmplxFFT(c)
cfftRow := fourier.NewCmplxFFT(r)
// Perform the first axis transform.
rows := make([]complex128, r*c)
for i := 0; i < r; i++ {
row := rows[c*i : c*(i+1)]
for j, v := range image.RawRowView(i) {
row[j] = complex(v, 0)
}
cfftCol.Coefficients(row, row)
}
// Perform the second axis transform, storing
// the result in freqs.
freqs := mat.NewDense(r, c, nil)
column := make([]complex128, r)
for j := 0; j < c; j++ {
for i := 0; i < r; i++ {
column[i] = rows[i*c+j]
}
cfftRow.Coefficients(column, column)
for i, v := range column {
// Center the frequencies.
freqs.Set(cfftRow.UnshiftIdx(i), cfftCol.UnshiftIdx(j), scalar.Round(cmplx.Abs(v), 1))
}
}
fmt.Printf("%v\n", mat.Formatted(freqs))
}
```