Author: celestin Date: Mon Sep 19 06:19:36 2011 New Revision: 1172473 URL: http://svn.apache.org/viewvc?rev=1172473&view=rev Log: Removed FieldDecompositionSolver.solve(T[]). This is in accordance with JIRA MATH-661. Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/FieldDecompositionSolver.java commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/FieldLUDecompositionImpl.java Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/FieldDecompositionSolver.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/FieldDecompositionSolver.java?rev=1172473&r1=1172472&r2=1172473&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/FieldDecompositionSolver.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/FieldDecompositionSolver.java Mon Sep 19 06:19:36 2011 @@ -47,7 +47,7 @@ public interface FieldDecompositionSolve * @throws SingularMatrixException * if the decomposed matrix is singular. */ - T[] solve(final T[] b); + //T[] solve(final T[] b); /** Solve the linear equation A × X = B for matrices A. *

The A matrix is implicit, it is provided by the underlying Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/FieldLUDecompositionImpl.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/FieldLUDecompositionImpl.java?rev=1172473&r1=1172472&r2=1172473&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/FieldLUDecompositionImpl.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/FieldLUDecompositionImpl.java Mon Sep 19 06:19:36 2011 @@ -253,45 +253,6 @@ public class FieldLUDecompositionImpl= 0; col--) { - bp[col] = bp[col].divide(lu[col][col]); - final T bpCol = bp[col]; - for (int i = 0; i < col; i++) { - bp[i] = bp[i].subtract(bpCol.multiply(lu[i][col])); - } - } - - return bp; - - } - - /** {@inheritDoc} */ public FieldVector solve(FieldVector b) { try { return solve((ArrayFieldVector) b); @@ -343,7 +304,42 @@ public class FieldLUDecompositionImpl solve(ArrayFieldVector b) { - return new ArrayFieldVector(field, solve(b.getDataRef()), false); + final int m = pivot.length; + if (b.data.length != m) { + throw new DimensionMismatchException(b.data.length, m); + } + if (singular) { + throw new SingularMatrixException(); + } + + @SuppressWarnings("unchecked") + // field is of type T + final T[] bp = (T[]) Array.newInstance(field.getZero().getClass(), + m); + + // Apply permutations to b + for (int row = 0; row < m; row++) { + bp[row] = b.data[pivot[row]]; + } + + // Solve LY = b + for (int col = 0; col < m; col++) { + final T bpCol = bp[col]; + for (int i = col + 1; i < m; i++) { + bp[i] = bp[i].subtract(bpCol.multiply(lu[i][col])); + } + } + + // Solve UX = Y + for (int col = m - 1; col >= 0; col--) { + bp[col] = bp[col].divide(lu[col][col]); + final T bpCol = bp[col]; + for (int i = 0; i < col; i++) { + bp[i] = bp[i].subtract(bpCol.multiply(lu[i][col])); + } + } + + return new ArrayFieldVector(bp, false); } /** {@inheritDoc} */