示例#1
0
/* ai: LABEL (here) = "check_square";*/
status_t check_square(const void* params, const int16_t * fft_r, const int16_t* fft_i)
{
  int i;
  const check_square_param_t* ps = (const check_square_param_t*)params;

  uint16_t base = abs_complex(fft_r[0],fft_i[0]);
  uint16_t top  = base;
  uint16_t f;
  int count = 0;
  if(base < ps->base_minimum) return S_BAD_SPECTRUM;


  for(i = 1; i < SAMPLE_COUNT>>1;i++)
  {
	  /* ai: loop here max 32; */
	  
    f = abs_complex(fft_r[i],fft_i[i]); /* ai: flow (here) <=32; */
    if(f > ps->noise_threshold) {
      count++;
      if(f > top) return S_BAD_SPECTRUM;
      top = f;
      if(count == 1) {
        if(f < ps->f1_minimum) return S_BAD_SPECTRUM;
      }
    }
  }
  if(count == 0) return S_BAD_SPECTRUM;
  return S_OK;
}
示例#2
0
inline doublecomplex complex_signum_complex(doublecomplex z) {
    doublecomplex r;
    double mag;
    if (z.r == 0 && z.i == 0) {
        r.r = 0;
        r.i = 0;
    } else {
        mag = abs_complex(z);
        r.r = z.r/mag;
        r.i = z.i/mag;
    }
    return r;
}
示例#3
0
void swap_largest(complex_t *array[], int n,int max_index)
{
	complex_t *temp;
	temp=array[max_index];
	array[max_index]=array[n-1];
	array[n-1]=temp;


int find_biggest(complex_t *array[], int n, int start, int curmax) {

	double  cabs2;
	cabs2= abs_complex(*array[start+1]);

	if (start == n-1);
	{
	return(curmax);
	}

	if (cabs2>abs_complex(*array[curmax]))
	{
	curmax=start+1;
	}
	return(find_biggest(array,n,start+1,curmax));
        }
示例#4
0
inline doublecomplex complex_abs_complex(doublecomplex z) {
    doublecomplex r;
    r.r = abs_complex(z);
    r.i = 0;
    return r;
}