From 131a72ee0a69fd0e1a1a879eb1fd7d10371e79d3 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Tue, 1 Jul 2014 04:43:41 +0000 Subject: [PATCH] converted trig functions to single prec floats to play happily on the STM32F4 git-svn-id: https://svn.code.sf.net/p/freetel/code@1722 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/src/fdmdv.c | 56 +++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/codec2-dev/src/fdmdv.c b/codec2-dev/src/fdmdv.c index 6e3e1b05..835b514c 100644 --- a/codec2-dev/src/fdmdv.c +++ b/codec2-dev/src/fdmdv.c @@ -106,7 +106,7 @@ static COMP cadd(COMP a, COMP b) static float cabsolute(COMP a) { - return sqrt(pow(a.real, 2.0) + pow(a.imag, 2.0)); + return sqrtf(pow(a.real, 2.0) + pow(a.imag, 2.0)); } /*---------------------------------------------------------------------------*\ @@ -164,8 +164,8 @@ struct FDMDV * fdmdv_create(int Nc) This helped PAPR for a few dB. We don't need to adjust rx phase as DQPSK takes care of that. */ - f->phase_tx[c].real = cos(2.0*PI*c/(Nc+1)); - f->phase_tx[c].imag = sin(2.0*PI*c/(Nc+1)); + f->phase_tx[c].real = cosf(2.0*PI*c/(Nc+1)); + f->phase_tx[c].imag = sinf(2.0*PI*c/(Nc+1)); f->phase_rx[c].real = 1.0; f->phase_rx[c].imag = 0.0; @@ -177,8 +177,8 @@ struct FDMDV * fdmdv_create(int Nc) } fdmdv_set_fsep(f, FSEP); - f->freq[Nc].real = cos(2.0*PI*FDMDV_FCENTRE/FS); - f->freq[Nc].imag = sin(2.0*PI*FDMDV_FCENTRE/FS); + f->freq[Nc].real = cosf(2.0*PI*FDMDV_FCENTRE/FS); + f->freq[Nc].imag = sinf(2.0*PI*FDMDV_FCENTRE/FS); f->freq_pol[Nc] = 2.0*PI*FDMDV_FCENTRE/FS; /* Generate DBPSK pilot Look Up Table (LUT) */ @@ -300,15 +300,15 @@ void fdmdv_set_fsep(struct FDMDV *f, float fsep) { for(c=0; cNc/2; c++) { carrier_freq = (-f->Nc/2 + c)*f->fsep + FDMDV_FCENTRE; - f->freq[c].real = cos(2.0*PI*carrier_freq/FS); - f->freq[c].imag = sin(2.0*PI*carrier_freq/FS); + f->freq[c].real = cosf(2.0*PI*carrier_freq/FS); + f->freq[c].imag = sinf(2.0*PI*carrier_freq/FS); f->freq_pol[c] = 2.0*PI*carrier_freq/FS; } for(c=f->Nc/2; cNc; c++) { carrier_freq = (-f->Nc/2 + c + 1)*f->fsep + FDMDV_FCENTRE; - f->freq[c].real = cos(2.0*PI*carrier_freq/FS); - f->freq[c].imag = sin(2.0*PI*carrier_freq/FS); + f->freq[c].real = cosf(2.0*PI*carrier_freq/FS); + f->freq[c].imag = sinf(2.0*PI*carrier_freq/FS); f->freq_pol[c] = 2.0*PI*carrier_freq/FS; } } @@ -387,7 +387,7 @@ void tx_filter(COMP tx_baseband[NC+1][M], int Nc, COMP tx_symbols[], COMP tx_fil float acc; COMP gain; - gain.real = sqrt(2.0)/2.0; + gain.real = sqrtf(2.0)/2.0; gain.imag = 0.0; for(c=0; creal; - pilot_fdm[i].imag = sqrt(2)*2*tx_baseband[i] * phase->imag; + pilot_fdm[i].real = sqrtf(2)*2*tx_baseband[i] * phase->real; + pilot_fdm[i].imag = sqrtf(2)*2*tx_baseband[i] * phase->imag; } } @@ -598,7 +598,7 @@ void generate_pilot_fdm(COMP *pilot_fdm, int *bit, float *symbol, void generate_pilot_lut(COMP pilot_lut[], COMP *pilot_freq) { int pilot_rx_bit = 0; - float pilot_symbol = sqrt(2.0); + float pilot_symbol = sqrtf(2.0); COMP pilot_phase = {1.0, 0.0}; float pilot_filter_mem[NFILTER]; COMP pilot[M]; @@ -764,8 +764,8 @@ void fdmdv_freq_shift(COMP rx_fdm_fcorr[], COMP rx_fdm[], float foff, float mag; int i; - foff_rect.real = cos(2.0*PI*foff/FS); - foff_rect.imag = sin(2.0*PI*foff/FS); + foff_rect.real = cosf(2.0*PI*foff/FS); + foff_rect.imag = sinf(2.0*PI*foff/FS); for(i=0; i P) @@ -1086,8 +1086,8 @@ float qpsk_to_bits(int rx_bits[], int *sync_bit, int Nc, COMP phase_difference[] int msb=0, lsb=0; float ferr, norm; - pi_on_4.real = cos(PI/4.0); - pi_on_4.imag = sin(PI/4.0); + pi_on_4.real = cosf(PI/4.0); + pi_on_4.imag = sinf(PI/4.0); /* Extra 45 degree clockwise lets us use real and imag axis as decision boundaries. "norm" makes sure the phase subtraction @@ -1167,8 +1167,8 @@ void snr_update(float sig_est[], float noise_est[], int Nc, COMP phase_differenc COMP pi_on_4; int c; - pi_on_4.real = cos(PI/4.0); - pi_on_4.imag = sin(PI/4.0); + pi_on_4.real = cosf(PI/4.0); + pi_on_4.imag = sinf(PI/4.0); /* mag of each symbol is distance from origin, this gives us a vector of mags, one for each carrier. */ @@ -1188,8 +1188,8 @@ void snr_update(float sig_est[], float noise_est[], int Nc, COMP phase_differenc quadrant for convenience. */ for(c=0; cfft_buf[i] * (0.5 - 0.5*cos((float)i*2.0*PI/(2*FDMDV_NSPEC))); + fft_in[i].real = f->fft_buf[i] * (0.5 - 0.5*cosf((float)i*2.0*PI/(2*FDMDV_NSPEC))); fft_in[i].imag = 0.0; } -- 2.25.1