Changeset 307 in Sophya for trunk/SophyaLib/NTools/cvector.cc


Ignore:
Timestamp:
May 19, 1999, 5:58:06 PM (26 years ago)
Author:
ansari
Message:

FIO_... + grosses modifs cmv 19/5/99

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/NTools/cvector.cc

    r303 r307  
    171171//////////////////////////////////////////////////////////
    172172//++
    173 Vector* Vector::FitResidus(GeneralFit& gfit)
     173Vector Vector::FitResidus(GeneralFit& gfit,double xorg,double dx)
    174174//
    175175//      Retourne une classe contenant les residus du fit ``gfit''.
    176 //      On suppose que x=i.
    177 //--
    178 {
    179 if(NElts()<=0) return NULL;
     176//      La coordonnee de l'element (i) est -> x = xorg + i*dx
     177//--
     178{
     179if(NElts()<=0)
     180  throw(SzMismatchError("Vector::FitResidus: size mismatch\n"));
    180181GeneralFunction* f = gfit.GetFunction();
    181 if(f==NULL) return NULL;
     182if(f==NULL)
     183  throw(NullPtrError("Vector::FitResidus: NULL pointer\n"));
    182184Vector par = gfit.GetParm();
    183 Vector* v = new Vector(*this);
     185Vector v(*this);
    184186for(int i=0;i<NElts();i++) {
    185   double x = (double)i;
    186   (*v)(i) -= f->Value(&x,par.Data());
     187  double x = xorg+i*dx;
     188  v(i) -= f->Value(&x,par.Data());
    187189}
    188190return v;
     
    190192
    191193//++
    192 Vector* Vector::FitFunction(GeneralFit& gfit)
     194Vector Vector::FitFunction(GeneralFit& gfit,double xorg,double dx)
    193195//
    194196//      Retourne une classe contenant la fonction du fit ``gfit''.
    195 //      On suppose que x=i.
    196 //--
    197 {
    198 if(NElts()<=0) return NULL;
     197//      La coordonnee de l'element (i) est -> x = xorg + i*dx
     198//--
     199{
     200if(NElts()<=0)
     201  throw(SzMismatchError("Vector::FitResidus: size mismatch\n"));
    199202GeneralFunction* f = gfit.GetFunction();
    200 if(f==NULL) return NULL;
     203if(f==NULL)
     204  throw(NullPtrError("Vector::FitResidus: NULL pointer\n"));
    201205Vector par = gfit.GetParm();
    202 Vector* v = new Vector(*this);
     206Vector v(*this);
    203207for(int i=0;i<NElts();i++) {
    204   double x = (double)i;
    205   (*v)(i) = f->Value(&x,par.Data());
     208  double x = xorg+i*dx;
     209  v(i) = f->Value(&x,par.Data());
    206210}
    207211return v;
Note: See TracChangeset for help on using the changeset viewer.