code: public int rank() {
          if (rows == 0 || columns == 0) {
              return 0;
          }
  
          // TODO:
          // handle small (1x1, 1xn, nx1, 2x2, 2xn, nx2, 3x3, 3xn, nx3)
          // matrices without SVD
  
          MatrixDecompositor decompositor = withDecompositor(LinearAlgebra.SVD);
          Matrix[] usv = decompositor.decompose();
          // TODO: Where is my pattern matching?
          Matrix s = usv[1];
          double tolerance = Math.max(rows, columns) * s.get(0, 0) * Matrices.EPS;
  
          int result = 0;
          for (int i = 0; i < s.rows(); i++) {
              if (s.get(i, i) > tolerance) {
                  result++;
              }
          }
  
          return result;
      }
docs: Calculates the rank of this matrix.
  
  <p>
  See <a href="http://mathworld.wolfram.com/MatrixRank.html">
  http://mathworld.wolfram.com/MatrixRank.html</a> for more details.
  </p>
  
  @return the rank of this matrix