Changeset 3461 in Sophya for trunk/SophyaPI


Ignore:
Timestamp:
Feb 13, 2008, 12:24:11 PM (18 years ago)
Author:
cmv
Message:
  • modifs sur le nombres de valeurs a traiter dans ComputLut_Range (gestion de nmax)
  • changement "bin=binmax+(nbsig*sigr)" -> "bin=binmax+int(nbsig*sigr)" pour eviter les warning compilation "int from double"

cmv 13/02/2008

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PI/parradapter.cc

    r3458 r3461  
    335335q = phis+binmax;
    336336while ( ((*q) > hmin) && (sigr < (nbin-binmax)) )  { sigr++;  q++; }
    337 if (sigr < 1) sigr = 1.;
     337if (sigr < 1) sigr = 1;
    338338int sigl = 0;
    339339q = phis+binmax;
    340340while ( ((*q) > hmin) && (sigl < binmax) )  { sigl++; q--; }
    341 if (sigl < 1) sigl = 1.;
     341if (sigl < 1) sigl = 1;
    342342
    343343if (nbsig <= 0.) nbsig = 1.;
    344344if (htail == false)  {  /*   On recherche le min/max autour du pic de l'histo  */
    345   if ( (bin = binmax-(nbsig*sigl)) < 0 )  bin = 0;
     345  if ( (bin = binmax-int(nbsig*sigl)) < 0 )  bin = 0;
    346346  min = minhis + (double)bin*binwidth;
    347   if ( (bin = binmax+(nbsig*sigr)) >= nbin ) bin = nbin-1;
     347  if ( (bin = binmax+int(nbsig*sigr)) >= nbin ) bin = nbin-1;
    348348  max = minhis + (double)bin*binwidth;
    349349  if (max < (min+MINDYNAMIC))  max = min+MINDYNAMIC;
     
    352352
    353353//  On recherche le min/max en supprimant le pic de l'histo  (la queue, > pic)
    354 if ( (bin = binmax+(nbsig*sigl)) >= nbin ) {
     354if ( (bin = binmax+int(nbsig*sigl)) >= nbin ) {
    355355  min = minhis + binmax*binwidth;
    356356  max = maxhis;
     
    380380int P2DArrayAdapter::ComputeLut_Range(double& min, double& max, double fracmin, double fracmax,int nmax)
    381381// Compute min and max by throwing away the "fracmin" lowest values and the "fracmax" greatest values
    382 // Use 1 value over "vit". Maximum number values to be used is "nmax".
    383 // Si echec alors min,max restent inchanges.
    384 {
    385   int lp=0;
     382// .."fracmin" in [0,1[  and   "fracmax" in [0,1[. If not they are set to zero.
     383// ..If min<max, use only the values inside [min,max]
     384// ..Maximum number values to be used is "nmax" (uniformly spread)
     385//     if "nmax" is in [-100,0[ take "-nmax%" values (-nmax/100*sX*sY)
     386//     if "nmax=0" or "nmax<-100" take all the values (sX*sY)
     387// ..If failed: min,max stay unchanged.
     388{
     389 int lp=0;
    386390 if(fracmin<0. || fracmin>=1.) fracmin=0.;
    387391 if(fracmax<0. || fracmax>=1.) fracmax=0.;
    388  if(nmax<10) nmax = 5000;
     392 if(nmax>=-100 && nmax<0) nmax = int(-nmax/100. * sX*sY);
     393 if(nmax<=2) nmax = sX*sY;
    389394
    390395 int vit = sX*sY/nmax;  // Not too many values, we are using qsort !
     
    398403 nmax = sX*sY/vit;
    399404
    400  double *buff = new double[nmax];
     405 double *buff = new double[nmax+1]; // +1 pour protection si sX=sY=0
    401406
    402407 if(lp) {printf("ComputeLut_Range: sX*sY=%d fracmin=%g fracmax=%g nmax=%d min=%g max=%g\n"
     
    411416 }
    412417
    413  if(nfill<1) {delete [] buff; return nfill;}
     418 if(nfill<=1) {delete [] buff; return nfill;}
    414419
    415420 qsort(buff,(size_t) nfill,sizeof(double),qSort_Dble);
Note: See TracChangeset for help on using the changeset viewer.