// file: extract_feature/extf_func_0.cc
//

// isip include files
//
#include "extract_feature.h"
#include <Signal.h>

#include "extract_feature_constants.h"
#include <signal_constants.h>

#include <fourier_transform.h>
#include <fourier_transform_constants.h>

// method: func_fft_cc
//
// arguments:
//  float_8* output_a: (output) FT transform magnitude coefficients
//  float_8* input_a: (input) real time domain signal data
//  int_4 num_samples_a: (input) number of samples to operate upon
//
// This method computes the Fourier transform of a signal
//
logical_1 Extract_feature::func_fft_cc(float_8* output_a, float_8* input_a, int_4 num_samples_a) {

  Fourier_transform ft;

  float_8 freq[num_samples_a * 2];
  
  ft.set_cc(num_samples_a, EXTF_FT_ALGO, EXTF_FT_DTYPE);

  ft.compute_cc(freq, input_a);

  for (int_4 i = 1; i < num_samples_a; i++) {
    float_8 real = freq[2 * i];
    float_8 imag = freq[2 * i + 1];
    output_a[i] = sqrt(real * real + imag * imag);
  }    
  output_a[0] = sqrt(freq[0] * freq[0]);

  // return without error
  //
  return ISIP_TRUE;
}

