Index: /trunk/SophyaLib/TArray/basarr.h
===================================================================
--- /trunk/SophyaLib/TArray/basarr.h	(revision 1080)
+++ /trunk/SophyaLib/TArray/basarr.h	(revision 1081)
@@ -10,4 +10,5 @@
 #include <iostream.h>
 #include "anydataobj.h"
+#include "mutyv.h"
 #include "dvlist.h"
 
@@ -134,5 +135,5 @@
 
   // an abstract element acces methode
-  virtual double ValueAtPosition(uint_8 ip) const = 0;
+  virtual MuTyV & ValueAtPosition(uint_8 ip) const = 0;
 
  // Impression, I/O, ...
Index: /trunk/SophyaLib/TArray/tarray.cc
===================================================================
--- /trunk/SophyaLib/TArray/tarray.cc	(revision 1080)
+++ /trunk/SophyaLib/TArray/tarray.cc	(revision 1081)
@@ -131,4 +131,16 @@
 }
 
+//! Constructor with size and contents copied (after conversion) from a different type TArray
+template <class T>
+TArray<T>::TArray(const BaseArray& a)
+  : BaseArray() , mNDBlock() 
+{
+  string exmsg = "TArray<T>::TArray(const BaseArray&)";
+  if (!UpdateSizes(a, exmsg))  throw( ParmError(exmsg) );
+  mNDBlock.ReSize(totsize_);    
+  //  if (a.mInfo) mInfo = new DVList(*(a.mInfo));  - pb protected !
+  ConvertAndCopyElt(a);
+}
+
 //! Destructor 
 template <class T>
@@ -155,4 +167,20 @@
 }
 
+//! Set array elements equal to the \b a array elements, after conversion 
+template <class T>
+TArray<T>& TArray<T>::SetBA(const BaseArray& a)
+{
+  if (this == &a) return(*this);
+  if (a.NbDimensions() < 1) 
+    throw RangeCheckError("TArray<T>::SetBA(a ) - Array a not allocated ! ");
+  if (NbDimensions() < 1) {
+    string exmsg = "TArray<T>::SetBA(const BaseArray& a)";
+    if (!UpdateSizes(a, exmsg))  throw( ParmError(exmsg) );
+    mNDBlock.ReSize(totsize_);    
+  }
+  ConvertAndCopyElt(a);
+  return(*this);
+}
+
 //! Clone array \b a
 template <class T>
@@ -233,44 +261,13 @@
 }
 
-inline double _SqrtRz_(double x) { return sqrt(x); }  // Pb avec SGI-CC - $CHECK$ - Reza 04/2000
-
 //! Give value (in \b double) for element at position \b ip..
 template <class T>
-double TArray<T>::ValueAtPosition(uint_8 ip) const
+MuTyV & TArray<T>::ValueAtPosition(uint_8 ip) const
 {
 #ifdef SO_BOUNDCHECKING
   if (ip >= totsize_)  throw( ParmError("TArray<T>::ValueAtPosition(uint_8 ip) Out-of-bound Error") );
 #endif
-  return( (double)(*(mNDBlock.Begin()+Offset(ip))) );
-}
-
-//! Give value (in \b double) for element at position \b ip..
-/*!
-  For complex values, we return the module of the complex number
-*/
-double TArray< complex<r_4> >::ValueAtPosition(uint_8 ip) const
-{
-#ifdef SO_BOUNDCHECKING
-  if (ip >= totsize_)  throw( ParmError("TArray<T>::ValueAtPosition(uint_8 ip) Out-of-bound Error") );
-#endif
-  complex<r_4> c = *(mNDBlock.Begin()+Offset(ip));
-  double cr = (double)(c.real());
-  double ci = (double)(c.imag());
-  return( _SqrtRz_(cr*cr+ci*ci) );
-}
-
-//! Give value (in \b double) for element at position \b ip..
-/*!
-  For complex values, we return the module of the complex number
-*/
-double TArray< complex<r_8> >::ValueAtPosition(uint_8 ip) const
-{
-#ifdef SO_BOUNDCHECKING
-  if (ip >= totsize_)  throw( ParmError("TArray<T>::ValueAtPosition(uint_8 ip) Out-of-bound Error") );
-#endif
-  complex<r_8> c = *(mNDBlock.Begin()+Offset(ip));
-  double cr = (double)(c.real());
-  double ci = (double)(c.imag());
-  return( _SqrtRz_(cr*cr+ci*ci) );
+  my_mtv = *(mNDBlock.Begin()+Offset(ip));
+  return( my_mtv );
 }
 
@@ -754,4 +751,30 @@
       for(k=0, ka=0;  k<gpas;  k+=step, ka+=stepa)  pe[k] = pea[ka]; 
     }
+  }
+  return(*this);
+}
+
+//! Converts and Copy elements of \b a
+template <class T>
+TArray<T>& TArray<T>::ConvertAndCopyElt(const BaseArray& a)
+{
+  if (NbDimensions() < 1) 
+    throw RangeCheckError("TArray<T>::ConvertAndCopyElt(const TArray<T>& )  - Not Allocated Array ! ");
+  if (!CompareSizes(a)) 
+    throw(SzMismatchError("TArray<T>::ConvertAndCopyElt(const TArray<T>&) SizeMismatch")) ;
+
+  T * pe;
+  uint_8 j,k,ka;
+  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);
+  for(j=0; j<naxa; j++)  {
+    pe = mNDBlock.Begin()+Offset(ax,j);
+    offa = a.Offset(ax,j);
+    for(k=0, ka=0;  k<gpas;  k+=step, ka+=stepa)  pe[k] = a.ValueAtPosition(offa+ka); 
   }
   return(*this);
Index: /trunk/SophyaLib/TArray/tarray.h
===================================================================
--- /trunk/SophyaLib/TArray/tarray.h	(revision 1080)
+++ /trunk/SophyaLib/TArray/tarray.h	(revision 1081)
@@ -35,4 +35,5 @@
   TArray(const TArray<T>& a);
   TArray(const TArray<T>& a, bool share);
+  TArray(const BaseArray& a);
 
   virtual ~TArray();
@@ -44,4 +45,8 @@
   inline  TArray<T>& operator = (const TArray<T>& a) { return Set(a); }
   virtual TArray<T>& Set(const TArray<T>& a);
+
+  //! = operator between  TArray 's with different types - Elements are converted.
+  inline  TArray<T>& operator = (const BaseArray& a) { return SetBA(a); }
+  virtual TArray<T>& SetBA(const BaseArray& a);
 
   // Gestion taille/Remplissage
@@ -83,5 +88,5 @@
   // ---- Access to data
   // Definition of virtual element acces method inherited from BaseArray class 
-  virtual double ValueAtPosition(uint_8 ip) const;
+  virtual MuTyV & ValueAtPosition(uint_8 ip) const;
 
   // Data Access: operator overloaded inline acces methods 
@@ -150,4 +155,6 @@
 // Recopie des valeurs, element par element
   virtual TArray<T>&  CopyElt(const TArray<T>& a);
+// Recopie des valeurs avec conversion prealable, element par element
+  virtual TArray<T>&  ConvertAndCopyElt(const BaseArray& a);
 
 // Somme et produit des elements
@@ -165,4 +172,5 @@
 
   NDataBlock<T> mNDBlock; //!< Block for datas
+  mutable MuTyV my_mtv;   //!< for use by ValueAtPosition()
 };
 
Index: /trunk/SophyaLib/TArray/tmatrix.cc
===================================================================
--- /trunk/SophyaLib/TArray/tmatrix.cc	(revision 1080)
+++ /trunk/SophyaLib/TArray/tmatrix.cc	(revision 1081)
@@ -1,3 +1,3 @@
-// $Id: tmatrix.cc,v 1.12 2000-05-02 15:49:29 ansari Exp $
+// $Id: tmatrix.cc,v 1.13 2000-07-24 12:51:27 ansari Exp $
 //                         C.Magneville          04/99
 #include "machdefs.h"
@@ -99,4 +99,13 @@
   UpdateMemoryMapping(a, mm);
 }
+
+template <class T>
+TMatrix<T>::TMatrix(const BaseArray& a)
+: TArray<T>()
+{
+  SetBA(a);
+}
+
+
 
 //! Destructor
@@ -125,4 +134,21 @@
   return(*this);
 }
+
+template <class T>
+TArray<T>& TMatrix<T>::SetBA(const BaseArray& a)
+{
+  if (a.NbDimensions() > 2) 
+    throw SzMismatchError("TMatrix<T>::SetBA(const BaseArray& a) a.NbDimensions() > 2");
+  TArray<T>::SetBA(a);
+  if (NbDimensions() == 1) {
+    size_[1] = 1;
+    step_[1] = size_[0]*step_[0];
+    ndim_ = 2;
+  }
+  UpdateMemoryMapping(*this, SameMemoryMapping);
+  return(*this);
+}
+
+
 
 //! Resize the matrix
Index: /trunk/SophyaLib/TArray/tmatrix.h
===================================================================
--- /trunk/SophyaLib/TArray/tmatrix.h	(revision 1080)
+++ /trunk/SophyaLib/TArray/tmatrix.h	(revision 1081)
@@ -20,4 +20,5 @@
   TMatrix(const TArray<T>& a); 
   TMatrix(const TArray<T>& a,  bool share, short mm=BaseArray::AutoMemoryMapping);
+  TMatrix(const BaseArray& a); 
 
   virtual ~TMatrix();
@@ -30,4 +31,8 @@
   inline  TMatrix<T>& operator = (const TMatrix<T>& a)
                      { Set(a);  return(*this); }
+
+  virtual TArray<T>& SetBA(const BaseArray& a);
+  inline  TMatrix<T>& operator = (const BaseArray& a)
+                     { SetBA(a);  return(*this); }
 
   // Size - Changing the Size 
