Changeset 307 in Sophya for trunk/SophyaLib/NTools/matrix.cc
- Timestamp:
- May 19, 1999, 5:58:06 PM (26 years ago)
- 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:21ansari Exp $1 // $Id: matrix.cc,v 1.4 1999-05-19 15:58:02 ansari Exp $ 2 2 3 3 #include "machdefs.h" … … 983 983 ////////////////////////////////////////////////////////// 984 984 //++ 985 Matrix* Matrix::FitResidus(GeneralFit& gfit) 985 Matrix Matrix::FitResidus(GeneralFit& gfit 986 ,double xorg,double yorg,double dx,double dy) 986 987 // 987 988 // 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 { 993 if(NCol()<=0||NRows()<=0) 994 throw(SzMismatchError("Matrix::FitResidus: size mismatch\n")); 992 995 GeneralFunction* f = gfit.GetFunction(); 993 if(f==NULL) return NULL; 996 if(f==NULL) 997 throw(NullPtrError("Matrix::FitResidus: NULL pointer\n")); 994 998 Vector par = gfit.GetParm(); 995 Matrix * m = new Matrix(*this);999 Matrix m(*this); 996 1000 for(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()); 999 1003 } 1000 1004 return m; … … 1002 1006 1003 1007 //++ 1004 Matrix* Matrix::FitFunction(GeneralFit& gfit) 1008 Matrix Matrix::FitFunction(GeneralFit& gfit 1009 ,double xorg,double yorg,double dx,double dy) 1005 1010 // 1006 1011 // 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 { 1016 if(NCol()<=0||NRows()<=0) 1017 throw(SzMismatchError("Matrix::FitFunction: size mismatch\n")); 1011 1018 GeneralFunction* f = gfit.GetFunction(); 1012 if(f==NULL) return NULL; 1019 if(f==NULL) 1020 throw(NullPtrError("Matrix::FitFunction: NULL pointer\n")); 1013 1021 Vector par = gfit.GetParm(); 1014 Matrix * m = new Matrix(*this);1022 Matrix m(*this); 1015 1023 for(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()); 1018 1026 } 1019 1027 return m;
Note:
See TracChangeset
for help on using the changeset viewer.