// file: $PDSP/class/fourier_transform/v3.0/fourier_transform.h
//

// this is the header for the fourier_transform class
//

// make sure definitions are only made once
//
#ifndef __ISIP_FOURIER_TRANSFORM
#define __ISIP_FOURIER_TRANSFORM

// isip include files
//
#ifndef __ISIP_INTEGRAL
#include <integral.h>
#endif

// Fourier_transform: a class that analyzes operations
//	for a variety of fourier transform algorithms
//
class Fourier_transform {
  
  //---------------------------------------------------------------------------
  //
  // protected data
  //
  //---------------------------------------------------------------------------
protected:
  
  // debugging parameters
  //
  int_4 debug_level_d;				// amount of debugging info
  
  // parameters related to the algorithm specification
  //
  int_4 N_d;					// order
  int_4 algorithm_d;				// numerical identifier
  int_4 data_type_d;				// real or complex
  
  // parameters related to the discrete fourier transform algorithm
  //
  int_4 df_last_order_d;
  float_8* df_wr_d;
  float_8* df_wi_d;
  
  // parameters related to the radix-2 algorithm
  //
  int_4 rad2_last_order_d;
  float_8* rad2_wr_d;
  float_8* rad2_wi_d;
  float_8* rad2_temp_d;    
  
  // parameters related to the radix-4 algorithm
  //
  int_4 rad4_last_order_d;
  float_8* rad4_wr_d;
  float_8* rad4_wi_d;
  float_8* rad4_temp_d;
  
  // parameters related to the split-radix algorithm
  //
  int_4 sr_last_order_d;
  float_8* sr_wr_d;
  float_8* sr_wi_d;
  float_8* sr_temp_d;
  
  // parameters related to the fast-hartley algorithm
  //
  int_4 fh_last_order_d;
  float_8* fh_temp_d;
  float_8* fh_temp_input_d;
  float_8* fh_temp_output_d;

  // parameters related to the quick fourier transform algorithm
  //
  int_4 qf_last_order_d;
  float_8* qf_real_coeff_d;
  float_8* qf_imag_coeff_d;
  float_8* qf_real_temp_d;
  float_8* qf_imag_temp_d;

  float_8* qf_comp_real_coeff_d;
  float_8* qf_comp_imag_coeff_d;
  float_8* qf_comp_real_temp_d;
  float_8* qf_comp_imag_temp_d;

  // workspace related pointers for quick fourier transform
  //
  float_8** ws; //	Workspace pointers
  float_8* sc;	//	Secant table addr.	
  int_4*   nc;	//	Current QFT length	
  int_4*   ic;	//	Current secant inc.	
  int_4*   mc;	//	Current output pruning	
  int_4	nn;	//	Pruned QFT input length
  int_4	mm;	//	Pruned QFT output length
  int_4	ii;	//	Current QFT recursion level
  
  // parameters related to the decimation in time frequency algorithm
  //
  int_4 ditf_last_order_d;
  float_8* ditf_wr_d;
  float_8* ditf_wi_d;
  float_8* ditf_temp_d;
  int_4* ditf_trans_factor_indices_d;
  int_4* ditf_indices_d;
  
  //---------------------------------------------------------------------------
  //
  // public methods
  //
  //---------------------------------------------------------------------------
public:

  // required methods
  //
  char_1* name_cc();
  volatile void error_handler_cc(char_1* method_name, char_1* message);
  
  // destructors/constructors
  //
  ~Fourier_transform();  
  Fourier_transform();

  // set signal processing parameters
  //
  logical_1 set_cc(int_4 order);
  logical_1 set_cc(int_4 order, int_4 algorithm);
  logical_1 set_cc(int_4 order, int_4 algorithm, long data_type);

  int_4 set_cc(char_1* algorithm);  
  logical_1 set_cc(int_4 order, char_1* algorithm);  
  logical_1 set_cc(int_4 order, char_1* algorithm, int_4 data_type);

  // get the name of chosen algorithm
  //
  logical_1 get_algorithm_cc(int_4& algorithm);
  logical_1 get_algorithm_name_cc(char_1* algorithm_name);
  
  // computation methods
  //
  logical_1 compute_cc(float_8* output, float_8* input);

  // debugging methods
  //
  logical_1 set_debug_cc(int_4 debug_level);
  logical_1 debug_cc(FILE* fp, char_1* message);
  
  //---------------------------------------------------------------------------
  //
  // private methods
  //
  //---------------------------------------------------------------------------
private:

  // miscellaneous math methods
  //
  logical_1 is_power_cc(int_4& exponent, int_4 base);

  // method to check the order of the algorithm and assign a default
  // algorithm if the chosen algorithm does not support the provided
  // order
  //
  logical_1 algorithm_check_cc();
  
  // algorithm methods for real signals
  //
  logical_1 df_real_cc(float_8* output, float_8* input);
  logical_1 rad2_real_cc(float_8* output, float_8* input);
  logical_1 rad4_real_cc(float_8* output, float_8* input);
  logical_1 sr_real_cc(float_8* output, float_8* input);
  logical_1 fh_real_cc(float_8* output, float_8* input);
  logical_1 qf_real_cc(float_8* output, float_8* input);
  logical_1 ditf_real_cc(float_8* output, float_8* input);
  logical_1 pfa_real_cc(float_8* output, float_8* input);

  // algorithm methods for complex signals
  //
  logical_1 df_complex_cc(float_8* output, float_8* input);
  logical_1 rad2_complex_cc(float_8* output, float_8* input);
  logical_1 rad4_complex_cc(float_8* output, float_8* input);
  logical_1 sr_complex_cc(float_8* output, float_8* input);
  logical_1 fh_complex_cc(float_8* output, float_8* input);
  logical_1 qf_complex_cc(float_8* output, float_8* input);
  logical_1 ditf_complex_cc(float_8* output,float_8* input);
  logical_1 pfa_complex_cc(float_8* output, float_8* input);
    
  //---------------------------------------------------------------------------
  //
  // auxillary methods needed for particular algorithms
  //
  //---------------------------------------------------------------------------
  // 
  // related to the discrete fourier
  //
  logical_1 df_init_cc(int_4 order);
  
  // related to the radix-2
  //
  logical_1 rad2_init_cc(int_4 order);

  // related to the radix-4
  //
  logical_1 rad4_init_cc(int_4 order);
  
  // related to the fast hartley
  //
  logical_1 fh_init_cc (int_4 order);
  logical_1 fh_trig_next_cc (int_4 k, float_8 c, float_8 s, int_4& p);
  
  // related to split-radix
  //
  logical_1 sr_init_cc(int_4 order);

  // related to quick fourier
  //
  logical_1 qf_init_cc(int_4 order);
  logical_1 qf_close_cc();
  logical_1 qf_real_dct_cc(float_8* coeff, float_8* data);
  logical_1 qf_real_dst_cc(float_8* coeff, float_8* data);

  // related to decimation in time and frequency
  //
  logical_1 ditf_init_cc(int_4 order);
  
  // related to the prime factors algorithm
  //
  
};

// end of file
// 
#endif
