Changeset 958 in Sophya for trunk/SophyaLib/NTools
- Timestamp:
- Apr 18, 2000, 3:38:53 PM (25 years ago)
- Location:
- trunk/SophyaLib/NTools
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/NTools/generaldata.cc
r938 r958 549 549 if(var<0 || var>3) return -1; 550 550 if(var>=2 && (ix<0 || ix>=mNVar) ) return -1; 551 double min , max;551 double min=1., max=-1.; 552 552 int ntest = 0; 553 553 for(int i=0;i<mNData;i++) { 554 554 if( ! IsValid(i) ) continue; 555 555 double v; 556 if(var== 0) v =Val(i);557 else if(var==1) v = EVal(i);558 else if(var==2) v =Absc(ix,i);559 else if(var==3) v = EAbsc(ix,i);556 if(var==1) v = EVal(i); 557 else if(var==2) v = Absc(ix,i); 558 else if(var==3) v = EAbsc(ix,i); 559 else v = Val(i); 560 560 if(ntest==0) {min = max = v; imin = imax = i;} 561 561 if(v<min) {min = v; imin = i;} … … 616 616 if( ! IsValid(i) ) continue; 617 617 double v; 618 if(var== 0) v =Val(i);619 else if(var==1) v = EVal(i);620 else if(var==2) v =Absc(ix,i);621 else if(var==3) v = EAbsc(ix,i);618 if(var==1) v = EVal(i); 619 else if(var==2) v = Absc(ix,i); 620 else if(var==3) v = EAbsc(ix,i); 621 else v = Val(i); 622 622 if(min<max && (v<min || max<v)) continue; 623 623 mean += v; … … 662 662 if( ! IsValid(i) ) continue; 663 663 double v; 664 if(var== 0) v =Val(i);665 else if(var==1) v = EVal(i);666 else if(var==2) v =Absc(ix,i);667 else if(var==3) v = EAbsc(ix,i);664 if(var==1) v = EVal(i); 665 else if(var==2) v = Absc(ix,i); 666 else if(var==3) v = EAbsc(ix,i); 667 else v = Val(i); 668 668 if(min<max && (v<min || max<v)) continue; 669 669 buff[ntest] = v; -
trunk/SophyaLib/NTools/generaldata.h
r926 r958 158 158 void Delete(); 159 159 160 int_4 mNVar; 161 int_4 mNDataAlloc; 162 int_4 mNData; 163 int_4 mNDataGood; 164 uint_2 mOk_EXP; 160 int_4 mNVar; //!< number of variables 161 int_4 mNDataAlloc; //!< space allocated for datas 162 int_4 mNData; //!< number of datas 163 int_4 mNDataGood; //!< number of good datas (not killed) 164 uint_2 mOk_EXP; //!< true if errors on variables X,Y,.. 165 165 r_8* mXP; //!< x0 y0 z0, x1 y1 z1, ..., xn yn zn 166 166 r_8* mErrXP; //!< Ex0 Ey0 Ez0, Ex1 Ey1 Ez1, ..., Exn Eyn Ezn … … 168 168 r_8* mErr; //!< EF0, EF1, ...., EFn 169 169 uint_2* mOK; //!< 1 si pt valid, 0 sinon 170 r_8* BuffVar; 171 r_4* BuffVarR4; 170 r_8* BuffVar; //!< dummy buffer 171 r_4* BuffVarR4; //!< dummy buffer 172 172 }; 173 173 … … 178 178 // Classe pour la gestion de persistance 179 179 180 //! For persistance management 180 181 inline POutPersist& operator << (POutPersist& os, GeneralFitData & obj) 181 182 { ObjFileIO<GeneralFitData> fio(&obj); fio.Write(os); return(os); } 183 //! For persistance management 182 184 inline PInPersist& operator >> (PInPersist& is, GeneralFitData & obj) 183 185 { ObjFileIO<GeneralFitData> fio(&obj); fio.Read(is); return(is); } -
trunk/SophyaLib/NTools/poly.cc
r938 r958 4 4 #include "fioarr.h" 5 5 6 //++ 7 // Class Poly 8 // Lib Outils++ 9 // include poly.h 10 // 11 // Classe de calcul sur polynômes à une variable. 12 //-- 13 14 //++ 15 // Links Parents 16 // Vector 17 //-- 18 19 //++ 20 // Titre Constructeurs 21 //-- 22 23 24 ////////////////////////////////////////////////////////////////////////// 25 //++ 26 // Poly::Poly(int degre=0) 27 // 28 // Crée un nouveau polynôme, en allouant de la place pour 29 // le degré spécifié. 30 //-- 31 6 //////////////////////////////////////////////////////////// 7 //////////////////////////////////////////////////////////// 8 //////////////////////////////////////////////////////////// 9 //////////////////////////////////////////////////////////// 10 //////////////////////////////////////////////////////////// 11 /*! 12 \class SOPHYA::Poly 13 \ingroup NTools 14 One dimensional polynomials class. 15 */ 16 17 //! Constructor 18 /*! Create a 1D polynomial of degre \b degre */ 32 19 Poly::Poly(int degre) 33 20 : TVector<r_8>(degre+1), dirty(0), deg(0) … … 36 23 } 37 24 38 // ++25 //! Constructor by copy 39 26 Poly::Poly(Poly const& a) 40 //41 // Constructeur par copie.42 //--43 27 :TVector<r_8>(a), dirty(a.dirty), deg(a.deg) 44 28 { … … 46 30 } 47 31 48 32 //! update degre 33 /*! update degre (that could be changed after operations) */ 49 34 void Poly::UpdateDeg() const 50 35 { … … 56 41 } 57 42 58 //++ 59 // Titre Méthodes 60 //-- 61 62 //++ 63 // double& Poly::operator[](int i) 64 // Permet d'accéder au coefficient de degré i (avec version 65 // const). 66 //-- 67 68 //++ 43 //! compute value P(\b x) 69 44 double Poly::operator()(double x) const 70 //71 // Calcule la valeur du polynôme au point x.72 //--73 45 { 74 46 UpdateDegIfDirty(); … … 81 53 } 82 54 83 // ++55 //! Replace p(x) by its derivate 84 56 void Poly::Derivate() 85 //86 // Remplace le polynôme par le polynôme dérivé.87 //--88 57 { 89 58 UpdateDegIfDirty(); … … 96 65 97 66 98 // ++67 //! Return the derivate in \b der(x) 99 68 void Poly::Derivate(Poly& der) const 100 //101 // Retourne dans der le polynôme dérivé.102 //--103 69 { 104 70 UpdateDegIfDirty(); … … 110 76 111 77 112 //++ 78 //! Return the roots of the polynomial into \b roots 79 /*! 80 This works until degre 2 81 \return the number of roots 82 */ 113 83 int Poly::Roots(TVector<r_8>& roots) const 114 //115 // Retourne dans roots les racines réelles, si on sait116 // les calculer. Retourne le nombre de racines.117 //--118 84 { 119 85 UpdateDegIfDirty(); … … 135 101 136 102 137 //++ 103 //! Return root \b r for a degre 1 polynomial 104 /*! \return return 1 if succes, 0 if not */ 138 105 int Poly::Root1(double& r) const 139 //140 // Seulement si le polynôme est de degré 1: retourne141 // la racine dans "r". Retourne 1 (nombre de racines).142 //--143 106 { 144 107 UpdateDegIfDirty(); … … 150 113 } 151 114 152 //++ 115 //! Return roots \b r1 and \b r2 for a degre 2 polynomial 116 /*! \return return the number of roots found */ 153 117 int Poly::Root2(double& r1, double& r2) const 154 //155 // Seulement si le polynôme est de degre 2: retourne156 // les racines dans "r1" et "r2". Retourne 0, 1 ou 2157 // (nombre de racines).158 //--159 118 { 160 119 UpdateDegIfDirty(); … … 172 131 } 173 132 174 // ++133 //! Operator P(x) = a(x) 175 134 Poly& Poly::operator = (Poly const& a) 176 //177 // Opérateur d'affectation.178 //--179 135 { 180 136 if (this == &a) return *this; … … 185 141 } 186 142 187 //++ 188 // Titres Opérations sur polynômes 189 //-- 190 191 //++ 143 //! Perform P(x) += b(x) 192 144 Poly& Poly::operator += (Poly const& b) 193 //194 //--195 145 { 196 146 UpdateDegIfDirty(); … … 206 156 } 207 157 208 // ++158 //! Perform P(x) -= b(x) 209 159 Poly& Poly::operator -= (Poly const& b) 210 //211 //--212 160 { 213 161 UpdateDegIfDirty(); … … 223 171 } 224 172 225 // ++173 //! Perform P(x) *= b(x) 226 174 Poly& Poly::operator *= (double a) 227 //228 //--229 175 { 230 176 UpdateDegIfDirty(); … … 233 179 } 234 180 235 // ++181 //! Return P(x) = *this(x) * b(x) 236 182 Poly Poly::Mult(Poly const& b) const 237 //238 //--239 183 { 240 184 Poly c(deg + b.deg); … … 254 198 } 255 199 256 // ++200 //! Print on stream \b s 257 201 void Poly::Print(ostream& s, int_4 , bool ) const 258 //259 // Impresssion.260 //--261 202 { 262 203 UpdateDegIfDirty(); … … 274 215 } 275 216 276 //++ 217 //! Fit datas by a polynomial 218 /*! 219 Fit y(x) by a polynimial P(x) 220 \param x : x datas 221 \param y : y datas 222 \param degre : degre of the polynomial P(x) to be fitted 223 \warning result is stored in the current object 224 \return return chisquare 225 */ 277 226 double Poly::Fit(TVector<r_8> const& x, TVector<r_8> const& y, int degre) 278 //279 // Ajustement polynomial par moindre carrés. Un polynôme de280 // degré "degre" est ajusté sur les données "x" et "y", et stocké dans281 // l'objet courant. Retourne le chi2.282 //--283 227 { 284 228 int n = x.NElts(); … … 303 247 } 304 248 305 //++ 249 //! Fit datas with errors by a polynomial 250 /*! 251 Fit y(x) by a polynimial P(x) 252 \param x : x datas 253 \param y : y datas 254 \param erry2 : errors squared on y 255 \param degre : degre of the polynomial P(x) to be fitted 256 \warning result is stored in the current object 257 \return \b errcoeff : errors on the coefficients 258 \return return chisquare 259 */ 306 260 double Poly::Fit(TVector<r_8> const& x, TVector<r_8> const& y, 307 261 TVector<r_8> const& erry2, int degre,TVector<r_8>& errCoef) 308 //309 // Ajustement polynomial par moindre carrés. Un polynôme de310 // degré est ajusté sur les données x et y, et stocké dans311 // l'objet courant. erry2 contient le carre des erreurs sur y.312 // Retourne le chi2.313 //--314 262 { 315 263 int n = x.NElts(); … … 337 285 338 286 339 //++ 340 // Poly Poly::power(int n) const 341 // 342 // Retourne le polynôme à la puissance n 343 //-- 344 287 //! Return the polynomial at power \b n : ( \f$ P(x)^n \f$ ) 345 288 Poly Poly::power(int n) const // a accelerer !!! 346 289 { … … 351 294 } 352 295 353 // ++296 //! Substitue polynomial and return P\f$ (b(x)) \f$ 354 297 Poly Poly::operator() (Poly const& b) const 355 //356 // Substitution d'un polynôme dans un autre.357 //--358 298 { 359 299 Poly c(b.Degre()*Degre()); … … 365 305 366 306 ////////////////////////////////////////////////////////////////////////// 307 //! For persistance management 367 308 void ObjFileIO<Poly>::ReadSelf(PInPersist& is) 368 309 { … … 375 316 } 376 317 318 //! For persistance management 377 319 void ObjFileIO<Poly>::WriteSelf(POutPersist& os) const 378 320 { … … 385 327 386 328 ////////////////////////////////////////////////////////////////////////// 329 /*! \ingroup NTools 330 \fn binomial(int,int) 331 Return the binomial coefficient \f$ {C_n}^p \f$. 332 */ 387 333 int binomial(int n, int p) 388 334 { … … 393 339 } 394 340 395 ////////////////////////////////////////////////////////////////////////// 396 // ******************* POLY 2 VARIABLES ****************** 397 //++ 398 // Class Poly2 399 // Lib Outils++ 400 // include poly.h 401 // 402 // Classe de calcul sur polynômes à deux variables. 403 //-- 404 405 //++ 406 // Links Parents 407 // Vector 408 //-- 409 410 //++ 411 // Titre Constructeurs 412 //-- 413 414 //++ 341 342 //////////////////////////////////////////////////////////// 343 //////////////////////////////////////////////////////////// 344 //////////////////////////////////////////////////////////// 345 //////////////////////////////////////////////////////////// 346 //////////////////////////////////////////////////////////// 347 /*! 348 \class SOPHYA::Poly2 349 \ingroup NTools 350 Two dimensional polynomials class. 351 */ 352 353 //! Constructor of 2D polynomial of degres \b degreX \b degreY 415 354 Poly2::Poly2(int degreX, int degreY) 416 //417 // Crée un polynôme de degrés partiels degreX et degreY.418 //--419 355 :TVector<r_8>((degreX+1)*(degreY+1)), dirty(0), 420 356 maxDegX(degreX), maxDegY(degreY), degX(0), degY(0), deg(0) … … 423 359 } 424 360 425 // ++361 //! Constructor of 2D polynomial \f$ P(x,y) = px(x) * py(y) \f$ 426 362 Poly2::Poly2(Poly const& polX, Poly const& polY) 427 //428 // Crée un polynôme à deux variables comme produit429 // de deux polynômes à une variable, p2(x,y)=px(x)py(y)430 //--431 363 :TVector<r_8>((polX.Degre()+1)*(polY.Degre()+1)), dirty(0), 432 364 maxDegX(polX.Degre()), maxDegY(polY.Degre()), … … 439 371 } 440 372 441 // ++373 //! Constructor by copy 442 374 Poly2::Poly2(Poly2 const& a) 443 //444 // Constructeur par copie.445 //--446 375 :TVector<r_8>(a), dirty(a.dirty), 447 376 maxDegX(a.maxDegX), maxDegY(a.maxDegY), … … 451 380 } 452 381 453 454 //++ 455 // Titre Méthodes 456 //-- 457 458 //++ 382 //! Operator P(x) = a(x) 459 383 Poly2& Poly2::operator = (Poly2 const& a) 460 //461 // Opérateur d'affectation.462 //--463 384 { 464 385 if (this == &a) return *this; … … 475 396 } 476 397 477 // ++398 //! Re-allocate space for 2D polynomial with partial degres \b degreX \b degreY 478 399 void Poly2::Realloc(int degreX, int degreY) 479 //480 // Redimensionne le polynôme comme etant un481 // polynôme de degrés partiels degreX et degreY.482 //--483 400 { 484 401 UpdateDegIfDirty(); … … 499 416 500 417 418 //! update degres 419 /*! update degres (that could be changed after operations) */ 501 420 void Poly2::UpdateDeg() const 502 421 { … … 514 433 } 515 434 516 //++ 517 // int Poly2::DegX() const 518 // Degré partiel en X. 519 // int Poly2::DegY() const 520 // Degré partiel en Y 521 // int Poly2::MaxDegX() const 522 // Degré partiel maximum (alloué) en X 523 // int Poly2::MaxDegY() const 524 // Degré partiel maximum (alloué) en Y 525 // int Poly2::Deg() const 526 // Degré total. 527 //-- 528 529 //++ 530 // double& Poly2::Coef(int dx, int dy) 531 // Retourne le coefficient de x^dx y^dy 532 // (avec aussi version const). 533 //-- 534 535 //++ 435 //! Return P(\b x, \b y) 536 436 double Poly2::operator()(double x, double y) const 537 //538 // Retourne la valeur en (x,y).539 //--540 437 { 541 438 UpdateDegIfDirty(); … … 553 450 } 554 451 555 //++ 452 //! Fit datas by a polynomial 453 /*! 454 Fit z(x,y) by a polynimial P(x,y) 455 \param x : x datas 456 \param y : y datas 457 \param z : z datas 458 \param degreX : partial degre on X 459 \param degreY : partial degre on Y 460 \warning result is stored in the current object 461 \return return chisquare 462 */ 556 463 double Poly2::Fit(TVector<r_8> const& x, TVector<r_8> const& y, 557 464 TVector<r_8> const& z, int degreX, int degreY) 558 //559 // Ajustement par moindre carrés z = P(x,y), degrés partiels imposés.560 //--561 465 { 562 466 int n = x.NElts(); … … 586 490 } 587 491 588 589 //++ 492 //! Fit datas with errors by a polynomial 493 /*! 494 Fit z(x,y) by a polynimial P(x,y) 495 \param x : x datas 496 \param y : y datas 497 \param z : z datas 498 \param errz2 : errors squared on z 499 \param degreX : partial degre on X 500 \param degreY : partial degre on Y 501 \warning result is stored in the current object 502 \return \b errcoeff : errors on the coefficients 503 \return return chisquare 504 */ 590 505 double Poly2::Fit(TVector<r_8> const& x, TVector<r_8> const& y, TVector<r_8> const& z, 591 506 TVector<r_8> const& errz2, int degreX, int degreY, 592 507 TVector<r_8>& errCoef) 593 //594 // Ajustement par moindre carrés z = P(x,y), degrés partiels imposés,595 // et erreurs^2 sur z dans errz2.596 //--597 508 { 598 509 int n = x.NElts(); … … 624 535 } 625 536 626 //++ 537 //! Fit datas by a polynomial 538 /*! 539 Fit z(x,y) by a polynimial P(x,y) 540 \param x : x datas 541 \param y : y datas 542 \param z : z datas 543 \param degre : total degre 544 \warning result is stored in the current object 545 \return return chisquare 546 */ 627 547 double Poly2::Fit(TVector<r_8> const& x, TVector<r_8> const& y, 628 548 TVector<r_8> const& z, int degre) 629 //630 // Ajustement par moindre carrés z = P(x,y), degré total imposé.631 //--632 549 { 633 550 int n = x.NElts(); … … 668 585 } 669 586 670 671 //++ 587 //! Fit datas with errors by a polynomial 588 /*! 589 Fit z(x,y) by a polynimial P(x,y) 590 \param x : x datas 591 \param y : y datas 592 \param z : z datas 593 \param errz2 : errors squared on z 594 \param degre : total degre 595 \warning result is stored in the current object 596 \return \b errcoeff : errors on the coefficients 597 \return return chisquare 598 */ 672 599 double Poly2::Fit(TVector<r_8> const& x, TVector<r_8> const& y, 673 600 TVector<r_8> const& z,TVector<r_8> const& errz2, 674 601 int degre, TVector<r_8>& errCoef) 675 //676 // Ajustement par moindre carrés z = P(x,y), degré total imposé,677 // et erreurs^2 sur z dans errz2.678 //--679 602 { 680 603 int n = x.NElts(); … … 721 644 } 722 645 723 // ++646 //! Print on stream \b s 724 647 void Poly2::Print(ostream& s, int_4 , bool ) const 725 //726 // Impression sur stream s.727 //--728 648 { 729 649 UpdateDegIfDirty(); … … 750 670 } 751 671 752 //++ 753 // Titre Opérations 754 //-- 755 756 //++ 672 //! Operator: return P(x) = *this(x) + b(x) 757 673 Poly2& Poly2::operator += (Poly2 const& b) 758 //759 //--760 674 { 761 675 if (maxDegX < b.DegX() || maxDegY < b.DegY()) … … 774 688 } 775 689 776 // ++690 //! Operator: return P(x) = *this(x) - b(x) 777 691 Poly2& Poly2::operator -= (Poly2 const& b) 778 //779 //--780 692 { 781 693 if (maxDegX < b.DegX() || maxDegY < b.DegY()) … … 794 706 } 795 707 796 // ++708 //! Operator: return P(x) = *this(x) * a 797 709 Poly2& Poly2::operator *= (double a) 798 //799 //--800 710 { 801 711 for (int i=0; i<NElts(); i++) … … 805 715 } 806 716 807 // ++717 //! Operator: return P(x) = *this(x) * b(x) 808 718 Poly2 Poly2::Mult(Poly2 const& b) const 809 //810 //--811 719 { 812 720 Poly2 c(DegX() + b.DegX(), DegY() + b.DegY()); … … 822 730 } 823 731 824 // ++732 //! Return \f$ P(x,y)^n \f$ 825 733 Poly2 Poly2::power(int n) const 826 //827 // Calcule le polynôme P(x,y)^n828 //--829 734 { 830 735 if (n < 0) THROW(rangeCheckErr); … … 835 740 836 741 837 // ++742 //! substitute and return \f$ P(a(x),b(x)) \f$ 838 743 Poly2 Poly2::operator() (Poly const& a, Poly const& b) const 839 //840 // Substitution de deux polynômes en X et Y,841 // P2(pa(x), pb(y)).842 //--843 744 { 844 745 UpdateDegIfDirty(); … … 854 755 } 855 756 856 // ++757 //! substitute and return 2D polynomial \f$ P(a(x,y)) \f$, P is a 1D polynomial 857 758 Poly2 Poly::operator() (Poly2 const& a) const 858 //859 // Substitution d'un polynôme à deux variables dans860 // un polynôme à une variable, P(P2(x,y)).861 //--862 759 { 863 760 Poly2 c(a.MaxDegX()*Degre(), a.MaxDegY()*Degre()); … … 869 766 870 767 ////////////////////////////////////////////////////////////////////////// 768 //! For persistance management 871 769 void ObjFileIO<Poly2>::ReadSelf(PInPersist& is) 872 770 { … … 879 777 } 880 778 779 //! For persistance management 881 780 void ObjFileIO<Poly2>::WriteSelf(POutPersist& os) const 882 781 { -
trunk/SophyaLib/NTools/poly.h
r938 r958 1 1 // This may look like C code, but it is really -*- C++ -*- 2 2 // 3 // $Id: poly.h,v 1. 7 2000-04-14 16:14:31ansari Exp $3 // $Id: poly.h,v 1.8 2000-04-18 13:38:36 ansari Exp $ 4 4 // 5 5 … … 21 21 22 22 ////////////////////////////////////////////////////////////////////////// 23 //! Class of 1 dimension polynomials P(x) 23 24 class Poly : public TVector<r_8> { 24 25 friend class ObjFileIO<Poly>; … … 27 28 Poly(Poly const& a); 28 29 30 //! Return degre of polynomials 29 31 inline int Degre() const {UpdateDegIfDirty(); return deg;} 30 32 33 //! Return space for a \b n degre polynomial 34 /*! 35 \param \b n : degre of new polynomial 36 \param \b force : force re-allocation if true,\ 37 if not allocation occurs only 38 if space needed is greater than the old one 39 */ 31 40 inline void Realloc(int n, bool force=false) 32 41 {TVector<r_8>::Realloc(n+1,force);} 33 42 34 43 // Pour compatibilite PEIDA - Reza 03/2000 44 //! Return coefficient of degre \b i 35 45 inline double Element(int i) const { return Elem(i,0,0,0,0); } 46 //! Return coefficient of degre \b i 36 47 inline double & Element(int i) { return Elem(i,0,0,0,0); } 37 48 49 //! Return coefficient of degre \b i 38 50 inline double operator[](int i) const {return Elem(i,0,0,0,0);} 51 //! Return coefficient of degre \b i 39 52 inline double& operator[](int i) {dirty = 1; return Elem(i,0,0,0,0);} 40 53 // Retourne le coefficient de degre i … … 87 100 }; 88 101 102 /*! \ingroup NTools \fn operator*(Poly const&,Poly const&) 103 \brief perform and return P(X) = a(x) * b(x) */ 89 104 inline Poly operator* (Poly const& a, Poly const& b) 90 105 { return a.Mult(b); } 91 106 107 /*! \ingroup NTools \fn operator+(Poly const&,Poly const&) 108 \brief perform and return P(X) = a(x) + b(x) */ 92 109 inline Poly operator+ (Poly const& a, Poly const& b) 93 110 { Poly c((a.Degre() > b.Degre())?(a.Degre()+1):(b.Degre()+1)); 94 111 c = a; c += b; return c; } 95 112 113 /*! \ingroup NTools \fn operator-(Poly const&,Poly const&) 114 \brief perform and return P(X) = a(x) - b(x) */ 96 115 inline Poly operator- (Poly const& a, Poly const& b) 97 116 { Poly c((a.Degre() > b.Degre())?(a.Degre()+1):(b.Degre()+1)); 98 117 c = a; c -= b; return c; } 99 118 119 /*! \ingroup NTools \fn operator*(double,Poly const&) 120 \brief perform and return P(X) = a * b(x) */ 100 121 inline Poly operator* (double a, Poly const& b) 101 122 { Poly c(b); c *= a; return c; } 102 123 124 /*! \ingroup NTools \fn operator<<(ostream&,const Poly&) 125 \brief Print a(x) on stream \b s */ 103 126 inline ostream& operator << (ostream& s, const Poly& a) 104 127 { a.Print(s); return s; } 105 128 106 129 ////////////////////////////////////////////////////////////////////////// 130 /*! \ingroup NTools \fn operator<<(POutPersist&,Poly&) 131 \brief For persistance management */ 107 132 inline POutPersist& operator << (POutPersist& os, Poly & obj) 108 133 { ObjFileIO<Poly> fio(&obj); fio.Write(os); return(os); } 134 /*! \ingroup NTools \fn operator<<(PInPersist&,,Poly&) 135 \brief For persistance management */ 109 136 inline PInPersist& operator >> (PInPersist& is, Poly & obj) 110 137 { ObjFileIO<Poly> fio(&obj); fio.Read(is); return(is); } … … 116 143 117 144 ////////////////////////////////////////////////////////////////////////// 145 //! Class of 2 dimensions polynomials P(x,y) 118 146 class Poly2 : public TVector<r_8> { 119 147 friend class ObjFileIO<Poly2>; … … 124 152 Poly2(Poly2 const& a); 125 153 154 //! Return polynomial partial degre for X 126 155 inline int DegX() const {UpdateDegIfDirty(); return degX;} 156 //! Return polynomial partial degre for Y 127 157 inline int DegY() const {UpdateDegIfDirty(); return degY;} 158 //! Return polynomial maximum partial degre for X 128 159 inline int MaxDegX() const {return maxDegX;} 160 //! Return polynomial maximum partial degre for Y 129 161 inline int MaxDegY() const {return maxDegY;} 162 //! Return polynomial total degre for X 130 163 inline int Deg() const {UpdateDegIfDirty(); return deg;} 131 164 // les degres partiels en x et y, et totaux. 132 165 133 166 // Pour compatibilite PEIDA - Reza 03/2000 167 //! Return coefficient of degre \b i 134 168 inline double Element(int i) const { return Elem(i,0,0,0,0); } 169 //! Return coefficient of degre \b i 135 170 inline double & Element(int i) { return Elem(i,0,0,0,0); } 136 171 … … 138 173 // retourne la valeur en (x,y) 139 174 175 //! Return index of coefficient of X^dx * Y^dy in the vector 140 176 inline int IndCoef(int dx, int dy) const { 141 177 if (dx>maxDegX || dy>maxDegY) THROW(rangeCheckErr); … … 146 182 // d'un fit... 147 183 184 //! Return coefficient of X^dx * Y^dy 148 185 inline double Coef(int dx, int dy) const { 149 186 return (dx>maxDegX || dy>maxDegY) ? 0 : Element(IndCoef(dx,dy)); 150 187 } 188 //! Return coefficient of X^dx * Y^dy 151 189 inline double& Coef(int dx, int dy) { 152 190 if (dx>maxDegX || dy>maxDegY) THROW(rangeCheckErr); … … 199 237 }; 200 238 239 /*! \ingroup NTools \fn operator*(Poly2 const&,Poly2 const&) 240 \brief Perform P(x,y) = a(x,y) * b(x,y) */ 201 241 inline Poly2 operator* (Poly2 const& a, Poly2 const& b) 202 242 { return a.Mult(b); } 203 243 244 /*! \ingroup NTools \fn operator+(Poly2 const&,Poly2 const&) 245 \brief Perform P(x,y) = a(x,y) + b(x,y) */ 204 246 inline Poly2 operator+ (Poly2 const& a, Poly2 const& b) 205 247 { Poly2 c(a); c += b; return c; } 206 248 249 /*! \ingroup NTools \fn operator-(Poly2 const&,Poly2 const&) 250 \brief Perform P(x,y) = a(x,y) - b(x,y) */ 207 251 inline Poly2 operator- (Poly2 const& a, Poly2 const& b) 208 252 { Poly2 c(a); c -= b; return c; } 209 253 254 /*! \ingroup NTools \fn operator-(double,Poly2 const&) 255 \brief Perform P(x,y) = a * b(x,y) */ 210 256 inline Poly2 operator * (double a, Poly2 const& b) 211 257 { Poly2 c(b); c *= a; return c; } 212 258 259 /*! \ingroup NTools \fn operator<<(ostream&,const Poly2&) 260 \brief Print a(x,y) on stream \b s */ 213 261 inline ostream& operator << (ostream& s, const Poly2& a) 214 262 { a.Print(s); return s; } 215 263 216 264 ////////////////////////////////////////////////////////////////////////// 265 /*! \ingroup NTools \fn operator<<(POutPersist&,Poly2&) 266 \brief For persistance management */ 217 267 inline POutPersist& operator << (POutPersist& os, Poly2 & obj) 218 268 { ObjFileIO<Poly2> fio(&obj); fio.Write(os); return(os); } 269 /*! \ingroup NTools \fn operator<<(POutPersist&,Poly2&) 270 \brief For persistance management */ 219 271 inline PInPersist& operator >> (PInPersist& is, Poly2 & obj) 220 272 { ObjFileIO<Poly2> fio(&obj); fio.Read(is); return(is); }
Note:
See TracChangeset
for help on using the changeset viewer.