Пример #1
0
void
test_complex_d(vsip_length N, vsip_major axis)
{
  vsip_length rows = 5;
  vsip_length cols = N;
  if (axis == VSIP_COL)
  {
    rows = N;
    cols = 5;
  }
  vsip_fftm_d *f_fftm = vsip_ccfftmop_create_d(rows, cols, 1.0,
                                               VSIP_FFT_FWD, axis, 0, VSIP_ALG_SPACE);
  vsip_fftm_d *i_fftm = vsip_ccfftmop_create_d(rows, cols, 1.0/N,
                                               VSIP_FFT_INV, axis, 0, VSIP_ALG_SPACE);

  vsip_fftm_attr_d attr;
  vsip_fftm_getattr_d(f_fftm, &attr);
  test_assert(attr.input.r == rows && attr.input.c == cols);
  test_assert(attr.output.r == rows && attr.output.c == cols);
  vsip_fftm_getattr_d(i_fftm, &attr);
  test_assert(attr.input.r == rows && attr.input.c == cols);
  test_assert(attr.output.r == rows && attr.output.c == cols);

  vsip_cmview_d *in = vsip_cmcreate_d(rows, cols, VSIP_ROW, VSIP_MEM_NONE);
  vsip_randstate *rng = vsip_randcreate(0, 1, 1, VSIP_PRNG);
  vsip_cmrandu_d(rng, in);
  vsip_randdestroy(rng);
  vsip_cmview_d *out = vsip_cmcreate_d(rows, cols, VSIP_ROW, VSIP_MEM_NONE);
  vsip_cmview_d *inv = vsip_cmcreate_d(rows, cols, VSIP_ROW, VSIP_MEM_NONE);
  vsip_ccfftmop_d(f_fftm, in, out);
  vsip_ccfftmop_d(i_fftm, out, inv);
  test_assert(cmequal_d(inv, in));
  vsip_cmalldestroy_d(inv);
  vsip_cmalldestroy_d(out);
  vsip_cmalldestroy_d(in);
  vsip_fftm_destroy_d(i_fftm);
  vsip_fftm_destroy_d(f_fftm);
}
Пример #2
0
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;
}