mirror of
https://github.com/apache/commons-math.git
synced 2025-02-13 13:35:56 +00:00
Changed o.a.c.m3.linear.ConjugateGradient according to MATH-771.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1306133 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
380892dbd0
commit
0bff3901f4
@ -139,10 +139,10 @@ public class ConjugateGradient
|
|||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public RealVector solveInPlace(final RealLinearOperator a,
|
public RealVector solveInPlace(final RealLinearOperator a,
|
||||||
final RealLinearOperator minv, final RealVector b, final RealVector x0)
|
final RealLinearOperator m, final RealVector b, final RealVector x0)
|
||||||
throws NullArgumentException, NonSquareOperatorException,
|
throws NullArgumentException, NonSquareOperatorException,
|
||||||
DimensionMismatchException, MaxCountExceededException {
|
DimensionMismatchException, MaxCountExceededException {
|
||||||
checkParameters(a, minv, b, x0);
|
checkParameters(a, m, b, x0);
|
||||||
final IterationManager manager = getIterationManager();
|
final IterationManager manager = getIterationManager();
|
||||||
// Initialization of default stopping criterion
|
// Initialization of default stopping criterion
|
||||||
manager.resetIterationCount();
|
manager.resetIterationCount();
|
||||||
@ -163,7 +163,7 @@ public class ConjugateGradient
|
|||||||
final RealVector rro = RealVector.unmodifiableRealVector(r);
|
final RealVector rro = RealVector.unmodifiableRealVector(r);
|
||||||
double rnorm = r.getNorm();
|
double rnorm = r.getNorm();
|
||||||
RealVector z;
|
RealVector z;
|
||||||
if (minv == null) {
|
if (m == null) {
|
||||||
z = r;
|
z = r;
|
||||||
} else {
|
} else {
|
||||||
z = null;
|
z = null;
|
||||||
@ -182,15 +182,15 @@ public class ConjugateGradient
|
|||||||
evt = new DefaultIterativeLinearSolverEvent(this,
|
evt = new DefaultIterativeLinearSolverEvent(this,
|
||||||
manager.getIterations(), xro, bro, rro, rnorm);
|
manager.getIterations(), xro, bro, rro, rnorm);
|
||||||
manager.fireIterationStartedEvent(evt);
|
manager.fireIterationStartedEvent(evt);
|
||||||
if (minv != null) {
|
if (m != null) {
|
||||||
z = minv.operate(r);
|
z = m.operate(r);
|
||||||
}
|
}
|
||||||
final double rhoNext = r.dotProduct(z);
|
final double rhoNext = r.dotProduct(z);
|
||||||
if (check && (rhoNext <= 0.)) {
|
if (check && (rhoNext <= 0.)) {
|
||||||
final NonPositiveDefiniteOperatorException e;
|
final NonPositiveDefiniteOperatorException e;
|
||||||
e = new NonPositiveDefiniteOperatorException();
|
e = new NonPositiveDefiniteOperatorException();
|
||||||
final ExceptionContext context = e.getContext();
|
final ExceptionContext context = e.getContext();
|
||||||
context.setValue(OPERATOR, minv);
|
context.setValue(OPERATOR, m);
|
||||||
context.setValue(VECTOR, r);
|
context.setValue(VECTOR, r);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user