code: public static QRDecomposition<DoubleMatrix> qr(DoubleMatrix A) {
      int minmn = min(A.rows, A.columns);
      DoubleMatrix result = A.dup();
      DoubleMatrix tau = new DoubleMatrix(minmn);
      SimpleBlas.geqrf(result, tau);
      DoubleMatrix R = new DoubleMatrix(A.rows, A.columns);
      for (int i = 0; i < A.rows; i++) {
        for (int j = i; j < A.columns; j++) {
          R.put(i, j, result.get(i, j));
        }
      }
      DoubleMatrix Q = DoubleMatrix.eye(A.rows);
      SimpleBlas.ormqr('L', 'N', result, tau, Q);
      return new QRDecomposition<DoubleMatrix>(Q, R);
    }
docs: QR decomposition.
  
  Decomposes (m,n) matrix A into a (m,m) matrix Q and an (m,n) matrix R such that
  Q is orthogonal, R is upper triangular and Q * R = A
  
  Note that if A has more rows than columns, then the lower rows of R will contain
  only zeros, such that the corresponding later columns of Q do not enter the computation
  at all. For some reason, LAPACK does not properly normalize those columns.
  
  @param A matrix
  @return QR decomposition