Index: /trunk/SophyaProg/Tests/arrt.cc
===================================================================
--- /trunk/SophyaProg/Tests/arrt.cc	(revision 811)
+++ /trunk/SophyaProg/Tests/arrt.cc	(revision 812)
@@ -6,12 +6,13 @@
 #include "nbrandom.h"
 #include "tarrinit.h"
-#include "tarray.h"
-#include "fioarr.h"
-#include "matharr.h"
+#include "array.h"
+// #include "fioarr.h"
+// #include "matharr.h"
 #include "timing.h"
 
-
-void tstioarr(TArray<int_4> & ia, TArray<int_4> & ib, TArray<int_4> & ic);
-void tstmtx();
+static void tstarr(bool tio);
+static void tstioarr(TArray<int_4> & ia, TArray<int_4> & ib, TArray<int_4> & ic);
+static void tstmtx(int n);
+void _ZZ_TestTMatrixRC_YY_(TMatrix<r_8> & m);
 
 int main(int narg, char* arg[])
@@ -22,11 +23,134 @@
 
 
+  if (narg < 2) {
+    cout << " arrt - TArray<T> Test - Usage arrt a/p/m/z [size=5] [prtlev=1] [nprt=50]\n" 
+	 << " a: Simple Array Test  w: a+ PPersist Test (FIO_TArray<T>) \n" 
+	 << " m: Matrix and Vector Test \n" 
+	 << " z: Appel_ZZ_TestTMatrixRC_YY_ " << endl;
+    exit(0);
+  }
+
+  int opt = *(arg[1]);
   int n = 5;
-  int i,j,k;
-
-  bool tio = false;
-  if (narg > 1) tio = true;
+  if (narg > 2) n = atoi(arg[2]);
+  uint_4 prtlev = 1;
+  uint_4 nprt = 50;
+  if (narg > 3) prtlev = atoi(arg[3]);
+  if (narg > 4) nprt = atoi(arg[4]);
+
+  BaseArray::SetMaxPrint(nprt, prtlev);
 
   try {
+    if ((opt == 'w') || (opt == 'a')) tstarr((opt=='w'));
+    else if (opt == 'z') {
+      if (n<5) n = 5;
+      TMatrix<r_8> tza(n,n+3);
+      tza = Sequence(2.,1.5);
+      _ZZ_TestTMatrixRC_YY_(tza);
+      TMatrix<r_8> tza2 = tza(Range(1,3), Range(2,5));
+      _ZZ_TestTMatrixRC_YY_(tza2);
+    }
+    else tstmtx(n);
+  }
+  catch (PThrowable exc) {
+    cerr << " catched Exception " << exc.Msg() << endl;
+  }  
+  catch (...) {
+    cerr << " catched unknown (...) exception " << endl; 
+  }  
+  PrtTim("--- End of arrt ---");
+  cout << " ---------------  END of ArrayTest programme -------------- " << endl;
+}
+
+
+void tstmtx(int n)
+{
+  TMatrix<r_4> ma(4,7);
+  ma = Sequence(10., 2.);
+  cout << "\n ::::::  Testing TMatrix - TVector ::::::  " << endl;  
+  TMatrix<r_4> sma1 = ma(Range(1,2), Range(2,4));
+  cout << " ----- Matrix ma = \n " << ma << endl;
+  sma1 = 3.14;
+  cout << " ----- Matrix ma (Avec sma1=ma(Range(1,2), Range(2,3))=3.14) = \n " << ma << endl;
+  TMatrix<r_4> mb(2,3);
+  mb = 50.;
+  TMatrix<r_4> mc = mb+sma1;
+  cout << " ----- Matrix mc = mb(=50.)+sma1(=3.14) = " << mc << endl;
+  TMatrix<r_4> md = (float)100+mc;
+  cout << " ----- Matrix md=100.+mc = " << md << endl;
+  cout << " ----- Matrix md-50 = " << md-(float)50. << endl;
+
+  TMatrix<int_4> ima(3,10);
+  ima = Sequence(0.01,1.);
+  cout << " ----- Matrix ima(3,10) = Sequence(0.01,1.) = " << ima << endl;
+  cout << " ----- Matrix  ima.Column(3) = \n" << ima.Column(3) << endl;
+  TVector<int_4> vcol = ima.Column(7);
+  cout << " ----- Vector  vcol=ima.Column(7) = \n" << vcol << endl;
+  cout << " ----- Matrix  ima.Row(0) = \n" << ima.Row(0) << endl;
+  TVector<int_4> vlig = ima.Row(1);
+  cout << " ----- Vector  vlig=ima.Row(1) = \n" << vlig << endl;
+
+  TMatrix<int_4> imb(3,10);
+  imb = Sequence(100.01,10.);
+  cout << " ----- Matrix imb(3,10) = Sequence(100.01,10.) = " << imb << endl;
+  TMatrix<int_4> imc = ima+imb;
+  cout << " ----- Matrix imc=ima+imb = " << imc << endl;
+  TMatrix<int_4> imd(3,10);
+  TMatrix<int_4> imd2(3,10);
+  imd += 25;
+  imd *= 2;
+  imd2 = 2;
+  imd.MulElt(imd2);
+  cout << " ----- Matrix imd (? = 100) " << imd << endl;
+  imb -= imd;
+  imc -= imd;
+  cout << " ----- Matrix ((imc-=imd)-(imb-=imd))-ima (== 0 ?) " 
+       << (imc-imb)-ima << endl;
+  TVector<r_4> va(16, BaseArray::RowVector);
+  va = Sequence(0.,1.);
+  cout << " ----- Vector va = Sequence(0.,1.) = " << va << endl;
+  va(Range(2,0,6,2)) *= 10.;
+  cout << " ----- Vector va apres va(Range(2,0,6,2)) *= 10. " << va << endl;
+  va(Range(0,5)) += 100.;
+  cout << " ----- Vector va apres va(Range(0,6)) += 100. " << va << endl;
+
+  cout << "\n :::::: Testing Matrix operations :::::: " << endl;
+  TMatrix<r_4> ra(2,2), ira(2,2);
+  ra(0,0) = 2.;   ra(0,1) = 1.;
+  ra(1,0) = 4.;   ra(1,1) = 3.;
+  ira(0,0) = 1.5;   ira(0,1) = -0.5;
+  ira(1,0) = -2.;    ira(1,1) = 1.;
+  cout << " ----- Matrix ra = \n " << ra << endl; 
+  cout << " ----- Matrix ira = \n " << ira << endl; 
+  cout << " ----- Matrix ira*ra = (= Identity ?) " << ira*ra << endl; 
+
+
+  cout << "\n ::::::: Testing Matrix Inversion ::::::: " << endl;
+  SimpleMatrixOperation<r_4> smr;
+  TMatrix<r_4> cira = smr.Inverse(ra);
+  cout << " ----- Matrix Inverse(ra) =  " << cira << endl;
+  cout << " ----- ira-Inverse(ra) = " << ira-cira << endl;
+
+  Matrix a(n,n);
+
+    
+  for(int i=0; i<n; i++)
+    for(int j=0; j<n; j++)  a(j,i) = GauRnd(0., 1.);
+  cout << " ----- Matrix a = \n " << a << endl;
+  Vector x(n);
+  x = Sequence(1.,3.);
+  Vector b = a*x;
+  cout << " ----- Vector x = \n " << x << endl;
+  cout << " ----- Vector b = a*x = \n " << b << endl;
+  SimpleMatrixOperation<r_8> smo;
+  Matrix inva = smo.Inverse(a);
+  cout << " ----- Matrix Inverse(a) = \n " << inva << endl;
+  cout << " ----- Matrix a*Inverse(a) = \n " << inva*a << endl;
+  cout << " ----- Matrix Inverse(a)*b (=Inv(a)*a*x) = \n " << inva*b << endl;
+  cout << " ----- Matrix x-Inverse(a)*b = (=0 ?)\n " << x-inva*b << endl;
+}
+
+void tstarr(bool tio)
+{
   cout << "\n -----> Testing TArray <---- " << endl;  
   // We create a integer array SizeX=7, SizeY=5
@@ -34,13 +158,13 @@
   // We fill it with a sequence of numbers starting at 10., with step = 2.
   ia = Sequence(10., 2.);
-  cout << " ----- matrix IA = \n " << ia << endl;
-  // sub array extraction, Range(2,3) : starting position=2 , size=3
-  TArray<int_4> ic = ia(Range(2,3),Range(1,2),Range(0));
-  cout << " ----- matrix IC IA(Range(2,3),Range(1,2)) = \n " << ic << endl;
+  cout << " ----- Array IA = \n " << ia << endl;
+  // sub array extraction, Range(2,4) : starting position=2 , End=4
+  TArray<int_4> ic = ia(Range(2,3),Range(1,3),Range(0));
+  cout << " ----- Array IC IA(Range(2,4),Range(1,2)) = \n " << ic << endl;
   // we set the sub-array to zero, this should reflect in the original array
   // sub-arrays share their data with parent array
   ic = 0;
-  cout << " ----- matrix IC Apres (=0) = \n " << ic << endl;
-  cout << " ----- matrix IA Apres IC=0 = \n " << ia << endl;
+  cout << " ----- Array IC Apres (=0) = \n " << ic << endl;
+  cout << " ----- Array IA Apres IC=0 = \n " << ia << endl;
 
   cout << "  :::: 3 Dim arrays ::::: " << endl;
@@ -49,10 +173,12 @@
   TArray<int_4> ib(8,7,2);
   ib = 5;
-  cout << " ----- matrix IB = \n " << ib << endl;
+  cout << " ----- Array IB = \n " << ib << endl;
   // Sub array extraction  X from 1 , size 4 - Y from 2 , size 3 , in Z default, from 0, size 1
   // we multiply this sub-array elements by 3
-  ib(Range(1,4),Range(2,3), Range(0)) *= 3;
-  cout << " -- matrix IB , Apres ib(Range(1,3),Range(2,1))*=3 : " << endl;
+  ib(Range(1,4),Range(2,4), Range(0)) *= 3;
+  cout << " -- Array IB , Apres ib(Range(1,4),Range(2,4))*=3 : " << endl;
   cout << ib;
+  cout << " -- Array ib(Range(1,4),Range(2,4)) =  : " 
+       << ib(Range(1,4),Range(2,4), Range(0)) << endl;
 
   // Creating a double array X=5 x Y=2
@@ -69,13 +195,4 @@
 
   if (tio) tstioarr(ia, ib, ic);
-
-  }
-  catch (PThrowable exc) {
-    cerr << " catched Exception " << exc.Msg() << endl;
-  }  
-  catch (...) {
-    cerr << " catched unknown (...) exception " << endl; 
-  }  
-  cout << " ---------------  END of Programme -------------- " << endl;
 }
 
@@ -104,10 +221,10 @@
   // We read the three arrays from the stream 
   pis >> iaa >> ibb >> icc;
-  cout << " ----- matrix IAA = \n " << iaa << endl;
-  cout << " ----- matrix IBB = \n " << ibb << endl;
-  cout << " ----- matrix ICC = \n " << icc << endl;
+  cout << " ----- Array IAA = \n " << iaa << endl;
+  cout << " ----- Array IBB = \n " << ibb << endl;
+  cout << " ----- Array ICC = \n " << icc << endl;
   icc = 12;
-  cout << " ----- matrix ICC (=12) = \n " << icc << endl;
-  cout << " ----- matrix IAA (ICC=12) = \n " << iaa << endl;
+  cout << " ----- Array ICC (=12) = \n " << icc << endl;
+  cout << " ----- Array IAA (ICC=12) = \n " << iaa << endl;
   }
 
@@ -124,12 +241,12 @@
   pis.GetObject(iaa, tag);
 
-  cout << " ----- matrix IAAA = \n " << iaa << endl;
-  cout << " ----- matrix IBBB = \n " << ibb << endl;
-  cout << " ----- matrix ICCC = \n " << icc << endl;
+  cout << " ----- Array IAAA = \n " << iaa << endl;
+  cout << " ----- Array IBBB = \n " << ibb << endl;
+  cout << " ----- Array ICCC = \n " << icc << endl;
   icc = 68;
-  cout << " ----- matrix ICCC (=12) = \n " << icc << endl;
-  cout << " ----- matrix IAAA (ICC=12) = \n " << iaa << endl;
-  }
-
-
-}
+  cout << " ----- Array ICCC (=12) = \n " << icc << endl;
+  cout << " ----- Array IAAA (ICC=12) = \n " << iaa << endl;
+  }
+
+
+}
Index: /trunk/SophyaProg/Tests/lpk.cc
===================================================================
--- /trunk/SophyaProg/Tests/lpk.cc	(revision 811)
+++ /trunk/SophyaProg/Tests/lpk.cc	(revision 812)
@@ -12,4 +12,7 @@
 
 
+void lpk_tarr(int n);
+void lpk_tmtx(int n);
+
 int main(int narg, char* arg[])
 {
@@ -19,10 +22,70 @@
 
 
+
+  if (narg < 2) {
+    cout << " lpk - LinAlg/LapackServer test - Usage lpk t/s [size=5] [prtlev=0] [nprtmax=100]\n" 
+	 << " t:  lpk_tarr() rztest_lapack with TArray<r_4> \n" 
+	 << " s:  lpk_tmtx() LapackServer with TMatrix<r_8> \n" << endl;
+    exit(0);
+  }
   int n = 5;
+  int opt = 's';
+  opt = *(arg[1]);
+  if (narg > 2) n = atoi(arg[2]);
+  int nprt = 100;
+  int prtlev = 1;
+  if (narg > 3) prtlev = atoi(arg[3]);
+  if (narg > 4) nprt = atoi(arg[4]);
+
+  BaseArray::SetMaxPrint(nprt, prtlev);
+  try {
+    if (opt == 's') lpk_tmtx(n);
+    else lpk_tarr(n);
+  }
+  catch (PThrowable exc) {
+    cerr << " catched Exception (lpk.cc) " << exc.Msg() << endl;
+  }  
+  catch (...) {
+    cerr << " catched unknown (...) exception (lpk.cc) " << endl; 
+  } 
+  
+  PrtTim(" End of lpk LinAlg/Lapack test ");
+  cout << " ---------------  END of Programme -------------- " << endl;
+}
+
+
+void lpk_tmtx(int n)
+{
   int i,j,k;
+  BaseArray::SetDefaultMemoryMapping(BaseArray::FortranMemoryMapping);
+  Matrix a(n,n);
+  for(i=0; i<n; i++)
+    for(j=0; j<n; j++)  a(j,i) = GauRnd(0., 1.);
+  cout << " ------------ Matrix A = \n " << a << "\n" << endl; 
+  
+  Vector x(n), b;
+  //  Matrix  x(n,1), b;
+  cout << " ------------ Vector X = \n " << x << "\n" << endl; 
+  for(i=0; i<n; i++) x(i) = GauRnd(2., 1.5);
+  b = a*x;
 
-  if (narg > 1) n = atoi(arg[1]);
-  cout << ":::::::: rztest_lapack - Size=" << n << "  ::::::::: " << endl;
-  try {
+  //  cout << ":::::::: rztest_lapack - Size=" << n << "  ::::::::: " << endl;
+  cout << " ------- lpk_tmtx() LapackServerTest Using TMatrix<r_8> -------- " << endl; 
+  cout << " ------------ Matrix A = \n " << a << "\n" << endl; 
+  cout << " ------------ Matrix X = \n " << x << "\n" << endl; 
+  cout << " ------------ Matrix B = \n " << b << "\n" << endl; 
+
+  cout << "\n   Calling LapackLinSolve(a,b) .... " << endl;
+  LapackLinSolve(a,b);
+
+  cout << " ------------ Result B(=X ?) = \n " << b << "\n" << endl; 
+  Vector diff = b-x;
+  cout << " ------------ Vector diff B-X = \n " << diff << "\n" << endl; 
+
+}
+
+void lpk_tarr(int n)
+{
+  int i,j,k;
   TArray<r_4> a(n,n);
   for(i=0; i<n; i++)
@@ -38,4 +101,6 @@
   }
 
+  //  cout << ":::::::: rztest_lapack - Size=" << n << "  ::::::::: " << endl;
+  cout << " ------- lpk_tarr() LapaackTest Using TArray<r_4> -------- " << endl; 
   cout << " ------------ Array A = \n " << a << "\n" << endl; 
   cout << " ------------ Array X = \n " << x << "\n" << endl; 
@@ -47,14 +112,3 @@
 
   cout << " ------------ Result B(=X ?) = \n " << b << "\n" << endl; 
-
-  PrtTim(" End of lpk (rztest_lapack) ");
-  }
-  catch (PThrowable exc) {
-    cerr << " catched Exception (rztest_lapack) " << exc.Msg() << endl;
-  }  
-  catch (...) {
-    cerr << " catched unknown (...) exception (rztest_lapack) " << endl; 
-  }  
-  
-  cout << " ---------------  END of Programme -------------- " << endl;
 }
