Exemplo n.º 1
0
void LastRank_HK::raz()
{
    mPopTot = 0;
    _last_val = -1;
    _rank_last_val = 0;
    set_cste(_h-1,0,_max_vals+1);
}
Exemplo n.º 2
0
Flux_To_Surf_Computed::Flux_To_Surf_Computed
(
     Arg  arg,
     bool front
)  :
   RLE_Flux_Pts_Computed(2,arg.b._p1.x-arg.b._p0.x),
   _b          (arg.b),
   _last       (false),
   _with_front (front?1:0)
{
   _l_cur =  NEW_VECTEUR(_b._p0.x,_b._p1.x+3,INT);
   set_cste(_l_cur+_b._p0.x,0,_b._p1.x+3-_b._p0.x);
   _l = NEW_VECTEUR(_b._p0.y,_b._p1.y,Line);

   INT   * y = arg.pts->_pts[1];
   INT   * x = arg.pts->_pts[0];
   INT   nb = arg.pts->nb();


   {
        // compute nb pts by line 

        for (INT ky=_b._p0.y ; ky<_b._p1.y ; ky++)
        {
            _l[ky].nb = 0;
            _l[ky].nb_ev = 0;
        }
        for (INT k=0 ; k<nb ; k++)
            _l[y[k]].nb++;
   }

   {
        // compute (end of) adresse to put x values;

        _res_x   = NEW_VECTEUR(0,nb,INT);
        _res_evt   = NEW_VECTEUR(0,nb,bool);
        _l[_b._p0.y].xs = _res_x +  _l[_b._p0.y].nb;
        _l[_b._p0.y].evts = _res_evt +  _l[_b._p0.y].nb;

        for (INT ky=_b._p0.y +1 ; ky<_b._p1.y ; ky++)
        {
            _l[ky].xs   = _l[ky-1].xs   + _l[ky].nb;
            _l[ky].evts = _l[ky-1].evts + _l[ky].nb;
        }
   }

   //  put x values ("begin by end")
   for (INT k=0 ; k<nb ; k++)
   {
        Line * l = _l + y[k];
        l->xs --;
        l->evts --;
        *(l->xs)  = x[k];
        *(l->evts)  = 
                (
                       ( y[mod(k-1,nb)] < y[k])
                   !=  ( y[mod(k+1,nb)] < y[k])
                 );
        if (*(l->evts)) 
           l->nb_ev ++;
   }
   delete arg.pts;
   new_line(_b._p0.y);
}
Exemplo n.º 3
0
         FoncATrou_OPB_Comp<Type>::FoncATrou_OPB_Comp
         (
                 Liste_Pts<Type,INT>  l,
                 INT                       X0,
                 INT                       X1,
                 INT                       Y0,
                 INT                       Y1
         )   :
         _values      (1,1),
         _l            (1),
         _cpt         (NEW_VECTEUR(Y0,Y1+1,INT)),
         _dim_vals    (l.dim()-2)
{
	INT k;

     set_cste(_cpt+Y0,0,Y1-Y0+1);

     Im2D<Type,INT> XYV = l.image();

     INT nb_pts = 0;
     Type * tx = XYV.data()[0];
     Type * ty = XYV.data()[1];
     Type **   xyv  = XYV.data();


   //----  filtre les pts hors du rectangle ---------

     INT dim =        XYV.ty();

     {
          INT nb_pts_tot = XYV.tx();
          for( k=0; k<nb_pts_tot; k++)
              if (
                         (tx[k]>=X0) 
                      && (tx[k]< X1)
                      && (ty[k]>=Y0) 
                      && (ty[k]< Y1)
                 )
              {
                  for(INT d=0; d<dim; d++)
                     xyv[d][nb_pts] = xyv[d][k];
                  nb_pts++;
              }
     }

   //--------- histo en Y + cumule -----------------------
     for( k=0; k<nb_pts; k++)
         _cpt[ty[k]]++;
     for (INT y = Y0+1; y<=Y1; y++)
          _cpt[y] +=  _cpt[y-1];


    //---------------- range en y croissant ----------------
     _values = Im2D<Type,INT> (nb_pts,_dim_vals+1);
     _tx     = _values.data()[0];
     _v      = _values.data()+1;

     for( k=0; k<nb_pts ; k++)
     {
         INT adr =  --_cpt[ty[k]];
         _tx[adr] =  tx[k];
         for (INT d = 0; d<_dim_vals; d++)
             _v[d][adr] = xyv[d+2][k];
     }
}
Exemplo n.º 4
0
void Can_Exp_OPB_Comp::post_new_line(bool first)
{
        if (first)
        {
           for (INT y = 0 ; y < _nb; y++)
               exp_line(y);
        }
        exp_line(_nb);

        for (INT d =0; d < _dim_out ; d++)
        {
            REAL ** lines = kth_buf((REAL *)0,0)[d];
            REAL *    bav = _cumul_line_av[d];
            REAL * res = _buf_res[d];

            if (first)
               set_cste(bav+_x0,0.0,_x1-_x0);

            {
               REAL * l0     = lines[0];
               for (INT x=_x0 ; x<_x1 ; x++)
                   res[x] = bav[x] = _fy * bav[x] + l0[x];
             }

            if (! _nb)
               return;

            if (_rec_arr)
            {
                REAL ** brecar = _buf_rec_arr[d];
                REAL *  corar  = _correc_arr[d];

                if (! _cptl)
                {
                   convert
                   (
                      brecar[_nb]+_x0,
                      lines[_nb] +_x0,
                      _x1-_x0
                   );
                   for (INT y=_nb-1 ; y>=1 ; y--)
                   {
                      REAL * ly   = lines[y];
                      REAL * cur  = brecar[y];
                      REAL * prec = brecar[y+1];
                      for (INT x=_x0 ; x<_x1 ; x++)
                          cur[x] = ly[x] + _fy * prec[x];
                   }
                   set_cste(corar+_x0,0.0,_x1-_x0);
                }
                else
                {
                   REAL * lnb   = lines[_nb];
                   REAL fact_cor    = Pow(_fy,_cptl-1);
                   for (INT x = _x0 ; x<_x1 ; x++)
                      corar[x] +=  fact_cor * lnb[x];
                }
                REAL * lar = brecar[_cptl+1];
                REAL fact_cor = Pow(_fy,_nb+1-_cptl);
                for (INT x = _x0 ; x<_x1 ; x++)
                    res[x] +=  _fy*lar[x] + fact_cor * corar[x];
            }
            else
            {
                 REAL   fNy = 1.0;
                 for (INT y=1 ; y<=_nb ; y++)
                 {
                      fNy *= _fy;
                      REAL * ly = lines[y];
                      for (INT x = _x0 ; x<_x1 ; x++)
                          res[x] += ly[x] * fNy ;
                 }
            }

       }
       _cptl    = (_cptl+1) % _nb;
}