Index: trunk/SophyaProg/Tests/lpk.cc
===================================================================
--- trunk/SophyaProg/Tests/lpk.cc	(revision 2615)
+++ trunk/SophyaProg/Tests/lpk.cc	(revision 2647)
@@ -12,10 +12,12 @@
 
 
-int lpk_rzt_arr(int n);
-int lpk_linsolve_mtx(int n);
-int lpk_svd_mtx(int l, int c, int wsf, bool covu=true);
-int lpk_leastsquare_mtx(int l, int c);
+int lpk_linsolve_mtx(int n);                             // ErrorCode = 8
+int lpk_svd_mtx(int l, int c, int wsf, bool covu=true);  // ErrorCode = 16
+int lpk_leastsquare_mtx(int l, int c);                   // ErrorCode = 32   
+int lpk_inverse_mtx(int l);                              // ErrorCode = 64
 
 static double TOLERANCE = 1.e-6;
+static int nprt = 100;
+static int prtlev = 1;
 
 int main(int narg, char* arg[])
@@ -29,11 +31,12 @@
   if (narg < 2) {
     cout << " lpk - LinAlg/LapackServer test \n" 
-	 << " Usage: lpk linsolve/svd/rzt [sizeL,C=5,5] [prtlev=0] \n" 
+	 << " Usage: lpk select [sizeL,C=5,5] [prtlev=1] \n" 
 	 << "             [nprtmax=100] [WorkSpaceSizeFactor=2] \n" 
+	 << "   select= linsolve svd svds lss inverse / all= \n"
 	 << "   linsolve:  lpk_linsolve_mtx() LapackServer::LinSolve with TMatrix<r_8> \n" 
 	 << "   svd:  lpk_svd_mtx() LapackServer::SVD(a,s,u,vt) with TMatrix<r_8> \n" 
 	 << "   svds:  lpk_svd_mtx() LapackServer::SVD(a,s); with TMatrix<r_8> \n"
 	 << "   lss:  lpk_leastsquare_mtx() LapackServer::LeastSquareSolve() r_8 \n"
-	 << "   rzt:  lpk_rzt_tarr() rztest_lapack with TArray<r_4> \n" << endl;
+	 << "   inverse:  LapackServer::ComputeInverse() r_8 \n" << endl;
     exit(0);
   }
@@ -43,18 +46,24 @@
   string opt = arg[1];
   if (narg > 2) sscanf(arg[2], "%d,%d", &l, &c); 
-  int nprt = 100;
-  int prtlev = 1;
   if (narg > 3) prtlev = atoi(arg[3]);
   if (narg > 4) nprt = atoi(arg[4]);
   if (narg > 5) wsf = atoi(arg[5]);
 
+  cout << " lpk - LinAlg/LapackServer_Test sizeL,C=" << l << "," << c 
+       << " opt= " << opt << endl;
   int rc = 0;
   BaseArray::SetMaxPrint(nprt, prtlev);
   try {
-    if (opt == "linsolve") rc = lpk_linsolve_mtx(l);
+    if (opt == "all") {
+      rc += lpk_linsolve_mtx(l);
+      rc += lpk_svd_mtx(l,c,wsf,true);
+      rc += lpk_leastsquare_mtx(l,c);
+      rc += lpk_inverse_mtx(l);
+    }
+    else if (opt == "linsolve") rc = lpk_linsolve_mtx(l);
     else if (opt == "svd") rc = lpk_svd_mtx(l,c,wsf,true);
     else if (opt == "svds") rc = lpk_svd_mtx(l,c,wsf,false);
     else if (opt == "lss") rc = lpk_leastsquare_mtx(l,c);
-    else if (opt == "rzt") rc = lpk_rzt_arr(l);
+    else if (opt == "inverse") rc = lpk_inverse_mtx(l);
     else { cout << " Unknown option " << opt << " ! " << endl; rc = 66; }
   }
@@ -87,13 +96,15 @@
   Vector x(n), b;
   //  Matrix  x(n,1), b;
-  cout << " ------------ Vector X = \n " << x << "\n" << endl; 
+  if (prtlev > 0) 
+    cout << " ------------ Vector X = \n " << x << "\n" << endl; 
   for(i=0; i<n; i++) x(i) = GauRnd(2., 1.5);
   b = a*x;
 
-  cout << " ---- lpk_tmtx() LapackServer::LinSolve Test 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; 
-
+  if (prtlev > 0) {
+    cout << " ---- lpk_tmtx() LapackServer::LinSolve Test 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;
   PrtTim(" Calling LapackLinSolve(a,b) ");
@@ -101,8 +112,10 @@
   PrtTim(" End LapackLinSolve(a,b) ");
 
-  cout << " ------------ Result B(=X ?) = \n " << b << "\n" << endl; 
+  if (prtlev > 0) 
+    cout << " ------------ Result B(=X ?) = \n " << b << "\n" << endl; 
   Vector diff = b-x;
   PrtTim(" End of Compute(diff)");
-  cout << " ------------ Vector diff B-X = \n " << diff << "\n" << endl; 
+  if (prtlev > 0) 
+    cout << " ------------ Vector diff B-X = \n " << diff << "\n" << endl; 
   double min,max;
   diff.MinMax(min, max);
@@ -112,5 +125,5 @@
     cout << " !!! Difference exceeding tolerance (=" << TOLERANCE << ") !!!" 
 	 << endl;
-    return(99);
+    return(8);
   } 
   return(0);
@@ -131,5 +144,6 @@
   Matrix u, vt;
   cout << " ---- lpk_svd_tmtx() LapackServer::SVD Test Using TMatrix<r_8> ---- " << endl; 
-  cout << " ------------ Matrix A = \n " << a << "\n" << endl; 
+  if (prtlev > 0) 
+    cout << " ------------ Matrix A = \n " << a << "\n" << endl; 
 
   cout << "\n   Calling LapackSVD(a,s,u,vt) .... " << endl;
@@ -141,8 +155,11 @@
   PrtTim(" End LapackSVD() ");
 
-  cout << " ------------ Result S  = \n " << s << "\n" << endl; 
+  if (prtlev > 0) 
+    cout << " ------------ Result S  = \n " << s << "\n" << endl; 
   if (!covu) return(0);
-  cout << " ------------ Result U  = \n " << u << "\n" << endl; 
-  cout << " ------------ Result VT = \n " << vt << "\n" << endl; 
+  if (prtlev > 0) {
+    cout << " ------------ Result U  = \n " << u << "\n" << endl; 
+    cout << " ------------ Result VT = \n " << vt << "\n" << endl; 
+  }
   Matrix sm(m,n);
   int minmn = (m<n) ? m : n ;
@@ -150,5 +167,6 @@
   Matrix diff = u*(sm*vt) - a;
   PrtTim(" End of Compute(diff)");
-  cout << " ------------ Matrix diff U*S*Vt - A = \n " << diff << "\n" << endl; 
+  if (prtlev > 0) 
+    cout << " ------------ Matrix diff U*S*Vt - A = \n " << diff << "\n" << endl; 
   double min,max;
   diff.MinMax(min, max);
@@ -158,5 +176,5 @@
     cout << " !!! Difference exceeding tolerance (=" << TOLERANCE << ") !!!" 
 	 << endl;
-    return(99);
+    return(16);
   } 
   return(0);
@@ -182,8 +200,9 @@
  
   cout << " ---- lpk_leastsquare_tmtx() LapackLeastSquareSolve<r_8> ---- " << endl; 
-  cout << " ------------ Matrix A = \n " << a << "\n" << endl; 
-  cout << " ------------ Vector B = \n " << bx << "\n" << endl; 
-  cout << " ------------ Vector X = \n " << x << "\n" << endl; 
-
+  if (prtlev > 0) {
+    cout << " ------------ Matrix A = \n " << a << "\n" << endl; 
+    cout << " ------------ Vector B = \n " << bx << "\n" << endl; 
+    cout << " ------------ Vector X = \n " << x << "\n" << endl; 
+  }
   cout << "\n   Calling  LapackLeastSquareSolve(a,bx) .... " << endl;
   PrtTim(" Calling LapackLeastSquareSolve() ");
@@ -191,9 +210,12 @@
   PrtTim(" End LapackLeastSquareSolve() ");
   bx.Share(bx(Range(0,0,n)));
-  cout << " ------------ Result X  = \n " << bx << "\n" << endl; 
-  cout << " ------------ X-X_Real  = \n " << bx-x << "\n" << endl; 
+  if (prtlev > 0) {
+    cout << " ------------ Result X  = \n " << bx << "\n" << endl; 
+    cout << " ------------ X-X_Real  = \n " << bx-x << "\n" << endl; 
+  }
   Vector diff = b-a*bx;
   PrtTim(" End of Compute(diff)");
-  cout << " ------------ Matrix diff b-a*x = \n " << diff << "\n" << endl; 
+  if (prtlev > 0) 
+    cout << " ------------ Matrix diff b-a*x = \n " << diff << "\n" << endl; 
   double mean,sigma;
   MeanSigma(diff, mean, sigma);
@@ -203,40 +225,48 @@
     cout << " !!! Difference exceeding tolerance (=" << TOLERANCE << ") !!!" 
 	 << endl;
-    return(99);
-  } 
-  return(0);
-
-}
-
-
-void rztest_lapack(TArray<r_4>& aa, TArray<r_4>& bb);
-
-int  lpk_rzt_arr(int n)
-{
-  int i,j;
-  TArray<r_4> a(n,n);
-  for(i=0; i<n; i++)
-    for(j=0; j<n; j++)  a(i,j,0) = GauRnd(0., 1.);
-  
-  TArray<r_4> x(n,1), b(n,1);
-  r_4 sum ;
-  for(i=0; i<n; i++) x(i,0,0) = GauRnd(2., 1.5);
-  for(i=0; i<n; i++) {
-    sum = 0.;
-    for(j=0; j<n; j++) sum +=  a(i,j,0)*x(j,0,0);
-    b(i,0,0) = sum;
-  }
-
-  //  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; 
-  cout << " ------------ Array B = \n " << b << "\n" << endl; 
-
-  cout << "\n     Calling rztest_lapack ... " << endl;
-
-  rztest_lapack(a, b);
-
-  cout << " ------------ Result B(=X ?) = \n " << b << "\n" << endl; 
-  return(0);
-}
+    return 32;
+  } 
+  return 0;
+
+}
+// -----------------------------------------------------------------------
+/* Nouvelle-Fonction */
+int lpk_inverse_mtx(int m)
+{
+  BaseArray::SetDefaultMemoryMapping(BaseArray::FortranMemoryMapping);
+  cout << " lpk_inverse_mtx() - Test of LapackComputeInverse<r_8> " << endl;
+  
+  Matrix a(m , m), aa, ainv, idmx(m,m), mxprod, diff;
+  a = RandomSequence(RandomSequence::Gaussian, 0., 4.);
+  aa = a;  // We make a copy of a, as it is modified by LapackServer
+  PrtTim(" End of a_inint");
+
+  cout << "\n   Calling  LapackInverse() .... " << endl;
+  ainv = LapackInverse(aa);
+  PrtTim(" End of LapackInverse(a)");
+  mxprod = a*ainv;
+  PrtTim(" End of mxprod = a*ainv");
+  idmx = IdentityMatrix();
+  PrtTim(" End of idmx = IdentityMatrix()");
+  diff = mxprod-idmx;
+  PrtTim(" End of Compute(diff)");
+
+  if (prtlev > 0) {
+    cout << " ------------ Matrix A = \n " << a << "\n" << endl; 
+    cout << " ------------ Matrix Inverse(A) = \n " << ainv << "\n" << endl; 
+    cout << " ------------ Matrix mxprod = A*Inverse(A) = \n " << mxprod << "\n" << endl; 
+  }
+  double min,max;
+  diff.MinMax(min, max);
+  PrtTim(" End of diffCheck");
+  cout << " Min/Max difference Matrix (?=0) , Min= " << min 
+       << " Max= " << max << endl;
+  if ((fabs(min) > TOLERANCE) || (fabs(max) > TOLERANCE)) {
+    cout << " !!! Difference exceeding tolerance (=" << TOLERANCE << ") !!!" 
+	 << endl;
+    return 64;
+  }
+  return 0;
+
+}
+
Index: trunk/SophyaProg/Tests/tmxv.cc
===================================================================
--- trunk/SophyaProg/Tests/tmxv.cc	(revision 2647)
+++ trunk/SophyaProg/Tests/tmxv.cc	(revision 2647)
@@ -0,0 +1,110 @@
+#include "sopnamsp.h"
+#include "machdefs.h"
+
+#include <math.h>
+#include <iostream>
+
+#include "srandgen.h"
+#include "tarrinit.h"
+#include "tvector.h"
+#include "sopemtx.h"
+#include "timing.h"
+
+/********************************************************
+  Programme test pour les fonctionalites de calcul
+  sur matrices et vecteurs dans SOPHYA/TArray
+              Reza - fev 2005 
+*********************************************************/ 
+
+int mxv_inverse(int l);                    // ErrorCode = 64
+
+static double TOLERANCE = 1.e-6;
+static int nprt = 100;
+static int prtlev = 1;
+
+int main(int narg, char* arg[])
+{
+
+  SophyaInit();
+  InitTim();   // Initializing the CPU timer
+
+
+
+  if (narg < 2) {
+    cout << " tmxv : Test SOPHYA Matrix/Vector operations\n" 
+	 << " Usage: tmxv select [sizeL,C=5,5] [prtlev=1] [nprtmax=100]\n" 
+	 << "   select= inverse / all= \n"
+	 << "   inverse:  ComputeInverse() r_8 \n" << endl;
+    exit(0);
+  }
+  int l,c;
+  l = c = 5;
+  int wsf = 2;
+  string opt = arg[1];
+  if (narg > 2) sscanf(arg[2], "%d,%d", &l, &c); 
+  if (narg > 3) prtlev = atoi(arg[3]);
+  if (narg > 4) nprt = atoi(arg[4]);
+
+  cout << " tmxv - TMatrix/TVector operations tests sizeL,C=" << l << "," << c 
+       << " opt= " << opt << endl;
+  int rc = 0;
+  BaseArray::SetMaxPrint(nprt, prtlev);
+  try {
+    if (opt == "inverse") rc = mxv_inverse(l);
+    else { cout << "tmxv/ Unknown option " << opt << " ! " << endl; rc = 66; }
+  }
+  catch (PThrowable exc) {
+    cerr << " tmxv catched Exception (lpk.cc) " << exc.Msg() << endl;
+    rc = 77;
+  }  
+  catch (...) {
+    cerr << " tmxv catched unknown (...) exception (lpk.cc) " << endl; 
+    rc = 78; 
+  } 
+  
+  PrtTim(" End of lpk LinAlg/Lapack test ");
+  cout << " ---------------  END of Programme -------- (Rc= " 
+       << rc << ") --- " << endl;
+  return(rc);
+}
+
+// -----------------------------------------------------------------------
+/* Nouvelle-Fonction */
+int mxv_inverse(int m)
+{
+  cout << " mxv_inverse() - Test SimpleMatrixOperation<r_8> " << endl;
+  
+  Matrix a(m , m), ainv, idmx(m,m), mxprod, diff;
+  a = RandomSequence(RandomSequence::Gaussian, 0., 4.);
+  PrtTim(" End of a_inint");
+
+  cout << "\n   Calling  SimpleMatrixOperation::Inverse .... " << endl;
+  SimpleMatrixOperation<r_8> smo;
+  ainv = smo.Inverse(a);
+  PrtTim(" End of smo.Inverse()");
+  mxprod = a*ainv;
+  PrtTim(" End of mxprod = a*ainv");
+  idmx = IdentityMatrix();
+  PrtTim(" End of idmx = IdentityMatrix()");
+  diff = mxprod-idmx;
+  PrtTim(" End of Compute(diff)");
+
+  if (prtlev > 0) {
+    cout << " ------------ Matrix A = \n " << a << "\n" << endl; 
+    cout << " ------------ Matrix Inverse(A) = \n " << ainv << "\n" << endl; 
+    cout << " ------------ Matrix mxprod = A*Inverse(A) = \n " << mxprod << "\n" << endl; 
+  }
+  double min,max;
+  diff.MinMax(min, max);
+  PrtTim(" End of diffCheck");
+  cout << " Min/Max difference Matrix (?=0) , Min= " << min 
+       << " Max= " << max << endl;
+  if ((fabs(min) > TOLERANCE) || (fabs(max) > TOLERANCE)) {
+    cout << " !!! Difference exceeding tolerance (=" << TOLERANCE << ") !!!" 
+	 << endl;
+    return 64;
+  }
+  return 0;
+
+}
+
