Author: luc
Date: Sun Jan 4 11:02:14 2009
New Revision: 731335
URL: http://svn.apache.org/viewvc?rev=731335&view=rev
Log:
removed all external decomposition solvers
Removed:
commons/proper/math/trunk/src/java/org/apache/commons/math/linear/EigenSolver.java
commons/proper/math/trunk/src/java/org/apache/commons/math/linear/LUSolver.java
commons/proper/math/trunk/src/java/org/apache/commons/math/linear/QRSolver.java
commons/proper/math/trunk/src/java/org/apache/commons/math/linear/SingularValueSolver.java
Modified:
commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/AbstractEstimator.java
commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/GaussNewtonEstimator.java
commons/proper/math/trunk/src/java/org/apache/commons/math/linear/AbstractRealMatrix.java
commons/proper/math/trunk/src/java/org/apache/commons/math/stat/regression/GLSMultipleLinearRegression.java
commons/proper/math/trunk/src/test/org/apache/commons/math/linear/DenseRealMatrixTest.java
commons/proper/math/trunk/src/test/org/apache/commons/math/linear/EigenSolverTest.java
commons/proper/math/trunk/src/test/org/apache/commons/math/linear/LUSolverTest.java
commons/proper/math/trunk/src/test/org/apache/commons/math/linear/RealMatrixImplTest.java
commons/proper/math/trunk/src/test/org/apache/commons/math/linear/SingularValueSolverTest.java
commons/proper/math/trunk/src/test/org/apache/commons/math/linear/SparseRealMatrixTest.java
Modified:
commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/AbstractEstimator.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/AbstractEstimator.java?rev=731335&r1=731334&r2=731335&view=diff
==============================================================================
---
commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/AbstractEstimator.java
(original)
+++
commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/AbstractEstimator.java
Sun Jan 4 11:02:14 2009
@@ -21,7 +21,6 @@
import org.apache.commons.math.linear.InvalidMatrixException;
import org.apache.commons.math.linear.LUDecompositionImpl;
-import org.apache.commons.math.linear.LUSolver;
import org.apache.commons.math.linear.MatrixUtils;
import org.apache.commons.math.linear.RealMatrix;
@@ -183,7 +182,7 @@
try {
// compute the covariances matrix
RealMatrix inverse =
- new LUSolver(new
LUDecompositionImpl(MatrixUtils.createRealMatrix(jTj))).getInverse();
+ new
LUDecompositionImpl(MatrixUtils.createRealMatrix(jTj)).getSolver().getInverse();
return inverse.getData();
} catch (InvalidMatrixException ime) {
throw new EstimationException("unable to compute covariances:
singular problem",
Modified:
commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/GaussNewtonEstimator.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/GaussNewtonEstimator.java?rev=731335&r1=731334&r2=731335&view=diff
==============================================================================
---
commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/GaussNewtonEstimator.java
(original)
+++
commons/proper/math/trunk/src/java/org/apache/commons/math/estimation/GaussNewtonEstimator.java
Sun Jan 4 11:02:14 2009
@@ -21,7 +21,6 @@
import org.apache.commons.math.linear.InvalidMatrixException;
import org.apache.commons.math.linear.LUDecompositionImpl;
-import org.apache.commons.math.linear.LUSolver;
import org.apache.commons.math.linear.MatrixUtils;
import org.apache.commons.math.linear.RealMatrix;
import org.apache.commons.math.linear.RealVector;
@@ -152,7 +151,7 @@
try {
// solve the linearized least squares problem
- RealVector dX = new LUSolver(new
LUDecompositionImpl(a)).solve(b);
+ RealVector dX = new
LUDecompositionImpl(a).getSolver().solve(b);
// update the estimated parameters
for (int i = 0; i < parameters.length; ++i) {
Modified:
commons/proper/math/trunk/src/java/org/apache/commons/math/linear/AbstractRealMatrix.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/linear/AbstractRealMatrix.java?rev=731335&r1=731334&r2=731335&view=diff
==============================================================================
---
commons/proper/math/trunk/src/java/org/apache/commons/math/linear/AbstractRealMatrix.java
(original)
+++
commons/proper/math/trunk/src/java/org/apache/commons/math/linear/AbstractRealMatrix.java
Sun Jan 4 11:02:14 2009
@@ -38,7 +38,7 @@
/** Cached LU solver.
* @deprecated as of release 2.0, since all methods using this are
deprecated
*/
- private LUSolver lu;
+ private DecompositionSolver lu;
/**
* Creates a matrix with no data
@@ -657,7 +657,7 @@
public RealMatrix inverse()
throws InvalidMatrixException {
if (lu == null) {
- lu = new LUSolver(new LUDecompositionImpl(this,
MathUtils.SAFE_MIN));
+ lu = new LUDecompositionImpl(this, MathUtils.SAFE_MIN).getSolver();
}
return lu.getInverse();
}
@@ -666,10 +666,7 @@
@Deprecated
public double getDeterminant()
throws InvalidMatrixException {
- if (lu == null) {
- lu = new LUSolver(new LUDecompositionImpl(this,
MathUtils.SAFE_MIN));
- }
- return lu.getDeterminant();
+ return new LUDecompositionImpl(this,
MathUtils.SAFE_MIN).getDeterminant();
}
/** {...@inheritdoc} */
@@ -681,7 +678,7 @@
@Deprecated
public boolean isSingular() {
if (lu == null) {
- lu = new LUSolver(new LUDecompositionImpl(this,
MathUtils.SAFE_MIN));
+ lu = new LUDecompositionImpl(this, MathUtils.SAFE_MIN).getSolver();
}
return !lu.isNonSingular();
}
@@ -985,7 +982,7 @@
public double[] solve(final double[] b)
throws IllegalArgumentException, InvalidMatrixException {
if (lu == null) {
- lu = new LUSolver(new LUDecompositionImpl(this,
MathUtils.SAFE_MIN));
+ lu = new LUDecompositionImpl(this, MathUtils.SAFE_MIN).getSolver();
}
return lu.solve(b);
}
@@ -995,7 +992,7 @@
public RealMatrix solve(final RealMatrix b)
throws IllegalArgumentException, InvalidMatrixException {
if (lu == null) {
- lu = new LUSolver(new LUDecompositionImpl(this,
MathUtils.SAFE_MIN));
+ lu = new LUDecompositionImpl(this, MathUtils.SAFE_MIN).getSolver();
}
return lu.solve(b);
}
@@ -1023,7 +1020,7 @@
public void luDecompose()
throws InvalidMatrixException {
if (lu == null) {
- lu = new LUSolver(new LUDecompositionImpl(this,
MathUtils.SAFE_MIN));
+ lu = new LUDecompositionImpl(this, MathUtils.SAFE_MIN).getSolver();
}
}
Modified:
commons/proper/math/trunk/src/java/org/apache/commons/math/stat/regression/GLSMultipleLinearRegression.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/regression/GLSMultipleLinearRegression.java?rev=731335&r1=731334&r2=731335&view=diff
==============================================================================
---
commons/proper/math/trunk/src/java/org/apache/commons/math/stat/regression/GLSMultipleLinearRegression.java
(original)
+++
commons/proper/math/trunk/src/java/org/apache/commons/math/stat/regression/GLSMultipleLinearRegression.java
Sun Jan 4 11:02:14 2009
@@ -17,7 +17,6 @@
package org.apache.commons.math.stat.regression;
import org.apache.commons.math.linear.LUDecompositionImpl;
-import org.apache.commons.math.linear.LUSolver;
import org.apache.commons.math.linear.RealMatrix;
import org.apache.commons.math.linear.RealMatrixImpl;
@@ -109,7 +108,7 @@
protected RealMatrix calculateBetaVariance() {
RealMatrix OI = getOmegaInverse();
RealMatrix XTOIX = X.transpose().multiply(OI).multiply(X);
- return new LUSolver(new LUDecompositionImpl(XTOIX)).getInverse();
+ return new LUDecompositionImpl(XTOIX).getSolver().getInverse();
}
/**
Modified:
commons/proper/math/trunk/src/test/org/apache/commons/math/linear/DenseRealMatrixTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/linear/DenseRealMatrixTest.java?rev=731335&r1=731334&r2=731335&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/org/apache/commons/math/linear/DenseRealMatrixTest.java
(original)
+++
commons/proper/math/trunk/src/test/org/apache/commons/math/linear/DenseRealMatrixTest.java
Sun Jan 4 11:02:14 2009
@@ -460,7 +460,7 @@
assertEquals(2, p.getRowDimension());
assertEquals(2, p.getColumnDimension());
// Invert p
- RealMatrix pInverse = new LUSolver(new
LUDecompositionImpl(p)).getInverse();
+ RealMatrix pInverse = new
LUDecompositionImpl(p).getSolver().getInverse();
assertEquals(2, pInverse.getRowDimension());
assertEquals(2, pInverse.getColumnDimension());
@@ -468,7 +468,7 @@
double[][] coefficientsData = {{2, 3, -2}, {-1, 7, 6}, {4, -3, -5}};
RealMatrix coefficients = new DenseRealMatrix(coefficientsData);
double[] constants = {1, -2, 1};
- double[] solution = new LUSolver(new
LUDecompositionImpl(coefficients)).solve(constants);
+ double[] solution = new
LUDecompositionImpl(coefficients).getSolver().solve(constants);
assertEquals(2 * solution[0] + 3 * solution[1] -2 * solution[2],
constants[0], 1E-12);
assertEquals(-1 * solution[0] + 7 * solution[1] + 6 * solution[2],
constants[1], 1E-12);
assertEquals(4 * solution[0] - 3 * solution[1] -5 * solution[2],
constants[2], 1E-12);
Modified:
commons/proper/math/trunk/src/test/org/apache/commons/math/linear/EigenSolverTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/linear/EigenSolverTest.java?rev=731335&r1=731334&r2=731335&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/org/apache/commons/math/linear/EigenSolverTest.java
(original)
+++
commons/proper/math/trunk/src/test/org/apache/commons/math/linear/EigenSolverTest.java
Sun Jan 4 11:02:14 2009
@@ -45,7 +45,7 @@
Random r = new Random(9994100315209l);
RealMatrix m =
EigenDecompositionImplTest.createTestMatrix(r, new double[] { 1.0,
0.0, -1.0, -2.0, -3.0 });
- EigenSolver es = new EigenSolver(new EigenDecompositionImpl(m,
MathUtils.SAFE_MIN));
+ DecompositionSolver es = new EigenDecompositionImpl(m,
MathUtils.SAFE_MIN).getSolver();
assertFalse(es.isNonSingular());
try {
es.getInverse();
@@ -62,7 +62,7 @@
Random r = new Random(9994100315209l);
RealMatrix m =
EigenDecompositionImplTest.createTestMatrix(r, new double[] { 1.0,
0.5, -1.0, -2.0, -3.0 });
- EigenSolver es = new EigenSolver(new EigenDecompositionImpl(m,
MathUtils.SAFE_MIN));
+ DecompositionSolver es = new EigenDecompositionImpl(m,
MathUtils.SAFE_MIN).getSolver();
assertTrue(es.isNonSingular());
RealMatrix inverse = es.getInverse();
RealMatrix error =
@@ -72,7 +72,7 @@
/** test solve dimension errors */
public void testSolveDimensionErrors() {
- EigenSolver es = new EigenSolver(new EigenDecompositionImpl(matrix,
MathUtils.SAFE_MIN));
+ DecompositionSolver es = new EigenDecompositionImpl(matrix,
MathUtils.SAFE_MIN).getSolver();
RealMatrix b = MatrixUtils.createRealMatrix(new double[2][2]);
try {
es.solve(b);
@@ -110,8 +110,7 @@
{ 40, 2, 21, 9, 51, 19 },
{ 14, -1, 8, 0, 19, 14 }
});
- EigenSolver es = new EigenSolver(new EigenDecompositionImpl(m,
MathUtils.SAFE_MIN));
- assertEquals(184041, es.getDeterminant(), 2.0e-8);
+ DecompositionSolver es = new EigenDecompositionImpl(m,
MathUtils.SAFE_MIN).getSolver();
RealMatrix b = MatrixUtils.createRealMatrix(new double[][] {
{ 1561, 269, 188 },
{ 69, -21, 70 },
Modified:
commons/proper/math/trunk/src/test/org/apache/commons/math/linear/LUSolverTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/linear/LUSolverTest.java?rev=731335&r1=731334&r2=731335&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/org/apache/commons/math/linear/LUSolverTest.java
(original)
+++
commons/proper/math/trunk/src/test/org/apache/commons/math/linear/LUSolverTest.java
Sun Jan 4 11:02:14 2009
@@ -62,25 +62,25 @@
{ 2.0, 5.0, 3.0},
{ 4.000001, 9.0, 9.0}
});
- assertFalse(new LUSolver(new LUDecompositionImpl(matrix,
1.0e-5)).isNonSingular());
- assertTrue(new LUSolver(new LUDecompositionImpl(matrix,
1.0e-10)).isNonSingular());
+ assertFalse(new LUDecompositionImpl(matrix,
1.0e-5).getSolver().isNonSingular());
+ assertTrue(new LUDecompositionImpl(matrix,
1.0e-10).getSolver().isNonSingular());
}
/** test singular */
public void testSingular() {
- LUSolver lu =
- new LUSolver(new
LUDecompositionImpl(MatrixUtils.createRealMatrix(testData)));
- assertTrue(lu.isNonSingular());
- lu = new LUSolver(new
LUDecompositionImpl(MatrixUtils.createRealMatrix(singular)));
- assertFalse(lu.isNonSingular());
- lu = new LUSolver(new
LUDecompositionImpl(MatrixUtils.createRealMatrix(bigSingular)));
- assertFalse(lu.isNonSingular());
+ DecompositionSolver solver =
+ new
LUDecompositionImpl(MatrixUtils.createRealMatrix(testData)).getSolver();
+ assertTrue(solver.isNonSingular());
+ solver = new
LUDecompositionImpl(MatrixUtils.createRealMatrix(singular)).getSolver();
+ assertFalse(solver.isNonSingular());
+ solver = new
LUDecompositionImpl(MatrixUtils.createRealMatrix(bigSingular)).getSolver();
+ assertFalse(solver.isNonSingular());
}
/** test solve dimension errors */
public void testSolveDimensionErrors() {
- LUSolver solver =
- new LUSolver(new
LUDecompositionImpl(MatrixUtils.createRealMatrix(testData)));
+ DecompositionSolver solver =
+ new
LUDecompositionImpl(MatrixUtils.createRealMatrix(testData)).getSolver();
RealMatrix b = MatrixUtils.createRealMatrix(new double[2][2]);
try {
solver.solve(b);
@@ -110,8 +110,8 @@
/** test solve singularity errors */
public void testSolveSingularityErrors() {
- LUSolver solver =
- new LUSolver(new
LUDecompositionImpl(MatrixUtils.createRealMatrix(singular)));
+ DecompositionSolver solver =
+ new
LUDecompositionImpl(MatrixUtils.createRealMatrix(singular)).getSolver();
RealMatrix b = MatrixUtils.createRealMatrix(new double[2][2]);
try {
solver.solve(b);
@@ -149,8 +149,8 @@
/** test solve */
public void testSolve() {
- LUSolver solver =
- new LUSolver(new
LUDecompositionImpl(MatrixUtils.createRealMatrix(testData)));
+ DecompositionSolver solver =
+ new
LUDecompositionImpl(MatrixUtils.createRealMatrix(testData)).getSolver();
RealMatrix b = MatrixUtils.createRealMatrix(new double[][] {
{ 1, 0 }, { 2, -5 }, { 3, 1 }
});
@@ -195,7 +195,7 @@
}
private double getDeterminant(RealMatrix m) {
- return new LUSolver(new LUDecompositionImpl(m)).getDeterminant();
+ return new LUDecompositionImpl(m).getDeterminant();
}
}
Modified:
commons/proper/math/trunk/src/test/org/apache/commons/math/linear/RealMatrixImplTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/linear/RealMatrixImplTest.java?rev=731335&r1=731334&r2=731335&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/org/apache/commons/math/linear/RealMatrixImplTest.java
(original)
+++
commons/proper/math/trunk/src/test/org/apache/commons/math/linear/RealMatrixImplTest.java
Sun Jan 4 11:02:14 2009
@@ -269,8 +269,8 @@
/** test transpose */
public void testTranspose() {
RealMatrix m = new RealMatrixImpl(testData);
- RealMatrix mIT = new LUSolver(new
LUDecompositionImpl(m)).getInverse().transpose();
- RealMatrix mTI = new LUSolver(new
LUDecompositionImpl(m.transpose())).getInverse();
+ RealMatrix mIT = new
LUDecompositionImpl(m).getSolver().getInverse().transpose();
+ RealMatrix mTI = new
LUDecompositionImpl(m.transpose()).getSolver().getInverse();
assertClose("inverse-transpose", mIT, mTI, normTolerance);
m = new RealMatrixImpl(testData2);
RealMatrix mt = new RealMatrixImpl(testData2T);
@@ -360,7 +360,7 @@
assertEquals(2, p.getRowDimension());
assertEquals(2, p.getColumnDimension());
// Invert p
- RealMatrix pInverse = new LUSolver(new
LUDecompositionImpl(p)).getInverse();
+ RealMatrix pInverse = new
LUDecompositionImpl(p).getSolver().getInverse();
assertEquals(2, pInverse.getRowDimension());
assertEquals(2, pInverse.getColumnDimension());
@@ -368,7 +368,7 @@
double[][] coefficientsData = {{2, 3, -2}, {-1, 7, 6}, {4, -3, -5}};
RealMatrix coefficients = new RealMatrixImpl(coefficientsData);
double[] constants = {1, -2, 1};
- double[] solution = new LUSolver(new
LUDecompositionImpl(coefficients)).solve(constants);
+ double[] solution = new
LUDecompositionImpl(coefficients).getSolver().solve(constants);
assertEquals(2 * solution[0] + 3 * solution[1] -2 * solution[2],
constants[0], 1E-12);
assertEquals(-1 * solution[0] + 7 * solution[1] + 6 * solution[2],
constants[1], 1E-12);
assertEquals(4 * solution[0] - 3 * solution[1] -5 * solution[2],
constants[2], 1E-12);
Modified:
commons/proper/math/trunk/src/test/org/apache/commons/math/linear/SingularValueSolverTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/linear/SingularValueSolverTest.java?rev=731335&r1=731334&r2=731335&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/org/apache/commons/math/linear/SingularValueSolverTest.java
(original)
+++
commons/proper/math/trunk/src/test/org/apache/commons/math/linear/SingularValueSolverTest.java
Sun Jan 4 11:02:14 2009
@@ -42,8 +42,8 @@
/** test solve dimension errors */
public void testSolveDimensionErrors() {
- SingularValueSolver solver =
- new SingularValueSolver(new
SingularValueDecompositionImpl(MatrixUtils.createRealMatrix(testSquare)));
+ DecompositionSolver solver =
+ new
SingularValueDecompositionImpl(MatrixUtils.createRealMatrix(testSquare)).getSolver();
RealMatrix b = MatrixUtils.createRealMatrix(new double[3][2]);
try {
solver.solve(b);
@@ -78,7 +78,7 @@
{ 1.0, 0.0 },
{ 0.0, 0.0 }
});
- SingularValueSolver solver = new SingularValueSolver(new
SingularValueDecompositionImpl(m));
+ DecompositionSolver solver = new
SingularValueDecompositionImpl(m).getSolver();
RealMatrix b = MatrixUtils.createRealMatrix(new double[2][2]);
try {
solver.solve(b);
@@ -116,8 +116,8 @@
/** test solve */
public void testSolve() {
- SingularValueSolver solver =
- new SingularValueSolver(new
SingularValueDecompositionImpl(MatrixUtils.createRealMatrix(testSquare)));
+ DecompositionSolver solver =
+ new
SingularValueDecompositionImpl(MatrixUtils.createRealMatrix(testSquare)).getSolver();
RealMatrix b = MatrixUtils.createRealMatrix(new double[][] {
{ 1, 2, 3 }, { 0, -5, 1 }
});
Modified:
commons/proper/math/trunk/src/test/org/apache/commons/math/linear/SparseRealMatrixTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/linear/SparseRealMatrixTest.java?rev=731335&r1=731334&r2=731335&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/org/apache/commons/math/linear/SparseRealMatrixTest.java
(original)
+++
commons/proper/math/trunk/src/test/org/apache/commons/math/linear/SparseRealMatrixTest.java
Sun Jan 4 11:02:14 2009
@@ -277,8 +277,8 @@
public void testTranspose() {
RealMatrix m = createSparseMatrix(testData);
- RealMatrix mIT = new LUSolver(new
LUDecompositionImpl(m)).getInverse().transpose();
- RealMatrix mTI = new LUSolver(new
LUDecompositionImpl(m.transpose())).getInverse();
+ RealMatrix mIT = new
LUDecompositionImpl(m).getSolver().getInverse().transpose();
+ RealMatrix mTI = new
LUDecompositionImpl(m.transpose()).getSolver().getInverse();
assertClose("inverse-transpose", mIT, mTI, normTolerance);
m = createSparseMatrix(testData2);
RealMatrix mt = createSparseMatrix(testData2T);
@@ -368,7 +368,7 @@
assertEquals(2, p.getRowDimension());
assertEquals(2, p.getColumnDimension());
// Invert p
- RealMatrix pInverse = new LUSolver(new
LUDecompositionImpl(p)).getInverse();
+ RealMatrix pInverse = new
LUDecompositionImpl(p).getSolver().getInverse();
assertEquals(2, pInverse.getRowDimension());
assertEquals(2, pInverse.getColumnDimension());
@@ -377,7 +377,7 @@
{ 4, -3, -5 } };
RealMatrix coefficients = createSparseMatrix(coefficientsData);
double[] constants = { 1, -2, 1 };
- double[] solution = new LUSolver(new
LUDecompositionImpl(coefficients)).solve(constants);
+ double[] solution = new
LUDecompositionImpl(coefficients).getSolver().solve(constants);
assertEquals(2 * solution[0] + 3 * solution[1] - 2 * solution[2],
constants[0], 1E-12);
assertEquals(-1 * solution[0] + 7 * solution[1] + 6 * solution[2],