Exemplo n.º 1
0
static int test_vec_dot_prod(void)
{
    int i;
    double x[100];
    double y[100];
    double zsa;
    double zsb;
    double ratio;

    printf("Testing vec_dot_prod()\n");
    for (i = 0;  i < 99;  i++)
    {
        x[i] = rand();
        y[i] = rand();
    }
    for (i = 1;  i < 99;  i++)
    {
        zsa = vec_dot_prod(x, y, i);
        zsb = vec_dot_prod_dumb(x, y, i);
        ratio = zsa/zsb;
        if (ratio < 0.9999  ||  ratio > 1.0001)
        {
            printf("vec_dot_prod() - %f %f\n", zsa, zsb);
            printf("Tests failed\n");
            exit(2);
        }
    }
    return 0;
}
Exemplo n.º 2
0
cf_t corr_sz(cf_t *z, cf_t *s) {
	cf_t sum;
	cf_t zsprod[32];
	vec_dot_prod(z, s, zsprod, N_SSS - 1);
	sum = sum_c(zsprod, N_SSS - 1);

	return sum;
}
Exemplo n.º 3
0
int conv_fft_cc_run(conv_fft_cc_t *state, _Complex float *input, _Complex float *filter, _Complex float *output) {

	dft_run_c2c(&state->input_plan, input, state->input_fft);
	dft_run_c2c(&state->filter_plan, filter, state->filter_fft);

	vec_dot_prod(state->input_fft,state->filter_fft,state->output_fft,state->output_len);

	dft_run_c2c(&state->output_plan, state->output_fft, output);

	return state->output_len;

}
Exemplo n.º 4
0
/* Assumes input points to the beginning of the SSS symbol. The SSS symbol start is
 * given by SSS_SYMBOL_ST() macro in sss.h.
 * Estimates the m0 and m1 values and saves in m0_value and m1_value
 * the resulted correlation (higher is more likely)
 *
 */
void sss_synch_m0m1(sss_synch_t *q, cf_t *input, int *m0, float *m0_value,
		int *m1, float *m1_value) {

	/* This is aprox 3-4 kbytes of stack. Consider moving to sss_synch_t?? */
	cf_t zdelay[N_SSS+1],zconj[N_SSS+1],zprod[N_SSS+1];
	cf_t y[2][N_SSS+1], z[N_SSS+1], tmp[N_SSS+1];
	float tmp_real[N_SSS+1];
	cf_t input_fft[SSS_DFT_LEN];

	int i;

	dft_run_c2c(&q->dftp_input, input, input_fft);

	for (i = 0; i < N_SSS; i++) {
		y[0][i] = input_fft[SSS_POS_SYMBOL + 2 * i];
		y[1][i] = input_fft[SSS_POS_SYMBOL + 2 * i + 1];
	}

	vec_dot_prod(y[0], q->fc_tables.c[0], z, N_SSS);
	memcpy(zdelay, &z[1], (N_SSS - 1) * sizeof(cf_t));
	vec_conj(z, zconj, N_SSS - 1);
	vec_dot_prod(zdelay, zconj, zprod, N_SSS - 1);

	corr_all_zs(zprod, q->fc_tables.s, tmp);
	vec_abs(tmp, tmp_real, N_SSS);
	vec_max(tmp_real, m0_value, m0, N_SSS);

	vec_dot_prod(y[1], q->fc_tables.c[1], tmp, N_SSS);
	vec_dot_prod(tmp, q->fc_tables.z1[*m0], z, N_SSS);
	memcpy(zdelay, &z[1], (N_SSS - 1) * sizeof(cf_t));
	vec_conj(z, zconj, N_SSS - 1);
	vec_dot_prod(zdelay, zconj, zprod, N_SSS - 1);

	corr_all_zs(zprod, q->fc_tables.s, tmp);
	vec_abs(tmp, tmp_real, N_SSS);
	vec_max(tmp_real, m1_value, m1, N_SSS);

}