コード例 #1
0
int main(){vsip_init((void*)0);
{
   vsip_cscalar_d alpha = vsip_cmplx_d(alpha_r,alpha_i);
   vsip_cscalar_d beta = vsip_cmplx_d(beta_r,beta_i);
   void VU_cmprint_d(vsip_cmview_d*);
   void VU_cmfill_d(vsip_cmview_d*, vsip_cscalar_d);
   vsip_cmview_d *A = vsip_cmcreate_d(M,N,VSIP_ROW,0),
                 *C = vsip_cmcreate_d(N,M,VSIP_ROW,0);
   int row, col,i;
   for(row=0;row<M;row++) for(col=0;col<N;col++)
        vsip_cmput_d(A,row,col,vsip_cmplx_d(col,-row - sqrt(col*row)));
   
   printf("\n A input \n");
   VU_cmprint_d(A);
   VU_cmfill_d(C,vsip_cmplx_d(0,0));
   printf("\n C input \n");
   VU_cmprint_d(C);
   printf("alpha= %f %+fi, beta= %f %+fi,\n",
               alpha_r,alpha_i,
               beta_r,beta_i);
   {
      vsip_mat_op OpA = VSIP_MAT_HERM;
      printf("OpA %i\n",OpA);
      for(i=0; i<L; i++){
         vsip_cgems_d(alpha,A,OpA,beta,C);
         printf("C number %i\n",i); VU_cmprint_d(C); 
      }
   }
   vsip_cmalldestroy_d(A);
   vsip_cmalldestroy_d(C);
   }vsip_finalize((void*)0);return 0;
}
コード例 #2
0
int main(){vsip_init((void*)0);
{
   vsip_cmview_d *A = vsip_cmcreate_d(M,P,VSIP_ROW,0),
                 *B = vsip_cmcreate_d(P,N,VSIP_ROW,0),
                 *R = vsip_cmcreate_d(M,N,VSIP_ROW,0);
   int i, j;
   for(i=0;i<M;i++) for(j=0;j<P;j++)
        vsip_cmput_d(A,i,j,vsip_cmplx_d(i,1 + sqrt(i*j)));
   
   for(i=0;i<P;i++) for(j=0;j<N;j++)
        vsip_cmput_d(B,i,j,vsip_cmplx_d(1 , i * j));
   
   printf("\n A input \n");
   vsip_cmprodj_d(A,B,R);
   {for(i=0;i<M;i++) {for(j=0;j<P;j++){
           printf("%5.2f + %5.2fi%s ",
             vsip_real_d(vsip_cmget_d(A,i,j)),
             vsip_imag_d(vsip_cmget_d(A,i,j)),
             (j == P-1) ? ";":",");
           }
       printf("\n");
       }
   }
   printf("\n B input \n");
   {for(i=0;i<P;i++) {for(j=0;j<N;j++){
           printf("%5.2f + %5.2fi%s ",
             vsip_real_d(vsip_cmget_d(B,i,j)),
             vsip_imag_d(vsip_cmget_d(B,i,j)),
             (j == N-1) ? ";":",");
           }
       printf("\n");
       }
   }
   printf("\n R output = A * conj(B)\n");
   {for(i=0;i<M;i++) {for(j=0;j<N;j++){
           printf("%5.2f + %5.2fi%s ",
             vsip_real_d(vsip_cmget_d(R,i,j)),
             vsip_imag_d(vsip_cmget_d(R,i,j)),
             (j == N-1) ? ";":",");
           }
       printf("\n");
       }
   }
   vsip_cmalldestroy_d(A);
   vsip_cmalldestroy_d(B);
   vsip_cmalldestroy_d(R);
   }vsip_finalize((void*)0);return 0;
}
コード例 #3
0
int main(){vsip_init((void*)0);
{
   vsip_cmview_d *A = vsip_cmcreate_d(M,P,VSIP_ROW,0),
                 *B = vsip_cmcreate_d(N,P,VSIP_ROW,0),
                 *R = vsip_cmcreate_d(M,N,VSIP_ROW,0);
   int i, j;
   for(i=0;i<M;i++) for(j=0;j<P;j++)
        vsip_cmput_d(A,i,j,vsip_cmplx_d(i,1 + sqrt(i*j)));
   
   for(i=0;i<N;i++) for(j=0;j<P;j++)
        vsip_cmput_d(B,i,j,vsip_cmplx_d(1 , i * j));
   
   printf("\n A input \n");
   vsip_cmprodh_d(A,B,R);
   {for(i=0;i<M;i++) {for(j=0;j<P;j++){
           printf(": (%5.2f, %5.2f) ",
             vsip_real_d(vsip_cmget_d(A,i,j)),
             vsip_imag_d(vsip_cmget_d(A,i,j)));
           }
       printf(":\n");
       }
   }
   printf("\n B input \n");
   {for(i=0;i<N;i++) {for(j=0;j<P;j++){
           printf(": (%5.2f, %5.2f) ",
             vsip_real_d(vsip_cmget_d(B,i,j)),
             vsip_imag_d(vsip_cmget_d(B,i,j)));
           }
       printf(":\n");
       }
   }
   printf("\n R output \n");
   {for(i=0;i<M;i++) {for(j=0;j<N;j++){
           printf(": (%5.2f, %5.2f) ",
             vsip_real_d(vsip_cmget_d(R,i,j)),
             vsip_imag_d(vsip_cmget_d(R,i,j)));
           }
       printf(":\n");
       }
   }
   vsip_cmalldestroy_d(A);
   vsip_cmalldestroy_d(B);
   vsip_cmalldestroy_d(R);
   }vsip_finalize((void*)0);return 0;
}
コード例 #4
0
ファイル: ccfftmx.c プロジェクト: josephdougherty/vsipl_dda
int main()
{
  int i;
  vsip_randstate *state;
  vsip_cmview_d *xy;
  vsip_cvview_d *xy_row;
  vsip_length stride;
  vsip_cvview_d *sum;
  vsip_fftm_d *ccfftmip;
  vsip_length seed =0, num_procs=1, id=1;

  vsip_init((void *)0);
  /* Initialize Random Number Generator */
  state = vsip_randcreate(seed, num_procs, id, VSIP_PRNG);
  /* Row major, 64 (ROWS) of 16 point data vectors */
  xy = vsip_cmcreate_d(ROWS, 16, VSIP_ROW, VSIP_MEM_NONE);
  /* Bind xy_row view initially to row 0 of xy */
  xy_row = vsip_cmrowview_d(xy, 0);
  /* Stride between column elements of xy */
  stride = vsip_cmgetcolstride_d(xy);
  sum = vsip_cvcreate_d(N, VSIP_MEM_NONE);
  /* Create an in-place Cmplx->Cmplx Multiple N-pt FFT */
  ccfftmip = vsip_ccfftmip_create_d(ROWS, N, 1.0, VSIP_FFT_FWD,
				    VSIP_ROW, 1, VSIP_ALG_TIME);
  /* Initialize xy by rows with complex Gaussian noise N(0,1) */
  for (i=0; i<ROWS; i++) 
  {
    vsip_cvputoffset_d(xy_row, i*stride); /* view of row i of xy */
    vsip_cvrand_d(state,xy_row); /* Initialize row i of xy */
  }
  /* Compute an in-place Cmplx->Cmplx Multiple N-pt FFT using the
     ccfftmip object*/
  vsip_ccfftmip_d(ccfftmip, xy);
  /* Coherently sum the rows together (in the Freq domain) */
  vsip_cvputoffset_d(xy_row, 0);
  vsip_cvcopy_d_d(xy_row, sum); /* sum = row 0 of xy */
  for (i=1; i<ROWS; i++)
  {
    vsip_cvputoffset_d(xy_row, i*stride); /* view of row i of xy */
    vsip_cvadd_d(xy_row, sum, sum); /* sum += row i of xy */
  }
  /* Print it */
  printf("\nComplex Output Vector (Real, Imag)\n");
  for(i=0; i<N; i++)
    printf("%d:\t" SCMPLX "\n", i, ACMPLX(vsip_cvget_d(sum,i)));
  printf("\n");
  /* Destroy all the objects */
  vsip_fftm_destroy_d(ccfftmip);
  vsip_cvdestroy(xy_row);
  vsip_cvdestroy(sum);
  vsip_cmalldestroy_d(xy);
  vsip_randdestroy(state);
  vsip_finalize((void *)0);
  return(0);
}
コード例 #5
0
int main() {
    vsip_init((void*)0);
    {
        vsip_cscalar_d alpha = vsip_cmplx_d(alpha_r,alpha_i),
                       beta  = vsip_cmplx_d(beta_r,beta_i);
        void VU_cmprint_d(vsip_cmview_d*);
        void VU_cmfill_d(vsip_cmview_d*, vsip_cscalar_d);
        vsip_cmview_d *A = vsip_cmcreate_d(M,N,VSIP_ROW,0),
                       *B = vsip_cmcreate_d(M,P,VSIP_ROW,0),
                        *C = vsip_cmcreate_d(N,P,VSIP_ROW,0);
        int row, col,i;
        for(row=0; row<M; row++) for(col=0; col<N; col++)
                vsip_cmput_d(A,row,col,vsip_cmplx_d(col,-row));

        for(row=0; row<M; row++) for(col=0; col<P; col++)
                vsip_cmput_d(B,row,col,vsip_cmplx_d(row, 2*col));

        printf("\n A input \n");
        VU_cmprint_d(A);
        printf("\n B input \n");
        VU_cmprint_d(B);
        VU_cmfill_d(C,vsip_cmplx_d(0,0));
        printf("alpha= (%f  %+fi), beta= (%f %+fi),\n",
               vsip_real_d(alpha),vsip_imag_d(alpha),
               vsip_real_d(beta),vsip_imag_d(beta));
        {
            vsip_mat_op OpA = VSIP_MAT_HERM;
            vsip_mat_op OpB = VSIP_MAT_NTRANS;
            printf("OpA %i OpB %i\n",OpA,OpB);
            for(i=0; i<L; i++) {
                vsip_cgemp_d(alpha,A,OpA,B,OpB,beta,C);
                printf("C number %i\n",i);
                VU_cmprint_d(C);
            }
        }
        vsip_cmalldestroy_d(A);
        vsip_cmalldestroy_d(B);
        vsip_cmalldestroy_d(C);
    }
    vsip_finalize((void*)0);
    return 0;
}
コード例 #6
0
ファイル: fftm.c プロジェクト: BackupTheBerlios/openvsipl
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);
}
コード例 #7
0
ファイル: fftm.c プロジェクト: BackupTheBerlios/openvsipl
void
test_real_d(vsip_length N, vsip_major axis)
{
  vsip_length rows = 5;
  vsip_length cols = N;
  vsip_length rows2 = 5;
  vsip_length cols2 = N/2 + 1;
  if (axis == VSIP_COL)
  {
    rows = N;
    cols = 5;
    rows2 = N/2 + 1;
    cols2 = 5;
  }
  vsip_fftm_d *f_fftm = vsip_rcfftmop_create_d(rows, cols, 1.0,
                                               axis, 0, VSIP_ALG_SPACE);
  vsip_fftm_d *i_fftm = vsip_crfftmop_create_d(rows, cols, 1.0/N,
                                               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 == rows2 && attr.output.c == cols2);

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

  vsip_mview_d *in = vsip_mcreate_d(rows, cols, VSIP_ROW, VSIP_MEM_NONE);
  vsip_randstate *rng = vsip_randcreate(0, 1, 1, VSIP_PRNG);
  vsip_mrandu_d(rng, in);
  vsip_randdestroy(rng);
  vsip_mview_d *inv = vsip_mcreate_d(rows, cols, VSIP_ROW, VSIP_MEM_NONE);
  vsip_cmview_d *out = vsip_cmcreate_d(rows2, cols2, VSIP_ROW, VSIP_MEM_NONE);

  vsip_rcfftmop_d(f_fftm, in, out);
  vsip_crfftmop_d(i_fftm, out, inv);
  test_assert(merror_db_d(inv, in) < -100.);
  vsip_malldestroy_d(inv);
  vsip_cmalldestroy_d(out);
  vsip_malldestroy_d(in);
  vsip_fftm_destroy_d(i_fftm);
  vsip_fftm_destroy_d(f_fftm);
}
コード例 #8
0
static vsip_cmview_d* VU_cI_d(vsip_length M)
{
  vsip_cmview_d *I = vsip_cmcreate_d(M,M,VSIP_ROW,VSIP_MEM_NONE);
  if(I != NULL){
      vsip_cvview_d *row = vsip_cmrowview_d(I,0);
      if(row != NULL){
          vsip_cvputlength_d(row,(vsip_length)(M * M));
          vsip_cvfill_d(vsip_cmplx_d(0.0,0.0),row);
          vsip_cvputlength_d(row,M);
          vsip_cvputstride_d(row,(vsip_stride) (M + 1));
          vsip_cvfill_d(vsip_cmplx_d(1.0,0.0),row);
          vsip_cvdestroy_d(row);
      } else {
          vsip_cmdestroy_d(I);
          return (vsip_cmview_d*) NULL;
      }
   } else {
      return (vsip_cmview_d*) NULL;
   }
   return I;
}
コード例 #9
0
int main(int argc, char *argv[]){vsip_init((void*)0);
{  if(argc < 3){
      printf("usage\nqrdex M N FileName\n");
   } else {
   /* matrix size */
   vsip_length M    = (vsip_length)atoi(argv[1]),
               N    = (vsip_length)atoi(argv[2]);
   /* Create some space to hold the matrix */
   vsip_cmview_d *A  = vsip_cmcreate_d(M,N,VSIP_COL,VSIP_MEM_NONE),
                *A0 = vsip_cmcreate_d(M,N,VSIP_COL,VSIP_MEM_NONE);
   /* get data */
   FILE *fptr = fopen(argv[3],"r");
   VU_cmreadf_d(fptr,A);
   fclose(fptr);
   vsip_cmcopy_d_d(A,A0); /* will use A, original data in A0 */
   { /* test prodq for Q1 */
     /* create a QRD object */
     vsip_cqr_d *qrd   = vsip_cqrd_create_d(M,N,VSIP_QRD_SAVEQ);
     /* create a matrix to hold Q */
     vsip_cmview_d *I = VU_cI_d(M);
     vsip_cmview_d *Q = vsip_cmsubview_d(I,0,0,M,M);
     vsip_cmview_d *Qt = vsip_cmtransview_d(Q);
     /* create a matrix to hold R */
     vsip_cmview_d *A1 = vsip_cmcreate_d(M,N,VSIP_ROW,VSIP_MEM_NONE);
     vsip_cmview_d *R1 = vsip_cmsubview_d(A1,0,0,M,N);
     vsip_cmview_d *R  = vsip_cmcreate_d(M,N,VSIP_ROW,VSIP_MEM_NONE);
     /* create a matrix to hold Q Q^h */
     vsip_cmview_d *I1 = vsip_cmcreate_d(M,M,VSIP_ROW,VSIP_MEM_NONE);
     /* create a matrix to hold Q^h Q */
     vsip_cmview_d *I2 = vsip_cmcreate_d(M,M,VSIP_ROW,VSIP_MEM_NONE);
     /* do decomposition */
     vsip_cqrd_d(qrd,A);
     printf("A decomposed = "); VU_cmprintm_d("6.4",A);
     /* find Q */
     vsip_cqrdprodq_d(qrd,VSIP_MAT_NTRANS,VSIP_MAT_RSIDE,I);
     printf("A = "); VU_cmprintm_d("6.4",A0);
     printf("Q = "); VU_cmprintm_d("6.4",Q);
     /* find R */
     vsip_cmcopy_d_d(A0,A1);
     VU_cmconjIP_d(Qt);
     vsip_cmprod_d(Qt,A1,R);
     VU_cmconjIP_d(Qt);
     printf("From mprod R = "); VU_cmprintm_d("6.4",R);
     vsip_cqrdprodq_d(qrd,VSIP_MAT_HERM,VSIP_MAT_LSIDE,A1);
     printf("From qrdprod R = "); VU_cmprintm_d("6.4",R1);

     /* find A from Q and R */
     vsip_cmprod_d(Q,R,A1);
     printf("Q R = ");VU_cmprintm_d("6.4",A1);

     /* find Q^h Q using mprod */
     VU_cmfillz_d(I1); VU_cmfillz_d(I2);
     vsip_cmherm_d(Q,I1);
     vsip_cmprod_d(I1,Q,I2);
     printf("directly using mprod Q^h Q = "); VU_cmprintm_d("6.4",I2);

     /* find Q^h Q using matprod on Rside */
     VU_cmfillz_d(I1);
     vsip_cmherm_d(Q,I1);
     vsip_cqrdprodq_d(qrd,VSIP_MAT_NTRANS,VSIP_MAT_RSIDE,I1);
     printf("using qrdprodq Q^h Q Rside = "); VU_cmprintm_d("6.4",I1);

     /* find Q^h Q using matprod on Lside */
     VU_cmfillz_d(I2);
     vsip_cmcopy_d_d(Q,I2);
     vsip_cqrdprodq_d(qrd,VSIP_MAT_HERM,VSIP_MAT_LSIDE,I2);
     printf("using qrdprodq Q^h Q Lside = "); VU_cmprintm_d("6.4",I2);
    
     /* find Q Q^h using Mprod */
     VU_cmfillz_d(I1); VU_cmfillz_d(I2);
     vsip_cmherm_d(Q,I1);
     vsip_cmprod_d(Q,I1,I2);
     printf("directly using mprod Q Q^h = "); VU_cmprintm_d("6.4",I2);
      
     /* find Q Q^h using matprod on Rside */
     VU_cmfillz_d(I1);
     vsip_cmcopy_d_d(Q,I1);
     vsip_cqrdprodq_d(qrd,VSIP_MAT_HERM,VSIP_MAT_RSIDE,I1);
     printf("using qrdprodq Q Q^h Rside = "); VU_cmprintm_d("6.4",I1);

     /* find Q Q^h using matprod on Lside */
     VU_cmfillz_d(I2);
     vsip_cmherm_d(Q,I2);
     vsip_cqrdprodq_d(qrd,VSIP_MAT_NTRANS,VSIP_MAT_LSIDE,I2);
     printf("using qrdprodq Q Q^h Lside = "); VU_cmprintm_d("6.4",I2);
    }
  }
  }vsip_finalize((void*)0);return 0;
}
コード例 #10
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;
}
コード例 #11
0
int main(){vsip_init((void*)0);
{
    vsip_cmview_d *Adummy  = vsip_cmcreate_d(5*NN,5*NN,VSIP_COL,0);
    vsip_cmview_d *A = vsip_cmsubview_d(Adummy,3,2,NN,NN);
/*    vsip_cmview_d *A= vsip_cmcreate_d(NN,NN,VSIP_COL,0); */
    vsip_cvview_d *x0 = vsip_cvcreate_d(NN,0);
    vsip_vview_d *x0_r = vsip_vrealview_d(x0);
    vsip_vview_d *x0_i = vsip_vimagview_d(x0);
    vsip_cmview_d *X  = vsip_cmcreate_d(NN,3,VSIP_ROW,0);
    vsip_cmview_d *XT  = vsip_cmcreate_d(NN,3,VSIP_COL,0);
    vsip_cmputrowstride_d(A,2*vsip_cmgetrowstride_d(A));
    vsip_cmputcolstride_d(A,3*vsip_cmgetcolstride_d(A)); 

    /* matrix data */
    vsip_cmput_d(A,0,0,vsip_cmplx_d(0.5,0.1)); vsip_cmput_d(A,0,1,vsip_cmplx_d(7,0.1)); 
    vsip_cmput_d(A,0,2,vsip_cmplx_d(10,0.1)); vsip_cmput_d(A,0,3,vsip_cmplx_d(12,0.1));
    vsip_cmput_d(A,0,4,vsip_cmplx_d(-3,0.1)); vsip_cmput_d(A,0,5,vsip_cmplx_d(0,0.1)); vsip_cmput_d(A,0,6,vsip_cmplx_d(.05,0.1));

    vsip_cmput_d(A,1,0,vsip_cmplx_d(2,0.1)); vsip_cmput_d(A,1,1,vsip_cmplx_d(13,0.1)); 
    vsip_cmput_d(A,1,2,vsip_cmplx_d(18,0.1)); vsip_cmput_d(A,1,3,vsip_cmplx_d(6,0.1));
    vsip_cmput_d(A,1,4,vsip_cmplx_d(0,0.1)); vsip_cmput_d(A,1,5,vsip_cmplx_d(130,0.1)); vsip_cmput_d(A,1,6,vsip_cmplx_d(8,0.1));

    vsip_cmput_d(A,2,0,vsip_cmplx_d(3,0.1)); vsip_cmput_d(A,2,1,vsip_cmplx_d(-9,0.1)); 
    vsip_cmput_d(A,2,2,vsip_cmplx_d(2,0.1)); vsip_cmput_d(A,2,3,vsip_cmplx_d(3,0.2));
    vsip_cmput_d(A,2,4,vsip_cmplx_d(2,0.2)); vsip_cmput_d(A,2,5,vsip_cmplx_d(-9,0.2)); vsip_cmput_d(A,2,6,vsip_cmplx_d(6,0.2));

    vsip_cmput_d(A,3,0,vsip_cmplx_d(4,0.2)); vsip_cmput_d(A,3,1,vsip_cmplx_d(2,0.2)); 
    vsip_cmput_d(A,3,2,vsip_cmplx_d(2,0.2)); vsip_cmput_d(A,3,3,vsip_cmplx_d(4,0.2));
    vsip_cmput_d(A,3,4,vsip_cmplx_d(1,0.2)); vsip_cmput_d(A,3,5,vsip_cmplx_d(2,0.2)); vsip_cmput_d(A,3,6,vsip_cmplx_d(3,0.2));

    vsip_cmput_d(A,4,0,vsip_cmplx_d(.2,0.3)); vsip_cmput_d(A,4,1,vsip_cmplx_d(2,0.3)); 
    vsip_cmput_d(A,4,2,vsip_cmplx_d(9,0.3)); vsip_cmput_d(A,4,3,vsip_cmplx_d(4,0.3));
    vsip_cmput_d(A,4,4,vsip_cmplx_d(1,0.3)); vsip_cmput_d(A,4,5,vsip_cmplx_d(2,0.3)); 
    vsip_cmput_d(A,4,6,vsip_cmplx_d(3,0.3));

    vsip_cmput_d(A,5,0,vsip_cmplx_d(.1,0.4)); vsip_cmput_d(A,5,1,vsip_cmplx_d(2,0.4)); 
    vsip_cmput_d(A,5,2,vsip_cmplx_d(.3,0.4)); vsip_cmput_d(A,5,3,vsip_cmplx_d(4,0.4));
    vsip_cmput_d(A,5,4,vsip_cmplx_d(1,0.4)); vsip_cmput_d(A,5,5,vsip_cmplx_d(2,0.4)); vsip_cmput_d(A,5,6,vsip_cmplx_d(3,0.4));

    vsip_cmput_d(A,6,0,vsip_cmplx_d(.01,0.4)); vsip_cmput_d(A,6,1,vsip_cmplx_d(.2,0.4)); 
    vsip_cmput_d(A,6,2,vsip_cmplx_d(3,0.4)); vsip_cmput_d(A,6,3,vsip_cmplx_d(4,0.4));
    vsip_cmput_d(A,6,4,vsip_cmplx_d(1,0.4)); vsip_cmput_d(A,6,5,vsip_cmplx_d(2,0.4)); vsip_cmput_d(A,6,6,vsip_cmplx_d(3,0.4));

    { /* were solving for NTRANS Ax = B */
      /* use a known X, calculate B using Ax */
      int k; 
      vsip_cvview_d *x;
      vsip_cmview_d *AT = vsip_cmcreate_d(NN,NN,VSIP_ROW,VSIP_MEM_NONE);
      vsip_length L     = vsip_cmgetrowlength_d(X);
      vsip_cmherm_d(A,AT);
      printf("A = "); VU_cmprintm_d("7.4",A);
      printf("AT = "); VU_cmprintm_d("7.4",AT);
      vsip_vramp_d(1,1,x0_r);
      vsip_vramp_d(1,-1,x0_i);
      for(k=0; k<L; k++){
        x  = vsip_cmcolview_d(X,k);
        vsip_cmvprod_d(A,x0,x);
        vsip_rscvmul_d(2.0,x0,x0);
        vsip_cvdestroy_d(x);
      }
      vsip_vramp_d(1,1,x0_r);
      vsip_vramp_d(1,-1,x0_i);
      for(k=0; k<L; k++){
        x  = vsip_cmcolview_d(XT,k);
        vsip_cmvprod_d(AT,x0,x);
        VU_cvprintm_d("7.4",x0);
        vsip_rscvmul_d(2.0,x0,x0);
        vsip_cvdestroy_d(x);
      }
      vsip_cmalldestroy_d(AT);
      printf("B = "); VU_cmprintm_d("7.4",X);
      printf("BT = "); VU_cmprintm_d("7.4",XT);
      {
        /* then solve to see if we get X back */
        vsip_clu_d* luAop = vsip_clud_create_d(NN);
        if(luAop == NULL) exit(1);
        vsip_clud_d(luAop,A);
        {  vsip_clu_attr_d attr;
           vsip_clud_getattr_d(luAop,&attr);
           printf("lud size %lu\n",attr.n);
        }  
        vsip_clusol_d(luAop,VSIP_MAT_NTRANS,X);
        vsip_clusol_d(luAop,VSIP_MAT_HERM,XT);
        vsip_clud_destroy_d(luAop);
      }
    }
    printf("A\\X = "); VU_cmprintm_d("9.6",X);
    printf("A'\\X = "); VU_cmprintm_d("9.6",XT);
    {
       vsip_vdestroy_d(x0_r);vsip_vdestroy_d(x0_i);
       vsip_cvalldestroy_d(x0);
       vsip_cmalldestroy_d(X);
       vsip_cmalldestroy_d(A);
    }
    }vsip_finalize((void*)0);return 1;
}