Q: How do I enter numbers from a file into a matrix? For some reason, the values for every number in the matrix is zero after inputing the values from a file.  It worked when I initialized the matrix with all zeroes, but for whatever reason I can't get the numbers to import from the text file.  
struct Vector {
  float* els;  
  int len;
    };

struct Matrix {
  Vector* col;  // col is array of Vectors; each Vector is one column of matrix 
  int ncols;    // total number of columns in matrix
};

...
ifstream fin("mat.def");
fin >> m >> n;
fin >> M;

...
istream& operator>>(istream& input, Matrix& mm) {

int m,n;
  n=mm.ncols;

  mm.col = new Vector[n]; // use n instead m for consistency

  for (int i=0;i<n;i++) {
    mm.col[i].els = new float[m];
    for (int k=0;k<m;k++) {
      input >> mm.col[i].els[k];
    }
  }

  return input;
}


A: You haven't shown any code that sets the value of nm.ncols. My guess is that the value of nm.cols is not set correctly before being used.
I suggest changing the strategy a little bit. Instead of
fin >> m >> n;
fin >> M;

Use
fin >> M;

and make sure the number of columns and rows are read in the operator>> function.
std::istream& operator>>(std::istream& input, Matrix& mm)
{
   int rows;
   input >> mm.ncols;
   input >> rows;

   mm.col = new Vector[mm.ncols];

   for (int i=0;i<mm.ncols;i++)
   {
      mm.col[i].len = rows;
      mm.col[i].els = new float[rows];
      for (int k=0;k<rows;k++) {
         input >> mm.col[i].els[k];
      }
   }

   return input;
}

