/*
 * Academic License - for use in teaching, academic research, and meeting
 * course requirements at degree granting institutions only.  Not for
 * government, commercial, or other organizational use.
 *
 * hilbert_fir.c
 *
 * Code generation for function 'hilbert_fir'
 *
 */

/* Include files */
#include "hilbert_fir.h"
#include <math.h>
#include <string.h>

/* Function Definitions */
void hilbert_fir(const double data[8], double i_data[8], double q_data[8])
{
  static const short iv[33] = {
      0,     -69,  0,     -202, 0,      -471, 0,     -950, 0,    -1766, 0,
      -3213, 0,    -6337, 0,    -20648, 0,    20648, 0,    6337, 0,     3213,
      0,     1766, 0,     950,  0,      471,  0,     202,  0,    69,    0};
  double q_data_temp[40];
  int b_k;
  int k;
  memcpy(&i_data[0], &data[0], 8U * sizeof(double));
  memset(&q_data_temp[0], 0, 40U * sizeof(double));
  for (k = 0; k < 8; k++) {
    for (b_k = 0; b_k < 33; b_k++) {
      int q_data_temp_tmp;
      q_data_temp_tmp = k + b_k;
      q_data_temp[q_data_temp_tmp] += data[k] * (double)iv[b_k];
    }
  }
  for (k = 0; k < 8; k++) {
    double d;
    d = floor(q_data_temp[k + 16] / 32768.0);
    q_data[k] = d;
    if (d > 32767.0) {
      d = 32767.0;
      q_data[k] = 32767.0;
    }
    if (d < -32768.0) {
      q_data[k] = -32768.0;
    }
  }
}

void hilbert_fir_initialize(void)
{
}

void hilbert_fir_terminate(void)
{
}

/* End of code generation (hilbert_fir.c) */
