commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r990658 [3/10] - in /commons/proper/math/trunk: ./ src/main/java/org/apache/commons/math/analysis/ src/main/java/org/apache/commons/math/analysis/integration/ src/main/java/org/apache/commons/math/analysis/interpolation/ src/main/java/org/a...
Date Sun, 29 Aug 2010 22:04:15 GMT
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/BlockFieldMatrix.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/BlockFieldMatrix.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/BlockFieldMatrix.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/BlockFieldMatrix.java Sun Aug 29 22:04:09 2010
@@ -23,6 +23,7 @@ import org.apache.commons.math.Field;
 import org.apache.commons.math.FieldElement;
 import org.apache.commons.math.MathRuntimeException;
 import org.apache.commons.math.exception.util.LocalizedFormats;
+import org.apache.commons.math.util.FastMath;
 
 /**
  * Cache-friendly implementation of FieldMatrix using a flat arrays to store
@@ -230,11 +231,11 @@ public class BlockFieldMatrix<T extends 
         int blockIndex = 0;
         for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
             final int pStart  = iBlock * BLOCK_SIZE;
-            final int pEnd    = Math.min(pStart + BLOCK_SIZE, rows);
+            final int pEnd    = FastMath.min(pStart + BLOCK_SIZE, rows);
             final int iHeight = pEnd - pStart;
             for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
                 final int qStart = jBlock * BLOCK_SIZE;
-                final int qEnd   = Math.min(qStart + BLOCK_SIZE, columns);
+                final int qEnd   = FastMath.min(qStart + BLOCK_SIZE, columns);
                 final int jWidth = qEnd - qStart;
 
                 // allocate new block
@@ -282,11 +283,11 @@ public class BlockFieldMatrix<T extends 
         int blockIndex = 0;
         for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
             final int pStart  = iBlock * BLOCK_SIZE;
-            final int pEnd    = Math.min(pStart + BLOCK_SIZE, rows);
+            final int pEnd    = FastMath.min(pStart + BLOCK_SIZE, rows);
             final int iHeight = pEnd - pStart;
             for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
                 final int qStart = jBlock * BLOCK_SIZE;
-                final int qEnd   = Math.min(qStart + BLOCK_SIZE, columns);
+                final int qEnd   = FastMath.min(qStart + BLOCK_SIZE, columns);
                 final int jWidth = qEnd - qStart;
                 blocks[blockIndex] = buildArray(field, iHeight * jWidth);
                 ++blockIndex;
@@ -342,9 +343,9 @@ public class BlockFieldMatrix<T extends 
                     final T[] outBlock = out.blocks[blockIndex];
                     final T[] tBlock   = blocks[blockIndex];
                     final int      pStart   = iBlock * BLOCK_SIZE;
-                    final int      pEnd     = Math.min(pStart + BLOCK_SIZE, rows);
+                    final int      pEnd     = FastMath.min(pStart + BLOCK_SIZE, rows);
                     final int      qStart   = jBlock * BLOCK_SIZE;
-                    final int      qEnd     = Math.min(qStart + BLOCK_SIZE, columns);
+                    final int      qEnd     = FastMath.min(qStart + BLOCK_SIZE, columns);
                     int k = 0;
                     for (int p = pStart; p < pEnd; ++p) {
                         for (int q = qStart; q < qEnd; ++q) {
@@ -415,9 +416,9 @@ public class BlockFieldMatrix<T extends 
                     final T[] outBlock = out.blocks[blockIndex];
                     final T[] tBlock   = blocks[blockIndex];
                     final int      pStart   = iBlock * BLOCK_SIZE;
-                    final int      pEnd     = Math.min(pStart + BLOCK_SIZE, rows);
+                    final int      pEnd     = FastMath.min(pStart + BLOCK_SIZE, rows);
                     final int      qStart   = jBlock * BLOCK_SIZE;
-                    final int      qEnd     = Math.min(qStart + BLOCK_SIZE, columns);
+                    final int      qEnd     = FastMath.min(qStart + BLOCK_SIZE, columns);
                     int k = 0;
                     for (int p = pStart; p < pEnd; ++p) {
                         for (int q = qStart; q < qEnd; ++q) {
@@ -525,12 +526,12 @@ public class BlockFieldMatrix<T extends 
             for (int iBlock = 0; iBlock < out.blockRows; ++iBlock) {
 
                 final int pStart = iBlock * BLOCK_SIZE;
-                final int pEnd   = Math.min(pStart + BLOCK_SIZE, rows);
+                final int pEnd   = FastMath.min(pStart + BLOCK_SIZE, rows);
 
                 for (int jBlock = 0; jBlock < out.blockColumns; ++jBlock) {
 
                     final int qStart = jBlock * BLOCK_SIZE;
-                    final int qEnd   = Math.min(qStart + BLOCK_SIZE, m.getColumnDimension());
+                    final int qEnd   = FastMath.min(qStart + BLOCK_SIZE, m.getColumnDimension());
 
                     // select current block
                     final T[] outBlock = out.blocks[blockIndex];
@@ -589,7 +590,7 @@ public class BlockFieldMatrix<T extends 
         for (int iBlock = 0; iBlock < out.blockRows; ++iBlock) {
 
             final int pStart = iBlock * BLOCK_SIZE;
-            final int pEnd   = Math.min(pStart + BLOCK_SIZE, rows);
+            final int pEnd   = FastMath.min(pStart + BLOCK_SIZE, rows);
 
             for (int jBlock = 0; jBlock < out.blockColumns; ++jBlock) {
                 final int jWidth = out.blockWidth(jBlock);
@@ -651,7 +652,7 @@ public class BlockFieldMatrix<T extends 
 
         for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
             final int pStart = iBlock * BLOCK_SIZE;
-            final int pEnd   = Math.min(pStart + BLOCK_SIZE, rows);
+            final int pEnd   = FastMath.min(pStart + BLOCK_SIZE, rows);
             int regularPos   = 0;
             int lastPos      = 0;
             for (int p = pStart; p < pEnd; ++p) {
@@ -833,14 +834,14 @@ public class BlockFieldMatrix<T extends 
         for (int iBlock = blockStartRow; iBlock < blockEndRow; ++iBlock) {
             final int iHeight  = blockHeight(iBlock);
             final int firstRow = iBlock * BLOCK_SIZE;
-            final int iStart   = Math.max(row,    firstRow);
-            final int iEnd     = Math.min(endRow + 1, firstRow + iHeight);
+            final int iStart   = FastMath.max(row,    firstRow);
+            final int iEnd     = FastMath.min(endRow + 1, firstRow + iHeight);
 
             for (int jBlock = blockStartColumn; jBlock < blockEndColumn; ++jBlock) {
                 final int jWidth      = blockWidth(jBlock);
                 final int firstColumn = jBlock * BLOCK_SIZE;
-                final int jStart      = Math.max(column,    firstColumn);
-                final int jEnd        = Math.min(endColumn + 1, firstColumn + jWidth);
+                final int jStart      = FastMath.max(column,    firstColumn);
+                final int jEnd        = FastMath.min(endColumn + 1, firstColumn + jWidth);
                 final int jLength     = jEnd - jStart;
 
                 // handle one block, row by row
@@ -1292,9 +1293,9 @@ public class BlockFieldMatrix<T extends 
                 final T[] outBlock = out.blocks[blockIndex];
                 final T[] tBlock   = blocks[jBlock * blockColumns + iBlock];
                 final int      pStart   = iBlock * BLOCK_SIZE;
-                final int      pEnd     = Math.min(pStart + BLOCK_SIZE, columns);
+                final int      pEnd     = FastMath.min(pStart + BLOCK_SIZE, columns);
                 final int      qStart   = jBlock * BLOCK_SIZE;
-                final int      qEnd     = Math.min(qStart + BLOCK_SIZE, rows);
+                final int      qEnd     = FastMath.min(qStart + BLOCK_SIZE, rows);
                 int k = 0;
                 for (int p = pStart; p < pEnd; ++p) {
                     final int lInc = pEnd - pStart;
@@ -1344,11 +1345,11 @@ public class BlockFieldMatrix<T extends 
         // perform multiplication block-wise, to ensure good cache behavior
         for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
             final int pStart = iBlock * BLOCK_SIZE;
-            final int pEnd   = Math.min(pStart + BLOCK_SIZE, rows);
+            final int pEnd   = FastMath.min(pStart + BLOCK_SIZE, rows);
             for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
                 final T[] block  = blocks[iBlock * blockColumns + jBlock];
                 final int      qStart = jBlock * BLOCK_SIZE;
-                final int      qEnd   = Math.min(qStart + BLOCK_SIZE, columns);
+                final int      qEnd   = FastMath.min(qStart + BLOCK_SIZE, columns);
                 int k = 0;
                 for (int p = pStart; p < pEnd; ++p) {
                     T sum = zero;
@@ -1394,11 +1395,11 @@ public class BlockFieldMatrix<T extends 
             final int jWidth3 = jWidth2 + jWidth;
             final int jWidth4 = jWidth3 + jWidth;
             final int qStart = jBlock * BLOCK_SIZE;
-            final int qEnd   = Math.min(qStart + BLOCK_SIZE, columns);
+            final int qEnd   = FastMath.min(qStart + BLOCK_SIZE, columns);
             for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
                 final T[] block  = blocks[iBlock * blockColumns + jBlock];
                 final int      pStart = iBlock * BLOCK_SIZE;
-                final int      pEnd   = Math.min(pStart + BLOCK_SIZE, rows);
+                final int      pEnd   = FastMath.min(pStart + BLOCK_SIZE, rows);
                 for (int q = qStart; q < qEnd; ++q) {
                     int k = q - qStart;
                     T sum = zero;
@@ -1432,12 +1433,12 @@ public class BlockFieldMatrix<T extends 
         visitor.start(rows, columns, 0, rows - 1, 0, columns - 1);
         for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
             final int pStart = iBlock * BLOCK_SIZE;
-            final int pEnd   = Math.min(pStart + BLOCK_SIZE, rows);
+            final int pEnd   = FastMath.min(pStart + BLOCK_SIZE, rows);
             for (int p = pStart; p < pEnd; ++p) {
                 for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
                     final int jWidth = blockWidth(jBlock);
                     final int qStart = jBlock * BLOCK_SIZE;
-                    final int qEnd   = Math.min(qStart + BLOCK_SIZE, columns);
+                    final int qEnd   = FastMath.min(qStart + BLOCK_SIZE, columns);
                     final T[] block = blocks[iBlock * blockColumns + jBlock];
                     int k = (p - pStart) * jWidth;
                     for (int q = qStart; q < qEnd; ++q) {
@@ -1457,12 +1458,12 @@ public class BlockFieldMatrix<T extends 
         visitor.start(rows, columns, 0, rows - 1, 0, columns - 1);
         for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
             final int pStart = iBlock * BLOCK_SIZE;
-            final int pEnd   = Math.min(pStart + BLOCK_SIZE, rows);
+            final int pEnd   = FastMath.min(pStart + BLOCK_SIZE, rows);
             for (int p = pStart; p < pEnd; ++p) {
                 for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
                     final int jWidth = blockWidth(jBlock);
                     final int qStart = jBlock * BLOCK_SIZE;
-                    final int qEnd   = Math.min(qStart + BLOCK_SIZE, columns);
+                    final int qEnd   = FastMath.min(qStart + BLOCK_SIZE, columns);
                     final T[] block = blocks[iBlock * blockColumns + jBlock];
                     int k = (p - pStart) * jWidth;
                     for (int q = qStart; q < qEnd; ++q) {
@@ -1485,14 +1486,14 @@ public class BlockFieldMatrix<T extends 
         visitor.start(rows, columns, startRow, endRow, startColumn, endColumn);
         for (int iBlock = startRow / BLOCK_SIZE; iBlock < 1 + endRow / BLOCK_SIZE; ++iBlock) {
             final int p0     = iBlock * BLOCK_SIZE;
-            final int pStart = Math.max(startRow, p0);
-            final int pEnd   = Math.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
+            final int pStart = FastMath.max(startRow, p0);
+            final int pEnd   = FastMath.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
             for (int p = pStart; p < pEnd; ++p) {
                 for (int jBlock = startColumn / BLOCK_SIZE; jBlock < 1 + endColumn / BLOCK_SIZE; ++jBlock) {
                     final int jWidth = blockWidth(jBlock);
                     final int q0     = jBlock * BLOCK_SIZE;
-                    final int qStart = Math.max(startColumn, q0);
-                    final int qEnd   = Math.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
+                    final int qStart = FastMath.max(startColumn, q0);
+                    final int qEnd   = FastMath.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
                     final T[] block = blocks[iBlock * blockColumns + jBlock];
                     int k = (p - p0) * jWidth + qStart - q0;
                     for (int q = qStart; q < qEnd; ++q) {
@@ -1515,14 +1516,14 @@ public class BlockFieldMatrix<T extends 
         visitor.start(rows, columns, startRow, endRow, startColumn, endColumn);
         for (int iBlock = startRow / BLOCK_SIZE; iBlock < 1 + endRow / BLOCK_SIZE; ++iBlock) {
             final int p0     = iBlock * BLOCK_SIZE;
-            final int pStart = Math.max(startRow, p0);
-            final int pEnd   = Math.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
+            final int pStart = FastMath.max(startRow, p0);
+            final int pEnd   = FastMath.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
             for (int p = pStart; p < pEnd; ++p) {
                 for (int jBlock = startColumn / BLOCK_SIZE; jBlock < 1 + endColumn / BLOCK_SIZE; ++jBlock) {
                     final int jWidth = blockWidth(jBlock);
                     final int q0     = jBlock * BLOCK_SIZE;
-                    final int qStart = Math.max(startColumn, q0);
-                    final int qEnd   = Math.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
+                    final int qStart = FastMath.max(startColumn, q0);
+                    final int qEnd   = FastMath.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
                     final T[] block = blocks[iBlock * blockColumns + jBlock];
                     int k = (p - p0) * jWidth + qStart - q0;
                     for (int q = qStart; q < qEnd; ++q) {
@@ -1543,10 +1544,10 @@ public class BlockFieldMatrix<T extends 
         int blockIndex = 0;
         for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
             final int pStart = iBlock * BLOCK_SIZE;
-            final int pEnd   = Math.min(pStart + BLOCK_SIZE, rows);
+            final int pEnd   = FastMath.min(pStart + BLOCK_SIZE, rows);
             for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
                 final int qStart = jBlock * BLOCK_SIZE;
-                final int qEnd   = Math.min(qStart + BLOCK_SIZE, columns);
+                final int qEnd   = FastMath.min(qStart + BLOCK_SIZE, columns);
                 final T[] block = blocks[blockIndex];
                 int k = 0;
                 for (int p = pStart; p < pEnd; ++p) {
@@ -1569,10 +1570,10 @@ public class BlockFieldMatrix<T extends 
         int blockIndex = 0;
         for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
             final int pStart = iBlock * BLOCK_SIZE;
-            final int pEnd   = Math.min(pStart + BLOCK_SIZE, rows);
+            final int pEnd   = FastMath.min(pStart + BLOCK_SIZE, rows);
             for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
                 final int qStart = jBlock * BLOCK_SIZE;
-                final int qEnd   = Math.min(qStart + BLOCK_SIZE, columns);
+                final int qEnd   = FastMath.min(qStart + BLOCK_SIZE, columns);
                 final T[] block = blocks[blockIndex];
                 int k = 0;
                 for (int p = pStart; p < pEnd; ++p) {
@@ -1597,13 +1598,13 @@ public class BlockFieldMatrix<T extends 
         visitor.start(rows, columns, startRow, endRow, startColumn, endColumn);
         for (int iBlock = startRow / BLOCK_SIZE; iBlock < 1 + endRow / BLOCK_SIZE; ++iBlock) {
             final int p0     = iBlock * BLOCK_SIZE;
-            final int pStart = Math.max(startRow, p0);
-            final int pEnd   = Math.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
+            final int pStart = FastMath.max(startRow, p0);
+            final int pEnd   = FastMath.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
             for (int jBlock = startColumn / BLOCK_SIZE; jBlock < 1 + endColumn / BLOCK_SIZE; ++jBlock) {
                 final int jWidth = blockWidth(jBlock);
                 final int q0     = jBlock * BLOCK_SIZE;
-                final int qStart = Math.max(startColumn, q0);
-                final int qEnd   = Math.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
+                final int qStart = FastMath.max(startColumn, q0);
+                final int qEnd   = FastMath.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
                 final T[] block = blocks[iBlock * blockColumns + jBlock];
                 for (int p = pStart; p < pEnd; ++p) {
                     int k = (p - p0) * jWidth + qStart - q0;
@@ -1627,13 +1628,13 @@ public class BlockFieldMatrix<T extends 
         visitor.start(rows, columns, startRow, endRow, startColumn, endColumn);
         for (int iBlock = startRow / BLOCK_SIZE; iBlock < 1 + endRow / BLOCK_SIZE; ++iBlock) {
             final int p0     = iBlock * BLOCK_SIZE;
-            final int pStart = Math.max(startRow, p0);
-            final int pEnd   = Math.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
+            final int pStart = FastMath.max(startRow, p0);
+            final int pEnd   = FastMath.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
             for (int jBlock = startColumn / BLOCK_SIZE; jBlock < 1 + endColumn / BLOCK_SIZE; ++jBlock) {
                 final int jWidth = blockWidth(jBlock);
                 final int q0     = jBlock * BLOCK_SIZE;
-                final int qStart = Math.max(startColumn, q0);
-                final int qEnd   = Math.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
+                final int qStart = FastMath.max(startColumn, q0);
+                final int qEnd   = FastMath.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
                 final T[] block = blocks[iBlock * blockColumns + jBlock];
                 for (int p = pStart; p < pEnd; ++p) {
                     int k = (p - p0) * jWidth + qStart - q0;

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/BlockRealMatrix.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/BlockRealMatrix.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/BlockRealMatrix.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/BlockRealMatrix.java Sun Aug 29 22:04:09 2010
@@ -22,6 +22,7 @@ import java.util.Arrays;
 
 import org.apache.commons.math.MathRuntimeException;
 import org.apache.commons.math.exception.util.LocalizedFormats;
+import org.apache.commons.math.util.FastMath;
 
 /**
  * Cache-friendly implementation of RealMatrix using a flat arrays to store
@@ -224,11 +225,11 @@ public class BlockRealMatrix extends Abs
         int blockIndex = 0;
         for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
             final int pStart  = iBlock * BLOCK_SIZE;
-            final int pEnd    = Math.min(pStart + BLOCK_SIZE, rows);
+            final int pEnd    = FastMath.min(pStart + BLOCK_SIZE, rows);
             final int iHeight = pEnd - pStart;
             for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
                 final int qStart = jBlock * BLOCK_SIZE;
-                final int qEnd   = Math.min(qStart + BLOCK_SIZE, columns);
+                final int qEnd   = FastMath.min(qStart + BLOCK_SIZE, columns);
                 final int jWidth = qEnd - qStart;
 
                 // allocate new block
@@ -272,11 +273,11 @@ public class BlockRealMatrix extends Abs
         int blockIndex = 0;
         for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
             final int pStart  = iBlock * BLOCK_SIZE;
-            final int pEnd    = Math.min(pStart + BLOCK_SIZE, rows);
+            final int pEnd    = FastMath.min(pStart + BLOCK_SIZE, rows);
             final int iHeight = pEnd - pStart;
             for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
                 final int qStart = jBlock * BLOCK_SIZE;
-                final int qEnd   = Math.min(qStart + BLOCK_SIZE, columns);
+                final int qEnd   = FastMath.min(qStart + BLOCK_SIZE, columns);
                 final int jWidth = qEnd - qStart;
                 blocks[blockIndex] = new double[iHeight * jWidth];
                 ++blockIndex;
@@ -332,9 +333,9 @@ public class BlockRealMatrix extends Abs
                     final double[] outBlock = out.blocks[blockIndex];
                     final double[] tBlock   = blocks[blockIndex];
                     final int      pStart   = iBlock * BLOCK_SIZE;
-                    final int      pEnd     = Math.min(pStart + BLOCK_SIZE, rows);
+                    final int      pEnd     = FastMath.min(pStart + BLOCK_SIZE, rows);
                     final int      qStart   = jBlock * BLOCK_SIZE;
-                    final int      qEnd     = Math.min(qStart + BLOCK_SIZE, columns);
+                    final int      qEnd     = FastMath.min(qStart + BLOCK_SIZE, columns);
                     int k = 0;
                     for (int p = pStart; p < pEnd; ++p) {
                         for (int q = qStart; q < qEnd; ++q) {
@@ -405,9 +406,9 @@ public class BlockRealMatrix extends Abs
                     final double[] outBlock = out.blocks[blockIndex];
                     final double[] tBlock   = blocks[blockIndex];
                     final int      pStart   = iBlock * BLOCK_SIZE;
-                    final int      pEnd     = Math.min(pStart + BLOCK_SIZE, rows);
+                    final int      pEnd     = FastMath.min(pStart + BLOCK_SIZE, rows);
                     final int      qStart   = jBlock * BLOCK_SIZE;
-                    final int      qEnd     = Math.min(qStart + BLOCK_SIZE, columns);
+                    final int      qEnd     = FastMath.min(qStart + BLOCK_SIZE, columns);
                     int k = 0;
                     for (int p = pStart; p < pEnd; ++p) {
                         for (int q = qStart; q < qEnd; ++q) {
@@ -514,12 +515,12 @@ public class BlockRealMatrix extends Abs
             for (int iBlock = 0; iBlock < out.blockRows; ++iBlock) {
 
                 final int pStart = iBlock * BLOCK_SIZE;
-                final int pEnd   = Math.min(pStart + BLOCK_SIZE, rows);
+                final int pEnd   = FastMath.min(pStart + BLOCK_SIZE, rows);
 
                 for (int jBlock = 0; jBlock < out.blockColumns; ++jBlock) {
 
                     final int qStart = jBlock * BLOCK_SIZE;
-                    final int qEnd   = Math.min(qStart + BLOCK_SIZE, m.getColumnDimension());
+                    final int qEnd   = FastMath.min(qStart + BLOCK_SIZE, m.getColumnDimension());
 
                     // select current block
                     final double[] outBlock = out.blocks[blockIndex];
@@ -577,7 +578,7 @@ public class BlockRealMatrix extends Abs
         for (int iBlock = 0; iBlock < out.blockRows; ++iBlock) {
 
             final int pStart = iBlock * BLOCK_SIZE;
-            final int pEnd   = Math.min(pStart + BLOCK_SIZE, rows);
+            final int pEnd   = FastMath.min(pStart + BLOCK_SIZE, rows);
 
             for (int jBlock = 0; jBlock < out.blockColumns; ++jBlock) {
                 final int jWidth = out.blockWidth(jBlock);
@@ -638,7 +639,7 @@ public class BlockRealMatrix extends Abs
 
         for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
             final int pStart = iBlock * BLOCK_SIZE;
-            final int pEnd   = Math.min(pStart + BLOCK_SIZE, rows);
+            final int pEnd   = FastMath.min(pStart + BLOCK_SIZE, rows);
             int regularPos   = 0;
             int lastPos      = 0;
             for (int p = pStart; p < pEnd; ++p) {
@@ -673,13 +674,13 @@ public class BlockRealMatrix extends Abs
                 for (int j = 0; j < jWidth; ++j) {
                     double sum = 0;
                     for (int i = 0; i < iHeight; ++i) {
-                        sum += Math.abs(block[i * jWidth + j]);
+                        sum += FastMath.abs(block[i * jWidth + j]);
                     }
                     colSums[j] += sum;
                 }
             }
             for (int j = 0; j < jWidth; ++j) {
-                maxColSum = Math.max(maxColSum, colSums[j]);
+                maxColSum = FastMath.max(maxColSum, colSums[j]);
             }
         }
         return maxColSum;
@@ -694,7 +695,7 @@ public class BlockRealMatrix extends Abs
                 sum2 += entry * entry;
             }
         }
-        return Math.sqrt(sum2);
+        return FastMath.sqrt(sum2);
     }
 
     /** {@inheritDoc} */
@@ -859,14 +860,14 @@ public class BlockRealMatrix extends Abs
         for (int iBlock = blockStartRow; iBlock < blockEndRow; ++iBlock) {
             final int iHeight  = blockHeight(iBlock);
             final int firstRow = iBlock * BLOCK_SIZE;
-            final int iStart   = Math.max(row,    firstRow);
-            final int iEnd     = Math.min(endRow + 1, firstRow + iHeight);
+            final int iStart   = FastMath.max(row,    firstRow);
+            final int iEnd     = FastMath.min(endRow + 1, firstRow + iHeight);
 
             for (int jBlock = blockStartColumn; jBlock < blockEndColumn; ++jBlock) {
                 final int jWidth      = blockWidth(jBlock);
                 final int firstColumn = jBlock * BLOCK_SIZE;
-                final int jStart      = Math.max(column,    firstColumn);
-                final int jEnd        = Math.min(endColumn + 1, firstColumn + jWidth);
+                final int jStart      = FastMath.max(column,    firstColumn);
+                final int jEnd        = FastMath.min(endColumn + 1, firstColumn + jWidth);
                 final int jLength     = jEnd - jStart;
 
                 // handle one block, row by row
@@ -1316,9 +1317,9 @@ public class BlockRealMatrix extends Abs
                 final double[] outBlock = out.blocks[blockIndex];
                 final double[] tBlock   = blocks[jBlock * blockColumns + iBlock];
                 final int      pStart   = iBlock * BLOCK_SIZE;
-                final int      pEnd     = Math.min(pStart + BLOCK_SIZE, columns);
+                final int      pEnd     = FastMath.min(pStart + BLOCK_SIZE, columns);
                 final int      qStart   = jBlock * BLOCK_SIZE;
-                final int      qEnd     = Math.min(qStart + BLOCK_SIZE, rows);
+                final int      qEnd     = FastMath.min(qStart + BLOCK_SIZE, rows);
                 int k = 0;
                 for (int p = pStart; p < pEnd; ++p) {
                     final int lInc = pEnd - pStart;
@@ -1367,11 +1368,11 @@ public class BlockRealMatrix extends Abs
         // perform multiplication block-wise, to ensure good cache behavior
         for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
             final int pStart = iBlock * BLOCK_SIZE;
-            final int pEnd   = Math.min(pStart + BLOCK_SIZE, rows);
+            final int pEnd   = FastMath.min(pStart + BLOCK_SIZE, rows);
             for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
                 final double[] block  = blocks[iBlock * blockColumns + jBlock];
                 final int      qStart = jBlock * BLOCK_SIZE;
-                final int      qEnd   = Math.min(qStart + BLOCK_SIZE, columns);
+                final int      qEnd   = FastMath.min(qStart + BLOCK_SIZE, columns);
                 int k = 0;
                 for (int p = pStart; p < pEnd; ++p) {
                     double sum = 0;
@@ -1415,11 +1416,11 @@ public class BlockRealMatrix extends Abs
             final int jWidth3 = jWidth2 + jWidth;
             final int jWidth4 = jWidth3 + jWidth;
             final int qStart = jBlock * BLOCK_SIZE;
-            final int qEnd   = Math.min(qStart + BLOCK_SIZE, columns);
+            final int qEnd   = FastMath.min(qStart + BLOCK_SIZE, columns);
             for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
                 final double[] block  = blocks[iBlock * blockColumns + jBlock];
                 final int      pStart = iBlock * BLOCK_SIZE;
-                final int      pEnd   = Math.min(pStart + BLOCK_SIZE, rows);
+                final int      pEnd   = FastMath.min(pStart + BLOCK_SIZE, rows);
                 for (int q = qStart; q < qEnd; ++q) {
                     int k = q - qStart;
                     double sum = 0;
@@ -1452,12 +1453,12 @@ public class BlockRealMatrix extends Abs
         visitor.start(rows, columns, 0, rows - 1, 0, columns - 1);
         for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
             final int pStart = iBlock * BLOCK_SIZE;
-            final int pEnd   = Math.min(pStart + BLOCK_SIZE, rows);
+            final int pEnd   = FastMath.min(pStart + BLOCK_SIZE, rows);
             for (int p = pStart; p < pEnd; ++p) {
                 for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
                     final int jWidth = blockWidth(jBlock);
                     final int qStart = jBlock * BLOCK_SIZE;
-                    final int qEnd   = Math.min(qStart + BLOCK_SIZE, columns);
+                    final int qEnd   = FastMath.min(qStart + BLOCK_SIZE, columns);
                     final double[] block = blocks[iBlock * blockColumns + jBlock];
                     int k = (p - pStart) * jWidth;
                     for (int q = qStart; q < qEnd; ++q) {
@@ -1477,12 +1478,12 @@ public class BlockRealMatrix extends Abs
         visitor.start(rows, columns, 0, rows - 1, 0, columns - 1);
         for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
             final int pStart = iBlock * BLOCK_SIZE;
-            final int pEnd   = Math.min(pStart + BLOCK_SIZE, rows);
+            final int pEnd   = FastMath.min(pStart + BLOCK_SIZE, rows);
             for (int p = pStart; p < pEnd; ++p) {
                 for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
                     final int jWidth = blockWidth(jBlock);
                     final int qStart = jBlock * BLOCK_SIZE;
-                    final int qEnd   = Math.min(qStart + BLOCK_SIZE, columns);
+                    final int qEnd   = FastMath.min(qStart + BLOCK_SIZE, columns);
                     final double[] block = blocks[iBlock * blockColumns + jBlock];
                     int k = (p - pStart) * jWidth;
                     for (int q = qStart; q < qEnd; ++q) {
@@ -1505,14 +1506,14 @@ public class BlockRealMatrix extends Abs
         visitor.start(rows, columns, startRow, endRow, startColumn, endColumn);
         for (int iBlock = startRow / BLOCK_SIZE; iBlock < 1 + endRow / BLOCK_SIZE; ++iBlock) {
             final int p0     = iBlock * BLOCK_SIZE;
-            final int pStart = Math.max(startRow, p0);
-            final int pEnd   = Math.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
+            final int pStart = FastMath.max(startRow, p0);
+            final int pEnd   = FastMath.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
             for (int p = pStart; p < pEnd; ++p) {
                 for (int jBlock = startColumn / BLOCK_SIZE; jBlock < 1 + endColumn / BLOCK_SIZE; ++jBlock) {
                     final int jWidth = blockWidth(jBlock);
                     final int q0     = jBlock * BLOCK_SIZE;
-                    final int qStart = Math.max(startColumn, q0);
-                    final int qEnd   = Math.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
+                    final int qStart = FastMath.max(startColumn, q0);
+                    final int qEnd   = FastMath.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
                     final double[] block = blocks[iBlock * blockColumns + jBlock];
                     int k = (p - p0) * jWidth + qStart - q0;
                     for (int q = qStart; q < qEnd; ++q) {
@@ -1535,14 +1536,14 @@ public class BlockRealMatrix extends Abs
         visitor.start(rows, columns, startRow, endRow, startColumn, endColumn);
         for (int iBlock = startRow / BLOCK_SIZE; iBlock < 1 + endRow / BLOCK_SIZE; ++iBlock) {
             final int p0     = iBlock * BLOCK_SIZE;
-            final int pStart = Math.max(startRow, p0);
-            final int pEnd   = Math.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
+            final int pStart = FastMath.max(startRow, p0);
+            final int pEnd   = FastMath.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
             for (int p = pStart; p < pEnd; ++p) {
                 for (int jBlock = startColumn / BLOCK_SIZE; jBlock < 1 + endColumn / BLOCK_SIZE; ++jBlock) {
                     final int jWidth = blockWidth(jBlock);
                     final int q0     = jBlock * BLOCK_SIZE;
-                    final int qStart = Math.max(startColumn, q0);
-                    final int qEnd   = Math.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
+                    final int qStart = FastMath.max(startColumn, q0);
+                    final int qEnd   = FastMath.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
                     final double[] block = blocks[iBlock * blockColumns + jBlock];
                     int k = (p - p0) * jWidth + qStart - q0;
                     for (int q = qStart; q < qEnd; ++q) {
@@ -1563,10 +1564,10 @@ public class BlockRealMatrix extends Abs
         int blockIndex = 0;
         for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
             final int pStart = iBlock * BLOCK_SIZE;
-            final int pEnd   = Math.min(pStart + BLOCK_SIZE, rows);
+            final int pEnd   = FastMath.min(pStart + BLOCK_SIZE, rows);
             for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
                 final int qStart = jBlock * BLOCK_SIZE;
-                final int qEnd   = Math.min(qStart + BLOCK_SIZE, columns);
+                final int qEnd   = FastMath.min(qStart + BLOCK_SIZE, columns);
                 final double[] block = blocks[blockIndex];
                 int k = 0;
                 for (int p = pStart; p < pEnd; ++p) {
@@ -1589,10 +1590,10 @@ public class BlockRealMatrix extends Abs
         int blockIndex = 0;
         for (int iBlock = 0; iBlock < blockRows; ++iBlock) {
             final int pStart = iBlock * BLOCK_SIZE;
-            final int pEnd   = Math.min(pStart + BLOCK_SIZE, rows);
+            final int pEnd   = FastMath.min(pStart + BLOCK_SIZE, rows);
             for (int jBlock = 0; jBlock < blockColumns; ++jBlock) {
                 final int qStart = jBlock * BLOCK_SIZE;
-                final int qEnd   = Math.min(qStart + BLOCK_SIZE, columns);
+                final int qEnd   = FastMath.min(qStart + BLOCK_SIZE, columns);
                 final double[] block = blocks[blockIndex];
                 int k = 0;
                 for (int p = pStart; p < pEnd; ++p) {
@@ -1617,13 +1618,13 @@ public class BlockRealMatrix extends Abs
         visitor.start(rows, columns, startRow, endRow, startColumn, endColumn);
         for (int iBlock = startRow / BLOCK_SIZE; iBlock < 1 + endRow / BLOCK_SIZE; ++iBlock) {
             final int p0     = iBlock * BLOCK_SIZE;
-            final int pStart = Math.max(startRow, p0);
-            final int pEnd   = Math.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
+            final int pStart = FastMath.max(startRow, p0);
+            final int pEnd   = FastMath.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
             for (int jBlock = startColumn / BLOCK_SIZE; jBlock < 1 + endColumn / BLOCK_SIZE; ++jBlock) {
                 final int jWidth = blockWidth(jBlock);
                 final int q0     = jBlock * BLOCK_SIZE;
-                final int qStart = Math.max(startColumn, q0);
-                final int qEnd   = Math.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
+                final int qStart = FastMath.max(startColumn, q0);
+                final int qEnd   = FastMath.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
                 final double[] block = blocks[iBlock * blockColumns + jBlock];
                 for (int p = pStart; p < pEnd; ++p) {
                     int k = (p - p0) * jWidth + qStart - q0;
@@ -1647,13 +1648,13 @@ public class BlockRealMatrix extends Abs
         visitor.start(rows, columns, startRow, endRow, startColumn, endColumn);
         for (int iBlock = startRow / BLOCK_SIZE; iBlock < 1 + endRow / BLOCK_SIZE; ++iBlock) {
             final int p0     = iBlock * BLOCK_SIZE;
-            final int pStart = Math.max(startRow, p0);
-            final int pEnd   = Math.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
+            final int pStart = FastMath.max(startRow, p0);
+            final int pEnd   = FastMath.min((iBlock + 1) * BLOCK_SIZE, 1 + endRow);
             for (int jBlock = startColumn / BLOCK_SIZE; jBlock < 1 + endColumn / BLOCK_SIZE; ++jBlock) {
                 final int jWidth = blockWidth(jBlock);
                 final int q0     = jBlock * BLOCK_SIZE;
-                final int qStart = Math.max(startColumn, q0);
-                final int qEnd   = Math.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
+                final int qStart = FastMath.max(startColumn, q0);
+                final int qEnd   = FastMath.min((jBlock + 1) * BLOCK_SIZE, 1 + endColumn);
                 final double[] block = blocks[iBlock * blockColumns + jBlock];
                 for (int p = pStart; p < pEnd; ++p) {
                     int k = (p - p0) * jWidth + qStart - q0;

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/CholeskyDecompositionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/CholeskyDecompositionImpl.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/CholeskyDecompositionImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/CholeskyDecompositionImpl.java Sun Aug 29 22:04:09 2010
@@ -19,6 +19,7 @@ package org.apache.commons.math.linear;
 
 import org.apache.commons.math.MathRuntimeException;
 import org.apache.commons.math.exception.util.LocalizedFormats;
+import org.apache.commons.math.util.FastMath;
 
 
 /**
@@ -118,8 +119,8 @@ public class CholeskyDecompositionImpl i
                 final double lIJ = lI[j];
                 final double lJI = lJ[i];
                 final double maxDelta =
-                    relativeSymmetryThreshold * Math.max(Math.abs(lIJ), Math.abs(lJI));
-                if (Math.abs(lIJ - lJI) > maxDelta) {
+                    relativeSymmetryThreshold * FastMath.max(FastMath.abs(lIJ), FastMath.abs(lJI));
+                if (FastMath.abs(lIJ - lJI) > maxDelta) {
                     throw new NotSymmetricMatrixException();
                 }
                 lJ[i] = 0;
@@ -136,7 +137,7 @@ public class CholeskyDecompositionImpl i
                 throw new NotPositiveDefiniteMatrixException();
             }
 
-            ltI[i] = Math.sqrt(ltI[i]);
+            ltI[i] = FastMath.sqrt(ltI[i]);
             final double inverse = 1.0 / ltI[i];
 
             for (int q = order - 1; q > i; --q) {

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/EigenDecompositionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/EigenDecompositionImpl.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/EigenDecompositionImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/EigenDecompositionImpl.java Sun Aug 29 22:04:09 2010
@@ -21,6 +21,7 @@ import org.apache.commons.math.MathRunti
 import org.apache.commons.math.MaxIterationsExceededException;
 import org.apache.commons.math.exception.util.LocalizedFormats;
 import org.apache.commons.math.util.MathUtils;
+import org.apache.commons.math.util.FastMath;
 
 /**
  * Calculates the eigen decomposition of a real <strong>symmetric</strong>
@@ -145,7 +146,7 @@ public class EigenDecompositionImpl impl
             for (int j = i + 1; j < columns; ++j) {
                 final double mij = matrix.getEntry(i, j);
                 final double mji = matrix.getEntry(j, i);
-                if (Math.abs(mij - mji) > (Math.max(Math.abs(mij), Math
+                if (FastMath.abs(mij - mji) > (FastMath.max(FastMath.abs(mij), Math
                         .abs(mji)) * eps)) {
                     return false;
                 }
@@ -484,20 +485,20 @@ public class EigenDecompositionImpl impl
         // Determine the largest main and secondary value in absolute term.
         double maxAbsoluteValue=0.0;
         for (int i = 0; i < n; i++) {
-            if (Math.abs(realEigenvalues[i])>maxAbsoluteValue) {
-                maxAbsoluteValue=Math.abs(realEigenvalues[i]);
+            if (FastMath.abs(realEigenvalues[i])>maxAbsoluteValue) {
+                maxAbsoluteValue=FastMath.abs(realEigenvalues[i]);
             }
-            if (Math.abs(e[i])>maxAbsoluteValue) {
-                maxAbsoluteValue=Math.abs(e[i]);
+            if (FastMath.abs(e[i])>maxAbsoluteValue) {
+                maxAbsoluteValue=FastMath.abs(e[i]);
             }
         }
         // Make null any main and secondary value too small to be significant
         if (maxAbsoluteValue!=0.0) {
             for (int i=0; i < n; i++) {
-                if (Math.abs(realEigenvalues[i])<=MathUtils.EPSILON*maxAbsoluteValue) {
+                if (FastMath.abs(realEigenvalues[i])<=MathUtils.EPSILON*maxAbsoluteValue) {
                     realEigenvalues[i]=0.0;
                 }
-                if (Math.abs(e[i])<=MathUtils.EPSILON*maxAbsoluteValue) {
+                if (FastMath.abs(e[i])<=MathUtils.EPSILON*maxAbsoluteValue) {
                     e[i]=0.0;
                 }
             }
@@ -508,8 +509,8 @@ public class EigenDecompositionImpl impl
             int m;
             do {
                 for (m = j; m < n - 1; m++) {
-                    double delta = Math.abs(realEigenvalues[m]) + Math.abs(realEigenvalues[m + 1]);
-                    if (Math.abs(e[m]) + delta == delta) {
+                    double delta = FastMath.abs(realEigenvalues[m]) + FastMath.abs(realEigenvalues[m + 1]);
+                    if (FastMath.abs(e[m]) + delta == delta) {
                         break;
                     }
                 }
@@ -519,7 +520,7 @@ public class EigenDecompositionImpl impl
                                 new MaxIterationsExceededException(maxIter));
                     its++;
                     double q = (realEigenvalues[j + 1] - realEigenvalues[j]) / (2 * e[j]);
-                    double t = Math.sqrt(1 + q * q);
+                    double t = FastMath.sqrt(1 + q * q);
                     if (q < 0.0) {
                         q = realEigenvalues[m] - realEigenvalues[j] + e[j] / (q - t);
                     } else {
@@ -532,15 +533,15 @@ public class EigenDecompositionImpl impl
                     for (i = m - 1; i >= j; i--) {
                         double p = s * e[i];
                         double h = c * e[i];
-                        if (Math.abs(p) >= Math.abs(q)) {
+                        if (FastMath.abs(p) >= FastMath.abs(q)) {
                             c = q / p;
-                            t = Math.sqrt(c * c + 1.0);
+                            t = FastMath.sqrt(c * c + 1.0);
                             e[i + 1] = p * t;
                             s = 1.0 / t;
                             c = c * s;
                         } else {
                             s = p / q;
-                            t = Math.sqrt(s * s + 1.0);
+                            t = FastMath.sqrt(s * s + 1.0);
                             e[i + 1] = q * t;
                             c = 1.0 / t;
                             s = s * c;
@@ -594,14 +595,14 @@ public class EigenDecompositionImpl impl
         // Determine the largest eigen value in absolute term.
         maxAbsoluteValue=0.0;
         for (int i = 0; i < n; i++) {
-            if (Math.abs(realEigenvalues[i])>maxAbsoluteValue) {
-                maxAbsoluteValue=Math.abs(realEigenvalues[i]);
+            if (FastMath.abs(realEigenvalues[i])>maxAbsoluteValue) {
+                maxAbsoluteValue=FastMath.abs(realEigenvalues[i]);
             }
         }
         // Make null any eigen value too small to be significant
         if (maxAbsoluteValue!=0.0) {
             for (int i=0; i < n; i++) {
-                if (Math.abs(realEigenvalues[i])<MathUtils.EPSILON*maxAbsoluteValue) {
+                if (FastMath.abs(realEigenvalues[i])<MathUtils.EPSILON*maxAbsoluteValue) {
                     realEigenvalues[i]=0.0;
                 }
             }

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=990658&r1=990657&r2=990658&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 Sun Aug 29 22:04:09 2010
@@ -19,6 +19,7 @@ package org.apache.commons.math.linear;
 
 import org.apache.commons.math.MathRuntimeException;
 import org.apache.commons.math.exception.util.LocalizedFormats;
+import org.apache.commons.math.util.FastMath;
 
 /**
  * Calculates the LUP-decomposition of a square matrix.
@@ -123,14 +124,14 @@ public class LUDecompositionImpl impleme
                 luRow[col] = sum;
 
                 // maintain best permutation choice
-                if (Math.abs(sum) > largest) {
-                    largest = Math.abs(sum);
+                if (FastMath.abs(sum) > largest) {
+                    largest = FastMath.abs(sum);
                     max = row;
                 }
             }
 
             // Singularity check
-            if (Math.abs(lu[max][col]) < singularityThreshold) {
+            if (FastMath.abs(lu[max][col]) < singularityThreshold) {
                 singular = true;
                 return;
             }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/OpenMapRealVector.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/OpenMapRealVector.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/OpenMapRealVector.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/OpenMapRealVector.java Sun Aug 29 22:04:09 2010
@@ -22,6 +22,7 @@ import org.apache.commons.math.MathRunti
 import org.apache.commons.math.exception.util.LocalizedFormats;
 import org.apache.commons.math.util.OpenIntToDoubleHashMap;
 import org.apache.commons.math.util.OpenIntToDoubleHashMap.Iterator;
+import org.apache.commons.math.util.FastMath;
 
 /**
  * This class implements the {@link RealVector} interface with a {@link OpenIntToDoubleHashMap} backing store.
@@ -204,7 +205,7 @@ public class OpenMapRealVector extends A
      * @since 2.1
      */
     protected boolean isDefaultValue(double value) {
-        return Math.abs(value) < epsilon;
+        return FastMath.abs(value) < epsilon;
     }
 
     /** {@inheritDoc} */
@@ -429,7 +430,7 @@ public class OpenMapRealVector extends A
                 res += value * value;
             }
         }
-        return Math.sqrt(res);
+        return FastMath.sqrt(res);
     }
 
     /** {@inheritDoc} */
@@ -451,7 +452,7 @@ public class OpenMapRealVector extends A
             double delta = entries.get(i) - v[i];
             res += delta * delta;
         }
-        return Math.sqrt(res);
+        return FastMath.sqrt(res);
     }
 
     /** {@inheritDoc} */
@@ -473,7 +474,7 @@ public class OpenMapRealVector extends A
         Iterator iter = entries.iterator();
         while (iter.hasNext()) {
             iter.advance();
-            double delta = Math.abs(iter.value() - v.getEntry(iter.key()));
+            double delta = FastMath.abs(iter.value() - v.getEntry(iter.key()));
             max += delta;
         }
         iter = v.getEntries().iterator();
@@ -481,8 +482,8 @@ public class OpenMapRealVector extends A
             iter.advance();
             int key = iter.key();
             if (!entries.containsKey(key)) {
-                double delta = Math.abs(iter.value());
-                max +=  Math.abs(delta);
+                double delta = FastMath.abs(iter.value());
+                max +=  FastMath.abs(delta);
             }
         }
         return max;
@@ -504,7 +505,7 @@ public class OpenMapRealVector extends A
         checkVectorDimensions(v.length);
         double max = 0;
         for (int i = 0; i < v.length; i++) {
-            double delta = Math.abs(getEntry(i) - v[i]);
+            double delta = FastMath.abs(getEntry(i) - v[i]);
             max += delta;
         }
         return max;
@@ -520,7 +521,7 @@ public class OpenMapRealVector extends A
         Iterator iter = entries.iterator();
         while (iter.hasNext()) {
             iter.advance();
-            double delta = Math.abs(iter.value() - v.getEntry(iter.key()));
+            double delta = FastMath.abs(iter.value() - v.getEntry(iter.key()));
             if (delta > max) {
                 max = delta;
             }
@@ -554,7 +555,7 @@ public class OpenMapRealVector extends A
         checkVectorDimensions(v.length);
         double max = 0;
         for (int i = 0; i < v.length; i++) {
-            double delta = Math.abs(getEntry(i) - v[i]);
+            double delta = FastMath.abs(getEntry(i) - v[i]);
             if (delta > max) {
                 max = delta;
             }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/QRDecompositionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/QRDecompositionImpl.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/QRDecompositionImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/QRDecompositionImpl.java Sun Aug 29 22:04:09 2010
@@ -21,6 +21,7 @@ import java.util.Arrays;
 
 import org.apache.commons.math.MathRuntimeException;
 import org.apache.commons.math.exception.util.LocalizedFormats;
+import org.apache.commons.math.util.FastMath;
 
 
 /**
@@ -73,7 +74,7 @@ public class QRDecompositionImpl impleme
         final int m = matrix.getRowDimension();
         final int n = matrix.getColumnDimension();
         qrt = matrix.transpose().getData();
-        rDiag = new double[Math.min(m, n)];
+        rDiag = new double[FastMath.min(m, n)];
         cachedQ  = null;
         cachedQT = null;
         cachedR  = null;
@@ -84,7 +85,7 @@ public class QRDecompositionImpl impleme
          * reflectors by repeating the following operations to each minor
          * A(minor,minor) of A:
          */
-        for (int minor = 0; minor < Math.min(m, n); minor++) {
+        for (int minor = 0; minor < FastMath.min(m, n); minor++) {
 
             final double[] qrtMinor = qrt[minor];
 
@@ -100,7 +101,7 @@ public class QRDecompositionImpl impleme
                 final double c = qrtMinor[row];
                 xNormSqr += c * c;
             }
-            final double a = (qrtMinor[minor] > 0) ? -Math.sqrt(xNormSqr) : Math.sqrt(xNormSqr);
+            final double a = (qrtMinor[minor] > 0) ? -FastMath.sqrt(xNormSqr) : FastMath.sqrt(xNormSqr);
             rDiag[minor] = a;
 
             if (a != 0.0) {
@@ -155,7 +156,7 @@ public class QRDecompositionImpl impleme
             cachedR = MatrixUtils.createRealMatrix(m, n);
 
             // copy the diagonal from rDiag and the upper triangle of qr
-            for (int row = Math.min(m, n) - 1; row >= 0; row--) {
+            for (int row = FastMath.min(m, n) - 1; row >= 0; row--) {
                 cachedR.setEntry(row, row, rDiag[row]);
                 for (int col = row + 1; col < n; col++) {
                     cachedR.setEntry(row, col, qrt[col][row]);
@@ -192,11 +193,11 @@ public class QRDecompositionImpl impleme
              * applying the Householder transformations Q_(m-1),Q_(m-2),...,Q1 in
              * succession to the result
              */
-            for (int minor = m - 1; minor >= Math.min(m, n); minor--) {
+            for (int minor = m - 1; minor >= FastMath.min(m, n); minor--) {
                 cachedQT.setEntry(minor, minor, 1.0);
             }
 
-            for (int minor = Math.min(m, n)-1; minor >= 0; minor--){
+            for (int minor = FastMath.min(m, n)-1; minor >= 0; minor--){
                 final double[] qrtMinor = qrt[minor];
                 cachedQT.setEntry(minor, minor, 1.0);
                 if (qrtMinor[minor] != 0.0) {
@@ -230,7 +231,7 @@ public class QRDecompositionImpl impleme
             final int m = qrt[0].length;
             cachedH = MatrixUtils.createRealMatrix(m, n);
             for (int i = 0; i < m; ++i) {
-                for (int j = 0; j < Math.min(i + 1, n); ++j) {
+                for (int j = 0; j < FastMath.min(i + 1, n); ++j) {
                     cachedH.setEntry(i, j, qrt[j][i] / -rDiag[j]);
                 }
             }
@@ -302,7 +303,7 @@ public class QRDecompositionImpl impleme
             final double[] y = b.clone();
 
             // apply Householder transforms to solve Q.y = b
-            for (int minor = 0; minor < Math.min(m, n); minor++) {
+            for (int minor = 0; minor < FastMath.min(m, n); minor++) {
 
                 final double[] qrtMinor = qrt[minor];
                 double dotProduct = 0;
@@ -378,14 +379,14 @@ public class QRDecompositionImpl impleme
 
             for (int kBlock = 0; kBlock < cBlocks; ++kBlock) {
                 final int kStart = kBlock * blockSize;
-                final int kEnd   = Math.min(kStart + blockSize, columns);
+                final int kEnd   = FastMath.min(kStart + blockSize, columns);
                 final int kWidth = kEnd - kStart;
 
                 // get the right hand side vector
                 b.copySubMatrix(0, m - 1, kStart, kEnd - 1, y);
 
                 // apply Householder transforms to solve Q.y = b
-                for (int minor = 0; minor < Math.min(m, n); minor++) {
+                for (int minor = 0; minor < FastMath.min(m, n); minor++) {
                     final double[] qrtMinor = qrt[minor];
                     final double factor     = 1.0 / (rDiag[minor] * qrtMinor[minor]);
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/SingularValueDecompositionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/SingularValueDecompositionImpl.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/SingularValueDecompositionImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/SingularValueDecompositionImpl.java Sun Aug 29 22:04:09 2010
@@ -19,6 +19,7 @@ package org.apache.commons.math.linear;
 
 import org.apache.commons.math.MathRuntimeException;
 import org.apache.commons.math.exception.util.LocalizedFormats;
+import org.apache.commons.math.util.FastMath;
 
 /**
  * Calculates the compact Singular Value Decomposition of a matrix.
@@ -137,7 +138,7 @@ public class SingularValueDecompositionI
             cachedV = eigenDecomposition.getV().getSubMatrix(0,n-1,0,p-1);
         }
         for (int i = 0; i < p; i++) {
-            singularValues[i] = Math.sqrt(Math.abs(singularValues[i]));
+            singularValues[i] = FastMath.sqrt(FastMath.abs(singularValues[i]));
         }
         // Up to this point, U and V are computed independently of each other.
         // There still a sign indetermination of each column of, say, U.
@@ -251,7 +252,7 @@ public class SingularValueDecompositionI
     /** {@inheritDoc} */
     public int getRank() throws IllegalStateException {
 
-        final double threshold = Math.max(m, n) * Math.ulp(singularValues[0]);
+        final double threshold = FastMath.max(m, n) * FastMath.ulp(singularValues[0]);
 
         for (int i = singularValues.length - 1; i >= 0; --i) {
             if (singularValues[i] > threshold) {

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/TriDiagonalTransformer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/TriDiagonalTransformer.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/TriDiagonalTransformer.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/TriDiagonalTransformer.java Sun Aug 29 22:04:09 2010
@@ -19,6 +19,8 @@ package org.apache.commons.math.linear;
 
 import java.util.Arrays;
 
+import org.apache.commons.math.util.FastMath;
+
 
 /**
  * Class transforming a symmetrical matrix to tridiagonal shape.
@@ -213,7 +215,7 @@ class TriDiagonalTransformer {
                 final double c = hK[j];
                 xNormSqr += c * c;
             }
-            final double a = (hK[k + 1] > 0) ? -Math.sqrt(xNormSqr) : Math.sqrt(xNormSqr);
+            final double a = (hK[k + 1] > 0) ? -FastMath.sqrt(xNormSqr) : FastMath.sqrt(xNormSqr);
             secondary[k] = a;
             if (a != 0.0) {
                 // apply Householder transform from left and right simultaneously

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/AbstractIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/AbstractIntegrator.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/AbstractIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/AbstractIntegrator.java Sun Aug 29 22:04:09 2010
@@ -27,6 +27,7 @@ import org.apache.commons.math.ode.event
 import org.apache.commons.math.ode.events.EventHandler;
 import org.apache.commons.math.ode.events.EventState;
 import org.apache.commons.math.ode.sampling.StepHandler;
+import org.apache.commons.math.util.FastMath;
 
 /**
  * Base class managing common boilerplate for all integrators.
@@ -206,10 +207,10 @@ public abstract class AbstractIntegrator
                     LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE, ode.getDimension(), y.length);
         }
 
-        if (Math.abs(t - t0) <= 1.0e-12 * Math.max(Math.abs(t0), Math.abs(t))) {
+        if (FastMath.abs(t - t0) <= 1.0e-12 * FastMath.max(FastMath.abs(t0), FastMath.abs(t))) {
             throw new IntegratorException(
                     LocalizedFormats.TOO_SMALL_INTEGRATION_INTERVAL,
-                    Math.abs(t - t0));
+                    FastMath.abs(t - t0));
         }
 
     }
@@ -236,7 +237,7 @@ public abstract class AbstractIntegrator
         }
         newManager.addEventHandler(new EndTimeChecker(endTime),
                                    Double.POSITIVE_INFINITY,
-                                   Math.ulp(Math.max(Math.abs(startTime), Math.abs(endTime))),
+                                   FastMath.ulp(FastMath.max(FastMath.abs(startTime), FastMath.abs(endTime))),
                                    100);
         return newManager;
     }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/ContinuousOutputModel.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/ContinuousOutputModel.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/ContinuousOutputModel.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/ContinuousOutputModel.java Sun Aug 29 22:04:09 2010
@@ -25,6 +25,7 @@ import org.apache.commons.math.MathRunti
 import org.apache.commons.math.exception.util.LocalizedFormats;
 import org.apache.commons.math.ode.sampling.StepHandler;
 import org.apache.commons.math.ode.sampling.StepInterpolator;
+import org.apache.commons.math.util.FastMath;
 
 /**
  * This class stores all information provided by an ODE integrator
@@ -149,9 +150,9 @@ public class ContinuousOutputModel
       final double previous = lastInterpolator.getPreviousTime();
       final double step = current - previous;
       final double gap = model.getInitialTime() - current;
-      if (Math.abs(gap) > 1.0e-3 * Math.abs(step)) {
+      if (FastMath.abs(gap) > 1.0e-3 * FastMath.abs(step)) {
         throw MathRuntimeException.createIllegalArgumentException(
-              LocalizedFormats.HOLE_BETWEEN_MODELS_TIME_RANGES, Math.abs(gap));
+              LocalizedFormats.HOLE_BETWEEN_MODELS_TIME_RANGES, FastMath.abs(gap));
       }
 
     }
@@ -297,7 +298,7 @@ public class ContinuousOutputModel
         final StepInterpolator sMed = steps.get(iMed);
         final double tMed = 0.5 * (sMed.getPreviousTime() + sMed.getCurrentTime());
 
-        if ((Math.abs(tMed - tMin) < 1e-6) || (Math.abs(tMax - tMed) < 1e-6)) {
+        if ((FastMath.abs(tMed - tMin) < 1e-6) || (FastMath.abs(tMax - tMed) < 1e-6)) {
           // too close to the bounds, we estimate using a simple dichotomy
           index = iMed;
         } else {
@@ -314,12 +315,12 @@ public class ContinuousOutputModel
                                     (dt1 * dt3 * d13) * iMed +
                                     (dt1 * dt2 * d12) * iMin) /
                                    (d12 * d23 * d13);
-          index = (int) Math.rint(iLagrange);
+          index = (int) FastMath.rint(iLagrange);
         }
 
         // force the next size reduction to be at least one tenth
-        final int low  = Math.max(iMin + 1, (9 * iMin + iMax) / 10);
-        final int high = Math.min(iMax - 1, (iMin + 9 * iMax) / 10);
+        final int low  = FastMath.max(iMin + 1, (9 * iMin + iMax) / 10);
+        final int high = FastMath.min(iMax - 1, (iMin + 9 * iMax) / 10);
         if (index < low) {
           index = low;
         } else if (index > high) {

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/MultistepIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/MultistepIntegrator.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/MultistepIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/MultistepIntegrator.java Sun Aug 29 22:04:09 2010
@@ -25,6 +25,7 @@ import org.apache.commons.math.ode.nonst
 import org.apache.commons.math.ode.nonstiff.DormandPrince853Integrator;
 import org.apache.commons.math.ode.sampling.StepHandler;
 import org.apache.commons.math.ode.sampling.StepInterpolator;
+import org.apache.commons.math.util.FastMath;
 
 /**
  * This class is the base class for multistep integrators for Ordinary
@@ -128,7 +129,7 @@ public abstract class MultistepIntegrato
         // set the default values of the algorithm control parameters
         setSafety(0.9);
         setMinReduction(0.2);
-        setMaxGrowth(Math.pow(2.0, -exp));
+        setMaxGrowth(FastMath.pow(2.0, -exp));
 
     }
 
@@ -167,7 +168,7 @@ public abstract class MultistepIntegrato
         // set the default values of the algorithm control parameters
         setSafety(0.9);
         setMinReduction(0.2);
-        setMaxGrowth(Math.pow(2.0, -exp));
+        setMaxGrowth(FastMath.pow(2.0, -exp));
 
     }
 
@@ -291,7 +292,7 @@ public abstract class MultistepIntegrato
      * @return grow/shrink factor for next step
      */
     protected double computeStepGrowShrinkFactor(final double error) {
-        return Math.min(maxGrowth, Math.max(minReduction, safety * Math.pow(error, exp)));
+        return FastMath.min(maxGrowth, FastMath.max(minReduction, safety * FastMath.pow(error, exp)));
     }
 
     /** Transformer used to convert the first step to Nordsieck representation. */

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/events/EventState.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/events/EventState.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/events/EventState.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/events/EventState.java Sun Aug 29 22:04:09 2010
@@ -24,6 +24,7 @@ import org.apache.commons.math.analysis.
 import org.apache.commons.math.analysis.solvers.BrentSolver;
 import org.apache.commons.math.ode.DerivativeException;
 import org.apache.commons.math.ode.sampling.StepInterpolator;
+import org.apache.commons.math.util.FastMath;
 
 /** This class handles the state for one {@link EventHandler
  * event handler} during integration steps.
@@ -95,7 +96,7 @@ public class EventState {
                       final double convergence, final int maxIterationCount) {
         this.handler           = handler;
         this.maxCheckInterval  = maxCheckInterval;
-        this.convergence       = Math.abs(convergence);
+        this.convergence       = FastMath.abs(convergence);
         this.maxIterationCount = maxIterationCount;
 
         // some dummy values ...
@@ -171,7 +172,7 @@ public class EventState {
 
             forward = interpolator.isForward();
             final double t1 = interpolator.getCurrentTime();
-            final int    n  = Math.max(1, (int) Math.ceil(Math.abs(t1 - t0) / maxCheckInterval));
+            final int    n  = FastMath.max(1, (int) FastMath.ceil(FastMath.abs(t1 - t0) / maxCheckInterval));
             final double h  = (t1 - t0) / n;
 
             double ta = t0;
@@ -227,15 +228,15 @@ public class EventState {
                     solver.setAbsoluteAccuracy(convergence);
                     solver.setMaximalIterationCount(maxIterationCount);
                     final double root = (ta <= tb) ? solver.solve(f, ta, tb) : solver.solve(f, tb, ta);
-                    if ((Math.abs(root - ta) <= convergence) &&
-                         (Math.abs(root - previousEventTime) <= convergence)) {
+                    if ((FastMath.abs(root - ta) <= convergence) &&
+                         (FastMath.abs(root - previousEventTime) <= convergence)) {
                         // we have either found nothing or found (again ?) a past event, we simply ignore it
                         ta = tb;
                         ga = gb;
                     } else if (Double.isNaN(previousEventTime) ||
-                               (Math.abs(previousEventTime - root) > convergence)) {
+                               (FastMath.abs(previousEventTime - root) > convergence)) {
                         pendingEventTime = root;
-                        if (pendingEvent && (Math.abs(t1 - pendingEventTime) <= convergence)) {
+                        if (pendingEvent && (FastMath.abs(t1 - pendingEventTime) <= convergence)) {
                             // we were already waiting for this event which was
                             // found during a previous call for a step that was
                             // rejected, this step must now be accepted since it

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/AdamsBashforthIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/AdamsBashforthIntegrator.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/AdamsBashforthIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/AdamsBashforthIntegrator.java Sun Aug 29 22:04:09 2010
@@ -24,6 +24,7 @@ import org.apache.commons.math.ode.Integ
 import org.apache.commons.math.ode.events.CombinedEventsManager;
 import org.apache.commons.math.ode.sampling.NordsieckStepInterpolator;
 import org.apache.commons.math.ode.sampling.StepHandler;
+import org.apache.commons.math.util.FastMath;
 
 
 /**
@@ -239,14 +240,14 @@ public class AdamsBashforthIntegrator ex
                 // evaluate error using the last term of the Taylor expansion
                 error = 0;
                 for (int i = 0; i < mainSetDimension; ++i) {
-                    final double yScale = Math.abs(y[i]);
+                    final double yScale = FastMath.abs(y[i]);
                     final double tol = (vecAbsoluteTolerance == null) ?
                                        (scalAbsoluteTolerance + scalRelativeTolerance * yScale) :
                                        (vecAbsoluteTolerance[i] + vecRelativeTolerance[i] * yScale);
                     final double ratio  = nordsieck.getEntry(lastRow, i) / tol;
                     error += ratio * ratio;
                 }
-                error = Math.sqrt(error / mainSetDimension);
+                error = FastMath.sqrt(error / mainSetDimension);
 
                 if (error <= 1.0) {
 
@@ -273,7 +274,7 @@ public class AdamsBashforthIntegrator ex
                     interpolatorTmp.storeTime(stepEnd);
                     if (manager.evaluateStep(interpolatorTmp)) {
                         final double dt = manager.getEventTime() - stepStart;
-                        if (Math.abs(dt) <= Math.ulp(stepStart)) {
+                        if (FastMath.abs(dt) <= FastMath.ulp(stepStart)) {
                             // we cannot simply truncate the step, reject the current computation
                             // and let the loop compute another state with the truncated step.
                             // it is so small (much probably exactly 0 due to limited accuracy)

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/AdamsMoultonIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/AdamsMoultonIntegrator.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/AdamsMoultonIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/AdamsMoultonIntegrator.java Sun Aug 29 22:04:09 2010
@@ -28,6 +28,7 @@ import org.apache.commons.math.ode.Integ
 import org.apache.commons.math.ode.events.CombinedEventsManager;
 import org.apache.commons.math.ode.sampling.NordsieckStepInterpolator;
 import org.apache.commons.math.ode.sampling.StepHandler;
+import org.apache.commons.math.util.FastMath;
 
 
 /**
@@ -291,7 +292,7 @@ public class AdamsMoultonIntegrator exte
                     interpolatorTmp.storeTime(stepEnd);
                     if (manager.evaluateStep(interpolatorTmp)) {
                         final double dt = manager.getEventTime() - stepStart;
-                        if (Math.abs(dt) <= Math.ulp(stepStart)) {
+                        if (FastMath.abs(dt) <= FastMath.ulp(stepStart)) {
                             // we cannot simply truncate the step, reject the current computation
                             // and let the loop compute another state with the truncated step.
                             // it is so small (much probably exactly 0 due to limited accuracy)
@@ -436,7 +437,7 @@ public class AdamsMoultonIntegrator exte
             for (int i = 0; i < after.length; ++i) {
                 after[i] += previous[i] + scaled[i];
                 if (i < mainSetDimension) {
-                    final double yScale = Math.max(Math.abs(previous[i]), Math.abs(after[i]));
+                    final double yScale = FastMath.max(FastMath.abs(previous[i]), FastMath.abs(after[i]));
                     final double tol = (vecAbsoluteTolerance == null) ?
                                        (scalAbsoluteTolerance + scalRelativeTolerance * yScale) :
                                        (vecAbsoluteTolerance[i] + vecRelativeTolerance[i] * yScale);
@@ -445,7 +446,7 @@ public class AdamsMoultonIntegrator exte
                 }
             }
 
-            return Math.sqrt(error / mainSetDimension);
+            return FastMath.sqrt(error / mainSetDimension);
 
         }
     }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/AdaptiveStepsizeIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/AdaptiveStepsizeIntegrator.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/AdaptiveStepsizeIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/AdaptiveStepsizeIntegrator.java Sun Aug 29 22:04:09 2010
@@ -23,6 +23,7 @@ import org.apache.commons.math.ode.Deriv
 import org.apache.commons.math.ode.ExtendedFirstOrderDifferentialEquations;
 import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
 import org.apache.commons.math.ode.IntegratorException;
+import org.apache.commons.math.util.FastMath;
 
 /**
  * This abstract class holds the common part of all adaptive
@@ -105,8 +106,8 @@ public abstract class AdaptiveStepsizeIn
 
     super(name);
 
-    this.minStep     = Math.abs(minStep);
-    this.maxStep     = Math.abs(maxStep);
+    this.minStep     = FastMath.abs(minStep);
+    this.maxStep     = FastMath.abs(maxStep);
     this.initialStep = -1.0;
 
     this.scalAbsoluteTolerance = scalAbsoluteTolerance;
@@ -239,7 +240,7 @@ public abstract class AdaptiveStepsizeIn
     }
 
     double h = ((yOnScale2 < 1.0e-10) || (yDotOnScale2 < 1.0e-10)) ?
-               1.0e-6 : (0.01 * Math.sqrt(yOnScale2 / yDotOnScale2));
+               1.0e-6 : (0.01 * FastMath.sqrt(yOnScale2 / yDotOnScale2));
     if (! forward) {
       h = -h;
     }
@@ -256,16 +257,16 @@ public abstract class AdaptiveStepsizeIn
       ratio         = (yDot1[j] - yDot0[j]) / scale[j];
       yDDotOnScale += ratio * ratio;
     }
-    yDDotOnScale = Math.sqrt(yDDotOnScale) / h;
+    yDDotOnScale = FastMath.sqrt(yDDotOnScale) / h;
 
     // step size is computed such that
     // h^order * max (||y'/tol||, ||y''/tol||) = 0.01
-    final double maxInv2 = Math.max(Math.sqrt(yDotOnScale2), yDDotOnScale);
+    final double maxInv2 = FastMath.max(FastMath.sqrt(yDotOnScale2), yDDotOnScale);
     final double h1 = (maxInv2 < 1.0e-15) ?
-                      Math.max(1.0e-6, 0.001 * Math.abs(h)) :
-                      Math.pow(0.01 / maxInv2, 1.0 / order);
-    h = Math.min(100.0 * Math.abs(h), h1);
-    h = Math.max(h, 1.0e-12 * Math.abs(t0));  // avoids cancellation when computing t1 - t0
+                      FastMath.max(1.0e-6, 0.001 * FastMath.abs(h)) :
+                      FastMath.pow(0.01 / maxInv2, 1.0 / order);
+    h = FastMath.min(100.0 * FastMath.abs(h), h1);
+    h = FastMath.max(h, 1.0e-12 * FastMath.abs(t0));  // avoids cancellation when computing t1 - t0
     if (h < getMinStep()) {
       h = getMinStep();
     }
@@ -293,13 +294,13 @@ public abstract class AdaptiveStepsizeIn
     throws IntegratorException {
 
       double filteredH = h;
-      if (Math.abs(h) < minStep) {
+      if (FastMath.abs(h) < minStep) {
           if (acceptSmall) {
               filteredH = forward ? minStep : -minStep;
           } else {
               throw new IntegratorException(
                       LocalizedFormats.MINIMAL_STEPSIZE_REACHED_DURING_INTEGRATION,
-                      minStep, Math.abs(h));
+                      minStep, FastMath.abs(h));
           }
       }
 
@@ -328,7 +329,7 @@ public abstract class AdaptiveStepsizeIn
   /** Reset internal state to dummy values. */
   protected void resetInternalState() {
     stepStart = Double.NaN;
-    stepSize  = Math.sqrt(minStep * maxStep);
+    stepSize  = FastMath.sqrt(minStep * maxStep);
   }
 
   /** Get the minimal step.

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/DormandPrince54Integrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/DormandPrince54Integrator.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/DormandPrince54Integrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/DormandPrince54Integrator.java Sun Aug 29 22:04:09 2010
@@ -17,6 +17,8 @@
 
 package org.apache.commons.math.ode.nonstiff;
 
+import org.apache.commons.math.util.FastMath;
+
 
 /**
  * This class implements the 5(4) Dormand-Prince integrator for Ordinary
@@ -140,7 +142,7 @@ public class DormandPrince54Integrator e
                               E4 * yDotK[3][j] +  E5 * yDotK[4][j] +
                               E6 * yDotK[5][j] +  E7 * yDotK[6][j];
 
-        final double yScale = Math.max(Math.abs(y0[j]), Math.abs(y1[j]));
+        final double yScale = FastMath.max(FastMath.abs(y0[j]), FastMath.abs(y1[j]));
         final double tol = (vecAbsoluteTolerance == null) ?
                            (scalAbsoluteTolerance + scalRelativeTolerance * yScale) :
                                (vecAbsoluteTolerance[j] + vecRelativeTolerance[j] * yScale);
@@ -149,7 +151,7 @@ public class DormandPrince54Integrator e
 
     }
 
-    return Math.sqrt(error / mainSetDimension);
+    return FastMath.sqrt(error / mainSetDimension);
 
   }
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/DormandPrince853Integrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/DormandPrince853Integrator.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/DormandPrince853Integrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/DormandPrince853Integrator.java Sun Aug 29 22:04:09 2010
@@ -17,6 +17,8 @@
 
 package org.apache.commons.math.ode.nonstiff;
 
+import org.apache.commons.math.util.FastMath;
+
 
 /**
  * This class implements the 8(5,3) Dormand-Prince integrator for Ordinary
@@ -59,8 +61,8 @@ public class DormandPrince853Integrator 
 
   /** Time steps Butcher array. */
   private static final double[] STATIC_C = {
-    (12.0 - 2.0 * Math.sqrt(6.0)) / 135.0, (6.0 - Math.sqrt(6.0)) / 45.0, (6.0 - Math.sqrt(6.0)) / 30.0,
-    (6.0 + Math.sqrt(6.0)) / 30.0, 1.0/3.0, 1.0/4.0, 4.0/13.0, 127.0/195.0, 3.0/5.0,
+    (12.0 - 2.0 * FastMath.sqrt(6.0)) / 135.0, (6.0 - FastMath.sqrt(6.0)) / 45.0, (6.0 - FastMath.sqrt(6.0)) / 30.0,
+    (6.0 + FastMath.sqrt(6.0)) / 30.0, 1.0/3.0, 1.0/4.0, 4.0/13.0, 127.0/195.0, 3.0/5.0,
     6.0/7.0, 1.0, 1.0
   };
 
@@ -68,55 +70,55 @@ public class DormandPrince853Integrator 
   private static final double[][] STATIC_A = {
 
     // k2
-    {(12.0 - 2.0 * Math.sqrt(6.0)) / 135.0},
+    {(12.0 - 2.0 * FastMath.sqrt(6.0)) / 135.0},
 
     // k3
-    {(6.0 - Math.sqrt(6.0)) / 180.0, (6.0 - Math.sqrt(6.0)) / 60.0},
+    {(6.0 - FastMath.sqrt(6.0)) / 180.0, (6.0 - FastMath.sqrt(6.0)) / 60.0},
 
     // k4
-    {(6.0 - Math.sqrt(6.0)) / 120.0, 0.0, (6.0 - Math.sqrt(6.0)) / 40.0},
+    {(6.0 - FastMath.sqrt(6.0)) / 120.0, 0.0, (6.0 - FastMath.sqrt(6.0)) / 40.0},
 
     // k5
-    {(462.0 + 107.0 * Math.sqrt(6.0)) / 3000.0, 0.0,
-     (-402.0 - 197.0 * Math.sqrt(6.0)) / 1000.0, (168.0 + 73.0 * Math.sqrt(6.0)) / 375.0},
+    {(462.0 + 107.0 * FastMath.sqrt(6.0)) / 3000.0, 0.0,
+     (-402.0 - 197.0 * FastMath.sqrt(6.0)) / 1000.0, (168.0 + 73.0 * FastMath.sqrt(6.0)) / 375.0},
 
     // k6
-    {1.0 / 27.0, 0.0, 0.0, (16.0 + Math.sqrt(6.0)) / 108.0, (16.0 - Math.sqrt(6.0)) / 108.0},
+    {1.0 / 27.0, 0.0, 0.0, (16.0 + FastMath.sqrt(6.0)) / 108.0, (16.0 - FastMath.sqrt(6.0)) / 108.0},
 
     // k7
-    {19.0 / 512.0, 0.0, 0.0, (118.0 + 23.0 * Math.sqrt(6.0)) / 1024.0,
-     (118.0 - 23.0 * Math.sqrt(6.0)) / 1024.0, -9.0 / 512.0},
+    {19.0 / 512.0, 0.0, 0.0, (118.0 + 23.0 * FastMath.sqrt(6.0)) / 1024.0,
+     (118.0 - 23.0 * FastMath.sqrt(6.0)) / 1024.0, -9.0 / 512.0},
 
     // k8
-    {13772.0 / 371293.0, 0.0, 0.0, (51544.0 + 4784.0 * Math.sqrt(6.0)) / 371293.0,
-     (51544.0 - 4784.0 * Math.sqrt(6.0)) / 371293.0, -5688.0 / 371293.0, 3072.0 / 371293.0},
+    {13772.0 / 371293.0, 0.0, 0.0, (51544.0 + 4784.0 * FastMath.sqrt(6.0)) / 371293.0,
+     (51544.0 - 4784.0 * FastMath.sqrt(6.0)) / 371293.0, -5688.0 / 371293.0, 3072.0 / 371293.0},
 
     // k9
     {58656157643.0 / 93983540625.0, 0.0, 0.0,
-     (-1324889724104.0 - 318801444819.0 * Math.sqrt(6.0)) / 626556937500.0,
-     (-1324889724104.0 + 318801444819.0 * Math.sqrt(6.0)) / 626556937500.0,
+     (-1324889724104.0 - 318801444819.0 * FastMath.sqrt(6.0)) / 626556937500.0,
+     (-1324889724104.0 + 318801444819.0 * FastMath.sqrt(6.0)) / 626556937500.0,
      96044563816.0 / 3480871875.0, 5682451879168.0 / 281950621875.0,
      -165125654.0 / 3796875.0},
 
     // k10
     {8909899.0 / 18653125.0, 0.0, 0.0,
-     (-4521408.0 - 1137963.0 * Math.sqrt(6.0)) / 2937500.0,
-     (-4521408.0 + 1137963.0 * Math.sqrt(6.0)) / 2937500.0,
+     (-4521408.0 - 1137963.0 * FastMath.sqrt(6.0)) / 2937500.0,
+     (-4521408.0 + 1137963.0 * FastMath.sqrt(6.0)) / 2937500.0,
      96663078.0 / 4553125.0, 2107245056.0 / 137915625.0,
      -4913652016.0 / 147609375.0, -78894270.0 / 3880452869.0},
 
     // k11
     {-20401265806.0 / 21769653311.0, 0.0, 0.0,
-     (354216.0 + 94326.0 * Math.sqrt(6.0)) / 112847.0,
-     (354216.0 - 94326.0 * Math.sqrt(6.0)) / 112847.0,
+     (354216.0 + 94326.0 * FastMath.sqrt(6.0)) / 112847.0,
+     (354216.0 - 94326.0 * FastMath.sqrt(6.0)) / 112847.0,
      -43306765128.0 / 5313852383.0, -20866708358144.0 / 1126708119789.0,
      14886003438020.0 / 654632330667.0, 35290686222309375.0 / 14152473387134411.0,
      -1477884375.0 / 485066827.0},
 
     // k12
     {39815761.0 / 17514443.0, 0.0, 0.0,
-     (-3457480.0 - 960905.0 * Math.sqrt(6.0)) / 551636.0,
-     (-3457480.0 + 960905.0 * Math.sqrt(6.0)) / 551636.0,
+     (-3457480.0 - 960905.0 * FastMath.sqrt(6.0)) / 551636.0,
+     (-3457480.0 + 960905.0 * FastMath.sqrt(6.0)) / 551636.0,
      -844554132.0 / 47026969.0, 8444996352.0 / 302158619.0,
      -2509602342.0 / 877790785.0, -28388795297996250.0 / 3199510091356783.0,
      226716250.0 / 18341897.0, 1371316744.0 / 2131383595.0},
@@ -259,7 +261,7 @@ public class DormandPrince853Integrator 
                              E2_09 * yDotK[8][j]  + E2_10 * yDotK[9][j] +
                              E2_11 * yDotK[10][j] + E2_12 * yDotK[11][j];
 
-      final double yScale = Math.max(Math.abs(y0[j]), Math.abs(y1[j]));
+      final double yScale = FastMath.max(FastMath.abs(y0[j]), FastMath.abs(y1[j]));
       final double tol = (vecAbsoluteTolerance == null) ?
                          (scalAbsoluteTolerance + scalRelativeTolerance * yScale) :
                          (vecAbsoluteTolerance[j] + vecRelativeTolerance[j] * yScale);
@@ -274,7 +276,7 @@ public class DormandPrince853Integrator 
       den = 1.0;
     }
 
-    return Math.abs(h) * error1 / Math.sqrt(mainSetDimension * den);
+    return FastMath.abs(h) * error1 / FastMath.sqrt(mainSetDimension * den);
 
   }
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java?rev=990658&r1=990657&r2=990658&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java Sun Aug 29 22:04:09 2010
@@ -24,6 +24,7 @@ import org.apache.commons.math.ode.event
 import org.apache.commons.math.ode.sampling.AbstractStepInterpolator;
 import org.apache.commons.math.ode.sampling.DummyStepInterpolator;
 import org.apache.commons.math.ode.sampling.StepHandler;
+import org.apache.commons.math.util.FastMath;
 
 /**
  * This class implements the common part of all embedded Runge-Kutta
@@ -245,11 +246,11 @@ public abstract class EmbeddedRungeKutta
           final double[] scale = new double[mainSetDimension];
           if (vecAbsoluteTolerance == null) {
               for (int i = 0; i < scale.length; ++i) {
-                scale[i] = scalAbsoluteTolerance + scalRelativeTolerance * Math.abs(y[i]);
+                scale[i] = scalAbsoluteTolerance + scalRelativeTolerance * FastMath.abs(y[i]);
               }
             } else {
               for (int i = 0; i < scale.length; ++i) {
-                scale[i] = vecAbsoluteTolerance[i] + vecRelativeTolerance[i] * Math.abs(y[i]);
+                scale[i] = vecAbsoluteTolerance[i] + vecRelativeTolerance[i] * FastMath.abs(y[i]);
               }
             }
           hNew = initializeStep(equations, forward, getOrder(), scale,
@@ -291,7 +292,7 @@ public abstract class EmbeddedRungeKutta
           interpolator.storeTime(stepStart + stepSize);
           if (manager.evaluateStep(interpolator)) {
               final double dt = manager.getEventTime() - stepStart;
-              if (Math.abs(dt) <= Math.ulp(stepStart)) {
+              if (FastMath.abs(dt) <= FastMath.ulp(stepStart)) {
                   // we cannot simply truncate the step, reject the current computation
                   // and let the loop compute another state with the truncated step.
                   // it is so small (much probably exactly 0 due to limited accuracy)
@@ -314,8 +315,8 @@ public abstract class EmbeddedRungeKutta
         } else {
           // reject the step and attempt to reduce error by stepsize control
           final double factor =
-              Math.min(maxGrowth,
-                       Math.max(minReduction, safety * Math.pow(error, exp)));
+              FastMath.min(maxGrowth,
+                       FastMath.max(minReduction, safety * FastMath.pow(error, exp)));
           hNew = filterStep(stepSize * factor, forward, false);
         }
 
@@ -352,9 +353,9 @@ public abstract class EmbeddedRungeKutta
           stepSize = filterStep(stepSize, forward, true);
 
         // stepsize control for next step
-        final double factor = Math.min(maxGrowth,
-                                       Math.max(minReduction,
-                                                safety * Math.pow(error, exp)));
+        final double factor = FastMath.min(maxGrowth,
+                                       FastMath.max(minReduction,
+                                                safety * FastMath.pow(error, exp)));
         final double  scaledH    = stepSize * factor;
         final double  nextT      = stepStart + scaledH;
         final boolean nextIsLast = forward ? (nextT >= t) : (nextT <= t);



Mime
View raw message