Index: trunk/SophyaLib/TArray/tarray.cc
===================================================================
--- trunk/SophyaLib/TArray/tarray.cc	(revision 1113)
+++ trunk/SophyaLib/TArray/tarray.cc	(revision 1156)
@@ -39,8 +39,8 @@
  */
 template <class T>
-TArray<T>::TArray(uint_4 ndim, const uint_4 * siz, uint_4 step)
+TArray<T>::TArray(int_4 ndim, const sa_size_t * siz, sa_size_t step)
   : BaseArray() , mNDBlock(ComputeTotalSize(ndim, siz, step, 1))
 {
-  string exmsg = "TArray<T>::TArray(uint_4, uint_4 *, uint_4)";
+  string exmsg = "TArray<T>::TArray(int_4, sa_size_t *, sa_size_t)";
   if (!UpdateSizes(ndim, siz, step, 0, exmsg))  throw( ParmError(exmsg) );
 }
@@ -51,11 +51,11 @@
  */
 template <class T>
-TArray<T>::TArray(uint_4 nx, uint_4 ny, uint_4 nz, uint_4 nt, uint_4 nu)
+TArray<T>::TArray(sa_size_t nx, sa_size_t ny, sa_size_t nz, sa_size_t nt, sa_size_t nu)
   : BaseArray() , mNDBlock(nx*((ny>0)?ny:1)*((nz>0)?nz:1)*((nt>0)?nt:1)*((nu>0)?nu:1)) 
 {
-  uint_4 size[BASEARRAY_MAXNDIMS];
+  sa_size_t size[BASEARRAY_MAXNDIMS];
   size[0] = nx;   size[1] = ny;   size[2] = nz;
   size[3] = nt;   size[4] = nu;
-  int ndim = 1;
+  int_4 ndim = 1;
   if ((size[1] > 0) && (size[2] > 0) && (size[3] > 0) && (size[4] > 0) ) ndim = 5;
   else if ((size[1] > 0) && (size[2] > 0) && (size[3] > 0) ) ndim = 4;
@@ -63,5 +63,5 @@
   else if (size[1] > 0)  ndim = 2;
   else ndim = 1;
-  string exmsg = "TArray<T>::TArray(uint_4, uint_4, uint_4)";
+  string exmsg = "TArray<T>::TArray(sa_size_t, sa_size_t, sa_size_t, sa_size_t, sa_size_t)";
   if (!UpdateSizes(ndim, size, 1, 0, exmsg))  throw( ParmError(exmsg) );
 }
@@ -77,8 +77,8 @@
  */
 template <class T>
-TArray<T>::TArray(uint_4 ndim, const uint_4 * siz, NDataBlock<T> & db, bool share, uint_4 step, uint_8 offset)
+TArray<T>::TArray(int_4 ndim, const sa_size_t * siz, NDataBlock<T> & db, bool share, sa_size_t step, sa_size_t offset)
   : BaseArray() , mNDBlock(db, share) 
 {
-  string exmsg = "TArray<T>::TArray(uint_4, uint_4 *,  NDataBlock<T> & ... )";
+  string exmsg = "TArray<T>::TArray(int_4, sa_size_t *,  NDataBlock<T> & ... )";
   if (!UpdateSizes(ndim, siz, step, offset, exmsg))  throw( ParmError(exmsg) );
   
@@ -97,8 +97,8 @@
  */
 template <class T>
-TArray<T>::TArray(uint_4 ndim, const uint_4 * siz, T* values, uint_4 step, uint_8 offset, Bridge* br)
+TArray<T>::TArray(int_4 ndim, const sa_size_t * siz, T* values, sa_size_t step, sa_size_t offset, Bridge* br)
   : BaseArray() , mNDBlock(ComputeTotalSize(ndim, siz, step, 1), values, br) 
 {
-  string exmsg = "TArray<T>::TArray(uint_4, uint_4 *, T* ... )";
+  string exmsg = "TArray<T>::TArray(int_4, sa_size_t *, T* ... )";
   if (!UpdateSizes(ndim, siz, step, offset, exmsg))  throw( ParmError(exmsg) );
 }
@@ -225,5 +225,5 @@
  */
 template <class T>
-void TArray<T>::ReSize(uint_4 ndim, uint_4 * siz, uint_4 step)
+void TArray<T>::ReSize(int_4 ndim, sa_size_t * siz, sa_size_t step)
 {
   if (arrtype_ != 0) {
@@ -247,5 +247,5 @@
  */
 template <class T>
-void TArray<T>::Realloc(uint_4 ndim, uint_4 * siz, uint_4 step, bool force)
+void TArray<T>::Realloc(int_4 ndim, sa_size_t * siz, sa_size_t step, bool force)
 {
   if (arrtype_ != 0) {
@@ -279,8 +279,8 @@
 //! Give value (in \b double) for element at position \b ip..
 template <class T>
-MuTyV & TArray<T>::ValueAtPosition(uint_8 ip) const
+MuTyV & TArray<T>::ValueAtPosition(sa_size_t ip) const
 {
 #ifdef SO_BOUNDCHECKING
-  if (ip >= totsize_)  throw( ParmError("TArray<T>::ValueAtPosition(uint_8 ip) Out-of-bound Error") );
+  if (ip >= totsize_)  throw( ParmError("TArray<T>::ValueAtPosition(sa_size_t ip) Out-of-bound Error") );
 #endif
   my_mtv = *(mNDBlock.Begin()+Offset(ip));
@@ -326,8 +326,8 @@
   if (NbDimensions() < 1) 
     throw RangeCheckError("TArray<T>::operator () (Range, ...) - Not Allocated Array ! ");
-  uint_4 ndim = 0;
-  uint_4 size[BASEARRAY_MAXNDIMS];
-  uint_4 step[BASEARRAY_MAXNDIMS];
-  uint_4 pos[BASEARRAY_MAXNDIMS];
+  int_4 ndim = 0;
+  sa_size_t size[BASEARRAY_MAXNDIMS];
+  sa_size_t step[BASEARRAY_MAXNDIMS];
+  sa_size_t pos[BASEARRAY_MAXNDIMS];
   size[0] = rx.Size();
   size[1] = ry.Size();
@@ -373,11 +373,11 @@
   
   T * pe;
-  uint_8 j,k;
-  int ka;
+  sa_size_t j,k;
+  int_4 ka;
   if (arrtype_ == 0)  ka = 0;
   else ka = macoli_;
-  uint_8 step = Step(ka);
-  uint_8 gpas = Size(ka);
-  uint_8 naxa = Size()/Size(ka);
+  sa_size_t step = Step(ka);
+  sa_size_t gpas = Size(ka);
+  sa_size_t naxa = Size()/Size(ka);
   for(j=0; j<naxa; j++)  {
     pe = mNDBlock.Begin()+Offset(ka,j);
@@ -401,16 +401,16 @@
     throw RangeCheckError("TArray<T>::SetT(T )  - Not Allocated Array ! ");
   T * pe;
-  uint_8 j,k;
+  sa_size_t j,k;
   if (AvgStep() > 0)   {  // regularly spaced elements
-    uint_8 step = AvgStep();
-    uint_8 maxx = totsize_*step;
+    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 ...
-    uint_4 ka = MaxSizeKA();
-    uint_8 step = Step(ka);
-    uint_8 gpas = Size(ka)*step;
-    uint_8 naxa = Size()/Size(ka);
+    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);
@@ -428,16 +428,16 @@
     throw RangeCheckError("TArray<T>::Add(T )  - Not Allocated Array ! ");
   T * pe;
-  uint_8 j,k;
+  sa_size_t j,k;
   if (AvgStep() > 0)   {  // regularly spaced elements
-    uint_8 step = AvgStep();
-    uint_8 maxx = totsize_*step;
+    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 ...
-    uint_4 ka = MaxSizeKA();
-    uint_8 step = Step(ka);
-    uint_8 gpas = Size(ka)*step;
-    uint_8 naxa = Size()/Size(ka);
+    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);
@@ -459,8 +459,8 @@
     throw RangeCheckError("TArray<T>::Sub(T )  - Not Allocated Array ! ");
   T * pe;
-  uint_8 j,k;
+  sa_size_t j,k;
   if (AvgStep() > 0)   {  // regularly spaced elements
-    uint_8 step = AvgStep();
-    uint_8 maxx = totsize_*step;
+    sa_size_t step = AvgStep();
+    sa_size_t maxx = totsize_*step;
     pe = Data();
     if (fginv)
@@ -470,8 +470,8 @@
   }
   else {    // Non regular data spacing ...
-    uint_4 ka = MaxSizeKA();
-    uint_8 step = Step(ka);
-    uint_8 gpas = Size(ka)*step;
-    uint_8 naxa = Size()/Size(ka);
+    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);
@@ -492,16 +492,16 @@
     throw RangeCheckError("TArray<T>::Mul(T )  - Not Allocated Array ! ");
   T * pe;
-  uint_8 j,k;
+  sa_size_t j,k;
   if (AvgStep() > 0)   {  // regularly spaced elements
-    uint_8 step = AvgStep();
-    uint_8 maxx = totsize_*step;
+    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 ...
-    uint_4 ka = MaxSizeKA();
-    uint_8 step = Step(ka);
-    uint_8 gpas = Size(ka)*step;
-    uint_8 naxa = Size()/Size(ka);
+    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);
@@ -525,8 +525,8 @@
     throw MathExc("TArray<T>::Div(T )  - Divide by zero ! ");
   T * pe;
-  uint_8 j,k;
+  sa_size_t j,k;
   if (AvgStep() > 0)   {  // regularly spaced elements
-    uint_8 step = AvgStep();
-    uint_8 maxx = totsize_*step;
+    sa_size_t step = AvgStep();
+    sa_size_t maxx = totsize_*step;
     pe = Data();
     if (fginv)
@@ -536,8 +536,8 @@
   }
   else {    // Non regular data spacing ...
-    uint_4 ka = MaxSizeKA();
-    uint_8 step = Step(ka);
-    uint_8 gpas = Size(ka)*step;
-    uint_8 naxa = Size()/Size(ka);
+    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);
@@ -552,5 +552,30 @@
 
 
-
+//! 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);
+}
 
 //  >>>> Operations avec 2nd membre de type tableau
@@ -567,9 +592,9 @@
   T * pe;
   const T * pea;
-  uint_8 j,k,ka;
+  sa_size_t j,k,ka;
   if (smo && (AvgStep() > 0) && (a.AvgStep() > 0))   {  // regularly spaced elements
-    uint_8 step = AvgStep();
-    uint_8 stepa = a.AvgStep();
-    uint_8 maxx = totsize_*step;
+    sa_size_t step = AvgStep();
+    sa_size_t stepa = a.AvgStep();
+    sa_size_t maxx = totsize_*step;
     pe = Data();
     pea = a.Data();
@@ -577,7 +602,7 @@
   }
   else {    // Non regular data spacing ...
-    int ax,axa;
-    uint_8 step, stepa;
-    uint_8 gpas, naxa;
+    int_4 ax,axa;
+    sa_size_t step, stepa;
+    sa_size_t gpas, naxa;
     GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa);
     for(j=0; j<naxa; j++)  {
@@ -606,9 +631,9 @@
   T * pe;
   const T * pea;
-  uint_8 j,k,ka;
+  sa_size_t j,k,ka;
   if (smo && (AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
-    uint_8 step = AvgStep();
-    uint_8 stepa = a.AvgStep();
-    uint_8 maxx = totsize_*step;
+    sa_size_t step = AvgStep();
+    sa_size_t stepa = a.AvgStep();
+    sa_size_t maxx = totsize_*step;
     pe = Data();
     pea = a.Data();
@@ -619,7 +644,7 @@
   }
   else {    // Non regular data spacing ...
-    int ax,axa;
-    uint_8 step, stepa;
-    uint_8 gpas, naxa;
+    int_4 ax,axa;
+    sa_size_t step, stepa;
+    sa_size_t gpas, naxa;
     GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa);
     for(j=0; j<naxa; j++)  {
@@ -648,9 +673,9 @@
   T * pe;
   const T * pea;
-  uint_8 j,k,ka;
+  sa_size_t j,k,ka;
   if (smo && (AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
-    uint_8 step = AvgStep();
-    uint_8 stepa = a.AvgStep();
-    uint_8 maxx = totsize_*step;
+    sa_size_t step = AvgStep();
+    sa_size_t stepa = a.AvgStep();
+    sa_size_t maxx = totsize_*step;
     pe = Data();
     pea = a.Data();
@@ -658,7 +683,7 @@
   }
   else {    // Non regular data spacing ...
-    int ax,axa;
-    uint_8 step, stepa;
-    uint_8 gpas, naxa;
+    int_4 ax,axa;
+    sa_size_t step, stepa;
+    sa_size_t gpas, naxa;
     GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa);
     for(j=0; j<naxa; j++)  {
@@ -689,9 +714,9 @@
   T * pe;
   const T * pea;
-  uint_8 j,k,ka;
+  sa_size_t j,k,ka;
   if (smo && (AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
-    uint_8 step = AvgStep();
-    uint_8 stepa = a.AvgStep();
-    uint_8 maxx = totsize_*step;
+    sa_size_t step = AvgStep();
+    sa_size_t stepa = a.AvgStep();
+    sa_size_t maxx = totsize_*step;
     pe = Data();
     pea = a.Data();
@@ -711,7 +736,7 @@
   }
   else {    // Non regular data spacing ...
-    int ax,axa;
-    uint_8 step, stepa;
-    uint_8 gpas, naxa;
+    int_4 ax,axa;
+    sa_size_t step, stepa;
+    sa_size_t gpas, naxa;
     GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa);
     for(j=0; j<naxa; j++)  {
@@ -748,9 +773,9 @@
   T * pe;
   const T * pea;
-  uint_8 j,k,ka;
+  sa_size_t j,k,ka;
   if (smo && (AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
-    uint_8 step = AvgStep();
-    uint_8 stepa = a.AvgStep();
-    uint_8 maxx = totsize_*step;
+    sa_size_t step = AvgStep();
+    sa_size_t stepa = a.AvgStep();
+    sa_size_t maxx = totsize_*step;
     pe = Data();
     pea = a.Data();
@@ -758,7 +783,7 @@
   }
   else {    // Non regular data spacing ...
-    int ax,axa;
-    uint_8 step, stepa;
-    uint_8 gpas, naxa;
+    int_4 ax,axa;
+    sa_size_t step, stepa;
+    sa_size_t gpas, naxa;
     GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa);
     for(j=0; j<naxa; j++)  {
@@ -782,10 +807,10 @@
 
   T * pe;
-  uint_8 j,k,ka;
-  uint_8 offa;
+  sa_size_t j,k,ka;
+  sa_size_t offa;
   // Non regular data spacing ...
-  int ax,axa;
-  uint_8 step, stepa;
-  uint_8 gpas, naxa;
+  int_4 ax,axa;
+  sa_size_t step, stepa;
+  sa_size_t gpas, naxa;
   GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa);
   for(j=0; j<naxa; j++)  {
@@ -812,16 +837,16 @@
   T ret=0;
   const T * pe;
-  uint_8 j,k;
+  sa_size_t j,k;
   if (AvgStep() > 0)   {  // regularly spaced elements
-    uint_8 step = AvgStep();
-    uint_8 maxx = totsize_*step;
+    sa_size_t step = AvgStep();
+    sa_size_t maxx = totsize_*step;
     pe = Data();
     for(k=0; k<maxx; k+=step )  ret += pe[k];
   }
   else {    // Non regular data spacing ...
-    uint_4 ka = MaxSizeKA();
-    uint_8 step = Step(ka);
-    uint_8 gpas = Size(ka)*step;
-    uint_8 naxa = Size()/Size(ka);
+    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);
@@ -840,16 +865,16 @@
   T ret=(T)1;
   const T * pe;
-  uint_8 j,k;
+  sa_size_t j,k;
   if (AvgStep() > 0)   {  // regularly spaced elements
-    uint_8 step = AvgStep();
-    uint_8 maxx = totsize_*step;
+    sa_size_t step = AvgStep();
+    sa_size_t maxx = totsize_*step;
     pe = Data();
     for(k=0; k<maxx; k+=step )  ret *= pe[k];
   }
   else {    // Non regular data spacing ...
-    uint_4 ka = MaxSizeKA();
-    uint_8 step = Step(ka);
-    uint_8 gpas = Size(ka)*step;
-    uint_8 naxa = Size()/Size(ka);
+    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);
@@ -868,16 +893,16 @@
   T ret=0;
   const T * pe;
-  uint_8 j,k;
+  sa_size_t j,k;
   if (AvgStep() > 0)   {  // regularly spaced elements
-    uint_8 step = AvgStep();
-    uint_8 maxx = totsize_*step;
+    sa_size_t step = AvgStep();
+    sa_size_t maxx = totsize_*step;
     pe = Data();
     for(k=0; k<maxx; k+=step )  ret += pe[k]*pe[k];
   }
   else {    // Non regular data spacing ...
-    uint_4 ka = MaxSizeKA();
-    uint_8 step = Step(ka);
-    uint_8 gpas = Size(ka)*step;
-    uint_8 naxa = Size()/Size(ka);
+    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);
@@ -896,9 +921,9 @@
 {
   const T * pe;
-  uint_8 j,k;
-  uint_4 ka = MaxSizeKA();
-  uint_8 step = Step(ka);
-  uint_8 gpas = Size(ka)*step;
-  uint_8 naxa = Size()/Size(ka);
+  sa_size_t j,k;
+  int_4 ka = MaxSizeKA();
+  sa_size_t step = Step(ka);
+  sa_size_t gpas = Size(ka)*step;
+  sa_size_t naxa = Size()/Size(ka);
   min = (*this)[0];
   max = (*this)[0];
@@ -948,8 +973,8 @@
 {
   if (maxprt < 0)  maxprt = max_nprt_;
-  uint_4 npr = 0;
+  sa_size_t npr = 0;
   Show(os, si);
   if (ndim_ < 1) return;
-  uint_4 k0,k1,k2,k3,k4;
+  sa_size_t k0,k1,k2,k3,k4;
   for(k4=0; k4<size_[4]; k4++) {
     if (size_[4] > 1) cout << "\n ----- Dimension 5 (U) K4= " << k4 << endl;
@@ -963,5 +988,5 @@
             if(k0 > 0) os << ", ";  
             os << Elem(k0, k1, k2, k3, k4);     npr++;
-	    if (npr >= (uint_4) maxprt) {
+	    if (npr >= (sa_size_t) maxprt) {
 	      if (npr < totsize_)  os << "\n     .... " << endl; return;
 	    }
