Changeset 508 in Sophya for trunk/SophyaLib/NTools/linfit.cc
- Timestamp:
- Oct 25, 1999, 12:36:22 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/NTools/linfit.cc
r244 r508 5 5 #include "cvector.h" 6 6 7 double LinFit(const Vector& x, constVector& y, int nf, double (*f)(int, double),8 Vector& c)7 double LinFit(const OVector& x, const OVector& y, int nf, double (*f)(int, double), 8 OVector& c) 9 9 { 10 10 int n = x.NElts(); 11 11 if (n != y.NElts()) THROW(sizeMismatchErr); 12 12 13 Matrix fx(nf, n);13 OMatrix fx(nf, n); 14 14 for (int i=0; i<nf; i++) 15 15 for (int j=0; j<n; j++) … … 21 21 22 22 23 double LinFit(const Matrix& fx, const Vector& y,Vector& c)23 double LinFit(const OMatrix& fx, const OVector& y, OVector& c) 24 24 { 25 25 int n = y.NElts(); … … 28 28 int nf = fx.NRows(); 29 29 30 Matrix a(nf,nf);30 OMatrix a(nf,nf); 31 31 32 32 for (int j=0; j<nf; j++) … … 36 36 c = fx * y; 37 37 38 if ( Matrix::GausPiv(a,c) == 0) THROW(singMatxErr);38 if (OMatrix::GausPiv(a,c) == 0) THROW(singMatxErr); 39 39 40 40 double xi2 = 0; … … 52 52 53 53 54 double LinFit(const Vector& x, const Vector& y, constVector& errY2, int nf,55 double (*f)(int, double), Vector& c,Vector& errC)54 double LinFit(const OVector& x, const OVector& y, const OVector& errY2, int nf, 55 double (*f)(int, double), OVector& c, OVector& errC) 56 56 { 57 57 int n = x.NElts(); 58 58 if (n != y.NElts()) THROW(sizeMismatchErr); 59 59 60 Matrix fx(nf, n);60 OMatrix fx(nf, n); 61 61 for (int i=0; i<nf; i++) 62 62 for (int j=0; j<n; j++) … … 67 67 68 68 69 double LinFit(const Matrix& fx, const Vector& y, constVector& errY2,70 Vector& c,Vector& errC)69 double LinFit(const OMatrix& fx, const OVector& y, const OVector& errY2, 70 OVector& c, OVector& errC) 71 71 { 72 72 int n = y.NElts(); … … 76 76 int nf = fx.NRows(); 77 77 78 Matrix a(nf,nf);78 OMatrix a(nf,nf); 79 79 80 80 c.Realloc(nf); … … 89 89 } 90 90 91 Matrix d(nf,nf+1);91 OMatrix d(nf,nf+1); 92 92 for (int k=0; k<nf; k++) { 93 93 double x=0; … … 99 99 } 100 100 101 if ( Matrix::GausPiv(a,d) == 0) THROW(singMatxErr);101 if (OMatrix::GausPiv(a,d) == 0) THROW(singMatxErr); 102 102 103 103 for (int l=0; l<nf; l++) {
Note:
See TracChangeset
for help on using the changeset viewer.