void VU_vfreqswapIP_d(vsip_vview_d* b)
{   vsip_length N = vsip_vgetlength_d(b);
    if(N%2){/* odd */
       vsip_vview_d *a1 = vsip_vsubview_d(b,
                 (vsip_index)(N/2)+1,
                 (vsip_length)(N/2));
       vsip_vview_d *a2 = vsip_vsubview_d(b,
                 (vsip_index)0,
                 (vsip_length)(N/2)+1);
       vsip_vview_d *a3 = vsip_vcreate_d((vsip_length)(N/2)+1,
                          VSIP_MEM_NONE);
       vsip_vcopy_d_d(a2,a3);
       vsip_vputlength_d(a2,(vsip_length)(N/2));
       vsip_vcopy_d_d(a1,a2);
       vsip_vputlength_d(a2,(vsip_length)(N/2) + 1);
       vsip_vputoffset_d(a2,(vsip_offset)(N/2));
       vsip_vcopy_d_d(a3,a2);
       vsip_vdestroy_d(a1); vsip_vdestroy_d(a2);
       vsip_valldestroy_d(a3);
    }else{ /* even */
       vsip_vview_d *a1 = vsip_vsubview_d(b,
                 (vsip_index)(N/2),
                 (vsip_length)(N/2));
       vsip_vputlength_d(b,(vsip_length)(N/2));
       vsip_vswap_d(b,a1);
       vsip_vdestroy_d(a1);
       vsip_vputlength_d(b,N);
    }
    return;
}
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;
}
Esempio n. 3
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;
}