Repository: commons-math
Updated Branches:
  refs/heads/master 9575054ff -> 9036edd6d


Reverted commit about mapping functions in MathArrays.

As discussed on the mailing list, the same result can be obtained with
existing higher level API, for example:

  new ArrayRealVector(array, false).map(f).toArray();


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/70538e67
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/70538e67
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/70538e67

Branch: refs/heads/master
Commit: 70538e67fba268e0734a77494849629acaa05423
Parents: 9575054
Author: Luc Maisonobe <l...@apache.org>
Authored: Mon Jul 6 20:33:37 2015 +0200
Committer: Luc Maisonobe <l...@apache.org>
Committed: Mon Jul 6 20:33:37 2015 +0200

----------------------------------------------------------------------
 src/changes/changes.xml                         |  4 --
 .../apache/commons/math4/util/MathArrays.java   | 71 --------------------
 .../commons/math4/util/MathArraysTest.java      | 34 +---------
 3 files changed, 1 insertion(+), 108 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/70538e67/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index b3bc225..9347ca5 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -70,10 +70,6 @@ If the output is not quite correct, check for invisible 
trailing spaces!
         These can be useful to manage an OutOfRangeException without the need 
to access
         the original x and y arrays.
       </action>
-      <action dev="luc" type="add" >
-        Added mapping functions to MathArrays. These methods allow to map
-        any univariate or bivariate functions to arrays.
-      </action>
       <action dev="tn" type="fix" issue="MATH-1240"> <!-- backported to 3.6 -->
         "KolmogorovSmirnovTest#ksSum(...)" returned wrong result in case the 
provided
         t-parameters was zero. This affected the calculation of 
"approximateP(...)" for

http://git-wip-us.apache.org/repos/asf/commons-math/blob/70538e67/src/main/java/org/apache/commons/math4/util/MathArrays.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/util/MathArrays.java 
b/src/main/java/org/apache/commons/math4/util/MathArrays.java
index 47e9484..29a8c37 100644
--- a/src/main/java/org/apache/commons/math4/util/MathArrays.java
+++ b/src/main/java/org/apache/commons/math4/util/MathArrays.java
@@ -25,8 +25,6 @@ import java.util.Comparator;
 import java.util.List;
 
 import org.apache.commons.math4.Field;
-import org.apache.commons.math4.analysis.BivariateFunction;
-import org.apache.commons.math4.analysis.UnivariateFunction;
 import org.apache.commons.math4.distribution.UniformIntegerDistribution;
 import org.apache.commons.math4.exception.DimensionMismatchException;
 import org.apache.commons.math4.exception.MathArithmeticException;
@@ -111,75 +109,6 @@ public class MathArrays {
 
     /**
      * Creates an array whose contents will be the element-by-element
-     * mapping of the function to argument.
-     *
-     * @param f function to map on elements
-     * @param a array of function parameters.
-     * @return a new array {@code r} where {@code r[i] = f(a[i])}.
-     * @since 4.0
-     */
-    public static double[] map(final UnivariateFunction f, final double[] a) {
-
-        final double[] result = new double[a.length];
-        for (int i = 0; i < result.length; ++i) {
-            result[i] = f.value(a[i]);
-        }
-
-        return result;
-
-    }
-
-    /**
-     * Creates an array whose contents will be the element-by-element
-     * mapping of the function to arguments.
-     *
-     * @param f function to map on elements
-     * @param a array of first parameters of the function.
-     * @param b array of second parameters of the function.
-     * @return a new array {@code r} where {@code r[i] = f(a[i], b[i])}.
-     * @throws DimensionMismatchException if the array lengths differ.
-     * @since 4.0
-     */
-    public static double[] map(final BivariateFunction f,
-                               final double[] a, final double[] b) {
-
-        if (a.length != b.length) {
-            throw new DimensionMismatchException(a.length, b.length);
-        }
-
-        final double[] result = new double[a.length];
-        for (int i = 0; i < result.length; ++i) {
-            result[i] = f.value(a[i], b[i]);
-        }
-
-        return result;
-
-    }
-
-    /**
-     * Creates an array whose contents will be the element-by-element
-     * mapping of the function to arguments.
-     *
-     * @param f function to map on elements
-     * @param a array of first parameters of the function.
-     * @param b fixed value for second function parameter.
-     * @return a new array {@code r} where {@code r[i] = f(a[i])}.
-     * @since 4.0
-     */
-    public static double[] map(final BivariateFunction f,
-                               final double[] a, final double b) {
-
-        final double[] result = new double[a.length];
-        for (int i = 0; i < result.length; ++i) {
-            result[i] = f.value(a[i], b);
-        }
-
-        return result;
-
-    }
-
-    /**
-     * Creates an array whose contents will be the element-by-element
      * addition of the arguments.
      *
      * @param a First term of the addition.

http://git-wip-us.apache.org/repos/asf/commons-math/blob/70538e67/src/test/java/org/apache/commons/math4/util/MathArraysTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/util/MathArraysTest.java 
b/src/test/java/org/apache/commons/math4/util/MathArraysTest.java
index e71851d..9b837e0 100644
--- a/src/test/java/org/apache/commons/math4/util/MathArraysTest.java
+++ b/src/test/java/org/apache/commons/math4/util/MathArraysTest.java
@@ -16,8 +16,6 @@ package org.apache.commons.math4.util;
 import java.util.Arrays;
 
 import org.apache.commons.math4.TestUtils;
-import org.apache.commons.math4.analysis.function.Abs;
-import org.apache.commons.math4.analysis.function.Add;
 import org.apache.commons.math4.exception.DimensionMismatchException;
 import org.apache.commons.math4.exception.MathArithmeticException;
 import org.apache.commons.math4.exception.MathIllegalArgumentException;
@@ -76,37 +74,7 @@ public class MathArraysTest {
             Assert.assertEquals(correctScaled[i], test[i], 0);
         }
     }
-
-    @Test
-    public void testMapUnivariate() {
-        final double[] expected = new double[] { 1, 2, 4, 8 };
-        final double[] observed =
-            MathArrays.map(new Abs(), new double[] { 1, -2, -4, 8});
-        TestUtils.assertEquals(expected, observed, 1.0e-15);
-    }
-
-    @Test
-    public void testMapBivariateTwoArrays() {
-        final double[] expected = new double[] { 1, 3, 6, 11 };
-        final double[] observed =
-            MathArrays.map(new Add(),
-                           new double[] { 1, 2, 4, 8}, new double[] { 0, 1, 2, 
3});
-        TestUtils.assertEquals(expected, observed, 1.0e-15);
-    }
-
-    @Test
-    public void testMapBivariateOneArray() {
-        final double[] expected = new double[] { 3.5, 4.5, 6.5, 10.5 };
-        final double[] observed =
-            MathArrays.map(new Add(), new double[] { 1, 2, 4, 8}, 2.5);
-        TestUtils.assertEquals(expected, observed, 1.0e-15);
-    }
-
-    @Test(expected=DimensionMismatchException.class)
-    public void testMapBivariatePrecondition() {
-        MathArrays.map(new Add(), new double[3], new double[4]);
-    }
-
+    
     @Test(expected=DimensionMismatchException.class)
     public void testEbeAddPrecondition() {
         MathArrays.ebeAdd(new double[3], new double[4]);

Reply via email to