Index: trunk/SophyaLib/TArray/tarray.cc
===================================================================
--- trunk/SophyaLib/TArray/tarray.cc	(revision 1085)
+++ trunk/SophyaLib/TArray/tarray.cc	(revision 1099)
@@ -223,4 +223,10 @@
 void TArray<T>::ReSize(uint_4 ndim, uint_4 * siz, uint_4 step)
 {
+  if (arrtype_ != 0) {
+    if (ndim != 2) 
+       throw( ParmError("TArray<T>::ReSize(ndim!=2,...) for Matrix" ) ); 
+    if ((arrtype_ == 2) && (siz[0] > 1) && (siz[1] > 1)) 
+       throw( ParmError("TArray<T>::ReSize(,siz[0]>1 && size[1]>1) for Vector" ) ); 
+  }
   string exmsg = "TArray<T>::ReSize()";
   if (!UpdateSizes(ndim, siz, step, 0, exmsg))  throw( ParmError(exmsg) );
@@ -239,4 +245,10 @@
 void TArray<T>::Realloc(uint_4 ndim, uint_4 * siz, uint_4 step, bool force)
 {
+  if (arrtype_ != 0) {
+    if (ndim != 2) 
+       throw( ParmError("TArray<T>::Realloc(ndim!=2,...) for Matrix" ) ); 
+    if ((arrtype_ == 2) && (siz[0] > 1) && (siz[1] > 1)) 
+       throw( ParmError("TArray<T>::Realloc(,siz[0]>1 && size[1]>1) for Vector" ) ); 
+  }
   string exmsg = "TArray<T>::Realloc()";
   if (!UpdateSizes(ndim, siz, step, 0, exmsg))  throw( ParmError(exmsg) );
@@ -545,5 +557,6 @@
   if (NbDimensions() < 1) 
     throw RangeCheckError("TArray<T>::AddElt(const TArray<T>& )  - Not Allocated Array ! ");
-  if (!CompareSizes(a)) 
+  bool smo;
+  if (!CompareSizes(a, smo)) 
     throw(SzMismatchError("TArray<T>::AddElt(const TArray<T>&) SizeMismatch")) ;
 
@@ -551,5 +564,5 @@
   const T * pea;
   uint_8 j,k,ka;
-  if ((AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
+  if (smo && (AvgStep() > 0) && (a.AvgStep() > 0))   {  // regularly spaced elements
     uint_8 step = AvgStep();
     uint_8 stepa = a.AvgStep();
@@ -560,12 +573,11 @@
   }
   else {    // Non regular data spacing ...
-    uint_4 ax = MaxSizeKA();
-    uint_8 step = Step(ax);
-    uint_8 stepa = a.Step(ax);
-    uint_8 gpas = Size(ax)*step;
-    uint_8 naxa = Size()/Size(ax);
+    int ax,axa;
+    uint_8 step, stepa;
+    uint_8 gpas, naxa;
+    GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa);
     for(j=0; j<naxa; j++)  {
       pe = mNDBlock.Begin()+Offset(ax,j);
-      pea = a.DataBlock().Begin()+a.Offset(ax,j);
+      pea = a.DataBlock().Begin()+a.Offset(axa,j);
       for(k=0, ka=0;  k<gpas;  k+=step, ka+=stepa)  pe[k] += pea[ka]; 
     }
@@ -584,5 +596,6 @@
   if (NbDimensions() < 1) 
     throw RangeCheckError("TArray<T>::SubElt(const TArray<T>& )  - Not Allocated Array ! ");
-  if (!CompareSizes(a)) 
+  bool smo;
+  if (!CompareSizes(a, smo)) 
     throw(SzMismatchError("TArray<T>::SubElt(const TArray<T>&) SizeMismatch")) ;
 
@@ -590,5 +603,5 @@
   const T * pea;
   uint_8 j,k,ka;
-  if ((AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
+  if (smo && (AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
     uint_8 step = AvgStep();
     uint_8 stepa = a.AvgStep();
@@ -602,12 +615,11 @@
   }
   else {    // Non regular data spacing ...
-    uint_4 ax = MaxSizeKA();
-    uint_8 step = Step(ax);
-    uint_8 stepa = a.Step(ax);
-    uint_8 gpas = Size(ax)*step;
-    uint_8 naxa = Size()/Size(ax);
+    int ax,axa;
+    uint_8 step, stepa;
+    uint_8 gpas, naxa;
+    GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa);
     for(j=0; j<naxa; j++)  {
       pe = mNDBlock.Begin()+Offset(ax,j);
-      pea = a.DataBlock().Begin()+a.Offset(ax,j);
+      pea = a.DataBlock().Begin()+a.Offset(axa,j);
       if (fginv) 
 	for(k=0, ka=0;  k<gpas;  k+=step, ka+=stepa)  pe[k] = pea[ka]-pe[k] ;
@@ -626,5 +638,6 @@
   if (NbDimensions() < 1) 
     throw RangeCheckError("TArray<T>::MulElt(const TArray<T>& )  - Not Allocated Array ! ");
-  if (!CompareSizes(a)) 
+  bool smo;
+  if (!CompareSizes(a, smo)) 
     throw(SzMismatchError("TArray<T>::MulElt(const TArray<T>&) SizeMismatch")) ;
 
@@ -632,5 +645,5 @@
   const T * pea;
   uint_8 j,k,ka;
-  if ((AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
+  if (smo && (AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
     uint_8 step = AvgStep();
     uint_8 stepa = a.AvgStep();
@@ -641,12 +654,11 @@
   }
   else {    // Non regular data spacing ...
-    uint_4 ax = MaxSizeKA();
-    uint_8 step = Step(ax);
-    uint_8 stepa = a.Step(ax);
-    uint_8 gpas = Size(ax)*step;
-    uint_8 naxa = Size()/Size(ax);
-    for(j=0; j<naxa; j++)  {
-      pe = mNDBlock.Begin()+Offset(ax,j);
-      pea = a.DataBlock().Begin()+a.Offset(ax,j);
+    int ax,axa;
+    uint_8 step, stepa;
+    uint_8 gpas, naxa;
+    GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa);
+    for(j=0; j<naxa; j++)  {
+      pe = mNDBlock.Begin()+Offset(axa,j);
+      pea = a.DataBlock().Begin()+a.Offset(axa,j);
       for(k=0, ka=0;  k<gpas;  k+=step, ka+=stepa)  pe[k] *= pea[ka]; 
     }
@@ -667,5 +679,6 @@
   if (NbDimensions() < 1) 
     throw RangeCheckError("TArray<T>::DivElt(const TArray<T>& )  - Not Allocated Array ! ");
-  if (!CompareSizes(a)) 
+  bool smo;
+  if (!CompareSizes(a, smo)) 
     throw(SzMismatchError("TArray<T>::DivElt(const TArray<T>&) SizeMismatch")) ;
 
@@ -673,5 +686,5 @@
   const T * pea;
   uint_8 j,k,ka;
-  if ((AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
+  if (smo && (AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
     uint_8 step = AvgStep();
     uint_8 stepa = a.AvgStep();
@@ -694,12 +707,11 @@
   }
   else {    // Non regular data spacing ...
-    uint_4 ax = MaxSizeKA();
-    uint_8 step = Step(ax);
-    uint_8 stepa = a.Step(ax);
-    uint_8 gpas = Size(ax)*step;
-    uint_8 naxa = Size()/Size(ax);
+    int ax,axa;
+    uint_8 step, stepa;
+    uint_8 gpas, naxa;
+    GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa);
     for(j=0; j<naxa; j++)  {
       pe = mNDBlock.Begin()+Offset(ax,j);
-      pea = a.DataBlock().Begin()+a.Offset(ax,j);
+      pea = a.DataBlock().Begin()+a.Offset(axa,j);
       if(divzero) {
         if (fginv) 
@@ -726,5 +738,6 @@
   if (NbDimensions() < 1) 
     throw RangeCheckError("TArray<T>::CopyElt(const TArray<T>& )  - Not Allocated Array ! ");
-  if (!CompareSizes(a)) 
+  bool smo;
+  if (!CompareSizes(a, smo)) 
     throw(SzMismatchError("TArray<T>::CopyElt(const TArray<T>&) SizeMismatch")) ;
 
@@ -732,5 +745,5 @@
   const T * pea;
   uint_8 j,k,ka;
-  if ((AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
+  if (smo && (AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
     uint_8 step = AvgStep();
     uint_8 stepa = a.AvgStep();
@@ -741,12 +754,11 @@
   }
   else {    // Non regular data spacing ...
-    uint_4 ax = MaxSizeKA();
-    uint_8 step = Step(ax);
-    uint_8 stepa = a.Step(ax);
-    uint_8 gpas = Size(ax)*step;
-    uint_8 naxa = Size()/Size(ax);
+    int ax,axa;
+    uint_8 step, stepa;
+    uint_8 gpas, naxa;
+    GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa);
     for(j=0; j<naxa; j++)  {
       pe = mNDBlock.Begin()+Offset(ax,j);
-      pea = a.DataBlock().Begin()+a.Offset(ax,j);
+      pea = a.DataBlock().Begin()+a.Offset(axa,j);
       for(k=0, ka=0;  k<gpas;  k+=step, ka+=stepa)  pe[k] = pea[ka]; 
     }
@@ -761,5 +773,6 @@
   if (NbDimensions() < 1) 
     throw RangeCheckError("TArray<T>::ConvertAndCopyElt(const TArray<T>& )  - Not Allocated Array ! ");
-  if (!CompareSizes(a)) 
+  bool smo;
+  if (!CompareSizes(a, smo)) 
     throw(SzMismatchError("TArray<T>::ConvertAndCopyElt(const TArray<T>&) SizeMismatch")) ;
 
@@ -768,12 +781,11 @@
   uint_8 offa;
   // Non regular data spacing ...
-  uint_4 ax = MaxSizeKA();
-  uint_8 step = Step(ax);
-  uint_8 stepa = a.Step(ax);
-  uint_8 gpas = Size(ax)*step;
-  uint_8 naxa = Size()/Size(ax);
+  int ax,axa;
+  uint_8 step, stepa;
+  uint_8 gpas, naxa;
+  GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa);
   for(j=0; j<naxa; j++)  {
     pe = mNDBlock.Begin()+Offset(ax,j);
-    offa = a.Offset(ax,j);
+    offa = a.Offset(axa,j);
 #if !defined(__GNUG__)
     for(k=0, ka=0;  k<gpas;  k+=step, ka+=stepa)  pe[k] = (T)a.ValueAtPosition(offa+ka); 
