Example #1
0
 /**
  * Computes the correlation of fdata with gdata. The value of the output at index i is the sum
  * over j of fdata[i+j]*gdata[j], although using the FFT is much faster than direct sum.
  *
  * @see http://www.ulib.org/webRoot/Books/Numerical_Recipes/bookcpdf.html section 13-2
  */
 public static final float[] correlate(float[] fdata, float[] gdata) {
   if (fdata.length != gdata.length) {
     throw new IllegalArgumentException(
         "fdata and gdata must have same length. " + fdata.length + " " + gdata.length);
   }
   Cmplx[] fTrans = fft(fdata);
   Cmplx[] gTrans = fft(gdata);
   for (int i = 0; i < fTrans.length; i++) {
     fTrans[i] = Cmplx.mul(fTrans[i], gTrans[i].conjg());
   } // end of for (int i=0; i<gdata.length; i++)
   return fftInverse(fTrans, fdata.length);
 }
Example #2
0
 public static final Cmplx mul(Cmplx a, double b) {
   return Cmplx.mul(a, new Cmplx(b, 0));
 }
Example #3
0
 public static final Cmplx mul(double a, Cmplx b) {
   return Cmplx.mul(new Cmplx(a, 0), b);
 }