Index: trunk/SophyaLib/NTools/generaldata.cc
===================================================================
--- trunk/SophyaLib/NTools/generaldata.cc	(revision 3018)
+++ trunk/SophyaLib/NTools/generaldata.cc	(revision 3062)
@@ -48,5 +48,5 @@
   indique que l'on fournit des erreurs sur les ``nVar'' variables en abscisse.
 */
-GeneralFitData::GeneralFitData(unsigned int nVar, unsigned int ndatalloc, uint_2 errx)
+GeneralFitData::GeneralFitData(uint_4 nVar, uint_4 ndatalloc, uint_2 errx)
   : mNVar(0), mNDataAlloc(0), mNData(0), mNDataGood(0), mOk_EXP(0)
   , mXP(NULL), mErrXP(NULL), mF(NULL), mErr(NULL), mOK(NULL)
@@ -83,5 +83,5 @@
  if(data.mNData>0) {
    r_8* ret;
-   for(int i=0;i<data.mNData;i++) {
+   for(int_4 i=0;i<data.mNData;i++) {
      if( clean && data.mOK[i]==0 ) continue;
        ret = data.GetVec(i,NULL);
@@ -120,23 +120,23 @@
   Pour redefinir la structure de donnees (ou la creer si on a utilise
   le createur par defaut). Voir les explications des arguments
-  dans les commentaires du constructeur. Si ``errx''\<0 alors
-  la valeur prise est celle definie auparavent.
-*/
-void GeneralFitData::Alloc(unsigned int nVar, unsigned int ndatalloc, int_2 errx)
-{
-ASSERT( nVar>0 && ndatalloc>0 );
-
+  dans les commentaires du constructeur.
+*/
+void GeneralFitData::Alloc(uint_4 nVar, uint_4 ndatalloc, uint_2 errx)
+{
 Delete();
-
-if(errx>=0) mOk_EXP = (uint_2) errx;
+if(nVar<=0 || ndatalloc<=0) return;
+
 mNVar = nVar;
 mNDataAlloc = ndatalloc;
 
 try {
-  mXP  = new r_8[nVar*ndatalloc];
-  if(mOk_EXP) mErrXP  = new r_8[nVar*ndatalloc];
-  mF   = new r_8[ndatalloc];
-  mErr = new r_8[ndatalloc];
-  mOK  = new uint_2[ndatalloc];
+  mXP = new r_8[nVar*ndatalloc]; memset(mXP,0,nVar*ndatalloc*sizeof(r_8));
+  if(errx) {
+    mErrXP = new r_8[nVar*ndatalloc]; memset(mErrXP,0,nVar*ndatalloc*sizeof(r_8));
+    mOk_EXP = errx;
+  }
+  mF = new r_8[ndatalloc]; memset(mF,0,ndatalloc*sizeof(r_8));
+  mErr = new r_8[ndatalloc]; memset(mErr,0,ndatalloc*sizeof(r_8));
+  mOK = new uint_2[ndatalloc]; memset(mOK,0,ndatalloc*sizeof(uint_2));
   BuffVar   = new r_8[2*nVar+3];
   BuffVarR4 = (r_4 *) BuffVar;
@@ -154,5 +154,5 @@
 mNVar = mNDataAlloc = mNData = mNDataGood = 0;
 if( mXP  != NULL ) {delete [] mXP;  mXP  = NULL;}
-if( mErrXP  != NULL ) {delete [] mErrXP;  mErrXP  = NULL;}
+if( mErrXP  != NULL ) {delete [] mErrXP;  mErrXP  = NULL; mOk_EXP = 0;}
 if( mF   != NULL ) {delete [] mF;   mF   = NULL;}
 if( mErr != NULL ) {delete [] mErr; mErr = NULL;}
@@ -167,11 +167,30 @@
   sont sur-ecrites.
 */
-void GeneralFitData::SetDataPtr(int ptr)
-{
- ASSERT(ptr >= 0 && ptr < mNDataAlloc);
+void GeneralFitData::SetDataPtr(int_4 ptr)
+{
+ if(ptr<0 || ptr>=mNDataAlloc) return;
  mNData = ptr;
  mNDataGood = 0;
  if(ptr==0) return;
- for(int i=0;i<mNData;i++) if(mOK[i]) mNDataGood++;
+ for(int_4 i=0;i<mNData;i++) if(mOK[i]) mNDataGood++;
+}
+
+///////////////////////////////////////////////////////////////////
+/*!
+  Operateur gd1 = gd2
+*/
+GeneralFitData& GeneralFitData::operator = (const GeneralFitData& g)
+{
+ if(this == &g) return *this;
+
+ Alloc(g.mNVar,g.mNDataAlloc,g.mOk_EXP);
+
+ if(g.mXP) memcpy(mXP,g.mXP,mNVar*mNDataAlloc*sizeof(r_8));
+ if(g.mErrXP) memcpy(mErrXP,g.mErrXP,mNVar*mNDataAlloc*sizeof(r_8));
+ if(g.mF) memcpy(mF,g.mF,mNDataAlloc*sizeof(r_8));
+ if(g.mErr) memcpy(mErr,g.mErr,mNDataAlloc*sizeof(r_8));
+ if(g.mOK) memcpy(mOK,g.mOK,mNDataAlloc*sizeof(uint_2));
+
+ return *this;
 }
 
@@ -180,7 +199,7 @@
   Pour tuer un point
 */
-void GeneralFitData::KillData(int i)
-{
- ASSERT(i >= 0 && i < mNData);
+void GeneralFitData::KillData(int_4 i)
+{
+ if(i<0 || i>=mNData) return;
 
  if( ! mOK[i] ) return;
@@ -192,11 +211,11 @@
   Pour tuer une serie de points
 */
-void GeneralFitData::KillData(int i1,int i2)
-{
- ASSERT(i1 >= 0 && i1 < mNData);
- ASSERT(i2 >= 0 && i2 < mNData);
- ASSERT(i1 <= i2 );
-
- for(int i=i1;i<=i2;i++) KillData(i);
+void GeneralFitData::KillData(int_4 i1,int_4 i2)
+{
+ if(i1<0 || i1>=mNData) return;
+ if(i2<0 || i2>=mNData) return;
+ if(i1>i2) return;
+
+ for(int_4 i=i1;i<=i2;i++) KillData(i);
 }
 
@@ -205,12 +224,12 @@
   Pour re-valider le point numero i ([0,NData]).
 */
-void GeneralFitData::ValidData(int i)
-{
- ASSERT(i >= 0 && i < mNData);
+void GeneralFitData::ValidData(int_4 i)
+{
+ if(i<0 || i>=mNData) return;
 
  if( mOK[i] ) return;
  if( mErr[i]<=0. ) return;
  if(mOk_EXP) {
-   for(int j=0;j<mNVar;j++) if(mErrXP[i*mNVar+j]<=0.) return;
+   for(int_4 j=0;j<mNVar;j++) if(mErrXP[i*mNVar+j]<=0.) return;
  }
  mOK[i] = 1;
@@ -221,11 +240,11 @@
   Pour re-valider les points numeros i1 a i2.
 */
-void GeneralFitData::ValidData(int i1,int i2)
-{
- ASSERT(i1 >= 0 && i1 < mNData);
- ASSERT(i2 >= 0 && i2 < mNData);
- ASSERT(i1 <= i2 );
-
- for(int i=i1;i<=i2;i++) ValidData(i);
+void GeneralFitData::ValidData(int_4 i1,int_4 i2)
+{
+ if(i1<0 || i1>=mNData) return;
+ if(i2<0 || i2>=mNData) return;
+ if(i1>i2) return;
+
+ for(int_4 i=i1;i<=i2;i++) ValidData(i);
 }
 
@@ -235,5 +254,5 @@
 void GeneralFitData::ValidData()
 {
- for(int i=0;i<mNData;i++) ValidData(i);
+ for(int_4 i=0;i<mNData;i++) ValidData(i);
 }
 
@@ -242,5 +261,5 @@
   Pour redefinir un point a \f$ {x,[errx] ; f,err} \f$
 */
-void GeneralFitData::RedefineData1(int i,double x,double f,double err,double errx)
+void GeneralFitData::RedefineData1(int_4 i,double x,double f,double err,double errx)
 {
  RedefineData(i,&x,f,err,&errx);
@@ -250,5 +269,5 @@
   Pour redefinir un point a \f$ {x,[errx], y,[erry] ; f,err} \f$ 
 */
-void GeneralFitData::RedefineData2(int i,double x,double y,double f
+void GeneralFitData::RedefineData2(int_4 i,double x,double y,double f
                                   ,double err,double errx,double erry)
 {
@@ -262,17 +281,17 @@
   \f$ {xp[0],[errxp[0]], xp[1],[errxp[1]], xp[2],[errxp[2]],... ; f,err} \f$ 
 */
-void GeneralFitData::RedefineData(int i,double* xp,double f,double err,double* errxp)
-{
- ASSERT(i>=0 && i<mNData);
+void GeneralFitData::RedefineData(int_4 i,double* xp,double f,double err,double* errxp)
+{
+ if(i<0 || i>=mNData) return;
  bool ok = true;
 
- int ip = mNVar*i;
- for(int j=0;j<mNVar;j++) mXP[ip+j] = xp[j];
+ int_4 ip = mNVar*i;
+ for(int_4 j=0;j<mNVar;j++) mXP[ip+j] = xp[j];
  if(mOk_EXP) {
    if(errxp) {
-     for(int j=0;j<mNVar;j++)
+     for(int_4 j=0;j<mNVar;j++)
        {mErrXP[ip+j] = errxp[j]; if(errxp[j]<=0.) ok=false;}
    } else {
-     for(int j=0;j<mNVar;j++) mErrXP[ip+j] = Def_ErrX;
+     for(int_4 j=0;j<mNVar;j++) mErrXP[ip+j] = Def_ErrX;
      ok=false;
    }
@@ -313,15 +332,17 @@
 void GeneralFitData::AddData(double* xp, double f, double err,double* errxp)
 {
- ASSERT(mNData < mNDataAlloc);
+ if(mNData >= mNDataAlloc)
+   {cout<<"GeneralFitData::AddData Error: no space left"<<endl;; return;}
+
  bool ok = true;
 
- int ip = mNVar*mNData;
- for(int i=0;i<mNVar;i++) mXP[ip+i] = xp[i];
+ int_4 ip = mNVar*mNData;
+ for(int_4 i=0;i<mNVar;i++) mXP[ip+i] = xp[i];
  if(mOk_EXP) {
    if(errxp) {
-     for(int j=0;j<mNVar;j++)
+     for(int_4 j=0;j<mNVar;j++)
        {mErrXP[ip+j] = errxp[j]; if(errxp[j]<=0.) ok=false;}
    } else {
-     for(int j=0;j<mNVar;j++) mErrXP[ip+j] = Def_ErrX;
+     for(int_4 j=0;j<mNVar;j++) mErrXP[ip+j] = Def_ErrX;
      ok=false;
    }
@@ -340,6 +361,6 @@
 void GeneralFitData::AddData(float* xp, float f, float err, float* errxp)
 {
- {for(int i=0;i<mNVar;i++) BuffVar[i] = (double) xp[i];}
- if(errxp) for(int i=0;i<mNVar;i++) BuffVar[mNVar+i] = (double) errxp[i];
+ {for(int_4 i=0;i<mNVar;i++) BuffVar[i] = (double) xp[i];}
+ if(errxp) for(int_4 i=0;i<mNVar;i++) BuffVar[mNVar+i] = (double) errxp[i];
  AddData(BuffVar,(double) f,(double)  err,BuffVar+mNVar);
 }
@@ -350,10 +371,12 @@
   \f$ {x(i),[errx(i)] ; f(i),err(i)} \f$
 */
-void GeneralFitData::SetData1(int nData
+void GeneralFitData::SetData1(int_4 nData
             , double* x, double* f, double *err, double *errx)
 {
- ASSERT(nData>0 && mNData+nData<=mNDataAlloc);
-
- for(int i=0;i<nData;i++) {
+ if(nData<=0) return;
+ if(mNData+nData>mNDataAlloc)
+   {cout<<"GeneralFitData::SetData1 Error: no space left"<<endl;; return;}
+
+ for(int_4 i=0;i<nData;i++) {
    double ex = (errx) ? errx[i]: Def_ErrX;
    double ef = (err ) ? err[i]:  Def_ErrF;
@@ -366,10 +389,12 @@
   \f$ {x(i),[errx(i)] ; f(i),err(i)} \f$
 */
-void GeneralFitData::SetData1(int nData
+void GeneralFitData::SetData1(int_4 nData
             , float* x, float* f, float* err, float *errx)
 {
- ASSERT(nData>0 && mNData+nData<=mNDataAlloc);
-
- for(int i=0;i<nData;i++) {
+ if(nData<=0) return;
+ if(mNData+nData>mNDataAlloc)
+   {cout<<"GeneralFitData::SetData1 Error: no space left"<<endl;; return;}
+
+ for(int_4 i=0;i<nData;i++) {
    double ex = (errx) ? (double) errx[i]: Def_ErrX;
    double ef = (err ) ? (double) err[i]:  Def_ErrF;
@@ -382,10 +407,12 @@
   \f$ {x(i),[errx(i)], y(i),[erry(i)], ; f(i),err(i)} \f$
 */
-void GeneralFitData::SetData2(int nData, double* x, double* y, double* f
+void GeneralFitData::SetData2(int_4 nData, double* x, double* y, double* f
                              ,double *err,double *errx,double *erry)
 {
- ASSERT(nData>0 && mNData+nData<=mNDataAlloc);
-
- for(int i=0;i<nData;i++) {
+ if(nData<=0) return;
+ if(mNData+nData>mNDataAlloc)
+   {cout<<"GeneralFitData::SetData2 Error: no space left"<<endl;; return;}
+
+ for(int_4 i=0;i<nData;i++) {
    double ex = (errx) ? (double) errx[i]: Def_ErrX;
    double ey = (erry) ? (double) erry[i]: Def_ErrX;
@@ -399,10 +426,12 @@
  \f$ {x(i),[errx(i)], y(i),[erry(i)], ; f(i),err(i)} \f$
 */
-void GeneralFitData::SetData2(int nData, float* x, float* y, float* f
+void GeneralFitData::SetData2(int_4 nData, float* x, float* y, float* f
                              ,float *err,float *errx,float *erry)
 {
- ASSERT(nData>0 && mNData+nData<=mNDataAlloc);
-
- for(int i=0;i<nData;i++) {
+ if(nData<=0) return;
+ if(mNData+nData>mNDataAlloc)
+   {cout<<"GeneralFitData::SetData2 Error: no space left"<<endl;; return;}
+
+ for(int_4 i=0;i<nData;i++) {
    double ex = (errx) ? (double) errx[i]: Def_ErrX;
    double ey = (erry) ? (double) erry[i]: Def_ErrX;
@@ -426,14 +455,17 @@
   \endverbatim
 */
-void GeneralFitData::SetData(int nData,double** xp, double *f
+void GeneralFitData::SetData(int_4 nData,double** xp, double *f
                             , double *err, double** errxp)
 {
- ASSERT(nData>0 && mNData+nData<=mNDataAlloc);
- if(mOk_EXP && !errxp) {for(int j=0;j<mNVar;j++) BuffVar[mNVar+j] = Def_ErrX;}
-
- for(int i=0;i<nData;i++) {
-   {for(int j=0;j<mNVar;j++) BuffVar[j] = *(xp[j]+i);}
+ if(nData<=0) return;
+ if(mNData+nData>mNDataAlloc)
+   {cout<<"GeneralFitData::SetData Error: no space left"<<endl;; return;}
+
+ if(mOk_EXP && !errxp) {for(int_4 j=0;j<mNVar;j++) BuffVar[mNVar+j] = Def_ErrX;}
+
+ for(int_4 i=0;i<nData;i++) {
+   {for(int_4 j=0;j<mNVar;j++) BuffVar[j] = *(xp[j]+i);}
    if(mOk_EXP && errxp)
-     {for(int j=0;j<mNVar;j++) BuffVar[mNVar+j] = *(errxp[j]+i);}
+     {for(int_4 j=0;j<mNVar;j++) BuffVar[mNVar+j] = *(errxp[j]+i);}
    double ef = (err) ? err[i]:  Def_ErrF;
    AddData(BuffVar,f[i],ef,BuffVar+mNVar);
@@ -444,15 +476,17 @@
   Voir commentaire ci-dessus.
 */
-void GeneralFitData::SetData(int nData,float** xp, float *f
+void GeneralFitData::SetData(int_4 nData,float** xp, float *f
                             , float *err, float** errxp)
 {
- ASSERT(nData>0 && mNData+nData<=mNDataAlloc);
-
- if(mOk_EXP && !errxp) {for(int j=0;j<mNVar;j++) BuffVar[mNVar+j] = Def_ErrX;}
-
- for(int i=0;i<nData;i++) {
-   {for(int j=0;j<mNVar;j++) BuffVar[j] = (double) *(xp[j]+i);}
+ if(nData<=0) return;
+ if(mNData+nData>mNDataAlloc)
+   {cout<<"GeneralFitData::SetData Error: no space left"<<endl;; return;}
+
+ if(mOk_EXP && !errxp) {for(int_4 j=0;j<mNVar;j++) BuffVar[mNVar+j] = Def_ErrX;}
+
+ for(int_4 i=0;i<nData;i++) {
+   {for(int_4 j=0;j<mNVar;j++) BuffVar[j] = (double) *(xp[j]+i);}
    if(mOk_EXP && errxp)
-     {for(int j=0;j<mNVar;j++) BuffVar[mNVar+j] = (double) *(errxp[j]+i);}
+     {for(int_4 j=0;j<mNVar;j++) BuffVar[mNVar+j] = (double) *(errxp[j]+i);}
    double ef = (err) ? err[i]:  Def_ErrF;
    AddData(BuffVar,(double) f[i],ef,BuffVar+mNVar);
@@ -476,13 +510,13 @@
   Impression du point i
 */
-void GeneralFitData::PrintData(int i) const
-{
- ASSERT(i>=0 && i<mNData);
+void GeneralFitData::PrintData(int_4 i) const
+{
+ if(i<0 || i>=mNData) return;
 
  cout<<" "<<i<<" F( ";
- {for(int j=0;j<mNVar;j++) cout<<" "<<Absc(j,i);}
+ {for(int_4 j=0;j<mNVar;j++) cout<<" "<<Absc(j,i);}
  if(mOk_EXP) {
    cout<<"  ;  ";
-   for(int j=0;j<mNVar;j++) cout<<" "<<EAbsc(j,i);
+   for(int_4 j=0;j<mNVar;j++) cout<<" "<<EAbsc(j,i);
  }
  cout<<")= "<<Val(i)<<" "<<EVal(i)<<" ("<<IsValid(i)<<")\n";
@@ -492,5 +526,5 @@
   Impression des points i1 a i2
 */
-void GeneralFitData::PrintData(int i1,int i2) const
+void GeneralFitData::PrintData(int_4 i1,int_4 i2) const
 {
  if(i1<0) i1=0;
@@ -501,5 +535,5 @@
  cout<<"GeneralFitData::PrintData[NData="
      <<mNData<<"/ NDataGood="<<mNDataGood<<"]"<<endl;
- for(int i=i1;i<=i2;i++) PrintData(i);
+ for(int_4 i=i1;i<=i2;i++) PrintData(i);
  cout<<flush;
 }
@@ -510,5 +544,5 @@
 void GeneralFitData::PrintData() const
 {
- ASSERT(mNData>0);
+  if(mNData<=0) return;
 
  PrintData(0,mNData-1);
@@ -523,5 +557,5 @@
 os<<"GeneralFitData:: NVar,ErrX="<<mNVar<<","<<mOk_EXP
   <<" Data: "<<mNData<<" Good,Alloc="<<mNDataGood<<","<<mNDataAlloc<<endl;
-for(int k=0;k<2*NVar()+3;k++) {
+for(int_4 k=0;k<2*NVar()+3;k++) {
   GetMinMax(k,min,max);
   os<<" - "<<k<<" "<<ColumnName(k)<<"  ,  "<<min<<","<<max<<endl;
@@ -543,14 +577,14 @@
   \endverbatim
 */
-int GeneralFitData::GetMnMx(int var,int& imin,int& imax) const
+int_4 GeneralFitData::GetMnMx(int_4 var,int_4& imin,int_4& imax) const
 {
 imin = imax = -1;
-int ix = var/10;
+int_4 ix = var/10;
 var = var%10;
 if(var<0 || var>3) return -1;
 if(var>=2 && (ix<0 || ix>=mNVar) ) return -1;
 double min=1., max=-1.;
-int ntest = 0;
-for(int i=0;i<mNData;i++) {
+int_4 ntest = 0;
+for(int_4 i=0;i<mNData;i++) {
   if( ! IsValid(i) ) continue;
   double v;
@@ -571,11 +605,11 @@
   (cf commentaires GetMnMx).
 */
-int GeneralFitData::GetMnMx(int var,double& min,double& max) const
+int_4 GeneralFitData::GetMnMx(int_4 var,double& min,double& max) const
 {
 min = 1.; max = -1.;
-int imin,imax;
-int ntest = GetMnMx(var,imin,imax);
+int_4 imin,imax;
+int_4 ntest = GetMnMx(var,imin,imax);
 if(ntest<=0) return ntest;
-int ix = var/10;
+int_4 ix = var/10;
 var = var%10;
 if(var==0) {
@@ -606,13 +640,13 @@
   \endverbatim
 */
-int GeneralFitData::GetMeanSigma(int var,double& mean,double& sigma,double min,double max) const
+int_4 GeneralFitData::GetMeanSigma(int_4 var,double& mean,double& sigma,double min,double max) const
 {
 mean = sigma = 0.;
-int ix = var/10;
+int_4 ix = var/10;
 var = var%10;
 if(var<0 || var>3) return -1;
 if(var>=2 && (ix<0 || ix>=mNVar) ) return -1;
-int ntest = 0;
-for(int i=0;i<mNData;i++) {
+int_4 ntest = 0;
+for(int_4 i=0;i<mNData;i++) {
   if( ! IsValid(i) ) continue;
   double v;
@@ -649,16 +683,16 @@
   \endverbatim
 */
-int GeneralFitData::GetMoMeMed(int var,double& mode,double& mean,double& median,
+int_4 GeneralFitData::GetMoMeMed(int_4 var,double& mode,double& mean,double& median,
                                double min,double max,double coeff) const
 {
 mode = mean = median = 0.;
 if(mNData<=0) return -1;
-int ix = var/10;
+int_4 ix = var/10;
 var = var%10;
 if(var<0 || var>3) return -1;
 if(var>=2 && (ix<0 || ix>=mNVar) ) return -1;
 double* buff = new double[mNData];
-int ntest = 0;
-for(int i=0;i<mNData;i++) {
+int_4 ntest = 0;
+for(int_4 i=0;i<mNData;i++) {
   if( ! IsValid(i) ) continue;
   double v;
@@ -677,5 +711,5 @@
   mean /= (double)ntest;
   qsort(buff,(size_t) ntest,sizeof(double),qSort_Dble);
-  int im;
+  int_4 im;
   if(ntest%2==1) {
     // nombre impair de points
@@ -696,5 +730,5 @@
   Cf description ci-dessus ``GetMoMeMed''.
 */
-int GeneralFitData::GetMode(int var,double& mode,double min,double max,double coeff) const
+int_4 GeneralFitData::GetMode(int_4 var,double& mode,double min,double max,double coeff) const
 {
 double mean,median;
@@ -718,5 +752,5 @@
   \endverbatim
 */
-double GeneralFitData::PolFit(int varx,Poly& pol,int degre,bool ey,double xc) const
+double GeneralFitData::PolFit(int_4 varx,Poly& pol,int_4 degre,bool ey,double xc) const
 {
 if(degre<0) return -1.;
@@ -727,6 +761,6 @@
 TVector<r_8> ey2(1);
 if(ey) ey2.Realloc(mNDataGood,true);
-int ntest = 0;
-for(int i=0;i<mNData;i++) {
+int_4 ntest = 0;
+for(int_4 i=0;i<mNData;i++) {
   if( ! IsValid(i) ) continue;
   if(ntest>=mNDataGood) return -5.;
@@ -767,5 +801,5 @@
   \endverbatim
 */
-double GeneralFitData::PolFit(int varx,int vary,Poly2& pol,int degre1,int degre2,bool ez
+double GeneralFitData::PolFit(int_4 varx,int_4 vary,Poly2& pol,int_4 degre1,int_4 degre2,bool ez
                              ,double xc,double yc) const
 {
@@ -779,6 +813,6 @@
 TVector<r_8> ez2(1);
 if(ez) ez2.Realloc(mNDataGood,true);
-int ntest = 0;
-for(int i=0;i<mNData;i++) {
+int_4 ntest = 0;
+for(int_4 i=0;i<mNData;i++) {
   if( ! IsValid(i) ) continue;
   if(ntest>=mNDataGood) return -5.;
@@ -834,7 +868,7 @@
   \endverbatim
 */
-r_8* GeneralFitData::GetVec(int n, r_8* ret)   const
-{
-int i;
+r_8* GeneralFitData::GetVec(int_4 n, r_8* ret)   const
+{
+int_4 i;
 if (ret == NULL) ret = BuffVar;
 for(i=0; i<2*mNVar+3; i++)  ret[i] = 0.;
@@ -853,10 +887,10 @@
   (meme commentaires que pour GetVec).
 */
-r_4* GeneralFitData::GetVecR4(int n, r_4* ret)   const
+r_4* GeneralFitData::GetVecR4(int_4 n, r_4* ret)   const
 {
 if (ret == NULL) ret = BuffVarR4;
 double *buff = new double[2*mNVar+3];
 GetVec(n,buff);
-for(int i=0;i<2*mNVar+3;i++) ret[i] = (float) buff[i];
+for(int_4 i=0;i<2*mNVar+3;i++) ret[i] = (float) buff[i];
 delete [] buff;
 return ret;
@@ -917,5 +951,5 @@
 void GeneralFitData::GetMinMax(sa_size_t k, double& min, double& max)  const
 {
-int var;
+int_4 var;
 if(k<0 || k>=2*NVar()+3) return;
 else if(k<NVar())      var = 10*k+2;          // Variable Xi
@@ -938,5 +972,5 @@
 sa_size_t GeneralFitData::ColumnIndex(string const & nom)  const
 {
-char str[64]; int k = -1;
+char str[64]; int_4 k = -1;
 strcpy(str,nom.c_str()); strip(str,'L',' ');
 if(str[0]=='y') return 2*NVar();
@@ -972,5 +1006,5 @@
 char buff[256];
 string rets;
-int i;
+int_4 i;
 rets = "\ndouble";
 for(i=0; i<mNVar; i++) {
@@ -1081,5 +1115,5 @@
 
 // Allocation de la place (attention Alloc efface mNData,mNDataGood);
-dobj->Alloc(nvar,ndatalloc,-1);
+dobj->Alloc(nvar,ndatalloc,dobj->mOk_EXP);
 dobj->mNData = ndata;
 dobj->mNDataGood = ndatagood;
@@ -1087,15 +1121,15 @@
 // Lecture des datas
 is.GetLine(strg, 255);
-int blen = dobj->mNVar + 3;
+int_4 blen = dobj->mNVar + 3;
 if(dobj->mOk_EXP) blen += dobj->mNVar;
 double *buff = new double[blen];
-for(int i=0;i<dobj->mNData;i++) {
+for(int_4 i=0;i<dobj->mNData;i++) {
   is.Get(buff, blen);
-  int ip = i*dobj->mNVar;
-  {for(int j=0;j<dobj->mNVar;j++)  dobj->mXP[ip+j] = buff[j];}
+  int_4 ip = i*dobj->mNVar;
+  {for(int_4 j=0;j<dobj->mNVar;j++)  dobj->mXP[ip+j] = buff[j];}
   dobj->mF[i] = buff[dobj->mNVar];
   dobj->mErr[i] = buff[dobj->mNVar+1];
   dobj->mOK[i] = (uint_2)(buff[dobj->mNVar+2]+0.01);
-  if(dobj->mOk_EXP) {for(int j=0;j<dobj->mNVar;j++)
+  if(dobj->mOk_EXP) {for(int_4 j=0;j<dobj->mNVar;j++)
                         dobj->mErrXP[ip+j] = buff[dobj->mNVar+3+j];}
 }
@@ -1129,13 +1163,13 @@
 os.PutLine(strg);
 
-int blen = dobj->mNVar + 3;
+int_4 blen = dobj->mNVar + 3;
 if(dobj->mOk_EXP) blen += dobj->mNVar;
 double *buff = new double[blen];
-for(int i=0;i<dobj->mNData;i++) {
-  {for(int j=0;j<dobj->mNVar;j++) buff[j] = dobj->Absc(j,i);}
+for(int_4 i=0;i<dobj->mNData;i++) {
+  {for(int_4 j=0;j<dobj->mNVar;j++) buff[j] = dobj->Absc(j,i);}
   buff[dobj->mNVar] = dobj->Val(i);
   buff[dobj->mNVar+1] = dobj->EVal(i);
   buff[dobj->mNVar+2] = (double) dobj->IsValid(i);
-  if(dobj->mOk_EXP) {for(int j=0;j<dobj->mNVar;j++) buff[dobj->mNVar+3+j] = dobj->EAbsc(j,i);}
+  if(dobj->mOk_EXP) {for(int_4 j=0;j<dobj->mNVar;j++) buff[dobj->mNVar+3+j] = dobj->EAbsc(j,i);}
   os.Put(buff, blen);
 }
Index: trunk/SophyaLib/NTools/generaldata.h
===================================================================
--- trunk/SophyaLib/NTools/generaldata.h	(revision 3018)
+++ trunk/SophyaLib/NTools/generaldata.h	(revision 3062)
@@ -13,4 +13,7 @@
 namespace SOPHYA {
 
+//  Forward class declaration for Fits handler
+template <class T>  class FitsHandler;
+
 class GeneralFit;
 
@@ -23,4 +26,5 @@
   friend class GeneralFit;
   friend class ObjFileIO<GeneralFitData>;
+  friend class FitsHandler<GeneralFitData>;
 public:
   //! Valeurs par defaut pour l'utilisation des erreurs
@@ -30,23 +34,22 @@
     };
 
-  GeneralFitData(unsigned int nVar, unsigned int nDataAlloc, uint_2 errx=0);
+  GeneralFitData(uint_4 nVar, uint_4 nDataAlloc, uint_2 errx=0);
   GeneralFitData(const GeneralFitData& data, bool clean=false);
   GeneralFitData();
   virtual ~GeneralFitData();
 
-  void Alloc(unsigned int nVar, unsigned int nDataAlloc, int_2 errx=-1);
-  void SetDataPtr(int ptr = 0);
-
-  void KillData(int i);
-  void KillData(int i1,int i2);
-
-  void ValidData(int i);
-  void ValidData(int i1,int i2);
+  void SetDataPtr(int_4 ptr = 0);
+
+  void KillData(int_4 i);
+  void KillData(int_4 i1,int_4 i2);
+
+  void ValidData(int_4 i);
+  void ValidData(int_4 i1,int_4 i2);
   void ValidData();
 
-  void RedefineData1(int i,double x,double f,double err=Def_ErrF,double errx=Def_ErrX);
-  void RedefineData2(int i,double x,double y,double f,double err=Def_ErrF
+  void RedefineData1(int_4 i,double x,double f,double err=Def_ErrF,double errx=Def_ErrX);
+  void RedefineData2(int_4 i,double x,double y,double f,double err=Def_ErrF
                     ,double errx=Def_ErrX,double erry=Def_ErrX);
-  void RedefineData(int i,double* xp,double f,double err=Def_ErrF,double* errxp=NULL);
+  void RedefineData(int_4 i,double* xp,double f,double err=Def_ErrF,double* errxp=NULL);
 
   void AddData1(double x, double f, double err=Def_ErrF,double errx=Def_ErrX);
@@ -56,33 +59,36 @@
   void AddData(float* xp, float f, float err=Def_ErrF,float* errxp=NULL);
 
-  void SetData1(int nData,double* x,double* f,double *err=NULL,double *errx=NULL);
-  void SetData1(int nData,float* x,float* f,float* err=NULL,float *errx=NULL);
-  void SetData2(int nData,double* x,double* y,double* f,double *err=NULL
+  void SetData1(int_4 nData,double* x,double* f,double *err=NULL,double *errx=NULL);
+  void SetData1(int_4 nData,float* x,float* f,float* err=NULL,float *errx=NULL);
+  void SetData2(int_4 nData,double* x,double* y,double* f,double *err=NULL
                ,double *errx=NULL,double *erry=NULL);
-  void SetData2(int nData,float* x,float* y,float* f,float* err=NULL
+  void SetData2(int_4 nData,float* x,float* y,float* f,float* err=NULL
                ,float *errx=NULL,float *erry=NULL);
-  void SetData(int nData,double** xp,double *f,double *err=NULL,double** errxp=NULL);
-  void SetData(int nData,float** xp,float* f,float* err=NULL,float** errxp=NULL);
+  void SetData(int_4 nData,double** xp,double *f,double *err=NULL,double** errxp=NULL);
+  void SetData(int_4 nData,float** xp,float* f,float* err=NULL,float** errxp=NULL);
 
   void PrintStatus() const;
-  void PrintData(int i) const;
-  void PrintData(int i1,int i2) const;
+  void PrintData(int_4 i) const;
+  void PrintData(int_4 i1,int_4 i2) const;
   void PrintData() const;
   void Show(ostream& os) const;
   inline void Show() const {Show(cout);}
 
+  //! Operator equal
+  GeneralFitData& operator = (const GeneralFitData& g);
+
   //! Retourne la place restante dans la structure (nombre de donnees que l'on peut encore stoquer).
-  inline int GetSpaceFree() const { return mNDataAlloc - mNData; }
+  inline int_4 GetSpaceFree() const { return mNDataAlloc - mNData; }
   //! Retourne le nombre de variables Xi
-  inline int NVar()       const {return mNVar;}
+  inline int_4 NVar()       const {return mNVar;}
   //! Retourne le nombre de donnees
-  inline int NData()      const {return mNData;}
+  inline int_4 NData()      const {return mNData;}
   //! Retourne le nombre de bonnes donnees (utilisees pour le fit)
-  inline int NDataGood()  const {return mNDataGood;}
+  inline int_4 NDataGood()  const {return mNDataGood;}
   //! Retourne la place maximale allouee pour les donnees
-  inline int NDataAlloc() const {return mNDataAlloc;}
+  inline int_4 NDataAlloc() const {return mNDataAlloc;}
 
   //! Retourne 1 si point valide, sinon 0
-  inline unsigned short int IsValid(int i) const
+  inline unsigned short IsValid(int_4 i) const
                 {if(i>=0 && i<mNData) return mOK[i]; else return 0;}
   //! Retourne ``true'' si il y a des erreurs sur les variables d'abscisse, ``false'' sinon.
@@ -90,54 +96,54 @@
 
   //! Retourne l'abscisse pour 1 dimension (y=f(x)) donnee I
-  inline double X1(int i) const
+  inline double X1(int_4 i) const
                 {if(i>=0 && i<mNData) return mXP[i]; else return 0.;}
   //! Retourne la 1er abscisse (X) pour (v=f(x,y,z,...)) donnee I
-  inline double X(int i) const
+  inline double X(int_4 i) const
                 {if(i>=0 && i<mNData) return mXP[i*mNVar]; else return 0.;}
   //! Retourne la 2sd abscisse (Y) pour (v=f(x,y,z,...)) donnee I
-  inline double Y(int i) const
+  inline double Y(int_4 i) const
                 {if(i>=0 && i<mNData && 1<mNVar) return mXP[i*mNVar+1]; else return 0.;}
   //! etourne la 3ieme abscisse (Z) pour (v=f(x,y,z,...)) donnee I
-  inline double Z(int i) const
+  inline double Z(int_4 i) const
                 {if(i>=0 && i<mNData && 2<mNVar) return mXP[i*mNVar+2]; else return 0.;}
   //! Retourne la Jieme abscisse (Xj) pour (v=f(x0,x1,x2,...)) donnee I
-  inline double Absc(int j,int i) const
+  inline double Absc(int_4 j,int_4 i) const
                 {if(i>=0 && i<mNData && j<mNVar)return mXP[i*mNVar+j]; else return 0.;}
   //! Retourne la valeur de la Ieme donnee
-  inline double Val(int i) const
+  inline double Val(int_4 i) const
                 {if(i>=0 && i<mNData) return mF[i]; else return 0.;}
 
   //! Retourne l'erreur (dx) sur l'abscisse pour 1 dimension (y=f(x)) donnee I
-  inline double EX1(int i) const
+  inline double EX1(int_4 i) const
                 {if(mErrXP && i>=0 && i<mNData) return mErrXP[i]; else return 0.;}
   //! Retourne l'erreur (dx) sur la 1er abscisse (X) pour (v=f(x,y,z,...)) donnee I
-  inline double EX(int i) const
+  inline double EX(int_4 i) const
                 {if(mErrXP && i>=0 && i<mNData) return mErrXP[i*mNVar]; else return 0.;}
   //! Retourne l'erreur (dy) sur la 2sd abscisse (Y) pour (v=f(x,y,z,...)) donnee I
-  inline double EY(int i) const
+  inline double EY(int_4 i) const
                 {if(mErrXP && i>=0 && i<mNData && 1<mNVar) return mErrXP[i*mNVar+1];
                  else return 0.;}
   //! Retourne l'erreur (dz) sur la 3ieme abscisse (Z) pour (v=f(x,y,z,...)) donnee I
-  inline double EZ(int i) const
+  inline double EZ(int_4 i) const
                 {if(mErrXP && i>=0 && i<mNData && 2<mNVar) return mErrXP[i*mNVar+2];
                  else return 0.;}
   //! Retourne l'erreur (dxj) sur la Jieme abscisse (Xj) pour (v=f(x0,x1,x2,...)) donnee I
-  inline double EAbsc(int j,int i) const
+  inline double EAbsc(int_4 j,int_4 i) const
                 {if(mErrXP && i>=0 && i<mNData && j<mNVar) return mErrXP[i*mNVar+j];
                  else return 0.;}
   //! Retourne l'erreur de la Ieme donnee
-  inline double EVal(int i) const
+  inline double EVal(int_4 i) const
                 {if(i>=0 && i<mNData) return mErr[i]; else return 0.;}
 
-  r_8* GetVec(int n, r_8* ret=NULL) const;
-  r_4* GetVecR4(int n, r_4* ret=NULL) const;
-  int GetMnMx(int var,int& imin,int& imax) const;
-  int GetMnMx(int var,double& min,double& max) const;
-  int GetMeanSigma(int var,double& mean,double& sigma,double min=1.,double max=-1.) const;
-  int GetMoMeMed(int var,double& mode,double& mean,double& median,
+  r_8* GetVec(int_4 n, r_8* ret=NULL) const;
+  r_4* GetVecR4(int_4 n, r_4* ret=NULL) const;
+  int_4 GetMnMx(int_4 var,int_4& imin,int_4& imax) const;
+  int_4 GetMnMx(int_4 var,double& min,double& max) const;
+  int_4 GetMeanSigma(int_4 var,double& mean,double& sigma,double min=1.,double max=-1.) const;
+  int_4 GetMoMeMed(int_4 var,double& mode,double& mean,double& median,
                  double min=1.,double max=-1.,double coeff=0.8) const;
-  int GetMode(int var,double& mode,double min=1.,double max=-1.,double coeff=0.8) const;
-  double PolFit(int varx,Poly& pol,int degre,bool ey=true,double xc=0.) const;
-  double PolFit(int varx,int vary,Poly2& pol,int degre1,int degre2=-1,bool ez=true
+  int_4 GetMode(int_4 var,double& mode,double min=1.,double max=-1.,double coeff=0.8) const;
+  double PolFit(int_4 varx,Poly& pol,int_4 degre,bool ey=true,double xc=0.) const;
+  double PolFit(int_4 varx,int_4 vary,Poly2& pol,int_4 degre1,int_4 degre2=-1,bool ez=true
                ,double xc=0.,double yc=0.) const;
   GeneralFitData FitResidus(GeneralFit& gfit) const;
@@ -161,4 +167,5 @@
 
 protected:
+  void Alloc(uint_4 nVar, uint_4 nDataAlloc, uint_2 errx=0);
   void Delete();
 
