package DFT;

import java.util.Vector;


class DftGen {

  public static float[] from(float[] signal){
	  float[] res = new float[signal.length];

    Vector<Point> data = new Vector<Point>();


    for (int i=0; i<signal.length; i++){
      Point p = new Point(i,signal[i]);
      data.addElement( p );
    }

    Dft DFT = new Dft( data );

    Vector<Complex> transData = new Vector<Complex>();
    int N = data.size();

    //
    // The DFT produces unique points only over the first
    // N/2 points for real values.  The other points are
    // a mirror of the first N/2 values.
    //
    for (int i = 0; i < N; i++) {
      Complex cx = DFT.dftPoint( i );
      transData.addElement( cx );
    }
    for (int i = 0; i < N; i++) res[i] = transData.get(i).mag();
    
    return res;
  }

}
