int main(){vsip_init((void*)0); { void VU_mprint_d(vsip_mview_d*); void VU_mfill_d(vsip_mview_d*, vsip_scalar_d); void VU_vprint_d(vsip_vview_d*); vsip_mview_d *A = vsip_mcreate_d(M,N,VSIP_ROW,0); vsip_mview_d *ATA = vsip_mcreate_d(N,N,VSIP_ROW,0); vsip_vview_d *b = vsip_vcreate_d(M,0); vsip_mview_d *ATB = vsip_mcreate_d(N,1,VSIP_COL,0); vsip_vview_d *ATb = vsip_mcolview_d(ATB,0); { /* store data */ vsip_mput_d(A,0,0,1); vsip_mput_d(A,0,1,2); vsip_mput_d(A,0,2,1); vsip_mput_d(A,1,0,3); vsip_mput_d(A,1,1,-1); vsip_mput_d(A,1,2,0); vsip_mput_d(A,2,0,2); vsip_mput_d(A,2,1,1); vsip_mput_d(A,2,2,-1); vsip_mput_d(A,3,0,1); vsip_mput_d(A,3,1,2); vsip_mput_d(A,3,2,2); vsip_vput_d(b,0,1); vsip_vput_d(b,1,2); vsip_vput_d(b,2,2); vsip_vput_d(b,3,1); } printf("b = \n");VU_vprint_d(b); printf("A = \n");VU_mprint_d(A); VU_mfill_d(ATA,0); vsip_gemp_d(1,A,VSIP_MAT_TRANS,A,VSIP_MAT_NTRANS,1,ATA); printf("ATA = \n");VU_mprint_d(ATA); vsip_vmprod_d(b,A,ATb); printf("ATb = \n"); VU_vprint_d(ATb); { vsip_lu_d* luAop = vsip_lud_create_d(N); vsip_lud_d(luAop,ATA); vsip_lusol_d(luAop,VSIP_MAT_NTRANS,ATB); printf("solve ATA x = ATb\n"); printf("x = \n"); VU_mprint_d(ATB); vsip_lud_destroy_d(luAop); } vsip_valldestroy_d(b); vsip_vdestroy_d(ATb); vsip_mdestroy_d(A); vsip_mdestroy_d(ATA); vsip_mdestroy_d(ATB); }vsip_finalize((void*)0);return 0; }
vsip_mview_d* VU_I_d(vsip_length M) { vsip_mview_d *I = vsip_mcreate_d(M,M,VSIP_ROW,VSIP_MEM_NONE); if(I != NULL){ vsip_vview_d *row = vsip_mrowview_d(I,0); if(row != NULL){ vsip_vputlength_d(row,(vsip_length)(M * M)); vsip_vfill_d((vsip_scalar_d)0.0,row); vsip_vputlength_d(row,M); vsip_vputstride_d(row,(vsip_stride) (M + 1)); vsip_vfill_d((vsip_scalar_d)1.0,row); vsip_vdestroy_d(row); } else { vsip_mdestroy_d(I); return (vsip_mview_d*) NULL; } } else { return (vsip_mview_d*) NULL; } return I; }
int main(){vsip_init((void*)0); { void VU_cmprint_d(vsip_cmview_d*); /* int i;*/ vsip_cmview_d *w = vsip_cmcreate_d(5,L+1,VSIP_ROW,0); vsip_cmview_d *W = vsip_cmcreate_d(5,L+1,VSIP_ROW,0); vsip_cmview_d *IW = vsip_cmcreate_d(5,L+1,VSIP_ROW,0); vsip_vview_d *blackman = vsip_vcreate_blackman_d(L,0), *hanning = vsip_vcreate_hanning_d(L,0), *kaiser = vsip_vcreate_kaiser_d(L,beta,0), *cheby = vsip_vcreate_cheby_d(L,ripple,0); vsip_fftm_d *fft = vsip_ccfftmop_create_d(4,L,1,VSIP_FFT_FWD,VSIP_ROW,0,0); vsip_fftm_d *ifft = vsip_ccfftmop_create_d(4, L, 1.0/L, VSIP_FFT_INV, VSIP_ROW,0,0); /*printf(" blackman "); printf(" hanning kaiser chebyshev\n"); for(i=0; i < L; i++) printf("%11.8f; %11.8f; %11.8f; %11.8f\n", vsip_vget_d(blackman,i), vsip_vget_d(hanning,i), vsip_vget_d(kaiser,i), vsip_vget_d(cheby,i)); */ vsip_cmputcollength_d(w,4); vsip_cmputcollength_d(W,4); vsip_cmputcollength_d(IW,4); vsip_cmputrowlength_d(w,L); vsip_cmputrowlength_d(W,L); vsip_cmputrowlength_d(IW,L); { vsip_mview_d *wR = vsip_mrealview_d(w); vsip_mview_d *wI = vsip_mimagview_d(w); vsip_vview_d *v = vsip_mrowview_d(wR,0); vsip_vview_d *vi = vsip_mrowview_d(wI,0); vsip_offset o = (vsip_offset)vsip_mgetcolstride_d(wR); vsip_offset oi = (vsip_offset)vsip_mgetcolstride_d(wI); vsip_vcopy_d_d(blackman,v); vsip_vfill_d(0,vi); vsip_vputoffset_d(v,vsip_vgetoffset_d(v) + o); vsip_vputoffset_d(vi,vsip_vgetoffset_d(vi) + oi); vsip_vcopy_d_d(hanning,v); vsip_vfill_d(0,vi); vsip_vputoffset_d(v,vsip_vgetoffset_d(v) + o); vsip_vputoffset_d(vi,vsip_vgetoffset_d(vi) + oi); vsip_vcopy_d_d(kaiser,v); vsip_vfill_d(0,vi); vsip_vputoffset_d(v,vsip_vgetoffset_d(v) + o); vsip_vputoffset_d(vi,vsip_vgetoffset_d(vi) + oi); vsip_vcopy_d_d(cheby,v); vsip_vfill_d(0,vi); vsip_mdestroy_d(wR); vsip_vdestroy_d(v); vsip_mdestroy_d(wI); vsip_vdestroy_d(vi); } vsip_ccfftmop_d(fft,w,W); vsip_ccfftmop_d(ifft,W,IW); printf(" w = ");VU_cmprint_d(w); printf(" W = ");VU_cmprint_d(W); printf("IW = ");VU_cmprint_d(IW); {/* test vsip_fftm_getattr_d */ vsip_fftm_attr_d attr; vsip_fftm_getattr_d(fft, &attr); printf("%lu %lu %lu %lu %d %f %d %d\n", vsip_rowindex(attr.input), vsip_colindex(attr.input), vsip_rowindex(attr.output), vsip_colindex(attr.output), attr.place,attr.scale,attr.dir,attr.major); vsip_fftm_getattr_d(ifft, &attr); printf("%lu %lu %lu %lu %d %f %d %d\n", vsip_rowindex(attr.input), vsip_colindex(attr.input), vsip_rowindex(attr.output), vsip_colindex(attr.output), attr.place,attr.scale,attr.dir,attr.major); } vsip_fftm_destroy_d(fft); vsip_fftm_destroy_d(ifft); vsip_valldestroy_d(blackman); vsip_valldestroy_d(hanning); vsip_valldestroy_d(kaiser); vsip_valldestroy_d(cheby); vsip_cmalldestroy_d(w); vsip_cmalldestroy_d(W); vsip_cmalldestroy_d(IW); }vsip_finalize((void*)0);return 0; }
void (vsip_malldestroy_d)( vsip_mview_d* M) { /* matrix view destructor */ vsip_blockdestroy_d(vsip_mdestroy_d(M)); return; }