vsip_scalar_f (vsip_cvmodulate_f)( const vsip_cvview_f* a, vsip_scalar_f nu, vsip_scalar_f phi, const vsip_cvview_f* r) { { /* register */ vsip_length n = r->length; vsip_stride cast = a->block->cstride, crst = r->block->cstride; vsip_scalar_f *apr = (vsip_scalar_f*) ((a->block->R->array) + cast * a->offset), *rpr = (vsip_scalar_f*) ((r->block->R->array) + crst * r->offset); vsip_scalar_f *api = (vsip_scalar_f*) ((a->block->I->array) + cast * a->offset), *rpi = (vsip_scalar_f*) ((r->block->I->array) + crst * r->offset); vsip_scalar_f arg = phi; /* register */ vsip_stride ast = (cast * a->stride), rst = (crst * r->stride); while(n-- > 0){ *rpr = *apr * VSIP_COS_F(arg) - *api * VSIP_SIN_F(arg); *rpi = *apr * VSIP_SIN_F(arg) + *api * VSIP_COS_F(arg); arg += nu; apr += ast; api += ast; rpr += rst; rpi += rst; } return arg; } }
void (vsip_mcos_f)( const vsip_mview_f *a, const vsip_mview_f *r) { { vsip_length n_mj, /* major length */ n_mn; /* minor length */ vsip_stride ast_mj, ast_mn, rst_mj, rst_mn; vsip_scalar_f *ap = (a->block->array) + a->offset * a->block->rstride, *rp = (r->block->array) + r->offset * r->block->rstride; vsip_scalar_f *ap0 = ap, *rp0 = rp; /* pick direction dependent on output */ if(r->row_stride < r->col_stride){ n_mj = r->row_length; n_mn = r->col_length; rst_mj = r->row_stride; rst_mn = r->col_stride; ast_mj = a->row_stride; ast_mn = a->col_stride; rst_mj *= r->block->rstride; rst_mn *= r->block->rstride; ast_mj *= a->block->rstride; ast_mn *= a->block->rstride; } else { n_mn = r->row_length; n_mj = r->col_length; rst_mn = r->row_stride; rst_mj = r->col_stride; ast_mn = a->row_stride; ast_mj = a->col_stride; rst_mn *= r->block->rstride; rst_mj *= r->block->rstride; ast_mn *= a->block->rstride; ast_mj *= a->block->rstride; } /*end define*/ if(ap == rp){ /* inplace */ while(n_mn-- > 0){ int n = n_mj; while(n-- >0){ *rp = (vsip_scalar_f) VSIP_COS_F(*rp); rp += rst_mj; } rp0 += rst_mn; rp = rp0; } } else { while(n_mn-- > 0){ int n = n_mj; while(n-- >0){ *rp = (vsip_scalar_f) VSIP_COS_F(*ap); ap += ast_mj; rp += rst_mj; } ap0 += ast_mn; rp0 += rst_mn; ap = ap0; rp = rp0; } } } return; }
void (vsip_vrect_f)( const vsip_vview_f* r, const vsip_vview_f* t, const vsip_cvview_f* a) {/* a_j = r_j*(cos(t_j), sin(t_j)) */ { /* register */ vsip_length n = r->length; vsip_stride cast = a->block->cstride, rrst = r->block->rstride, trst = r->block->rstride; vsip_scalar_f *apr = (vsip_scalar_f*) ((a->block->R->array) + cast * a->offset), *rp = (vsip_scalar_f*) ((r->block->array) + rrst * r->offset), *tp = (vsip_scalar_f*) ((t->block->array) + trst * t->offset); vsip_scalar_f *api = (vsip_scalar_f*) ((a->block->I->array) + cast * a->offset); vsip_scalar_f temp = 0; /* register */ vsip_stride ast = (cast * a->stride), rst = rrst * r->stride, tst = trst * t->stride; while(n-- > 0){ temp = *rp * VSIP_SIN_F(*tp); *apr = *rp * VSIP_COS_F(*tp); *api = temp; apr += ast; api += ast; rp += rst; tp += tst; } } }
vsip_vview_f* (vsip_vcreate_hanning_f)( vsip_length N, vsip_memory_hint h) { vsip_vview_f *a; a = VI_vcreate_f(N,h); if(a == NULL) return (vsip_vview_f*)NULL; { /*define variables*/ vsip_length n = 0; vsip_scalar_f *ap = (a->block->array) + a->offset, temp = (vsip_scalar_f)twoPI/(N+1); /*end define*/ /* Note this is always unit stride */ while(n++ < N ){ *ap++ = (vsip_scalar_f)0.5 * ((vsip_scalar_f)1. - (vsip_scalar_f)VSIP_COS_F(temp * (vsip_scalar_f) n)); } } return a; }
void (vsip_cmexp_f)( const vsip_cmview_f *a, const vsip_cmview_f *r) { { vsip_length n_mj, /* major length */ n_mn; /* minor length */ vsip_stride ast_mj, ast_mn, rst_mj, rst_mn; vsip_scalar_f *ap_r = (a->block->R->array) + a->offset * a->block->cstride, *rp_r = (r->block->R->array) + r->offset * r->block->cstride; vsip_scalar_f *ap_i = (a->block->I->array) + a->offset * a->block->cstride, *rp_i = (r->block->I->array) + r->offset * r->block->cstride; vsip_scalar_f *ap0_r = ap_r, *rp0_r = rp_r; vsip_scalar_f *ap0_i = ap_i, *rp0_i = rp_i; vsip_scalar_f mag = 0; /* pick direction dependent on output */ if(r->row_stride < r->col_stride){ n_mj = r->row_length; n_mn = r->col_length; rst_mj = r->row_stride; rst_mn = r->col_stride; ast_mj = a->row_stride; ast_mn = a->col_stride; rst_mj *= r->block->cstride; rst_mn *= r->block->cstride; ast_mj *= a->block->cstride; ast_mn *= a->block->cstride; } else { n_mn = r->row_length; n_mj = r->col_length; rst_mn = r->row_stride; rst_mj = r->col_stride; ast_mn = a->row_stride; ast_mj = a->col_stride; rst_mn *= r->block->cstride; rst_mj *= r->block->cstride; ast_mn *= a->block->cstride; ast_mj *= a->block->cstride; } /*end define*/ if(ap_i == rp_i){ /* inplace */ while(n_mn-- > 0){ vsip_length n = n_mj; while(n-- >0){ mag = VSIP_EXP_F(*rp_r); *rp_r = mag * VSIP_COS_F(*rp_i); *rp_i = mag * VSIP_SIN_F(*rp_i); rp_r += rst_mj; rp_i += rst_mj; } rp0_r += rst_mn; rp0_i += rst_mn; rp_r = rp0_r; rp_i = rp0_i; } } else { /* out of place */ while(n_mn-- > 0){ vsip_length n = n_mj; while(n-- >0){ mag = VSIP_EXP_F(*ap_r); *rp_r = mag * VSIP_COS_F(*ap_i); *rp_i = mag * VSIP_SIN_F(*ap_i); ap_r += ast_mj; rp_r += rst_mj; ap_i += ast_mj; rp_i += rst_mj; } ap0_r += ast_mn; rp0_r += rst_mn; ap0_i += ast_mn; rp0_i += rst_mn; ap_r = ap0_r; rp_r = rp0_r; ap_i = ap0_i; rp_i = rp0_i; } } } return; }
vsip_cscalar_f (vsip_rect_f)( vsip_scalar_f r, vsip_scalar_f t) { return vsip_cmplx_f(r * VSIP_COS_F(t), r * VSIP_SIN_F(t)); }