Changeset 2575 in Sophya for trunk/SophyaLib/TArray/tarray.h
- Timestamp:
- Jul 29, 2004, 2:31:16 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/TArray/tarray.h
r2569 r2575 125 125 //! Fill TArray with Sequence \b seq 126 126 inline TArray<T>& operator = (Sequence const & seq) { return SetSeq(seq); } 127 127 128 // A = x (tous les elements a x) 128 virtual TArray<T>& SetT(T x); 129 virtual TArray<T>& SetCst(T x); 130 //! Fill an array with a constant value \b x ( alias for \b SetCst() method ) 131 inline TArray<T>& SetT(T x) { return SetCst(x); } 129 132 //! Fill TArray with all elements equal to \b x 130 133 inline TArray<T>& operator = (T x) { return SetT(x); } … … 138 141 139 142 // A += -= *= /= x (ajoute, soustrait, ... x a tous les elements) 143 // Methodes Add/Sub/Mul/Div() sont la pour compatibilite avant V=2 (1.818) 144 // Faut-il les garder ? Reza, Juillet 2004 140 145 inline TArray<T>& Add(T x) { return AddCst(x, *this); } 141 146 inline TArray<T>& Sub(T x, bool fginv=false) { return SubCst(x, *this, fginv); } … … 158 163 159 164 // A += -= (ajoute, soustrait element par element les deux tableaux ) 160 virtual TArray<T>& AddElt(const TArray<T>& a); 161 //! Operator TArray += TArray 162 inline TArray<T>& operator += (const TArray<T>& a) { return AddElt(a); } 163 virtual TArray<T>& SubElt(const TArray<T>& a, bool fginv=false); 164 //! Operator TArray -= TArray 165 inline TArray<T>& operator -= (const TArray<T>& a) { return SubElt(a); } 165 virtual TArray<T>& AddElt(const TArray<T>& a, TArray<T>& res) const ; 166 virtual TArray<T>& SubElt(const TArray<T>& a, TArray<T>& res, bool fginv=false) const ; 166 167 // Multiplication, division element par element les deux tableaux 167 virtual TArray<T>& MulElt(const TArray<T>& a); 168 virtual TArray<T>& DivElt(const TArray<T>& a, bool fginv=false, bool divzero=false); 168 virtual TArray<T>& MulElt(const TArray<T>& a, TArray<T>& res) const ; 169 virtual TArray<T>& DivElt(const TArray<T>& a, TArray<T>& res, bool fginv=false, bool divzero=false) const ; 170 171 //! Operator TArray += TArray (element by element addition in place) 172 inline TArray<T>& operator += (const TArray<T>& a) { return AddElt(a, *this); } 173 //! Operator TArray -= TArray (element by element subtraction in place) 174 inline TArray<T>& operator -= (const TArray<T>& a) { return SubElt(a, *this); } 175 169 176 // Recopie des valeurs, element par element 170 177 virtual TArray<T>& CopyElt(const TArray<T>& a); 171 178 // Recopie des valeurs avec conversion prealable, element par element 172 179 virtual TArray<T>& ConvertAndCopyElt(const BaseArray& a); 180 181 // Calcul du produit scalaire ( Somme_i (*this)(i)*a(i) ) 182 virtual T ScalarProduct(const TArray<T>& a) const ; 183 // Norme(^2) 184 //! Returns the squarred of the array norm, defined as Sum_k (*this)(k)*(*this)(k) 185 inline T Norm2() const { return ScalarProduct(*this); } 173 186 174 187 // Somme et produit des elements … … 283 296 inline TArray<T> operator + (const TArray<T>& a,const TArray<T>& b) 284 297 { TArray<T> result; result.SetTemp(true); 285 if (b.IsTemp()) { result.Share(b); result.AddElt(a); } 286 else { result.CloneOrShare(a); result.AddElt(b); } 287 return result; } 298 a.AddElt(b, result); return result; } 288 299 289 300 /*! \ingroup TArray \fn operator-(const TArray<T>&,const TArray<T>&) … … 292 303 inline TArray<T> operator - (const TArray<T>& a,const TArray<T>& b) 293 304 { TArray<T> result; result.SetTemp(true); 294 if (b.IsTemp()) { result.Share(b); result.SubElt(a, true); } 295 else { result.CloneOrShare(a); result.SubElt(b); } 296 return result; } 305 a.SubElt(b, result); return result; } 297 306 298 307
Note:
See TracChangeset
for help on using the changeset viewer.