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