Suppose there are two functions $f(x)$ and $g(x)$. Each function is nonzero only in the specified interval, $[m_f, M_f]$ and $[m_g, M_g]$. What I want to calculate is the cross-correlation between two functions: $$ (f\star g)(t) = \int_{-\infty}^{\infty} f^\ast(x)g(x+t)dx $$ which can be obtained by applying convolution theorem: $$ (f\star g)(t) = \mathcal{F}^{-1}\left\{{\mathcal{F}\left\{f\right\}}^\ast\cdot\mathcal{F}\left\{g\right\}\right\}=\mathcal{F}^{-1}\left\{\hat{f}^\ast\cdot\hat{g}\right\} $$ where $\hat{.}$ denotes forward transformation.
Now, to write this in FFT, I prepared four sets of arrays: x_f, x_g, y_f, y_g
. x_f
and x_g
denote the $x$ domain of respective functions, and they are 1. zero-pad and 2. sampled in the same sampling. Basically, I took whichever was greater between $M_f-m_f$ and $M_g-m_g$, defined it to be $L/2$, made it as the interval axes. So, x_f[0]
is $m_f$, and x_f[-1]
is $m_f+L\geq M_f$. The same goes for x_g
. y_f
and y_g
are defined to be $f(x)$ and $g(x)$ at each x_f
and x_g
.
If we take y_c = ifft(fft(y_f).conjugate()*fft(y_g))
, we get a somewhat valid result. However, it is not easy to map y_c
corresponds to what x_c
so that y_c
is equal to $(f\star g)(x)$ at x_c
. How do you calculate this?
Also, what happens if there are three terms? i.e., $(f\star (g\star h))(t)$?