/*
 * ICOM 4035 - Data Structures
 * Dr. Manuel Rodriguez-Martinez
 * Department of Electrical and Computer Engineering
 * University of Puerto Rico, Mayaguez
 * 
 * STUDENT NAME:
 * STUDENT NUMBER:
 * STUDENT CLASS ACCOUNT:
 *
 * This file name: Matrix.cpp
 *
 * This file contains the implementation of the  matrix class.
 *
 */

#include "Matrix.h"

namespace uprm_icom4035 {

  /////////////////// DO NOT MODIFY THESE TWO FUNCTIONS/////////////
  // Output operator (Friend function)
  ostream& operator<<(ostream &out, const Matrix& M) {
    int i = 0, j = 0, len1 = 0, len2 = 0;
    
    len1 = M.get_rows();
    len2 = M.get_cols();
    
    for (i = 0; i < len1; ++i){
      for (j = 0; j < len2; ++j){
	out << M.get_value(i,j);
	if (j != len2 - 1){
	  out << "   ";
	}
      }
      out << "\n";
    }
    return out;
  }
 
  // Input operator (Friend function)
  istream& operator>>(istream &in, Matrix& M){
    int i = 0, j = 0, rows = 0, cols = 0;
    int new_val;
    
    in >> rows;
    in >> cols;
    
    M = Matrix(rows, cols);
    
    for (i = 0; i < rows; ++i){
      for (j = 0; j < cols; ++j){
	in >> new_val;
	M.set_value(i,j,new_val);
      }
    }
    return in;
  }
  ///////////////////////////////////////////////////////////////

  // ADD YOUR CODE HERE

}
