diff --git a/org/apache/commons/math/analysis/UnivariateRealFunctionProxy.java b/org/apache/commons/math/analysis/UnivariateRealFunctionProxy.java
new file mode 100644
index 000000000..538c3d246
--- /dev/null
+++ b/org/apache/commons/math/analysis/UnivariateRealFunctionProxy.java
@@ -0,0 +1,88 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowledgement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgement may appear in the software itself,
+ * if and wherever such third-party acknowledgements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their name without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ */
+
+package org.apache.commons.math.analysis;
+
+/**
+ * @todo add javadoc comment
+ * @version $Revision: 1.1 $ $Date: 2003/11/22 05:59:31 $
+ */
+public abstract class UnivariateRealFunctionProxy
+ implements UnivariateRealFunction {
+
+ private UnivariateRealFunction function;
+
+ /**
+ * @todo add javadoc comment
+ */
+ public UnivariateRealFunctionProxy(UnivariateRealFunction function) {
+ super();
+ setFunction(function);
+ }
+
+ /**
+ * @todo add javadoc comment
+ */
+ protected UnivariateRealFunction getFunction() {
+ return function;
+ }
+
+ /**
+ * @todo add javadoc comment
+ */
+ private void setFunction(UnivariateRealFunction function) {
+ this.function = function;
+ }
+
+}
diff --git a/org/apache/commons/math/analysis/UnivariateRealFunctionUtils.java b/org/apache/commons/math/analysis/UnivariateRealFunctionUtils.java
new file mode 100644
index 000000000..09a99f54c
--- /dev/null
+++ b/org/apache/commons/math/analysis/UnivariateRealFunctionUtils.java
@@ -0,0 +1,85 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowledgement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgement may appear in the software itself,
+ * if and wherever such third-party acknowledgements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their name without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ */
+
+package org.apache.commons.math.analysis;
+
+import org.apache.commons.math.analysis.derivative.BackwardDifferenceDerivative;
+import org.apache.commons.math.analysis.derivative.CenterDifferenceDerivative;
+import org.apache.commons.math.analysis.derivative.ForwardDifferenceDerivative;
+
+/**
+ * @todo add javadoc comment
+ * @version $Revision: 1.1 $ $Date: 2003/11/22 05:59:31 $
+ */
+public class UnivariateRealFunctionUtils {
+
+ /**
+ * @todo add javadoc comment
+ */
+ private UnivariateRealFunctionUtils() {
+ super();
+ }
+
+ public static UnivariateRealFunction backwardDifferenceDerivative(UnivariateRealFunction function, double delta) {
+ return BackwardDifferenceDerivative.decorate(function, delta);
+ }
+
+ public static UnivariateRealFunction centerDifferenceDerivative(UnivariateRealFunction function, double delta) {
+ return CenterDifferenceDerivative.decorate(function, delta);
+ }
+
+ public static UnivariateRealFunction forwardDifferenceDerivative(UnivariateRealFunction function, double delta) {
+ return ForwardDifferenceDerivative.decorate(function, delta);
+ }
+}
diff --git a/org/apache/commons/math/analysis/UnivariateRealFunctionUtilsTest.java b/org/apache/commons/math/analysis/UnivariateRealFunctionUtilsTest.java
new file mode 100644
index 000000000..2231b0a2e
--- /dev/null
+++ b/org/apache/commons/math/analysis/UnivariateRealFunctionUtilsTest.java
@@ -0,0 +1,102 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowledgement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgement may appear in the software itself,
+ * if and wherever such third-party acknowledgements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their name without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ */
+
+package org.apache.commons.math.analysis;
+
+import junit.framework.TestCase;
+
+/**
+ * @todo add javadoc comment
+ * @version $Revision: 1.1 $ $Date: 2003/11/22 05:59:31 $
+ */
+public class UnivariateRealFunctionUtilsTest extends TestCase {
+ /**
+ *
+ */
+ public void testLocalMaximumCentered() {
+ UnivariateRealFunction function = new SinFunction();
+ UnivariateRealFunction derivative = UnivariateRealFunctionUtils.centerDifferenceDerivative(function, 1.0e-5);
+ testLocalMaximum(derivative);
+ }
+
+ /**
+ *
+ */
+ public void testLocalMaximumForward() {
+ UnivariateRealFunction function = new SinFunction();
+ UnivariateRealFunction derivative = UnivariateRealFunctionUtils.forwardDifferenceDerivative(function, 1.0e-5);
+ testLocalMaximum(derivative);
+ }
+
+ /**
+ *
+ */
+ public void testLocalMaximumBackward() {
+ UnivariateRealFunction function = new SinFunction();
+ UnivariateRealFunction derivative = UnivariateRealFunctionUtils.backwardDifferenceDerivative(function, 1.0e-5);
+ testLocalMaximum(derivative);
+ }
+
+ /**
+ * Find a local extrema, i.e. f'(x) = 0.
+ */
+ private void testLocalMaximum(UnivariateRealFunction derivative) {
+ try {
+ double maximum = UnivariateRealSolverUtils.solve(derivative, Math.PI / 3.0, Math.PI * 2.0 / 3.0);
+ assertEquals(maximum, Math.PI / 2.0, 1.0e-5);
+ } catch (Exception ex) {
+ fail(ex.getMessage());
+ }
+ }
+}
diff --git a/org/apache/commons/math/analysis/derivative/AbstractDifferenceDerivative.java b/org/apache/commons/math/analysis/derivative/AbstractDifferenceDerivative.java
new file mode 100644
index 000000000..e8efcf14b
--- /dev/null
+++ b/org/apache/commons/math/analysis/derivative/AbstractDifferenceDerivative.java
@@ -0,0 +1,83 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowledgement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgement may appear in the software itself,
+ * if and wherever such third-party acknowledgements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their name without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ */
+
+package org.apache.commons.math.analysis.derivative;
+
+import org.apache.commons.math.analysis.UnivariateRealFunction;
+import org.apache.commons.math.analysis.UnivariateRealFunctionProxy;
+
+/**
+ * @todo add javadoc comment
+ * @version $Revision: 1.1 $ $Date: 2003/11/22 05:59:31 $
+ */
+public abstract class AbstractDifferenceDerivative extends UnivariateRealFunctionProxy implements UnivariateRealFunction {
+ /** */
+ private double delta;
+
+ /**
+ * @todo add javadoc comment
+ */
+ public AbstractDifferenceDerivative(UnivariateRealFunction function, double h) {
+ super(function);
+ setDelta(h);
+ }
+
+ private void setDelta(double h) {
+ this.delta = h;
+ }
+
+ protected double getDelta() {
+ return delta;
+ }
+}
diff --git a/org/apache/commons/math/analysis/derivative/BackwardDifferenceDerivative.java b/org/apache/commons/math/analysis/derivative/BackwardDifferenceDerivative.java
new file mode 100644
index 000000000..075c10551
--- /dev/null
+++ b/org/apache/commons/math/analysis/derivative/BackwardDifferenceDerivative.java
@@ -0,0 +1,88 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowledgement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgement may appear in the software itself,
+ * if and wherever such third-party acknowledgements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their name without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ */
+
+package org.apache.commons.math.analysis.derivative;
+
+import org.apache.commons.math.MathException;
+import org.apache.commons.math.analysis.UnivariateRealFunction;
+
+/**
+ * @todo add javadoc comment
+ * @version $Revision: 1.1 $ $Date: 2003/11/22 05:59:31 $
+ */
+public class BackwardDifferenceDerivative extends AbstractDifferenceDerivative {
+
+ /**
+ * @todo add javadoc comment
+ */
+ public BackwardDifferenceDerivative(UnivariateRealFunction function, double h) {
+ super(function, h);
+ }
+
+ /**
+ * @todo add javadoc comment
+ */
+ public double value(double x) throws MathException {
+ UnivariateRealFunction f = getFunction();
+ double h = getDelta();
+ return (f.value(x) - f.value(x - h)) / h;
+ }
+
+ /**
+ *
+ */
+ public static UnivariateRealFunction decorate(UnivariateRealFunction function, double h) {
+ return new BackwardDifferenceDerivative(function, h);
+ }
+}
diff --git a/org/apache/commons/math/analysis/derivative/CenterDifferenceDerivative.java b/org/apache/commons/math/analysis/derivative/CenterDifferenceDerivative.java
new file mode 100644
index 000000000..05a70f54e
--- /dev/null
+++ b/org/apache/commons/math/analysis/derivative/CenterDifferenceDerivative.java
@@ -0,0 +1,89 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowledgement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgement may appear in the software itself,
+ * if and wherever such third-party acknowledgements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their name without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ */
+
+package org.apache.commons.math.analysis.derivative;
+
+import org.apache.commons.math.MathException;
+import org.apache.commons.math.analysis.UnivariateRealFunction;
+
+/**
+ * @todo add javadoc comment
+ * @version $Revision: 1.1 $ $Date: 2003/11/22 05:59:31 $
+ */
+public class CenterDifferenceDerivative extends AbstractDifferenceDerivative {
+
+ /**
+ * @todo add javadoc comment
+ */
+ public CenterDifferenceDerivative(UnivariateRealFunction function, double h) {
+ super(function, h);
+ }
+
+ /**
+ * @todo add javadoc comment
+ */
+ public double value(double x) throws MathException {
+ UnivariateRealFunction f = getFunction();
+ double h2 = getDelta();
+ double h = h2 * .5;
+ return (f.value(x + h) - f.value(x - h)) / h2;
+ }
+
+ /**
+ *
+ */
+ public static UnivariateRealFunction decorate(UnivariateRealFunction function, double h) {
+ return new CenterDifferenceDerivative(function, h);
+ }
+}
diff --git a/org/apache/commons/math/analysis/derivative/ForwardDifferenceDerivative.java b/org/apache/commons/math/analysis/derivative/ForwardDifferenceDerivative.java
new file mode 100644
index 000000000..bba16693b
--- /dev/null
+++ b/org/apache/commons/math/analysis/derivative/ForwardDifferenceDerivative.java
@@ -0,0 +1,88 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowledgement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgement may appear in the software itself,
+ * if and wherever such third-party acknowledgements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their name without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ */
+
+package org.apache.commons.math.analysis.derivative;
+
+import org.apache.commons.math.MathException;
+import org.apache.commons.math.analysis.UnivariateRealFunction;
+
+/**
+ * @todo add javadoc comment
+ * @version $Revision: 1.1 $ $Date: 2003/11/22 05:59:31 $
+ */
+public class ForwardDifferenceDerivative extends AbstractDifferenceDerivative {
+
+ /**
+ * @todo add javadoc comment
+ */
+ public ForwardDifferenceDerivative(UnivariateRealFunction function, double h) {
+ super(function, h);
+ }
+
+ /**
+ * @todo add javadoc comment
+ */
+ public double value(double x) throws MathException {
+ UnivariateRealFunction f = getFunction();
+ double h = getDelta();
+ return (f.value(x + h) - f.value(x)) / h;
+ }
+
+ /**
+ *
+ */
+ public static UnivariateRealFunction decorate(UnivariateRealFunction function, double h) {
+ return new ForwardDifferenceDerivative(function, h);
+ }
+}
diff --git a/org/apache/commons/math/linear/Decomposer.java b/org/apache/commons/math/linear/Decomposer.java
index 228d28078..764b1ded9 100644
--- a/org/apache/commons/math/linear/Decomposer.java
+++ b/org/apache/commons/math/linear/Decomposer.java
@@ -14,6 +14,6 @@ package org.apache.commons.math.linear;
*/
public interface Decomposer {
- Decomposition decompose(RealMatrix);
+ Decomposition decompose(RealMatrix matrix);
}