private Matrix normal(Matrix mat) {
    Matrix globalMat = new Matrix(new double[mat.numRows()][mat.numColumns()]);
    for(int term = 0; term < mat.numColumns(); term++) {
      double norm = 0;
      for(int doc = 0; doc < mat.numRows(); doc++) {
        double tf = mat.m[doc][term];
        if (tf > 0) {
          norm += tf * tf;
        }
      }
      norm = Math.sqrt(norm);
      for(int doc = 0; doc < mat.numRows(); doc++) {
        if (mat.m[doc][term] > 0) {
          globalMat.m[doc][term] = norm;
        }
      }
    }
    return globalMat;
  }