On 07/09/2011 11:34, er...@apache.org wrote: > Author: erans > Date: Wed Sep 7 10:34:49 2011 > New Revision: 1166099 > > URL: http://svn.apache.org/viewvc?rev=1166099&view=rev > Log: > Added "final". > Moved declaration of "sum" where it is used.
You might want to re-consider that. I suspect sum was declared outside of the inner loops to save allocating memory for a new double on every iteration of the loop. It may be worth moving the declaration outside the outer loop too. Mark > Modified: > > commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/LUDecompositionImpl.java > > Modified: > commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/LUDecompositionImpl.java > URL: > http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/LUDecompositionImpl.java?rev=1166099&r1=1166098&r2=1166099&view=diff > ============================================================================== > --- > commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/LUDecompositionImpl.java > (original) > +++ > commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/LUDecompositionImpl.java > Wed Sep 7 10:34:49 2011 > @@ -36,9 +36,9 @@ public class LUDecompositionImpl impleme > /** Default bound to determine effective singularity in LU > decomposition. */ > private static final double DEFAULT_TOO_SMALL = 1e-11; > /** Entries of LU decomposition. */ > - private double lu[][]; > + private final double lu[][]; > /** Pivot permutation associated with LU decomposition */ > - private int[] pivot; > + private final int[] pivot; > /** Parity of the permutation associated with the LU decomposition */ > private boolean even; > /** Singularity indicator. */ > @@ -92,12 +92,10 @@ public class LUDecompositionImpl impleme > // Loop over columns > for (int col = 0; col < m; col++) { > > - double sum = 0; > - > // upper > for (int row = 0; row < col; row++) { > final double[] luRow = lu[row]; > - sum = luRow[col]; > + double sum = luRow[col]; > for (int i = 0; i < row; i++) { > sum -= luRow[i] * lu[i][col]; > } > @@ -109,7 +107,7 @@ public class LUDecompositionImpl impleme > double largest = Double.NEGATIVE_INFINITY; > for (int row = col; row < m; row++) { > final double[] luRow = lu[row]; > - sum = luRow[col]; > + double sum = luRow[col]; > for (int i = 0; i < col; i++) { > sum -= luRow[i] * lu[i][col]; > } > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org