static 
void 
VI_qprodm_d(
       vsip_mview_d *C,
       vsip_qr_d *qr)
{
     vsip_mview_d *H = qr->A;
     vsip_scalar_d *beta = qr->beta;
     vsip_vview_d *h, hh;
     vsip_length j;
     vsip_stride k;
     vsip_vview_d vv = *(qr->v),
                  ww = *(qr->w);
     vsip_vview_d *v = &vv, *w = &ww;
     VI_vfill_d(0,v);
     h = VI_mcolview_d(H,0,&hh);
     w->length = C->row_length;
     for(k = qr->N -1; k >= 0; k--){
          j = (vsip_length)k;
          h->offset = j * (H->row_stride + H->col_stride) + H->offset;
          h->length = H->col_length -j;
          v->length = h->length;
          v->offset = qr->M - h->length;
          VI_vcopy_d_d(h,v);
          VI_VPUT_D(v,(vsip_index)0,(vsip_scalar_d)1);
          vv = *(qr->v);
          v->length = C->col_length;
          VI_svmprod_d(-beta[j],v,C,w);
          v->length = qr->M;
          VI_opu_d(C,v,w);
     }
     return;
}
Exemple #2
0
void (vsip_vhisto_d)(
  const vsip_vview_d* a,
  vsip_scalar_d min,
  vsip_scalar_d max,
  vsip_hist_opt opt,
  const vsip_vview_d* r) { /* histogram	*/
  {
    vsip_stride		str = 0;
    vsip_length		n = a->length;
    vsip_length		p = r->length;
    double              p_s = (double)(p - 2);
    vsip_stride ast = a->stride * a->block->rstride,
                rst = r->stride * r->block->rstride;
    double	scale = (double)rst * p_s;
    double      iscale = (double)(max-min);
    vsip_scalar_d *ap = (a->block->array) + a->offset * a->block->rstride,
                  *rp = (r->block->array) + r->offset * r->block->rstride;
    vsip_scalar_d *rp0 = rp, 
                  *rp_end = rp + p - 1 ;
    rp++;
    if(opt == VSIP_HIST_RESET) VI_vfill_d((vsip_scalar_d)0, r);
    while(n-- > 0){
       if(*ap < min){
            (*rp0)++;
       } else if (*ap >= max){
            (*rp_end)++;
       } else {
            str = (vsip_stride)((scale * (double)(*ap - min))/iscale);
            (*(rp + str))++;
       }
       ap += ast;
    }
  }
}
Exemple #3
0
void vsip_fir_reset_d(
              vsip_fir_d *fir)
{
    fir->p = 0;
    fir->s->length = fir->M - 1;
    VI_vfill_d(0,fir->s);
    return;
}
void (vsip_mhisto_d)(
  const vsip_mview_d* a,
  vsip_scalar_d min,
  vsip_scalar_d max,
  vsip_hist_opt opt,
  const vsip_vview_d* r) { /* histogram	*/
  {
    vsip_stride		str = 0;
    vsip_length		p = r->length;
    double              p_s = (double)(p - 2);
    vsip_stride rst = r->stride * r->block->rstride;
    double	scale = (double)rst * p_s;
    double      iscale = (double)(max-min);
    vsip_scalar_d *rp = (r->block->array) + r->offset * r->block->rstride;
    vsip_scalar_d *rp0 = rp, *rp_end = rp + p - 1 ;

    vsip_length n_mj, /* major length */
                n_mn; /* minor length */
    vsip_stride ast_mj, ast_mn;
    vsip_scalar_d *ap = (a->block->array) + a->offset * a->block->rstride;
    vsip_scalar_d *ap0 = ap;
    if(a->row_stride < a->col_stride){
           n_mj = a->row_length; n_mn = a->col_length;
           ast_mj = a->row_stride; ast_mn = a->col_stride;
           ast_mj *= a->block->rstride; ast_mn *= a->block->rstride;
    } else {
           n_mn = a->row_length; n_mj = a->col_length;
           ast_mn = a->row_stride; ast_mj = a->col_stride;
           ast_mn *= a->block->rstride; ast_mj *= a->block->rstride;
    }

    rp++;
    if(opt == VSIP_HIST_RESET) VI_vfill_d((vsip_scalar_d)0., r);
    while(n_mn-- > 0){
          int n = n_mj;
          while(n-- >0){
             if(*ap < min){
                  (*rp0)++;
             } else if (*ap >= max){
                  (*rp_end)++;
             } else {
                  str = (vsip_stride)((scale * (double)(*ap - min))/iscale);
                  (*(rp + str))++;
             }
            ap += ast_mj;
          }
          ap0 += ast_mn;
          ap = ap0;
    }
  }
}
Exemple #5
0
int vsip_firflt_d(
        vsip_fir_d *fir,
        const vsip_vview_d *xc,
        const vsip_vview_d *yc)
{
    vsip_length nout,k;
    vsip_vview_d xx = *xc,
                 yy = *yc;
    vsip_vview_d H1 = *(fir->h),
                 H2 = *(fir->h);
    vsip_vview_d *x=&xx,*y=&yy;
    vsip_vview_d *h1=&H1,*h2=&H2;
    vsip_offset oinc;
    oinc = (vsip_offset)((vsip_stride)fir->D * x->stride);

    /* calculate number of terms in y */
    nout = (fir->N - fir->p);
    nout = ((nout % fir->D) == 0) ? (nout / fir->D ) : (nout / fir->D + 1);

    /* do overlap section */
    k = 0;
    x->length = fir->p + 1;
    h1->length = fir->s->length;
    h2->length = x->length;
    h2->offset = h1->length;

    while(x->length < fir->M){
        VI_VPUT_D(y,k++,vsip_vdot_d(h1,fir->s)+vsip_vdot_d(h2,x));
        x->length += fir->D;
        fir->s->length -= fir->D;
        fir->s->offset += fir->D;
        h1->length = fir->s->length;
        h2->length = x->length;
        h2->offset = h1->length;
    }
    x->offset += (x->length - fir->M) * x->stride;
    x->length = fir->M;

    while(k < nout){ /* do the rest of the pieces */
       VI_VPUT_D(y,k++,vsip_vdot_d(fir->h,x));
       x->offset += oinc;
    }

    {  /* Hacked Mod because In ANSI C it is a machine dependent mod for negative */
       vsip_stride temp_p = (fir->p % fir->D)  - (fir->N % fir->D);
       fir->p = ((temp_p < 0) ? (vsip_length)((vsip_stride)fir->D + temp_p) : (vsip_length)temp_p); 
    }
    fir->s->offset = 0;
    fir->s->length = (fir->state == VSIP_STATE_SAVE) ? fir->M - 1 - fir->p : fir->M -1;
    x->length = fir->s->length;
    /* fix by JMA 31/01/2000, incorrect offset calculation */
    /* x->offset = xc->length - fir->s->length; */
    x->offset = xc->offset + (xc->length - fir->s->length) * xc->stride;
    if((fir->s->length > 0) && (fir->state == VSIP_STATE_SAVE)) 
          VI_vcopy_d_d(x,fir->s);
    if(fir->state == VSIP_STATE_NO_SAVE){
         VI_vfill_d(0,fir->s);
         fir->p = 0;
     }
    return (int)k;
}
Exemple #6
0
vsip_fir_d *vsip_fir_create_d(
              const vsip_vview_d *kernel,
              vsip_symmetry symm,
              vsip_length N,
              vsip_length D,
              vsip_obj_state state,
              unsigned int ntimes,
              vsip_alg_hint hint)
{
    vsip_length klength = 0;
    vsip_fir_d *fir = (vsip_fir_d*)malloc(sizeof(vsip_fir_d));
    if(fir == NULL){ return (vsip_fir_d*) NULL;
    } else {
        switch(symm){
           case 0: klength = kernel->length;
                   break;
           case 1: klength = 2 * kernel->length - 1;
                   break;
           case 2: klength = 2 * kernel->length;
                   break;
        }
        fir->h = VI_vcreate_d(klength,VSIP_MEM_NONE);
        fir->s = VI_vcreate_d(klength-1,VSIP_MEM_NONE);
    }
    if((fir->h == NULL) | (fir->s == NULL)){ 
        vsip_fir_destroy_d(fir);
        return (vsip_fir_d*) NULL;
    } else {
       fir->N = N;
       fir->M = klength;
       fir->D = D;
       fir->p = 0;
       fir->ntimes = ntimes;
       fir->symm = symm;
       fir->hint = hint;
       switch(symm){
           case 0:{
              fir->h->offset = fir->h->length - 1;
              fir->h->stride = -1;
              VI_vcopy_d_d(kernel,fir->h);
           }
           break;
           case 1: {
              fir->h->length = kernel->length;
              VI_vcopy_d_d(kernel,fir->h);
              fir->h->offset = klength - 1;
              fir->h->stride = -1;
              VI_vcopy_d_d(kernel,fir->h);
              fir->h->length = klength;
           }
           break;
           case 2: {
              fir->h->length = kernel->length;
              VI_vcopy_d_d(kernel,fir->h);
              fir->h->offset = klength - 1;
              fir->h->stride = -1;
              VI_vcopy_d_d(kernel,fir->h);
              fir->h->length = klength;
           }
           break;
       }
       fir->state = state;
       fir->h->offset = 0;
       fir->h->stride = 1;
       VI_vfill_d(0,fir->s);
       return fir;
    }
}