#include "libscl.h"

using namespace std;
using namespace scl;

int main(int argc, char* argv[])
{

  INTEGER i,j,rr,cc;
  REAL    eps;
  char    msg[256];

  if (argc == 2)
    eps = atof(argv[1]);
  else
    eps = 1.0e-13;

  ifstream imat("matrix.dat");
  if (!imat) {
    cerr << "Error, main, cannot open matrix.dat";
    exit(1);
  }

  imat >> rr;
  imat >> cc;

  cout << rr << cc << '\n';
 
  realmat matrix(rr, cc);

  for (i=1; i<=rr; i++)
  for (j=1; j<=cc; j++)
    imat >> matrix.check(i,j);

  cout << starbox("/matrix read in//_") << matrix;

  realmat matrix_inv = invpsd(matrix,eps);

  sprintf(msg, "/inverse of matrix read in/eps = %g //_", eps);
  cout << starbox(msg) << matrix_inv;

  cout << starbox("/matrix * invpsd(matrix)//_") << matrix * matrix_inv;

  matrix.resize(1,1,1.0);

  cout << matrix << inv(matrix) << inv(matrix)*matrix; 

  matrix.resize(6,6,0.0);

  for (i=1; i<=6; i++) 
    for (j=1; j<=i; j++)
      matrix(i,j)=1.0;

  cout << matrix << inv(matrix) << inv(matrix)*matrix;

  matrix = T(matrix);

  cout << matrix << inv(matrix) << inv(matrix)*matrix; 
  
  exit(0);


}









