#include <iostream>
#include <fstream>
#include "matrix.h"
using namespace std;

int main() {

  fstream fin;

  do {
    if (fin.fail()) {
      cout << "Unable to open file." << endl;
      fin.clear();
    }
    string filename;
    cout << "Enter filename containing origin matrix: ";
    cin >> filename;
    fin.open(filename.c_str());
  } while (fin.fail());


  matrix A;
  fin >> A;

  cout << "Matrix A was read as:" << endl;
  cout << A << endl;

  int total = A.numRows() * A.numColumns();
  for (int r=1; r <= total; r++) {
    if (total % r == 0) {
      A.reshape(r, total/r);
      cout << "Reshaped as " << r << "x" << total/r << endl;
      cout << A << endl;
    }
  }
}
