Index: trunk/SophyaLib/TArray/tarray.cc
===================================================================
--- trunk/SophyaLib/TArray/tarray.cc	(revision 2937)
+++ trunk/SophyaLib/TArray/tarray.cc	(revision 2938)
@@ -598,7 +598,12 @@
 /*! 
 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 
+
+If not initially allocated, and if the source array (this) is not flagged as 
+temporary, the output array \b res is automatically 
 resized as a packed array with the same sizes as the source (this) array.
+If \b res is not allocated and (this) is temporary, data is shared between \b res and this.
+
 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). 
@@ -609,5 +614,8 @@
   if (NbDimensions() < 1) 
     throw RangeCheckError("TArray<T>::AddCst(T,res)  - Not allocated source array ");
-  if (res.NbDimensions() < 1)  res.SetSize(*this, true, false);
+  if (res.NbDimensions() < 1)  {
+    if ( IsTemp() )  res.Share(*this);
+    else res.SetSize(*this, true, false);
+  }
   bool smo;
   if (!CompareSizes(res, smo)) 
@@ -640,7 +648,12 @@
 /*! 
 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 
+
+If not initially allocated, and if the source array (this) is not flagged as 
+temporary, the output array \b res is automatically 
 resized as a packed array with the same sizes as the source (this) array.
+If \b res is not allocated and (this) is temporary, data is shared between \b res and this.
+
 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). 
@@ -652,5 +665,8 @@
   if (NbDimensions() < 1) 
     throw RangeCheckError("TArray<T>::SubCst(T,res)  - Not allocated source array ");
-  if (res.NbDimensions() < 1)  res.SetSize(*this, true, false);
+  if (res.NbDimensions() < 1)  {
+    if ( IsTemp() )  res.Share(*this);
+    else res.SetSize(*this, true, false);
+  }
   bool smo;
   if (!CompareSizes(res, smo)) 
@@ -689,7 +705,12 @@
 /*! 
 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 
+
+If not initially allocated, and if the source array (this) is not flagged as 
+temporary, the output array \b res is automatically 
 resized as a packed array with the same sizes as the source (this) array.
+If \b res is not allocated and (this) is temporary, data is shared between \b res and this.
+
 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). 
@@ -700,5 +721,8 @@
   if (NbDimensions() < 1) 
     throw RangeCheckError("TArray<T>::MulCst(T,res)  - Not allocated source array ");
-  if (res.NbDimensions() < 1)  res.SetSize(*this, true, false);
+  if (res.NbDimensions() < 1)  {
+    if ( IsTemp() )  res.Share(*this);
+    else res.SetSize(*this, true, false);
+  }
   bool smo;
   if (!CompareSizes(res, smo)) 
@@ -731,7 +755,12 @@
 /*! 
 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 
+
+If not initially allocated, and if the source array (this) is not flagged as 
+temporary, the output array \b res is automatically 
 resized as a packed array with the same sizes as the source (this) array.
+If \b res is not allocated and (this) is temporary, data is shared between \b res and this.
+
 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)). 
@@ -745,5 +774,8 @@
   if (!fginv && (x == (T) 0) ) 
     throw MathExc("TArray<T>::DivCst(T,res)  - Divide by zero ! ");
-  if (res.NbDimensions() < 1)  res.SetSize(*this, true, false);
+  if (res.NbDimensions() < 1)  {
+    if ( IsTemp() )  res.Share(*this);
+    else res.SetSize(*this, true, false);
+  }
   bool smo;
   if (!CompareSizes(res, smo)) 
@@ -782,6 +814,9 @@
 //! Stores the opposite of the source array in \b res (res=-(*this)). 
 /*! 
-If not initially allocated, the output array \b res is automatically 
+If not initially allocated, and if the source array (this) is not flagged as 
+temporary, the output array \b res is automatically 
 resized as a packed array with the same sizes as the source (this) array.
+If \b res is not allocated and (this) is temporary, data is shared between \b res and this.
+
 Returns a reference to the output array \b res. 
 */
@@ -791,5 +826,8 @@
   if (NbDimensions() < 1) 
     throw RangeCheckError("TArray<T>::NegateElt(res)  - Not allocated source array ");
-  if (res.NbDimensions() < 1)  res.SetSize(*this, true, false);
+  if (res.NbDimensions() < 1)  {
+    if ( IsTemp() )  res.Share(*this);
+    else res.SetSize(*this, true, false);
+  }
   bool smo;
   if (!CompareSizes(res, smo)) 
@@ -826,7 +864,13 @@
 and store the result in \b res (res = *this+a). The source and argument arrays (this, a)
 should have the same sizes.
-If not initially allocated, the output array \b res is automatically 
+
+If not initially allocated, and if none of the source arrays is flagged as 
+temporary, the output array \b res is automatically 
 resized as a packed array with the same sizes as the source (this) array.
+If \b res is not allocated and one of the source array is temporary,
+data is shared between \b res and the temporary source array.
+
 Returns a reference to the output array \b res. 
+
 \param a : Array to be added to the source array.
 \param res : Output array containing the result (res=this+a). 
@@ -840,5 +884,9 @@
   if (!CompareSizes(a, smoa)) 
     throw(SzMismatchError("TArray<T>::AddElt(...) SizeMismatch(this,a)")) ;
-  if (res.NbDimensions() < 1)  res.SetSize(*this, true, false);
+  if (res.NbDimensions() < 1)  {
+    if ( IsTemp() )  res.Share(*this);
+    else if ( a.IsTemp() ) res.Share(a);
+    else res.SetSize(*this, true, false);
+  }
   bool smor;
   if (!CompareSizes(res, smor)) 
@@ -892,7 +940,13 @@
 and the store result in \b res (res = *this-a or res=a-(*this)). 
 The source and argument arrays (this, a) should have the same sizes.
-If not initially allocated, the output array \b res is automatically 
+
+If not initially allocated, and if none of the source arrays is flagged as 
+temporary, the output array \b res is automatically 
 resized as a packed array with the same sizes as the source (this) array.
+If \b res is not allocated and one of the source array is temporary,
+data is shared between \b res and the temporary source array.
+
 Returns a reference to the output array \b res. 
+
 \param a : Array to be added to the source array.
 \param res : Output array containing the result (res=*this+x). 
@@ -908,5 +962,9 @@
   if (!CompareSizes(a, smoa)) 
     throw(SzMismatchError("TArray<T>::SubElt(...) SizeMismatch(this,a)")) ;
-  if (res.NbDimensions() < 1)  res.SetSize(*this, true, false);
+  if (res.NbDimensions() < 1)  {
+    if ( IsTemp() )  res.Share(*this);
+    else if ( a.IsTemp() ) res.Share(a);
+    else res.SetSize(*this, true, false);
+  }
   bool smor;
   if (!CompareSizes(res, smor)) 
@@ -966,7 +1024,13 @@
 and store the result in \b res (res = *this*a). The source and argument arrays (this, a)
 should have the same sizes.
-If not initially allocated, the output array \b res is automatically 
+
+If not initially allocated, and if none of the source arrays is flagged as 
+temporary, the output array \b res is automatically 
 resized as a packed array with the same sizes as the source (this) array.
+If \b res is not allocated and one of the source array is temporary,
+data is shared between \b res and the temporary source array.
+
 Returns a reference to the output array \b res. 
+
 \param a : Array to be added to the source array.
 \param res : Output array containing the result (res=(*this)*a). 
@@ -980,5 +1044,9 @@
   if (!CompareSizes(a, smoa)) 
     throw(SzMismatchError("TArray<T>::MulElt(...) SizeMismatch(this,a)")) ;
-  if (res.NbDimensions() < 1)  res.SetSize(*this, true, false);
+  if (res.NbDimensions() < 1)  {
+    if ( IsTemp() )  res.Share(*this);
+    else if ( a.IsTemp() ) res.Share(a);
+    else res.SetSize(*this, true, false);
+  }
   bool smor;
   if (!CompareSizes(res, smor)) 
@@ -1032,7 +1100,13 @@
 and store the result in \b res (res = *this/a). The source and argument arrays (this, a)
 should have the same sizes.
-If not initially allocated, the output array \b res is automatically 
+
+If not initially allocated, and if none of the source arrays is flagged as 
+temporary, the output array \b res is automatically 
 resized as a packed array with the same sizes as the source (this) array.
+If \b res is not allocated and one of the source array is temporary,
+data is shared between \b res and the temporary source array.
+
 Returns a reference to the output array \b res. 
+
 \param a : Array to be added to the source array.
 \param res : Output array containing the result (res=*this/a). 
@@ -1049,5 +1123,9 @@
   if (!CompareSizes(a, smoa)) 
     throw(SzMismatchError("TArray<T>::DivElt(...) SizeMismatch(this,a)")) ;
-  if (res.NbDimensions() < 1)  res.SetSize(*this, true, false);
+  if (res.NbDimensions() < 1)  {
+    if ( IsTemp() )  res.Share(*this);
+    else if ( a.IsTemp() ) res.Share(a);
+    else res.SetSize(*this, true, false);
+  }
   bool smor;
   if (!CompareSizes(res, smor)) 
Index: trunk/SophyaLib/TArray/tarray.h
===================================================================
--- trunk/SophyaLib/TArray/tarray.h	(revision 2937)
+++ trunk/SophyaLib/TArray/tarray.h	(revision 2938)
@@ -298,5 +298,5 @@
 
 ////////////////////////////////////////////////////////////////
-// Surcharge d'operateurs C = A (+,-) B
+// Surcharge d'operateurs C = A (+,-,&&,/) B
 
 /*! \ingroup TArray \fn operator+(const TArray<T>&,const TArray<T>&)
@@ -314,18 +314,18 @@
     a.SubElt(b, result);    return result; }
 
-/*! \ingroup TArray \fn MultiplyElt((const TArray<T>&,const TArray<T>&)
+/*! \ingroup TArray \fn operator && (const TArray<T>&,const TArray<T>&)
   \brief Element by element multiplication of two arrays TArray = TArray * TArray */
 
 template <class T>
-inline TArray<T> MultiplyElt(const TArray<T>& a,const TArray<T>& b)
+inline TArray<T> operator && (const TArray<T>& a,const TArray<T>& b)
     { TArray<T> result; result.SetTemp(true); 
     a.MulElt(b, result);    return result; }
 
-/*! \ingroup TArray \fn DivideElt((const TArray<T>&,const TArray<T>&)
-  \brief Element by element division of two arrays TArray = TArray * TArray */
-template <class T>
-inline TArray<T> DivideElt(const TArray<T>& a,const TArray<T>& b, bool divzero=false)
+/*! \ingroup TArray \fn operator / (const TArray<T>&,const TArray<T>&)
+  \brief Element by element division of two arrays TArray = TArray / TArray */
+template <class T>
+inline TArray<T> operator / (const TArray<T>& a,const TArray<T>& b)
     { TArray<T> result; result.SetTemp(true); 
-    a.DivElt(b, result, false, divzero);    return result; }
+    a.DivElt(b, result, false, false);    return result; }
 
 // --------------------------------------------------
