예제 #1
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;
}
예제 #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);
{
  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;
}
예제 #4
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;
}
예제 #5
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;
}
예제 #6
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;
}
예제 #7
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;
}
예제 #8
0
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;
}
예제 #9
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;
}
예제 #10
0
void VU_cmprint_d(vsip_cmview_d *X)
{
    vsip_length RL = vsip_cmgetrowlength_d(X);  
    vsip_length CL = vsip_cmgetcollength_d(X);  
    vsip_length i,j;
    vsip_cscalar_d x;
    printf("[\n");
    for(j=0; j<RL; j++){
      for(i=0; i<CL; i++){
        x=vsip_cmget_d(X,i,j);
        printf("(%6.4f%+6.4fi%s",vsip_real_d(x),vsip_imag_d(x),((i==(CL-1)) ? ");" : ")"));
      }
      printf("\n");
    }
    printf("];\n");
    return;
}
예제 #11
0
void VU_cmprint_d(vsip_cmview_d *X)
{
    vsip_length RL = vsip_cmgetrowlength_d(X);
    vsip_length CL = vsip_cmgetcollength_d(X);
    vsip_length row,col;
    vsip_cscalar_d x;
    printf("[\n");
    for(row=0; row<CL; row++){
      for(col=0; col<RL; col++){
        x=vsip_cmget_d(X,row,col);
        printf("(%6.4f %+6.4fi%s ",vsip_real_d(x),vsip_imag_d(x),((col==(RL-1)) ? ");" : ")"));
      }  
      printf("\n");
    }
    printf("];\n");
    return;
}
void VU_cvprintm_d(char s[],
    vsip_cvview_d *X)
{
    char format[50];
    vsip_length L = vsip_cvgetlength_d(X);
    vsip_index vi;
    vsip_cscalar_d x;
    strcpy(format,"(%");
    strcat(format,s);
    strcat(format,"lf %+");
    strcat(format,s);
    strcat(format,"lfi) %s\n");
    printf("[\n");	
    for(vi=0; vi<L; vi++){
      x=vsip_cvget_d(X,vi);
      printf(format,vsip_real_d(x),
                    vsip_imag_d(x),";");
    }  
    printf("];\n");
    return;
}
예제 #13
0
파일: vsip_cadd_d.c 프로젝트: rrjudd/jvsip
vsip_cscalar_d (vsip_cadd_d)(
  vsip_cscalar_d x, vsip_cscalar_d y) {/* x + y*/
  return vsip_cmplx_d(
    (vsip_real_d(x) + vsip_real_d(y)),
    (vsip_imag_d(x) + vsip_imag_d(y))); }
예제 #14
0
vsip_scalar_d (vsip_arg_d)(vsip_cscalar_d x) {
  return atan2(vsip_imag_d(x), vsip_real_d(x)); 
}
예제 #15
0
vsip_cscalar_d (vsip_rcmul_d)(
  vsip_scalar_d x, vsip_cscalar_d y) {		/*  x*y	*/
  return vsip_cmplx_d(
    x * vsip_real_d(y),
    x * vsip_imag_d(y)); }
예제 #16
0
파일: vsip_conj_d.c 프로젝트: rrjudd/jvsip
vsip_cscalar_d (vsip_conj_d)(vsip_cscalar_d x) {	/* conj(x)	*/
  return vsip_cmplx_d(vsip_real_d(x),
	   -(vsip_imag_d(x))); }