Index: trunk/SophyaLib/TArray/tarray.h
===================================================================
--- trunk/SophyaLib/TArray/tarray.h	(revision 772)
+++ trunk/SophyaLib/TArray/tarray.h	(revision 785)
@@ -14,4 +14,5 @@
 #include "ndatablock.h"
 #include "dvlist.h"
+#include "utilarr.h"
 
 
@@ -20,18 +21,4 @@
 
 namespace SOPHYA {
-
-/* Quelques utilitaires */
-typedef double (* Arr_DoubleFunctionOfX) (double x);
-typedef float  (* Arr_FloatFunctionOfX)  (float x);
-
-class Sequence { 
-public:
-  Sequence (double start=0., double step=1.);
-  inline double & Start() { return start_; }
-  inline double & Step() { return step_; }
-  inline double operator () (uint_4 k) { return(start_+(double)k*step_); }
-protected:
-  double start_, step_;
-};
 
 // Forward declaration
@@ -56,6 +43,4 @@
   virtual TArray<T>& operator = (const TArray<T>& a);
 
-  // Extraction de sous-tableau
-  virtual TArray<T> SubArray(uint_4 ndim, uint_4 * siz, uint_4 * pos);
 
   // Gestion taille/Remplissage
@@ -65,5 +50,7 @@
   // Returns true if ndim and sizes are equal
   virtual bool CompareSizes(const TArray<T>& a);
- 
+  // Compacts size=1 array dimensions
+  virtual TArray<T>& CompactDim();
+
   // Array dimensions
   inline uint_4 NbDimensions() const { return( ndim_ ); }
@@ -75,6 +62,8 @@
   inline uint_4 Size(int ka) const { return(size_[CheckDI(ka,1)]); }
 
+  uint_4 MaxSizeKA() const ;
+
   // memory organisation - packing information
-  inline bool   IsPacked() const { return(minstep_ == 1); }
+  inline bool   IsPacked() const { return(moystep_ == 1); }
   inline bool   IsPackedX() const { return(step_[0] == 1); }
   inline bool   IsPackedY() const { return(step_[1] == 1); }
@@ -82,5 +71,6 @@
   inline bool   IsPacked(int ka) const { return(step_[CheckDI(ka,2)] == 1); }
 
-  inline uint_4 Step() const  { return(minstep_); }
+  inline uint_4 MinStep() const  { return(minstep_); }
+  inline uint_4 AvgStep() const  { return(moystep_); }
   inline uint_4 StepX() const { return(step_[0]); }
   inline uint_4 StepZ() const { return(step_[1]); }
@@ -88,5 +78,7 @@
   inline uint_4 Step(int ka) const { return(step_[CheckDI(ka,3)]); }
 
-  inline uint_8 Offset() const { return(offset_); }
+  uint_4 MinStepKA() const ;
+
+  uint_8 Offset(uint_8 ip=0) const ;
 
 
@@ -94,4 +86,7 @@
   inline bool   IsTemp(void) const {return mNDBlock.IsTemp();}
   inline void   SetTemp(bool temp=false) const {mNDBlock.SetTemp(temp);}
+
+  // SubArrays
+  virtual TArray<T> operator () (Range rx, Range ry, Range rz=0, Range rt=0, Range ru=0); 
 
   // Acces to data
@@ -100,6 +95,6 @@
   inline T const& operator()(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu=0) const ;
   inline T&       operator()(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu=0);
-  inline T const& operator[](uint_4 ip) const ;
-  inline T&       operator[](uint_4 ip);
+  inline T const& operator[](uint_8 ip) const ;
+  inline T&       operator[](uint_8 ip);
 
   inline T const& Elem(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it=0, uint_4 iu=0) const ;
@@ -117,5 +112,5 @@
   inline operator T();
 // Met les elements a une suite de valeurs
-  virtual TArray<T>&  operator = (Sequence & seq);
+  virtual TArray<T>&  operator = (Sequence seq);
 // A = x (tous les elements a x)
   virtual TArray<T>&  operator = (T x);
@@ -162,4 +157,6 @@
   // Share: partage les donnees de "a"
   void Share(const TArray<T>& a);
+  // Extraction de sous-tableau
+  virtual void SubArray(TArray<T> & ra, uint_4 ndim, uint_4 * siz, uint_4 * pos, uint_4 * step);
 
   uint_4 ndim_;                   // nb of dimensions
@@ -168,4 +165,5 @@
   uint_4 step_[TARRAY_MAXNDIMS];     // two consecutive elements distance in a given dimension 
   uint_4 minstep_;                   // minimal step (in any axes)
+  uint_4 moystep_;                   // mean step 0 non regular steps
   uint_8 offset_;              // global offset -> position of elem[0] in DataBlock
   NDataBlock<T> mNDBlock;      // Le bloc des donnees
@@ -254,4 +252,5 @@
 }
 
+
 // --------------------------------------------------
 //        inline element acces methods
@@ -329,21 +328,23 @@
 }
 
-template <class T>
-inline T const& TArray<T>::operator[](uint_4 ip) const
+
+template <class T>
+inline T const& TArray<T>::operator[](uint_8 ip) const
 {
 #ifdef SO_BOUNDCHECKING
   if (ip >= totsize_)  throw( ParmError("TArray<T>::operator[] Out-of-bound Error") );
 #endif
-return *(mNDBlock.Begin()+offset_+ip*minstep_);
-}
-
-template <class T>
-inline T & TArray<T>::operator[](uint_4 ip) 
+return *(mNDBlock.Begin()+Offset(ip));
+}
+
+template <class T>
+inline T & TArray<T>::operator[](uint_8 ip) 
 {
 #ifdef SO_BOUNDCHECKING
   if (ip >= totsize_)  throw( ParmError("TArray<T>::operator[] Out-of-bound Error") );
 #endif
-return *(mNDBlock.Begin()+offset_+ip*minstep_);
-}
+return *(mNDBlock.Begin()+Offset(ip));
+}
+
 
 template <class T>
