Index: trunk/SophyaLib/TArray/tarray.h
===================================================================
--- trunk/SophyaLib/TArray/tarray.h	(revision 2322)
+++ trunk/SophyaLib/TArray/tarray.h	(revision 2564)
@@ -29,6 +29,6 @@
   // Creation / destruction 
   TArray();
-  TArray(int_4 ndim, const sa_size_t * siz, sa_size_t step =1);
-  TArray(sa_size_t nx, sa_size_t ny=0, sa_size_t nz=0, sa_size_t nt=0, sa_size_t nu=0);
+  TArray(int_4 ndim, const sa_size_t * siz, sa_size_t step =1, bool fzero=true);
+  TArray(sa_size_t nx, sa_size_t ny=0, sa_size_t nz=0, sa_size_t nt=0, sa_size_t nu=0, bool fzero=true);
   TArray(int_4 ndim, const sa_size_t * siz, NDataBlock<T> & db, bool share=false, sa_size_t step=1, sa_size_t offset=0);
   TArray(int_4 ndim, const sa_size_t * siz, T* values, sa_size_t step=1, sa_size_t offset=0, Bridge* br=NULL);
@@ -57,12 +57,12 @@
   void Share(const TArray<T>& a);
 
-  void ReSize(int_4 ndim, sa_size_t * siz, sa_size_t step=1);
-  void ReSize(const BaseArray& a);
+  void ReSize(int_4 ndim, sa_size_t * siz, sa_size_t step=1, bool fzero=true);
+  void ReSize(const BaseArray& a, bool pack=true, bool fzero=true);
   //! a synonym (alias) for method ReSize(int_4, ...)
-  inline void SetSize(int_4 ndim, sa_size_t * siz, sa_size_t step=1)
-		{ ReSize(ndim, siz, step); }
+  inline void SetSize(int_4 ndim, sa_size_t * siz, sa_size_t step=1, bool fzero=true)
+		{ ReSize(ndim, siz, step, fzero); }
   //! a synonym (alias) for method ReSize(const BaseArray&)
-  inline void SetSize(const BaseArray& a)
-		{ ReSize(a); }
+  inline void SetSize(const BaseArray& a, bool pack=true, bool fzero=true)
+		{ ReSize(a, pack, fzero); }
   void Realloc(int_4 ndim, sa_size_t * siz, sa_size_t step=1, bool force=false);
 
@@ -129,21 +129,32 @@
   //! Fill TArray with all elements equal to \b x
   inline  TArray<T>&  operator = (T x)             { return SetT(x); }
+
+// addition et soustraction de constante 
+  virtual TArray<T>&  AddCst(T x, TArray<T>& res) const ;
+  virtual TArray<T>&  SubCst(T x, TArray<T>& res, bool fginv=false) const ;
+// Multiplication et division par une  constante 
+  virtual TArray<T>&  MulCst(T x, TArray<T>& res) const ;
+  virtual TArray<T>&  DivCst(T x, TArray<T>& res, bool fginv=false) const ;
+
 // A += -= *= /= x (ajoute, soustrait, ... x a tous les elements)
-  virtual TArray<T>&  Add(T x);
+  inline  TArray<T>&  Add(T x)                     { return AddCst(x, *this); }
+  inline  TArray<T>&  Sub(T x, bool fginv=false)   { return SubCst(x, *this, fginv); }
+  inline  TArray<T>&  Mul(T x)                     { return MulCst(x, *this); }
+  inline  TArray<T>&  Div(T x, bool fginv=false)   { return DivCst(x, *this, fginv); }
+
   //! Add \b x to all elements
-  inline  TArray<T>&  operator += (T x)            { return Add(x); }
-  virtual TArray<T>&  Sub(T x, bool fginv=false);
+  inline  TArray<T>&  operator += (T x)            { return AddCst(x, *this); }
   //! Substract \b x to all elements
-  inline  TArray<T>&  operator -= (T x)            { return Sub(x); }
-  virtual TArray<T>&  Mul(T x);
+  inline  TArray<T>&  operator -= (T x)            { return SubCst(x, *this); }
   //! Multiply all elements by \b x
-  inline  TArray<T>&  operator *= (T x)            { return Mul(x); }
-  virtual TArray<T>&  Div(T x, bool fginv=false);
+  inline  TArray<T>&  operator *= (T x)            { return MulCst(x, *this); }
   //! Divide all elements by \b x
-  inline  TArray<T>&  operator /= (T x)            { return Div(x); }
+  inline  TArray<T>&  operator /= (T x)            { return DivCst(x, *this); }
 
 // applique le signe moins a tous les elements
-  virtual TArray<T>&  NegateElt();
-  
+  virtual TArray<T>&  NegateElt(TArray<T>& res) const ;
+//! Replace array elements values by their opposite ( (*this)(i) -> -(*this)(i) )
+  inline  TArray<T>&  NegateElt()                  { return NegateElt(*this); }
+
 // A += -=  (ajoute, soustrait element par element les deux tableaux )
   virtual TArray<T>&  AddElt(const TArray<T>& a);
@@ -209,48 +220,48 @@
   \brief Operator TArray = TArray + constant */
 template <class T> inline TArray<T> operator + (const TArray<T>& a, T b)
-    {TArray<T> result; result.CloneOrShare(a); result.SetTemp(true); 
-    result.Add(b); return result;}
+    {TArray<T> result; result.SetTemp(true); 
+    a.Add(b, result); return result;}
 
 /*! \ingroup TArray \fn operator+(T,const TArray<T>&)
   \brief Operator TArray = constant + TArray */
 template <class T> inline TArray<T> operator + (T b,const TArray<T>& a)
-    {TArray<T> result; result.CloneOrShare(a); result.SetTemp(true); 
-    result.Add(b); return result;}
+    {TArray<T> result; result.SetTemp(true); 
+    a.Add(b, result); return result;}
 
 /*! \ingroup TArray \fn operator-(const TArray<T>&,T)
   \brief Operator TArray = TArray - constant */
 template <class T> inline TArray<T> operator - (const TArray<T>& a, T b)
-    {TArray<T> result; result.CloneOrShare(a); result.SetTemp(true); 
-    result.Sub(b); return result;}
+    {TArray<T> result; result.SetTemp(true); 
+    a.Sub(b,result); return result;}
 
 /*! \ingroup TArray \fn operator-(T,const TArray<T>&)
   \brief Operator TArray = constant - TArray */
 template <class T> inline TArray<T> operator - (T b,const TArray<T>& a)
-    {TArray<T> result; result.CloneOrShare(a); result.SetTemp(true); 
-    result.Sub(b,true); return result;}
+    {TArray<T> result; result.SetTemp(true); 
+    a.Sub(b,result,true); return result;}
 
 /*! \ingroup TArray \fn operator*(const TArray<T>&,T)
   \brief Operator TArray = TArray * constant */
 template <class T> inline TArray<T> operator * (const TArray<T>& a, T b)
-    {TArray<T> result; result.CloneOrShare(a); result.SetTemp(true); 
-    result.Mul(b); return result;}
+    {TArray<T> result; result.SetTemp(true); 
+    a.MulCst(b, result); return result;}
 
 /*! \ingroup TArray \fn operator*(T,const TArray<T>&)
   \brief Operator TArray = constant * TArray */
 template <class T> inline TArray<T> operator * (T b,const TArray<T>& a)
-    {TArray<T> result; result.CloneOrShare(a); result.SetTemp(true); 
-    result.Mul(b); return result;}
+    {TArray<T> result; result.SetTemp(true); 
+    a.MulCst(b,result); return result;}
 
 /*! \ingroup TArray \fn operator/(const TArray<T>&,T)
   \brief Operator TArray = TArray / constant */
 template <class T> inline TArray<T> operator / (const TArray<T>& a, T b)
-    {TArray<T> result; result.CloneOrShare(a); result.SetTemp(true); 
-    result.Div(b); return result;}
+    {TArray<T> result; result.SetTemp(true); 
+    a.Div(b,result); return result;}
 
 /*! \ingroup TArray \fn operator/(T,const TArray<T>&)
   \brief Operator TArray = constant / TArray  */
 template <class T> inline TArray<T> operator / (T b, const TArray<T>& a)
-    {TArray<T> result; result.CloneOrShare(a); result.SetTemp(true); 
-    result.Div(b, true); return result;}
+    {TArray<T> result; result.SetTemp(true); 
+    a.Div(b, result, true); return result;}
 
 ////////////////////////////////////////////////////////////////
