#include <math.h>
#include <iostream.h>

#include "fftserver.h"
#include "nobjmgr.h"

extern "C" {
  void tfft(vector<string>& args);
  }

int main(int narg, char* arg)
{
vector<string> a;
string str = "nopiapp";
a.push_back(str);

cout << "Appel de tfft ( " << a[0] << " ) " << endl; 
tfft(a);
exit(0);
}

void tfft(vector<string>& args)
{
  
  int num=30;
  double tper = 2./num;
  /*  Vector* inp = new Vector(num);
  Vector* outp = new Vector(num);

  Vector& in = (*inp);
  Vector& out = (*outp);*/

  complex<double>* in = new complex<double>[num];
  
  
  for (int i=0; i<num ; i++){ in[i] = complex<double> (cos(i*3.141596*tper),cos(3.*i*3.141596*tper));}
  cout << "Input / L = " << num << endl; 
  for (int i=0; i<num ; i++){
    if (i%8 == 0) cout << "\n" << i << "-" << i+7 << " : " ; 
    cout << in[i] << " " ;
    }
  cout << endl;

  FFTServer ffts;
  ffts.fftf(num,in);

  cout << "Output / L = " << num << endl; 
  for (int i=0; i<num ; i++){ 
    if (i%8 == 0) cout << "\n" << i << "-" << i+7 << " : " ; 
    cout << in[i] << " " ;
    }
  cout << endl;

  /* if (args[0] == "nopiapp")  return;
   NamedObjMgr omg;
   string nom;
   nom = "vin";
   omg.AddObj(&in, nom);
   nom = "vout";
   omg.AddObj(&out, nom);*/

}
