Changeset 307 in Sophya for trunk/SophyaLib/NTools/matrix.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/matrix.cc

    r288 r307  
    1 // $Id: matrix.cc,v 1.3 1999-05-03 16:55:21 ansari Exp $
     1// $Id: matrix.cc,v 1.4 1999-05-19 15:58:02 ansari Exp $
    22
    33#include "machdefs.h"
     
    983983//////////////////////////////////////////////////////////
    984984//++
    985 Matrix* Matrix::FitResidus(GeneralFit& gfit)
     985Matrix Matrix::FitResidus(GeneralFit& gfit
     986               ,double xorg,double yorg,double dx,double dy)
    986987//
    987988//      Retourne une classe contenant les residus du fit ``gfit''.
    988 //      On suppose que x=j (colonnes) et y=i (lignes) pour m(i,j).
    989 //--
    990 {
    991 if(NCol()<=0||NRows()<=0) return NULL;
     989//      Les coordonnees de l'element (i,j) sont :
     990//      (i,j) -> x = xorg + j*dx , y = yorg + i*dy
     991//--
     992{
     993if(NCol()<=0||NRows()<=0)
     994  throw(SzMismatchError("Matrix::FitResidus: size mismatch\n"));
    992995GeneralFunction* f = gfit.GetFunction();
    993 if(f==NULL) return NULL;
     996if(f==NULL)
     997  throw(NullPtrError("Matrix::FitResidus: NULL pointer\n"));
    994998Vector par = gfit.GetParm();
    995 Matrix* m = new Matrix(*this);
     999Matrix m(*this);
    9961000for(int i=0;i<NRows();i++) for(int j=0;j<NCol();j++) {
    997   double x[2] = {(double)j,(double)i};
    998   (*m)(i,j) -= f->Value(x,par.Data());
     1001  double x[2] = {xorg+j*dx,yorg+i*dy};
     1002  m(i,j) -= f->Value(x,par.Data());
    9991003}
    10001004return m;
     
    10021006
    10031007//++
    1004 Matrix* Matrix::FitFunction(GeneralFit& gfit)
     1008Matrix Matrix::FitFunction(GeneralFit& gfit
     1009               ,double xorg,double yorg,double dx,double dy)
    10051010//
    10061011//      Retourne une classe contenant la fonction du fit ``gfit''.
    1007 //      On suppose que x=j (colonnes) et y=i (lignes) pour m(i,j).
    1008 //--
    1009 {
    1010 if(NCol()<=0||NRows()<=0) return NULL;
     1012//      Les coordonnees de l'element (i,j) sont :
     1013//      (i,j) -> x = xorg + j*dx , y = yorg + i*dy
     1014//--
     1015{
     1016if(NCol()<=0||NRows()<=0)
     1017  throw(SzMismatchError("Matrix::FitFunction: size mismatch\n"));
    10111018GeneralFunction* f = gfit.GetFunction();
    1012 if(f==NULL) return NULL;
     1019if(f==NULL)
     1020  throw(NullPtrError("Matrix::FitFunction: NULL pointer\n"));
    10131021Vector par = gfit.GetParm();
    1014 Matrix* m = new Matrix(*this);
     1022Matrix m(*this);
    10151023for(int i=0;i<NRows();i++) for(int j=0;j<NCol();j++) {
    1016   double x[2] = {(double)j,(double)i};
    1017   (*m)(i,j) = f->Value(x,par.Data());
     1024  double x[2] = {xorg+j*dx,yorg+i*dy};
     1025  m(i,j) = f->Value(x,par.Data());
    10181026}
    10191027return m;
Note: See TracChangeset for help on using the changeset viewer.