| [244] | 1 | #include "machdefs.h" | 
|---|
| [220] | 2 | #include <stdio.h> | 
|---|
|  | 3 | #include <stdlib.h> | 
|---|
|  | 4 | #include <iostream.h> | 
|---|
| [307] | 5 | #include <values.h> | 
|---|
| [220] | 6 | #include <math.h> | 
|---|
|  | 7 | #include <string.h> | 
|---|
|  | 8 | #include <string> | 
|---|
|  | 9 |  | 
|---|
| [490] | 10 | #include "strutil.h" | 
|---|
| [220] | 11 | #include "nbtri.h" | 
|---|
|  | 12 | #include "generalfit.h" | 
|---|
|  | 13 | #include "generaldata.h" | 
|---|
| [307] | 14 | #include "pexceptions.h" | 
|---|
|  | 15 | #include "objfio.h" | 
|---|
| [220] | 16 |  | 
|---|
|  | 17 | //================================================================ | 
|---|
|  | 18 | // GeneralFitData | 
|---|
|  | 19 | //================================================================ | 
|---|
|  | 20 |  | 
|---|
| [926] | 21 | /*! | 
|---|
|  | 22 | \class SOPHYA::GeneralFitData | 
|---|
|  | 23 | \ingroup NTools | 
|---|
|  | 24 | Classe de stoquage de donnees a plusieurs variables avec erreur | 
|---|
|  | 25 | sur l'ordonnee et sur les abscisses (options) : | 
|---|
|  | 26 |  | 
|---|
|  | 27 | \f$ {x0(i),Ex0(i), x1(i),Ex1(i), x2(i),Ex2(i) ... ; Y(i),EY(i)} \f$ | 
|---|
|  | 28 | \verbatim | 
|---|
|  | 29 | Pour memoire, structure du rangement (n=mNVar): | 
|---|
|  | 30 | - Valeur des abscisses mXP (idem pour mErrXP): | 
|---|
|  | 31 | x0,x1,x2,...,xn   x0,x1,x2,...,xn  ....  x0,x1,x2,....,xn | 
|---|
|  | 32 | |  1er point  |   |  2sd point  |  ....  | point mNData | | 
|---|
|  | 33 | Donc abscisse J=[0,mNVar[ du point numero I=[0,mNData[: mXP[I*mNVar+J] | 
|---|
|  | 34 | - Valeur de l'ordonnee mF (idem pour mErr et mOK): | 
|---|
|  | 35 | f                f                      f | 
|---|
|  | 36 | |  1er point  |  |  2sd point  |  .... | point mNData | | 
|---|
|  | 37 | Donc point numero I [0,mNData[ : mF[i] | 
|---|
|  | 38 | \endverbatim | 
|---|
|  | 39 | */ | 
|---|
|  | 40 |  | 
|---|
| [220] | 41 | ////////////////////////////////////////////////////////////////////// | 
|---|
| [914] | 42 | /*! | 
|---|
|  | 43 | Constructeur. ``nVar'' represente la dimension de l'espace des abscisses, | 
|---|
|  | 44 | ``ndatalloc'' le nombre maximum de points et ``errx'' si non nul | 
|---|
|  | 45 | indique que l'on fournit des erreurs sur les ``nVar'' variables en abscisse. | 
|---|
|  | 46 | */ | 
|---|
| [220] | 47 | GeneralFitData::GeneralFitData(unsigned int nVar, unsigned int ndatalloc, uint_2 errx) | 
|---|
|  | 48 | : mNVar(0), mNDataAlloc(0), mNData(0), mNDataGood(0), mOk_EXP(0) | 
|---|
|  | 49 | , mXP(NULL), mErrXP(NULL), mF(NULL), mErr(NULL), mOK(NULL) | 
|---|
|  | 50 | , BuffVar(NULL), BuffVarR4(NULL) | 
|---|
|  | 51 | { | 
|---|
| [307] | 52 | try { | 
|---|
|  | 53 | Alloc(nVar,ndatalloc,errx); | 
|---|
|  | 54 | } catch(PException e) { | 
|---|
|  | 55 | cout << "Exception : " << typeid(e).name() << " " << e.Msg() << endl; | 
|---|
|  | 56 | throw; | 
|---|
| [220] | 57 | } | 
|---|
| [307] | 58 | } | 
|---|
| [220] | 59 |  | 
|---|
| [914] | 60 | /*! | 
|---|
|  | 61 | Constructeur par copie. Si ``clean'' est ``true'' | 
|---|
|  | 62 | seules les donnees valides de ``data'' sont copiees. | 
|---|
|  | 63 | Si ``clean'' est ``false'' (defaut) toutes les donnees | 
|---|
|  | 64 | sont copiees et la taille totale de ``data'' est allouee | 
|---|
|  | 65 | meme si elle est plus grande que la taille des donnees stoquees. | 
|---|
|  | 66 | */ | 
|---|
| [307] | 67 | GeneralFitData::GeneralFitData(const GeneralFitData& data, bool clean) | 
|---|
| [220] | 68 | : mNVar(0), mNDataAlloc(0), mNData(0), mNDataGood(0), mOk_EXP(0) | 
|---|
|  | 69 | , mXP(NULL), mErrXP(NULL), mF(NULL), mErr(NULL), mOK(NULL) | 
|---|
|  | 70 | , BuffVar(NULL), BuffVarR4(NULL) | 
|---|
|  | 71 | { | 
|---|
| [307] | 72 | try { | 
|---|
|  | 73 | Alloc(data.mNVar,((clean)?data.mNDataGood:data.mNDataAlloc),((data.mErrXP)?1:0)); | 
|---|
|  | 74 | } catch(PException e) { | 
|---|
|  | 75 | cout << "Exception : " << typeid(e).name() << " " << e.Msg() << endl; | 
|---|
|  | 76 | throw; | 
|---|
|  | 77 | } | 
|---|
| [220] | 78 |  | 
|---|
|  | 79 | // Remplissage | 
|---|
|  | 80 | if(data.mNData>0) { | 
|---|
|  | 81 | r_8* ret; | 
|---|
|  | 82 | for(int i=0;i<data.mNData;i++) { | 
|---|
|  | 83 | if( clean && data.mOK[i]==0 ) continue; | 
|---|
|  | 84 | ret = data.GetVec(i,NULL); | 
|---|
|  | 85 | memcpy(mXP+mNData*mNVar,ret,mNVar*sizeof(r_8)); | 
|---|
|  | 86 | if(mErrXP) memcpy(mErrXP+mNData*mNVar,ret+mNVar,mNVar*sizeof(r_8)); | 
|---|
|  | 87 | mF[mNData]   = ret[2*mNVar]; | 
|---|
|  | 88 | mErr[mNData] = ret[2*mNVar+1]; | 
|---|
|  | 89 | mOK[mNData]  = (uint_2) (ret[2*mNVar+2]+0.001); | 
|---|
|  | 90 | if(mOK[mNData]!=0) mNDataGood++; | 
|---|
|  | 91 | mNData++; | 
|---|
|  | 92 | } | 
|---|
|  | 93 | } | 
|---|
|  | 94 |  | 
|---|
|  | 95 | END_CONSTRUCTOR | 
|---|
|  | 96 | } | 
|---|
|  | 97 |  | 
|---|
| [914] | 98 | /*! | 
|---|
|  | 99 | Constructeur par defaut. | 
|---|
|  | 100 | */ | 
|---|
| [220] | 101 | GeneralFitData::GeneralFitData() | 
|---|
|  | 102 | : mNVar(0), mNDataAlloc(0), mNData(0), mNDataGood(0), mOk_EXP(0) | 
|---|
|  | 103 | , mXP(NULL), mErrXP(NULL), mF(NULL), mErr(NULL), mOK(NULL) | 
|---|
|  | 104 | , BuffVar(NULL), BuffVarR4(NULL) | 
|---|
|  | 105 | { | 
|---|
|  | 106 | END_CONSTRUCTOR | 
|---|
|  | 107 | } | 
|---|
|  | 108 |  | 
|---|
| [914] | 109 | /*! | 
|---|
|  | 110 | Destructeur | 
|---|
|  | 111 | */ | 
|---|
| [220] | 112 | GeneralFitData::~GeneralFitData() | 
|---|
|  | 113 | { | 
|---|
|  | 114 | Delete(); | 
|---|
|  | 115 | } | 
|---|
|  | 116 |  | 
|---|
|  | 117 | ////////////////////////////////////////////////////////////////////// | 
|---|
| [914] | 118 | /*! | 
|---|
|  | 119 | Pour redefinir la structure de donnees (ou la creer si on a utilise | 
|---|
|  | 120 | le createur par defaut). Voir les explications des arguments | 
|---|
|  | 121 | dans les commentaires du constructeur. Si ``errx''\<0 alors | 
|---|
|  | 122 | la valeur prise est celle definie auparavent. | 
|---|
|  | 123 | */ | 
|---|
| [220] | 124 | void GeneralFitData::Alloc(unsigned int nVar, unsigned int ndatalloc, int_2 errx) | 
|---|
|  | 125 | { | 
|---|
| [490] | 126 | ASSERT( nVar>0 && ndatalloc>0 ); | 
|---|
| [220] | 127 |  | 
|---|
|  | 128 | Delete(); | 
|---|
|  | 129 |  | 
|---|
|  | 130 | if(errx>=0) mOk_EXP = (uint_2) errx; | 
|---|
|  | 131 | mNVar = nVar; | 
|---|
|  | 132 | mNDataAlloc = ndatalloc; | 
|---|
|  | 133 |  | 
|---|
| [307] | 134 | try { | 
|---|
| [220] | 135 | mXP  = new r_8[nVar*ndatalloc]; | 
|---|
|  | 136 | if(mOk_EXP) mErrXP  = new r_8[nVar*ndatalloc]; | 
|---|
|  | 137 | mF   = new r_8[ndatalloc]; | 
|---|
|  | 138 | mErr = new r_8[ndatalloc]; | 
|---|
|  | 139 | mOK  = new uint_2[ndatalloc]; | 
|---|
|  | 140 | BuffVar   = new r_8[2*nVar+3]; | 
|---|
|  | 141 | BuffVarR4 = (r_4 *) BuffVar; | 
|---|
| [307] | 142 | } catch(PException e) { | 
|---|
|  | 143 | throw(AllocationError("GeneralFitData::Alloc allocation error\n")); | 
|---|
| [220] | 144 | } | 
|---|
| [307] | 145 | } | 
|---|
| [220] | 146 |  | 
|---|
|  | 147 | ////////////////////////////////////////////////////////////////////// | 
|---|
| [914] | 148 | /*! | 
|---|
|  | 149 | Gestion des des-allocations | 
|---|
|  | 150 | */ | 
|---|
| [220] | 151 | void GeneralFitData::Delete() | 
|---|
|  | 152 | { | 
|---|
|  | 153 | mNVar = mNDataAlloc = mNData = mNDataGood = 0; | 
|---|
|  | 154 | if( mXP  != NULL ) {delete [] mXP;  mXP  = NULL;} | 
|---|
|  | 155 | if( mErrXP  != NULL ) {delete [] mErrXP;  mErrXP  = NULL;} | 
|---|
|  | 156 | if( mF   != NULL ) {delete [] mF;   mF   = NULL;} | 
|---|
|  | 157 | if( mErr != NULL ) {delete [] mErr; mErr = NULL;} | 
|---|
|  | 158 | if( mOK  != NULL ) {delete [] mOK;  mOK  = NULL;} | 
|---|
|  | 159 | if( BuffVar  != NULL ) {delete [] BuffVar; BuffVar = NULL; BuffVarR4 = NULL;} | 
|---|
|  | 160 | } | 
|---|
|  | 161 |  | 
|---|
|  | 162 | ////////////////////////////////////////////////////////////////////// | 
|---|
| [914] | 163 | /*! | 
|---|
|  | 164 | Remise a zero de la structure pour nouveau remplissage (pas d'arg) | 
|---|
|  | 165 | ou remise a la position ``ptr'' (si arg). Les donnees apres ``ptr'' | 
|---|
|  | 166 | sont sur-ecrites. | 
|---|
|  | 167 | */ | 
|---|
| [220] | 168 | void GeneralFitData::SetDataPtr(int ptr) | 
|---|
|  | 169 | { | 
|---|
| [490] | 170 | ASSERT(ptr >= 0 && ptr < mNDataAlloc); | 
|---|
| [220] | 171 | mNData = ptr; | 
|---|
|  | 172 | mNDataGood = 0; | 
|---|
|  | 173 | if(ptr==0) return; | 
|---|
|  | 174 | for(int i=0;i<mNData;i++) if(mOK[i]) mNDataGood++; | 
|---|
|  | 175 | } | 
|---|
|  | 176 |  | 
|---|
|  | 177 | ////////////////////////////////////////////////////////////////////// | 
|---|
| [914] | 178 | /*! | 
|---|
|  | 179 | Pour tuer un point | 
|---|
|  | 180 | */ | 
|---|
| [220] | 181 | void GeneralFitData::KillData(int i) | 
|---|
|  | 182 | { | 
|---|
| [490] | 183 | ASSERT(i >= 0 && i < mNData); | 
|---|
| [220] | 184 |  | 
|---|
|  | 185 | if( ! mOK[i] ) return; | 
|---|
|  | 186 | mOK[i] = 0; | 
|---|
|  | 187 | mNDataGood--; | 
|---|
|  | 188 | } | 
|---|
|  | 189 |  | 
|---|
| [914] | 190 | /*! | 
|---|
|  | 191 | Pour tuer une serie de points | 
|---|
|  | 192 | */ | 
|---|
| [220] | 193 | void GeneralFitData::KillData(int i1,int i2) | 
|---|
|  | 194 | { | 
|---|
| [490] | 195 | ASSERT(i1 >= 0 && i1 < mNData); | 
|---|
|  | 196 | ASSERT(i2 >= 0 && i2 < mNData); | 
|---|
|  | 197 | ASSERT(i1 <= i2 ); | 
|---|
| [220] | 198 |  | 
|---|
|  | 199 | for(int i=i1;i<=i2;i++) KillData(i); | 
|---|
|  | 200 | } | 
|---|
|  | 201 |  | 
|---|
|  | 202 | ////////////////////////////////////////////////////////////////////// | 
|---|
| [914] | 203 | /*! | 
|---|
|  | 204 | Pour re-valider le point numero i ([0,NData]). | 
|---|
|  | 205 | */ | 
|---|
| [220] | 206 | void GeneralFitData::ValidData(int i) | 
|---|
|  | 207 | { | 
|---|
| [490] | 208 | ASSERT(i >= 0 && i < mNData); | 
|---|
| [220] | 209 |  | 
|---|
|  | 210 | if( mOK[i] ) return; | 
|---|
|  | 211 | if( mErr[i]<=0. ) return; | 
|---|
|  | 212 | if(mOk_EXP) { | 
|---|
|  | 213 | for(int j=0;j<mNVar;j++) if(mErrXP[i*mNVar+j]<=0.) return; | 
|---|
|  | 214 | } | 
|---|
|  | 215 | mOK[i] = 1; | 
|---|
|  | 216 | mNDataGood++; | 
|---|
|  | 217 | } | 
|---|
|  | 218 |  | 
|---|
| [914] | 219 | /*! | 
|---|
|  | 220 | Pour re-valider les points numeros i1 a i2. | 
|---|
|  | 221 | */ | 
|---|
| [220] | 222 | void GeneralFitData::ValidData(int i1,int i2) | 
|---|
|  | 223 | { | 
|---|
| [490] | 224 | ASSERT(i1 >= 0 && i1 < mNData); | 
|---|
|  | 225 | ASSERT(i2 >= 0 && i2 < mNData); | 
|---|
|  | 226 | ASSERT(i1 <= i2 ); | 
|---|
| [220] | 227 |  | 
|---|
|  | 228 | for(int i=i1;i<=i2;i++) ValidData(i); | 
|---|
|  | 229 | } | 
|---|
|  | 230 |  | 
|---|
| [914] | 231 | /*! | 
|---|
|  | 232 | Pour re-valider tous les points. | 
|---|
|  | 233 | */ | 
|---|
| [220] | 234 | void GeneralFitData::ValidData() | 
|---|
|  | 235 | { | 
|---|
|  | 236 | for(int i=0;i<mNData;i++) ValidData(i); | 
|---|
|  | 237 | } | 
|---|
|  | 238 |  | 
|---|
|  | 239 | ////////////////////////////////////////////////////////////////////// | 
|---|
| [914] | 240 | /*! | 
|---|
|  | 241 | Pour redefinir un point a \f$ {x,[errx] ; f,err} \f$ | 
|---|
|  | 242 | */ | 
|---|
| [220] | 243 | void GeneralFitData::RedefineData1(int i,double x,double f,double err,double errx) | 
|---|
|  | 244 | { | 
|---|
|  | 245 | RedefineData(i,&x,f,err,&errx); | 
|---|
|  | 246 | } | 
|---|
|  | 247 |  | 
|---|
| [914] | 248 | /*! | 
|---|
|  | 249 | Pour redefinir un point a \f$ {x,[errx], y,[erry] ; f,err} \f$ | 
|---|
|  | 250 | */ | 
|---|
| [220] | 251 | void GeneralFitData::RedefineData2(int i,double x,double y,double f | 
|---|
|  | 252 | ,double err,double errx,double erry) | 
|---|
|  | 253 | { | 
|---|
|  | 254 | double xp[2] = {x,y}; | 
|---|
|  | 255 | double errxp[2] = {errx,erry}; | 
|---|
|  | 256 | RedefineData(i,xp,f,err,errxp); | 
|---|
|  | 257 | } | 
|---|
|  | 258 |  | 
|---|
| [914] | 259 | /*! | 
|---|
|  | 260 | Pour redefinir un point a | 
|---|
|  | 261 | \f$ {xp[0],[errxp[0]], xp[1],[errxp[1]], xp[2],[errxp[2]],... ; f,err} \f$ | 
|---|
|  | 262 | */ | 
|---|
| [220] | 263 | void GeneralFitData::RedefineData(int i,double* xp,double f,double err,double* errxp) | 
|---|
|  | 264 | { | 
|---|
| [490] | 265 | ASSERT(i>=0 && i<mNData); | 
|---|
| [220] | 266 | bool ok = true; | 
|---|
|  | 267 |  | 
|---|
|  | 268 | int ip = mNVar*i; | 
|---|
|  | 269 | for(int j=0;j<mNVar;j++) mXP[ip+j] = xp[j]; | 
|---|
|  | 270 | if(mOk_EXP) { | 
|---|
|  | 271 | if(errxp) { | 
|---|
|  | 272 | for(int j=0;j<mNVar;j++) | 
|---|
|  | 273 | {mErrXP[ip+j] = errxp[j]; if(errxp[j]<=0.) ok=false;} | 
|---|
|  | 274 | } else { | 
|---|
|  | 275 | for(int j=0;j<mNVar;j++) mErrXP[ip+j] = Def_ErrX; | 
|---|
|  | 276 | ok=false; | 
|---|
|  | 277 | } | 
|---|
|  | 278 | } | 
|---|
|  | 279 | mF[i] = f; | 
|---|
|  | 280 | mErr[i] = err;  if(err<=0.) ok = false; | 
|---|
|  | 281 | if(ok) { | 
|---|
|  | 282 | if(! mOK[i]) {mOK[i]=1; mNDataGood++;} | 
|---|
|  | 283 | } else { | 
|---|
|  | 284 | if(  mOK[i]) {mOK[i]=0; mNDataGood--;} | 
|---|
|  | 285 | } | 
|---|
|  | 286 | } | 
|---|
|  | 287 |  | 
|---|
|  | 288 | ////////////////////////////////////////////////////////////////////// | 
|---|
| [914] | 289 | /*! | 
|---|
|  | 290 | Pour ajouter un point \f$ {x,[errx] ; f,err} \f$ | 
|---|
|  | 291 | */ | 
|---|
| [220] | 292 | void GeneralFitData::AddData1(double x, double f, double err, double errx) | 
|---|
|  | 293 | { | 
|---|
|  | 294 | AddData(&x,f,err,&errx); | 
|---|
|  | 295 | } | 
|---|
|  | 296 |  | 
|---|
| [914] | 297 | /*! | 
|---|
|  | 298 | Pour ajouter un point \f$ {x,[errx], y,[erry] ; f,err} \f$ | 
|---|
|  | 299 | */ | 
|---|
| [220] | 300 | void GeneralFitData::AddData2(double x, double y, double f | 
|---|
|  | 301 | , double err, double errx, double erry) | 
|---|
|  | 302 | { | 
|---|
|  | 303 | double xp[2] = {x,y}; | 
|---|
|  | 304 | double errxp[2] = {errx,erry}; | 
|---|
|  | 305 | AddData(xp,f,err,errxp); | 
|---|
|  | 306 | } | 
|---|
|  | 307 |  | 
|---|
| [914] | 308 | /*! | 
|---|
|  | 309 | Pour ajouter un point | 
|---|
|  | 310 | \f$ {xp[0],[errxp[0]], xp[1],[errxp[1]], xp[2],[errxp[2]],... ; f,err} \f$ | 
|---|
|  | 311 | */ | 
|---|
| [220] | 312 | void GeneralFitData::AddData(double* xp, double f, double err,double* errxp) | 
|---|
|  | 313 | { | 
|---|
| [490] | 314 | ASSERT(mNData < mNDataAlloc); | 
|---|
| [220] | 315 | bool ok = true; | 
|---|
|  | 316 |  | 
|---|
|  | 317 | int ip = mNVar*mNData; | 
|---|
|  | 318 | for(int i=0;i<mNVar;i++) mXP[ip+i] = xp[i]; | 
|---|
|  | 319 | if(mOk_EXP) { | 
|---|
|  | 320 | if(errxp) { | 
|---|
|  | 321 | for(int j=0;j<mNVar;j++) | 
|---|
|  | 322 | {mErrXP[ip+j] = errxp[j]; if(errxp[j]<=0.) ok=false;} | 
|---|
|  | 323 | } else { | 
|---|
|  | 324 | for(int j=0;j<mNVar;j++) mErrXP[ip+j] = Def_ErrX; | 
|---|
|  | 325 | ok=false; | 
|---|
|  | 326 | } | 
|---|
|  | 327 | } | 
|---|
|  | 328 | mF[mNData] = f; | 
|---|
|  | 329 | mErr[mNData] = err; | 
|---|
|  | 330 | if(err<=0.) ok = false; | 
|---|
|  | 331 | if(ok) { mOK[mNData]=1; mNDataGood++; } else mOK[mNData]=0; | 
|---|
|  | 332 | mNData++; | 
|---|
|  | 333 | } | 
|---|
|  | 334 |  | 
|---|
| [914] | 335 | /*! | 
|---|
|  | 336 | Pour ajouter un point | 
|---|
|  | 337 | \f$ {xp[0],[errxp[0]], xp[1],[errxp[1]], xp[2],[errxp[2]],... ; f,err} \f$ | 
|---|
|  | 338 | */ | 
|---|
| [220] | 339 | void GeneralFitData::AddData(float* xp, float f, float err, float* errxp) | 
|---|
|  | 340 | { | 
|---|
|  | 341 | {for(int i=0;i<mNVar;i++) BuffVar[i] = (double) xp[i];} | 
|---|
|  | 342 | if(errxp) for(int i=0;i<mNVar;i++) BuffVar[mNVar+i] = (double) errxp[i]; | 
|---|
|  | 343 | AddData(BuffVar,(double) f,(double)  err,BuffVar+mNVar); | 
|---|
|  | 344 | } | 
|---|
|  | 345 |  | 
|---|
|  | 346 | ////////////////////////////////////////////////////////////////////// | 
|---|
| [914] | 347 | /*! | 
|---|
|  | 348 | Pour remplir la structure de donnees d'un seul coup avec | 
|---|
|  | 349 | \f$ {x(i),[errx(i)] ; f(i),err(i)} \f$ | 
|---|
|  | 350 | */ | 
|---|
| [220] | 351 | void GeneralFitData::SetData1(int nData | 
|---|
|  | 352 | , double* x, double* f, double *err, double *errx) | 
|---|
|  | 353 | { | 
|---|
| [490] | 354 | ASSERT(nData>0 && mNData+nData<=mNDataAlloc); | 
|---|
| [220] | 355 |  | 
|---|
|  | 356 | for(int i=0;i<nData;i++) { | 
|---|
|  | 357 | double ex = (errx) ? errx[i]: Def_ErrX; | 
|---|
|  | 358 | double ef = (err ) ? err[i]:  Def_ErrF; | 
|---|
|  | 359 | AddData1(x[i],f[i],ef,ex); | 
|---|
|  | 360 | } | 
|---|
|  | 361 | } | 
|---|
|  | 362 |  | 
|---|
| [914] | 363 | /*! | 
|---|
|  | 364 | Pour remplir la structure de donnees d'un seul coup avec | 
|---|
|  | 365 | \f$ {x(i),[errx(i)] ; f(i),err(i)} \f$ | 
|---|
|  | 366 | */ | 
|---|
| [220] | 367 | void GeneralFitData::SetData1(int nData | 
|---|
|  | 368 | , float* x, float* f, float* err, float *errx) | 
|---|
|  | 369 | { | 
|---|
| [490] | 370 | ASSERT(nData>0 && mNData+nData<=mNDataAlloc); | 
|---|
| [220] | 371 |  | 
|---|
|  | 372 | for(int i=0;i<nData;i++) { | 
|---|
|  | 373 | double ex = (errx) ? (double) errx[i]: Def_ErrX; | 
|---|
|  | 374 | double ef = (err ) ? (double) err[i]:  Def_ErrF; | 
|---|
|  | 375 | AddData1((double) x[i],(double) f[i],ef,ex); | 
|---|
|  | 376 | } | 
|---|
|  | 377 | } | 
|---|
|  | 378 |  | 
|---|
| [914] | 379 | /*! | 
|---|
|  | 380 | Pour remplir la structure de donnees d'un seul coup avec | 
|---|
|  | 381 | \f$ {x(i),[errx(i)], y(i),[erry(i)], ; f(i),err(i)} \f$ | 
|---|
|  | 382 | */ | 
|---|
| [220] | 383 | void GeneralFitData::SetData2(int nData, double* x, double* y, double* f | 
|---|
|  | 384 | ,double *err,double *errx,double *erry) | 
|---|
|  | 385 | { | 
|---|
| [490] | 386 | ASSERT(nData>0 && mNData+nData<=mNDataAlloc); | 
|---|
| [220] | 387 |  | 
|---|
|  | 388 | for(int i=0;i<nData;i++) { | 
|---|
|  | 389 | double ex = (errx) ? (double) errx[i]: Def_ErrX; | 
|---|
|  | 390 | double ey = (erry) ? (double) erry[i]: Def_ErrX; | 
|---|
|  | 391 | double ef = (err ) ? (double) err[i]:  Def_ErrF; | 
|---|
|  | 392 | AddData2(x[i],y[i],f[i],ef,ex,ey); | 
|---|
|  | 393 | } | 
|---|
|  | 394 | } | 
|---|
|  | 395 |  | 
|---|
| [914] | 396 | /*! | 
|---|
|  | 397 | Pour remplir la structure de donnees d'un seul coup avec | 
|---|
|  | 398 | \f$ {x(i),[errx(i)], y(i),[erry(i)], ; f(i),err(i)} \f$ | 
|---|
|  | 399 | */ | 
|---|
| [220] | 400 | void GeneralFitData::SetData2(int nData, float* x, float* y, float* f | 
|---|
|  | 401 | ,float *err,float *errx,float *erry) | 
|---|
|  | 402 | { | 
|---|
| [490] | 403 | ASSERT(nData>0 && mNData+nData<=mNDataAlloc); | 
|---|
| [220] | 404 |  | 
|---|
|  | 405 | for(int i=0;i<nData;i++) { | 
|---|
|  | 406 | double ex = (errx) ? (double) errx[i]: Def_ErrX; | 
|---|
|  | 407 | double ey = (erry) ? (double) erry[i]: Def_ErrX; | 
|---|
|  | 408 | double ef = (err ) ? (double) err[i]:  Def_ErrF; | 
|---|
|  | 409 | AddData2((double) x[i],(double) y[i],(double) f[i],ef,ex,ey); | 
|---|
|  | 410 | } | 
|---|
|  | 411 | } | 
|---|
|  | 412 |  | 
|---|
| [914] | 413 | /*! | 
|---|
|  | 414 | Pour remplir la structure de donnees d'un seul coup avec | 
|---|
|  | 415 | \f$ {X0(i),[EX0(i)], X1(i),[EX1(i)], X2(i),[EX2(i)], ... ; F(i),Err(i)} \f$ | 
|---|
|  | 416 |  | 
|---|
|  | 417 | Attention: si la structure est n'est pas vide, les tableaux sont copies | 
|---|
|  | 418 | apres les donnees pre-existantes (qui ne sont donc pas detruites). Pour | 
|---|
|  | 419 | effacer les donnees pre-existantes utiliser SetDataPtr(0). | 
|---|
|  | 420 | \verbatim | 
|---|
|  | 421 | Ici **xp est un pointeur sur un tableau de pointeurs tq | 
|---|
|  | 422 | xp[0] = &X0[0], xp[1] = &X1[0], xp[2] = &X2[0] ... | 
|---|
|  | 423 | ou X0,X1,X2,... sont les tableaux X0[nData] X1[nData] X2[nData] ... | 
|---|
|  | 424 | des variables (meme commentaire pour errxp). | 
|---|
|  | 425 | \endverbatim | 
|---|
|  | 426 | */ | 
|---|
| [220] | 427 | void GeneralFitData::SetData(int nData,double** xp, double *f | 
|---|
|  | 428 | , double *err, double** errxp) | 
|---|
|  | 429 | { | 
|---|
| [490] | 430 | ASSERT(nData>0 && mNData+nData<=mNDataAlloc); | 
|---|
| [220] | 431 | if(mOk_EXP && !errxp) {for(int j=0;j<mNVar;j++) BuffVar[mNVar+j] = Def_ErrX;} | 
|---|
|  | 432 |  | 
|---|
|  | 433 | for(int i=0;i<nData;i++) { | 
|---|
|  | 434 | {for(int j=0;j<mNVar;j++) BuffVar[j] = *(xp[j]+i);} | 
|---|
|  | 435 | if(mOk_EXP && errxp) | 
|---|
|  | 436 | {for(int j=0;j<mNVar;j++) BuffVar[mNVar+j] = *(errxp[j]+i);} | 
|---|
|  | 437 | double ef = (err) ? err[i]:  Def_ErrF; | 
|---|
|  | 438 | AddData(BuffVar,f[i],ef,BuffVar+mNVar); | 
|---|
|  | 439 | } | 
|---|
|  | 440 | } | 
|---|
|  | 441 |  | 
|---|
| [914] | 442 | /*! | 
|---|
|  | 443 | Voir commentaire ci-dessus. | 
|---|
|  | 444 | */ | 
|---|
| [220] | 445 | void GeneralFitData::SetData(int nData,float** xp, float *f | 
|---|
|  | 446 | , float *err, float** errxp) | 
|---|
|  | 447 | { | 
|---|
| [490] | 448 | ASSERT(nData>0 && mNData+nData<=mNDataAlloc); | 
|---|
| [220] | 449 |  | 
|---|
|  | 450 | if(mOk_EXP && !errxp) {for(int j=0;j<mNVar;j++) BuffVar[mNVar+j] = Def_ErrX;} | 
|---|
|  | 451 |  | 
|---|
|  | 452 | for(int i=0;i<nData;i++) { | 
|---|
|  | 453 | {for(int j=0;j<mNVar;j++) BuffVar[j] = (double) *(xp[j]+i);} | 
|---|
|  | 454 | if(mOk_EXP && errxp) | 
|---|
|  | 455 | {for(int j=0;j<mNVar;j++) BuffVar[mNVar+j] = (double) *(errxp[j]+i);} | 
|---|
|  | 456 | double ef = (err) ? err[i]:  Def_ErrF; | 
|---|
|  | 457 | AddData(BuffVar,(double) f[i],ef,BuffVar+mNVar); | 
|---|
|  | 458 | } | 
|---|
|  | 459 | } | 
|---|
|  | 460 |  | 
|---|
|  | 461 | ////////////////////////////////////////////////////////////////////// | 
|---|
| [914] | 462 | /*! | 
|---|
|  | 463 | Impression de l'etat de la structure de donnees | 
|---|
|  | 464 | */ | 
|---|
| [220] | 465 | void GeneralFitData::PrintStatus() | 
|---|
|  | 466 | { | 
|---|
|  | 467 | cout<<"GeneralFitData:: "<<endl | 
|---|
|  | 468 | <<"NVar="<<mNVar<<" NDataAlloc="<<mNDataAlloc<<" Ok_EXP="<<mOk_EXP | 
|---|
|  | 469 | <<" ,NData="<<mNData<<" NDataGood="<<mNDataGood<<endl | 
|---|
|  | 470 | <<"  mXP="<<mXP<<"  [mErrXP="<<mErrXP<<"] mF="<<mF<<" mErr="<<mErr | 
|---|
|  | 471 | <<" mOK="<<mOK<<endl; | 
|---|
|  | 472 | } | 
|---|
|  | 473 |  | 
|---|
| [914] | 474 | /*! | 
|---|
|  | 475 | Impression du point i | 
|---|
|  | 476 | */ | 
|---|
| [220] | 477 | void GeneralFitData::PrintData(int i) | 
|---|
|  | 478 | { | 
|---|
| [490] | 479 | ASSERT(i>=0 && i<mNData); | 
|---|
| [220] | 480 |  | 
|---|
|  | 481 | cout<<" "<<i<<" F( "; | 
|---|
|  | 482 | {for(int j=0;j<mNVar;j++) cout<<" "<<Absc(j,i);} | 
|---|
|  | 483 | if(mOk_EXP) { | 
|---|
|  | 484 | cout<<"  ;  "; | 
|---|
|  | 485 | for(int j=0;j<mNVar;j++) cout<<" "<<EAbsc(j,i); | 
|---|
|  | 486 | } | 
|---|
|  | 487 | cout<<")= "<<Val(i)<<" "<<EVal(i)<<" ("<<IsValid(i)<<")\n"; | 
|---|
|  | 488 | } | 
|---|
|  | 489 |  | 
|---|
| [914] | 490 | /*! | 
|---|
|  | 491 | Impression des points i1 a i2 | 
|---|
|  | 492 | */ | 
|---|
| [220] | 493 | void GeneralFitData::PrintData(int i1,int i2) | 
|---|
|  | 494 | { | 
|---|
|  | 495 | if(i1<0) i1=0; | 
|---|
|  | 496 | if(i1>=mNData) i1 = mNData-1; | 
|---|
|  | 497 | if(i2>=mNData) i2 = mNData-1; | 
|---|
|  | 498 | if(i1>i2) i2 = mNData-1; | 
|---|
|  | 499 |  | 
|---|
|  | 500 | cout<<"GeneralFitData::PrintData[NData=" | 
|---|
|  | 501 | <<mNData<<"/ NDataGood="<<mNDataGood<<"]"<<endl; | 
|---|
|  | 502 | for(int i=i1;i<=i2;i++) PrintData(i); | 
|---|
|  | 503 | cout<<flush; | 
|---|
|  | 504 | } | 
|---|
|  | 505 |  | 
|---|
| [914] | 506 | /*! | 
|---|
|  | 507 | Impression de tous les points | 
|---|
|  | 508 | */ | 
|---|
| [220] | 509 | void GeneralFitData::PrintData() | 
|---|
|  | 510 | { | 
|---|
| [490] | 511 | ASSERT(mNData>0); | 
|---|
| [220] | 512 |  | 
|---|
|  | 513 | PrintData(0,mNData-1); | 
|---|
|  | 514 | } | 
|---|
|  | 515 |  | 
|---|
| [914] | 516 | /*! | 
|---|
|  | 517 | Impression de l'etat de la structure de donnees avec bornes sur "s" | 
|---|
|  | 518 | */ | 
|---|
| [490] | 519 | void GeneralFitData::Show(ostream& os) const | 
|---|
|  | 520 | { | 
|---|
|  | 521 | double min,max; | 
|---|
|  | 522 | os<<"GeneralFitData:: NVar,ErrX="<<mNVar<<","<<mOk_EXP | 
|---|
|  | 523 | <<" Data: "<<mNData<<" Good,Alloc="<<mNDataGood<<","<<mNDataAlloc<<endl; | 
|---|
|  | 524 | for(int k=0;k<2*NVar()+3;k++) { | 
|---|
|  | 525 | GetMinMax(k,min,max); | 
|---|
|  | 526 | os<<" - "<<k<<" "<<ColumnName(k)<<"  ,  "<<min<<","<<max<<endl; | 
|---|
|  | 527 | } | 
|---|
|  | 528 | return; | 
|---|
|  | 529 | } | 
|---|
|  | 530 |  | 
|---|
| [220] | 531 | ////////////////////////////////////////////////////////////////////// | 
|---|
| [914] | 532 | /*! | 
|---|
|  | 533 | Retourne les numeros des points de valeurs minimum et maximum | 
|---|
|  | 534 | de la variable ``var'': | 
|---|
|  | 535 | \verbatim | 
|---|
|  | 536 | La variable "var" est de la forme : var = AB avec | 
|---|
|  | 537 | B = 0 : variable d'ordonnee Y (valeur de A indifferente) | 
|---|
|  | 538 | B = 1 : erreur variable d'ordonnee EY (valeur de A indifferente) | 
|---|
|  | 539 | B = 2 : variable d'abscisse X numero A #[0,NVar[ | 
|---|
|  | 540 | B = 3 : erreur variable d'abscisse EX numero A #[0,NVar[ | 
|---|
|  | 541 | - Return NData checked si ok, -1 si probleme. | 
|---|
|  | 542 | \endverbatim | 
|---|
|  | 543 | */ | 
|---|
| [490] | 544 | int GeneralFitData::GetMnMx(int var,int& imin,int& imax) const | 
|---|
| [220] | 545 | { | 
|---|
|  | 546 | imin = imax = -1; | 
|---|
|  | 547 | int ix = var/10; | 
|---|
|  | 548 | var = var%10; | 
|---|
|  | 549 | if(var<0 || var>3) return -1; | 
|---|
|  | 550 | if(var>=2 && (ix<0 || ix>=mNVar) ) return -1; | 
|---|
| [958] | 551 | double min=1., max=-1.; | 
|---|
| [220] | 552 | int ntest = 0; | 
|---|
|  | 553 | for(int i=0;i<mNData;i++) { | 
|---|
|  | 554 | if( ! IsValid(i) ) continue; | 
|---|
|  | 555 | double v; | 
|---|
| [958] | 556 | if(var==1)          v = EVal(i); | 
|---|
|  | 557 | else if(var==2)   v = Absc(ix,i); | 
|---|
|  | 558 | else if(var==3) v = EAbsc(ix,i); | 
|---|
|  | 559 | else          v = Val(i); | 
|---|
| [220] | 560 | if(ntest==0) {min = max = v; imin = imax = i;} | 
|---|
|  | 561 | if(v<min) {min = v; imin = i;} | 
|---|
|  | 562 | if(v>max) {max = v; imax = i;} | 
|---|
|  | 563 | ntest++; | 
|---|
|  | 564 | } | 
|---|
|  | 565 | return ntest; | 
|---|
|  | 566 | } | 
|---|
|  | 567 |  | 
|---|
| [914] | 568 | /*! | 
|---|
|  | 569 | Retourne le minimum et le maximum de la variable ``var'' | 
|---|
|  | 570 | (cf commentaires GetMnMx). | 
|---|
|  | 571 | */ | 
|---|
| [490] | 572 | int GeneralFitData::GetMnMx(int var,double& min,double& max) const | 
|---|
| [220] | 573 | { | 
|---|
|  | 574 | min = 1.; max = -1.; | 
|---|
|  | 575 | int imin,imax; | 
|---|
| [490] | 576 | int ntest = GetMnMx(var,imin,imax); | 
|---|
| [220] | 577 | if(ntest<=0) return ntest; | 
|---|
|  | 578 | int ix = var/10; | 
|---|
|  | 579 | var = var%10; | 
|---|
|  | 580 | if(var==0) { | 
|---|
|  | 581 | if(imin>=0) min = Val(imin); | 
|---|
|  | 582 | if(imax>=0) max = Val(imax); | 
|---|
|  | 583 | } else if(var==1) { | 
|---|
|  | 584 | if(imin>=0) min = EVal(imin); | 
|---|
|  | 585 | if(imax>=0) max = EVal(imax); | 
|---|
|  | 586 | } else if(var==2) { | 
|---|
|  | 587 | if(imin>=0) min = Absc(ix,imin); | 
|---|
|  | 588 | if(imax>=0) max = Absc(ix,imax); | 
|---|
|  | 589 | } else if(var==3) { | 
|---|
|  | 590 | if(imin>=0) min = EAbsc(ix,imin); | 
|---|
|  | 591 | if(imax>=0) max = EAbsc(ix,imax); | 
|---|
|  | 592 | } | 
|---|
|  | 593 | return ntest; | 
|---|
|  | 594 | } | 
|---|
|  | 595 |  | 
|---|
|  | 596 | ////////////////////////////////////////////////////////////////////// | 
|---|
| [914] | 597 | /*! | 
|---|
|  | 598 | // | 
|---|
|  | 599 | Retourne la moyenne et le sigma de la variable ``var'' | 
|---|
|  | 600 | (cf commentaires GetMnMx). | 
|---|
|  | 601 | \verbatim | 
|---|
|  | 602 | - Return : nombre de donnees utilisees, -1 si pb, -2 si sigma<0. | 
|---|
|  | 603 | - Seuls les points valides de valeur entre min,max sont utilises. | 
|---|
|  | 604 | Si min>=max pas de coupures sur les valeurs. | 
|---|
|  | 605 | \endverbatim | 
|---|
|  | 606 | */ | 
|---|
| [220] | 607 | int GeneralFitData::GetMeanSigma(int var,double& mean,double& sigma,double min,double max) | 
|---|
|  | 608 | { | 
|---|
|  | 609 | mean = sigma = 0.; | 
|---|
|  | 610 | int ix = var/10; | 
|---|
|  | 611 | var = var%10; | 
|---|
|  | 612 | if(var<0 || var>3) return -1; | 
|---|
|  | 613 | if(var>=2 && (ix<0 || ix>=mNVar) ) return -1; | 
|---|
|  | 614 | int ntest = 0; | 
|---|
|  | 615 | for(int i=0;i<mNData;i++) { | 
|---|
|  | 616 | if( ! IsValid(i) ) continue; | 
|---|
|  | 617 | double v; | 
|---|
| [958] | 618 | if(var==1)          v = EVal(i); | 
|---|
|  | 619 | else if(var==2)   v = Absc(ix,i); | 
|---|
|  | 620 | else if(var==3) v = EAbsc(ix,i); | 
|---|
|  | 621 | else          v = Val(i); | 
|---|
| [220] | 622 | if(min<max && (v<min || max<v)) continue; | 
|---|
|  | 623 | mean += v; | 
|---|
|  | 624 | sigma += v*v; | 
|---|
|  | 625 | ntest++; | 
|---|
|  | 626 | } | 
|---|
|  | 627 | if(ntest==0) { | 
|---|
|  | 628 | mean = sigma = 0.; | 
|---|
|  | 629 | } else { | 
|---|
|  | 630 | mean /= (double)ntest; | 
|---|
|  | 631 | sigma = sigma/(double)ntest - mean*mean; | 
|---|
|  | 632 | if(sigma<0.) ntest = -2; | 
|---|
|  | 633 | else if(sigma>0.) sigma = sqrt(sigma); | 
|---|
|  | 634 | } | 
|---|
|  | 635 | return ntest; | 
|---|
|  | 636 | } | 
|---|
|  | 637 |  | 
|---|
| [914] | 638 | /*! | 
|---|
|  | 639 | Retourne le mode de la variable ``var'' | 
|---|
|  | 640 | (cf commentaires GetMnMx). | 
|---|
|  | 641 | \verbatim | 
|---|
|  | 642 | - Return : nombre de donnees utilisees, -1 si pb. | 
|---|
|  | 643 | - Seuls les points valides de valeur entre min,max sont utilises. | 
|---|
|  | 644 | Si min>=max pas de coupures sur les valeurs. | 
|---|
|  | 645 | - Le calcul du mode est approximee par la formule: | 
|---|
|  | 646 | Mode = Median - coeff*(Mean-Median)   (def: coeff=0.8) | 
|---|
|  | 647 | - Kendall and Stuart donne coeff=2., mais coeff peut etre regle. | 
|---|
|  | 648 | \endverbatim | 
|---|
|  | 649 | */ | 
|---|
| [220] | 650 | int GeneralFitData::GetMoMeMed(int var,double& mode,double& mean,double& median, | 
|---|
|  | 651 | double min,double max,double coeff) | 
|---|
|  | 652 | { | 
|---|
|  | 653 | mode = mean = median = 0.; | 
|---|
|  | 654 | if(mNData<=0) return -1; | 
|---|
|  | 655 | int ix = var/10; | 
|---|
|  | 656 | var = var%10; | 
|---|
|  | 657 | if(var<0 || var>3) return -1; | 
|---|
|  | 658 | if(var>=2 && (ix<0 || ix>=mNVar) ) return -1; | 
|---|
|  | 659 | double* buff = new double[mNData]; | 
|---|
|  | 660 | int ntest = 0; | 
|---|
|  | 661 | for(int i=0;i<mNData;i++) { | 
|---|
|  | 662 | if( ! IsValid(i) ) continue; | 
|---|
|  | 663 | double v; | 
|---|
| [958] | 664 | if(var==1)          v = EVal(i); | 
|---|
|  | 665 | else if(var==2)   v = Absc(ix,i); | 
|---|
|  | 666 | else if(var==3) v = EAbsc(ix,i); | 
|---|
|  | 667 | else          v = Val(i); | 
|---|
| [220] | 668 | if(min<max && (v<min || max<v)) continue; | 
|---|
|  | 669 | buff[ntest] = v; | 
|---|
|  | 670 | mean += v; | 
|---|
|  | 671 | ntest++; | 
|---|
|  | 672 | } | 
|---|
|  | 673 | if(ntest==0) { | 
|---|
|  | 674 | mean = 0.; | 
|---|
|  | 675 | } else { | 
|---|
|  | 676 | mean /= (double)ntest; | 
|---|
|  | 677 | qsort(buff,(size_t) ntest,sizeof(double),qSort_Dble); | 
|---|
|  | 678 | int im; | 
|---|
|  | 679 | if(ntest%2==1) { | 
|---|
|  | 680 | // nombre impair de points | 
|---|
|  | 681 | im = ntest/2; | 
|---|
|  | 682 | median = buff[im]; | 
|---|
|  | 683 | } else { | 
|---|
|  | 684 | // nombre pair de points | 
|---|
|  | 685 | im = (ntest-1)/2; | 
|---|
|  | 686 | median = (buff[im]+buff[im+1])/2.; | 
|---|
|  | 687 | } | 
|---|
|  | 688 | mode = median - coeff*(mean-median); | 
|---|
|  | 689 | } | 
|---|
|  | 690 | delete [] buff; | 
|---|
|  | 691 | return ntest; | 
|---|
|  | 692 | } | 
|---|
|  | 693 |  | 
|---|
| [914] | 694 | /*! | 
|---|
|  | 695 | Cf description ci-dessus ``GetMoMeMed''. | 
|---|
|  | 696 | */ | 
|---|
| [220] | 697 | int GeneralFitData::GetMode(int var,double& mode,double min,double max,double coeff) | 
|---|
|  | 698 | { | 
|---|
|  | 699 | double mean,median; | 
|---|
|  | 700 | return GetMoMeMed(var,mode,mean,median,min,max,coeff); | 
|---|
|  | 701 | } | 
|---|
|  | 702 |  | 
|---|
|  | 703 | ////////////////////////////////////////////////////////////////////// | 
|---|
| [914] | 704 | /*! | 
|---|
|  | 705 | Pour fiter un polynome de degre ``degre''. On fite | 
|---|
|  | 706 | Y=f(X) ou Y=Val et X=Absc(varx). Si ``ey'' est ``true'' | 
|---|
|  | 707 | le fit prend en compte les erreurs stoquees dans EVal, | 
|---|
|  | 708 | sinon fit sans erreurs. Le resultat du fit est retourne | 
|---|
|  | 709 | dans le polynome ``pol''. | 
|---|
|  | 710 | \verbatim | 
|---|
|  | 711 | Return: | 
|---|
|  | 712 | -   Res = le residu du fit | 
|---|
|  | 713 | -   -1 si degre<0 | 
|---|
|  | 714 | -   -2 si probleme sur numero de variable X | 
|---|
|  | 715 | -   -4 si NDataGood<0 | 
|---|
|  | 716 | -   -5 si nombre de data trouves different de NDataGood | 
|---|
|  | 717 | \endverbatim | 
|---|
|  | 718 | */ | 
|---|
| [220] | 719 | double GeneralFitData::PolFit(int varx,Poly& pol,int degre,bool ey) | 
|---|
|  | 720 | { | 
|---|
|  | 721 | if(degre<0) return -1.; | 
|---|
|  | 722 | if(varx<0 || varx>=mNVar) return -2.; | 
|---|
|  | 723 | if(mNDataGood<=0) return -4.; | 
|---|
| [938] | 724 | TVector<r_8> x(mNDataGood); | 
|---|
|  | 725 | TVector<r_8> y(mNDataGood); | 
|---|
|  | 726 | TVector<r_8> ey2(1); | 
|---|
| [220] | 727 | if(ey) ey2.Realloc(mNDataGood,true); | 
|---|
|  | 728 | int ntest = 0; | 
|---|
|  | 729 | for(int i=0;i<mNData;i++) { | 
|---|
|  | 730 | if( ! IsValid(i) ) continue; | 
|---|
|  | 731 | if(ntest>=mNDataGood) return -5.; | 
|---|
|  | 732 | x(ntest) = Absc(varx,i); | 
|---|
|  | 733 | y(ntest) = Val(i); | 
|---|
|  | 734 | if(ey) ey2(ntest) = EVal(i)*EVal(i); | 
|---|
|  | 735 | ntest++; | 
|---|
|  | 736 | } | 
|---|
|  | 737 | double res = 0.; | 
|---|
|  | 738 | if(ey) { | 
|---|
| [938] | 739 | TVector<r_8> errcoef(1); | 
|---|
| [220] | 740 | res = pol.Fit(x,y,ey2,degre,errcoef); | 
|---|
|  | 741 | } else { | 
|---|
|  | 742 | res = pol.Fit(x,y,degre); | 
|---|
|  | 743 | } | 
|---|
|  | 744 | return res; | 
|---|
|  | 745 | } | 
|---|
|  | 746 |  | 
|---|
| [914] | 747 | /*! | 
|---|
|  | 748 | Pour fiter un polynome de degre ``degre1''. On fite | 
|---|
|  | 749 | Z=f(X,Y) ou Z=Val et X=Absc(varx) et Y=Absc(vary). | 
|---|
|  | 750 | Si ``ey'' est ``true'' le fit prend en compte les erreurs | 
|---|
|  | 751 | stoquees dans EVal, sinon fit sans erreurs. Si ``degre2'' | 
|---|
|  | 752 | negatif, le fit determine un polynome en X,Y de degre | 
|---|
|  | 753 | total ``degre`''. Si ``degre2'' positif ou nul, le fit | 
|---|
|  | 754 | demande un fit de ``degre1'' pour la variable X et de degre | 
|---|
|  | 755 | ``degre2'' sur la variable Y. Le resultat du fit est retourne | 
|---|
|  | 756 | dans le polynome ``pol''. | 
|---|
|  | 757 | \verbatim | 
|---|
|  | 758 | Return: | 
|---|
|  | 759 | -   Res = le residu du fit | 
|---|
|  | 760 | -   -1 si degre<0 | 
|---|
|  | 761 | -   -2 si probleme sur numero de variable X | 
|---|
|  | 762 | -   -3 si probleme sur numero de variable Y | 
|---|
|  | 763 | -   -4 si NDataGood<0 | 
|---|
|  | 764 | -   -5 si nombre de data trouves different de NDataGood | 
|---|
|  | 765 | \endverbatim | 
|---|
|  | 766 | */ | 
|---|
| [220] | 767 | double GeneralFitData::PolFit(int varx,int vary,Poly2& pol,int degre1,int degre2,bool ez) | 
|---|
|  | 768 | { | 
|---|
|  | 769 | if(degre1<0) return -1.; | 
|---|
|  | 770 | if(varx<0 || varx>=mNVar) return -2.; | 
|---|
|  | 771 | if(vary<0 || vary>=mNVar || vary==varx) return -3.; | 
|---|
|  | 772 | if(mNDataGood<=0) return -4.; | 
|---|
| [938] | 773 | TVector<r_8> x(mNDataGood); | 
|---|
|  | 774 | TVector<r_8> y(mNDataGood); | 
|---|
|  | 775 | TVector<r_8> z(mNDataGood); | 
|---|
|  | 776 | TVector<r_8> ez2(1); | 
|---|
| [220] | 777 | if(ez) ez2.Realloc(mNDataGood,true); | 
|---|
|  | 778 | int ntest = 0; | 
|---|
|  | 779 | for(int i=0;i<mNData;i++) { | 
|---|
|  | 780 | if( ! IsValid(i) ) continue; | 
|---|
|  | 781 | if(ntest>=mNDataGood) return -5.; | 
|---|
|  | 782 | x(ntest) = Absc(varx,i); | 
|---|
|  | 783 | y(ntest) = Absc(vary,i); | 
|---|
|  | 784 | z(ntest) = Val(i); | 
|---|
|  | 785 | if(ez) ez2(ntest) = EVal(i)*EVal(i); | 
|---|
|  | 786 | ntest++; | 
|---|
|  | 787 | } | 
|---|
|  | 788 | double res = 0.; | 
|---|
|  | 789 | if(ez) { | 
|---|
| [938] | 790 | TVector<r_8> errcoef(1); | 
|---|
| [220] | 791 | if(degre2>0) res = pol.Fit(x,y,z,ez2,degre1,degre2,errcoef); | 
|---|
|  | 792 | else         res = pol.Fit(x,y,z,ez2,degre1,errcoef); | 
|---|
|  | 793 | } else { | 
|---|
|  | 794 | if(degre2>0) res = pol.Fit(x,y,z,degre1,degre2); | 
|---|
|  | 795 | else         res = pol.Fit(x,y,z,degre1); | 
|---|
|  | 796 | } | 
|---|
|  | 797 | return res; | 
|---|
|  | 798 | } | 
|---|
|  | 799 |  | 
|---|
|  | 800 | ////////////////////////////////////////////////////////////////////// | 
|---|
| [914] | 801 | /*! | 
|---|
|  | 802 | Retourne une classe contenant les residus du fit ``gfit''. | 
|---|
|  | 803 | */ | 
|---|
| [307] | 804 | GeneralFitData GeneralFitData::FitResidus(GeneralFit& gfit) | 
|---|
| [220] | 805 | { | 
|---|
| [307] | 806 | if(gfit.GetNVar()!=mNVar) | 
|---|
|  | 807 | throw(SzMismatchError("GeneralFitData::FitResidus: size mismatch\n")); | 
|---|
| [220] | 808 | return gfit.DataResidus(true); | 
|---|
|  | 809 | } | 
|---|
|  | 810 |  | 
|---|
| [914] | 811 | /*! | 
|---|
|  | 812 | Retourne une classe contenant la function du fit ``gfit''. | 
|---|
|  | 813 | */ | 
|---|
| [307] | 814 | GeneralFitData GeneralFitData::FitFunction(GeneralFit& gfit) | 
|---|
| [220] | 815 | { | 
|---|
| [307] | 816 | if(gfit.GetNVar()!=mNVar) | 
|---|
|  | 817 | throw(SzMismatchError("GeneralFitData::FitFunction: size mismatch\n")); | 
|---|
| [220] | 818 | return gfit.DataFunction(true); | 
|---|
|  | 819 | } | 
|---|
|  | 820 |  | 
|---|
|  | 821 | ////////////////////////////////////////////////////////////////////// | 
|---|
| [914] | 822 | /*! | 
|---|
|  | 823 | // | 
|---|
|  | 824 | Retourne la donnee `n' dans le vecteur de double `ret'. | 
|---|
|  | 825 | \verbatim | 
|---|
|  | 826 | Par defaut, ret=NULL et le buffer interne de la classe est retourne | 
|---|
|  | 827 | - Les donnees sont rangees dans l'ordre: | 
|---|
|  | 828 | x0,x1,x2,... ; ex0,ex1,ex2,...  ; y ; ey ; ok(0/1) | 
|---|
|  | 829 | |<- NVar ->| + |<-   NVar   ->| + 1 +  1 +  1 | 
|---|
|  | 830 | Le vecteur ret a la taille 2*NVar+2+1 | 
|---|
|  | 831 | \endverbatim | 
|---|
|  | 832 | */ | 
|---|
| [220] | 833 | r_8* GeneralFitData::GetVec(int n, r_8* ret)   const | 
|---|
|  | 834 | { | 
|---|
|  | 835 | int i; | 
|---|
|  | 836 | if (ret == NULL) ret = BuffVar; | 
|---|
|  | 837 | for(i=0; i<2*mNVar+3; i++)  ret[i] = 0.; | 
|---|
|  | 838 | if (n >= mNData) return(ret); | 
|---|
|  | 839 |  | 
|---|
|  | 840 | memcpy(ret, mXP+n*mNVar, mNVar*sizeof(r_8)); | 
|---|
|  | 841 | if(mErrXP) memcpy(ret+mNVar, mErrXP+n*mNVar, mNVar*sizeof(r_8)); | 
|---|
|  | 842 | ret[2*mNVar] = mF[n]; | 
|---|
|  | 843 | ret[2*mNVar+1] = mErr[n]; | 
|---|
|  | 844 | ret[2*mNVar+2] = (double) mOK[n]; | 
|---|
|  | 845 | return(ret); | 
|---|
|  | 846 | } | 
|---|
|  | 847 |  | 
|---|
| [914] | 848 | /*! | 
|---|
|  | 849 | Retourne la donnee `n' dans le vecteur de float `ret' | 
|---|
|  | 850 | (meme commentaires que pour GetVec). | 
|---|
|  | 851 | */ | 
|---|
| [220] | 852 | r_4* GeneralFitData::GetVecR4(int n, r_4* ret)   const | 
|---|
|  | 853 | { | 
|---|
|  | 854 | if (ret == NULL) ret = BuffVarR4; | 
|---|
|  | 855 | double *buff = new double[2*mNVar+3]; | 
|---|
|  | 856 | GetVec(n,buff); | 
|---|
|  | 857 | for(int i=0;i<2*mNVar+3;i++) ret[i] = (float) buff[i]; | 
|---|
|  | 858 | delete [] buff; | 
|---|
|  | 859 | return ret; | 
|---|
|  | 860 | } | 
|---|
|  | 861 |  | 
|---|
|  | 862 | ////////////////////////////////////////////////////////////////////// | 
|---|
| [490] | 863 | // ------- Implementation de  l interface NTuple  --------- | 
|---|
|  | 864 |  | 
|---|
| [914] | 865 | /*! | 
|---|
|  | 866 | Retourne le nombre de ligne = NData() (pour interface NTuple) | 
|---|
|  | 867 | */ | 
|---|
| [490] | 868 | uint_4 GeneralFitData::NbLines() const | 
|---|
| [307] | 869 | { | 
|---|
| [490] | 870 | return(NData()); | 
|---|
| [307] | 871 | } | 
|---|
|  | 872 |  | 
|---|
| [914] | 873 | /*! | 
|---|
|  | 874 | Retourne le nombre de colonnes du ntuple equivalent: | 
|---|
|  | 875 | \verbatim | 
|---|
|  | 876 | Exemple: on a une fonction sur un espace a 4 dimensions: | 
|---|
|  | 877 | "x0,x1,x2,x3    , ex0,ex1,ex2,ex3    , y,   ey ,    ok" | 
|---|
|  | 878 | 0  1  2  3        4   5   6   7      8     9      10 | 
|---|
|  | 879 | |        |        |           |      |     |       | | 
|---|
|  | 880 | 0       nv-1     nv         2*nv-1  2*nv  2*nv+1  2*nv+2 | 
|---|
|  | 881 | soit 2*nvar+3 variables/colonnes. | 
|---|
|  | 882 | \endverbatim | 
|---|
|  | 883 | (pour interface NTuple) | 
|---|
|  | 884 | */ | 
|---|
| [490] | 885 | uint_4 GeneralFitData::NbColumns() const | 
|---|
| [307] | 886 | { | 
|---|
| [490] | 887 | return(2*NVar()+3); | 
|---|
| [307] | 888 | } | 
|---|
|  | 889 |  | 
|---|
| [914] | 890 | //! Pour interface NTuple | 
|---|
| [490] | 891 | r_8 * GeneralFitData::GetLineD(int n) const | 
|---|
|  | 892 | { | 
|---|
|  | 893 | return(GetVec(n,NULL)); | 
|---|
| [307] | 894 | } | 
|---|
|  | 895 |  | 
|---|
| [914] | 896 | //! Pour interface NTuple | 
|---|
| [490] | 897 | r_8 GeneralFitData::GetCell(int n, int k) const | 
|---|
|  | 898 | { | 
|---|
|  | 899 | if(k<0 || k>=2*NVar()+3) return 0.; | 
|---|
|  | 900 | r_8 * val = GetVec(n,NULL); | 
|---|
|  | 901 | return val[k]; | 
|---|
| [307] | 902 | } | 
|---|
|  | 903 |  | 
|---|
| [914] | 904 | //! Pour interface NTuple | 
|---|
| [490] | 905 | r_8 GeneralFitData::GetCell(int n, string const & nom) const | 
|---|
| [307] | 906 | { | 
|---|
| [490] | 907 | int k = ColumnIndex(nom); | 
|---|
|  | 908 | return(GetCell(n,k)); | 
|---|
| [307] | 909 | } | 
|---|
|  | 910 |  | 
|---|
| [914] | 911 | /*! | 
|---|
|  | 912 | Retourne le minimum et le maximum de la variable `k' (pour interface NTuple). | 
|---|
|  | 913 | */ | 
|---|
| [490] | 914 | void GeneralFitData::GetMinMax(int k, double& min, double& max)  const | 
|---|
| [307] | 915 | { | 
|---|
| [490] | 916 | int var; | 
|---|
|  | 917 | if(k<0 || k>=2*NVar()+3) return; | 
|---|
|  | 918 | else if(k<NVar())      var = 10*k+2;          // Variable Xi | 
|---|
|  | 919 | else if(k<2*NVar())    var = 10*(k-NVar())+3; // Variable EXi | 
|---|
|  | 920 | else if(k==2*NVar())   var = 0;               // Variable Y | 
|---|
|  | 921 | else if(k==2*NVar()+1) var = 1;               // Variable EY | 
|---|
|  | 922 | else {min=0.; max=1.; return;}                // Variable Ok | 
|---|
|  | 923 | GetMnMx(var,min,max); | 
|---|
|  | 924 | return; | 
|---|
| [307] | 925 | } | 
|---|
|  | 926 |  | 
|---|
| [914] | 927 | //! Pour interface NTuple | 
|---|
| [490] | 928 | void GeneralFitData::GetMinMax(string const & nom, double& min, double& max)   const | 
|---|
| [307] | 929 | { | 
|---|
| [490] | 930 | int k = ColumnIndex(nom); | 
|---|
|  | 931 | GetMinMax(k,min,max); | 
|---|
|  | 932 | } | 
|---|
|  | 933 |  | 
|---|
| [914] | 934 | //! Pour interface NTuple | 
|---|
| [490] | 935 | int GeneralFitData::ColumnIndex(string const & nom)  const | 
|---|
|  | 936 | { | 
|---|
|  | 937 | char str[64]; int k = -1; | 
|---|
|  | 938 | strcpy(str,nom.c_str()); strip(str,'L',' '); | 
|---|
|  | 939 | if(str[0]=='y') return 2*NVar(); | 
|---|
|  | 940 | if(str[0]=='o') return 2*NVar()+2; | 
|---|
|  | 941 | if(str[0]=='x') {sscanf(str,"x%d",&k); return k;} | 
|---|
|  | 942 | if(str[0]=='e') | 
|---|
|  | 943 | if(str[1]=='y') return 2*NVar()+1; | 
|---|
|  | 944 | else if(str[1]=='x') {sscanf(str,"ex%d",&k); return NVar()+k;} | 
|---|
|  | 945 | return -1; | 
|---|
|  | 946 | } | 
|---|
|  | 947 |  | 
|---|
| [914] | 948 | //! Pour interface NTuple | 
|---|
| [490] | 949 | string GeneralFitData::ColumnName(int k) const | 
|---|
|  | 950 | { | 
|---|
|  | 951 | if(k==2*NVar())                return string("y"); | 
|---|
|  | 952 | else if(k==2*NVar()+1)         return string("ey"); | 
|---|
|  | 953 | else if(k==2*NVar()+2)         return string("ok"); | 
|---|
|  | 954 | else if(k<0 || k>=2*NVar()+3)  return string(""); | 
|---|
|  | 955 |  | 
|---|
|  | 956 | char str[64] = ""; | 
|---|
|  | 957 | if(k<NVar()) sprintf(str,"x%d",k); | 
|---|
|  | 958 | else if(k<2*NVar()) sprintf(str,"ex%d",k-NVar()); | 
|---|
|  | 959 | return string(str); | 
|---|
|  | 960 | } | 
|---|
|  | 961 |  | 
|---|
| [914] | 962 | /*! | 
|---|
|  | 963 | Retourne une chaine de caracteres avec la declaration des noms de | 
|---|
|  | 964 | variables. si "nomx!=NULL" , des instructions d'affectation | 
|---|
|  | 965 | a partir d'un tableau "nomx[i]" sont ajoutees (pour interface NTuple). | 
|---|
|  | 966 | */ | 
|---|
| [490] | 967 | string GeneralFitData::VarList_C(const char* nomx)  const | 
|---|
|  | 968 | { | 
|---|
|  | 969 | char buff[256]; | 
|---|
|  | 970 | string rets; | 
|---|
|  | 971 | int i; | 
|---|
|  | 972 | rets = "\ndouble"; | 
|---|
|  | 973 | for(i=0; i<mNVar; i++) { | 
|---|
|  | 974 | sprintf(buff," x%d, ex%d",i,i); | 
|---|
|  | 975 | rets += buff; | 
|---|
|  | 976 | if(i!=mNVar-1) rets += ","; else rets += ";\n"; | 
|---|
|  | 977 | } | 
|---|
|  | 978 | sprintf(buff,"\ndouble y, ey, ok;\n"); | 
|---|
|  | 979 | rets += buff; | 
|---|
|  | 980 | if (nomx) { | 
|---|
|  | 981 | for(i=0; i<mNVar; i++) { | 
|---|
|  | 982 | sprintf(buff,"x%d=%s[%d];\n", i, nomx, i); | 
|---|
|  | 983 | rets += buff; | 
|---|
|  | 984 | } | 
|---|
|  | 985 | for(i=0; i<mNVar; i++) { | 
|---|
|  | 986 | sprintf(buff,"ex%d=%s[%d];\n", i, nomx, mNVar+i); | 
|---|
|  | 987 | rets += buff; | 
|---|
|  | 988 | } | 
|---|
|  | 989 | } | 
|---|
|  | 990 | sprintf(buff,"y=%s[%d];\ney=%s[%d];\nok=%s[%d];\n" | 
|---|
|  | 991 | ,nomx,2*mNVar,nomx,2*mNVar+1,nomx,2*mNVar+2); | 
|---|
|  | 992 | rets += buff; | 
|---|
|  | 993 |  | 
|---|
|  | 994 | return(rets); | 
|---|
|  | 995 | } | 
|---|
|  | 996 |  | 
|---|
|  | 997 | /////////////////////////////////////////////////////////// | 
|---|
|  | 998 | // -------------------------------------------------------- | 
|---|
|  | 999 | //   Les objets delegues pour la gestion de persistance | 
|---|
|  | 1000 | // -------------------------------------------------------- | 
|---|
|  | 1001 | /////////////////////////////////////////////////////////// | 
|---|
|  | 1002 |  | 
|---|
|  | 1003 |  | 
|---|
|  | 1004 | void ObjFileIO<GeneralFitData>::ReadSelf(PInPersist& is) | 
|---|
|  | 1005 | { | 
|---|
| [307] | 1006 | char strg[256]; | 
|---|
|  | 1007 |  | 
|---|
|  | 1008 | if(dobj==NULL) dobj=new GeneralFitData; | 
|---|
|  | 1009 | else         dobj->Delete(); | 
|---|
|  | 1010 |  | 
|---|
|  | 1011 | // Lecture entete | 
|---|
|  | 1012 | is.GetLine(strg, 255); | 
|---|
|  | 1013 |  | 
|---|
|  | 1014 | // Ecriture des valeurs de definitions | 
|---|
|  | 1015 | int_4 nvar,ndatalloc,ndata,ndatagood; | 
|---|
|  | 1016 | is.Get(nvar); | 
|---|
|  | 1017 | is.Get(ndatalloc); | 
|---|
|  | 1018 | is.Get(ndata); | 
|---|
|  | 1019 | is.Get(ndatagood); | 
|---|
|  | 1020 | is.Get(dobj->mOk_EXP); | 
|---|
|  | 1021 | if(nvar<=0 || ndatalloc<=0 || ndata<=0 || ndatagood<0 || ndatalloc<ndata) return; | 
|---|
|  | 1022 |  | 
|---|
|  | 1023 | // Allocation de la place (attention Alloc efface mNData,mNDataGood); | 
|---|
|  | 1024 | dobj->Alloc(nvar,ndatalloc,-1); | 
|---|
|  | 1025 | dobj->mNData = ndata; | 
|---|
|  | 1026 | dobj->mNDataGood = ndatagood; | 
|---|
|  | 1027 |  | 
|---|
|  | 1028 | // Lecture des datas | 
|---|
|  | 1029 | is.GetLine(strg, 255); | 
|---|
|  | 1030 | int blen = dobj->mNVar + 3; | 
|---|
|  | 1031 | if(dobj->mOk_EXP) blen += dobj->mNVar; | 
|---|
|  | 1032 | double *buff = new double[blen]; | 
|---|
|  | 1033 | for(int i=0;i<dobj->mNData;i++) { | 
|---|
|  | 1034 | is.Get(buff, blen); | 
|---|
|  | 1035 | int ip = i*dobj->mNVar; | 
|---|
|  | 1036 | {for(int j=0;j<dobj->mNVar;j++)  dobj->mXP[ip+j] = buff[j];} | 
|---|
|  | 1037 | dobj->mF[i] = buff[dobj->mNVar]; | 
|---|
|  | 1038 | dobj->mErr[i] = buff[dobj->mNVar+1]; | 
|---|
|  | 1039 | dobj->mOK[i] = (uint_2)(buff[dobj->mNVar+2]+0.01); | 
|---|
|  | 1040 | if(dobj->mOk_EXP) {for(int j=0;j<dobj->mNVar;j++) | 
|---|
|  | 1041 | dobj->mErrXP[ip+j] = buff[dobj->mNVar+3+j];} | 
|---|
|  | 1042 | } | 
|---|
|  | 1043 | delete [] buff; | 
|---|
|  | 1044 |  | 
|---|
|  | 1045 | return; | 
|---|
|  | 1046 | } | 
|---|
|  | 1047 |  | 
|---|
| [490] | 1048 | void ObjFileIO<GeneralFitData>::WriteSelf(POutPersist& os) const | 
|---|
| [307] | 1049 | { | 
|---|
|  | 1050 | if (dobj == NULL)   return; | 
|---|
|  | 1051 | char strg[256]; | 
|---|
|  | 1052 |  | 
|---|
|  | 1053 | // Ecriture entete pour identifier facilement | 
|---|
|  | 1054 | sprintf(strg,"GeneralFitData: NVar=%d NDataAlloc=%d NData=%d NDataGood=%d Ok_EXP=%d" | 
|---|
|  | 1055 | ,dobj->mNVar,dobj->mNDataAlloc,dobj->mNData,dobj->mNDataGood,dobj->mOk_EXP); | 
|---|
|  | 1056 | os.PutLine(strg); | 
|---|
|  | 1057 |  | 
|---|
|  | 1058 | // Ecriture des valeurs de definitions | 
|---|
|  | 1059 | os.Put(dobj->mNVar); | 
|---|
|  | 1060 | os.Put(dobj->mNDataAlloc); | 
|---|
|  | 1061 | os.Put(dobj->mNData); | 
|---|
|  | 1062 | os.Put(dobj->mNDataGood); | 
|---|
|  | 1063 | os.Put(dobj->mOk_EXP); | 
|---|
|  | 1064 | if(dobj->mNVar<=0 || dobj->mNDataAlloc<=0 || dobj->mNData<=0 || dobj->mNDataGood<0) return; | 
|---|
|  | 1065 |  | 
|---|
|  | 1066 | // Ecriture des datas (on n'ecrit que mNData / mNDataAlloc) | 
|---|
|  | 1067 | sprintf(strg | 
|---|
|  | 1068 | ,"GeneralFitData: Abscisses, Ordonnee, Erreur Ordonnee, Flag, Erreur Abscisses"); | 
|---|
|  | 1069 | os.PutLine(strg); | 
|---|
|  | 1070 |  | 
|---|
|  | 1071 | int blen = dobj->mNVar + 3; | 
|---|
|  | 1072 | if(dobj->mOk_EXP) blen += dobj->mNVar; | 
|---|
|  | 1073 | double *buff = new double[blen]; | 
|---|
|  | 1074 | for(int i=0;i<dobj->mNData;i++) { | 
|---|
|  | 1075 | {for(int j=0;j<dobj->mNVar;j++) buff[j] = dobj->Absc(j,i);} | 
|---|
|  | 1076 | buff[dobj->mNVar] = dobj->Val(i); | 
|---|
|  | 1077 | buff[dobj->mNVar+1] = dobj->EVal(i); | 
|---|
|  | 1078 | buff[dobj->mNVar+2] = (double) dobj->IsValid(i); | 
|---|
|  | 1079 | if(dobj->mOk_EXP) {for(int j=0;j<dobj->mNVar;j++) buff[dobj->mNVar+3+j] = dobj->EAbsc(j,i);} | 
|---|
|  | 1080 | os.Put(buff, blen); | 
|---|
|  | 1081 | } | 
|---|
|  | 1082 | delete [] buff; | 
|---|
|  | 1083 |  | 
|---|
|  | 1084 | return; | 
|---|
|  | 1085 | } | 
|---|
| [490] | 1086 |  | 
|---|
|  | 1087 |  | 
|---|
|  | 1088 | #ifdef __CXX_PRAGMA_TEMPLATES__ | 
|---|
|  | 1089 | #pragma define_template ObjFileIO<GeneralFitData> | 
|---|
|  | 1090 | #endif | 
|---|
|  | 1091 |  | 
|---|
|  | 1092 | #if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES) | 
|---|
|  | 1093 | template class ObjFileIO<GeneralFitData>; | 
|---|
|  | 1094 | #endif | 
|---|