vsip_cvview_d* (vsip_cmcolview_d)( const vsip_cmview_d* v, vsip_index j) { return vsip_cvbind_d( v->block, v->offset + j * v->row_stride, v->col_stride, v->col_length); }
vsip_cvview_d* (vsip_cvsubview_d)( const vsip_cvview_d* v, vsip_index i, vsip_length n) { return vsip_cvbind_d(v->block, v->offset + i * v->stride, v->stride, n); }
vsip_cvview_d* (vsip_cvcreate_d)( vsip_length n, vsip_memory_hint h) { vsip_cblock_d* b = VI_cblockcreate_d((size_t)n, h); vsip_cvview_d* v = (vsip_cvview_d*)NULL; if(b != (vsip_cblock_d*)NULL){ v = vsip_cvbind_d(b, (vsip_offset)0, (vsip_stride)1, n); if(v == (vsip_cvview_d*)NULL) VI_cblockdestroy_d(b); } return v; }
vsip_cvview_d* (vsip_cmdiagview_d)( const vsip_cmview_d* v, vsip_stride idiag) { vsip_index i = (idiag < 0) ? -idiag : 0, /* row index of origin */ j = (idiag > 0) ? idiag : 0; /* col index of origin */ vsip_length n_row = v->col_length - i; /* # rows from origin to end */ vsip_length n_col = v->row_length - j; /* # cols from origin to end */ return vsip_cvbind_d( v->block, v->offset + i * v->col_stride + j * v->row_stride, v->row_stride + v->col_stride, (n_row < n_col) ? n_row : n_col); }
int main (){ vsip_init((void*)0); { int i; vsip_cblock_d* blockOut = vsip_cblockcreate_d(2 * L, 0); vsip_cvview_d* vectorOut = vsip_cvbind_d(blockOut,0,2,L); vsip_cvview_d* vectorIn = vsip_cvcreate_d(L,0); vsip_vview_d* realIn = vsip_vrealview_d(vectorIn); vsip_vview_d* imagIn = vsip_vimagview_d(vectorIn); vsip_fft_d* fftplan = vsip_ccfftop_create_d(L,1,-1,0,0); vsip_fft_d* fftplanI = vsip_ccfftop_create_d(L,(double)1/L,1,0,0); char inputdata[L][20]; /* put some data in realIn*/ vsip_vramp_d(0, 2 * PI * F, realIn); vsip_vcos_d(realIn,realIn); /* print realIn */ for(i=0; i<L; i++) sprintf(inputdata[i],"%2d input-> %7.3f",i, vsip_vget_d(realIn,i)); /*make sure imagIn is full of zeros*/ vsip_vfill_d(0,imagIn); /*find the fft*/ vsip_ccfftop_d(fftplan,vectorIn,vectorOut); /*invert the fft*/ vsip_ccfftop_d(fftplanI,vectorOut,vectorIn); /*print it */ for(i=0; i<L; i++) printf("%s fft -> (%7.3f, %7.3f) ifft -> (%7.3f, %7.3f)\n", inputdata[i], vsip_real_d(vsip_cvget_d(vectorOut,i)), vsip_imag_d(vsip_cvget_d(vectorOut,i)), vsip_real_d(vsip_cvget_d(vectorIn,i)), vsip_imag_d(vsip_cvget_d(vectorIn,i))); { vsip_vdestroy_d(imagIn); vsip_vdestroy_d(realIn); vsip_cblockdestroy_d(vsip_cvdestroy_d(vectorIn)); vsip_cblockdestroy_d(vsip_cvdestroy_d(vectorOut)); vsip_fft_destroy_d(fftplan); vsip_fft_destroy_d(fftplanI); } } vsip_finalize((void*)0);return 0; }