// Assumes that f is no smaller than x. func copyRealToChannel(f *rimg64.Multi, p int, x *fftw.Array2) { for u := 0; u < f.Width; u++ { for v := 0; v < f.Height; v++ { f.Set(u, v, p, real(x.At(u, v))) } } }
// Assumes that f is no smaller than x. func copyRealTo(f *rimg64.Image, x *fftw.Array2) { for u := 0; u < f.Width; u++ { for v := 0; v < f.Height; v++ { f.Set(u, v, real(x.At(u, v))) } } }
// ai <- k ai func scale(k complex128, c *fftw.Array2) { m, n := c.Dims() for i := 0; i < m; i++ { for j := 0; j < n; j++ { c.Set(i, j, k*c.At(i, j)) } } }
// ci <- k conj(ai) bi func scaleMul(c *fftw.Array2, k complex128, a, b *fftw.Array2) { m, n := a.Dims() for i := 0; i < m; i++ { for j := 0; j < n; j++ { ax := cmplx.Conj(a.At(i, j)) bx := b.At(i, j) c.Set(i, j, k*ax*bx) } } }
// ci <- ci + conj(ai) bi func addMul(c *fftw.Array2, a, b *fftw.Array2) { m, n := a.Dims() for i := 0; i < m; i++ { for j := 0; j < n; j++ { ax := cmplx.Conj(a.At(i, j)) bx := b.At(i, j) cx := c.At(i, j) c.Set(i, j, cx+ax*bx) } } }