public static double[] solve(double[][] A, double[] b) {
    final int rows = A.length, cols = A[0].length;
    return rows == cols //
        ? (new LUDecomposition(A, rows, cols)).solve(b) //
        : (new QRDecomposition(A, rows, cols)).solve(b);
  }
public static double [ ] solve ( double [ ] [ ] A , double [ ] b ) { final int rows = A . length , cols = A [ 0 ] . length ; return rows == cols ? ( new LUDecomposition ( A , rows , cols ) ) . solve ( b ) : ( new QRDecomposition ( A , rows , cols ) ) . solve ( b ) ; }
Solve A*X = b

@param b right hand side
@return solution if A is square, least squares solution otherwise