Index: trunk/SophyaLib/TArray/tarray.cc
===================================================================
--- trunk/SophyaLib/TArray/tarray.cc	(revision 2478)
+++ trunk/SophyaLib/TArray/tarray.cc	(revision 2564)
@@ -70,8 +70,9 @@
   \param siz[ndim] : size along each dimension
   \param step : step (same for all dimensions)
- */
-template <class T>
-TArray<T>::TArray(int_4 ndim, const sa_size_t * siz, sa_size_t step)
-  : BaseArray() , mNDBlock(ComputeTotalSize(ndim, siz, step, 1))
+  \param fzero : if \b true , set array elements to zero 
+ */
+template <class T>
+TArray<T>::TArray(int_4 ndim, const sa_size_t * siz, sa_size_t step, bool fzero)
+  : BaseArray() , mNDBlock(ComputeTotalSize(ndim, siz, step, 1), fzero)
 {
   string exmsg = "TArray<T>::TArray(int_4, sa_size_t *, sa_size_t)";
@@ -82,7 +83,8 @@
 /*!
   \param nx,ny,nz,nt,nu : sizes along first, second, third, fourth and fifth dimension
- */
-template <class T>
-TArray<T>::TArray(sa_size_t nx, sa_size_t ny, sa_size_t nz, sa_size_t nt, sa_size_t nu)
+  \param fzero : if \b true , set array elements to zero 
+ */
+template <class T>
+TArray<T>::TArray(sa_size_t nx, sa_size_t ny, sa_size_t nz, sa_size_t nt, sa_size_t nu, bool fzero)
   : BaseArray() , mNDBlock(nx*((ny>0)?ny:1)*((nz>0)?nz:1)*((nt>0)?nt:1)*((nu>0)?nu:1)) 
 {
@@ -268,7 +270,8 @@
   \param siz[ndim] : size along each dimension
   \param step : step (same for all dimensions)
- */
-template <class T>
-void TArray<T>::ReSize(int_4 ndim, sa_size_t * siz, sa_size_t step)
+  \param fzero : if \b true , set array elements to zero 
+ */
+template <class T>
+void TArray<T>::ReSize(int_4 ndim, sa_size_t * siz, sa_size_t step, bool fzero)
 {
   if (arrtype_ != 0) {
@@ -280,5 +283,5 @@
   string exmsg = "TArray<T>::ReSize(int_4 ...)";
   if (!UpdateSizes(ndim, siz, step, 0, exmsg))  throw( ParmError(exmsg) );
-  mNDBlock.ReSize(totsize_);    
+  mNDBlock.ReSize(totsize_, fzero);    
 }
 
@@ -287,7 +290,9 @@
   The array size and memory layout are copied from the array \b a.
   \param a : Array used as template for setting the size and memory layout.
- */
-template <class T>
-void TArray<T>::ReSize(const BaseArray& a)
+  \param pack : if \b true , create a packed array, else same memory layout as \b a. 
+  \param fzero : if \b true , set array elements to zero 
+ */
+template <class T>
+void TArray<T>::ReSize(const BaseArray& a, bool pack, bool fzero)
 {
   if (arrtype_ != 0) {
@@ -298,6 +303,14 @@
   }
   string exmsg = "TArray<T>::ReSize(const TArray<T>&)";
-  if (!UpdateSizes(a, exmsg))  throw( ParmError(exmsg) );
-  mNDBlock.ReSize(totsize_);      
+  if (pack) {
+    sa_size_t siz[BASEARRAY_MAXNDIMS];
+    for(int ksz=0; ksz<BASEARRAY_MAXNDIMS; ksz++) siz[ksz] = a.Size(ksz);
+    if (!UpdateSizes(a.NbDimensions(), siz, 1, 0, exmsg))  throw( ParmError(exmsg) );
+    mNDBlock.ReSize(totsize_, fzero);        
+  }
+  else {
+    if (!UpdateSizes(a, exmsg))  throw( ParmError(exmsg) );
+    mNDBlock.ReSize(totsize_);      
+  }
 }
 
@@ -491,160 +504,226 @@
 }
 
-//! Add a constant value \b x to an array
-template <class T>
-TArray<T>& TArray<T>::Add(T x)
-{
-  if (NbDimensions() < 1) 
-    throw RangeCheckError("TArray<T>::Add(T )  - Not Allocated Array ! ");
-  T * pe;
-  sa_size_t j,k;
-  if (AvgStep() > 0)   {  // regularly spaced elements
-    sa_size_t step = AvgStep();
-    sa_size_t maxx = totsize_*step;
-    pe = Data();
-    for(k=0; k<maxx; k+=step )  pe[k] += x;
-  }
-  else {    // Non regular data spacing ...
-    int_4 ka = MaxSizeKA();
-    sa_size_t step = Step(ka);
-    sa_size_t gpas = Size(ka)*step;
-    sa_size_t naxa = Size()/Size(ka);
-    for(j=0; j<naxa; j++)  {
-      pe = mNDBlock.Begin()+Offset(ka,j);
-      for(k=0; k<gpas; k+=step)  pe[k] += x;
-    }
-  }
-  return(*this);
-}
-
-//! Substract a constant value \b x to an array
+//! Add a constant value \b x to the source array and store the result in \b res. 
 /*! 
-Substract a constant from the *this = *this-x
-\param fginv == true : Perfoms the inverse subtraction (*this = x-(*this)) 
-*/
-template <class T>
-TArray<T>& TArray<T>::Sub(T x, bool fginv)
-{
-  if (NbDimensions() < 1) 
-    throw RangeCheckError("TArray<T>::Sub(T )  - Not Allocated Array ! ");
-  T * pe;
-  sa_size_t j,k;
-  if (AvgStep() > 0)   {  // regularly spaced elements
-    sa_size_t step = AvgStep();
-    sa_size_t maxx = totsize_*step;
-    pe = Data();
-    if (fginv)
-      for(k=0; k<maxx; k+=step )  pe[k] = x-pe[k];
-    else
-      for(k=0; k<maxx; k+=step )  pe[k] -= x;
-  }
-  else {    // Non regular data spacing ...
-    int_4 ka = MaxSizeKA();
-    sa_size_t step = Step(ka);
-    sa_size_t gpas = Size(ka)*step;
-    sa_size_t naxa = Size()/Size(ka);
-    for(j=0; j<naxa; j++)  {
-      pe = mNDBlock.Begin()+Offset(ka,j);
-      if (fginv)
-	for(k=0; k<gpas; k+=step)  pe[k] = x-pe[k];
+Add a constant to the source array \b this and store the result in \b res (res = *this+x).  
+If not initially allocated, the output array \b res is automatically 
+resized as a packed array with the same sizes as the source (this) array.
+Returns a reference to the output array \b res. 
+\param x : constant to add to the array elements
+\param res : Output array containing the result (res=this+x). 
+*/
+template <class T>
+TArray<T>& TArray<T>::AddCst(T x, TArray<T>& res) const
+{
+  if (NbDimensions() < 1) 
+    throw RangeCheckError("TArray<T>::AddCst(T,res)  - Not allocated source array ");
+  if (res.NbDimensions() < 1)  res.SetSize(*this, true, false);
+  bool smo;
+  if (!CompareSizes(res, smo)) 
+    throw(SzMismatchError("TArray<T>::AddCst(T, res) SizeMismatch(this,res) ")) ;
+
+  const T * pe;
+  T * per;
+  sa_size_t j,k,kr;
+  if (smo && (IsPacked() > 0) && (res.IsPacked() > 0))   {  // regularly spaced elements
+    sa_size_t maxx = totsize_;
+    pe = Data();
+    per = res.Data();
+    for(k=0; k<maxx; k++) { *per = (*pe)+x;  per++;  pe++; }
+  }
+  else {    // Non regular data spacing ...
+    int_4 ax,axr;
+    sa_size_t step, stepr;
+    sa_size_t gpas, naxr;
+    GetOpeParams(res, smo, ax, axr, step, stepr, gpas, naxr);
+    for(j=0; j<naxr; j++)  {
+      pe = mNDBlock.Begin()+Offset(ax,j);
+      per = res.DataBlock().Begin()+res.Offset(axr,j);
+      for(k=0, kr=0;  k<gpas;  k+=step, kr+=stepr)  per[kr] = pe[k]+x; 
+    }
+  }
+  return(res);
+}
+
+//! Subtract a constant value \b x from the source array and store the result in \b res. 
+/*! 
+Subtract a constant from the source array \b this and store the result in \b res (res = *this-x).  
+If not initially allocated, the output array \b res is automatically 
+resized as a packed array with the same sizes as the source (this) array.
+Returns a reference to the output array \b res. 
+\param x : constant to subtract from the array elements
+\param res : Output array containing the result (res=this+x or res=x-this). 
+\param fginv == true : Invert subtraction argument order (*this = x-(*this)) 
+*/
+template <class T>
+TArray<T>& TArray<T>::SubCst(T x, TArray<T>& res, bool fginv) const
+{
+  if (NbDimensions() < 1) 
+    throw RangeCheckError("TArray<T>::SubCst(T,res)  - Not allocated source array ");
+  if (res.NbDimensions() < 1)  res.SetSize(*this, true, false);
+  bool smo;
+  if (!CompareSizes(res, smo)) 
+    throw(SzMismatchError("TArray<T>::SubCst(T, res) SizeMismatch(this,res) ")) ;
+
+  const T * pe;
+  T * per;
+  sa_size_t j,k,kr;
+  if (smo && (IsPacked() > 0) && (res.IsPacked() > 0))   {  // regularly spaced elements
+    sa_size_t maxx = totsize_;
+    pe = Data();
+    per = res.Data();
+    if (!fginv) 
+      for(k=0; k<maxx; k++) { *per = (*pe)-x;  per++;  pe++; }
+    else 
+      for(k=0; k<maxx; k++) { *per = x-(*pe);  per++;  pe++; }
+  }
+  else {    // Non regular data spacing ...
+    int_4 ax,axr;
+    sa_size_t step, stepr;
+    sa_size_t gpas, naxr;
+    GetOpeParams(res, smo, ax, axr, step, stepr, gpas, naxr);
+    for(j=0; j<naxr; j++)  {
+      pe = mNDBlock.Begin()+Offset(ax,j);
+      per = res.DataBlock().Begin()+res.Offset(axr,j);
+      if (!fginv) 
+        for(k=0, kr=0;  k<gpas;  k+=step, kr+=stepr)  per[kr] = pe[k]-x; 
       else
-	for(k=0; k<gpas; k+=step)  pe[k] -= x;
-    }
-  }
-  return(*this);
-}
-
-//! Multiply an array by a constant value \b x
-template <class T>
-TArray<T>& TArray<T>::Mul(T x)
-{
-  if (NbDimensions() < 1) 
-    throw RangeCheckError("TArray<T>::Mul(T )  - Not Allocated Array ! ");
-  T * pe;
-  sa_size_t j,k;
-  if (AvgStep() > 0)   {  // regularly spaced elements
-    sa_size_t step = AvgStep();
-    sa_size_t maxx = totsize_*step;
-    pe = Data();
-    for(k=0; k<maxx; k+=step )  pe[k] *= x;
-  }
-  else {    // Non regular data spacing ...
-    int_4 ka = MaxSizeKA();
-    sa_size_t step = Step(ka);
-    sa_size_t gpas = Size(ka)*step;
-    sa_size_t naxa = Size()/Size(ka);
-    for(j=0; j<naxa; j++)  {
-      pe = mNDBlock.Begin()+Offset(ka,j);
-      for(k=0; k<gpas; k+=step)  pe[k] *= x;
-    }
-  }
-  return(*this);
-}
-
-//! Divide an array by a constant value \b x
+        for(k=0, kr=0;  k<gpas;  k+=step, kr+=stepr)  per[kr] = x-pe[k]; 
+    }
+  }
+  return(res);
+}
+
+//! Multiply the source array by a constant value \b x and store the result in \b res. 
 /*! 
-Divide the array by a constant *this = *this/x
-\param fginv == true : Perfoms the inverse division (*this = x/(*this)) 
-*/
-template <class T>
-TArray<T>& TArray<T>::Div(T x, bool fginv)
-{
-  if (NbDimensions() < 1) 
-    throw RangeCheckError("TArray<T>::Div(T )  - Not Allocated Array ! ");
+Multiply the source array \b this by a constant \b x and store the result in \b res (res = *this*x).  
+If not initially allocated, the output array \b res is automatically 
+resized as a packed array with the same sizes as the source (this) array.
+Returns a reference to the output array \b res. 
+\param x : Array elements are multiplied by x
+\param res : Output array containing the result (res=this*x). 
+*/
+template <class T>
+TArray<T>& TArray<T>::MulCst(T x, TArray<T>& res) const
+{
+  if (NbDimensions() < 1) 
+    throw RangeCheckError("TArray<T>::MulCst(T,res)  - Not allocated source array ");
+  if (res.NbDimensions() < 1)  res.SetSize(*this, true, false);
+  bool smo;
+  if (!CompareSizes(res, smo)) 
+    throw(SzMismatchError("TArray<T>::MulCst(T, res) SizeMismatch(this,res) ")) ;
+
+  const T * pe;
+  T * per;
+  sa_size_t j,k,kr;
+  if (smo && (IsPacked() > 0) && (res.IsPacked() > 0))   {  // regularly spaced elements
+    sa_size_t maxx = totsize_;
+    pe = Data();
+    per = res.Data();
+    for(k=0; k<maxx; k++) { *per = (*pe)*x;  per++;  pe++; }
+  }
+  else {    // Non regular data spacing ...
+    int_4 ax,axr;
+    sa_size_t step, stepr;
+    sa_size_t gpas, naxr;
+    GetOpeParams(res, smo, ax, axr, step, stepr, gpas, naxr);
+    for(j=0; j<naxr; j++)  {
+      pe = mNDBlock.Begin()+Offset(ax,j);
+      per = res.DataBlock().Begin()+res.Offset(axr,j);
+      for(k=0, kr=0;  k<gpas;  k+=step, kr+=stepr)  per[kr] = pe[k]*x; 
+    }
+  }
+  return(res);
+}
+
+//! Divide the source array by a constant value \b x and store the result in \b res.
+/*! 
+Divide the source array \b this by a constant \b x and store the result in \b res (res = *this/x).  
+If not initially allocated, the output array \b res is automatically 
+resized as a packed array with the same sizes as the source (this) array.
+Returns a reference to the output array \b res. 
+\param x : Array elements are divied by x
+\param res : Output array containing the result (res=(*this)/x or res=x/(*this)). 
+\param fginv == true : Invert the operation order (res = x/(*this)) 
+*/
+template <class T>
+TArray<T>& TArray<T>::DivCst(T x, TArray<T>& res, bool fginv) const
+{
+  if (NbDimensions() < 1) 
+    throw RangeCheckError("TArray<T>::DivCst(T,res)  - Not allocated source array ! ");
   if (!fginv && (x == (T) 0) ) 
-    throw MathExc("TArray<T>::Div(T )  - Divide by zero ! ");
-  T * pe;
-  sa_size_t j,k;
-  if (AvgStep() > 0)   {  // regularly spaced elements
-    sa_size_t step = AvgStep();
-    sa_size_t maxx = totsize_*step;
-    pe = Data();
-    if (fginv)
-      for(k=0; k<maxx; k+=step )  pe[k] = x/pe[k];
+    throw MathExc("TArray<T>::DivCst(T,res)  - Divide by zero ! ");
+  if (res.NbDimensions() < 1)  res.SetSize(*this, true, false);
+  bool smo;
+  if (!CompareSizes(res, smo)) 
+    throw(SzMismatchError("TArray<T>::DivCst(T, res) SizeMismatch(this,res) ")) ;
+
+  const T * pe;
+  T * per;
+  sa_size_t j,k,kr;
+  if (smo && (IsPacked() > 0) && (res.IsPacked() > 0))   {  // regularly spaced elements
+    sa_size_t maxx = totsize_;
+    pe = Data();
+    per = res.Data();
+    if (!fginv) 
+      for(k=0; k<maxx; k++) { *per = (*pe)/x;  per++;  pe++; }
     else 
-      for(k=0; k<maxx; k+=step )  pe[k] /= x;
-  }
-  else {    // Non regular data spacing ...
-    int_4 ka = MaxSizeKA();
-    sa_size_t step = Step(ka);
-    sa_size_t gpas = Size(ka)*step;
-    sa_size_t naxa = Size()/Size(ka);
-    for(j=0; j<naxa; j++)  {
-      pe = mNDBlock.Begin()+Offset(ka,j);
-      if (fginv)
-	for(k=0; k<gpas; k+=step)  pe[k] = x/pe[k];
-      else 
-	for(k=0; k<gpas; k+=step)  pe[k] /= x;
-    }
-  }
-  return(*this);
-}
-
-
-//! Replace array elements values by their opposite ( a(i) -> -a(i) )
-template <class T>
-TArray<T>& TArray<T>::NegateElt()
-{
-  if (NbDimensions() < 1) 
-    throw RangeCheckError("TArray<T>::NegateElt()  - Not Allocated Array ! ");
-  T * pe;
-  sa_size_t j,k;
-  if (AvgStep() > 0)   {  // regularly spaced elements
-    sa_size_t step = AvgStep();
-    sa_size_t maxx = totsize_*step;
-    pe = Data();
-    for(k=0; k<maxx; k+=step )  pe[k] = -pe[k];
-  }
-  else {    // Non regular data spacing ...
-    int_4 ka = MaxSizeKA();
-    sa_size_t step = Step(ka);
-    sa_size_t gpas = Size(ka)*step;
-    sa_size_t naxa = Size()/Size(ka);
-    for(j=0; j<naxa; j++)  {
-      pe = mNDBlock.Begin()+Offset(ka,j);
-      for(k=0; k<gpas; k+=step)  pe[k] = -pe[k];
-    }
-  }
-  return(*this);
+      for(k=0; k<maxx; k++) { *per = x/(*pe);  per++;  pe++; }
+  }
+  else {    // Non regular data spacing ...
+    int_4 ax,axr;
+    sa_size_t step, stepr;
+    sa_size_t gpas, naxr;
+    GetOpeParams(res, smo, ax, axr, step, stepr, gpas, naxr);
+    for(j=0; j<naxr; j++)  {
+      pe = mNDBlock.Begin()+Offset(ax,j);
+      per = res.DataBlock().Begin()+res.Offset(axr,j);
+      if (!fginv) 
+        for(k=0, kr=0;  k<gpas;  k+=step, kr+=stepr)  per[kr] = pe[k]/x; 
+      else
+        for(k=0, kr=0;  k<gpas;  k+=step, kr+=stepr)  per[kr] = x/pe[k]; 
+    }
+  }
+  return(res);
+}
+
+
+//! Stores the opposite of the source array in \b res (res=-(*this)). 
+/*! 
+If not initially allocated, the output array \b res is automatically 
+resized as a packed array with the same sizes as the source (this) array.
+Returns a reference to the output array \b res. 
+*/
+template <class T>
+TArray<T>& TArray<T>::NegateElt(TArray<T>& res) const
+{
+  if (NbDimensions() < 1) 
+    throw RangeCheckError("TArray<T>::NegateElt(res)  - Not allocated source array ");
+  if (res.NbDimensions() < 1)  res.SetSize(*this, true, false);
+  bool smo;
+  if (!CompareSizes(res, smo)) 
+    throw(SzMismatchError("TArray<T>::NegateElt(res) SizeMismatch(this,res) ")) ;
+
+  const T * pe;
+  T * per;
+  sa_size_t j,k,kr;
+  if (smo && (IsPacked() > 0) && (res.IsPacked() > 0))   {  // regularly spaced elements
+    sa_size_t maxx = totsize_;
+    pe = Data();
+    per = res.Data();
+    for(k=0; k<maxx; k++) { *per = -(*pe);  per++;  pe++; }
+  }
+  else {    // Non regular data spacing ...
+    int_4 ax,axr;
+    sa_size_t step, stepr;
+    sa_size_t gpas, naxr;
+    GetOpeParams(res, smo, ax, axr, step, stepr, gpas, naxr);
+    for(j=0; j<naxr; j++)  {
+      pe = mNDBlock.Begin()+Offset(ax,j);
+      per = res.DataBlock().Begin()+res.Offset(axr,j);
+      for(k=0, kr=0;  k<gpas;  k+=step, kr+=stepr)  per[kr] = -pe[k]; 
+    }
+  }
+  return(res);
 }
 
Index: trunk/SophyaLib/TArray/tarray.h
===================================================================
--- trunk/SophyaLib/TArray/tarray.h	(revision 2478)
+++ 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;}
 
 ////////////////////////////////////////////////////////////////
Index: trunk/SophyaLib/TArray/tmatrix.h
===================================================================
--- trunk/SophyaLib/TArray/tmatrix.h	(revision 2478)
+++ trunk/SophyaLib/TArray/tmatrix.h	(revision 2564)
@@ -93,11 +93,11 @@
   inline  TMatrix<T>&  operator = (T x)             { SetT(x); return(*this); }
   //! += : add constant value \b x to matrix
-  inline  TMatrix<T>&  operator += (T x)            { Add(x); return(*this); }
+  inline  TMatrix<T>&  operator += (T x)            { AddCst(x,*this); return(*this); }
   //! -= : substract constant value \b x to matrix
-  inline  TMatrix<T>&  operator -= (T x)            { Sub(x); return(*this); }
+  inline  TMatrix<T>&  operator -= (T x)            { SubCst(x,*this); return(*this); }
   //! *= : multiply matrix by constant value \b x
-  inline  TMatrix<T>&  operator *= (T x)            { Mul(x); return(*this); }
+  inline  TMatrix<T>&  operator *= (T x)            { MulCst(x,*this); return(*this); }
   //! /= : divide matrix by constant value \b x
-  inline  TMatrix<T>&  operator /= (T x)            { Div(x); return(*this); }
+  inline  TMatrix<T>&  operator /= (T x)            { DivCst(x,*this); return(*this); }
 
   //  operations avec matrices 
@@ -149,48 +149,48 @@
   \brief Operator TMatrix = TMatrix + constant */
 template <class T> inline TMatrix<T> operator + (const TMatrix<T>& a, T b)
-    {TMatrix<T> result; result.CloneOrShare(a); result.SetTemp(true); 
-    result.Add(b); return result;}
+    {TMatrix<T> result; result.SetTemp(true); 
+    a.AddCst(b,result); return result;}
 
 /*! \ingroup TMatrix \fn operator+(T,const TMatrix<T>&)
   \brief Operator TMatrix = constant + TMatrix */
 template <class T> inline TMatrix<T> operator + (T b,const TMatrix<T>& a)
-    {TMatrix<T> result; result.CloneOrShare(a); result.SetTemp(true); 
-    result.Add(b); return result;}
+    {TMatrix<T> result; result.SetTemp(true); 
+    a.AddCst(b,result); return result;}
 
 /*! \ingroup TMatrix \fn operator-(const TMatrix<T>&,T)
   \brief Operator TMatrix = TMatrix - constant */
 template <class T> inline TMatrix<T> operator - (const TMatrix<T>& a, T b)
-    {TMatrix<T> result; result.CloneOrShare(a); result.SetTemp(true); 
-    result.Sub(b); return result;}
+    {TMatrix<T> result; result.SetTemp(true); 
+    a.SubCst(b,result); return result;}
 
 /*! \ingroup TMatrix \fn operator-(T,const TMatrix<T>&)
   \brief Operator TMatrix = constant - TMatrix */
 template <class T> inline TMatrix<T> operator - (T b,const TMatrix<T>& a)
-    {TMatrix<T> result; result.CloneOrShare(a); result.SetTemp(true); 
-    result.Sub(b,true); return result;}
+    {TMatrix<T> result; result.SetTemp(true); 
+    a.SubCst(b,result,true); return result;}
 
 /*! \ingroup TMatrix \fn operator*(const TMatrix<T>&,T)
   \brief Operator TMatrix = TMatrix * constant */
 template <class T> inline TMatrix<T> operator * (const TMatrix<T>& a, T b)
-    {TMatrix<T> result; result.CloneOrShare(a); result.SetTemp(true); 
-    result.Mul(b); return result;}
+    {TMatrix<T> result; result.SetTemp(true); 
+    a.MulCst(b,result); return result;}
 
 /*! \ingroup TMatrix \fn operator*(T,const TMatrix<T>&)
   \brief Operator TMatrix = constant * TMatrix */
 template <class T> inline TMatrix<T> operator * (T b,const TMatrix<T>& a)
-    {TMatrix<T> result; result.CloneOrShare(a); result.SetTemp(true); 
-    result.Mul(b); return result;}
+    {TMatrix<T> result; result.SetTemp(true); 
+    a.MulCst(b,result); return result;}
 
 /*! \ingroup TMatrix \fn operator/(const TMatrix<T>&,T)
   \brief Operator TMatrix = TMatrix / constant */
 template <class T> inline TMatrix<T> operator / (const TMatrix<T>& a, T b)
-    {TMatrix<T> result; result.CloneOrShare(a); result.SetTemp(true); 
-    result.Div(b); return result;}
+    {TMatrix<T> result; result.SetTemp(true); 
+    a.DivCst(b,result); return result;}
 
 /*! \ingroup TMatrix \fn operator/(T,const TMatrix<T>&)
   \brief Operator TMatrix = constant / TMatrix  */
 template <class T> inline TMatrix<T> operator / (T b, const TMatrix<T>& a)
-    {TMatrix<T> result; result.CloneOrShare(a); result.SetTemp(true); 
-    result.Div(b, true); return result;}
+    {TMatrix<T> result; result.SetTemp(true); 
+    a.Div(b,result,true); return result;}
 
 ////////////////////////////////////////////////////////////////
Index: trunk/SophyaLib/TArray/tvector.h
===================================================================
--- trunk/SophyaLib/TArray/tvector.h	(revision 2478)
+++ trunk/SophyaLib/TArray/tvector.h	(revision 2564)
@@ -67,11 +67,11 @@
   inline  TVector<T>&  operator = (T x)             { SetT(x); return(*this); }
   //! Add constant value \b x to vector elements
-  inline  TVector<T>&  operator += (T x)            { Add(x); return(*this); }
+  inline  TVector<T>&  operator += (T x)            { AddCst(x,*this); return(*this); }
   //! Substract constant value \b x to vector elements
-  inline  TVector<T>&  operator -= (T x)            { Sub(x); return(*this); }
+  inline  TVector<T>&  operator -= (T x)            { SubCst(x,*this); return(*this); }
   //! Multiply vector elements by constant value \b x
-  inline  TVector<T>&  operator *= (T x)            { Mul(x); return(*this); }
+  inline  TVector<T>&  operator *= (T x)            { MulCst(x,*this); return(*this); }
   //! Divide vector elements by constant value \b x
-  inline  TVector<T>&  operator /= (T x)            { Div(x); return(*this); }
+  inline  TVector<T>&  operator /= (T x)            { DivCst(x,*this); return(*this); }
 
   //  operations avec matrices 
