// This may look like C code, but it is really -*- C++ -*-

/*
 *  Copyright (c) University of Aizu
 */

#include "Eigen.h"

int main(int argc, char *argv[])
{
  // Cut-off value
  const double epsilon = 0.0001;

  // Read Dimension
  int n;
  cin >> n;
  cout << "Dimensions: " << n << endl;

  // Ask for Real
  int real;
  cin >> real;
  cout << "Real: " << real << endl;

  // Ask for Randomize
  int randomize;
  cin >> randomize;
  cout << "Randomize: " << randomize << endl;
    
  // Read Matrix
  Cmatrix input(n,n);
  cin >> input;
  cout << "Matrix:" << endl << input << endl;

  // Set up eigen system
  Eigen system(n);

  // Set initial values
  if (!system.init(real)) {
    cerr << "Error while initializing";
    return 1;
  }

  // Solve it
  if (!system.solve(input, epsilon, 200, randomize)) {
    cerr << "Error while computing";
    return 1;
  }

  // print results
  cout << endl << "Results:" << endl << "========" << endl;
  system.print();

  // check results
  cout << endl << "Checking:" << endl;
  if (!system.check(input, epsilon, 1)) {
    cerr << "Check failed" << endl;
    return 1;
  }

  // Everything worked fine...
  return 0;
}

