Changeset 976 in Sophya
- Timestamp:
- Apr 27, 2000, 7:55:14 PM (25 years ago)
- Location:
- trunk/SophyaLib
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/BaseTools/ndatablock.cc
r969 r976 114 114 //! Copy constructor 115 115 /*! 116 \warning datas are shared if \b a is temporary, cloned if not.116 \warning datas are \b SHARED with \b a. 117 117 */ 118 118 template <class T> … … 199 199 200 200 //! \b Share with \b a if \b temporary, \b clone from \b a if not. 201 /*! \warning For most purposes, users don't have to worry with 202 the "temporary" nature of a NDataBlock. That is used 203 internaly to avoid memory allocation in operation 204 like A = B + C + D for instance. The method is not 205 protected to allow users to write complicated functions 206 on NDataBlock. 207 \verbatim 208 ---------------------------------------------------------- 209 Pourquoi une complication avec la notion de "temporaire" : 210 ---------------------------------------------------------- 211 - Le constructeur par copie partageant les donnees, 212 dans une methode un { NDataBlock<T> result; ...; return result;} 213 ne va pas allouer de la memoire pour retourner "result". 214 - La gestion de temporaire sert quand on enchaine plusieurs 215 operations sur la meme ligne, par exemple : A = B+C+D; 216 Dans ce cas l'objet CD=C+D est d'abord alloue et rempli 217 avec C+D, puis CD est mis a "temporaire". 218 Quand on ajoute B a CD, la methode d'addition va se rendre compte 219 que CD est "temporaire" et additionner B "in-place" dans CD 220 sans allouer une fois de plus de la place (pas d'allocation 221 de place BCD pour mettre B+CD mais une operation CD += B). 222 Si la notion d'objet "temporaire" n'avait pas ete consideree 223 l'addition A = B+C+D aurait alloue de la place pour "CD=C+D" 224 puis pour BCD=B+CD : 2 allocations auraient ete necessaires 225 contre 1 seule dans notre cas de geston de "temporaire". 226 \endverbatim 227 */ 201 228 template <class T> 202 229 void NDataBlock<T>::CloneOrShare(const NDataBlock<T>& a) … … 473 500 /////////////////////////////////////////////////////////////// 474 501 475 //! Operator = : ND = ND 1476 /*! \warning share if \b a is temporary, clone if not*/502 //! Operator = : ND = NDa 503 /*! \warning Datas are copied (cloned) from \b a. */ 477 504 template <class T> 478 505 NDataBlock<T>& NDataBlock<T>::operator = (const NDataBlock<T>& a) … … 487 514 if(a.mSz==0) 488 515 throw(SzMismatchError("NDataBlock::operator=A null size \n")); 489 if (mSz==0) { 490 CloneOrShare(a); 491 return *this; 492 } 516 if (mSz==0) { CloneOrShare(a); return *this; } 493 517 if (a.mSz != mSz) 494 518 throw(SzMismatchError("NDataBlock::operator=A Unequal sizes \n")); … … 506 530 <<" mSz="<<mSz<<" mSRef="<<mSRef<<" IsTemp="<<mIsTemp<<endl; 507 531 508 509 532 if(mSz==0) throw(SzMismatchError("NDataBlock::operator=v null size\n")); 510 T *p=Begin(), *pe=End(); 511 while (p<pe) *p++ = v; 533 T *p=Begin(), *pe=End(); while (p<pe) *p++ = v; 512 534 return *this; 513 535 } … … 522 544 { 523 545 if(mSz==0) throw(SzMismatchError("NDataBlock::operator+=v null size\n")); 524 T *p=Begin(), *pe=End(); 525 while (p<pe) *p++ += b; 546 T *p=Begin(), *pe=End(); while (p<pe) *p++ += b; 526 547 return *this; 527 548 } … … 532 553 { 533 554 if(mSz==0) throw(SzMismatchError("NDataBlock::operator-=v null size\n")); 534 T *p=Begin(), *pe=End(); 535 while (p<pe) *p++ -= b; 555 T *p=Begin(), *pe=End(); while (p<pe) *p++ -= b; 536 556 return *this; 537 557 } … … 542 562 { 543 563 if(mSz==0) throw(SzMismatchError("NDataBlock::operator*=v null size\n")); 544 T *p=Begin(), *pe=End(); 545 while (p<pe) *p++ *= b; 546 return *this; 547 } 548 549 //! Divide by a constant : ND *= b 564 T *p=Begin(), *pe=End(); while (p<pe) *p++ *= b; 565 return *this; 566 } 567 568 //! Divide by a constant : ND /= b 550 569 template <class T> 551 570 NDataBlock<T>& NDataBlock<T>::operator /= (T b) … … 553 572 if(b==(T) 0) throw(ParmError("NDataBlock::operator/=v divide by zero\n")); 554 573 if(mSz==0) throw(SzMismatchError("NDataBlock::operator/=v null size\n")); 555 T *p=Begin(), *pe=End(); 556 while (p<pe) *p++ /= b; 574 T *p=Begin(), *pe=End(); while (p<pe) *p++ /= b; 557 575 return *this; 558 576 } … … 562 580 //////////////////////////////////////////////////////////////////// 563 581 564 //! Add a NDataBlock : ND += ND 1582 //! Add a NDataBlock : ND += NDa 565 583 template <class T> 566 584 NDataBlock<T>& NDataBlock<T>::operator += (const NDataBlock<T>& a) … … 574 592 } 575 593 576 //! Substract a NDataBlock : ND -= ND 1594 //! Substract a NDataBlock : ND -= NDa 577 595 template <class T> 578 596 NDataBlock<T>& NDataBlock<T>::operator -= (const NDataBlock<T>& a) … … 586 604 } 587 605 588 //! Multiply by a NDataBlock : ND *= ND 1606 //! Multiply by a NDataBlock : ND *= NDa 589 607 template <class T> 590 608 NDataBlock<T>& NDataBlock<T>::operator *= (const NDataBlock<T>& a) … … 598 616 } 599 617 600 //! Divide by a NDataBlock : ND *= ND1618 //! Divide by a NDataBlock : ND /= NDa 601 619 template <class T> 602 620 NDataBlock<T>& NDataBlock<T>::operator /= (const NDataBlock<T>& a) … … 607 625 T *p=Begin(), *pe=End(); 608 626 T const *pa=a.Begin(); 609 while (p<pe) *p++ /= *pa++; 610 return *this; 611 } 612 613 //////////////////////////////////////////////////////////////// 614 // Pour surcharge de +,-,*,/ : NDataBlock = NDataBlock1+<T>b; // 615 // NDataBlock = <T>b+NDataBlock1; // 616 //////////////////////////////////////////////////////////////// 627 while (p<pe) *p++ /= *pa++; // Division par zero non protegee 628 return *this; 629 } 630 631 ////////////////////////////////////////////////////////////////// 632 // Pour surcharge de +,-,*,/ : NDataBlock = NDataBlock1+<T>b; // 633 // NDataBlock = <T>b+NDataBlock1; // 634 // Pour la notion de "temporaire" voir blabla dans CloneOrShare // 635 ////////////////////////////////////////////////////////////////// 617 636 618 637 //! Add a constant and return NDataBlock : NDret = ND + b … … 627 646 } 628 647 629 //! Substract a constant and return NDataBlock : NDret = ND - b 630 template <class T> 631 NDataBlock<T> NDataBlock<T>::Sub(T b) const 632 // Pour A-b 648 //! Substract a constant and return NDataBlock : NDret = ND - b or NDret = b - ND 649 /*! Substract a constant or from a constant 650 \param fginv==false : performs NDret = ND - b (default) 651 \param fginv==true : performs NDret = b - ND 652 */ 653 template <class T> 654 NDataBlock<T> NDataBlock<T>::Sub(T b,bool fginv) const 655 // Pour A-b sauf si fginv==true b-A (- n'est pas commutatif!) 633 656 { 634 657 NDataBlock<T> result; 635 658 result.CloneOrShare(*this); result.SetTemp(true); 636 return result -= b; 637 } 638 639 //! Substract from a constant and return NDataBlock : NDret = b - ND 640 template <class T> 641 NDataBlock<T> NDataBlock<T>::SubInv(T b) const 642 // Pour b-A 659 if(fginv) { 660 T *p=result.Begin(), *pe=result.End(); 661 T const *pa=this->Begin(); 662 while(p<pe) {*p++ = b - *pa++;} 663 } else result -= b; 664 return result; 665 } 666 667 //! Multiply by a constant and return NDataBlock : NDret = ND * b 668 template <class T> 669 NDataBlock<T> NDataBlock<T>::Mul(T b) const 670 // Pour A*b 643 671 { 644 672 NDataBlock<T> result; 645 673 result.CloneOrShare(*this); result.SetTemp(true); 646 T *p=result.Begin(), *pe=result.End(); 647 T const *pa=this->Begin(); 648 while(p<pe) {*p++ = b - *pa++;} 674 result *= b; 649 675 return result; 650 676 } 651 677 652 //! Multiply by a constant and return NDataBlock : NDret = ND * b 653 template <class T> 654 NDataBlock<T> NDataBlock<T>::Mul(T b) const 655 // Pour A*b 678 //! Divide by a constant and return NDataBlock : NDret = ND / b or NDret = b / ND 679 /*! Divide by a constant or from a constant 680 \param fginv==false : performs NDret = ND / b (default) 681 \param fginv==true : performs NDret = b / ND 682 */ 683 template <class T> 684 NDataBlock<T> NDataBlock<T>::Div(T b,bool fginv) const 685 // Pour A/b sauf si fginv==true b/A (/ n'est pas commutatif!) 656 686 { 657 687 NDataBlock<T> result; 658 688 result.CloneOrShare(*this); result.SetTemp(true); 659 return result *= b; 660 } 661 662 //! Divide by a constant and return NDataBlock : NDret = ND / b 663 template <class T> 664 NDataBlock<T> NDataBlock<T>::Div(T b) const 665 // Pour A/b 666 { 667 NDataBlock<T> result; 668 result.CloneOrShare(*this); result.SetTemp(true); 669 return result /= b; 670 } 671 672 //! Divide from a constant and return NDataBlock : NDret = b / ND 673 template <class T> 674 NDataBlock<T> NDataBlock<T>::DivInv(T b) const 675 // Pour b/A 676 { 677 NDataBlock<T> result; 678 result.CloneOrShare(*this); result.SetTemp(true); 679 T *p=result.Begin(), *pe=result.End(); 680 T const *pa = this->Begin(); 681 while(p<pe) {*p++ = b / *pa++;} 689 if(fginv) { 690 T *p=result.Begin(), *pe=result.End(); 691 T const *pa = this->Begin(); 692 while(p<pe) {*p++ = b / *pa++;} // Division par zero non protegee 693 } else { 694 if( b == (T) 0 ) throw MathExc("NDataBlock<T>::Div(T) - Divide by zero ! "); 695 result /= b; 696 } 682 697 return result; 683 698 } … … 740 755 result.Share(b); 741 756 T *p=result.Begin(), *pe=result.End(); T const *pa=Begin(); 742 while(p<pe) {*p = *pa++ / *p; p++;} 757 while(p<pe) {*p = *pa++ / *p; p++;} // Division par zero non protegee 743 758 } else {result.CloneOrShare(*this); result /= b;} 744 759 return result; -
trunk/SophyaLib/BaseTools/ndatablock.h
r948 r976 133 133 // Surcharge d'operateurs: C = A @ x , C = A @ B 134 134 NDataBlock<T> Add(T b) const; 135 NDataBlock<T> Sub(T b) const; 136 NDataBlock<T> SubInv(T b) const; 135 NDataBlock<T> Sub(T b,bool fginv=false) const; 137 136 NDataBlock<T> Mul(T b) const; 138 NDataBlock<T> Div(T b) const; 139 NDataBlock<T> DivInv(T b) const; 137 NDataBlock<T> Div(T b,bool fginv=false) const; 140 138 141 139 NDataBlock<T> Add(const NDataBlock<T>& b) const; 142 140 NDataBlock<T> Sub(const NDataBlock<T>& b) const; 143 NDataBlock<T> SubInv(const NDataBlock<T>& b) const;144 141 NDataBlock<T> Mul(const NDataBlock<T>& b) const; 145 142 NDataBlock<T> Div(const NDataBlock<T>& b) const; 146 NDataBlock<T> DivInv(const NDataBlock<T>& b) const;147 143 148 144 protected: … … 186 182 template<class T> 187 183 inline NDataBlock<T> operator - (T b,const NDataBlock<T>& a) 188 {return a.Sub Inv(b);}184 {return a.Sub(b,true);} 189 185 //! Multiply datas by a constant and return NDataBlock : ND = NDa * b 190 186 template<class T> … … 202 198 template<class T> 203 199 inline NDataBlock<T> operator / (T b,const NDataBlock<T>& a) 204 {return a.Div Inv(b);}200 {return a.Div(b,true);} 205 201 206 202 //! Add datas of two data blocks and return NDataBlock : ND = NDa + NDb -
trunk/SophyaLib/Manual/dox_sophya.conf
r916 r976 16 16 # if some version control system is used. 17 17 18 PROJECT_NUMBER = 0.9.36 V_Avr200018 PROJECT_NUMBER = 19 19 20 20 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) … … 191 191 # with spaces. 192 192 193 INPUT = ../SysTools ../TArray ../NTools ../HiStats193 INPUT = 194 194 195 195 # If the value of the INPUT tag contains directories, you can use the … … 222 222 # the \include command). 223 223 224 EXAMPLE_PATH = ../SysTools ../TArray ../NTools224 EXAMPLE_PATH = 225 225 226 226 # If the value of the EXAMPLE_PATH tag contains directories, you can use the -
trunk/SophyaLib/Manual/mkmf
r891 r976 1 1 #!/bin/csh 2 ################################################### 2 ##################################################### 3 3 if( $#argv >= 1 ) then 4 4 if( "$1" == "-h" ) then 5 echo "mkmf [ module1] [module2] [...]"5 echo "mkmf [-options] [-o dir] [module1] [module2] [...]" 6 6 echo " generate documentation for all Sophya" 7 echo " or only for module [module]" 8 exit 0 7 echo " or only for module [module...]" 8 echo " **** [-options] :" 9 echo " -html : generate HTML doc" 10 echo " -latex : generate LATEX doc" 11 echo " -man : generate MAN doc" 12 echo " -rtf : generate RTF doc" 13 echo " default is : html + latex" 14 echo " **** [-o dir] : directory where doc have to be put" 15 echo " default is ." 16 exit -1 9 17 endif 18 endif 19 ##################################################### 20 21 ################################## 22 ######## Decode arguments ######## 23 ################################## 24 set allmodules = ( SysTools TArray NTools HiStats ) 25 unset modules; unset latex; unset html; unset man; unset rtf 26 set outdir = "." 27 if( $#argv >= 1 ) then 28 while ( $#argv > 0) 29 if( "$1" == "-o" ) then 30 shift 31 set outdir = $1 32 else if( "$1" == "-html" ) then 33 set html 34 else if( "$1" == "-latex" ) then 35 set latex 36 else if( "$1" == "-man" ) then 37 set man 38 else if( "$1" == "-rtf" ) then 39 set rtf 40 else 41 if( ! $?modules ) set modules 42 set modules = ( $modules $1 ) 43 endif 44 shift 45 end 46 endif 47 if( ! $?html && ! $?latex && ! $?man && ! $?rtf ) then 48 set html 49 set latex 50 endif 51 if( ! $?modules ) then 52 set modules = ( $allmodules ) 10 53 endif 11 54 … … 14 57 ########################################## 15 58 59 #------------ 16 60 # mydoxy.conf 61 #------------ 17 62 cp dox_sophya.conf mydoxy.conf 18 foreach n ( 1 2 3 4 5 )19 echo " " >> mydoxy.conf20 end21 63 64 #---------- 22 65 # doxygen ? 66 #---------- 23 67 which doxygen >! /dev/null 24 68 if( $status != 0 ) then … … 27 71 endif 28 72 73 #------------- 29 74 # doxysearch ? 75 #------------- 30 76 which doxysearch >! /dev/null 31 77 if( $status != 0 ) then … … 34 80 else 35 81 set s = `which doxysearch` 36 echo 'doxysearch is installed in :' 37 echo $s:h 82 echo 'doxysearch is installed in : ' $s:h 38 83 echo 'mkmf will automatically update the config file.' 39 84 echo "BIN_ABSPATH = $s:h" >> mydoxy.conf … … 41 86 endif 42 87 43 # partial doc ? 44 if( $#argv >= 1 ) then 45 echo Partial doc generation : 46 set lf = 47 foreach f ( $* ) 48 echo "... adding ../$f to INPUT" 49 set lf = ( ../$f $lf ) 50 end 51 echo "INPUT = $lf" >> mydoxy.conf 52 grep 'INPUT = ' mydoxy.conf | grep -v ^\# | tail -1 88 #----------------- 89 # Version number ? 90 #----------------- 91 set f = ../SysTools/sversion.h 92 if( -e $f ) then 93 set v = `grep 'SOPHYA_VERSION' $f | awk '{print $3}'` 94 set r = `grep 'SOPHYA_REVISION' $f | awk '{print $3}'` 95 set t = `grep 'SOPHYA_TAG' $f | awk '{print $3}'` 96 echo "PROJECT_NUMBER = V${v}_R${r}_${t}" >> mydoxy.conf 97 else 98 echo "PROJECT_NUMBER = Not_Defined" >> mydoxy.conf 53 99 endif 100 grep 'PROJECT_NUMBER = ' mydoxy.conf | tail -1 101 102 #--------------- 103 # What modules ? 104 #--------------- 105 set lf = 106 foreach f ( $modules ) 107 echo "... Generating doc for ../$f" 108 set lf = ( ../$f $lf ) 109 end 110 echo "INPUT = $lf" >> mydoxy.conf 111 grep 'INPUT = ' mydoxy.conf | tail -1 112 113 set lf = 114 foreach f ( $allmodules ) 115 set lf = ( ../$f $lf ) 116 end 117 echo "EXAMPLE_PATH = $lf" >> mydoxy.conf 118 119 #------------------- 120 # What kind of doc ? 121 #------------------- 122 if( $?html ) then 123 echo "GENERATE_HTML = YES" >> mydoxy.conf 124 echo "...... generating HTML" 125 else 126 echo "GENERATE_HTML = NO" >> mydoxy.conf 127 endif 128 if( $?latex ) then 129 echo "GENERATE_LATEX = YES" >> mydoxy.conf 130 echo "...... generating LATEX" 131 else 132 echo "GENERATE_LATEX = NO" >> mydoxy.conf 133 endif 134 if( $?man ) then 135 echo "GENERATE_MAN = YES" >> mydoxy.conf 136 echo "...... generating MAN" 137 else 138 echo "GENERATE_MAN = NO" >> mydoxy.conf 139 endif 140 if( $?rtf ) then 141 echo "GENERATE_RTF = YES" >> mydoxy.conf 142 echo "...... generating RTF" 143 else 144 echo "GENERATE_RTF = NO" >> mydoxy.conf 145 endif 146 147 #------------------------ 148 # What output directory ? 149 #------------------------ 150 echo "OUTPUT_DIRECTORY = $outdir" >> mydoxy.conf 151 grep 'OUTPUT_DIRECTORY = ' mydoxy.conf | tail -1 152 153 #-------------------------- 154 # Configuration file update 155 #-------------------------- 156 doxygen -u mydoxy.conf >! /dev/null 157 rm -f mydoxy.conf.bak 54 158 55 159 ######################################### -
trunk/SophyaLib/TArray/sopemtx.cc
r939 r976 539 539 TMatrix<T> SimpleMatrixOperation<T>::Inverse(TMatrix<T> const & A) 540 540 { 541 TMatrix<T> a(A );541 TMatrix<T> a(A,false); 542 542 TMatrix<T> b(a.NCols(),a.NRows()); b = IdentityMatrix(1.); 543 543 if( TMatrixRC<T>::Abs_Value(GausPiv(a,b)) < 1.e-50) 544 544 throw(MathExc("TMatrix Inverse() Singular Matrix")); 545 b.SetTemp(true); 545 546 return b; 546 547 } -
trunk/SophyaLib/TArray/tarray.cc
r970 r976 105 105 106 106 //! Constructor by copy 107 /*! \sa NDataBlock::NDataBlock(const NDataBlock<T>&) */ 107 /*! 108 \warning datas are \b SHARED with \b a. 109 \sa NDataBlock::NDataBlock(const NDataBlock<T>&) 110 */ 108 111 template <class T> 109 112 TArray<T>::TArray(const TArray<T>& a) … … 137 140 138 141 //! Set array equal to \b a and return *this 142 /*! 143 \warning Datas are copied (cloned) from \b a. 144 \sa NDataBlock::operator=(const NDataBlock<T>&) 145 */ 139 146 template <class T> 140 147 TArray<T>& TArray<T>::Set(const TArray<T>& a) … … 160 167 161 168 //! Clone if \b a is not temporary, share if temporary 169 /*! \sa NDataBlock::CloneOrShare(const NDataBlock<T>&) */ 162 170 template <class T> 163 171 void TArray<T>::CloneOrShare(const TArray<T>& a) -
trunk/SophyaLib/TArray/tarray.h
r970 r976 40 40 // A = B 41 41 //! = operator between TArray 42 /*! \sa Set \sa NDataBlock::operator=(const NDataBlock<T>&) */ 42 /*! \warning Datas are copied (cloned) from \b a. 43 \sa Set \sa NDataBlock::operator=(const NDataBlock<T>&) */ 43 44 inline TArray<T>& operator = (const TArray<T>& a) { return Set(a); } 44 45 virtual TArray<T>& Set(const TArray<T>& a); -
trunk/SophyaLib/TArray/tmatrix.cc
r970 r976 1 // $Id: tmatrix.cc,v 1.1 0 2000-04-26 17:55:10ansari Exp $1 // $Id: tmatrix.cc,v 1.11 2000-04-27 17:53:51 ansari Exp $ 2 2 // C.Magneville 04/99 3 3 #include "machdefs.h" … … 43 43 44 44 //! Constructor by copy 45 /*! \sa NDataBlock::NDataBlock(const NDataBlock<T>&) */ 45 /*! 46 \warning datas are \b SHARED with \b a. 47 \sa NDataBlock::NDataBlock(const NDataBlock<T>&) 48 */ 46 49 template <class T> 47 50 TMatrix<T>::TMatrix(const TMatrix<T>& a) … … 103 106 } 104 107 105 //! Set matirx equal to \b a and return *this 108 //! Set matrix equal to \b a and return *this 109 /*! 110 \warning Datas are copied (cloned) from \b a. 111 \sa NDataBlock::operator=(const NDataBlock<T>&) 112 */ 106 113 template <class T> 107 114 TArray<T>& TMatrix<T>::Set(const TArray<T>& a) -
trunk/SophyaLib/TArray/tmatrix.h
r970 r976 25 25 virtual TArray<T>& Set(const TArray<T>& a); 26 26 //! Operator = between matrices 27 /*! \sa NDataBlock::operator=(const NDataBlock<T>&) */ 27 /*! \warning Datas are copied (cloned) from \b a. 28 \sa NDataBlock::operator=(const NDataBlock<T>&) */ 28 29 inline TMatrix<T>& operator = (const TMatrix<T>& a) 29 30 { Set(a); return(*this); } -
trunk/SophyaLib/TArray/tvector.cc
r967 r976 1 // $Id: tvector.cc,v 1. 7 2000-04-21 16:31:26ansari Exp $1 // $Id: tvector.cc,v 1.8 2000-04-27 17:53:52 ansari Exp $ 2 2 // C.Magneville 04/99 3 3 #include "machdefs.h" … … 40 40 41 41 //! Constructor by copy 42 /*! \sa NDataBlock::NDataBlock(const NDataBlock<T>&) */ 42 /*! 43 \warning datas are \b SHARED with \b a. 44 \sa NDataBlock::NDataBlock(const NDataBlock<T>&) 45 */ 43 46 template <class T> 44 47 TVector<T>::TVector(const TVector<T>& a) -
trunk/SophyaLib/TArray/tvector.h
r967 r976 23 23 24 24 //! Operator = 25 /*! \sa NDataBlock::operator=(const NDataBlock<T>&) */ 25 /*! \warning Datas are copied (cloned) from \b a. 26 \sa NDataBlock::operator=(const NDataBlock<T>&) */ 26 27 inline TVector<T>& operator = (const TVector<T>& a) 27 28 { Set(a); return(*this); }
Note:
See TracChangeset
for help on using the changeset viewer.