예제 #1
0
int main(){vsip_init((void*)0);
{
     void VU_vfprintyg_d(char*,vsip_vview_d*,char*);
     void VU_vfreqswapIP_d(vsip_vview_d*);
     vsip_vview_d* Cw = vsip_vcreate_cheby_d(Nlength,ripple,0);
     vsip_fft_d *fft  = vsip_ccfftip_create_d(Nlength,1.0,VSIP_FFT_FWD,0,0);
     vsip_cvview_d* FCW = vsip_cvcreate_d(Nlength,0);
     /*printf("CW = "); VU_vprintm_d("%6.8f ;\n",Cw); */
     VU_vfprintyg_d("%6.8f\n",Cw,"Cheby_Window");
     vsip_cvfill_d(vsip_cmplx_d(0,0),FCW);
     { vsip_vview_d *rv = vsip_vrealview_d(FCW);
       vsip_vcopy_d_d(Cw,rv);
       vsip_ccfftip_d(fft,FCW);
       vsip_vcmagsq_d(FCW,rv);
       { vsip_index ind;
         vsip_scalar_d max = vsip_vmaxval_d(rv,&ind);
         vsip_scalar_d min = max/(10e12);
         vsip_vclip_d(rv,min,max,min,max,rv);
       } 
       vsip_vlog10_d(rv,rv);
       vsip_svmul_d(10,rv,rv);
       VU_vfreqswapIP_d(rv);
         VU_vfprintyg_d("%6.8f\n",rv,"Cheby_Window_Frequency_Response");
       vsip_vdestroy_d(rv);
     }
     vsip_fft_destroy_d(fft);
     vsip_valldestroy_d(Cw);
     vsip_cvalldestroy_d(FCW);
     } vsip_finalize((void*)0); return 0;
}
예제 #2
0
int main(int argc, char *argv[]){vsip_init((void*)0);
{  if(argc < 3){
      printf("usage\nqrdex M N FileName\n");
      exit(1);
   }
   {
     int VU_qrd_f(vsip_mview_f*,vsip_mview_f*);
     vsip_length M = (vsip_length)atoi(argv[1]),
                 N = (vsip_length)atoi(argv[2]);
     vsip_mview_f *A = vsip_mcreate_f(M,N,VSIP_COL,0),
                  *Q = vsip_mcreate_f(M,N,VSIP_COL,0),
                  *R = vsip_mcreate_f(N,N,VSIP_ROW,0);
     FILE *fptr = fopen(argv[3],"r");
     VU_mreadf_f(fptr,A);
     fclose(fptr);
     vsip_mcopy_f_f(A,Q);
     printf("A =");VU_mprintm_f("9.6",A);
     VU_qrd_f(Q,R);
     printf("Q =");VU_mprintm_f("9.6",Q); 
     printf("R =");VU_mprintm_f("9.6",R);
     vsip_mprod_f(Q,R,A);
     printf("QR =");VU_mprintm_f("9.6",A);
     vsip_malldestroy_f(A);
     vsip_malldestroy_f(Q);
     vsip_malldestroy_f(R);
     } vsip_finalize((void*)0); return 0;
   }
}
예제 #3
0
int main()
{
  double data[N]; /* a user-created data space */
  int i;
  vsip_vview_d* a;
  vsip_vview_d* x;

  vsip_init((void *)0);
  a = vsip_vbind_d(vsip_blockbind_d(data,N, VSIP_MEM_NONE),0,1,N);
  x = vsip_vcreate_d(N, VSIP_MEM_NONE);
  vsip_vramp_d(0.0, 1.0, x);
  /* admit the user block with no update */
  vsip_blockadmit_d(vsip_vgetblock_d(a),VSIP_FALSE);
  /*compute the 10^x value */
  vsip_vexp10_d(x, a);
  /* release the user block with update */
  vsip_blockrelease_d(vsip_vgetblock_d(a),VSIP_TRUE);
  /*print it */
  for(i=0; i<N; i++)
    printf("%f ",data[i]);
  printf("\n");
  /*destroy the vector views and any associated blocks */
  vsip_blockdestroy_d(vsip_vdestroy_d(x));
  vsip_blockdestroy_d(vsip_vdestroy_d(a));
  vsip_finalize((void *)0);
  return 0;
}
예제 #4
0
#include <stdio.h>
#include "vsip.h"
#define L 7                  /* length */
int main()
{
  double data[L];    /*a user-created data space */
  int i;
  vsip_vview_d* ramp;
  vsip_vview_d* output;

  vsip_init((void *)0);
  ramp = vsip_vcreate_d(L, VSIP_MEM_NONE);
  output = vsip_vbind_d(vsip_blockbind_d(data,L, VSIP_MEM_NONE),0,1,L);
  /*compute a ramp from zero to L-1*/
  vsip_vramp_d(0.0, 1.0, ramp);
  /* admit the user block with no update */
  vsip_blockadmit_d(vsip_vgetblock_d(output),VSIP_FALSE);
  /*compute the hyperbolic cosine value */
  vsip_vcosh_d(ramp, output);
  /* release the user block with update */
  vsip_blockrelease_d(vsip_vgetblock_d(output),VSIP_TRUE);
  /*print it */
  for(i=0; i<L; i++)
    printf("%f ",data[i]);
  printf("\n");
  /*destroy the vector views and any associated blocks */
  vsip_blockdestroy_d(vsip_vdestroy_d(ramp));
  vsip_blockdestroy_d(vsip_vdestroy_d(output));
  vsip_finalize((void *)0);
  return 0;
}
예제 #5
0
int main(){vsip_init((void*)0);
{
   FILE *vfptr = fopen("vector.data","r");
   FILE *mfptr = fopen("matrix.data","r");
   vsip_mview_f *B = vsip_mcreate_f(3,5,VSIP_ROW,0);
   vsip_mview_f *R = vsip_mcreate_f(3,5,VSIP_ROW,0);
   vsip_vview_f *a = vsip_vcreate_f(5,0);
   VU_vreadf_f(vfptr,a);
   VU_mreadf_f(mfptr,B);
   fclose(vfptr); fclose(mfptr);
   vsip_vmmul_f(a,B,VSIP_ROW,R);
   printf("a = "); VU_vprintm_f("6.2",a);
   printf("B = "); VU_mprintm_f("6.2",B);
   printf("R = "); VU_mprintm_f("6.2",R);
   { /* test for VSIP_COL */
     vsip_mview_f *BT = vsip_mtransview_f(B);
     vsip_mview_f *RT = vsip_mtransview_f(R);
     vsip_vmmul_f(a,BT,VSIP_COL,RT);
     printf("a = "); VU_vprintm_f("6.2",a);
     printf("BT = "); VU_mprintm_f("6.2",BT);
     printf("RT = "); VU_mprintm_f("6.2",RT);
     vsip_mdestroy_f(BT);
     vsip_mdestroy_f(RT);
   }
   vsip_valldestroy_f(a);
   vsip_malldestroy_f(B);
   vsip_malldestroy_f(R);
   } vsip_finalize((void*)0); return 0;
}
예제 #6
0
/* $Id: example16.c,v 2.0 2003/02/22 15:27:32 judd Exp $ */

#include<vsip.h>
#define L 20 /* A length*/
int main(){vsip_init((void*)0);
{
    vsip_vview_f*   a = vsip_vcreate_f(L,0);
    vsip_vview_f*   b = vsip_vcreate_f(L,0);
    vsip_vview_vi*  ab_vi = vsip_vcreate_vi(L,0);
    vsip_vview_bl*  ab_bl= vsip_vcreate_bl(L,0);
    int i;
    vsip_length N;
    /* make up some data */
    vsip_vramp_f(0,2 * M_PI/(L-1),a);
    vsip_vcos_f(a,b);
    /* find out where b is greater than zero */
    vsip_vfill_f(0,a);
    vsip_vlgt_f(b,a,ab_bl);
    /* find the index where b is greater than zero */
    if((N = vsip_vindexbool(ab_bl,ab_vi))){
        /* make a vector of those points where b is greater than zero*/
        vsip_vgather_f(b,ab_vi,vsip_vputlength_f(a,N));
        /*print out the results */
        printf("Index   Value\n");
        for(i=0; i<N; i++)
           printf("%li      %6.3f\n",
             vsip_vget_vi(ab_vi,i),
             vsip_vget_f(a,i));
     }   
     else{ printf("Zero Length Index");
     }   
     vsip_valldestroy_f(a);
     vsip_valldestroy_f(b);
     vsip_valldestroy_vi(ab_vi);
     vsip_valldestroy_bl(ab_bl);
     } vsip_finalize((void*)0); return 0;
}
예제 #7
0
int main (int argc, const char * argv[]) 
{
  int retval = vsip_init((void*)0);
  vsip_length N0 = 11;
  vsip_spline_f *spl = vsip_spline_create_f(N0);
  vsip_length N = 201;
  vsip_vview_f *yf = vsip_vcreate_f(N,VSIP_MEM_NONE);
  vsip_vview_f *xf = vsip_vcreate_f(N,VSIP_MEM_NONE);
  vsip_vview_f *xp = vsip_vcreate_f(N0,VSIP_MEM_NONE);
  vsip_vview_f *yp = vsip_vcreate_f(N0,VSIP_MEM_NONE);
  vsip_vramp_f(0.0,1.0,xp);
  vsip_vramp_f(0.0,0.05,xf);
  vsip_svmul_f(2.0/5.0 * M_PI,xp,yp);
  vsip_vsin_f(yp,yp);
  printf("xp = ");VPRINT(xp);
  printf("yp = ");VPRINT(yp);
  printf("xf = ");VPRINT(xf);
  vsip_vinterp_spline_f(xp,yp,spl,xf,yf);
  printf("spline = ");VPRINT(yf);
  vsip_spline_destroy_f(spl);
  vsip_valldestroy_f(xf);
  vsip_valldestroy_f(xp);
  vsip_valldestroy_f(yp);
  vsip_valldestroy_f(yf);
  vsip_finalize((void*)0);
  return retval;
}
예제 #8
0
파일: ssdiv.c 프로젝트: ssacco/specs
int main()
{
    int i;
    /* define some data space */
    vsip_cvview_d* dataComplex;
    vsip_cvview_d* dataComplexQuotient;

    vsip_init((void *)0);
    dataComplex = vsip_cvcreate_d(L, VSIP_MEM_NONE);
    dataComplexQuotient = vsip_cvcreate_d(L, VSIP_MEM_NONE);
    /* put some complex data in dataComplex */
    for(i = 0; i < L; i++)
        vsip_cvput_d(dataComplex,i,
                     vsip_cmplx_d((double)(i * i),(double)(i+1)));
    /*divide dataComplex by some denom and print the input and output */
    vsip_cvrsdiv_d(dataComplex,denom,dataComplexQuotient);
    for(i=0; i<L; i++)
        printf("(%7.4f + %7.4fi) / %7.4f) = (%7.4f + %7.4fi)\n",
               vsip_real_d(vsip_cvget_d(dataComplex,i)),
               vsip_imag_d(vsip_cvget_d(dataComplex,i)),
               denom,
               vsip_real_d(vsip_cvget_d(dataComplexQuotient,i)),
               vsip_imag_d(vsip_cvget_d(dataComplexQuotient,i)));
    vsip_cblockdestroy_d(vsip_cvdestroy_d(dataComplex));
    vsip_cblockdestroy_d(vsip_cvdestroy_d(dataComplexQuotient));
    vsip_finalize((void *)0);
    return 0;
}
예제 #9
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;
}
예제 #10
0
int main()
{
  int i;
  vsip_cvview_d* dataEuler;
  vsip_vview_d* data;

  vsip_init((void *)0);
  dataEuler = vsip_cvcreate_d(L, VSIP_MEM_NONE);
  data = vsip_vcreate_d(L, VSIP_MEM_NONE);
  /* Make up some data */
  /* Compute a ramp from zero to 2pi */
  vsip_vramp_d(0.0, (2.0 * PI / (double) (L - 1)), data);
  /* Compute Euler */
  vsip_veuler_d(data,dataEuler);
  /* Now print out data and dataEuler */
  for(i=0; i < L; i++)
  {
    printf(" %7.4f => (%7.4f, %7.4f)\n",vsip_vget_d(data,i),
    vsip_real_d(vsip_cvget_d(dataEuler,i)),
    vsip_imag_d(vsip_cvget_d(dataEuler,i)));
  }
  /* Destroy the vector views and any associated blocks */
  vsip_blockdestroy_d(vsip_vdestroy_d(data));
  vsip_cblockdestroy_d(vsip_cvdestroy_d(dataEuler));
  vsip_finalize((void *)0);
  return 0;
}
예제 #11
0
int main(){vsip_init((void*)0);
{
   vsip_cscalar_f alpha = vsip_cmplx_f(alpha_r,alpha_i);
   vsip_cscalar_f beta = vsip_cmplx_f(beta_r,beta_i);
   void VU_cmprint_f(vsip_cmview_f*);
   void VU_cmfill_f(vsip_cmview_f*, vsip_cscalar_f);
   vsip_cmview_f *A = vsip_cmcreate_f(N,M,VSIP_ROW,0),
                 *C = vsip_cmcreate_f(N,M,VSIP_ROW,0);
   int row, col,i;
   for(row=0;row<N;row++) for(col=0;col<M;col++)
        vsip_cmput_f(A,row,col,vsip_cmplx_f(row,-col - sqrt(col*row)));
   
   printf("\n A input \n");
   VU_cmprint_f(A);
   VU_cmfill_f(C,vsip_cmplx_f(0,0));
   printf("\n C input \n");
   VU_cmprint_f(C);
   printf("alpha= %f %+fi, beta= %f %+fi,\n",
               alpha_r,alpha_i,
               beta_r,beta_i);
   {
      vsip_mat_op OpA = VSIP_MAT_CONJ;
      printf("OpA %i\n",OpA);
      for(i=0; i<L; i++){
         vsip_cgems_f(alpha,A,OpA,beta,C);
         printf("C number %i\n",i); VU_cmprint_f(C); 
      }
   }
   vsip_cmalldestroy_f(A);
   vsip_cmalldestroy_f(C);
   } vsip_finalize((void*)0); return 0;
}
예제 #12
0
int main()
{
  int i;
  vsip_scalar_d dataLeft;
  vsip_vview_d* dataRight;
  vsip_vview_d* dataSum;
  vsip_init((void *)0);
  dataRight = vsip_vcreate_d(L, VSIP_MEM_NONE);
  dataSum = vsip_vcreate_d(L, VSIP_MEM_NONE);
  /* Make up some data to find the magnitude of */
  /* First set the scalar equal to 1*/
  dataLeft = 1.0;
  /* Then compute a ramp from one to minus one */
  vsip_vramp_d(1.0, -2.0/(double)(L-1), dataRight);
  /* Add the scalar and the vector */
  vsip_svadd_d(dataLeft, dataRight, dataSum);
  /* now print out the data and its sum */
  for(i=0; i < L; i++)
    printf("%7.4f = (%7.4f) + (%7.4f) \n", vsip_vget_d(dataSum,i),
           dataLeft, vsip_vget_d(dataRight,i));
  /* destroy the vector views and any associated blocks */
  vsip_blockdestroy_d(vsip_vdestroy_d(dataRight));
  vsip_blockdestroy_d(vsip_vdestroy_d(dataSum));
  vsip_finalize((void *)0);
  return 0;
}
예제 #13
0
int main(){vsip_init((void*)0);
{
   void VU_mprint_f(vsip_mview_f*);
   void VU_mfill_f(vsip_mview_f*, vsip_scalar_f);
   vsip_mview_f *A = vsip_mcreate_f(M,N,VSIP_ROW,0),
                *B = vsip_mcreate_f(M,P,VSIP_ROW,0),
                *C = vsip_mcreate_f(N,P,VSIP_ROW,0);
   int row, col,i;
   for(row=0;row<M;row++) for(col=0;col<N;col++)
        vsip_mput_f(A,row,col,1 + sqrt(col*row));
   
   for(row=0;row<M;row++) for(col=0;col<P;col++)
        vsip_mput_f(B,row,col,1 + row * col);
   
   printf("\n A input \n");
   VU_mprint_f(A);
   printf("\n B input \n");
   VU_mprint_f(B);
   VU_mfill_f(C,0);
   printf("alpha= %f, beta= %f,\n",alpha,beta);
   {
      vsip_mat_op OpA = VSIP_MAT_TRANS;
      vsip_mat_op OpB = VSIP_MAT_NTRANS;
      printf("OpA %i; OpB %i\n",OpA,OpB);
      for(i=0; i<L; i++){
         vsip_gemp_f(alpha,A,OpA,B,OpB,beta,C);
         printf("C number %i\n",i); VU_mprint_f(C); 
      }
   }
   vsip_malldestroy_f(A);
   vsip_malldestroy_f(B);
   vsip_malldestroy_f(C);
   } vsip_finalize((void*)0); return 0;
}
예제 #14
0
int main(){vsip_init((void*)0);
{
   vsip_vview_d *a = vsip_vcreate_d(N,0),
                *r = vsip_vcreate_d(P,0);
   vsip_mview_d *B = vsip_mcreate_d(P,N,VSIP_ROW,0);
   int i, j;
   vsip_vramp_d(1.0,1.0,a);
   for(i=0;i<P;i++) for(j=0;j<N;j++)
        vsip_mput_d(B,i,j,1 + i * j);
   
   printf("\n  vector input \n");
   vsip_mvprod_d(B,a,r);
   for(j=0;j<N;j++){
        printf(" %6.2f  ",vsip_vget_d(a,j));
   }
   printf("\n");
   printf("\n matrix input \n");
   {for(i=0; i<P; i++) {for(j=0;j<N;j++){
           printf(" %6.2f  ",vsip_mget_d(B,i,j));
           }
       printf(";\n");
       }
   }
   printf("\n vector output \n");
   for(j=0;j<P;j++){
           printf("%6.2f ",vsip_vget_d(r,j));
   }
   printf("\n");
   vsip_valldestroy_d(a);
   vsip_valldestroy_d(r);
   vsip_malldestroy_d(B);
   }vsip_finalize((void*)0);return 0;
}
예제 #15
0
int main(){vsip_init((void*)0);
{
   vsip_cmview_f *A   = vsip_cmcreate_f(M,M,VSIP_ROW,0);
   vsip_cmview_f *ATA = vsip_cmcreate_f(M,M,VSIP_ROW,0);
   vsip_cmview_f *ATB = vsip_cmcreate_f(M,1,VSIP_COL,0);
   { /* store data ; upper trianglar so answers are obvious */
     vsip_cmput_f(A,0,0,vsip_cmplx_f(1,0)); vsip_cmput_f(A,0,1,vsip_cmplx_f(2,1)); 
          vsip_cmput_f(A,0,2,vsip_cmplx_f(1,2));vsip_cmput_f(A,0,3,vsip_cmplx_f(1,3));
     vsip_cmput_f(A,1,0,vsip_cmplx_f(0,0)); vsip_cmput_f(A,1,1,vsip_cmplx_f(3,0)); 
          vsip_cmput_f(A,1,2,vsip_cmplx_f(0,0));vsip_cmput_f(A,1,3,vsip_cmplx_f(0,1));
     vsip_cmput_f(A,2,0,vsip_cmplx_f(0,0)); vsip_cmput_f(A,2,1,vsip_cmplx_f(0,0)); 
          vsip_cmput_f(A,2,2,vsip_cmplx_f(2,0));vsip_cmput_f(A,2,3,vsip_cmplx_f(3,1));
     vsip_cmput_f(A,3,0,vsip_cmplx_f(0,0)); vsip_cmput_f(A,3,1,vsip_cmplx_f(0,0)); 
          vsip_cmput_f(A,3,2,vsip_cmplx_f(0,0));vsip_cmput_f(A,3,3,vsip_cmplx_f(1,0));
  
     vsip_cmput_f(ATB,0,0,vsip_cmplx_f(1,0)); vsip_cmput_f(ATB,1,0,vsip_cmplx_f(2,1)); 
          vsip_cmput_f(ATB,2,0,vsip_cmplx_f(1,0)); vsip_cmput_f(ATB,3,0,vsip_cmplx_f(3,1));
   }
   printf("b = ");VU_cmprintm_f("6.4",ATB); 
   printf("use upper triangular so Q is I and R is A\n");
   printf("A = ");VU_cmprintm_f("6.4",A); 
   vsip_cmcopy_f_f(A,ATA);
   { /* solve using LUD */
      vsip_clu_f* luAop = vsip_clud_create_f(M);
      vsip_clud_f(luAop,ATA);
      vsip_clusol_f(luAop,VSIP_MAT_HERM,ATB);
      printf("solve A x = b\n");
      printf("x from LUD = "); VU_cmprintm_f("6.4",ATB); 
      vsip_clud_destroy_f(luAop);
   } 
   vsip_cmcopy_f_f(A,ATA);
   { /* solve using qrdsolr */
     vsip_cqr_f *qrd;
     vsip_cmview_f *B = vsip_cmcreate_f(4,1,VSIP_COL,0);
     qrd = vsip_cqrd_create_f(4,4,VSIP_QRD_NOSAVEQ);
     vsip_cqrd_f(qrd,ATA);
     vsip_cmput_f(B,0,0,vsip_cmplx_f(1,0)); vsip_cmput_f(B,1,0,vsip_cmplx_f(2,1)); 
          vsip_cmput_f(B,2,0,vsip_cmplx_f(1,0)); vsip_cmput_f(B,3,0,vsip_cmplx_f(3,1));
     vsip_cqrdsolr_f(qrd,VSIP_MAT_HERM,vsip_cmplx_f(1,0),B);
     printf("X from qrdsolr NOSAVEQ =");VU_cmprintm_f("6.4",B); 
     vsip_cqrd_destroy_f(qrd);
    }
   vsip_cmcopy_f_f(A,ATA);
   { /* solve using qrdsolr */
     vsip_cqr_f *qrd;
     vsip_cmview_f *B = vsip_cmcreate_f(4,1,VSIP_COL,0);
     qrd = vsip_cqrd_create_f(4,4,VSIP_QRD_SAVEQ);
     vsip_cqrd_f(qrd,ATA);
     vsip_cmput_f(B,0,0,vsip_cmplx_f(1,0)); vsip_cmput_f(B,1,0,vsip_cmplx_f(2,1)); 
          vsip_cmput_f(B,2,0,vsip_cmplx_f(1,0)); vsip_cmput_f(B,3,0,vsip_cmplx_f(3,1));
     vsip_cqrdsolr_f(qrd,VSIP_MAT_HERM,vsip_cmplx_f(1,0),B);
     printf("X from qrdsolr SAVEQ1 =");VU_cmprintm_f("6.4",B); 
     vsip_cqrd_destroy_f(qrd);
    }
   vsip_cmdestroy_f(A);
   vsip_cmdestroy_f(ATA);
   vsip_cmdestroy_f(ATB);
   } vsip_finalize((void*)0); return 0;
}
예제 #16
0
int main(){vsip_init((void*)0);
{
   FILE *fptr = fopen("tm.data","r");
   vsip_mview_d *M = vsip_mcreate_d(2,3,VSIP_ROW,0);
   VU_mreadf_d(fptr,M);
   VU_mprintm_d("6.4",M);
   }vsip_finalize((void*)0);return 0;
}
예제 #17
0
int
main(int argc, char** argv)
{
  vsip_init(0);
  corr_cover_d();
  ccorr_cover_d();
  return 0;
}
예제 #18
0
int main(){
   vsip_init((void*)0);
   chol_f();
   cchol_f();
   chol_d();
   cchol_d();
   vsip_finalize((void*)0);
   return 0;
}
예제 #19
0
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);
}
예제 #20
0
int main()
{
  vsip_vview_d* data;
  vsip_init((void *)0);
  data = vsip_vcreate_d(L, VSIP_MEM_NONE);
  /* Make up some data to find the sum of squares of */
  vsip_vramp_d(0.0, 1.0, data);
  printf("%f \n", vsip_vsumsqval_d(data));
  vsip_blockdestroy_d(vsip_vdestroy_d(data));
  vsip_finalize((void *)0);
  return 0;
} /* output */
예제 #21
0
int main(int argc, char *argv[]) {
    vsip_init((void*)0);
{   if(argc < 4) {
            printf("usage\nfirEx length decimation filterFile <indataFile >outputFile\n");
            exit(0);
        }
        {
            vsip_length N = (vsip_length)atoi(argv[1]);
            int D = atoi(argv[2]);
            vsip_scalar_vi n = 0,k = 0;
            vsip_scalar_d hv;
            FILE *fh;
            vsip_fir_d *fir;
            vsip_vview_d *x = vsip_vcreate_d(N,0),
                          *h,*y;
            fh = fopen(argv[3],"r");
            while(fscanf(fh,"%lf",&hv) == 1) n++;
            rewind(fh);
            y = vsip_vcreate_d(N/D + 1,0);
            h = vsip_vcreate_d(n,0);
            n=0;
            while(fscanf(fh,"%lf",&hv) == 1) {
                vsip_vput_d(h,n,hv);
                n++;
            }
            fclose(fh);
            fir = vsip_fir_create_d(h,VSIP_NONSYM,N,D,STATE,0,0);
            n = VU_scanstdin_d(x);
            while(n == N) {
                k = vsip_firflt_d(fir,x,y);
                VU_printstdout_d(y,0,k);
                n = VU_scanstdin_d(x);
            }
            if(n != 0) {
                k = vsip_firflt_d(fir,x,y);
                VU_printstdout_d(y,0,k);
            }
            {   /* test getattr */
                vsip_fir_attr attr;
                vsip_fir_getattr_d(fir,&attr);
                printf("kernel %lu\n input %lu\n output %lu\ndecimation %d\n",
                       attr.kernel_len,attr.in_len,attr.out_len, attr.decimation);
            }
            vsip_valldestroy_d(y);
            vsip_valldestroy_d(x);
            vsip_valldestroy_d(h);
            vsip_fir_destroy_d(fir);
        }
        vsip_finalize((void*)0);
        return 1;
    }
}
예제 #22
0
int main()
{
  vsip_vview_d *dataA;
  vsip_vview_d *dataB;
  vsip_vview_vi *Index;
  vsip_vview_bl *dataBl;
  int i;
  vsip_length N;

  vsip_init((void *)0);
  dataA = vsip_vcreate_d(L, VSIP_MEM_NONE);
  dataB = vsip_vcreate_d(L, VSIP_MEM_NONE);
  Index = vsip_vcreate_vi(L, VSIP_MEM_NONE);
  dataBl= vsip_vcreate_bl(L, VSIP_MEM_NONE);
  /* make up some data */
  vsip_vramp_d(0,2 * PI/(L-1),dataA);
  vsip_vcos_d(dataA,dataB);
  /* find out where dataB is greater than zero */
  vsip_vfill_d(0,dataA);
  vsip_vlgt_d(dataB,dataA,dataBl);
  /* find the index where dataB is greater than zero */
  if((N = vsip_vindexbool(dataBl,Index)))
  {
    /* make a vector of those points where dataB is greater than zero*/
    vsip_vgather_d(dataB,Index,vsip_vputlength_d(dataA,N));
    /*print out the results */
    printf("Index Value\n");
    for(i=0; i<N; i++)
      printf("%li %6.3f\n",
	     vsip_vget_vi(Index,i),
	     vsip_vget_d(dataA,i));
  }
  else
  {
    printf("Zero Length Index");
    exit(0);
  }
  vsip_vfill_d(0,dataB);
  vsip_vscatter_d(dataA,dataB,Index);
  for(i=0; i<L; i++)
    printf("%6.3f\n",vsip_vget_d(dataB,i));
  /*recover the data space*/
  vsip_blockdestroy_d(vsip_vdestroy_d(dataA));
  vsip_blockdestroy_d(vsip_vdestroy_d(dataB));
  vsip_blockdestroy_vi(vsip_vdestroy_vi(Index));
  vsip_blockdestroy_bl(vsip_vdestroy_bl(dataBl));
  vsip_finalize((void *)0);
  return 0;
}
예제 #23
0
int main (){vsip_init((void*)0);
{
  int i;
  vsip_cvview_d* vector = vsip_cvcreate_d(L,0);
  vsip_vview_d* realIn = vsip_vrealview_d(vector);
  vsip_vview_d* imagIn = vsip_vimagview_d(vector);
  vsip_fft_d* fftplan = vsip_ccfftip_create_d(L,1,-1,0,0);
  vsip_fft_d* fftplanI = vsip_ccfftip_create_d(L,(double)1/L,1,0,0);
  char printDataOne[L][20],
       printDataTwo[L][30];

  /* put some data in realIn*/
  vsip_vramp_d(0, 2 * VU_PI * F, realIn);
  vsip_vcos_d(realIn,realIn);
  /* print realIn */
  for(i=0; i<L; i++){ 
       sprintf(printDataOne[i],"%2d input -> %7.4f",i, vsip_vget_d(realIn,i));
  }
  /*make sure imagIn is full of zeros*/
  vsip_vfill_d(0,imagIn);

  /*find the fft*/
  vsip_ccfftip_d(fftplan,vector);
  for(i=0; i<L; i++){
     sprintf(printDataTwo[i]," fft -> (%7.3f, %7.3f)",
           vsip_real_d(vsip_cvget_d(vector,i)),
           vsip_imag_d(vsip_cvget_d(vector,i)));
  }
  /*invert the fft*/
  vsip_ccfftip_d(fftplanI,vector);
  /*print it */
  for(i=0; i<L; i++){
     printf("%s %s  ifft -> (%7.3f, %7.3f)\n",
           printDataOne[i],
           printDataTwo[i],
           vsip_real_d(vsip_cvget_d(vector,i)),
           vsip_imag_d(vsip_cvget_d(vector,i)));
  }
 
  {
     vsip_vdestroy_d((void*)imagIn);
     vsip_vdestroy_d((void*)realIn);
     vsip_cblockdestroy_d(vsip_cvdestroy_d((void*)vector));
     vsip_fft_destroy_d((void*)fftplan);
     vsip_fft_destroy_d((void*)fftplanI);
  }
  } vsip_finalize((void*)0);return 0;
}
예제 #24
0
int main(){
  vsip_init((void*)0);
  acos_f();
  asin_f();
  atan2_f();
  atan_f();
  cos_f();
  sin_f();
  sqrt_f();
  tan_f();
  ceil_f();
  exp_f();
  exp10_f();
  floor_f();
  fmod_f();
  hypot_f();
  log_f();
  log10_f();
  mag_f();
  max_f();
  min_f();
  pow_f();
  rsqrt_f();
  sinh_f();
  tanh_f();
  cosh_f();
  arg_f();
  cadd_f();
  cdiv_f();
  cexp_f();
  cjmul_f();
  cmul_f();
  clog_f();
  cmag_f();
  cmagsq_f();
  cmplx_f();
  cneg_f();
  conj_f();
  crecip_f();
  csqrt_f();
  csub_f(0);
  imag_f();
  real_f();
  polar_f();
  rect_f();
  vsip_finalize((void*)0);
  return 0;
}
예제 #25
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;
}
예제 #26
0
int main()
{
  vsip_vview_d* data;

  vsip_init((void *)0);
  data = vsip_vcreate_d(L, VSIP_MEM_NONE);
  /* Make up some data to find the mean square value of */
  /* Compute a ramp from zero to L-1 */
  vsip_vramp_d(0.0, 1.0, data);
  /* And find and print its mean square value */
  printf("%f \n",vsip_vmeansqval_d(data));
  /*destroy the vector views and any associated blocks */
  vsip_blockdestroy_d(vsip_vdestroy_d(data));
  vsip_finalize((void *)0);
  return 0;
}
예제 #27
0
int main()
{
  int i;
  /* define some vectors */
  vsip_vview_d* dataReOne;
  vsip_vview_d* dataReTwo;
  vsip_vview_d* dataReQuotient;
  vsip_cvview_d* dataComplex;
  vsip_cvview_d* dataComplexQuotient;

  vsip_init((void *)0);
  dataReOne = vsip_vcreate_d(L, VSIP_MEM_NONE);
  dataReTwo = vsip_vcreate_d(L, VSIP_MEM_NONE);
  dataReQuotient = vsip_vcreate_d(L, VSIP_MEM_NONE);
  dataComplex = vsip_cvcreate_d(L, VSIP_MEM_NONE);
  dataComplexQuotient = vsip_cvcreate_d(L, VSIP_MEM_NONE);
  /* make up some data */
  vsip_vramp_d(1,1,dataReOne);
  vsip_vfill_d(2,dataReTwo);
  vsip_vcmplx_d(dataReTwo,dataReOne,dataComplex);

  /*divide one by two and print the input and output */
  vsip_vdiv_d(dataReOne,dataReTwo,dataReQuotient);
  for(i=0; i<L; i++)
    printf("%7.4f / %7.4f = %7.4f\n",
           vsip_vget_d(dataReOne,i), vsip_vget_d(dataReTwo,i),
           vsip_vget_d(dataReQuotient,i)); printf("\n");
  /*divide one by complex and print the input and output */
  vsip_rcvdiv_d(dataReOne,dataComplex,dataComplexQuotient);
  for(i=0; i<L; i++)
    printf("%7.4f / (%7.4f + %7.4fi) = (%7.4f + %7.4fi)\n",
           vsip_vget_d(dataReOne,i),
           vsip_real_d(vsip_cvget_d(dataComplex,i)),
           vsip_imag_d(vsip_cvget_d(dataComplex,i)),
           vsip_real_d(vsip_cvget_d(dataComplexQuotient,i)),
           vsip_imag_d(vsip_cvget_d(dataComplexQuotient,i)));
  /* destroy created objects */
  vsip_blockdestroy_d(vsip_vdestroy_d(dataReOne));
  vsip_blockdestroy_d(vsip_vdestroy_d(dataReTwo));
  vsip_blockdestroy_d(vsip_vdestroy_d(dataReQuotient));
  vsip_cblockdestroy_d(vsip_cvdestroy_d(dataComplex));
  vsip_cblockdestroy_d(vsip_cvdestroy_d(dataComplexQuotient));
  vsip_finalize((void *)0);
  return 0;
}
예제 #28
0
int main(){vsip_init((void*)0);
{
/*   vsip_cmview_d *B = vsip_cmcreate_d(P,N,VSIP_ROW,0);*/
   vsip_scalar_d Re[20], Im[20];
   vsip_cblock_d *Bblock = vsip_cblockbind_d(Re,Im,20,0);
   vsip_cmview_d *B = vsip_cmbind_d(Bblock,0,4,5,1,4);
   vsip_cvview_d *a = vsip_cvcreate_d(P,0),
                 *r = vsip_cvcreate_d(N,0);
   int i, j;
   for(i=0;i<P;i++) 
        vsip_cvput_d(a,i,vsip_cmplx_d(i,1 + sqrt(i)));
   
   for(i=0;i<P;i++) for(j=0;j<N;j++)
        vsip_cmput_d(B,i,j,vsip_cmplx_d(1 , i * j));
   
   vsip_cvmprod_d(a,B,r);
   printf("\n vector input \n v=[");

   for(i=0;i<P;i++)
          printf("(%5.2f %+5.2fi) ",
          vsip_real_d(vsip_cvget_d(a,i)),
          vsip_imag_d(vsip_cvget_d(a,i)));
   printf("]\n");
   
   printf("\n B input \n B =[\n");
   {for(i=0;i<P;i++) {for(j=0;j<N;j++){
           printf(" (%5.2f %+5.2fi) ",
             vsip_real_d(vsip_cmget_d(B,i,j)),
             vsip_imag_d(vsip_cmget_d(B,i,j)));
           }
           printf(";\n");
       }
       printf("]\n");
   }
   printf("\n vector output \n");
   for(i=0;i<N;i++)
           printf("(%5.2f, %5.2f) ",
             vsip_real_d(vsip_cvget_d(r,i)),
             vsip_imag_d(vsip_cvget_d(r,i)));
   printf("\n");
   vsip_cvalldestroy_d(a);
   vsip_cmalldestroy_d(B);
   vsip_cvalldestroy_d(r);
   }vsip_finalize((void*)0);return 0;
}
예제 #29
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;
}
예제 #30
0
int main()
{
  int i;
  vsip_cscalar_d z;
  vsip_scalar_d data[N]; /* a public data space for I/O */
  vsip_fft_d *rcfftNop;
  vsip_block_d *block;
  vsip_vview_d *xin;
  vsip_cvview_d *yout;

  vsip_init((void *)0);
  rcfftNop = /* Create an out-of-place Real->Cmplx N-pt FFT */
    vsip_rcfftop_create_d(N, 1.0, 1, VSIP_ALG_TIME);
  /* Create a block object and bind it to the array data */
  block = vsip_blockbind_d(data, N, VSIP_MEM_NONE);
  xin = vsip_vbind_d(block, 0, 1, N);
  /* Create another block and complex vector view for the
     symmetric output */
  yout = vsip_cvcreate_d((N/2)+1, VSIP_MEM_NONE);
  /* Admit block to VSIPL for processing and initialize with a
     linear ramp */
  vsip_blockadmit_d(block, VSIP_FALSE);
  vsip_vramp_d(0.0, 1.0, xin);
  /* Compute an out-of-place Real->Cmplx N-pt FFT using the
     rcfftNop object */
  vsip_rcfftop_d(rcfftNop, xin, yout);
  /* print it */
  printf("Real Input Vector\n");
  for(i=0; i<N; i++) 
  {
    printf("%g\n", vsip_vget_d(xin,i));
  }
  printf("\nComplex Output Vector\n");
  for(i=0; i<(N/2)+1; i++) 
  {
    z = vsip_cvget_d(yout,i);
    printf(SCMPLX "\n", ACMPLX(z));
  }
  /* Destroy the rcfftNop, blocks, and view objects */
  vsip_fft_destroy_d(rcfftNop);
  vsip_valldestroy_d(xin);
  vsip_cvalldestroy_d(yout);
  vsip_finalize((void *)0);
  return(0);
}