www.pudn.com > wimax_ofdm_implementation_code.rar > doubler.c
/*****************************************************************************/
/* FIle Name : doubler.c */
/* Description : Wi-Max Encoder's interpolation */
/* author : miffie */
/* Date : aug/12/05 */
/* Copyright (c) 2005 miffie All rights reserved. */
/*****************************************************************************/
double cubic_spline (double y0, double y1, double y2, double y3,
double xx) { //cubic_spline
double yxx ;
double aa, bb, cc, dd ;
//Y(xx)= aa*xx^3 + bb*xx^2 + cc*xx +dd
//Y(0) = y1
//Y(1) = y2
//Y'(0) = (y2-y0)/2
//Y''(1) = (y3-y1)/2
aa = ( y3 - 3*y2 + 3*y1 - y0 )/2 ;
bb = (- y3 + 4*y2 - 5*y1 + 2*y0)/2 ;
cc = (y2 - y0)/2 ;
dd = y1 ;
yxx = ( aa * xx * xx * xx ) +
( bb * xx * xx ) +
( cc * xx ) +
( dd ) ;
return( yxx ) ;
} //cubic_spline
struct complexset doubler (struct complexset datain ) {
int ii ;
struct complex *top ;
int tx_floor , tx_ceil ;
struct complexset ctop ;
double y0, y1, y2, y3 ;
if ((top = (struct complex *)malloc(datain.size*2*sizeof(struct complex)) ) == NULL) {
PRINTF( " malloc failed in doubler.c\n") ;
} //fail
else { //allocated
PRINTF("doubler size=\n", datain.size ) ;
for( ii=0;ii=datain.size) y2 = datain.data[ii].realp ;
else y2 = datain.data[ii+1].realp ;
if ((ii+2)>=datain.size) y3 = datain.data[ii].realp ;
else y3 = datain.data[ii+2].realp ;
top[2*ii].realp = y1 ;
top[2*ii+1].realp = cubic_spline(y0, y1, y2, y3, 0.5) ;
if(ii==0) y0 = datain.data[ 0 ].image ;
else y0 = datain.data[ii-1].image ;
y1 = datain.data[ii].image ;
if ((ii+1)>=datain.size) y2 = datain.data[ii].image ;
else y2 = datain.data[ii+1].image ;
if ((ii+2)>=datain.size) y3 = datain.data[ii].image ;
else y3 = datain.data[ii+2].image ;
top[2*ii].image = y1 ;
top[2*ii+1].image = cubic_spline(y0, y1, y2, y3, 0.5) ;
} //for
} //allocated
ctop.data = top ;
ctop.size = datain.size * 2 ;
free( datain.data ) ;
return( ctop ) ;
}//doubler