Changeset 514 in Sophya
- Timestamp:
- Oct 25, 1999, 6:43:04 PM (26 years ago)
- Location:
- trunk/SophyaLib
- Files:
-
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/NTools/difeq.cc
r508 r514 106 106 //++ 107 107 DiffEqSolver& 108 DiffEqSolver::StartV( OVector const& yi, double t)108 DiffEqSolver::StartV(Vector const& yi, double t) 109 109 // 110 110 // Spécifie le point de départ de l'intégration de l'équadif. … … 169 169 170 170 //++ 171 // virtual void DiffEqSolver::SolveArr( OMatrix& y, double* t, double tf, int n)=0171 // virtual void DiffEqSolver::SolveArr(Matrix& y, double* t, double tf, int n)=0 172 172 // Lance la résolution de l'équadif, jusqu'à la valeur 173 173 // tf du temps. N valeurs intermédiaires sont retournées dans … … 189 189 //++ 190 190 void 191 DiffEqSolver::SolveV( OVector& yf, double tf)191 DiffEqSolver::SolveV(Vector& yf, double tf) 192 192 // 193 193 // Lance la résolution de l'équadif, jusqu'à la valeur … … 201 201 { 202 202 double t; 203 OMatrix m(1, mFunc->NFuncReal());203 Matrix m(1, mFunc->NFuncReal()); 204 204 SolveArr(m, &t, tf, 1); 205 205 yf.Realloc(mFunc->NFunc()); … … 219 219 ASSERT(mFunc->NFunc() == 1); 220 220 double t; 221 OMatrix m(1,mFunc->NFuncReal());221 Matrix m(1,mFunc->NFuncReal()); 222 222 SolveArr(m, &t, tf, 1); 223 223 yf = m(0,0); … … 238 238 { 239 239 double t; 240 OMatrix m(1, mFunc->NFuncReal());240 Matrix m(1, mFunc->NFuncReal()); 241 241 SolveArr(m, &t, tf, 1); 242 242 for (int i=0; i<mFunc->NFunc(); i++) … … 258 258 { 259 259 ASSERT(mFunc->NFunc() == 1); 260 OMatrix m(n, mFunc->NFuncReal());260 Matrix m(n, mFunc->NFuncReal()); 261 261 SolveArr(m, t, tf, n); 262 262 for (int i=0; i<n; i++) … … 281 281 //-- 282 282 { 283 OMatrix m(n, mFunc->NFuncReal());283 Matrix m(n, mFunc->NFuncReal()); 284 284 SolveArr(m, t, tf, n); 285 285 for (int i=0; i<n; i++) … … 318 318 319 319 //++ 320 // virtual void ComputeV( OVector& fpi, OVector const& fi)320 // virtual void ComputeV(Vector& fpi, Vector const& fi) 321 321 // Calcule les valeurs des dérivées fpi à partir des valeurs 322 322 // des fonctions fi. A redéfinir. … … 340 340 341 341 //++ 342 // virtual void AdjustStart( OVector& start, double tstart)342 // virtual void AdjustStart(Vector& start, double tstart) 343 343 // Pour ajuster le vecteur de départ quand il y a des 344 344 // fonctions à usage interne... … … 405 405 406 406 void 407 DiffEqFcnT1::ComputeV( OVector& fpi, OVector const& fi)407 DiffEqFcnT1::ComputeV(Vector& fpi, Vector const& fi) 408 408 { 409 409 fpi(0) = (*mFcn)(fi(0), fi(1)); … … 412 412 413 413 void 414 DiffEqFcnT1::AdjustStart( OVector& start, double tstart)414 DiffEqFcnT1::AdjustStart(Vector& start, double tstart) 415 415 { 416 416 start.Realloc(2); … … 446 446 447 447 void 448 DiffEqFcn2::ComputeV( OVector& fpi, OVector const& fi)448 DiffEqFcn2::ComputeV(Vector& fpi, Vector const& fi) 449 449 { 450 450 fpi(0) = fi(1); … … 481 481 482 482 void 483 DiffEqFcnT2::ComputeV( OVector& fpi, OVector const& fi)483 DiffEqFcnT2::ComputeV(Vector& fpi, Vector const& fi) 484 484 { 485 485 fpi(0) = fi(1); … … 489 489 490 490 void 491 DiffEqFcnT2::AdjustStart( OVector& start, double tstart)491 DiffEqFcnT2::AdjustStart(Vector& start, double tstart) 492 492 { 493 493 start.Realloc(3); … … 505 505 // un vecteur de dimension 3. 506 506 // On fournit une fonction de type 507 //| typedef void(*DIFEQFCNV)( OVector& y2, OVector const& y1,508 //| OVector const& y);507 //| typedef void(*DIFEQFCNV)(Vector& y2, Vector const& y1, 508 //| Vector const& y); 509 509 // qui retourne y'' en fonction de y' et y. 510 510 // Note : le système résolu est alors en fait … … 527 527 528 528 void 529 DiffEqFcnV::ComputeV( OVector& fpi, OVector const& fi)529 DiffEqFcnV::ComputeV(Vector& fpi, Vector const& fi) 530 530 { 531 531 fpi(0) = fi(3); … … 582 582 583 583 void 584 RK4DiffEq::SolveArr( OMatrix& y, double* t, double tf, int n)584 RK4DiffEq::SolveArr(Matrix& y, double* t, double tf, int n) 585 585 { 586 586 //TIMEF; … … 592 592 double dx = (tf - mXStart)/(n*nStep); 593 593 594 OVector yt = mYStart;594 Vector yt = mYStart; 595 595 596 596 k1.Realloc(mFunc->NFuncReal()); … … 610 610 611 611 void 612 RK4DiffEq::RKStep( OVector& newY, OVector const& y0, double dt)612 RK4DiffEq::RKStep(Vector& newY, Vector const& y0, double dt) 613 613 { 614 614 mFunc->ComputeV(k1, y0); 615 615 k1 *= dt; 616 mFunc->ComputeV(k2, y0 + k1/2 );616 mFunc->ComputeV(k2, y0 + k1/2.); 617 617 k2 *= dt; 618 mFunc->ComputeV(k3, y0 + k2/2 );618 mFunc->ComputeV(k3, y0 + k2/2.); 619 619 k3 *= dt; 620 620 mFunc->ComputeV(k4, y0 + k3); 621 621 k4 *= dt; 622 622 623 newY = y0 + (k1 + k2*2. + k3*2. + k4)/6 ;624 } 625 623 newY = y0 + (k1 + k2*2. + k3*2. + k4)/6.; 624 } 625 -
trunk/SophyaLib/NTools/difeq.h
r508 r514 5 5 #include "machdefs.h" 6 6 #include "pexceptions.h" 7 #include "cvector.h" 8 9 namespace PlanckDPC {class GeneralFunction;} 7 #include "tvector.h" 8 9 namespace PlanckDPC { 10 11 class GeneralFunction; 10 12 11 13 // <summary> fonction pour equadifs </summary> … … 28 30 29 31 // Calcule les valeurs des derivees fpi a partir des valeurs des fonctions fi 30 virtual void ComputeV( OVector& fpi, OVector const& fi)32 virtual void ComputeV(Vector& fpi, Vector const& fi) 31 33 { Compute(fpi(0), fi(0)); } 32 34 … … 44 46 // Pour ajuster vecteur de depart quand il y a des fonctions a usage 45 47 // interne... 46 virtual void AdjustStart( OVector& /*start*/, double /*tstart*/)48 virtual void AdjustStart(Vector& /*start*/, double /*tstart*/) 47 49 {} 48 50 protected: … … 87 89 // Implementation de Compute qui va utiliser la fonction fournie 88 90 // au constructeur. 89 virtual void ComputeV( OVector& fpi, OVector const& fi);91 virtual void ComputeV(Vector& fpi, Vector const& fi); 90 92 91 93 // Implementation de AdjustStart qui gere la fonction a usage interne. 92 virtual void AdjustStart( OVector& start, double tstart);94 virtual void AdjustStart(Vector& start, double tstart); 93 95 protected: 94 96 DIFEQFCNT1 mFcn; … … 102 104 DiffEqFcn2(DIFEQFCN2); 103 105 104 virtual void ComputeV( OVector& fpi, OVector const& fi);106 virtual void ComputeV(Vector& fpi, Vector const& fi); 105 107 protected: 106 108 DIFEQFCN2 mFcn; … … 121 123 // Implementation de Compute qui va utiliser la fonction fournie 122 124 // au constructeur. 123 virtual void ComputeV( OVector& fpi, OVector const& fi);125 virtual void ComputeV(Vector& fpi, Vector const& fi); 124 126 125 127 // Implementation de AdjustStart qui gere la fonction a usage interne. 126 virtual void AdjustStart( OVector& start, double tstart);128 virtual void AdjustStart(Vector& start, double tstart); 127 129 protected: 128 130 DIFEQFCNT2 mFcn; … … 130 132 131 133 // Cas y'' = f(y',y) avec des 3-vecteurs 132 typedef void(*DIFEQFCNV)( OVector&, OVector const&, OVector const&);134 typedef void(*DIFEQFCNV)(Vector&, Vector const&, Vector const&); 133 135 134 136 // <summary> y'' = f(y',y,t) </summary> 135 137 // Cas y'' = f(y',y,t), on fournit la fonction f, sous la forme 136 // double f( OVector), et ca construit la bonne DiffEqFunction138 // double f(Vector), et ca construit la bonne DiffEqFunction 137 139 class DiffEqFcnV : public DiffEqFunction { 138 140 public: 139 // Constructeur, on fournit une fonction ( OVector)->double141 // Constructeur, on fournit une fonction (Vector)->double 140 142 // qui donne y'' en fonction du vecteur (t, y, y') 141 143 DiffEqFcnV(DIFEQFCNV); … … 143 145 // Implementation de Compute qui va utiliser la fonction fournie 144 146 // au constructeur. 145 virtual void ComputeV( OVector& fpi, OVector const& fi);147 virtual void ComputeV(Vector& fpi, Vector const& fi); 146 148 protected: 147 149 DIFEQFCNV mFcn; 148 OVector tmp1, tmp2, tmp3;150 Vector tmp1, tmp2, tmp3; 149 151 }; 150 152 … … 176 178 // Change les conditions initiales. Notation chainee possible. 177 179 // <group> 178 DiffEqSolver& StartV( OVector const& yi, double t);180 DiffEqSolver& StartV(Vector const& yi, double t); 179 181 // si NFunc == 1 180 182 DiffEqSolver& Start1(double yi, double t); … … 184 186 // Lance la resolution, avec ou sans conservation de n valeurs intermediaires 185 187 // <group> 186 virtual void SolveV( OVector& yf, double tf);188 virtual void SolveV(Vector& yf, double tf); 187 189 // si NFunc == 1 188 190 virtual void Solve1(double& yf, double tf); 189 191 virtual void Solve(double* yf, double tf); 190 virtual void SolveArr( OMatrix& y, double* t, double tf, int n)=0;192 virtual void SolveArr(Matrix& y, double* t, double tf, int n)=0; 191 193 // si NFunc == 1 192 194 virtual void SolveArr1(double* y, double* t, double tf, int n); … … 198 200 bool mOwnFunc; 199 201 200 OVector mYStart;202 Vector mYStart; 201 203 double mXStart; 202 204 double mStep; … … 215 217 216 218 // Implementation de RK4 217 virtual void SolveArr( OMatrix& y, double* t, double tf, int n);219 virtual void SolveArr(Matrix& y, double* t, double tf, int n); 218 220 219 221 protected: 220 222 // Un pas RK4 221 void RKStep( OVector& newY, OVector const& y0, double dt);223 void RKStep(Vector& newY, Vector const& y0, double dt); 222 224 // Vecteurs utilises en interne, pour ne pas les reallouer. 223 OVector k1, k2, k3, k4; 224 }; 225 226 225 Vector k1, k2, k3, k4; 226 }; 227 228 229 } // Fin du namespace 227 230 228 231 #endif -
trunk/SophyaLib/NTools/dvlist.cc
r404 r514 37 37 // PPersist 38 38 //-- 39 40 41 using namespace PlanckDPC;42 39 43 40 char MuTyV::myStrBuf[64]; // Declare static ds le .h -
trunk/SophyaLib/NTools/fct1dfit.cc
r307 r514 8 8 #include "nbconst.h" 9 9 #include "tabmath.h" 10 11 using namespace PlanckDPC;12 10 13 11 //define EXPO exp -
trunk/SophyaLib/NTools/fct2dfit.cc
r490 r514 16 16 #define EXPO tabFExp 17 17 #define MINEXPM (100.) 18 19 using namespace PlanckDPC;20 18 21 19 //================================================================ -
trunk/SophyaLib/NTools/fftserver.cc
r508 r514 156 156 } 157 157 158 void FFTServer::fftf( OVector& in, OVector& out)158 void FFTServer::fftf(Vector& in, Vector& out) 159 159 { 160 160 int l = in.NElts(); 161 /* ----- Si c'etait un OVector<float> on aurait ecrit comme ca162 Pour le moment OVector est double, on passe donc par un tableau161 /* ----- Si c'etait un Vector<float> on aurait ecrit comme ca 162 Pour le moment Vector est double, on passe donc par un tableau 163 163 intermediare 164 164 // La transformee sur le tableau de flaot se fait en place, … … 175 175 } 176 176 177 void FFTServer::fftb( OVector& in, OVector& out)177 void FFTServer::fftb(Vector& in, Vector& out) 178 178 { 179 179 int l = in.NElts(); 180 /* ----- Si c'etait un OVector<float> on aurait ecrit comme ca181 Pour le moment OVector est double, on passe donc par un tableau180 /* ----- Si c'etait un Vector<float> on aurait ecrit comme ca 181 Pour le moment Vector est double, on passe donc par un tableau 182 182 intermediare 183 183 // La transformee sur le tableau de flaot se fait en place, -
trunk/SophyaLib/NTools/fftserver.h
r508 r514 3 3 4 4 #include <complex> 5 #include " cvector.h"5 #include "tvector.h" 6 6 7 7 class FFTServer{ … … 17 17 virtual void fftf(int l, complex<double>* inout); 18 18 virtual void fftb(int l, complex<double>* inout); 19 virtual void fftf( OVector& in, OVector& out);20 virtual void fftb( OVector& in, OVector& out);19 virtual void fftf(Vector& in, Vector& out); 20 virtual void fftb(Vector& in, Vector& out); 21 21 22 22 protected: … … 94 94 \param inout input array /output backward FFT(original array destroyed) 95 95 */ 96 /*!\fn virtual void FFTServer::fftf( OVector& in, OVector& out)96 /*!\fn virtual void FFTServer::fftf(Vector& in, Vector& out) 97 97 \param in input array 98 98 \param out forward FFT 99 99 */ 100 /*! \fn virtual void FFTServer::fftb( OVector& in, OVector& out)100 /*! \fn virtual void FFTServer::fftb(Vector& in, Vector& out) 101 101 \param in input array 102 102 \param out backward FFT -
trunk/SophyaLib/NTools/generaldata.cc
r508 r514 14 14 #include "pexceptions.h" 15 15 #include "objfio.h" 16 17 using namespace PlanckDPC;18 16 19 17 //================================================================ … … 748 746 if(varx<0 || varx>=mNVar) return -2.; 749 747 if(mNDataGood<=0) return -4.; 750 OVector x(mNDataGood);751 OVector y(mNDataGood);752 OVector ey2(1);748 Vector x(mNDataGood); 749 Vector y(mNDataGood); 750 Vector ey2(1); 753 751 if(ey) ey2.Realloc(mNDataGood,true); 754 752 int ntest = 0; … … 763 761 double res = 0.; 764 762 if(ey) { 765 OVector errcoef(1);763 Vector errcoef(1); 766 764 res = pol.Fit(x,y,ey2,degre,errcoef); 767 765 } else { … … 797 795 if(vary<0 || vary>=mNVar || vary==varx) return -3.; 798 796 if(mNDataGood<=0) return -4.; 799 OVector x(mNDataGood);800 OVector y(mNDataGood);801 OVector z(mNDataGood);802 OVector ez2(1);797 Vector x(mNDataGood); 798 Vector y(mNDataGood); 799 Vector z(mNDataGood); 800 Vector ez2(1); 803 801 if(ez) ez2.Realloc(mNDataGood,true); 804 802 int ntest = 0; … … 814 812 double res = 0.; 815 813 if(ez) { 816 OVector errcoef(1);814 Vector errcoef(1); 817 815 if(degre2>0) res = pol.Fit(x,y,z,ez2,degre1,degre2,errcoef); 818 816 else res = pol.Fit(x,y,z,ez2,degre1,errcoef); -
trunk/SophyaLib/NTools/generalfit.cc
r508 r514 9 9 #include "pexceptions.h" 10 10 #include "generalfit.h" 11 #include "cvector.h"12 11 13 12 #define EPS_FIT_MIN 1.e-8 14 15 using namespace PlanckDPC;16 13 17 14 //================================================================ … … 874 871 875 872 //++ 876 OVector GeneralFit::GetParm()873 Vector GeneralFit::GetParm() 877 874 // 878 875 // Retourne les valeurs des parametres dans un vecteur. … … 1096 1093 { 1097 1094 volatile double oldChi2; 1098 OMatrix COVAR(mNPar,mNPar);1099 OVector DA(mNPar);1100 OVector dparam(mNPar);1101 OVector paramTry(mNPar);1102 OVector param_tr(mNPar);1103 OVector paramTry_tr(mNPar);1104 OVector step_tr(mNPar);1095 Matrix COVAR(mNPar,mNPar); 1096 Vector DA(mNPar); 1097 Vector dparam(mNPar); 1098 Vector paramTry(mNPar); 1099 Vector param_tr(mNPar); 1100 Vector paramTry_tr(mNPar); 1101 Vector step_tr(mNPar); 1105 1102 nStop = nStopL = nStep = 0; 1106 1103 Chi2 = oldChi2 = 0.; … … 1515 1512 1516 1513 ////////////////////////////////////////////////////////////////////// 1517 void GeneralFit::write_in_step(double ci2, OVector& par)1514 void GeneralFit::write_in_step(double ci2,Vector& par) 1518 1515 { 1519 1516 if(FileStep==NULL) return; … … 1524 1521 1525 1522 ////////////////////////////////////////////////////////////////////// 1526 void GeneralFit::TryFunc( OVector& par,OVector& par_tr)1523 void GeneralFit::TryFunc(Vector& par,Vector& par_tr) 1527 1524 { 1528 1525 BETA_Try = 0; 1529 1526 ATGA_Try = 0; 1530 1527 Chi2 = 0; 1531 OVector deriv(mNPar);1532 OVector derivtr(mNPar);1528 Vector deriv(mNPar); 1529 Vector derivtr(mNPar); 1533 1530 double result; 1534 1531 … … 1564 1561 1565 1562 ////////////////////////////////////////////////////////////////////// 1566 void GeneralFit::TryXi2( OVector& par,OVector& par_tr)1563 void GeneralFit::TryXi2(Vector& par,Vector& par_tr) 1567 1564 { 1568 1565 double c, *parloc; … … 1664 1661 1665 1662 ////////////////////////////////////////////////////////////////////// 1666 OVector GeneralFit::p_vers_tr(OVector const& p)1667 { 1668 OVector tr(p);1663 Vector GeneralFit::p_vers_tr(Vector const& p) 1664 { 1665 Vector tr(p); 1669 1666 for(int i=0;i<mNPar;i++) { 1670 1667 if( fixParam[i] || ! boundParam[i] ) continue; … … 1675 1672 1676 1673 ////////////////////////////////////////////////////////////////////// 1677 void GeneralFit::p_vers_tr( OVector const& p,OVector& tr)1674 void GeneralFit::p_vers_tr(Vector const& p,Vector& tr) 1678 1675 { 1679 1676 for(int i=0;i<mNPar;i++) { … … 1695 1692 1696 1693 ////////////////////////////////////////////////////////////////////// 1697 OVector GeneralFit::tr_vers_p(OVector const& tr)1698 { 1699 OVector p(tr);1694 Vector GeneralFit::tr_vers_p(Vector const& tr) 1695 { 1696 Vector p(tr); 1700 1697 for(int i=0;i<mNPar;i++) { 1701 1698 if( fixParam[i] || ! boundParam[i] ) continue; … … 1706 1703 1707 1704 ////////////////////////////////////////////////////////////////////// 1708 void GeneralFit::tr_vers_p( OVector const& tr,OVector& p)1705 void GeneralFit::tr_vers_p(Vector const& tr,Vector& p) 1709 1706 { 1710 1707 for(int i=0;i<mNPar;i++) { … … 1727 1724 1728 1725 ////////////////////////////////////////////////////////////////////// 1729 OVector GeneralFit::dp_vers_dtr(OVector const& dp,OVector const& tr)1730 { 1731 OVector dtr(dp);1726 Vector GeneralFit::dp_vers_dtr(Vector const& dp,Vector const& tr) 1727 { 1728 Vector dtr(dp); 1732 1729 for(int i=0;i<mNPar;i++) { 1733 1730 if( fixParam[i] || ! boundParam[i] ) continue; … … 1738 1735 1739 1736 ////////////////////////////////////////////////////////////////////// 1740 void GeneralFit::dp_vers_dtr( OVector const& dp,OVector const& tr,OVector& dtr)1737 void GeneralFit::dp_vers_dtr(Vector const& dp,Vector const& tr,Vector& dtr) 1741 1738 { 1742 1739 for(int i=0;i<mNPar;i++) { … … 1759 1756 1760 1757 ////////////////////////////////////////////////////////////////////// 1761 OVector GeneralFit::dtr_vers_dp(OVector const& dtr,OVector const& tr)1762 { 1763 OVector dp(dtr);1758 Vector GeneralFit::dtr_vers_dp(Vector const& dtr,Vector const& tr) 1759 { 1760 Vector dp(dtr); 1764 1761 for(int i=0;i<mNPar;i++) { 1765 1762 if( fixParam[i] || ! boundParam[i] ) continue; … … 1771 1768 ////////////////////////////////////////////////////////////////////// 1772 1769 // inline fonction pour aller + vite dans le try() 1773 //void GeneralFit::dtr_vers_dp( OVector const& dtr,OVector const& tr,OVector& dp)1774 1775 ////////////////////////////////////////////////////////////////////// 1776 int GeneralFit::put_in_limits_for_deriv( OVector const& p,OVector& dp,double dist)1770 //void GeneralFit::dtr_vers_dp(Vector const& dtr,Vector const& tr,Vector& dp) 1771 1772 ////////////////////////////////////////////////////////////////////// 1773 int GeneralFit::put_in_limits_for_deriv(Vector const& p,Vector& dp,double dist) 1777 1774 // 1-/ Redefinit dp pour qu'il soit superieur a minStepDeriv 1778 1775 // 2-/ Redefinit dp pour que p+/-dp reste dans les limites (parametre borne) -
trunk/SophyaLib/NTools/generalfit.h
r508 r514 4 4 5 5 #include "pexceptions.h" 6 #include "matrix.h" 7 #include "cvector.h" 6 #include "tvector.h" 8 7 #include "generaldata.h" 9 8 … … 124 123 125 124 double GetParm(int); 126 OVector GetParm();125 Vector GetParm(); 127 126 double GetParmErr(int); 128 127 double GetCoVar(int,int); … … 168 167 GeneralFitData* mData; 169 168 170 OVector Param;171 OVector errParam;172 OVector stepParam;173 OVector minParam;174 OVector maxParam;175 OVector minStepDeriv;176 OVector Eps;169 Vector Param; 170 Vector errParam; 171 Vector stepParam; 172 Vector minParam; 173 Vector maxParam; 174 Vector minStepDeriv; 175 Vector Eps; 177 176 unsigned short int* fixParam; 178 177 unsigned short int* boundParam; … … 188 187 FILE *FileStep; 189 188 190 OMatrix ATGA;191 OVector BETA;192 OMatrix ATGA_Try;193 OVector BETA_Try;194 OVector C;195 OVector D;189 Matrix ATGA; 190 Vector BETA; 191 Matrix ATGA_Try; 192 Vector BETA_Try; 193 Vector C; 194 Vector D; 196 195 197 196 double Chi2; … … 202 201 203 202 // Fonctions privees 204 void write_in_step(double ci2, OVector& par);203 void write_in_step(double ci2,Vector& par); 205 204 void General_Init(void); 206 void TryFunc( OVector& par,OVector& par_tr);207 void TryXi2( OVector& par,OVector& par_tr);205 void TryFunc(Vector& par,Vector& par_tr); 206 void TryXi2(Vector& par,Vector& par_tr); 208 207 void CheckSanity(); 209 208 void Set_Bound_C_D(int i); 210 209 void Set_Bound_C_D(); 211 210 double p_vers_tr(int i,double p); 212 OVector p_vers_tr(OVector const& p);213 void p_vers_tr( OVector const& p,OVector& tr);211 Vector p_vers_tr(Vector const& p); 212 void p_vers_tr(Vector const& p,Vector& tr); 214 213 double tr_vers_p(int i,double tr); 215 OVector tr_vers_p(OVector const& tr);216 void tr_vers_p( OVector const& tr,OVector& p);214 Vector tr_vers_p(Vector const& tr); 215 void tr_vers_p(Vector const& tr,Vector& p); 217 216 double c_dp_vers_dtr(int i,double tr); 218 OVector dp_vers_dtr(OVector const& dp,OVector const& tr);219 void dp_vers_dtr( OVector const& dp,OVector const& tr,OVector& dtr);217 Vector dp_vers_dtr(Vector const& dp,Vector const& tr); 218 void dp_vers_dtr(Vector const& dp,Vector const& tr,Vector& dtr); 220 219 double c_dtr_vers_dp(int i,double tr); 221 OVector dtr_vers_dp(OVector const& dtr,OVector const& tr);222 int put_in_limits_for_deriv( OVector const& p,OVector& dp,double dist=0.66);223 inline void dtr_vers_dp( OVector const& dtr,OVector const& tr,OVector& dp)220 Vector dtr_vers_dp(Vector const& dtr,Vector const& tr); 221 int put_in_limits_for_deriv(Vector const& p,Vector& dp,double dist=0.66); 222 inline void dtr_vers_dp(Vector const& dtr,Vector const& tr,Vector& dp) 224 223 { for(int i=0;i<mNPar;i++) 225 224 { if( fixParam[i] ) continue; -
trunk/SophyaLib/NTools/hisprof.cc
r508 r514 5 5 #include "hisprof.h" 6 6 #include "perrors.h" 7 #include "cvector.h"8 9 using namespace PlanckDPC;10 7 11 8 //++ … … 260 257 //-- 261 258 //++ 262 // inline void GetMean( OVector& v)259 // inline void GetMean(Vector& v) 263 260 // Retourne le contenu de la moyenne dans le vecteur v 264 261 //-- 265 262 //++ 266 // inline void GetError2( OVector& v)263 // inline void GetError2(Vector& v) 267 264 // Retourne le contenu au carre de la dispersion/erreur dans le vecteur v 268 265 //-- -
trunk/SophyaLib/NTools/hisprof.h
r508 r514 4 4 #include <stdio.h> 5 5 #include "peida.h" 6 #include " cvector.h"6 #include "tvector.h" 7 7 #include "ppersist.h" 8 8 #include "histos.h" … … 29 29 // Acces a l information 30 30 inline Histo GetHisto() {if(!Ok) UpdateHisto(); return (Histo) *this;} 31 inline void GetMean( OVector& v) {if(!Ok) UpdateHisto(); Histo::GetValue(v);}32 inline void GetError2( OVector& v) {if(!Ok) UpdateHisto(); Histo::GetError2(v);}31 inline void GetMean(Vector& v) {if(!Ok) UpdateHisto(); Histo::GetValue(v);} 32 inline void GetError2(Vector& v) {if(!Ok) UpdateHisto(); Histo::GetError2(v);} 33 33 inline float operator()(int i) const {if(!Ok) UpdateHisto(); return data[i];} 34 34 inline float Error2(int i) const {if(!Ok) UpdateHisto(); return (float) err2[i];} -
trunk/SophyaLib/NTools/histos.cc
r508 r514 1 1 // 2 // $Id: histos.cc,v 1. 5 1999-10-25 10:36:07 ansari Exp $2 // $Id: histos.cc,v 1.6 1999-10-25 16:39:57 ansari Exp $ 3 3 // 4 4 … … 9 9 #include "histos.h" 10 10 #include "perrors.h" 11 #include "cvector.h"12 11 #include "poly.h" 13 12 #include "strutil.h" 14 13 #include "generalfit.h" 15 16 using namespace PlanckDPC;17 14 18 15 //++ … … 404 401 /********* Methode *********/ 405 402 //++ 406 void Histo::GetAbsc( OVector &v)403 void Histo::GetAbsc(Vector &v) 407 404 // 408 405 // Remplissage d'un tableau avec la valeur des abscisses … … 415 412 416 413 //++ 417 void Histo::GetValue( OVector &v)414 void Histo::GetValue(Vector &v) 418 415 // 419 416 // Remplissage d'un tableau avec la valeur du contenu … … 426 423 427 424 //++ 428 void Histo::GetError2( OVector &v)425 void Histo::GetError2(Vector &v) 429 426 // 430 427 // Remplissage d'un tableau avec la valeur des erreurs au carre … … 438 435 439 436 //++ 440 void Histo::GetError( OVector &v)437 void Histo::GetError(Vector &v) 441 438 // 442 439 // Remplissage d'un tableau avec la valeur des erreurs … … 451 448 /********* Methode *********/ 452 449 //++ 453 void Histo::PutValue( OVector &v, int ierr)450 void Histo::PutValue(Vector &v, int ierr) 454 451 // 455 452 // Remplissage du contenu de l'histo avec les valeurs d'un vecteur … … 465 462 466 463 //++ 467 void Histo::PutValueAdd( OVector &v, int ierr)464 void Histo::PutValueAdd(Vector &v, int ierr) 468 465 // 469 466 // Addition du contenu de l'histo avec les valeurs d'un vecteur … … 479 476 480 477 //++ 481 void Histo::PutError2( OVector &v)478 void Histo::PutError2(Vector &v) 482 479 // 483 480 // Remplissage des erreurs au carre de l'histo avec les valeurs d'un vecteur … … 491 488 492 489 //++ 493 void Histo::PutError2Add( OVector &v)490 void Histo::PutError2Add(Vector &v) 494 491 // 495 492 // Addition des erreurs au carre de l'histo avec les valeurs d'un vecteur … … 503 500 504 501 //++ 505 void Histo::PutError( OVector &v)502 void Histo::PutError(Vector &v) 506 503 // 507 504 // Remplissage des erreurs de l'histo avec les valeurs d'un vecteur … … 1121 1118 } 1122 1119 1123 OVector xFit(nLowHigh);1124 OVector yFit(nLowHigh);1125 OVector e2Fit(nLowHigh);1126 OVector errcoef(1);1120 Vector xFit(nLowHigh); 1121 Vector yFit(nLowHigh); 1122 Vector e2Fit(nLowHigh); 1123 Vector errcoef(1); 1127 1124 int ii = 0; 1128 1125 for (int j=iLow; j<=iHigh; j++) { … … 1444 1441 if(f==NULL) 1445 1442 throw(NullPtrError("Histo::FitResidus: NULL pointer\n")); 1446 OVector par = gfit.GetParm();1443 Vector par = gfit.GetParm(); 1447 1444 Histo h(*this); 1448 1445 for(int i=0;i<NBins();i++) { … … 1464 1461 if(f==NULL) 1465 1462 throw(NullPtrError("Histo::FitFunction: NULL pointer\n")); 1466 OVector par = gfit.GetParm();1463 Vector par = gfit.GetParm(); 1467 1464 Histo h(*this); 1468 1465 for(int i=0;i<NBins();i++) { -
trunk/SophyaLib/NTools/histos.h
r508 r514 1 1 // This may look like C code, but it is really -*- C++ -*- 2 2 // 3 // $Id: histos.h,v 1. 4 1999-10-25 10:36:07 ansari Exp $3 // $Id: histos.h,v 1.5 1999-10-25 16:39:57 ansari Exp $ 4 4 // 5 5 … … 11 11 #include <stdio.h> 12 12 #include "peida.h" 13 #include " cvector.h"13 #include "tvector.h" 14 14 #include "ppersist.h" 15 15 #include "anydataobj.h" … … 66 66 67 67 // get/put dans/depuis un vector 68 void GetAbsc( OVector& v);69 void GetValue( OVector& v);70 void GetError2( OVector& v);71 void GetError( OVector& v);72 void PutValue( OVector& v, int ierr=0);73 void PutValueAdd( OVector &v, int ierr=0);74 void PutError2( OVector& v);75 void PutError2Add( OVector& v);76 void PutError( OVector& v);68 void GetAbsc(Vector& v); 69 void GetValue(Vector& v); 70 void GetError2(Vector& v); 71 void GetError(Vector& v); 72 void PutValue(Vector& v, int ierr=0); 73 void PutValueAdd(Vector &v, int ierr=0); 74 void PutError2(Vector& v); 75 void PutError2Add(Vector& v); 76 void PutError(Vector& v); 77 77 78 78 // INLINES -
trunk/SophyaLib/NTools/histos2.cc
r508 r514 15 15 #include "histos2.h" 16 16 #include "generalfit.h" 17 18 using namespace PlanckDPC;19 17 20 18 //++ … … 603 601 /////////////////////////////////////////////////////////////////// 604 602 //++ 605 void Histo2D::GetXCoor( OVector &v)603 void Histo2D::GetXCoor(Vector &v) 606 604 // 607 605 // Remplissage d'un tableau avec les valeurs des abscisses. … … 615 613 616 614 //++ 617 void Histo2D::GetYCoor( OVector &v)615 void Histo2D::GetYCoor(Vector &v) 618 616 // 619 617 // Remplissage d'un tableau avec les valeurs des ordonnees. … … 644 642 645 643 //++ 646 void Histo2D::GetValue( OMatrix &v)644 void Histo2D::GetValue(Matrix &v) 647 645 // 648 646 // Remplissage d'un tableau avec les valeurs du contenu. … … 656 654 657 655 //++ 658 void Histo2D::GetError2( OMatrix &v)656 void Histo2D::GetError2(Matrix &v) 659 657 // 660 658 // Remplissage d'un tableau avec les valeurs du carre des erreurs. … … 670 668 671 669 //++ 672 void Histo2D::GetError( OMatrix &v)670 void Histo2D::GetError(Matrix &v) 673 671 // 674 672 // Remplissage d'un tableau avec les valeurs des erreurs. … … 685 683 /////////////////////////////////////////////////////////////////// 686 684 //++ 687 void Histo2D::PutValue( OMatrix &v, int ierr)685 void Histo2D::PutValue(Matrix &v, int ierr) 688 686 // 689 687 // Remplissage du contenu de l'histo avec les valeurs d'un tableau. … … 700 698 701 699 //++ 702 void Histo2D::PutValueAdd( OMatrix &v, int ierr)700 void Histo2D::PutValueAdd(Matrix &v, int ierr) 703 701 // 704 702 // Addition du contenu de l'histo avec les valeurs d'un tableau. … … 715 713 716 714 //++ 717 void Histo2D::PutError2( OMatrix &v)715 void Histo2D::PutError2(Matrix &v) 718 716 // 719 717 // Remplissage des erreurs au carre de l'histo … … 729 727 730 728 //++ 731 void Histo2D::PutError2Add( OMatrix &v)729 void Histo2D::PutError2Add(Matrix &v) 732 730 // 733 731 // Addition des erreurs au carre de l'histo … … 744 742 745 743 //++ 746 void Histo2D::PutError( OMatrix &v)744 void Histo2D::PutError(Matrix &v) 747 745 // 748 746 // Remplissage des erreurs de l'histo avec les valeurs d'un tableau. … … 1105 1103 if(f==NULL) 1106 1104 throw(NullPtrError("Histo2D::FitResidus: NULL pointer\n")); 1107 OVector par = gfit.GetParm();1105 Vector par = gfit.GetParm(); 1108 1106 Histo2D h2(*this); 1109 1107 for(int i=0;i<NBinX();i++) for(int j=0;j<NBinY();j++) { … … 1127 1125 if(f==NULL) 1128 1126 throw(NullPtrError("Histo2D::FitFunction: NULL pointer\n")); 1129 OVector par = gfit.GetParm();1127 Vector par = gfit.GetParm(); 1130 1128 Histo2D h2(*this); 1131 1129 for(int i=0;i<NBinX();i++) for(int j=0;j<NBinY();j++) { -
trunk/SophyaLib/NTools/histos2.h
r508 r514 63 63 64 64 // get/put dans/depuis une matrice / vector 65 void GetXCoor( OVector& v);66 void GetValue( OMatrix &v);67 void GetYCoor( OVector& v);68 void GetError2( OMatrix& v);69 void GetError( OMatrix& v);70 void PutValue( OMatrix& v, int ierr=0);71 void PutValueAdd( OMatrix& v, int ierr=0);72 void PutError2( OMatrix& v);73 void PutError2Add( OMatrix& v);74 void PutError( OMatrix& v);65 void GetXCoor(Vector& v); 66 void GetValue(Matrix &v); 67 void GetYCoor(Vector& v); 68 void GetError2(Matrix& v); 69 void GetError(Matrix& v); 70 void PutValue(Matrix& v, int ierr=0); 71 void PutValueAdd(Matrix& v, int ierr=0); 72 void PutError2(Matrix& v); 73 void PutError2Add(Matrix& v); 74 void PutError(Matrix& v); 75 75 76 76 // INLINES -
trunk/SophyaLib/NTools/integ.h
r490 r514 3 3 // integ.h 4 4 // 5 // $Id: integ.h,v 1. 4 1999-10-21 15:25:49 ansari Exp $5 // $Id: integ.h,v 1.5 1999-10-25 16:39:59 ansari Exp $ 6 6 // 7 7 … … 13 13 #include <set> 14 14 15 namespace PlanckDPC {class GeneralFunction;} 15 namespace PlanckDPC { 16 17 class GeneralFunction; 16 18 17 19 class Integrator EXC_AWARE { … … 95 97 }; 96 98 97 99 } // Fin du namespace 98 100 99 101 #endif -
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++) { -
trunk/SophyaLib/NTools/linfit.h
r508 r514 1 1 // This may look like C code, but it is really -*- C++ -*- 2 2 // 3 // $Id: linfit.h,v 1. 3 1999-10-25 10:36:08ansari Exp $3 // $Id: linfit.h,v 1.4 1999-10-25 16:40:00 ansari Exp $ 4 4 // 5 5 … … 10 10 11 11 #include "machdefs.h" 12 class OMatrix; 13 class OVector; 12 #include "tvector.h" 14 13 15 double LinFit(const OVector& x, const OVector& y, int nf, 16 double (*f)(int, double), OVector& c); 14 namespace PlanckDPC { 15 16 double LinFit(const Vector& x, const Vector& y, int nf, 17 double (*f)(int, double), Vector& c); 17 18 // fit lineaire des y en tant que somme de c(i)f(i,x), i=0..nf-1; 18 19 19 20 20 double LinFit(const OMatrix& fx, const OVector& y, OVector& c);21 double LinFit(const Matrix& fx, const Vector& y, Vector& c); 21 22 // fit lineaire des y en tant que somme de c(i)f(i,x), i=0..nf-1, 22 23 // la matrice fx contient les valeurs des f: … … 24 25 25 26 26 double LinFit(const OVector& x, const OVector& y, const OVector& errY2, int nf,27 double (*f)(int, double), OVector& c, OVector& errC);27 double LinFit(const Vector& x, const Vector& y, const Vector& errY2, int nf, 28 double (*f)(int, double), Vector& c, Vector& errC); 28 29 // fit lineaire des y en tant que somme de c(i)f(i,x), i=0..nf-1, 29 30 // errY2 contient les carres des erreurs sur les Y. … … 31 32 32 33 33 double LinFit(const OMatrix& fx, const OVector& y, const OVector& errY2,34 OVector& c, OVector& errC);34 double LinFit(const Matrix& fx, const Vector& y, const Vector& errY2, 35 Vector& c, Vector& errC); 35 36 // fit lineaire des y en tant que somme de c(i)f(i,x), i=0..nf-1, 36 37 // la matrice fx contient les valeurs des f: … … 39 40 // au retour, errC contient les erreurs sur les coefs. 40 41 42 } // Fin du namespace 43 41 44 #endif // LINFIT_SEEN -
trunk/SophyaLib/NTools/outilsinit.cc
r508 r514 34 34 PPRegister(OMatrix); 35 35 PPRegister(OVector); 36 PPRegister( Poly);37 PPRegister( Poly2);36 PPRegister(ObjFileIO<Poly>); 37 PPRegister(ObjFileIO<Poly2>); 38 38 PPRegister(ObjFileIO<DVList>); 39 39 PPRegister(ObjFileIO<Histo>); -
trunk/SophyaLib/NTools/poly.cc
r508 r514 13 13 //++ 14 14 // Links Parents 15 // OVector15 // Vector 16 16 //-- 17 17 … … 21 21 22 22 23 ////////////////////////////////////////////////////////////////////////// 23 24 //++ 24 25 // Poly::Poly(int degre=0) … … 29 30 30 31 Poly::Poly(int degre) 31 : OVector(degre+1), dirty(0), deg(0)32 : Vector(degre+1), dirty(0), deg(0) 32 33 { 33 34 END_CONSTRUCTOR 34 35 } 35 36 37 //++ 38 Poly::Poly(Poly const& a) 39 // 40 // Constructeur par copie. 41 //-- 42 :Vector(a), dirty(a.dirty), deg(a.deg) 43 { 44 END_CONSTRUCTOR 45 } 46 36 47 37 48 void Poly::UpdateDeg() const 38 49 { 39 int i = nalloc-1;40 while ( data[i]== 0 && i>0) i--;50 int i = NElts()-1; 51 while (Element(i) == 0 && i>0) i--; 41 52 42 53 (int&) deg = i; // bientot mutable dans ANSI C++ … … 61 72 { 62 73 UpdateDegIfDirty(); 63 double res = data[deg];74 double res = Element(deg); 64 75 for (int i=deg-1; i>=0; i--) { 65 76 res *= x; 66 res += data[i];77 res += Element(i); 67 78 } 68 79 return res; … … 76 87 { 77 88 UpdateDegIfDirty(); 78 if (deg == 0) { data[0]= 0; return;}89 if (deg == 0) { Element(0) = 0; return;} 79 90 for (int i=1; i<=deg; i++) 80 data[i-1] = data[i]*i;81 data[deg]= 0;91 Element(i-1) = Element(i)*i; 92 Element(deg) = 0; 82 93 deg--; 83 94 } … … 94 105 // der.Zero(); // on sait que Realloc met a zero le reste. 95 106 for (int i=1; i<=deg; i++) 96 der. data[i-1] = data[i]*i;97 } 98 99 100 //++ 101 int Poly::Roots( OVector& roots) const107 der.Element(i-1) = Element(i)*i; 108 } 109 110 111 //++ 112 int Poly::Roots(Vector& roots) const 102 113 // 103 114 // Retourne dans roots les racines réelles, si on sait … … 133 144 if (deg != 1) THROW(sizeMismatchErr); 134 145 135 if ( data[1]== 0) return 0;136 r = - data[0]/data[1];146 if (Element(1) == 0) return 0; 147 r = -Element(0)/Element(1); 137 148 return 1; 138 149 } … … 149 160 if (deg != 2) THROW(sizeMismatchErr); 150 161 151 double delta = data[1]*data[1] - 4*data[0]*data[2];162 double delta = Element(1)*Element(1) - 4*Element(0)*Element(2); 152 163 if (delta < 0) return 0; 153 164 if (delta == 0) { 154 r1 = r2 = - data[1]/2/data[0];165 r1 = r2 = -Element(1)/2/Element(0); 155 166 return 1; 156 167 } 157 r1 = (- data[1] - sqrt(delta))/2/data[0];158 r2 = (- data[1] + sqrt(delta))/2/data[0];168 r1 = (-Element(1) - sqrt(delta))/2/Element(0); 169 r2 = (-Element(1) + sqrt(delta))/2/Element(0); 159 170 return 2; 160 171 } … … 167 178 { 168 179 if (this == &a) return *this; 169 OVector::operator=(a);180 Vector::operator=(a); 170 181 171 182 UpdateDeg(); … … 185 196 b.UpdateDegIfDirty(); 186 197 187 if (b.deg > deg) 188 Realloc(b.deg); 198 if (b.deg > deg) Realloc(b.deg); 189 199 190 200 int n = (deg > b.deg) ? deg : b.deg; 191 for (int i=0; i<=n; i++) 192 data[i] += b.data[i]; 201 for (int i=0; i<=n; i++) Element(i) += b.Element(i); 193 202 194 203 UpdateDeg(); … … 204 213 b.UpdateDegIfDirty(); 205 214 206 if (b.deg > deg) 207 Realloc(b.deg); 215 if (b.deg > deg) Realloc(b.deg); 208 216 209 217 int n = (deg > b.deg) ? deg : b.deg; 210 for (int i=0; i<=n; i++) 211 data[i] -= b.data[i]; 218 for (int i=0; i<=n; i++) Element(i) -= b.Element(i); 212 219 213 220 UpdateDeg(); … … 215 222 } 216 223 217 218 //++ 219 Poly operator+ (Poly const& a, Poly const& b) 220 // 221 //-- 222 #if HAS_NAMED_RETURN 223 return c((a.deg > b.deg)?(a.deg+1):(b.deg+1)) 224 #endif 225 { 226 #if !HAS_NAMED_RETURN 227 Poly c((a.deg > b.deg)?(a.deg+1):(b.deg+1)); 228 #endif 229 c = a; 230 c += b; 231 #if !HAS_NAMED_RETURN 232 return c; 233 #endif 234 } 235 236 //++ 237 Poly operator- (Poly const& a, Poly const& b) 238 // 239 //-- 240 #if HAS_NAMED_RETURN 241 return c((a.deg > b.deg)?(a.deg+1):(b.deg+1)) 242 #endif 243 { 244 #if !HAS_NAMED_RETURN 245 Poly c((a.deg > b.deg)?(a.deg+1):(b.deg+1)); 246 #endif 247 c = a; 248 c -= b; 249 #if !HAS_NAMED_RETURN 250 return c; 251 #endif 252 } 253 254 //++ 255 Poly operator* (Poly const& a, Poly const& b) 256 // 257 //-- 258 //#if HAS_NAMED_RETURN 259 // return c(a.deg + b.deg) 260 //#endif 261 { 262 //#if !HAS_NAMED_RETURN 263 Poly c(a.deg + b.deg); 264 //#endif 265 a.UpdateDegIfDirty(); 224 //++ 225 Poly& Poly::operator *= (double a) 226 // 227 //-- 228 { 229 UpdateDegIfDirty(); 230 for (int i=0; i<=deg; i++) Element(i) *= a; 231 return *this; 232 } 233 234 //++ 235 Poly Poly::Mult(Poly const& b) const 236 // 237 //-- 238 { 239 Poly c(deg + b.deg); 240 UpdateDegIfDirty(); 266 241 b.UpdateDegIfDirty(); 267 242 268 c.deg = a.deg + b.deg;243 c.deg = deg + b.deg; 269 244 270 245 for (int i=0; i<=c.deg; i++) { 271 246 c[i] = 0; 272 int kmin = (i <= a.deg) ? 0 : i - a.deg;273 int kmax = (i <= a.deg) ? i : a.deg;247 int kmin = (i <= deg) ? 0 : i - deg; 248 int kmax = (i <= deg) ? i : deg; 274 249 for (int k=kmin; k<=kmax; k++) 275 c[i] += a[k] * b[i-k]; 276 } 277 //#if !HAS_NAMED_RETURN 250 c[i] += (*this)[k] * b[i-k]; 251 } 278 252 return c; 279 //#endif280 }281 282 //++283 Poly& Poly::operator *= (double a)284 //285 //--286 {287 UpdateDegIfDirty();288 289 for (int i=0; i<=deg; i++)290 data[i] *= a;291 292 return *this;293 }294 295 296 //++297 Poly operator* (double a, Poly const& b)298 //299 //--300 #if HAS_NAMED_RETURN301 return c(b)302 #endif303 {304 #if !HAS_NAMED_RETURN305 Poly c(b);306 #endif307 308 c *= a;309 310 #if !HAS_NAMED_RETURN311 return c;312 #endif313 }314 315 316 void Poly::ReadSelf(PInPersist& s)317 {318 int_4 dg;319 s >> dg;320 Realloc(dg, true);321 322 #ifdef DEBUG323 int r = nr; int c = nc;324 #endif325 326 OVector::ReadSelf(s);327 328 #ifdef DEBUG329 DBASSERT(r == nr && c == nc);330 #endif331 UpdateDeg();332 333 #ifdef DEBUG334 DBASSERT(dg == deg);335 #endif336 }337 338 void Poly::WriteSelf(POutPersist& s) const339 {340 UpdateDegIfDirty();341 ((Poly*)(this))->Realloc(deg, true);342 s << deg;343 OVector::WriteSelf(s);344 253 } 345 254 … … 365 274 366 275 //++ 367 ostream& operator << (ostream& s, const Poly& a) 368 // 369 // Impressions sur le stream "s". 370 //-- 371 { 372 a.Print(s); 373 return s; 374 } 375 376 //++ 377 double Poly::Fit(OVector const& x, OVector const& y, int degre) 276 double Poly::Fit(Vector const& x, Vector const& y, int degre) 378 277 // 379 278 // Ajustement polynomial par moindre carrés. Un polynôme de … … 387 286 Realloc(degre); 388 287 389 OMatrix a(degre+1, n);288 Matrix a(degre+1, n); 390 289 391 290 for (int c=0; c<n; c++) { … … 397 296 } 398 297 399 double rc = LinFit(a,y,( OVector&)*this);298 double rc = LinFit(a,y,(Vector&)*this); 400 299 UpdateDeg(); 401 300 return rc; … … 403 302 404 303 //++ 405 double Poly::Fit( OVector const& x, OVector const& y, OVector const& erry2, int degre,406 OVector& errCoef)304 double Poly::Fit(Vector const& x, Vector const& y, Vector const& erry2, int degre, 305 Vector& errCoef) 407 306 // 408 307 // Ajustement polynomial par moindre carrés. Un polynôme de … … 419 318 errCoef.Realloc(degre+1); 420 319 421 OMatrix a(degre+1, n);320 Matrix a(degre+1, n); 422 321 423 322 for (int c=0; c<n; c++) { … … 429 328 } 430 329 431 double rc = LinFit(a,y,erry2,( OVector&)*this,errCoef);330 double rc = LinFit(a,y,erry2,(Vector&)*this,errCoef); 432 331 UpdateDeg(); 433 332 return rc; 434 333 } 435 334 335 336 //++ 337 // Poly Poly::power(int n) const 338 // 339 // Retourne le polynôme à la puissance n 340 //-- 341 342 Poly Poly::power(int n) const // a accelerer !!! 343 { 344 if (n < 0) THROW(rangeCheckErr); 345 if (n == 0) { Poly r(0); r[0] = 1; return r;} 346 if (n == 1) { return *this; } 347 return *this * power(n-1); 348 } 349 350 //++ 351 Poly Poly::operator() (Poly const& b) const 352 // 353 // Substitution d'un polynôme dans un autre. 354 //-- 355 { 356 Poly c(b.Degre()*Degre()); 357 for (int i=0; i<= Degre(); i++) 358 c += (*this)[i] * b.power(i); 359 return c; 360 } 361 362 363 ////////////////////////////////////////////////////////////////////////// 364 void ObjFileIO<Poly>::ReadSelf(PInPersist& is) 365 { 366 if(dobj==NULL) dobj=new Poly; 367 int_4 dg; 368 is >> dg; 369 dobj->Realloc(dg,true); 370 is >> *((Vector *) dobj); 371 dobj->UpdateDeg(); 372 } 373 374 void ObjFileIO<Poly>::WriteSelf(POutPersist& os) const 375 { 376 if(dobj == NULL) return; 377 dobj->UpdateDegIfDirty(); 378 dobj->Realloc(dobj->deg,true); 379 os << dobj->deg; 380 os << *((Vector *) dobj); 381 } 382 383 ////////////////////////////////////////////////////////////////////////// 436 384 int binomial(int n, int p) 437 385 { … … 442 390 } 443 391 444 445 //++ 446 // Poly Poly::power(int n) const 447 // 448 // Retourne le polynôme à la puissance n 449 //-- 450 451 Poly Poly::power(int n) const // a accelerer !!! 452 { 453 if (n < 0) THROW(rangeCheckErr); 454 if (n == 0) { Poly r(0); r[0] = 1; return r;} 455 if (n == 1) { return *this; } 456 return *this * power(n-1); 457 } 458 459 //++ 460 Poly Poly::operator() (Poly const& b) const 461 // 462 // Substitution d'un polynôme dans un autre. 463 //-- 464 { 465 Poly c(b.Degre()*Degre()); 466 for (int i=0; i<= Degre(); i++) 467 c += (*this)[i] * b.power(i); 468 return c; 469 } 470 471 392 ////////////////////////////////////////////////////////////////////////// 472 393 // ******************* POLY 2 VARIABLES ****************** 473 474 394 //++ 475 395 // Class Poly2 … … 482 402 //++ 483 403 // Links Parents 484 // OVector404 // Vector 485 405 //-- 486 406 … … 494 414 // Crée un polynôme de degrés partiels degreX et degreY. 495 415 //-- 496 : OVector((degreX+1)*(degreY+1)), dirty(0),416 :Vector((degreX+1)*(degreY+1)), dirty(0), 497 417 maxDegX(degreX), maxDegY(degreY), degX(0), degY(0), deg(0) 498 418 { … … 506 426 // de deux polynômes à une variable, p2(x,y)=px(x)py(y) 507 427 //-- 508 : OVector((polX.Degre()+1)*(polY.Degre()+1)), dirty(0),428 :Vector((polX.Degre()+1)*(polY.Degre()+1)), dirty(0), 509 429 maxDegX(polX.Degre()), maxDegY(polY.Degre()), 510 430 degX(polX.Degre()), degY(polY.Degre()), deg(degX+degY) … … 521 441 // Constructeur par copie. 522 442 //-- 523 : OVector(a), dirty(a.dirty),443 :Vector(a), dirty(a.dirty), 524 444 maxDegX(a.maxDegX), maxDegY(a.maxDegY), 525 445 degX(a.degX), degY(a.degY), deg(a.deg) … … 561 481 UpdateDegIfDirty(); 562 482 Poly2 tmp(*this); 563 OVector::Realloc((degreX+1)*(degreY+1));564 Zero();483 Vector::Realloc((degreX+1)*(degreY+1)); 484 Reset(); 565 485 maxDegX = degreX; 566 486 maxDegY = degreY; … … 631 551 632 552 //++ 633 double Poly2::Fit( OVector const& x, OVector const& y, OVector const& z,553 double Poly2::Fit(Vector const& x, Vector const& y, Vector const& z, 634 554 int degreX, int degreY) 635 555 // … … 643 563 Realloc(degreX, degreY); 644 564 645 OMatrix a((degreX+1)*(degreY+1), n);565 Matrix a((degreX+1)*(degreY+1), n); 646 566 647 567 for (int c=0; c<n; c++) { … … 657 577 } 658 578 659 double rc = LinFit(a,z,( OVector&)*this);579 double rc = LinFit(a,z,(Vector&)*this); 660 580 UpdateDeg(); 661 581 return rc; … … 664 584 665 585 //++ 666 double Poly2::Fit( OVector const& x, OVector const& y, OVector const& z,667 OVector const& errz2, int degreX, int degreY,668 OVector& errCoef)586 double Poly2::Fit(Vector const& x, Vector const& y, Vector const& z, 587 Vector const& errz2, int degreX, int degreY, 588 Vector& errCoef) 669 589 // 670 590 // Ajustement par moindre carrés z = P(x,y), degrés partiels imposés, … … 680 600 errCoef.Realloc((degreX+1)*(degreY+1)); 681 601 682 OMatrix a((degreX+1)*(degreY+1), n);602 Matrix a((degreX+1)*(degreY+1), n); 683 603 684 604 for (int c=0; c<n; c++) { … … 694 614 } 695 615 696 double rc = LinFit(a,z,errz2,( OVector&)*this,errCoef);616 double rc = LinFit(a,z,errz2,(Vector&)*this,errCoef); 697 617 UpdateDeg(); 698 618 return rc; … … 700 620 701 621 //++ 702 double Poly2::Fit( OVector const& x, OVector const& y, OVector const& z,622 double Poly2::Fit(Vector const& x, Vector const& y, Vector const& z, 703 623 int degre) 704 624 // … … 712 632 Realloc(degre, degre); // certains vaudront 0, impose. 713 633 714 OMatrix a((degre+1)*(degre+2)/2, n);715 OVector cf((degre+1)*(degre+2)/2);634 Matrix a((degre+1)*(degre+2)/2, n); 635 Vector cf((degre+1)*(degre+2)/2); 716 636 #define C_INDEX(i,j) ((i) + (j)*(2*degre+3-(j))/2) 717 637 … … 744 664 745 665 //++ 746 double Poly2::Fit( OVector const& x, OVector const& y, OVector const& z,747 OVector const& errz2, int degre,748 OVector& errCoef)666 double Poly2::Fit(Vector const& x, Vector const& y, Vector const& z, 667 Vector const& errz2, int degre, 668 Vector& errCoef) 749 669 // 750 670 // Ajustement par moindre carrés z = P(x,y), degré total imposé, … … 761 681 #define C_INDEX(i,j) ((i) + (j)*(2*degre+3-(j))/2) 762 682 763 OMatrix a((degre+1)*(degre+2)/2, n);764 OVector cf((degre+1)*(degre+2)/2);765 OVector ecf((degre+1)*(degre+2)/2);683 Matrix a((degre+1)*(degre+2)/2, n); 684 Vector cf((degre+1)*(degre+2)/2); 685 Vector ecf((degre+1)*(degre+2)/2); 766 686 767 687 for (int c=0; c<n; c++) { … … 792 712 UpdateDeg(); 793 713 return rc; 794 }795 796 797 void Poly2::ReadSelf(PInPersist& s)798 {799 int_4 dgx, dgy;800 s >> dgx >> dgy;801 802 Realloc(dgx, dgy);803 804 #ifdef DEBUG805 int r = nr; int c = nc;806 #endif807 808 OVector::ReadSelf(s);809 810 #ifdef DEBUG811 DBASSERT(r == nr && c == nc);812 #endif813 UpdateDeg();814 }815 816 void Poly2::WriteSelf(POutPersist& s) const817 {818 s << maxDegX << maxDegY;819 OVector::WriteSelf(s);820 714 } 821 715 … … 850 744 851 745 //++ 852 ostream& operator << (ostream& s, const Poly2& a)853 //854 // Impression sur stream s.855 //--856 {857 a.Print(s);858 return s;859 }860 861 862 //++863 746 // Titre Opérations 864 747 //-- … … 905 788 906 789 //++ 907 Poly2 operator+ (Poly2 const& a, Poly2 const& b)908 //909 //--910 #if HAS_NAMED_RETURN911 return c(a)912 #endif913 {914 #if !HAS_NAMED_RETURN915 Poly2 c(a);916 #endif917 c += b;918 #if !HAS_NAMED_RETURN919 return c;920 #endif921 }922 923 //++924 Poly2 operator- (Poly2 const& a, Poly2 const& b)925 //926 //--927 #if HAS_NAMED_RETURN928 return c(a)929 #endif930 {931 #if !HAS_NAMED_RETURN932 Poly2 c(a);933 #endif934 c -= b;935 #if !HAS_NAMED_RETURN936 return c;937 #endif938 }939 940 //++941 790 Poly2& Poly2::operator *= (double a) 942 791 // … … 944 793 { 945 794 for (int i=0; i<NElts(); i++) 946 data[i]*= a;795 Element(i) *= a; 947 796 948 797 return *this; … … 950 799 951 800 //++ 952 Poly2 operator * (double a, Poly2 const& b) 953 // 954 //-- 955 #if HAS_NAMED_RETURN 956 return c(b) 957 #endif 958 { 959 #if !HAS_NAMED_RETURN 960 Poly2 c(b); 961 #endif 962 c *= a; 963 #if !HAS_NAMED_RETURN 964 return c; 965 #endif 966 } 967 968 //++ 969 Poly2 operator* (Poly2 const& a, Poly2 const& b) 970 // 971 //-- 972 { 973 Poly2 c(a.DegX() + b.DegX(), a.DegY() + b.DegY()); 974 a.UpdateDegIfDirty(); 801 Poly2 Poly2::Mult(Poly2 const& b) const 802 // 803 //-- 804 { 805 Poly2 c(DegX() + b.DegX(), DegY() + b.DegY()); 806 UpdateDegIfDirty(); 975 807 b.UpdateDegIfDirty(); 976 808 977 for (int i=0; i<= a.DegX(); i++)978 for (int j=0; j<= a.DegY(); j++)809 for (int i=0; i<=DegX(); i++) 810 for (int j=0; j<=DegY(); j++) 979 811 for (int k=0; k<=b.DegX(); k++) 980 812 for (int l=0; l<=b.DegY(); l++) 981 c.Coef(i+k,j+l) += a.Coef(i,j)*b.Coef(k,l);813 c.Coef(i+k,j+l) += Coef(i,j)*b.Coef(k,l); 982 814 return c; 983 815 } … … 1029 861 } 1030 862 1031 863 ////////////////////////////////////////////////////////////////////////// 864 void ObjFileIO<Poly2>::ReadSelf(PInPersist& is) 865 { 866 if(dobj==NULL) dobj=new Poly2; 867 int_4 dgx, dgy; 868 is >> dgx >> dgy; 869 dobj->Realloc(dgx,dgy); 870 is >> *((Vector *) dobj); 871 dobj->UpdateDeg(); 872 } 873 874 void ObjFileIO<Poly2>::WriteSelf(POutPersist& os) const 875 { 876 if(dobj == NULL) return; 877 os << dobj->maxDegX << dobj->maxDegY; 878 os << *((Vector *) dobj); 879 } 880 881 882 ////////////////////////////////////////////////////////////////////////// 883 #ifdef __CXX_PRAGMA_TEMPLATES__ 884 #pragma define_template ObjFileIO<Poly> 885 #pragma define_template ObjFileIO<Poly2> 886 #endif 887 888 #if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES) 889 template class ObjFileIO<Poly>; 890 template class ObjFileIO<Poly2>; 891 #endif -
trunk/SophyaLib/NTools/poly.h
r508 r514 1 1 // This may look like C code, but it is really -*- C++ -*- 2 2 // 3 // $Id: poly.h,v 1. 2 1999-10-25 10:36:11 ansari Exp $3 // $Id: poly.h,v 1.3 1999-10-25 16:40:01 ansari Exp $ 4 4 // 5 6 5 7 6 // Des polynomes avec des operations de bases et surtout des fits. … … 10 9 #define POLY_SEEN 11 10 11 #include "objfio.h" 12 12 #include <stdio.h> 13 13 #include "peida.h" 14 #include "cvector.h" 14 #include "tvector.h" 15 #include "ppersist.h" 16 #include "anydataobj.h" 17 18 namespace PlanckDPC { 15 19 16 20 class Poly2; 17 21 18 class Poly : public OVector { 22 ////////////////////////////////////////////////////////////////////////// 23 class Poly : public Vector { 24 friend class ObjFileIO<Poly>; 19 25 public: 20 26 Poly(int degre = 0); 27 Poly(Poly const& a); 21 28 22 29 enum {classId = ClassId_Poly1}; 23 int_4 ClassId() const { return classId; } 24 static PPersist* Create() {return new Poly;} 30 int_4 ClassId() const { return classId; } 25 31 26 32 inline int Degre() const {UpdateDegIfDirty(); return deg;} 27 33 28 inline void Realloc(int n, bool force=false) { OVector::Realloc(n+1,force);}29 30 inline double operator[](int i) const {return data[i];}31 inline double& operator[](int i) {dirty = 1; return data[i];}34 inline void Realloc(int n, bool force=false) {Vector::Realloc(n+1,force);} 35 36 inline double operator[](int i) const {return Element(i);} 37 inline double& operator[](int i) {dirty = 1; return Element(i);} 32 38 // Retourne le coefficient de degre i 33 39 … … 41 47 // Derive le polynome dans un autre 42 48 43 int Roots( OVector& roots) const;49 int Roots(Vector& roots) const; 44 50 // retourne les racines si on peut les calculer... 45 51 … … 49 55 int Root2(double& r1, double& r2) const; 50 56 // special degre 2 51 52 friend Poly operator* (Poly const& a, Poly const& b);53 friend Poly operator+ (Poly const& a, Poly const& b);54 friend Poly operator- (Poly const& a, Poly const& b);55 57 56 58 Poly& operator = (Poly const& b); … … 58 60 Poly& operator -= (Poly const& b); 59 61 60 friend Poly operator* (double a, Poly const& b);61 62 62 Poly& operator *= (double a); 63 64 Poly Mult(Poly const& b) const; 63 65 64 66 Poly power(int n) const; … … 66 68 Poly2 operator() (Poly2 const& b) const; 67 69 68 void ReadSelf(PInPersist&);69 void WriteSelf(POutPersist&) const;70 71 70 void Print(ostream& s) const; 72 friend ostream& operator << (ostream& s, const Poly& a); 73 74 double Fit(OVector const& x, OVector const& y, int degre); 71 72 double Fit(Vector const& x, Vector const& y, int degre); 75 73 // Fit d'un polynome de degre donne sur les x et y. 76 74 77 double Fit( OVector const& x, OVector const& y, OVector const& erry2, int degre,78 OVector& errCoef);75 double Fit(Vector const& x, Vector const& y, Vector const& erry2, int degre, 76 Vector& errCoef); 79 77 // En plus, on fournit les carres des erreurs sur y et on a les erreurs 80 78 // sur les coefficients dans un vecteur. … … 87 85 }; 88 86 87 inline Poly operator* (Poly const& a, Poly const& b) 88 { return a.Mult(b); } 89 90 inline Poly operator+ (Poly const& a, Poly const& b) 91 { Poly c((a.Degre() > b.Degre())?(a.Degre()+1):(b.Degre()+1)); 92 c = a; c += b; return c; } 93 94 inline Poly operator- (Poly const& a, Poly const& b) 95 { Poly c((a.Degre() > b.Degre())?(a.Degre()+1):(b.Degre()+1)); 96 c = a; c -= b; return c; } 97 98 inline Poly operator* (double a, Poly const& b) 99 { Poly c(b); c *= a; return c; } 100 101 inline ostream& operator << (ostream& s, const Poly& a) 102 { a.Print(s); return s; } 103 104 ////////////////////////////////////////////////////////////////////////// 105 inline POutPersist& operator << (POutPersist& os, Poly & obj) 106 { ObjFileIO<Poly> fio(&obj); fio.Write(os); return(os); } 107 inline PInPersist& operator >> (PInPersist& is, Poly & obj) 108 { ObjFileIO<Poly> fio(&obj); fio.Read(is); return(is); } 109 // Classe pour la gestion de persistance 110 // ObjFileIO<Poly> 111 112 ////////////////////////////////////////////////////////////////////////// 89 113 int binomial(int n, int p); 90 114 91 92 class Poly2 : public OVector { // Ca pourrait etre une matrice mais 93 // la encore, un vecteur est utile pour les 94 // fits. 95 115 ////////////////////////////////////////////////////////////////////////// 116 class Poly2 : public Vector { 117 friend class ObjFileIO<Poly2>; 96 118 public: 97 119 Poly2(int degreX=0, int degreY=0); … … 101 123 102 124 enum {classId = ClassId_Poly2}; 103 int_4 ClassId() const { return classId; } 104 static PPersist* Create() {return new Poly2;} 125 int_4 ClassId() const { return classId; } 105 126 106 127 inline int DegX() const {UpdateDegIfDirty(); return degX;} … … 123 144 124 145 inline double Coef(int dx, int dy) const { 125 return (dx>maxDegX || dy>maxDegY) ? 0 : data[IndCoef(dx,dy)];146 return (dx>maxDegX || dy>maxDegY) ? 0 : Element(IndCoef(dx,dy)); 126 147 } 127 148 inline double& Coef(int dx, int dy) { 128 149 if (dx>maxDegX || dy>maxDegY) THROW(rangeCheckErr); 129 dirty = 1; return data[IndCoef(dx,dy)];150 dirty = 1; return Element(IndCoef(dx,dy)); 130 151 } 131 152 // retourne le coefficient de degre (dx,dy) 132 153 133 double Fit( OVector const& x, OVector const& y, OVector const& z,154 double Fit(Vector const& x, Vector const& y, Vector const& z, 134 155 int degreX, int degreY); 135 double Fit( OVector const& x, OVector const& y, OVector const& z,136 OVector const& errz2, int degreX, int degreY,137 OVector& errCoef);156 double Fit(Vector const& x, Vector const& y, Vector const& z, 157 Vector const& errz2, int degreX, int degreY, 158 Vector& errCoef); 138 159 // degres partiels imposes. cf Poly::Fit sinon 139 160 140 161 141 double Fit( OVector const& x, OVector const& y, OVector const& z,162 double Fit(Vector const& x, Vector const& y, Vector const& z, 142 163 int degre); 143 double Fit( OVector const& x, OVector const& y, OVector const& z,144 OVector const& errz2, int degre,145 OVector& errCoef);164 double Fit(Vector const& x, Vector const& y, Vector const& z, 165 Vector const& errz2, int degre, 166 Vector& errCoef); 146 167 // degre total impose. cf Poly::Fit sinon 147 168 … … 151 172 Poly2& operator -= (Poly2 const& b); 152 173 153 friend Poly2 operator + (Poly2 const& a, Poly2 const& b);154 friend Poly2 operator - (Poly2 const& a, Poly2 const& b); 155 friend Poly2 operator * (Poly2 const& a, Poly2 const& b);174 Poly2& operator *= (double a); 175 176 Poly2 Mult(Poly2 const& b) const; 156 177 157 178 Poly2 power(int n) const; 158 159 Poly2& operator *= (double a);160 friend Poly2 operator * (double a, Poly2 const& b);161 179 162 180 Poly2 operator() (Poly const& px, Poly const& py) const; … … 165 183 void Realloc(int degreX, int degreY); 166 184 167 void ReadSelf(PInPersist&);168 void WriteSelf(POutPersist&) const;169 170 185 void Print(ostream& s) const; 171 friend ostream& operator << (ostream& s, const Poly2& a);172 186 173 187 private: … … 182 196 }; 183 197 198 inline Poly2 operator* (Poly2 const& a, Poly2 const& b) 199 { return a.Mult(b); } 200 201 inline Poly2 operator+ (Poly2 const& a, Poly2 const& b) 202 { Poly2 c(a); c += b; return c; } 203 204 inline Poly2 operator- (Poly2 const& a, Poly2 const& b) 205 { Poly2 c(a); c -= b; return c; } 206 207 inline Poly2 operator * (double a, Poly2 const& b) 208 { Poly2 c(b); c *= a; return c; } 209 210 inline ostream& operator << (ostream& s, const Poly2& a) 211 { a.Print(s); return s; } 212 213 ////////////////////////////////////////////////////////////////////////// 214 inline POutPersist& operator << (POutPersist& os, Poly2 & obj) 215 { ObjFileIO<Poly2> fio(&obj); fio.Write(os); return(os); } 216 inline PInPersist& operator >> (PInPersist& is, Poly2 & obj) 217 { ObjFileIO<Poly2> fio(&obj); fio.Read(is); return(is); } 218 // Classe pour la gestion de persistance 219 // ObjFileIO<Poly2> 220 221 222 } // Fin du namespace 223 184 224 #endif // POLY_SEEN -
trunk/SophyaLib/NTools/rk4cdifeq.cc
r508 r514 74 74 //++ 75 75 RK4CDiffEq& 76 RK4CDiffEq::AbsAccuracy( OVector const& vScal)76 RK4CDiffEq::AbsAccuracy(Vector const& vScal) 77 77 // 78 78 // On souhaite une précision absolue, et le vecteur vScal contient … … 118 118 119 119 void 120 RK4CDiffEq::RKCStep( OVector& newY, OVector const& y0, OVector const& yScale,120 RK4CDiffEq::RKCStep(Vector& newY, Vector const& y0, Vector const& yScale, 121 121 double dttry, double& dtdone, double& dtnext) 122 122 { … … 151 151 // Et on corrige a l'ordre 5 152 152 153 newY += yTemp/15 ;153 newY += yTemp/15.; 154 154 } 155 155 156 156 void 157 RK4CDiffEq::SolveArr( OMatrix& y, double* t, double tf, int n)157 RK4CDiffEq::SolveArr(Matrix& y, double* t, double tf, int n) 158 158 { 159 159 //TIMEF; … … 162 162 double dxres = (tf - mXStart)/n; 163 163 164 OVector yt = mYStart;164 Vector yt = mYStart; 165 165 166 166 k1.Realloc(mFunc->NFuncReal()); -
trunk/SophyaLib/NTools/rk4cdifeq.h
r508 r514 4 4 5 5 #include "difeq.h" 6 7 namespace PlanckDPC { 6 8 7 9 // <summary> Runge-Kutta ordre 4 adaptatif </summary> … … 20 22 // <group> 21 23 RK4CDiffEq& Accuracy(double); 22 RK4CDiffEq& AbsAccuracy( OVector const& vScal);24 RK4CDiffEq& AbsAccuracy(Vector const& vScal); 23 25 RK4CDiffEq& AbsAccuracy(double scal); 24 26 RK4CDiffEq& RelAccuracy(); … … 26 28 27 29 // Implementation RK4 adaptatif 28 virtual void SolveArr( OMatrix& y, double* t, double tf, int n);30 virtual void SolveArr(Matrix& y, double* t, double tf, int n); 29 31 30 32 protected: 31 33 // Un pas adaptatif 32 void RKCStep( OVector& newY, OVector const& y0, OVector const& yScale,34 void RKCStep(Vector& newY, Vector const& y0, Vector const& yScale, 33 35 double dttry, double& dtdone, double& dtnext); 34 36 35 37 double eps; 36 38 bool relAccuracy; 37 OVector accScale;38 OVector yTemp; // Pour ne pas reallouer39 OVector ySave;39 Vector accScale; 40 Vector yTemp; // Pour ne pas reallouer 41 Vector ySave; 40 42 }; 41 43 44 } // Fin du namespace 45 42 46 #endif -
trunk/SophyaLib/NTools/rzimage.cc
r508 r514 5 5 // LAL (Orsay) / IN2P3-CNRS DAPNIA/SPP (Saclay) / CEA 6 6 7 // $Id: rzimage.cc,v 1. 5 1999-10-25 10:36:12ansari Exp $7 // $Id: rzimage.cc,v 1.6 1999-10-25 16:40:03 ansari Exp $ 8 8 9 9 #include "machdefs.h" … … 765 765 GeneralFunction* f = gfit.GetFunction(); 766 766 if(f==NULL) return NULL; 767 OVector par = gfit.GetParm();767 Vector par = gfit.GetParm(); 768 768 RzImage* img = new RzImage(DataType((r_4)0.),XSize(),YSize()); 769 769 img->SetOrg(XOrg(),YOrg()); … … 790 790 GeneralFunction* f = gfit.GetFunction(); 791 791 if(f==NULL) return NULL; 792 OVector par = gfit.GetParm();792 Vector par = gfit.GetParm(); 793 793 RzImage* img = new RzImage(DataType((r_4)0.),XSize(),YSize()); 794 794 img->SetOrg(XOrg(),YOrg()); -
trunk/SophyaLib/NTools/tmatrix.cc
r508 r514 1 // $Id: tmatrix.cc,v 1.1 1 1999-10-25 10:36:12ansari Exp $1 // $Id: tmatrix.cc,v 1.12 1999-10-25 16:40:03 ansari Exp $ 2 2 // C.Magneville 04/99 3 3 #include "machdefs.h" … … 10 10 #include "tmatrix.h" 11 11 #include "objfio.h" 12 13 using namespace PlanckDPC;14 12 15 13 //////////////////////////////////////////////////////////////// … … 184 182 } 185 183 186 #include "matrix.h"187 184 //////////////////////////////////////////////////////////////// 188 185 //**** Pour inversion -
trunk/SophyaLib/NTools/tmatrix.h
r508 r514 50 50 inline uint_4 NRows() const {return mNr;} 51 51 inline uint_4 NCols() const {return mNc;} 52 inline uint_4 NCol() const {return mNc;} // back-compat Peida 52 53 inline T const& operator()(uint_4 r,uint_4 c) const 53 54 {return *(mNDBlock.Begin()+r*mNc+c);} … … 139 140 140 141 //////////////////////////////////////////////////////////////// 141 // Surcharge d'operateurs A (+ =,-=,*=,/=) (T) x142 // Surcharge d'operateurs A (+,-,*,/) (T) x 142 143 143 144 template <class T> inline TMatrix<T> operator + (const TMatrix<T>& a, T b) -
trunk/SophyaLib/NTools/tvector.cc
r306 r514 1 // $Id: tvector.cc,v 1. 4 1999-05-19 10:17:42ansari Exp $1 // $Id: tvector.cc,v 1.5 1999-10-25 16:40:04 ansari Exp $ 2 2 // C.Magneville 04/99 3 3 #include "machdefs.h" … … 9 9 #include "tvector.h" 10 10 #include "objfio.h" 11 12 using namespace PlanckDPC;13 11 14 12 template <class T> -
trunk/SophyaLib/NTools/tvector.h
r508 r514 47 47 48 48 // produit scalaire, matrice*vecteur 49 template <class T> inline T operator* (const TVector<T>& v1, const TVector<T>& v2) 49 template <class T> 50 inline T operator* (const TVector<T>& v1, const TVector<T>& v2) 50 51 {if(v1.NRows() != v2.NRows()) 51 52 throw(SzMismatchError("TVector::operator*(TVector& v1,TVector v2) size mismatch")); … … 55 56 return r;} 56 57 57 template <class T> inline TVector<T> operator* (const TMatrix<T>& a, const TVector<T>& b) 58 {return TVector<T>(a * ((TMatrix<T> const&)(b)));} 58 template <class T> 59 inline TVector<T> operator* (const TMatrix<T>& a, const TVector<T>& b) 60 {return TVector<T>(a * ((TMatrix<T> const&)(b)));} 59 61 60 62 // Resolution du systeme A*C = B -
trunk/SophyaLib/Samba/anagen.cc
r508 r514 37 37 double phi0; 38 38 float theta; 39 OVector phin, datan, phis, datas;39 Vector phin, datan, phis, datas; 40 40 map.GetThetaSlice(map.NbThetaSlices()-ith-1,theta,phis,datas); 41 41 map.GetThetaSlice(ith,theta,phin,datan); … … 77 77 78 78 79 void comp_phas2gen(int nsmax,int nlmax,int nmmax, OVector datain,79 void comp_phas2gen(int nsmax,int nlmax,int nmmax, Vector datain, 80 80 int nph,vector< complex<double> >& dataout,double phi0){ 81 81 /*======================================================================= … … 92 92 //FFTVector outf=FFTServer::solve(inf,-1); 93 93 FFTServer fft; 94 OVector outf;94 Vector outf; 95 95 //cout<<"in :"<<datain<<endl; 96 96 fft.fftb(datain,outf); -
trunk/SophyaLib/Samba/anagen.h
r508 r514 4 4 #include <complex> 5 5 #include <vector> 6 #include " cvector.h"6 #include "tvector.h" 7 7 #include "sphericalmap.h" 8 8 … … 10 10 vector< vector< complex<double> > >& alm, double cos_theta_cut); 11 11 12 void comp_phas2gen(int nsmax,int nlmax,int nmmax, OVector datain,12 void comp_phas2gen(int nsmax,int nlmax,int nmmax, Vector datain, 13 13 int nph,vector< complex<double> >& dataout,double phi0); 14 14 -
trunk/SophyaLib/Samba/syngen.cc
r508 r514 43 43 double phi0; 44 44 float theta,thetas; 45 OVector phin, datan,phis,datas;45 Vector phin, datan,phis,datas; 46 46 map.GetThetaSlice(map.NbThetaSlices()-ith-1,thetas,phis,datas); 47 47 map.GetThetaSlice(ith,theta,phin,datan); … … 104 104 void syn_phasgen(const int nsmax,const int nlmax,const int nmmax, 105 105 const vector< complex<long double> >& datain, 106 int nph, OVector& dataout, double phi0,106 int nph, Vector& dataout, double phi0, 107 107 vector< complex<long double> >& bw){ 108 108 -
trunk/SophyaLib/Samba/syngen.h
r508 r514 4 4 #include <complex> 5 5 #include <vector> 6 #include " cvector.h"6 #include "tvector.h" 7 7 #include "sphericalmap.h" 8 8 … … 18 18 void syn_phasgen(const int nsmax,const int nlmax,const int nmmax, 19 19 const vector< complex<long double> >& datain, 20 int nph, OVector& dataout, double phi0,20 int nph, Vector& dataout, double phi0, 21 21 vector< complex<long double> >& bw); 22 22
Note:
See TracChangeset
for help on using the changeset viewer.