http://git-wip-us.apache.org/repos/asf/commons-math/blob/a7b4803f/src/main/java/org/apache/commons/math3/Field.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/Field.java b/src/main/java/org/apache/commons/math3/Field.java deleted file mode 100644 index 618536c..0000000 --- a/src/main/java/org/apache/commons/math3/Field.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.math3; - -/** - * Interface representing a <a href="http://mathworld.wolfram.com/Field.html">field</a>. - * <p> - * Classes implementing this interface will often be singletons. - * </p> - * @param <T> the type of the field elements - * @see FieldElement - * @since 2.0 - */ -public interface Field<T> { - - /** Get the additive identity of the field. - * <p> - * The additive identity is the element e<sub>0</sub> of the field such that - * for all elements a of the field, the equalities a + e<sub>0</sub> = - * e<sub>0</sub> + a = a hold. - * </p> - * @return additive identity of the field - */ - T getZero(); - - /** Get the multiplicative identity of the field. - * <p> - * The multiplicative identity is the element e<sub>1</sub> of the field such that - * for all elements a of the field, the equalities a × e<sub>1</sub> = - * e<sub>1</sub> × a = a hold. - * </p> - * @return multiplicative identity of the field - */ - T getOne(); - - /** - * Returns the runtime class of the FieldElement. - * - * @return The {@code Class} object that represents the runtime - * class of this object. - */ - Class<? extends FieldElement<T>> getRuntimeClass(); - -}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/a7b4803f/src/main/java/org/apache/commons/math3/FieldElement.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/FieldElement.java b/src/main/java/org/apache/commons/math3/FieldElement.java deleted file mode 100644 index 8a7533a..0000000 --- a/src/main/java/org/apache/commons/math3/FieldElement.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.math3; - -import org.apache.commons.math3.exception.MathArithmeticException; -import org.apache.commons.math3.exception.NullArgumentException; - - -/** - * Interface representing <a href="http://mathworld.wolfram.com/Field.html">field</a> elements. - * @param <T> the type of the field elements - * @see Field - * @since 2.0 - */ -public interface FieldElement<T> { - - /** Compute this + a. - * @param a element to add - * @return a new element representing this + a - * @throws NullArgumentException if {@code addend} is {@code null}. - */ - T add(T a) throws NullArgumentException; - - /** Compute this - a. - * @param a element to subtract - * @return a new element representing this - a - * @throws NullArgumentException if {@code a} is {@code null}. - */ - T subtract(T a) throws NullArgumentException; - - /** - * Returns the additive inverse of {@code this} element. - * @return the opposite of {@code this}. - */ - T negate(); - - /** Compute n × this. Multiplication by an integer number is defined - * as the following sum - * <center> - * n × this = ∑<sub>i=1</sub><sup>n</sup> this. - * </center> - * @param n Number of times {@code this} must be added to itself. - * @return A new element representing n × this. - */ - T multiply(int n); - - /** Compute this × a. - * @param a element to multiply - * @return a new element representing this × a - * @throws NullArgumentException if {@code a} is {@code null}. - */ - T multiply(T a) throws NullArgumentException; - - /** Compute this ÷ a. - * @param a element to add - * @return a new element representing this ÷ a - * @throws NullArgumentException if {@code a} is {@code null}. - * @throws MathArithmeticException if {@code a} is zero - */ - T divide(T a) throws NullArgumentException, MathArithmeticException; - - /** - * Returns the multiplicative inverse of {@code this} element. - * @return the inverse of {@code this}. - * @throws MathArithmeticException if {@code this} is zero - */ - T reciprocal() throws MathArithmeticException; - - /** Get the {@link Field} to which the instance belongs. - * @return {@link Field} to which the instance belongs - */ - Field<T> getField(); -} http://git-wip-us.apache.org/repos/asf/commons-math/blob/a7b4803f/src/main/java/org/apache/commons/math3/RealFieldElement.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/RealFieldElement.java b/src/main/java/org/apache/commons/math3/RealFieldElement.java deleted file mode 100644 index 0e54ba1..0000000 --- a/src/main/java/org/apache/commons/math3/RealFieldElement.java +++ /dev/null @@ -1,402 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.math3; - -import org.apache.commons.math3.exception.DimensionMismatchException; - -/** - * Interface representing a <a href="http://mathworld.wolfram.com/RealNumber.html">real</a> - * <a href="http://mathworld.wolfram.com/Field.html">field</a>. - * @param <T> the type of the field elements - * @see FieldElement - * @since 3.2 - */ -public interface RealFieldElement<T> extends FieldElement<T> { - - /** Get the real value of the number. - * @return real value - */ - double getReal(); - - /** '+' operator. - * @param a right hand side parameter of the operator - * @return this+a - */ - T add(double a); - - /** '-' operator. - * @param a right hand side parameter of the operator - * @return this-a - */ - T subtract(double a); - - /** '×' operator. - * @param a right hand side parameter of the operator - * @return this×a - */ - T multiply(double a); - - /** '÷' operator. - * @param a right hand side parameter of the operator - * @return this÷s;a - */ - T divide(double a); - - /** IEEE remainder operator. - * @param a right hand side parameter of the operator - * @return this - n × a where n is the closest integer to this/a - * (the even integer is chosen for n if this/a is halfway between two integers) - */ - T remainder(double a); - - /** IEEE remainder operator. - * @param a right hand side parameter of the operator - * @return this - n × a where n is the closest integer to this/a - * (the even integer is chosen for n if this/a is halfway between two integers) - * @exception DimensionMismatchException if number of free parameters or orders are inconsistent - */ - T remainder(T a) - throws DimensionMismatchException; - - /** absolute value. - * @return abs(this) - */ - T abs(); - - /** Get the smallest whole number larger than instance. - * @return ceil(this) - */ - T ceil(); - - /** Get the largest whole number smaller than instance. - * @return floor(this) - */ - T floor(); - - /** Get the whole number that is the nearest to the instance, or the even one if x is exactly half way between two integers. - * @return a double number r such that r is an integer r - 0.5 <= this <= r + 0.5 - */ - T rint(); - - /** Get the closest long to instance value. - * @return closest long to {@link #getReal()} - */ - long round(); - - /** Compute the signum of the instance. - * The signum is -1 for negative numbers, +1 for positive numbers and 0 otherwise - * @return -1.0, -0.0, +0.0, +1.0 or NaN depending on sign of a - */ - T signum(); - - /** - * Returns the instance with the sign of the argument. - * A NaN {@code sign} argument is treated as positive. - * - * @param sign the sign for the returned value - * @return the instance with the same sign as the {@code sign} argument - */ - T copySign(T sign); - - /** - * Returns the instance with the sign of the argument. - * A NaN {@code sign} argument is treated as positive. - * - * @param sign the sign for the returned value - * @return the instance with the same sign as the {@code sign} argument - */ - T copySign(double sign); - - /** - * Multiply the instance by a power of 2. - * @param n power of 2 - * @return this × 2<sup>n</sup> - */ - T scalb(int n); - - /** - * Returns the hypotenuse of a triangle with sides {@code this} and {@code y} - * - sqrt(<i>this</i><sup>2</sup> +<i>y</i><sup>2</sup>)<br/> - * avoiding intermediate overflow or underflow. - * - * <ul> - * <li> If either argument is infinite, then the result is positive infinity.</li> - * <li> else, if either argument is NaN then the result is NaN.</li> - * </ul> - * - * @param y a value - * @return sqrt(<i>this</i><sup>2</sup> +<i>y</i><sup>2</sup>) - * @exception DimensionMismatchException if number of free parameters or orders are inconsistent - */ - T hypot(T y) - throws DimensionMismatchException; - - /** {@inheritDoc} */ - T reciprocal(); - - /** Square root. - * @return square root of the instance - */ - T sqrt(); - - /** Cubic root. - * @return cubic root of the instance - */ - T cbrt(); - - /** N<sup>th</sup> root. - * @param n order of the root - * @return n<sup>th</sup> root of the instance - */ - T rootN(int n); - - /** Power operation. - * @param p power to apply - * @return this<sup>p</sup> - */ - T pow(double p); - - /** Integer power operation. - * @param n power to apply - * @return this<sup>n</sup> - */ - T pow(int n); - - /** Power operation. - * @param e exponent - * @return this<sup>e</sup> - * @exception DimensionMismatchException if number of free parameters or orders are inconsistent - */ - T pow(T e) - throws DimensionMismatchException; - - /** Exponential. - * @return exponential of the instance - */ - T exp(); - - /** Exponential minus 1. - * @return exponential minus one of the instance - */ - T expm1(); - - /** Natural logarithm. - * @return logarithm of the instance - */ - T log(); - - /** Shifted natural logarithm. - * @return logarithm of one plus the instance - */ - T log1p(); - -// TODO: add this method in 4.0, as it is not possible to do it in 3.2 -// due to incompatibility of the return type in the Dfp class -// /** Base 10 logarithm. -// * @return base 10 logarithm of the instance -// */ -// T log10(); - - /** Cosine operation. - * @return cos(this) - */ - T cos(); - - /** Sine operation. - * @return sin(this) - */ - T sin(); - - /** Tangent operation. - * @return tan(this) - */ - T tan(); - - /** Arc cosine operation. - * @return acos(this) - */ - T acos(); - - /** Arc sine operation. - * @return asin(this) - */ - T asin(); - - /** Arc tangent operation. - * @return atan(this) - */ - T atan(); - - /** Two arguments arc tangent operation. - * @param x second argument of the arc tangent - * @return atan2(this, x) - * @exception DimensionMismatchException if number of free parameters or orders are inconsistent - */ - T atan2(T x) - throws DimensionMismatchException; - - /** Hyperbolic cosine operation. - * @return cosh(this) - */ - T cosh(); - - /** Hyperbolic sine operation. - * @return sinh(this) - */ - T sinh(); - - /** Hyperbolic tangent operation. - * @return tanh(this) - */ - T tanh(); - - /** Inverse hyperbolic cosine operation. - * @return acosh(this) - */ - T acosh(); - - /** Inverse hyperbolic sine operation. - * @return asin(this) - */ - T asinh(); - - /** Inverse hyperbolic tangent operation. - * @return atanh(this) - */ - T atanh(); - - /** - * Compute a linear combination. - * @param a Factors. - * @param b Factors. - * @return <code>Σ<sub>i</sub> a<sub>i</sub> b<sub>i</sub></code>. - * @throws DimensionMismatchException if arrays dimensions don't match - * @since 3.2 - */ - T linearCombination(T[] a, T[] b) - throws DimensionMismatchException; - - /** - * Compute a linear combination. - * @param a Factors. - * @param b Factors. - * @return <code>Σ<sub>i</sub> a<sub>i</sub> b<sub>i</sub></code>. - * @throws DimensionMismatchException if arrays dimensions don't match - * @since 3.2 - */ - T linearCombination(double[] a, T[] b) - throws DimensionMismatchException; - - /** - * Compute a linear combination. - * @param a1 first factor of the first term - * @param b1 second factor of the first term - * @param a2 first factor of the second term - * @param b2 second factor of the second term - * @return a<sub>1</sub>×b<sub>1</sub> + - * a<sub>2</sub>×b<sub>2</sub> - * @see #linearCombination(Object, Object, Object, Object, Object, Object) - * @see #linearCombination(Object, Object, Object, Object, Object, Object, Object, Object) - * @since 3.2 - */ - T linearCombination(T a1, T b1, T a2, T b2); - - /** - * Compute a linear combination. - * @param a1 first factor of the first term - * @param b1 second factor of the first term - * @param a2 first factor of the second term - * @param b2 second factor of the second term - * @return a<sub>1</sub>×b<sub>1</sub> + - * a<sub>2</sub>×b<sub>2</sub> - * @see #linearCombination(double, Object, double, Object, double, Object) - * @see #linearCombination(double, Object, double, Object, double, Object, double, Object) - * @since 3.2 - */ - T linearCombination(double a1, T b1, double a2, T b2); - - /** - * Compute a linear combination. - * @param a1 first factor of the first term - * @param b1 second factor of the first term - * @param a2 first factor of the second term - * @param b2 second factor of the second term - * @param a3 first factor of the third term - * @param b3 second factor of the third term - * @return a<sub>1</sub>×b<sub>1</sub> + - * a<sub>2</sub>×b<sub>2</sub> + a<sub>3</sub>×b<sub>3</sub> - * @see #linearCombination(Object, Object, Object, Object) - * @see #linearCombination(Object, Object, Object, Object, Object, Object, Object, Object) - * @since 3.2 - */ - T linearCombination(T a1, T b1, T a2, T b2, T a3, T b3); - - /** - * Compute a linear combination. - * @param a1 first factor of the first term - * @param b1 second factor of the first term - * @param a2 first factor of the second term - * @param b2 second factor of the second term - * @param a3 first factor of the third term - * @param b3 second factor of the third term - * @return a<sub>1</sub>×b<sub>1</sub> + - * a<sub>2</sub>×b<sub>2</sub> + a<sub>3</sub>×b<sub>3</sub> - * @see #linearCombination(double, Object, double, Object) - * @see #linearCombination(double, Object, double, Object, double, Object, double, Object) - * @since 3.2 - */ - T linearCombination(double a1, T b1, double a2, T b2, double a3, T b3); - - /** - * Compute a linear combination. - * @param a1 first factor of the first term - * @param b1 second factor of the first term - * @param a2 first factor of the second term - * @param b2 second factor of the second term - * @param a3 first factor of the third term - * @param b3 second factor of the third term - * @param a4 first factor of the third term - * @param b4 second factor of the third term - * @return a<sub>1</sub>×b<sub>1</sub> + - * a<sub>2</sub>×b<sub>2</sub> + a<sub>3</sub>×b<sub>3</sub> + - * a<sub>4</sub>×b<sub>4</sub> - * @see #linearCombination(Object, Object, Object, Object) - * @see #linearCombination(Object, Object, Object, Object, Object, Object) - * @since 3.2 - */ - T linearCombination(T a1, T b1, T a2, T b2, T a3, T b3, T a4, T b4); - - /** - * Compute a linear combination. - * @param a1 first factor of the first term - * @param b1 second factor of the first term - * @param a2 first factor of the second term - * @param b2 second factor of the second term - * @param a3 first factor of the third term - * @param b3 second factor of the third term - * @param a4 first factor of the third term - * @param b4 second factor of the third term - * @return a<sub>1</sub>×b<sub>1</sub> + - * a<sub>2</sub>×b<sub>2</sub> + a<sub>3</sub>×b<sub>3</sub> + - * a<sub>4</sub>×b<sub>4</sub> - * @see #linearCombination(double, Object, double, Object) - * @see #linearCombination(double, Object, double, Object, double, Object) - * @since 3.2 - */ - T linearCombination(double a1, T b1, double a2, T b2, double a3, T b3, double a4, T b4); - -} http://git-wip-us.apache.org/repos/asf/commons-math/blob/a7b4803f/src/main/java/org/apache/commons/math3/analysis/BivariateFunction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/analysis/BivariateFunction.java b/src/main/java/org/apache/commons/math3/analysis/BivariateFunction.java deleted file mode 100644 index d8aaca5..0000000 --- a/src/main/java/org/apache/commons/math3/analysis/BivariateFunction.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.commons.math3.analysis; - -/** - * An interface representing a bivariate real function. - * - * @since 2.1 - */ -public interface BivariateFunction { - /** - * Compute the value for the function. - * - * @param x Abscissa for which the function value should be computed. - * @param y Ordinate for which the function value should be computed. - * @return the value. - */ - double value(double x, double y); - -} http://git-wip-us.apache.org/repos/asf/commons-math/blob/a7b4803f/src/main/java/org/apache/commons/math3/analysis/DifferentiableMultivariateFunction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/analysis/DifferentiableMultivariateFunction.java b/src/main/java/org/apache/commons/math3/analysis/DifferentiableMultivariateFunction.java deleted file mode 100644 index c7fad48..0000000 --- a/src/main/java/org/apache/commons/math3/analysis/DifferentiableMultivariateFunction.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.commons.math3.analysis; - -/** - * Extension of {@link MultivariateFunction} representing a differentiable - * multivariate real function. - * @since 2.0 - * @deprecated as of 3.1 replaced by {@link org.apache.commons.math3.analysis.differentiation.MultivariateDifferentiableFunction} - */ -@Deprecated -public interface DifferentiableMultivariateFunction extends MultivariateFunction { - - /** - * Returns the partial derivative of the function with respect to a point coordinate. - * <p> - * The partial derivative is defined with respect to point coordinate - * x<sub>k</sub>. If the partial derivatives with respect to all coordinates are - * needed, it may be more efficient to use the {@link #gradient()} method which will - * compute them all at once. - * </p> - * @param k index of the coordinate with respect to which the partial - * derivative is computed - * @return the partial derivative function with respect to k<sup>th</sup> point coordinate - */ - MultivariateFunction partialDerivative(int k); - - /** - * Returns the gradient function. - * <p>If only one partial derivative with respect to a specific coordinate is - * needed, it may be more efficient to use the {@link #partialDerivative(int)} method - * which will compute only the specified component.</p> - * @return the gradient function - */ - MultivariateVectorFunction gradient(); - -} http://git-wip-us.apache.org/repos/asf/commons-math/blob/a7b4803f/src/main/java/org/apache/commons/math3/analysis/DifferentiableMultivariateVectorFunction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/analysis/DifferentiableMultivariateVectorFunction.java b/src/main/java/org/apache/commons/math3/analysis/DifferentiableMultivariateVectorFunction.java deleted file mode 100644 index 5bfa97b..0000000 --- a/src/main/java/org/apache/commons/math3/analysis/DifferentiableMultivariateVectorFunction.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.commons.math3.analysis; - -/** - * Extension of {@link MultivariateVectorFunction} representing a differentiable - * multivariate vectorial function. - * @since 2.0 - * @deprecated as of 3.1 replaced by {@link org.apache.commons.math3.analysis.differentiation.MultivariateDifferentiableVectorFunction} - */ -@Deprecated -public interface DifferentiableMultivariateVectorFunction - extends MultivariateVectorFunction { - - /** - * Returns the jacobian function. - * @return the jacobian function - */ - MultivariateMatrixFunction jacobian(); - -} http://git-wip-us.apache.org/repos/asf/commons-math/blob/a7b4803f/src/main/java/org/apache/commons/math3/analysis/DifferentiableUnivariateFunction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/analysis/DifferentiableUnivariateFunction.java b/src/main/java/org/apache/commons/math3/analysis/DifferentiableUnivariateFunction.java deleted file mode 100644 index db0314c..0000000 --- a/src/main/java/org/apache/commons/math3/analysis/DifferentiableUnivariateFunction.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.math3.analysis; - -/** - * Extension of {@link UnivariateFunction} representing a differentiable univariate real function. - * - * @deprecated as of 3.1 replaced by {@link org.apache.commons.math3.analysis.differentiation.UnivariateDifferentiableFunction} - */ -@Deprecated -public interface DifferentiableUnivariateFunction - extends UnivariateFunction { - - /** - * Returns the derivative of the function - * - * @return the derivative function - */ - UnivariateFunction derivative(); - -} http://git-wip-us.apache.org/repos/asf/commons-math/blob/a7b4803f/src/main/java/org/apache/commons/math3/analysis/DifferentiableUnivariateMatrixFunction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/analysis/DifferentiableUnivariateMatrixFunction.java b/src/main/java/org/apache/commons/math3/analysis/DifferentiableUnivariateMatrixFunction.java deleted file mode 100644 index 375fcfd..0000000 --- a/src/main/java/org/apache/commons/math3/analysis/DifferentiableUnivariateMatrixFunction.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.math3.analysis; - -/** - * Extension of {@link UnivariateMatrixFunction} representing a differentiable univariate matrix function. - * - * @since 2.0 - * @deprecated as of 3.1 replaced by {@link org.apache.commons.math3.analysis.differentiation.UnivariateDifferentiableMatrixFunction} - */ -@Deprecated -public interface DifferentiableUnivariateMatrixFunction - extends UnivariateMatrixFunction { - - /** - * Returns the derivative of the function - * - * @return the derivative function - */ - UnivariateMatrixFunction derivative(); - -} http://git-wip-us.apache.org/repos/asf/commons-math/blob/a7b4803f/src/main/java/org/apache/commons/math3/analysis/DifferentiableUnivariateVectorFunction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/analysis/DifferentiableUnivariateVectorFunction.java b/src/main/java/org/apache/commons/math3/analysis/DifferentiableUnivariateVectorFunction.java deleted file mode 100644 index b5ab198..0000000 --- a/src/main/java/org/apache/commons/math3/analysis/DifferentiableUnivariateVectorFunction.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.math3.analysis; - -/** - * Extension of {@link UnivariateVectorFunction} representing a differentiable univariate vectorial function. - * - * @since 2.0 - * @deprecated as of 3.1 replaced by {@link org.apache.commons.math3.analysis.differentiation.UnivariateDifferentiableVectorFunction} - */ -@Deprecated -public interface DifferentiableUnivariateVectorFunction - extends UnivariateVectorFunction { - - /** - * Returns the derivative of the function - * - * @return the derivative function - */ - UnivariateVectorFunction derivative(); - -} http://git-wip-us.apache.org/repos/asf/commons-math/blob/a7b4803f/src/main/java/org/apache/commons/math3/analysis/FunctionUtils.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/analysis/FunctionUtils.java b/src/main/java/org/apache/commons/math3/analysis/FunctionUtils.java deleted file mode 100644 index 2bc1c48..0000000 --- a/src/main/java/org/apache/commons/math3/analysis/FunctionUtils.java +++ /dev/null @@ -1,795 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.commons.math3.analysis; - -import org.apache.commons.math3.analysis.differentiation.DerivativeStructure; -import org.apache.commons.math3.analysis.differentiation.MultivariateDifferentiableFunction; -import org.apache.commons.math3.analysis.differentiation.MultivariateDifferentiableVectorFunction; -import org.apache.commons.math3.analysis.differentiation.UnivariateDifferentiableFunction; -import org.apache.commons.math3.analysis.function.Identity; -import org.apache.commons.math3.exception.DimensionMismatchException; -import org.apache.commons.math3.exception.NotStrictlyPositiveException; -import org.apache.commons.math3.exception.NumberIsTooLargeException; -import org.apache.commons.math3.exception.util.LocalizedFormats; - -/** - * Utilities for manipulating function objects. - * - * @since 3.0 - */ -public class FunctionUtils { - /** - * Class only contains static methods. - */ - private FunctionUtils() {} - - /** - * Composes functions. - * <br/> - * The functions in the argument list are composed sequentially, in the - * given order. For example, compose(f1,f2,f3) acts like f1(f2(f3(x))). - * - * @param f List of functions. - * @return the composite function. - */ - public static UnivariateFunction compose(final UnivariateFunction ... f) { - return new UnivariateFunction() { - /** {@inheritDoc} */ - public double value(double x) { - double r = x; - for (int i = f.length - 1; i >= 0; i--) { - r = f[i].value(r); - } - return r; - } - }; - } - - /** - * Composes functions. - * <br/> - * The functions in the argument list are composed sequentially, in the - * given order. For example, compose(f1,f2,f3) acts like f1(f2(f3(x))). - * - * @param f List of functions. - * @return the composite function. - * @since 3.1 - */ - public static UnivariateDifferentiableFunction compose(final UnivariateDifferentiableFunction ... f) { - return new UnivariateDifferentiableFunction() { - - /** {@inheritDoc} */ - public double value(final double t) { - double r = t; - for (int i = f.length - 1; i >= 0; i--) { - r = f[i].value(r); - } - return r; - } - - /** {@inheritDoc} */ - public DerivativeStructure value(final DerivativeStructure t) { - DerivativeStructure r = t; - for (int i = f.length - 1; i >= 0; i--) { - r = f[i].value(r); - } - return r; - } - - }; - } - - /** - * Composes functions. - * <br/> - * The functions in the argument list are composed sequentially, in the - * given order. For example, compose(f1,f2,f3) acts like f1(f2(f3(x))). - * - * @param f List of functions. - * @return the composite function. - * @deprecated as of 3.1 replaced by {@link #compose(UnivariateDifferentiableFunction...)} - */ - @Deprecated - public static DifferentiableUnivariateFunction compose(final DifferentiableUnivariateFunction ... f) { - return new DifferentiableUnivariateFunction() { - /** {@inheritDoc} */ - public double value(double x) { - double r = x; - for (int i = f.length - 1; i >= 0; i--) { - r = f[i].value(r); - } - return r; - } - - /** {@inheritDoc} */ - public UnivariateFunction derivative() { - return new UnivariateFunction() { - /** {@inheritDoc} */ - public double value(double x) { - double p = 1; - double r = x; - for (int i = f.length - 1; i >= 0; i--) { - p *= f[i].derivative().value(r); - r = f[i].value(r); - } - return p; - } - }; - } - }; - } - - /** - * Adds functions. - * - * @param f List of functions. - * @return a function that computes the sum of the functions. - */ - public static UnivariateFunction add(final UnivariateFunction ... f) { - return new UnivariateFunction() { - /** {@inheritDoc} */ - public double value(double x) { - double r = f[0].value(x); - for (int i = 1; i < f.length; i++) { - r += f[i].value(x); - } - return r; - } - }; - } - - /** - * Adds functions. - * - * @param f List of functions. - * @return a function that computes the sum of the functions. - * @since 3.1 - */ - public static UnivariateDifferentiableFunction add(final UnivariateDifferentiableFunction ... f) { - return new UnivariateDifferentiableFunction() { - - /** {@inheritDoc} */ - public double value(final double t) { - double r = f[0].value(t); - for (int i = 1; i < f.length; i++) { - r += f[i].value(t); - } - return r; - } - - /** {@inheritDoc} - * @throws DimensionMismatchException if functions are not consistent with each other - */ - public DerivativeStructure value(final DerivativeStructure t) - throws DimensionMismatchException { - DerivativeStructure r = f[0].value(t); - for (int i = 1; i < f.length; i++) { - r = r.add(f[i].value(t)); - } - return r; - } - - }; - } - - /** - * Adds functions. - * - * @param f List of functions. - * @return a function that computes the sum of the functions. - * @deprecated as of 3.1 replaced by {@link #add(UnivariateDifferentiableFunction...)} - */ - @Deprecated - public static DifferentiableUnivariateFunction add(final DifferentiableUnivariateFunction ... f) { - return new DifferentiableUnivariateFunction() { - /** {@inheritDoc} */ - public double value(double x) { - double r = f[0].value(x); - for (int i = 1; i < f.length; i++) { - r += f[i].value(x); - } - return r; - } - - /** {@inheritDoc} */ - public UnivariateFunction derivative() { - return new UnivariateFunction() { - /** {@inheritDoc} */ - public double value(double x) { - double r = f[0].derivative().value(x); - for (int i = 1; i < f.length; i++) { - r += f[i].derivative().value(x); - } - return r; - } - }; - } - }; - } - - /** - * Multiplies functions. - * - * @param f List of functions. - * @return a function that computes the product of the functions. - */ - public static UnivariateFunction multiply(final UnivariateFunction ... f) { - return new UnivariateFunction() { - /** {@inheritDoc} */ - public double value(double x) { - double r = f[0].value(x); - for (int i = 1; i < f.length; i++) { - r *= f[i].value(x); - } - return r; - } - }; - } - - /** - * Multiplies functions. - * - * @param f List of functions. - * @return a function that computes the product of the functions. - * @since 3.1 - */ - public static UnivariateDifferentiableFunction multiply(final UnivariateDifferentiableFunction ... f) { - return new UnivariateDifferentiableFunction() { - - /** {@inheritDoc} */ - public double value(final double t) { - double r = f[0].value(t); - for (int i = 1; i < f.length; i++) { - r *= f[i].value(t); - } - return r; - } - - /** {@inheritDoc} */ - public DerivativeStructure value(final DerivativeStructure t) { - DerivativeStructure r = f[0].value(t); - for (int i = 1; i < f.length; i++) { - r = r.multiply(f[i].value(t)); - } - return r; - } - - }; - } - - /** - * Multiplies functions. - * - * @param f List of functions. - * @return a function that computes the product of the functions. - * @deprecated as of 3.1 replaced by {@link #multiply(UnivariateDifferentiableFunction...)} - */ - @Deprecated - public static DifferentiableUnivariateFunction multiply(final DifferentiableUnivariateFunction ... f) { - return new DifferentiableUnivariateFunction() { - /** {@inheritDoc} */ - public double value(double x) { - double r = f[0].value(x); - for (int i = 1; i < f.length; i++) { - r *= f[i].value(x); - } - return r; - } - - /** {@inheritDoc} */ - public UnivariateFunction derivative() { - return new UnivariateFunction() { - /** {@inheritDoc} */ - public double value(double x) { - double sum = 0; - for (int i = 0; i < f.length; i++) { - double prod = f[i].derivative().value(x); - for (int j = 0; j < f.length; j++) { - if (i != j) { - prod *= f[j].value(x); - } - } - sum += prod; - } - return sum; - } - }; - } - }; - } - - /** - * Returns the univariate function <br/> - * {@code h(x) = combiner(f(x), g(x))}. - * - * @param combiner Combiner function. - * @param f Function. - * @param g Function. - * @return the composite function. - */ - public static UnivariateFunction combine(final BivariateFunction combiner, - final UnivariateFunction f, - final UnivariateFunction g) { - return new UnivariateFunction() { - /** {@inheritDoc} */ - public double value(double x) { - return combiner.value(f.value(x), g.value(x)); - } - }; - } - - /** - * Returns a MultivariateFunction h(x[]) defined by <pre> <code> - * h(x[]) = combiner(...combiner(combiner(initialValue,f(x[0])),f(x[1]))...),f(x[x.length-1])) - * </code></pre> - * - * @param combiner Combiner function. - * @param f Function. - * @param initialValue Initial value. - * @return a collector function. - */ - public static MultivariateFunction collector(final BivariateFunction combiner, - final UnivariateFunction f, - final double initialValue) { - return new MultivariateFunction() { - /** {@inheritDoc} */ - public double value(double[] point) { - double result = combiner.value(initialValue, f.value(point[0])); - for (int i = 1; i < point.length; i++) { - result = combiner.value(result, f.value(point[i])); - } - return result; - } - }; - } - - /** - * Returns a MultivariateFunction h(x[]) defined by <pre> <code> - * h(x[]) = combiner(...combiner(combiner(initialValue,x[0]),x[1])...),x[x.length-1]) - * </code></pre> - * - * @param combiner Combiner function. - * @param initialValue Initial value. - * @return a collector function. - */ - public static MultivariateFunction collector(final BivariateFunction combiner, - final double initialValue) { - return collector(combiner, new Identity(), initialValue); - } - - /** - * Creates a unary function by fixing the first argument of a binary function. - * - * @param f Binary function. - * @param fixed Value to which the first argument of {@code f} is set. - * @return the unary function h(x) = f(fixed, x) - */ - public static UnivariateFunction fix1stArgument(final BivariateFunction f, - final double fixed) { - return new UnivariateFunction() { - /** {@inheritDoc} */ - public double value(double x) { - return f.value(fixed, x); - } - }; - } - /** - * Creates a unary function by fixing the second argument of a binary function. - * - * @param f Binary function. - * @param fixed Value to which the second argument of {@code f} is set. - * @return the unary function h(x) = f(x, fixed) - */ - public static UnivariateFunction fix2ndArgument(final BivariateFunction f, - final double fixed) { - return new UnivariateFunction() { - /** {@inheritDoc} */ - public double value(double x) { - return f.value(x, fixed); - } - }; - } - - /** - * Samples the specified univariate real function on the specified interval. - * <br/> - * The interval is divided equally into {@code n} sections and sample points - * are taken from {@code min} to {@code max - (max - min) / n}; therefore - * {@code f} is not sampled at the upper bound {@code max}. - * - * @param f Function to be sampled - * @param min Lower bound of the interval (included). - * @param max Upper bound of the interval (excluded). - * @param n Number of sample points. - * @return the array of samples. - * @throws NumberIsTooLargeException if the lower bound {@code min} is - * greater than, or equal to the upper bound {@code max}. - * @throws NotStrictlyPositiveException if the number of sample points - * {@code n} is negative. - */ - public static double[] sample(UnivariateFunction f, double min, double max, int n) - throws NumberIsTooLargeException, NotStrictlyPositiveException { - - if (n <= 0) { - throw new NotStrictlyPositiveException( - LocalizedFormats.NOT_POSITIVE_NUMBER_OF_SAMPLES, - Integer.valueOf(n)); - } - if (min >= max) { - throw new NumberIsTooLargeException(min, max, false); - } - - final double[] s = new double[n]; - final double h = (max - min) / n; - for (int i = 0; i < n; i++) { - s[i] = f.value(min + i * h); - } - return s; - } - - /** Convert a {@link UnivariateDifferentiableFunction} into a {@link DifferentiableUnivariateFunction}. - * @param f function to convert - * @return converted function - * @deprecated this conversion method is temporary in version 3.1, as the {@link - * DifferentiableUnivariateFunction} interface itself is deprecated - */ - @Deprecated - public static DifferentiableUnivariateFunction toDifferentiableUnivariateFunction(final UnivariateDifferentiableFunction f) { - return new DifferentiableUnivariateFunction() { - - /** {@inheritDoc} */ - public double value(final double x) { - return f.value(x); - } - - /** {@inheritDoc} */ - public UnivariateFunction derivative() { - return new UnivariateFunction() { - /** {@inheritDoc} */ - public double value(final double x) { - return f.value(new DerivativeStructure(1, 1, 0, x)).getPartialDerivative(1); - } - }; - } - - }; - } - - /** Convert a {@link DifferentiableUnivariateFunction} into a {@link UnivariateDifferentiableFunction}. - * <p> - * Note that the converted function is able to handle {@link DerivativeStructure} up to order one. - * If the function is called with higher order, a {@link NumberIsTooLargeException} will be thrown. - * </p> - * @param f function to convert - * @return converted function - * @deprecated this conversion method is temporary in version 3.1, as the {@link - * DifferentiableUnivariateFunction} interface itself is deprecated - */ - @Deprecated - public static UnivariateDifferentiableFunction toUnivariateDifferential(final DifferentiableUnivariateFunction f) { - return new UnivariateDifferentiableFunction() { - - /** {@inheritDoc} */ - public double value(final double x) { - return f.value(x); - } - - /** {@inheritDoc} - * @exception NumberIsTooLargeException if derivation order is greater than 1 - */ - public DerivativeStructure value(final DerivativeStructure t) - throws NumberIsTooLargeException { - switch (t.getOrder()) { - case 0 : - return new DerivativeStructure(t.getFreeParameters(), 0, f.value(t.getValue())); - case 1 : { - final int parameters = t.getFreeParameters(); - final double[] derivatives = new double[parameters + 1]; - derivatives[0] = f.value(t.getValue()); - final double fPrime = f.derivative().value(t.getValue()); - int[] orders = new int[parameters]; - for (int i = 0; i < parameters; ++i) { - orders[i] = 1; - derivatives[i + 1] = fPrime * t.getPartialDerivative(orders); - orders[i] = 0; - } - return new DerivativeStructure(parameters, 1, derivatives); - } - default : - throw new NumberIsTooLargeException(t.getOrder(), 1, true); - } - } - - }; - } - - /** Convert a {@link MultivariateDifferentiableFunction} into a {@link DifferentiableMultivariateFunction}. - * @param f function to convert - * @return converted function - * @deprecated this conversion method is temporary in version 3.1, as the {@link - * DifferentiableMultivariateFunction} interface itself is deprecated - */ - @Deprecated - public static DifferentiableMultivariateFunction toDifferentiableMultivariateFunction(final MultivariateDifferentiableFunction f) { - return new DifferentiableMultivariateFunction() { - - /** {@inheritDoc} */ - public double value(final double[] x) { - return f.value(x); - } - - /** {@inheritDoc} */ - public MultivariateFunction partialDerivative(final int k) { - return new MultivariateFunction() { - /** {@inheritDoc} */ - public double value(final double[] x) { - - final int n = x.length; - - // delegate computation to underlying function - final DerivativeStructure[] dsX = new DerivativeStructure[n]; - for (int i = 0; i < n; ++i) { - if (i == k) { - dsX[i] = new DerivativeStructure(1, 1, 0, x[i]); - } else { - dsX[i] = new DerivativeStructure(1, 1, x[i]); - } - } - final DerivativeStructure y = f.value(dsX); - - // extract partial derivative - return y.getPartialDerivative(1); - - } - }; - } - - public MultivariateVectorFunction gradient() { - return new MultivariateVectorFunction() { - /** {@inheritDoc} */ - public double[] value(final double[] x) { - - final int n = x.length; - - // delegate computation to underlying function - final DerivativeStructure[] dsX = new DerivativeStructure[n]; - for (int i = 0; i < n; ++i) { - dsX[i] = new DerivativeStructure(n, 1, i, x[i]); - } - final DerivativeStructure y = f.value(dsX); - - // extract gradient - final double[] gradient = new double[n]; - final int[] orders = new int[n]; - for (int i = 0; i < n; ++i) { - orders[i] = 1; - gradient[i] = y.getPartialDerivative(orders); - orders[i] = 0; - } - - return gradient; - - } - }; - } - - }; - } - - /** Convert a {@link DifferentiableMultivariateFunction} into a {@link MultivariateDifferentiableFunction}. - * <p> - * Note that the converted function is able to handle {@link DerivativeStructure} elements - * that all have the same number of free parameters and order, and with order at most 1. - * If the function is called with inconsistent numbers of free parameters or higher order, a - * {@link DimensionMismatchException} or a {@link NumberIsTooLargeException} will be thrown. - * </p> - * @param f function to convert - * @return converted function - * @deprecated this conversion method is temporary in version 3.1, as the {@link - * DifferentiableMultivariateFunction} interface itself is deprecated - */ - @Deprecated - public static MultivariateDifferentiableFunction toMultivariateDifferentiableFunction(final DifferentiableMultivariateFunction f) { - return new MultivariateDifferentiableFunction() { - - /** {@inheritDoc} */ - public double value(final double[] x) { - return f.value(x); - } - - /** {@inheritDoc} - * @exception NumberIsTooLargeException if derivation order is higher than 1 - * @exception DimensionMismatchException if numbers of free parameters are inconsistent - */ - public DerivativeStructure value(final DerivativeStructure[] t) - throws DimensionMismatchException, NumberIsTooLargeException { - - // check parameters and orders limits - final int parameters = t[0].getFreeParameters(); - final int order = t[0].getOrder(); - final int n = t.length; - if (order > 1) { - throw new NumberIsTooLargeException(order, 1, true); - } - - // check all elements in the array are consistent - for (int i = 0; i < n; ++i) { - if (t[i].getFreeParameters() != parameters) { - throw new DimensionMismatchException(t[i].getFreeParameters(), parameters); - } - - if (t[i].getOrder() != order) { - throw new DimensionMismatchException(t[i].getOrder(), order); - } - } - - // delegate computation to underlying function - final double[] point = new double[n]; - for (int i = 0; i < n; ++i) { - point[i] = t[i].getValue(); - } - final double value = f.value(point); - final double[] gradient = f.gradient().value(point); - - // merge value and gradient into one DerivativeStructure - final double[] derivatives = new double[parameters + 1]; - derivatives[0] = value; - final int[] orders = new int[parameters]; - for (int i = 0; i < parameters; ++i) { - orders[i] = 1; - for (int j = 0; j < n; ++j) { - derivatives[i + 1] += gradient[j] * t[j].getPartialDerivative(orders); - } - orders[i] = 0; - } - - return new DerivativeStructure(parameters, order, derivatives); - - } - - }; - } - - /** Convert a {@link MultivariateDifferentiableVectorFunction} into a {@link DifferentiableMultivariateVectorFunction}. - * @param f function to convert - * @return converted function - * @deprecated this conversion method is temporary in version 3.1, as the {@link - * DifferentiableMultivariateVectorFunction} interface itself is deprecated - */ - @Deprecated - public static DifferentiableMultivariateVectorFunction toDifferentiableMultivariateVectorFunction(final MultivariateDifferentiableVectorFunction f) { - return new DifferentiableMultivariateVectorFunction() { - - /** {@inheritDoc} */ - public double[] value(final double[] x) { - return f.value(x); - } - - public MultivariateMatrixFunction jacobian() { - return new MultivariateMatrixFunction() { - /** {@inheritDoc} */ - public double[][] value(final double[] x) { - - final int n = x.length; - - // delegate computation to underlying function - final DerivativeStructure[] dsX = new DerivativeStructure[n]; - for (int i = 0; i < n; ++i) { - dsX[i] = new DerivativeStructure(n, 1, i, x[i]); - } - final DerivativeStructure[] y = f.value(dsX); - - // extract Jacobian - final double[][] jacobian = new double[y.length][n]; - final int[] orders = new int[n]; - for (int i = 0; i < y.length; ++i) { - for (int j = 0; j < n; ++j) { - orders[j] = 1; - jacobian[i][j] = y[i].getPartialDerivative(orders); - orders[j] = 0; - } - } - - return jacobian; - - } - }; - } - - }; - } - - /** Convert a {@link DifferentiableMultivariateVectorFunction} into a {@link MultivariateDifferentiableVectorFunction}. - * <p> - * Note that the converted function is able to handle {@link DerivativeStructure} elements - * that all have the same number of free parameters and order, and with order at most 1. - * If the function is called with inconsistent numbers of free parameters or higher order, a - * {@link DimensionMismatchException} or a {@link NumberIsTooLargeException} will be thrown. - * </p> - * @param f function to convert - * @return converted function - * @deprecated this conversion method is temporary in version 3.1, as the {@link - * DifferentiableMultivariateFunction} interface itself is deprecated - */ - @Deprecated - public static MultivariateDifferentiableVectorFunction toMultivariateDifferentiableVectorFunction(final DifferentiableMultivariateVectorFunction f) { - return new MultivariateDifferentiableVectorFunction() { - - /** {@inheritDoc} */ - public double[] value(final double[] x) { - return f.value(x); - } - - /** {@inheritDoc} - * @exception NumberIsTooLargeException if derivation order is higher than 1 - * @exception DimensionMismatchException if numbers of free parameters are inconsistent - */ - public DerivativeStructure[] value(final DerivativeStructure[] t) - throws DimensionMismatchException, NumberIsTooLargeException { - - // check parameters and orders limits - final int parameters = t[0].getFreeParameters(); - final int order = t[0].getOrder(); - final int n = t.length; - if (order > 1) { - throw new NumberIsTooLargeException(order, 1, true); - } - - // check all elements in the array are consistent - for (int i = 0; i < n; ++i) { - if (t[i].getFreeParameters() != parameters) { - throw new DimensionMismatchException(t[i].getFreeParameters(), parameters); - } - - if (t[i].getOrder() != order) { - throw new DimensionMismatchException(t[i].getOrder(), order); - } - } - - // delegate computation to underlying function - final double[] point = new double[n]; - for (int i = 0; i < n; ++i) { - point[i] = t[i].getValue(); - } - final double[] value = f.value(point); - final double[][] jacobian = f.jacobian().value(point); - - // merge value and Jacobian into a DerivativeStructure array - final DerivativeStructure[] merged = new DerivativeStructure[value.length]; - for (int k = 0; k < merged.length; ++k) { - final double[] derivatives = new double[parameters + 1]; - derivatives[0] = value[k]; - final int[] orders = new int[parameters]; - for (int i = 0; i < parameters; ++i) { - orders[i] = 1; - for (int j = 0; j < n; ++j) { - derivatives[i + 1] += jacobian[k][j] * t[j].getPartialDerivative(orders); - } - orders[i] = 0; - } - merged[k] = new DerivativeStructure(parameters, order, derivatives); - } - - return merged; - - } - - }; - } - -} http://git-wip-us.apache.org/repos/asf/commons-math/blob/a7b4803f/src/main/java/org/apache/commons/math3/analysis/MultivariateFunction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/analysis/MultivariateFunction.java b/src/main/java/org/apache/commons/math3/analysis/MultivariateFunction.java deleted file mode 100644 index f86ba2a..0000000 --- a/src/main/java/org/apache/commons/math3/analysis/MultivariateFunction.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.commons.math3.analysis; - -/** - * An interface representing a multivariate real function. - * - * @since 2.0 - */ -public interface MultivariateFunction { - - /** - * Compute the value for the function at the given point. - * - * @param point Point at which the function must be evaluated. - * @return the function value for the given point. - * @throws org.apache.commons.math3.exception.DimensionMismatchException - * if the parameter's dimension is wrong for the function being evaluated. - * @throws org.apache.commons.math3.exception.MathIllegalArgumentException - * when the activated method itself can ascertain that preconditions, - * specified in the API expressed at the level of the activated method, - * have been violated. In the vast majority of cases where Commons Math - * throws this exception, it is the result of argument checking of actual - * parameters immediately passed to a method. - */ - double value(double[] point); -} http://git-wip-us.apache.org/repos/asf/commons-math/blob/a7b4803f/src/main/java/org/apache/commons/math3/analysis/MultivariateMatrixFunction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/analysis/MultivariateMatrixFunction.java b/src/main/java/org/apache/commons/math3/analysis/MultivariateMatrixFunction.java deleted file mode 100644 index f064904..0000000 --- a/src/main/java/org/apache/commons/math3/analysis/MultivariateMatrixFunction.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.commons.math3.analysis; - -/** - * An interface representing a multivariate matrix function. - * @since 2.0 - */ -public interface MultivariateMatrixFunction { - - /** - * Compute the value for the function at the given point. - * @param point point at which the function must be evaluated - * @return function value for the given point - * @exception IllegalArgumentException if point's dimension is wrong - */ - double[][] value(double[] point) - throws IllegalArgumentException; - -} http://git-wip-us.apache.org/repos/asf/commons-math/blob/a7b4803f/src/main/java/org/apache/commons/math3/analysis/MultivariateVectorFunction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/analysis/MultivariateVectorFunction.java b/src/main/java/org/apache/commons/math3/analysis/MultivariateVectorFunction.java deleted file mode 100644 index 26a69f2..0000000 --- a/src/main/java/org/apache/commons/math3/analysis/MultivariateVectorFunction.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.commons.math3.analysis; - -/** - * An interface representing a multivariate vectorial function. - * @since 2.0 - */ -public interface MultivariateVectorFunction { - - /** - * Compute the value for the function at the given point. - * @param point point at which the function must be evaluated - * @return function value for the given point - * @exception IllegalArgumentException if point's dimension is wrong - */ - double[] value(double[] point) - throws IllegalArgumentException; - -} http://git-wip-us.apache.org/repos/asf/commons-math/blob/a7b4803f/src/main/java/org/apache/commons/math3/analysis/ParametricUnivariateFunction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/analysis/ParametricUnivariateFunction.java b/src/main/java/org/apache/commons/math3/analysis/ParametricUnivariateFunction.java deleted file mode 100644 index 616b35d..0000000 --- a/src/main/java/org/apache/commons/math3/analysis/ParametricUnivariateFunction.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.commons.math3.analysis; - -/** - * An interface representing a real function that depends on one independent - * variable plus some extra parameters. - * - * @since 3.0 - */ -public interface ParametricUnivariateFunction { - /** - * Compute the value of the function. - * - * @param x Point for which the function value should be computed. - * @param parameters Function parameters. - * @return the value. - */ - double value(double x, double ... parameters); - - /** - * Compute the gradient of the function with respect to its parameters. - * - * @param x Point for which the function value should be computed. - * @param parameters Function parameters. - * @return the value. - */ - double[] gradient(double x, double ... parameters); -} http://git-wip-us.apache.org/repos/asf/commons-math/blob/a7b4803f/src/main/java/org/apache/commons/math3/analysis/TrivariateFunction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/analysis/TrivariateFunction.java b/src/main/java/org/apache/commons/math3/analysis/TrivariateFunction.java deleted file mode 100644 index 30ba767..0000000 --- a/src/main/java/org/apache/commons/math3/analysis/TrivariateFunction.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.commons.math3.analysis; - -/** - * An interface representing a trivariate real function. - * - * @since 2.2 - */ -public interface TrivariateFunction { - /** - * Compute the value for the function. - * - * @param x x-coordinate for which the function value should be computed. - * @param y y-coordinate for which the function value should be computed. - * @param z z-coordinate for which the function value should be computed. - * @return the value. - */ - double value(double x, double y, double z); -} http://git-wip-us.apache.org/repos/asf/commons-math/blob/a7b4803f/src/main/java/org/apache/commons/math3/analysis/UnivariateFunction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/analysis/UnivariateFunction.java b/src/main/java/org/apache/commons/math3/analysis/UnivariateFunction.java deleted file mode 100644 index e99f1f3..0000000 --- a/src/main/java/org/apache/commons/math3/analysis/UnivariateFunction.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.math3.analysis; - -/** - * An interface representing a univariate real function. - * <br/> - * When a <em>user-defined</em> function encounters an error during - * evaluation, the {@link #value(double) value} method should throw a - * <em>user-defined</em> unchecked exception. - * <br/> - * The following code excerpt shows the recommended way to do that using - * a root solver as an example, but the same construct is applicable to - * ODE integrators or optimizers. - * - * <pre> - * private static class LocalException extends RuntimeException { - * // The x value that caused the problem. - * private final double x; - * - * public LocalException(double x) { - * this.x = x; - * } - * - * public double getX() { - * return x; - * } - * } - * - * private static class MyFunction implements UnivariateFunction { - * public double value(double x) { - * double y = hugeFormula(x); - * if (somethingBadHappens) { - * throw new LocalException(x); - * } - * return y; - * } - * } - * - * public void compute() { - * try { - * solver.solve(maxEval, new MyFunction(a, b, c), min, max); - * } catch (LocalException le) { - * // Retrieve the x value. - * } - * } - * </pre> - * - * As shown, the exception is local to the user's code and it is guaranteed - * that Apache Commons Math will not catch it. - * - */ -public interface UnivariateFunction { - /** - * Compute the value of the function. - * - * @param x Point at which the function value should be computed. - * @return the value of the function. - * @throws IllegalArgumentException when the activated method itself can - * ascertain that a precondition, specified in the API expressed at the - * level of the activated method, has been violated. - * When Commons Math throws an {@code IllegalArgumentException}, it is - * usually the consequence of checking the actual parameters passed to - * the method. - */ - double value(double x); -} http://git-wip-us.apache.org/repos/asf/commons-math/blob/a7b4803f/src/main/java/org/apache/commons/math3/analysis/UnivariateMatrixFunction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/analysis/UnivariateMatrixFunction.java b/src/main/java/org/apache/commons/math3/analysis/UnivariateMatrixFunction.java deleted file mode 100644 index 0c4b1a9..0000000 --- a/src/main/java/org/apache/commons/math3/analysis/UnivariateMatrixFunction.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.math3.analysis; - -/** - * An interface representing a univariate matrix function. - * - * @since 2.0 - */ -public interface UnivariateMatrixFunction { - - /** - * Compute the value for the function. - * @param x the point for which the function value should be computed - * @return the value - */ - double[][] value(double x); - -} http://git-wip-us.apache.org/repos/asf/commons-math/blob/a7b4803f/src/main/java/org/apache/commons/math3/analysis/UnivariateVectorFunction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/analysis/UnivariateVectorFunction.java b/src/main/java/org/apache/commons/math3/analysis/UnivariateVectorFunction.java deleted file mode 100644 index 19a9e5d..0000000 --- a/src/main/java/org/apache/commons/math3/analysis/UnivariateVectorFunction.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.math3.analysis; - -/** - * An interface representing a univariate vectorial function. - * - * @since 2.0 - */ -public interface UnivariateVectorFunction { - - /** - * Compute the value for the function. - * @param x the point for which the function value should be computed - * @return the value - */ - double[] value(double x); - -}