Replaced deprecated method with alternative from "MathArrays".


git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1414441 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gilles Sadowski 2012-11-27 22:27:17 +00:00
parent bc69c0088d
commit d580fb2ca8
1 changed files with 8 additions and 3 deletions

View File

@ -17,6 +17,7 @@
package org.apache.commons.math3.linear;
import org.apache.commons.math3.analysis.function.Sqrt;
import org.apache.commons.math3.util.MathArrays;
/**
* This class implements the standard Jacobi (diagonal) preconditioner. For a
@ -95,7 +96,9 @@ public class JacobiPreconditioner extends RealLinearOperator {
@Override
public RealVector operate(final RealVector x) {
// Dimension check is carried out by ebeDivide
return x.ebeDivide(diag);
return new ArrayRealVector(MathArrays.ebeDivide(x.toArray(),
diag.toArray()),
false);
}
/**
@ -105,13 +108,15 @@ public class JacobiPreconditioner extends RealLinearOperator {
*
* @return the square root of {@code this} preconditioner
*/
public RealLinearOperator sqrt(){
public RealLinearOperator sqrt() {
final RealVector sqrtDiag = diag.map(new Sqrt());
return new RealLinearOperator() {
/** {@inheritDoc} */
@Override
public RealVector operate(final RealVector x) {
return x.ebeDivide(sqrtDiag);
return new ArrayRealVector(MathArrays.ebeDivide(x.toArray(),
sqrtDiag.toArray()),
false);
}
/** {@inheritDoc} */