int vsip_cfirflt_f( vsip_cfir_f *fir, const vsip_cvview_f *xc, const vsip_cvview_f *yc) { vsip_length nout,k; vsip_cvview_f xx = *(xc), yy = *(yc); vsip_cvview_f H1 = *(fir->h), H2 = *(fir->h); vsip_cvview_f *x=&xx,*y=&yy; vsip_cvview_f *h1=&H1,*h2=&H2; vsip_offset oinc; oinc = (vsip_offset)((vsip_stride)fir->D * x->stride); /* calculate number of terms in y */ nout = (fir->N - fir->p); nout = ((nout % fir->D) == 0) ? (nout / fir->D ) : (nout / fir->D + 1); /* do overlap section */ k = 0; x->length = fir->p + 1; h1->length = fir->s->length; h2->length = x->length; h2->offset = h1->length; while(x->length < fir->M){ vsip_cscalar_f a = vsip_cvdot_f(h1,fir->s); vsip_cscalar_f b = vsip_cvdot_f(h2,x); vsip_cvput_f(y,k++,vsip_cmplx_f(a.r + b.r,a.i + b.i)); x->length += fir->D; fir->s->length -= fir->D; fir->s->offset += fir->D; h1->length = fir->s->length; h2->length = x->length; h2->offset = h1->length; } x->offset += (x->length - fir->M) * x->stride; x->length = fir->M; while(k < nout){ /* do the rest of the pieces */ vsip_cvput_f(y,k++,vsip_cvdot_f(fir->h,x)); x->offset += oinc; } { vsip_stride temp_p = (fir->p % fir->D) - (fir->N % fir->D); fir->p = ((temp_p < 0) ? (vsip_length)((vsip_stride)fir->D + temp_p) : (vsip_length)temp_p); } fir->s->offset = 0; fir->s->length = (fir->state == VSIP_STATE_SAVE) ? fir->M - 1 - fir->p : fir->M -1; x->length = fir->s->length; /* fix by JMA, 31/01/2000, incorrect offset calculation */ /* x->offset = xc->length - fir->s->length; */ x->offset = xc->offset + (xc->length - fir->s->length) * xc->stride; if((fir->s->length > 0) && (fir->state == VSIP_STATE_SAVE)) VI_cvcopy_f_f(x,fir->s); if(fir->state == VSIP_STATE_NO_SAVE) { VI_cvfill_f(vsip_cmplx_f((vsip_scalar_f)0,(vsip_scalar_f)0),fir->s); fir->p = 0; } return k; }
void vsip_ccorrelate1d_f( const vsip_ccorr1d_f *cor, vsip_bias bias, const vsip_cvview_f *h, const vsip_cvview_f *x, const vsip_cvview_f *y) { vsip_cvview_f xx = *cor->x, hh = *cor->h; vsip_cvview_f *xt = &xx, *ht = &hh; xt->length = cor->x->length - x->length; VI_cvfill_f(vsip_cmplx_f((vsip_scalar_f)0,(vsip_scalar_f)0),xt); xt->offset = xt->length; xt->length = x->length; VI_cvcopy_f_f(x,xt); xt->length = cor->x->length; xt->offset = 0; ht->length = cor->h->length - h->length; ht->offset = h->length; VI_cvfill_f(vsip_cmplx_f((vsip_scalar_f)0,(vsip_scalar_f)0),ht); ht->offset = 0; ht->length = h->length; VI_cvcopy_f_f(h,ht); vsip_ccfftip_f(cor->fft,cor->h); vsip_ccfftip_f(cor->fft,cor->x); vsip_cvjmul_f(cor->x,cor->h,cor->x); vsip_cvconj_f(cor->x,cor->x); vsip_rscvmul_f(1/(vsip_scalar_f)cor->N,cor->x,cor->x); vsip_ccfftip_f(cor->fft,cor->x); /* vsip_cvconj_f(cor->x,cor->x); */ switch(cor->support){ case VSIP_SUPPORT_FULL: xt->offset = xt->length - cor->mn; xt->length = y->length; if(bias == VSIP_UNBIASED){ VI_cvunbiasfull_f(cor,xt,y); } else { VI_cvcopy_f_f(xt,y); } break; case VSIP_SUPPORT_SAME: xt->offset = xt->length - cor->mn + (cor->m-1)/2; xt->length = y->length; if(bias == VSIP_UNBIASED){ VI_cvunbiassame_f(cor,xt,y); } else { VI_cvcopy_f_f(xt,y); } break; case VSIP_SUPPORT_MIN: xt->offset = xt->length - cor->mn + cor->m - 1; xt->length = y->length; if(bias == VSIP_UNBIASED){ vsip_rscvmul_f((vsip_scalar_f)1.0/(vsip_scalar_f)cor->m,xt,y); } else { VI_cvcopy_f_f(xt,y); } break; } return; }