diff --git a/src/main/java/org/apache/commons/math/linear/IterativeLinearSolver.java b/src/main/java/org/apache/commons/math/linear/IterativeLinearSolver.java index 70e74ec8b..fb5d7f61f 100644 --- a/src/main/java/org/apache/commons/math/linear/IterativeLinearSolver.java +++ b/src/main/java/org/apache/commons/math/linear/IterativeLinearSolver.java @@ -88,10 +88,10 @@ public abstract class IterativeLinearSolver { } if (inPlace) { MathUtils.checkNotNull(x0); - if (x0.getDimension() != a.getColumnDimension()) { - throw new DimensionMismatchException(x0.getDimension(), - a.getColumnDimension()); - } + } + if ((x0 != null) && (x0.getDimension() != a.getColumnDimension())) { + throw new DimensionMismatchException(x0.getDimension(), + a.getColumnDimension()); } } diff --git a/src/main/java/org/apache/commons/math/linear/PreconditionedIterativeLinearSolver.java b/src/main/java/org/apache/commons/math/linear/PreconditionedIterativeLinearSolver.java index e2514c283..f75b268a1 100644 --- a/src/main/java/org/apache/commons/math/linear/PreconditionedIterativeLinearSolver.java +++ b/src/main/java/org/apache/commons/math/linear/PreconditionedIterativeLinearSolver.java @@ -126,10 +126,10 @@ public abstract class PreconditionedIterativeLinearSolver /** {@inheritDoc} */ @Override public RealVector solve(final RealLinearOperator a, final RealVector b, - final RealVector x, final boolean inPlace) + final RealVector x0, final boolean inPlace) throws NullArgumentException, NonSquareLinearOperatorException, DimensionMismatchException, MaxCountExceededException { - checkParameters(a, b, x, inPlace); - return solve(a, null, b, x, inPlace); + checkParameters(a, b, x0, inPlace); + return solve(a, null, b, x0, inPlace); } }