Remove deprecated interfaces/classes/methods in analysis package.

This commit is contained in:
Thomas Neidhart 2015-04-11 15:47:35 +02:00
parent 8e4e522151
commit 306fa74602
79 changed files with 196 additions and 1430 deletions

View File

@ -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.math4.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.math4.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();
}

View File

@ -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.math4.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.math4.analysis.differentiation.MultivariateDifferentiableVectorFunction}
*/
@Deprecated
public interface DifferentiableMultivariateVectorFunction
extends MultivariateVectorFunction {
/**
* Returns the jacobian function.
* @return the jacobian function
*/
MultivariateMatrixFunction jacobian();
}

View File

@ -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.math4.analysis;
/**
* Extension of {@link UnivariateFunction} representing a differentiable univariate real function.
*
* @deprecated as of 3.1 replaced by {@link org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction}
*/
@Deprecated
public interface DifferentiableUnivariateFunction
extends UnivariateFunction {
/**
* Returns the derivative of the function
*
* @return the derivative function
*/
UnivariateFunction derivative();
}

View File

@ -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.math4.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.math4.analysis.differentiation.UnivariateDifferentiableMatrixFunction}
*/
@Deprecated
public interface DifferentiableUnivariateMatrixFunction
extends UnivariateMatrixFunction {
/**
* Returns the derivative of the function
*
* @return the derivative function
*/
UnivariateMatrixFunction derivative();
}

View File

@ -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.math4.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.math4.analysis.differentiation.UnivariateDifferentiableVectorFunction}
*/
@Deprecated
public interface DifferentiableUnivariateVectorFunction
extends UnivariateVectorFunction {
/**
* Returns the derivative of the function
*
* @return the derivative function
*/
UnivariateVectorFunction derivative();
}

View File

@ -18,8 +18,6 @@
package org.apache.commons.math4.analysis;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.MultivariateDifferentiableFunction;
import org.apache.commons.math4.analysis.differentiation.MultivariateDifferentiableVectorFunction;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math4.analysis.function.Identity;
import org.apache.commons.math4.exception.DimensionMismatchException;
@ -97,49 +95,6 @@ public class 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.
* @deprecated as of 3.1 replaced by {@link #compose(UnivariateDifferentiableFunction...)}
*/
@Deprecated
public static DifferentiableUnivariateFunction compose(final DifferentiableUnivariateFunction ... f) {
return new DifferentiableUnivariateFunction() {
/** {@inheritDoc} */
@Override
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} */
@Override
public UnivariateFunction derivative() {
return new UnivariateFunction() {
/** {@inheritDoc} */
@Override
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.
*
@ -196,44 +151,6 @@ public class FunctionUtils {
};
}
/**
* 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} */
@Override
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} */
@Override
public UnivariateFunction derivative() {
return new UnivariateFunction() {
/** {@inheritDoc} */
@Override
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.
*
@ -287,50 +204,6 @@ public class FunctionUtils {
};
}
/**
* 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} */
@Override
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} */
@Override
public UnivariateFunction derivative() {
return new UnivariateFunction() {
/** {@inheritDoc} */
@Override
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))}.
@ -464,369 +337,4 @@ public class FunctionUtils {
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} */
@Override
public double value(final double x) {
return f.value(x);
}
/** {@inheritDoc} */
@Override
public UnivariateFunction derivative() {
return new UnivariateFunction() {
/** {@inheritDoc} */
@Override
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} */
@Override
public double value(final double x) {
return f.value(x);
}
/** {@inheritDoc}
* @exception NumberIsTooLargeException if derivation order is greater than 1
*/
@Override
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} */
@Override
public double value(final double[] x) {
return f.value(x);
}
/** {@inheritDoc} */
@Override
public MultivariateFunction partialDerivative(final int k) {
return new MultivariateFunction() {
/** {@inheritDoc} */
@Override
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} */
@Override
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} */
@Override
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
*/
@Override
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} */
@Override
public double[] value(final double[] x) {
return f.value(x);
}
public MultivariateMatrixFunction jacobian() {
return new MultivariateMatrixFunction() {
/** {@inheritDoc} */
@Override
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} */
@Override
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
*/
@Override
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;
}
};
}
}

View File

@ -764,6 +764,7 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
/** Base 10 logarithm.
* @return base 10 logarithm of the instance
*/
@Override
public DerivativeStructure log10() {
final DerivativeStructure result = new DerivativeStructure(compiler);
compiler.log10(data, 0, result.data, 0);

View File

@ -573,6 +573,7 @@ public class SparseGradient implements RealFieldElement<SparseGradient>, Seriali
/** Base 10 logarithm.
* @return base 10 logarithm of the instance
*/
@Override
public SparseGradient log10() {
return new SparseGradient(FastMath.log10(value), 1.0 / (FastMath.log(10.0) * value), derivatives);
}

View File

@ -17,9 +17,6 @@
package org.apache.commons.math4.analysis.function;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.FunctionUtils;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math4.util.FastMath;
@ -29,22 +26,13 @@ import org.apache.commons.math4.util.FastMath;
*
* @since 3.0
*/
public class Acos implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
public class Acos implements UnivariateDifferentiableFunction {
/** {@inheritDoc} */
@Override
public double value(double x) {
return FastMath.acos(x);
}
/** {@inheritDoc}
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
*/
@Deprecated
@Override
public UnivariateFunction derivative() {
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
}
/** {@inheritDoc}
* @since 3.1
*/

View File

@ -17,9 +17,6 @@
package org.apache.commons.math4.analysis.function;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.FunctionUtils;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math4.util.FastMath;
@ -29,22 +26,13 @@ import org.apache.commons.math4.util.FastMath;
*
* @since 3.0
*/
public class Acosh implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
public class Acosh implements UnivariateDifferentiableFunction {
/** {@inheritDoc} */
@Override
public double value(double x) {
return FastMath.acosh(x);
}
/** {@inheritDoc}
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
*/
@Deprecated
@Override
public UnivariateFunction derivative() {
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
}
/** {@inheritDoc}
* @since 3.1
*/

View File

@ -17,9 +17,6 @@
package org.apache.commons.math4.analysis.function;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.FunctionUtils;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math4.util.FastMath;
@ -29,22 +26,13 @@ import org.apache.commons.math4.util.FastMath;
*
* @since 3.0
*/
public class Asin implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
public class Asin implements UnivariateDifferentiableFunction {
/** {@inheritDoc} */
@Override
public double value(double x) {
return FastMath.asin(x);
}
/** {@inheritDoc}
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
*/
@Deprecated
@Override
public UnivariateFunction derivative() {
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
}
/** {@inheritDoc}
* @since 3.1
*/

View File

@ -17,9 +17,6 @@
package org.apache.commons.math4.analysis.function;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.FunctionUtils;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math4.util.FastMath;
@ -29,22 +26,13 @@ import org.apache.commons.math4.util.FastMath;
*
* @since 3.0
*/
public class Asinh implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
public class Asinh implements UnivariateDifferentiableFunction {
/** {@inheritDoc} */
@Override
public double value(double x) {
return FastMath.asinh(x);
}
/** {@inheritDoc}
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
*/
@Deprecated
@Override
public UnivariateFunction derivative() {
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
}
/** {@inheritDoc}
* @since 3.1
*/

View File

@ -17,9 +17,6 @@
package org.apache.commons.math4.analysis.function;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.FunctionUtils;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math4.util.FastMath;
@ -29,22 +26,13 @@ import org.apache.commons.math4.util.FastMath;
*
* @since 3.0
*/
public class Atan implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
public class Atan implements UnivariateDifferentiableFunction {
/** {@inheritDoc} */
@Override
public double value(double x) {
return FastMath.atan(x);
}
/** {@inheritDoc}
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
*/
@Deprecated
@Override
public UnivariateFunction derivative() {
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
}
/** {@inheritDoc}
* @since 3.1
*/

View File

@ -17,9 +17,6 @@
package org.apache.commons.math4.analysis.function;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.FunctionUtils;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math4.util.FastMath;
@ -29,22 +26,13 @@ import org.apache.commons.math4.util.FastMath;
*
* @since 3.0
*/
public class Atanh implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
public class Atanh implements UnivariateDifferentiableFunction {
/** {@inheritDoc} */
@Override
public double value(double x) {
return FastMath.atanh(x);
}
/** {@inheritDoc}
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
*/
@Deprecated
@Override
public UnivariateFunction derivative() {
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
}
/** {@inheritDoc}
* @since 3.1
*/

View File

@ -17,9 +17,6 @@
package org.apache.commons.math4.analysis.function;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.FunctionUtils;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math4.util.FastMath;
@ -29,22 +26,13 @@ import org.apache.commons.math4.util.FastMath;
*
* @since 3.0
*/
public class Cbrt implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
public class Cbrt implements UnivariateDifferentiableFunction {
/** {@inheritDoc} */
@Override
public double value(double x) {
return FastMath.cbrt(x);
}
/** {@inheritDoc}
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
*/
@Deprecated
@Override
public UnivariateFunction derivative() {
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
}
/** {@inheritDoc}
* @since 3.1
*/

View File

@ -17,7 +17,6 @@
package org.apache.commons.math4.analysis.function;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
@ -26,7 +25,7 @@ import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiabl
*
* @since 3.0
*/
public class Constant implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
public class Constant implements UnivariateDifferentiableFunction {
/** Constant. */
private final double c;
@ -43,15 +42,6 @@ public class Constant implements UnivariateDifferentiableFunction, Differentiabl
return c;
}
/** {@inheritDoc}
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
*/
@Deprecated
@Override
public DifferentiableUnivariateFunction derivative() {
return new Constant(0);
}
/** {@inheritDoc}
* @since 3.1
*/

View File

@ -17,9 +17,6 @@
package org.apache.commons.math4.analysis.function;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.FunctionUtils;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math4.util.FastMath;
@ -29,22 +26,13 @@ import org.apache.commons.math4.util.FastMath;
*
* @since 3.0
*/
public class Cos implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
public class Cos implements UnivariateDifferentiableFunction {
/** {@inheritDoc} */
@Override
public double value(double x) {
return FastMath.cos(x);
}
/** {@inheritDoc}
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
*/
@Deprecated
@Override
public UnivariateFunction derivative() {
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
}
/** {@inheritDoc}
* @since 3.1
*/

View File

@ -17,7 +17,6 @@
package org.apache.commons.math4.analysis.function;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math4.util.FastMath;
@ -27,22 +26,13 @@ import org.apache.commons.math4.util.FastMath;
*
* @since 3.0
*/
public class Cosh implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
public class Cosh implements UnivariateDifferentiableFunction {
/** {@inheritDoc} */
@Override
public double value(double x) {
return FastMath.cosh(x);
}
/** {@inheritDoc}
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
*/
@Deprecated
@Override
public DifferentiableUnivariateFunction derivative() {
return new Sinh();
}
/** {@inheritDoc}
* @since 3.1
*/

View File

@ -17,9 +17,6 @@
package org.apache.commons.math4.analysis.function;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.FunctionUtils;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math4.util.FastMath;
@ -29,22 +26,13 @@ import org.apache.commons.math4.util.FastMath;
*
* @since 3.0
*/
public class Exp implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
public class Exp implements UnivariateDifferentiableFunction {
/** {@inheritDoc} */
@Override
public double value(double x) {
return FastMath.exp(x);
}
/** {@inheritDoc}
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
*/
@Override
@Deprecated
public UnivariateFunction derivative() {
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
}
/** {@inheritDoc}
* @since 3.1
*/

View File

@ -17,9 +17,6 @@
package org.apache.commons.math4.analysis.function;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.FunctionUtils;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math4.util.FastMath;
@ -29,22 +26,13 @@ import org.apache.commons.math4.util.FastMath;
*
* @since 3.0
*/
public class Expm1 implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
public class Expm1 implements UnivariateDifferentiableFunction {
/** {@inheritDoc} */
@Override
public double value(double x) {
return FastMath.expm1(x);
}
/** {@inheritDoc}
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
*/
@Override
@Deprecated
public UnivariateFunction derivative() {
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
}
/** {@inheritDoc}
* @since 3.1
*/

View File

@ -19,10 +19,7 @@ package org.apache.commons.math4.analysis.function;
import java.util.Arrays;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.FunctionUtils;
import org.apache.commons.math4.analysis.ParametricUnivariateFunction;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math4.exception.DimensionMismatchException;
@ -37,7 +34,7 @@ import org.apache.commons.math4.util.Precision;
*
* @since 3.0
*/
public class Gaussian implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
public class Gaussian implements UnivariateDifferentiableFunction {
/** Mean. */
private final double mean;
/** Inverse of the standard deviation. */
@ -95,15 +92,6 @@ public class Gaussian implements UnivariateDifferentiableFunction, Differentiabl
return value(x - mean, norm, i2s2);
}
/** {@inheritDoc}
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
*/
@Override
@Deprecated
public UnivariateFunction derivative() {
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
}
/**
* Parametric function where the input array contains the parameters of
* the Gaussian, ordered as follows:
@ -125,6 +113,7 @@ public class Gaussian implements UnivariateDifferentiableFunction, Differentiabl
* not 3.
* @throws NotStrictlyPositiveException if {@code param[2]} is negative.
*/
@Override
public double value(double x, double ... param)
throws NullArgumentException,
DimensionMismatchException,
@ -150,6 +139,7 @@ public class Gaussian implements UnivariateDifferentiableFunction, Differentiabl
* not 3.
* @throws NotStrictlyPositiveException if {@code param[2]} is negative.
*/
@Override
public double[] gradient(double x, double ... param)
throws NullArgumentException,
DimensionMismatchException,

View File

@ -17,10 +17,7 @@
package org.apache.commons.math4.analysis.function;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.FunctionUtils;
import org.apache.commons.math4.analysis.ParametricUnivariateFunction;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math4.exception.DimensionMismatchException;
@ -33,7 +30,7 @@ import org.apache.commons.math4.util.FastMath;
*
* @since 3.0
*/
public class HarmonicOscillator implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
public class HarmonicOscillator implements UnivariateDifferentiableFunction {
/** Amplitude. */
private final double amplitude;
/** Angular frequency. */
@ -62,15 +59,6 @@ public class HarmonicOscillator implements UnivariateDifferentiableFunction, Dif
return value(omega * x + phase, amplitude);
}
/** {@inheritDoc}
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
*/
@Override
@Deprecated
public UnivariateFunction derivative() {
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
}
/**
* Parametric function where the input array contains the parameters of
* the harmonic oscillator function, ordered as follows:
@ -91,6 +79,7 @@ public class HarmonicOscillator implements UnivariateDifferentiableFunction, Dif
* @throws DimensionMismatchException if the size of {@code param} is
* not 3.
*/
@Override
public double value(double x, double ... param)
throws NullArgumentException,
DimensionMismatchException {
@ -111,6 +100,7 @@ public class HarmonicOscillator implements UnivariateDifferentiableFunction, Dif
* @throws DimensionMismatchException if the size of {@code param} is
* not 3.
*/
@Override
public double[] gradient(double x, double ... param)
throws NullArgumentException,
DimensionMismatchException {

View File

@ -17,7 +17,6 @@
package org.apache.commons.math4.analysis.function;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
@ -26,22 +25,13 @@ import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiabl
*
* @since 3.0
*/
public class Identity implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
public class Identity implements UnivariateDifferentiableFunction {
/** {@inheritDoc} */
@Override
public double value(double x) {
return x;
}
/** {@inheritDoc}
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
*/
@Override
@Deprecated
public DifferentiableUnivariateFunction derivative() {
return new Constant(1);
}
/** {@inheritDoc}
* @since 3.1
*/

View File

@ -17,9 +17,6 @@
package org.apache.commons.math4.analysis.function;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.FunctionUtils;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
@ -28,22 +25,13 @@ import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiabl
*
* @since 3.0
*/
public class Inverse implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
public class Inverse implements UnivariateDifferentiableFunction {
/** {@inheritDoc} */
@Override
public double value(double x) {
return 1 / x;
}
/** {@inheritDoc}
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
*/
@Override
@Deprecated
public UnivariateFunction derivative() {
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
}
/** {@inheritDoc}
* @since 3.1
*/

View File

@ -17,9 +17,6 @@
package org.apache.commons.math4.analysis.function;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.FunctionUtils;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math4.util.FastMath;
@ -29,22 +26,13 @@ import org.apache.commons.math4.util.FastMath;
*
* @since 3.0
*/
public class Log implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
public class Log implements UnivariateDifferentiableFunction {
/** {@inheritDoc} */
@Override
public double value(double x) {
return FastMath.log(x);
}
/** {@inheritDoc}
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
*/
@Override
@Deprecated
public UnivariateFunction derivative() {
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
}
/** {@inheritDoc}
* @since 3.1
*/

View File

@ -17,9 +17,6 @@
package org.apache.commons.math4.analysis.function;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.FunctionUtils;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math4.util.FastMath;
@ -29,7 +26,7 @@ import org.apache.commons.math4.util.FastMath;
*
* @since 3.0
*/
public class Log10 implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
public class Log10 implements UnivariateDifferentiableFunction {
/** {@inheritDoc} */
@Override
@ -37,15 +34,6 @@ public class Log10 implements UnivariateDifferentiableFunction, DifferentiableUn
return FastMath.log10(x);
}
/** {@inheritDoc}
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
*/
@Override
@Deprecated
public UnivariateFunction derivative() {
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
}
/** {@inheritDoc}
* @since 3.1
*/

View File

@ -17,9 +17,6 @@
package org.apache.commons.math4.analysis.function;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.FunctionUtils;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math4.util.FastMath;
@ -29,22 +26,13 @@ import org.apache.commons.math4.util.FastMath;
*
* @since 3.0
*/
public class Log1p implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
public class Log1p implements UnivariateDifferentiableFunction {
/** {@inheritDoc} */
@Override
public double value(double x) {
return FastMath.log1p(x);
}
/** {@inheritDoc}
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
*/
@Override
@Deprecated
public UnivariateFunction derivative() {
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
}
/** {@inheritDoc}
* @since 3.1
*/

View File

@ -17,10 +17,7 @@
package org.apache.commons.math4.analysis.function;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.FunctionUtils;
import org.apache.commons.math4.analysis.ParametricUnivariateFunction;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math4.exception.DimensionMismatchException;
@ -34,7 +31,7 @@ import org.apache.commons.math4.util.FastMath;
*
* @since 3.0
*/
public class Logistic implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
public class Logistic implements UnivariateDifferentiableFunction {
/** Lower asymptote. */
private final double a;
/** Upper asymptote. */
@ -86,15 +83,6 @@ public class Logistic implements UnivariateDifferentiableFunction, Differentiabl
return value(m - x, k, b, q, a, oneOverN);
}
/** {@inheritDoc}
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
*/
@Override
@Deprecated
public UnivariateFunction derivative() {
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
}
/**
* Parametric function where the input array contains the parameters of
* the {@link Logistic#Logistic(double,double,double,double,double,double)
@ -121,6 +109,7 @@ public class Logistic implements UnivariateDifferentiableFunction, Differentiabl
* not 6.
* @throws NotStrictlyPositiveException if {@code param[5] <= 0}.
*/
@Override
public double value(double x, double ... param)
throws NullArgumentException,
DimensionMismatchException,
@ -146,6 +135,7 @@ public class Logistic implements UnivariateDifferentiableFunction, Differentiabl
* not 6.
* @throws NotStrictlyPositiveException if {@code param[5] <= 0}.
*/
@Override
public double[] gradient(double x, double ... param)
throws NullArgumentException,
DimensionMismatchException,

View File

@ -17,10 +17,7 @@
package org.apache.commons.math4.analysis.function;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.FunctionUtils;
import org.apache.commons.math4.analysis.ParametricUnivariateFunction;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math4.exception.DimensionMismatchException;
@ -35,7 +32,7 @@ import org.apache.commons.math4.util.FastMath;
*
* @since 3.0
*/
public class Logit implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
public class Logit implements UnivariateDifferentiableFunction {
/** Lower bound. */
private final double lo;
/** Higher bound. */
@ -68,15 +65,6 @@ public class Logit implements UnivariateDifferentiableFunction, DifferentiableUn
return value(x, lo, hi);
}
/** {@inheritDoc}
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
*/
@Override
@Deprecated
public UnivariateFunction derivative() {
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
}
/**
* Parametric function where the input array contains the parameters of
* the logit function, ordered as follows:
@ -96,6 +84,7 @@ public class Logit implements UnivariateDifferentiableFunction, DifferentiableUn
* @throws DimensionMismatchException if the size of {@code param} is
* not 2.
*/
@Override
public double value(double x, double ... param)
throws NullArgumentException,
DimensionMismatchException {
@ -116,6 +105,7 @@ public class Logit implements UnivariateDifferentiableFunction, DifferentiableUn
* @throws DimensionMismatchException if the size of {@code param} is
* not 2.
*/
@Override
public double[] gradient(double x, double ... param)
throws NullArgumentException,
DimensionMismatchException {

View File

@ -17,7 +17,6 @@
package org.apache.commons.math4.analysis.function;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
@ -26,22 +25,13 @@ import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiabl
*
* @since 3.0
*/
public class Minus implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
public class Minus implements UnivariateDifferentiableFunction {
/** {@inheritDoc} */
@Override
public double value(double x) {
return -x;
}
/** {@inheritDoc}
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
*/
@Override
@Deprecated
public DifferentiableUnivariateFunction derivative() {
return new Constant(-1);
}
/** {@inheritDoc}
* @since 3.1
*/

View File

@ -17,9 +17,6 @@
package org.apache.commons.math4.analysis.function;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.FunctionUtils;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math4.util.FastMath;
@ -29,7 +26,7 @@ import org.apache.commons.math4.util.FastMath;
*
* @since 3.0
*/
public class Power implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
public class Power implements UnivariateDifferentiableFunction {
/** Power. */
private final double p;
@ -46,15 +43,6 @@ public class Power implements UnivariateDifferentiableFunction, DifferentiableUn
return FastMath.pow(x, p);
}
/** {@inheritDoc}
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
*/
@Override
@Deprecated
public UnivariateFunction derivative() {
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
}
/** {@inheritDoc}
* @since 3.1
*/

View File

@ -19,10 +19,7 @@ package org.apache.commons.math4.analysis.function;
import java.util.Arrays;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.FunctionUtils;
import org.apache.commons.math4.analysis.ParametricUnivariateFunction;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math4.exception.DimensionMismatchException;
@ -38,7 +35,7 @@ import org.apache.commons.math4.util.FastMath;
*
* @since 3.0
*/
public class Sigmoid implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
public class Sigmoid implements UnivariateDifferentiableFunction {
/** Lower asymptote. */
private final double lo;
/** Higher asymptote. */
@ -64,15 +61,6 @@ public class Sigmoid implements UnivariateDifferentiableFunction, Differentiable
this.hi = hi;
}
/** {@inheritDoc}
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
*/
@Override
@Deprecated
public UnivariateFunction derivative() {
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
}
/** {@inheritDoc} */
@Override
public double value(double x) {
@ -99,6 +87,7 @@ public class Sigmoid implements UnivariateDifferentiableFunction, Differentiable
* @throws DimensionMismatchException if the size of {@code param} is
* not 2.
*/
@Override
public double value(double x, double ... param)
throws NullArgumentException,
DimensionMismatchException {
@ -119,6 +108,7 @@ public class Sigmoid implements UnivariateDifferentiableFunction, Differentiable
* @throws DimensionMismatchException if the size of {@code param} is
* not 2.
*/
@Override
public double[] gradient(double x, double ... param)
throws NullArgumentException,
DimensionMismatchException {

View File

@ -17,7 +17,6 @@
package org.apache.commons.math4.analysis.function;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math4.util.FastMath;
@ -27,22 +26,13 @@ import org.apache.commons.math4.util.FastMath;
*
* @since 3.0
*/
public class Sin implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
public class Sin implements UnivariateDifferentiableFunction {
/** {@inheritDoc} */
@Override
public double value(double x) {
return FastMath.sin(x);
}
/** {@inheritDoc}
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
*/
@Override
@Deprecated
public DifferentiableUnivariateFunction derivative() {
return new Cos();
}
/** {@inheritDoc}
* @since 3.1
*/

View File

@ -17,9 +17,6 @@
package org.apache.commons.math4.analysis.function;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.FunctionUtils;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math4.exception.DimensionMismatchException;
@ -35,7 +32,7 @@ import org.apache.commons.math4.util.FastMath;
*
* @since 3.0
*/
public class Sinc implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
public class Sinc implements UnivariateDifferentiableFunction {
/**
* Value below which the computations are done using Taylor series.
* <p>
@ -95,15 +92,6 @@ public class Sinc implements UnivariateDifferentiableFunction, DifferentiableUni
}
}
/** {@inheritDoc}
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
*/
@Override
@Deprecated
public UnivariateFunction derivative() {
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
}
/** {@inheritDoc}
* @since 3.1
*/

View File

@ -17,7 +17,6 @@
package org.apache.commons.math4.analysis.function;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math4.util.FastMath;
@ -27,22 +26,13 @@ import org.apache.commons.math4.util.FastMath;
*
* @since 3.0
*/
public class Sinh implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
public class Sinh implements UnivariateDifferentiableFunction {
/** {@inheritDoc} */
@Override
public double value(double x) {
return FastMath.sinh(x);
}
/** {@inheritDoc}
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
*/
@Override
@Deprecated
public DifferentiableUnivariateFunction derivative() {
return new Cosh();
}
/** {@inheritDoc}
* @since 3.1
*/

View File

@ -17,9 +17,6 @@
package org.apache.commons.math4.analysis.function;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.FunctionUtils;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math4.util.FastMath;
@ -29,22 +26,13 @@ import org.apache.commons.math4.util.FastMath;
*
* @since 3.0
*/
public class Sqrt implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
public class Sqrt implements UnivariateDifferentiableFunction {
/** {@inheritDoc} */
@Override
public double value(double x) {
return FastMath.sqrt(x);
}
/** {@inheritDoc}
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
*/
@Override
@Deprecated
public UnivariateFunction derivative() {
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
}
/** {@inheritDoc}
* @since 3.1
*/

View File

@ -17,9 +17,6 @@
package org.apache.commons.math4.analysis.function;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.FunctionUtils;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math4.util.FastMath;
@ -29,22 +26,13 @@ import org.apache.commons.math4.util.FastMath;
*
* @since 3.0
*/
public class Tan implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
public class Tan implements UnivariateDifferentiableFunction {
/** {@inheritDoc} */
@Override
public double value(double x) {
return FastMath.tan(x);
}
/** {@inheritDoc}
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
*/
@Override
@Deprecated
public UnivariateFunction derivative() {
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
}
/** {@inheritDoc}
* @since 3.1
*/

View File

@ -17,9 +17,6 @@
package org.apache.commons.math4.analysis.function;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.FunctionUtils;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math4.util.FastMath;
@ -29,22 +26,13 @@ import org.apache.commons.math4.util.FastMath;
*
* @since 3.0
*/
public class Tanh implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
public class Tanh implements UnivariateDifferentiableFunction {
/** {@inheritDoc} */
@Override
public double value(double x) {
return FastMath.tanh(x);
}
/** {@inheritDoc}
* @deprecated as of 3.1, replaced by {@link #value(DerivativeStructure)}
*/
@Override
@Deprecated
public UnivariateFunction derivative() {
return FunctionUtils.toDifferentiableUnivariateFunction(this).derivative();
}
/** {@inheritDoc}
* @since 3.1
*/

View File

@ -158,6 +158,7 @@ public class IterativeLegendreGaussIntegrator
throws TooManyEvaluationsException {
// Function to be integrated is stored in the base class.
final UnivariateFunction f = new UnivariateFunction() {
@Override
public double value(double x)
throws MathIllegalArgumentException, TooManyEvaluationsException {
return computeObjectiveValue(x);

View File

@ -63,6 +63,7 @@ public class AkimaSplineInterpolator
* @throws NumberIsTooSmallException if the size of {@code xvals} is smaller
* than 5.
*/
@Override
public PolynomialSplineFunction interpolate(double[] xvals,
double[] yvals)
throws DimensionMismatchException,

View File

@ -52,6 +52,7 @@ public class DividedDifferenceInterpolator
* @throws NonMonotonicSequenceException if {@code x} is not sorted in
* strictly increasing order.
*/
@Override
public PolynomialFunctionNewtonForm interpolate(double x[], double y[])
throws DimensionMismatchException,
NumberIsTooSmallException,

View File

@ -164,8 +164,8 @@ public class HermiteInterpolator implements UnivariateDifferentiableVectorFuncti
* @return interpolated value
* @exception NoDataException if sample is empty
*/
public double[] value(double x)
throws NoDataException {
@Override
public double[] value(double x) throws NoDataException {
// safety check
checkInterpolation();
@ -196,6 +196,7 @@ public class HermiteInterpolator implements UnivariateDifferentiableVectorFuncti
* @return interpolated value
* @exception NoDataException if sample is empty
*/
@Override
public DerivativeStructure[] value(final DerivativeStructure x)
throws NoDataException {

View File

@ -42,6 +42,7 @@ public class LinearInterpolator implements UnivariateInterpolator {
* @throws NumberIsTooSmallException if the size of {@code x} is smaller
* than 2.
*/
@Override
public PolynomialSplineFunction interpolate(double x[], double y[])
throws DimensionMismatchException,
NumberIsTooSmallException,

View File

@ -180,6 +180,7 @@ public class LoessInterpolator
* accomodate the size of the input data (i.e. the bandwidth must be
* larger than 2/n).
*/
@Override
public final PolynomialSplineFunction interpolate(final double[] xval,
final double[] yval)
throws NonMonotonicSequenceException,

View File

@ -194,6 +194,7 @@ public class MicrosphereInterpolatingFunction
* @return the interpolated value.
* @throws DimensionMismatchException if point dimension does not math sample
*/
@Override
public double value(double[] point) throws DimensionMismatchException {
final RealVector p = new ArrayRealVector(point);

View File

@ -51,6 +51,7 @@ public class NevilleInterpolator implements UnivariateInterpolator,
* @throws NonMonotonicSequenceException if two abscissae have the same
* value.
*/
@Override
public PolynomialFunctionLagrangeForm interpolate(double x[], double y[])
throws DimensionMismatchException,
NumberIsTooSmallException,

View File

@ -62,6 +62,7 @@ public class SplineInterpolator implements UnivariateInterpolator {
* @throws NumberIsTooSmallException if the size of {@code x} is smaller
* than 3.
*/
@Override
public PolynomialSplineFunction interpolate(double x[], double y[])
throws DimensionMismatchException,
NumberIsTooSmallException,

View File

@ -471,8 +471,8 @@ class TricubicFunction
* @throws OutOfRangeException if {@code x}, {@code y} or
* {@code z} are not in the interval {@code [0, 1]}.
*/
public double value(double x, double y, double z)
throws OutOfRangeException {
@Override
public double value(double x, double y, double z) throws OutOfRangeException {
if (x < 0 || x > 1) {
throw new OutOfRangeException(x, 0, 1);
}

View File

@ -116,6 +116,7 @@ public class UnivariatePeriodicInterpolator
final UnivariateFunction f = interpolator.interpolate(x, y);
return new UnivariateFunction() {
@Override
public double value(final double x) throws MathIllegalArgumentException {
return f.value(MathUtils.reduce(x, period, offset));
}

View File

@ -19,9 +19,7 @@ package org.apache.commons.math4.analysis.polynomials;
import java.io.Serializable;
import java.util.Arrays;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.ParametricUnivariateFunction;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math4.exception.NoDataException;
@ -37,7 +35,7 @@ import org.apache.commons.math4.util.MathUtils;
* is used to evaluate the function.</p>
*
*/
public class PolynomialFunction implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction, Serializable {
public class PolynomialFunction implements UnivariateDifferentiableFunction, Serializable {
/**
* Serialization identifier
*/
@ -87,8 +85,10 @@ public class PolynomialFunction implements UnivariateDifferentiableFunction, Dif
*
* @param x Argument for which the function value should be computed.
* @return the value of the polynomial at the given point.
* @see UnivariateFunction#value(double)
* @see {@link org.apache.commons.math4.analysis.UnivariateFunction#value(double)
* UnivariateFunction#value(double)}
*/
@Override
public double value(double x) {
return evaluate(coefficients, x);
}
@ -281,15 +281,6 @@ public class PolynomialFunction implements UnivariateDifferentiableFunction, Dif
return new PolynomialFunction(differentiate(coefficients));
}
/**
* Returns the derivative as a {@link UnivariateFunction}.
*
* @return the derivative function.
*/
public UnivariateFunction derivative() {
return polynomialDerivative();
}
/**
* Returns a string representation of the polynomial.
*

View File

@ -95,6 +95,7 @@ public class PolynomialFunctionLagrangeForm implements UnivariateFunction {
* @throws NumberIsTooSmallException if the size of {@code x} is less
* than 2.
*/
@Override
public double value(double z) {
return evaluateInternal(x, y, z);
}

View File

@ -92,6 +92,7 @@ public class PolynomialFunctionNewtonForm implements UnivariateDifferentiableFun
* @param z Point at which the function value is to be computed.
* @return the function value.
*/
@Override
public double value(double z) {
return evaluate(a, c, z);
}

View File

@ -18,8 +18,6 @@ package org.apache.commons.math4.analysis.polynomials;
import java.util.Arrays;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math4.exception.DimensionMismatchException;
@ -63,7 +61,7 @@ import org.apache.commons.math4.util.MathArrays;
* <code>polynomials[j](x - knot[j])</code></li></ol></p>
*
*/
public class PolynomialSplineFunction implements UnivariateDifferentiableFunction, DifferentiableUnivariateFunction {
public class PolynomialSplineFunction implements UnivariateDifferentiableFunction {
/**
* Spline segment interval delimiters (knots).
* Size is n + 1 for n segments.
@ -132,6 +130,7 @@ public class PolynomialSplineFunction implements UnivariateDifferentiableFunctio
* spline function (smaller than the smallest knot point or larger than the
* largest knot point).
*/
@Override
public double value(double v) {
if (v < knots[0] || v > knots[n]) {
throw new OutOfRangeException(v, knots[0], knots[n]);
@ -149,15 +148,6 @@ public class PolynomialSplineFunction implements UnivariateDifferentiableFunctio
return polynomials[i].value(v - knots[i]);
}
/**
* Get the derivative of the polynomial spline function.
*
* @return the derivative function.
*/
public UnivariateFunction derivative() {
return polynomialSplineDerivative();
}
/**
* Get the derivative of the polynomial spline function.
*

View File

@ -1,82 +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.math4.analysis.solvers;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.exception.TooManyEvaluationsException;
/**
* Provide a default implementation for several functions useful to generic
* solvers.
*
* @since 3.0
* @deprecated as of 3.1, replaced by {@link AbstractUnivariateDifferentiableSolver}
*/
@Deprecated
public abstract class AbstractDifferentiableUnivariateSolver
extends BaseAbstractUnivariateSolver<DifferentiableUnivariateFunction>
implements DifferentiableUnivariateSolver {
/** Derivative of the function to solve. */
private UnivariateFunction functionDerivative;
/**
* Construct a solver with given absolute accuracy.
*
* @param absoluteAccuracy Maximum absolute error.
*/
protected AbstractDifferentiableUnivariateSolver(final double absoluteAccuracy) {
super(absoluteAccuracy);
}
/**
* Construct a solver with given accuracies.
*
* @param relativeAccuracy Maximum relative error.
* @param absoluteAccuracy Maximum absolute error.
* @param functionValueAccuracy Maximum function value error.
*/
protected AbstractDifferentiableUnivariateSolver(final double relativeAccuracy,
final double absoluteAccuracy,
final double functionValueAccuracy) {
super(relativeAccuracy, absoluteAccuracy, functionValueAccuracy);
}
/**
* Compute the objective function value.
*
* @param point Point at which the objective function must be evaluated.
* @return the objective function value at specified point.
* @throws TooManyEvaluationsException if the maximal number of evaluations is exceeded.
*/
protected double computeDerivativeObjectiveValue(double point)
throws TooManyEvaluationsException {
incrementEvaluationCount();
return functionDerivative.value(point);
}
/**
* {@inheritDoc}
*/
@Override
protected void setup(int maxEval, DifferentiableUnivariateFunction f,
double min, double max, double startValue) {
super.setup(maxEval, f, min, max, startValue);
functionDerivative = f.derivative();
}
}

View File

@ -1,30 +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.math4.analysis.solvers;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
/**
* Interface for (univariate real) rootfinding algorithms.
* Implementations will search for only one zero in the given interval.
*
* @deprecated as of 3.1, replaced by {@link UnivariateDifferentiableSolver}
*/
@Deprecated
public interface DifferentiableUnivariateSolver
extends BaseUnivariateSolver<DifferentiableUnivariateFunction> {}

View File

@ -17,15 +17,7 @@
package org.apache.commons.math4.analysis;
import org.apache.commons.math4.analysis.BivariateFunction;
import org.apache.commons.math4.analysis.DifferentiableMultivariateFunction;
import org.apache.commons.math4.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math4.analysis.FunctionUtils;
import org.apache.commons.math4.analysis.MultivariateFunction;
import org.apache.commons.math4.analysis.MultivariateVectorFunction;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.MultivariateDifferentiableFunction;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math4.analysis.function.Add;
import org.apache.commons.math4.analysis.function.Constant;
@ -241,116 +233,4 @@ public class FunctionUtilsTest {
}
}
@Test
@Deprecated
public void testToDifferentiableUnivariateFunction() {
// Sin implements both UnivariateDifferentiableFunction and DifferentiableUnivariateFunction
Sin sin = new Sin();
DifferentiableUnivariateFunction converted = FunctionUtils.toDifferentiableUnivariateFunction(sin);
for (double x = 0.1; x < 0.5; x += 0.01) {
Assert.assertEquals(sin.value(x), converted.value(x), 1.0e-10);
Assert.assertEquals(sin.derivative().value(x), converted.derivative().value(x), 1.0e-10);
}
}
@Test
@Deprecated
public void testToUnivariateDifferential() {
// Sin implements both UnivariateDifferentiableFunction and DifferentiableUnivariateFunction
Sin sin = new Sin();
UnivariateDifferentiableFunction converted = FunctionUtils.toUnivariateDifferential(sin);
for (double x = 0.1; x < 0.5; x += 0.01) {
DerivativeStructure t = new DerivativeStructure(2, 1, x, 1.0, 2.0);
Assert.assertEquals(sin.value(t).getValue(), converted.value(t).getValue(), 1.0e-10);
Assert.assertEquals(sin.value(t).getPartialDerivative(1, 0),
converted.value(t).getPartialDerivative(1, 0),
1.0e-10);
Assert.assertEquals(sin.value(t).getPartialDerivative(0, 1),
converted.value(t).getPartialDerivative(0, 1),
1.0e-10);
}
}
@Test
@Deprecated
public void testToDifferentiableMultivariateFunction() {
MultivariateDifferentiableFunction hypot = new MultivariateDifferentiableFunction() {
public double value(double[] point) {
return FastMath.hypot(point[0], point[1]);
}
public DerivativeStructure value(DerivativeStructure[] point) {
return DerivativeStructure.hypot(point[0], point[1]);
}
};
DifferentiableMultivariateFunction converted = FunctionUtils.toDifferentiableMultivariateFunction(hypot);
for (double x = 0.1; x < 0.5; x += 0.01) {
for (double y = 0.1; y < 0.5; y += 0.01) {
double[] point = new double[] { x, y };
Assert.assertEquals(hypot.value(point), converted.value(point), 1.0e-10);
Assert.assertEquals(x / hypot.value(point), converted.gradient().value(point)[0], 1.0e-10);
Assert.assertEquals(y / hypot.value(point), converted.gradient().value(point)[1], 1.0e-10);
}
}
}
@Test
@Deprecated
public void testToMultivariateDifferentiableFunction() {
DifferentiableMultivariateFunction hypot = new DifferentiableMultivariateFunction() {
public double value(double[] point) {
return FastMath.hypot(point[0], point[1]);
}
public MultivariateFunction partialDerivative(final int k) {
return new MultivariateFunction() {
public double value(double[] point) {
return point[k] / FastMath.hypot(point[0], point[1]);
}
};
}
public MultivariateVectorFunction gradient() {
return new MultivariateVectorFunction() {
public double[] value(double[] point) {
final double h = FastMath.hypot(point[0], point[1]);
return new double[] { point[0] / h, point[1] / h };
}
};
}
};
MultivariateDifferentiableFunction converted = FunctionUtils.toMultivariateDifferentiableFunction(hypot);
for (double x = 0.1; x < 0.5; x += 0.01) {
for (double y = 0.1; y < 0.5; y += 0.01) {
DerivativeStructure[] t = new DerivativeStructure[] {
new DerivativeStructure(3, 1, x, 1.0, 2.0, 3.0 ),
new DerivativeStructure(3, 1, y, 4.0, 5.0, 6.0 )
};
DerivativeStructure h = DerivativeStructure.hypot(t[0], t[1]);
Assert.assertEquals(h.getValue(), converted.value(t).getValue(), 1.0e-10);
Assert.assertEquals(h.getPartialDerivative(1, 0, 0),
converted.value(t).getPartialDerivative(1, 0, 0),
1.0e-10);
Assert.assertEquals(h.getPartialDerivative(0, 1, 0),
converted.value(t).getPartialDerivative(0, 1, 0),
1.0e-10);
Assert.assertEquals(h.getPartialDerivative(0, 0, 1),
converted.value(t).getPartialDerivative(0, 0, 1),
1.0e-10);
}
}
}
}

View File

@ -16,7 +16,6 @@
*/
package org.apache.commons.math4.analysis;
import org.apache.commons.math4.analysis.UnivariateFunction;
/**
* Wrapper class for counting functions calls.
@ -37,12 +36,13 @@ public class MonitoredFunction implements UnivariateFunction {
return callsCount;
}
@Override
public double value(double x) {
++callsCount;
return f.value(x);
}
private int callsCount;
private UnivariateFunction f;
private final UnivariateFunction f;
}

View File

@ -28,10 +28,12 @@ public class QuinticFunction implements UnivariateDifferentiableFunction {
/* Evaluate quintic.
* @see org.apache.commons.math4.UnivariateFunction#value(double)
*/
@Override
public double value(double x) {
return (x-1)*(x-0.5)*x*(x+0.5)*(x+1);
}
@Override
public DerivativeStructure value(DerivativeStructure t) {
return t.subtract(1).multiply(t.subtract(0.5)).multiply(t).multiply(t.add(0.5)).multiply(t.add(1));
}

View File

@ -16,8 +16,6 @@
*/
package org.apache.commons.math4.analysis;
import org.apache.commons.math4.analysis.MultivariateFunction;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.function.Sinc;
/**
@ -43,6 +41,7 @@ public class SumSincFunction implements MultivariateFunction {
* @param point Argument.
* @return the value of this function at point {@code x}.
*/
@Override
public double value(double[] point) {
double sum = 0;
for (int i = 0, max = point.length; i < max; i++) {

View File

@ -25,13 +25,15 @@ import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiabl
*/
public class XMinus5Function implements UnivariateDifferentiableFunction {
/* Evaluate x - 5 fuction.
/* Evaluate x - 5 function.
* @see org.apache.commons.math4.UnivariateFunction#value(double)
*/
@Override
public double value(double x) {
return x - 5;
}
@Override
public DerivativeStructure value(DerivativeStructure t) {
return t.subtract(5);
}

View File

@ -22,12 +22,6 @@ import org.apache.commons.math4.analysis.QuinticFunction;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.UnivariateMatrixFunction;
import org.apache.commons.math4.analysis.UnivariateVectorFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.FiniteDifferencesDifferentiator;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableMatrixFunction;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableVectorFunction;
import org.apache.commons.math4.analysis.differentiation.UnivariateFunctionDifferentiator;
import org.apache.commons.math4.analysis.function.Gaussian;
import org.apache.commons.math4.analysis.function.Sin;
import org.apache.commons.math4.exception.MathInternalError;
@ -69,6 +63,7 @@ public class FiniteDifferencesDifferentiatorTest {
new FiniteDifferencesDifferentiator(5, 0.01);
UnivariateDifferentiableFunction f =
differentiator.differentiate(new UnivariateFunction() {
@Override
public double value(double x) {
return 42.0;
}
@ -87,6 +82,7 @@ public class FiniteDifferencesDifferentiatorTest {
new FiniteDifferencesDifferentiator(5, 0.01);
UnivariateDifferentiableFunction f =
differentiator.differentiate(new UnivariateFunction() {
@Override
public double value(double x) {
return 2 - 3 * x;
}
@ -159,7 +155,7 @@ public class FiniteDifferencesDifferentiatorTest {
// the 1.0e-6 step size is far too small for finite differences in the quintic on this abscissa range for 7 points
// the errors are huge!
final double[] expectedBad = new double[] {
2.910e-11, 2.087e-5, 147.7, 3.820e7, 6.354e14, 6.548e19, 1.543e27
2.910e-11, 2.087e-5, 147.7, 3.820e7, 6.354e14, 6.548e19, 1.543e27
};
for (int i = 0; i < maxErrorGood.length; ++i) {
@ -173,6 +169,7 @@ public class FiniteDifferencesDifferentiatorTest {
public void testWrongOrder() {
UnivariateDifferentiableFunction f =
new FiniteDifferencesDifferentiator(3, 0.01).differentiate(new UnivariateFunction() {
@Override
public double value(double x) {
// this exception should not be thrown because wrong order
// should be detected before function call
@ -186,6 +183,7 @@ public class FiniteDifferencesDifferentiatorTest {
public void testWrongOrderVector() {
UnivariateDifferentiableVectorFunction f =
new FiniteDifferencesDifferentiator(3, 0.01).differentiate(new UnivariateVectorFunction() {
@Override
public double[] value(double x) {
// this exception should not be thrown because wrong order
// should be detected before function call
@ -199,6 +197,7 @@ public class FiniteDifferencesDifferentiatorTest {
public void testWrongOrderMatrix() {
UnivariateDifferentiableMatrixFunction f =
new FiniteDifferencesDifferentiator(3, 0.01).differentiate(new UnivariateMatrixFunction() {
@Override
public double[][] value(double x) {
// this exception should not be thrown because wrong order
// should be detected before function call
@ -218,6 +217,7 @@ public class FiniteDifferencesDifferentiatorTest {
final double slope = 2.5;
UnivariateFunction f = new UnivariateFunction() {
@Override
public double value(double x) {
if (x < 0) {
throw new NumberIsTooSmallException(x, 0, true);
@ -261,11 +261,11 @@ public class FiniteDifferencesDifferentiatorTest {
// here, we did set the bounds, so evaluations are done within domain
// using f(0.0), f(0.1), f(0.2)
Assert.assertEquals(slope, properlyBounded.value(tLow).getPartialDerivative(1), 1.0e-10);
// here, we did set the bounds, so evaluations are done within domain
// using f(0.8), f(0.9), f(1.0)
Assert.assertEquals(slope, properlyBounded.value(tHigh).getPartialDerivative(1), 1.0e-10);
}
@Test
@ -274,6 +274,7 @@ public class FiniteDifferencesDifferentiatorTest {
UnivariateFunctionDifferentiator differentiator =
new FiniteDifferencesDifferentiator(9, 1.0 / 32, 0.0, Double.POSITIVE_INFINITY);
UnivariateDifferentiableFunction sqrt = differentiator.differentiate(new UnivariateFunction() {
@Override
public double value(double x) {
return FastMath.sqrt(x);
}
@ -296,11 +297,12 @@ public class FiniteDifferencesDifferentiatorTest {
new FiniteDifferencesDifferentiator(7, 0.01);
UnivariateDifferentiableVectorFunction f =
differentiator.differentiate(new UnivariateVectorFunction() {
@Override
public double[] value(double x) {
return new double[] { FastMath.cos(x), FastMath.sin(x) };
}
});
for (double x = -10; x < 10; x += 0.1) {
@ -331,14 +333,15 @@ public class FiniteDifferencesDifferentiatorTest {
new FiniteDifferencesDifferentiator(7, 0.01);
UnivariateDifferentiableMatrixFunction f =
differentiator.differentiate(new UnivariateMatrixFunction() {
@Override
public double[][] value(double x) {
return new double[][] {
{ FastMath.cos(x), FastMath.sin(x) },
{ FastMath.cosh(x), FastMath.sinh(x) }
};
}
});
for (double x = -1; x < 1; x += 0.02) {

View File

@ -18,9 +18,6 @@
package org.apache.commons.math4.analysis.differentiation;
import org.apache.commons.math4.TestUtils;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.GradientFunction;
import org.apache.commons.math4.analysis.differentiation.MultivariateDifferentiableFunction;
import org.apache.commons.math4.exception.DimensionMismatchException;
import org.apache.commons.math4.exception.MathIllegalArgumentException;
import org.apache.commons.math4.util.FastMath;
@ -59,7 +56,8 @@ public class GradientFunctionTest {
}
private static class EuclideanDistance implements MultivariateDifferentiableFunction {
@Override
public double value(double[] point) {
double d2 = 0;
for (double x : point) {
@ -67,7 +65,8 @@ public class GradientFunctionTest {
}
return FastMath.sqrt(d2);
}
@Override
public DerivativeStructure value(DerivativeStructure[] point)
throws DimensionMismatchException, MathIllegalArgumentException {
DerivativeStructure d2 = point[0].getField().getZero();

View File

@ -17,12 +17,9 @@
package org.apache.commons.math4.analysis.differentiation;
import org.junit.Assert;
import org.apache.commons.math4.TestUtils;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.JacobianFunction;
import org.apache.commons.math4.analysis.differentiation.MultivariateDifferentiableVectorFunction;
import org.apache.commons.math4.util.FastMath;
import org.junit.Assert;
import org.junit.Test;
@ -56,7 +53,8 @@ public class JacobianFunctionTest {
public SphereMapping(final double radius) {
this.radius = radius;
}
@Override
public double[] value(double[] point) {
final double cLat = FastMath.cos(point[0]);
final double sLat = FastMath.sin(point[0]);
@ -68,7 +66,8 @@ public class JacobianFunctionTest {
radius * sLat
};
}
@Override
public DerivativeStructure[] value(DerivativeStructure[] point) {
final DerivativeStructure cLat = point[0].cos();
final DerivativeStructure sLat = point[0].sin();

View File

@ -21,7 +21,6 @@ import java.util.List;
import org.apache.commons.math4.ExtendedFieldElementAbstractTest;
import org.apache.commons.math4.TestUtils;
import org.apache.commons.math4.analysis.differentiation.SparseGradient;
import org.apache.commons.math4.analysis.polynomials.PolynomialFunction;
import org.apache.commons.math4.random.Well1024a;
import org.apache.commons.math4.util.FastMath;
@ -309,7 +308,7 @@ public class SparseGradientTest extends ExtendedFieldElementAbstractTest<SparseG
Assert.assertEquals(dfdx, sg.getDerivative(0), FastMath.abs(epsilon * dfdx));
}
}
}
}
@ -353,7 +352,7 @@ public class SparseGradientTest extends ExtendedFieldElementAbstractTest<SparseG
Assert.assertEquals(dfdz, f.getDerivative(2), FastMath.abs(epsilon * dfdz));
}
}
}
}
}
@Test
@ -952,7 +951,7 @@ public class SparseGradientTest extends ExtendedFieldElementAbstractTest<SparseG
for (int i = poly.degree(); i >= 0; --i) {
sgY1 = sgY1.multiply(sgX).add(poly.getCoefficients()[i]);
}
SparseGradient sgY2 = sgX.compose(poly.value(x), poly.derivative().value(x));
SparseGradient sgY2 = sgX.compose(poly.value(x), poly.polynomialDerivative().value(x));
SparseGradient zero = sgY1.subtract(sgY2);
checkF0F1(zero, 0.0, 0.0);
}

View File

@ -18,7 +18,6 @@ package org.apache.commons.math4.analysis.function;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.function.Sinc;
import org.apache.commons.math4.dfp.Dfp;
import org.apache.commons.math4.dfp.DfpField;
import org.apache.commons.math4.dfp.DfpMath;
@ -32,6 +31,7 @@ public class SincTest {
public void testShortcut() {
final Sinc s = new Sinc();
final UnivariateFunction f = new UnivariateFunction() {
@Override
public double value(double x) {
Dfp dfpX = new DfpField(25).newDfp(x);
return DfpMath.sin(dfpX).divide(dfpX).toDouble();
@ -106,7 +106,8 @@ public class SincTest {
public void testDerivativeShortcut() {
final Sinc sinc = new Sinc();
final UnivariateFunction f = new UnivariateFunction() {
public double value(double x) {
@Override
public double value(double x) {
Dfp dfpX = new DfpField(25).newDfp(x);
return DfpMath.cos(dfpX).subtract(DfpMath.sin(dfpX).divide(dfpX)).divide(dfpX).toDouble();
}

View File

@ -19,20 +19,20 @@ package org.apache.commons.math4.analysis.function;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.differentiation.DerivativeStructure;
import org.apache.commons.math4.analysis.differentiation.UnivariateDifferentiableFunction;
import org.apache.commons.math4.analysis.function.Sqrt;
import org.apache.commons.math4.util.FastMath;
import org.junit.Test;
import org.junit.Assert;
import org.junit.Test;
public class SqrtTest {
@Test
public void testComparison() {
final Sqrt s = new Sqrt();
final UnivariateFunction f = new UnivariateFunction() {
public double value(double x) {
return FastMath.sqrt(x);
}
};
@Override
public double value(double x) {
return FastMath.sqrt(x);
}
};
for (double x = 1e-30; x < 1e10; x *= 2) {
final double fX = f.value(x);
@ -45,7 +45,8 @@ public class SqrtTest {
public void testDerivativeComparison() {
final UnivariateDifferentiableFunction sPrime = new Sqrt();
final UnivariateFunction f = new UnivariateFunction() {
public double value(double x) {
@Override
public double value(double x) {
return 1 / (2 * FastMath.sqrt(x));
}
};

View File

@ -22,9 +22,6 @@ import org.apache.commons.math4.analysis.QuinticFunction;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.function.Gaussian;
import org.apache.commons.math4.analysis.function.Sin;
import org.apache.commons.math4.analysis.integration.BaseAbstractUnivariateIntegrator;
import org.apache.commons.math4.analysis.integration.IterativeLegendreGaussIntegrator;
import org.apache.commons.math4.analysis.integration.UnivariateIntegrator;
import org.apache.commons.math4.analysis.polynomials.PolynomialFunction;
import org.apache.commons.math4.exception.TooManyEvaluationsException;
import org.apache.commons.math4.util.FastMath;
@ -128,6 +125,7 @@ public class IterativeLegendreGaussIntegratorTest {
public void testIssue464() {
final double value = 0.2;
UnivariateFunction f = new UnivariateFunction() {
@Override
public double value(double x) {
return (x >= 0 && x <= 5) ? value : 0.0;
}

View File

@ -16,9 +16,10 @@
*/
package org.apache.commons.math4.analysis.interpolation;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.interpolation.AkimaSplineInterpolator;
import org.apache.commons.math4.analysis.interpolation.UnivariateInterpolator;
import org.apache.commons.math4.distribution.UniformRealDistribution;
import org.apache.commons.math4.exception.DimensionMismatchException;
import org.apache.commons.math4.exception.NonMonotonicSequenceException;
@ -31,8 +32,6 @@ import org.apache.commons.math4.util.Precision;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.Assert.*;
public class AkimaSplineInterpolatorTest
{
@ -119,6 +118,7 @@ public class AkimaSplineInterpolatorTest
UnivariateFunction f = new UnivariateFunction()
{
@Override
public double value( double x )
{
return 2 * x - 5;
@ -147,6 +147,7 @@ public class AkimaSplineInterpolatorTest
UnivariateFunction f = new UnivariateFunction()
{
@Override
public double value( double x )
{
return ( 3 * x * x ) - ( 5 * x ) + 7;
@ -174,6 +175,7 @@ public class AkimaSplineInterpolatorTest
UnivariateFunction f = new UnivariateFunction()
{
@Override
public double value( double x )
{
return ( 3 * x * x * x ) - ( 0.5 * x * x ) + ( 1 * x ) - 1;

View File

@ -17,7 +17,6 @@
package org.apache.commons.math4.analysis.interpolation;
import org.apache.commons.math4.analysis.BivariateFunction;
import org.apache.commons.math4.analysis.interpolation.BicubicInterpolatingFunction;
import org.apache.commons.math4.distribution.UniformRealDistribution;
import org.apache.commons.math4.exception.DimensionMismatchException;
import org.apache.commons.math4.exception.MathIllegalArgumentException;
@ -28,7 +27,6 @@ import org.apache.commons.math4.util.FastMath;
import org.apache.commons.math4.util.Precision;
import org.junit.Assert;
import org.junit.Test;
import org.junit.Ignore;
/**
* Test case for the bicubic function.
@ -193,21 +191,25 @@ public final class BicubicInterpolatingFunctionTest {
// Function values
BivariateFunction f = new BivariateFunction() {
@Override
public double value(double x, double y) {
return 2 * x - 3 * y + 5;
}
};
BivariateFunction dfdx = new BivariateFunction() {
@Override
public double value(double x, double y) {
return 2;
}
};
BivariateFunction dfdy = new BivariateFunction() {
@Override
public double value(double x, double y) {
return -3;
}
};
BivariateFunction d2fdxdy = new BivariateFunction() {
@Override
public double value(double x, double y) {
return 0;
}
@ -247,21 +249,25 @@ public final class BicubicInterpolatingFunctionTest {
// Function values
BivariateFunction f = new BivariateFunction() {
@Override
public double value(double x, double y) {
return 2 * x * x - 3 * y * y + 4 * x * y - 5;
}
};
BivariateFunction dfdx = new BivariateFunction() {
@Override
public double value(double x, double y) {
return 4 * (x + y);
}
};
BivariateFunction dfdy = new BivariateFunction() {
@Override
public double value(double x, double y) {
return 4 * x - 6 * y;
}
};
BivariateFunction d2fdxdy = new BivariateFunction() {
@Override
public double value(double x, double y) {
return 4;
}

View File

@ -17,9 +17,6 @@
package org.apache.commons.math4.analysis.interpolation;
import org.apache.commons.math4.analysis.BivariateFunction;
import org.apache.commons.math4.analysis.interpolation.BicubicInterpolatingFunction;
import org.apache.commons.math4.analysis.interpolation.BicubicInterpolator;
import org.apache.commons.math4.analysis.interpolation.BivariateGridInterpolator;
import org.apache.commons.math4.distribution.UniformRealDistribution;
import org.apache.commons.math4.exception.DimensionMismatchException;
import org.apache.commons.math4.exception.MathIllegalArgumentException;
@ -86,6 +83,7 @@ public final class BicubicInterpolatorTest {
@Test
public void testPlane() {
BivariateFunction f = new BivariateFunction() {
@Override
public double value(double x, double y) {
return 2 * x - 3 * y + 5;
}
@ -105,6 +103,7 @@ public final class BicubicInterpolatorTest {
@Test
public void testParaboloid() {
BivariateFunction f = new BivariateFunction() {
@Override
public double value(double x, double y) {
return 2 * x * x - 3 * y * y + 4 * x * y - 5;
}

View File

@ -17,8 +17,6 @@
package org.apache.commons.math4.analysis.interpolation;
import org.apache.commons.math4.analysis.MultivariateFunction;
import org.apache.commons.math4.analysis.interpolation.MicrosphereInterpolator;
import org.apache.commons.math4.analysis.interpolation.MultivariateInterpolator;
import org.apache.commons.math4.util.FastMath;
import org.junit.Assert;
import org.junit.Test;
@ -36,13 +34,14 @@ public final class MicrosphereInterpolatorTest {
@Test
public void testLinearFunction2D() {
MultivariateFunction f = new MultivariateFunction() {
public double value(double[] x) {
if (x.length != 2) {
throw new IllegalArgumentException();
}
return 2 * x[0] - 3 * x[1] + 5;
@Override
public double value(double[] x) {
if (x.length != 2) {
throw new IllegalArgumentException();
}
};
return 2 * x[0] - 3 * x[1] + 5;
}
};
MultivariateInterpolator interpolator = new MicrosphereInterpolator();
@ -88,6 +87,7 @@ public final class MicrosphereInterpolatorTest {
@Test
public void testParaboloid2D() {
MultivariateFunction f = new MultivariateFunction() {
@Override
public double value(double[] x) {
if (x.length != 2) {
throw new IllegalArgumentException();

View File

@ -17,7 +17,6 @@
package org.apache.commons.math4.analysis.interpolation;
import org.apache.commons.math4.analysis.BivariateFunction;
import org.apache.commons.math4.analysis.interpolation.PiecewiseBicubicSplineInterpolatingFunction;
import org.apache.commons.math4.distribution.UniformRealDistribution;
import org.apache.commons.math4.exception.DimensionMismatchException;
import org.apache.commons.math4.exception.InsufficientDataException;
@ -145,6 +144,7 @@ public final class PiecewiseBicubicSplineInterpolatingFunctionTest {
// Function values
BivariateFunction f = new BivariateFunction() {
@Override
public double value(double x, double y) {
return 2 * x - 3 * y + 5;
}
@ -180,6 +180,7 @@ public final class PiecewiseBicubicSplineInterpolatingFunctionTest {
// Function values
BivariateFunction f = new BivariateFunction() {
@Override
public double value(double x, double y) {
return 2 * x * x - 3 * y * y + 4 * x * y - 5;
}

View File

@ -17,12 +17,9 @@
package org.apache.commons.math4.analysis.interpolation;
import org.apache.commons.math4.analysis.BivariateFunction;
import org.apache.commons.math4.analysis.interpolation.BivariateGridInterpolator;
import org.apache.commons.math4.analysis.interpolation.PiecewiseBicubicSplineInterpolator;
import org.apache.commons.math4.distribution.UniformRealDistribution;
import org.apache.commons.math4.exception.DimensionMismatchException;
import org.apache.commons.math4.exception.InsufficientDataException;
import org.apache.commons.math4.exception.MathIllegalArgumentException;
import org.apache.commons.math4.exception.NonMonotonicSequenceException;
import org.apache.commons.math4.exception.NullArgumentException;
import org.apache.commons.math4.random.RandomGenerator;
@ -43,7 +40,6 @@ public final class PiecewiseBicubicSplineInterpolatorTest {
double[] yval = new double[] { -4, -3, -1, 2.5, 3.5 };
double[][] zval = new double[xval.length][yval.length];
@SuppressWarnings( "unused" )
BivariateGridInterpolator interpolator = new PiecewiseBicubicSplineInterpolator();
try {
@ -145,6 +141,7 @@ public final class PiecewiseBicubicSplineInterpolatorTest {
// Function values
BivariateFunction f = new BivariateFunction() {
@Override
public double value( double x, double y ) {
return 2 * x - 3 * y + 5;
}
@ -196,6 +193,7 @@ public final class PiecewiseBicubicSplineInterpolatorTest {
// Function values
BivariateFunction f = new BivariateFunction() {
@Override
public double value( double x, double y ) {
return 2 * x * x - 3 * y * y + 4 * x * y - 5;
}

View File

@ -18,8 +18,6 @@ package org.apache.commons.math4.analysis.interpolation;
import org.apache.commons.math4.TestUtils;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.interpolation.SplineInterpolator;
import org.apache.commons.math4.analysis.interpolation.UnivariateInterpolator;
import org.apache.commons.math4.analysis.polynomials.PolynomialFunction;
import org.apache.commons.math4.analysis.polynomials.PolynomialSplineFunction;
import org.apache.commons.math4.exception.DimensionMismatchException;
@ -215,10 +213,10 @@ public class SplineInterpolatorTest {
for (int i = 1; i < x.length - 2; i++) {
// evaluate polynomials and derivatives at x[i + 1]
Assert.assertEquals(polynomials[i].value(x[i +1] - x[i]), polynomials[i + 1].value(0), 0.1);
Assert.assertEquals(polynomials[i].derivative().value(x[i +1] - x[i]),
polynomials[i + 1].derivative().value(0), 0.5);
Assert.assertEquals(polynomials[i].polynomialDerivative().derivative().value(x[i +1] - x[i]),
polynomials[i + 1].polynomialDerivative().derivative().value(0), 0.5);
Assert.assertEquals(polynomials[i].polynomialDerivative().value(x[i +1] - x[i]),
polynomials[i + 1].polynomialDerivative().value(0), 0.5);
Assert.assertEquals(polynomials[i].polynomialDerivative().polynomialDerivative().value(x[i +1] - x[i]),
polynomials[i + 1].polynomialDerivative().polynomialDerivative().value(0), 0.5);
}
}

View File

@ -17,7 +17,6 @@
package org.apache.commons.math4.analysis.interpolation;
import org.apache.commons.math4.analysis.TrivariateFunction;
import org.apache.commons.math4.analysis.interpolation.TricubicInterpolatingFunction;
import org.apache.commons.math4.distribution.UniformRealDistribution;
import org.apache.commons.math4.exception.DimensionMismatchException;
import org.apache.commons.math4.exception.MathIllegalArgumentException;
@ -30,7 +29,6 @@ import org.junit.Test;
/**
* Test case for the bicubic function.
*
*/
public final class TricubicInterpolatingFunctionTest {
/**
@ -47,7 +45,7 @@ public final class TricubicInterpolatingFunctionTest {
TrivariateFunction tcf = new TricubicInterpolatingFunction(xval, yval, zval,
fval, fval, fval, fval,
fval, fval, fval, fval);
double[] wxval = new double[] {3, 2, 5, 6.5};
try {
tcf = new TricubicInterpolatingFunction(wxval, yval, zval,
@ -420,30 +418,35 @@ public final class TricubicInterpolatingFunctionTest {
@Test
public void testPlane() {
final TrivariateFunction f = new TrivariateFunction() {
@Override
public double value(double x, double y, double z) {
return 2 * x - 3 * y - 4 * z + 5;
}
};
final TrivariateFunction dfdx = new TrivariateFunction() {
@Override
public double value(double x, double y, double z) {
return 2;
}
};
final TrivariateFunction dfdy = new TrivariateFunction() {
@Override
public double value(double x, double y, double z) {
return -3;
}
};
final TrivariateFunction dfdz = new TrivariateFunction() {
@Override
public double value(double x, double y, double z) {
return -4;
}
};
final TrivariateFunction zero = new TrivariateFunction() {
@Override
public double value(double x, double y, double z) {
return 0;
}
@ -477,48 +480,56 @@ public final class TricubicInterpolatingFunctionTest {
@Test
public void testQuadric() {
final TrivariateFunction f = new TrivariateFunction() {
@Override
public double value(double x, double y, double z) {
return 2 * x * x - 3 * y * y - 4 * z * z + 5 * x * y + 6 * x * z - 2 * y * z + 3;
}
};
final TrivariateFunction dfdx = new TrivariateFunction() {
@Override
public double value(double x, double y, double z) {
return 4 * x + 5 * y + 6 * z;
}
};
final TrivariateFunction dfdy = new TrivariateFunction() {
@Override
public double value(double x, double y, double z) {
return -6 * y + 5 * x - 2 * z;
}
};
final TrivariateFunction dfdz = new TrivariateFunction() {
@Override
public double value(double x, double y, double z) {
return -8 * z + 6 * x - 2 * y;
}
};
final TrivariateFunction d2fdxdy = new TrivariateFunction() {
@Override
public double value(double x, double y, double z) {
return 5;
}
};
final TrivariateFunction d2fdxdz = new TrivariateFunction() {
@Override
public double value(double x, double y, double z) {
return 6;
}
};
final TrivariateFunction d2fdydz = new TrivariateFunction() {
@Override
public double value(double x, double y, double z) {
return -2;
}
};
final TrivariateFunction d3fdxdydz = new TrivariateFunction() {
@Override
public double value(double x, double y, double z) {
return 0;
}
@ -558,54 +569,63 @@ public final class TricubicInterpolatingFunctionTest {
final double ky = 1;
final TrivariateFunction arg = new TrivariateFunction() {
@Override
public double value(double x, double y, double z) {
return omega * z - kx * x - ky * y;
}
};
final TrivariateFunction f = new TrivariateFunction() {
@Override
public double value(double x, double y, double z) {
return a * FastMath.cos(arg.value(x, y, z));
}
};
final TrivariateFunction dfdx = new TrivariateFunction() {
@Override
public double value(double x, double y, double z) {
return kx * a * FastMath.sin(arg.value(x, y, z));
}
};
final TrivariateFunction dfdy = new TrivariateFunction() {
@Override
public double value(double x, double y, double z) {
return ky * a * FastMath.sin(arg.value(x, y, z));
}
};
final TrivariateFunction dfdz = new TrivariateFunction() {
@Override
public double value(double x, double y, double z) {
return -omega * a * FastMath.sin(arg.value(x, y, z));
}
};
final TrivariateFunction d2fdxdy = new TrivariateFunction() {
@Override
public double value(double x, double y, double z) {
return -ky * kx * a * FastMath.cos(arg.value(x, y, z));
}
};
final TrivariateFunction d2fdxdz = new TrivariateFunction() {
@Override
public double value(double x, double y, double z) {
return omega * kx * a * FastMath.cos(arg.value(x, y, z));
}
};
final TrivariateFunction d2fdydz = new TrivariateFunction() {
@Override
public double value(double x, double y, double z) {
return omega * ky * a * FastMath.cos(arg.value(x, y, z));
}
};
final TrivariateFunction d3fdxdydz = new TrivariateFunction() {
@Override
public double value(double x, double y, double z) {
return omega * ky * kx * a * FastMath.sin(arg.value(x, y, z));
}

View File

@ -17,8 +17,6 @@
package org.apache.commons.math4.analysis.interpolation;
import org.apache.commons.math4.analysis.TrivariateFunction;
import org.apache.commons.math4.analysis.interpolation.TricubicInterpolatingFunction;
import org.apache.commons.math4.analysis.interpolation.TricubicInterpolator;
import org.apache.commons.math4.exception.DimensionMismatchException;
import org.apache.commons.math4.exception.MathIllegalArgumentException;
import org.apache.commons.math4.util.FastMath;
@ -127,6 +125,7 @@ public final class TricubicInterpolatorTest {
// Function values
TrivariateFunction f = new TrivariateFunction() {
@Override
public double value(double x, double y, double z) {
return 2 * x - 3 * y - 4 * z + 5;
}
@ -186,6 +185,7 @@ public final class TricubicInterpolatorTest {
// Function values
TrivariateFunction f = new TrivariateFunction() {
@Override
public double value(double x, double y, double z) {
return a * FastMath.cos(omega * z - kx * x - ky * y);
}

View File

@ -17,10 +17,9 @@
package org.apache.commons.math4.analysis.polynomials;
import org.apache.commons.math4.TestUtils;
import org.apache.commons.math4.analysis.polynomials.PolynomialFunction;
import org.apache.commons.math4.util.FastMath;
import org.junit.Test;
import org.junit.Assert;
import org.junit.Test;
/**
* Tests the PolynomialFunction implementation of a UnivariateFunction.
@ -48,9 +47,9 @@ public final class PolynomialFunctionTest {
Assert.assertEquals(f.value(456.89), c[0], tolerance);
Assert.assertEquals(f.degree(), 0);
Assert.assertEquals(f.derivative().value(0), 0, tolerance);
Assert.assertEquals(f.polynomialDerivative().value(0), 0, tolerance);
Assert.assertEquals(f.polynomialDerivative().derivative().value(0), 0, tolerance);
Assert.assertEquals(f.polynomialDerivative().polynomialDerivative().value(0), 0, tolerance);
}
/**
@ -79,7 +78,7 @@ public final class PolynomialFunctionTest {
Assert.assertEquals(f.degree(), 1);
Assert.assertEquals(f.polynomialDerivative().derivative().value(0), 0, tolerance);
Assert.assertEquals(f.polynomialDerivative().polynomialDerivative().value(0), 0, tolerance);
}
/**
@ -142,15 +141,15 @@ public final class PolynomialFunctionTest {
PolynomialFunction h = new PolynomialFunction(h_coeff);
// compare f' = g
Assert.assertEquals(f.derivative().value(0), g.value(0), tolerance);
Assert.assertEquals(f.derivative().value(1), g.value(1), tolerance);
Assert.assertEquals(f.derivative().value(100), g.value(100), tolerance);
Assert.assertEquals(f.derivative().value(4.1), g.value(4.1), tolerance);
Assert.assertEquals(f.derivative().value(-3.25), g.value(-3.25), tolerance);
Assert.assertEquals(f.polynomialDerivative().value(0), g.value(0), tolerance);
Assert.assertEquals(f.polynomialDerivative().value(1), g.value(1), tolerance);
Assert.assertEquals(f.polynomialDerivative().value(100), g.value(100), tolerance);
Assert.assertEquals(f.polynomialDerivative().value(4.1), g.value(4.1), tolerance);
Assert.assertEquals(f.polynomialDerivative().value(-3.25), g.value(-3.25), tolerance);
// compare g' = h
Assert.assertEquals(g.derivative().value(FastMath.PI), h.value(FastMath.PI), tolerance);
Assert.assertEquals(g.derivative().value(FastMath.E), h.value(FastMath.E), tolerance);
Assert.assertEquals(g.polynomialDerivative().value(FastMath.PI), h.value(FastMath.PI), tolerance);
Assert.assertEquals(g.polynomialDerivative().value(FastMath.E), h.value(FastMath.E), tolerance);
}
@Test
@ -241,15 +240,15 @@ public final class PolynomialFunctionTest {
PolynomialFunction h = new PolynomialFunction(h_coeff);
// compare f' = g
Assert.assertEquals(f.derivative().value(0), g.value(0), tolerance);
Assert.assertEquals(f.derivative().value(1), g.value(1), tolerance);
Assert.assertEquals(f.derivative().value(100), g.value(100), tolerance);
Assert.assertEquals(f.derivative().value(4.1), g.value(4.1), tolerance);
Assert.assertEquals(f.derivative().value(-3.25), g.value(-3.25), tolerance);
Assert.assertEquals(f.polynomialDerivative().value(0), g.value(0), tolerance);
Assert.assertEquals(f.polynomialDerivative().value(1), g.value(1), tolerance);
Assert.assertEquals(f.polynomialDerivative().value(100), g.value(100), tolerance);
Assert.assertEquals(f.polynomialDerivative().value(4.1), g.value(4.1), tolerance);
Assert.assertEquals(f.polynomialDerivative().value(-3.25), g.value(-3.25), tolerance);
// compare g' = h
Assert.assertEquals(g.derivative().value(FastMath.PI), h.value(FastMath.PI), tolerance);
Assert.assertEquals(g.derivative().value(FastMath.E), h.value(FastMath.E), tolerance);
Assert.assertEquals(g.polynomialDerivative().value(FastMath.PI), h.value(FastMath.PI), tolerance);
Assert.assertEquals(g.polynomialDerivative().value(FastMath.E), h.value(FastMath.E), tolerance);
}
public void checkPolynomial(PolynomialFunction p, String reference) {

View File

@ -19,8 +19,6 @@ package org.apache.commons.math4.analysis.polynomials;
import java.util.Arrays;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.polynomials.PolynomialFunction;
import org.apache.commons.math4.analysis.polynomials.PolynomialSplineFunction;
import org.apache.commons.math4.exception.MathIllegalArgumentException;
import org.apache.commons.math4.exception.MathIllegalStateException;
import org.apache.commons.math4.exception.OutOfRangeException;
@ -94,7 +92,7 @@ public class PolynomialSplineFunctionTest {
public void testValues() {
PolynomialSplineFunction spline =
new PolynomialSplineFunction(knots, polynomials);
UnivariateFunction dSpline = spline.derivative();
UnivariateFunction dSpline = spline.polynomialSplineDerivative();
/**
* interior points -- spline value at x should equal p(x - knot)
@ -153,7 +151,7 @@ public class PolynomialSplineFunctionTest {
Assert.assertTrue(spline.isValidPoint(x));
// Ensure that no exception is thrown.
spline.value(x);
final double xRange = xMax - xMin;
x = xMin + xRange / 3.4;
Assert.assertTrue(spline.isValidPoint(x));

View File

@ -18,8 +18,6 @@ package org.apache.commons.math4.analysis.polynomials;
import org.apache.commons.math4.analysis.UnivariateFunction;
import org.apache.commons.math4.analysis.integration.IterativeLegendreGaussIntegrator;
import org.apache.commons.math4.analysis.polynomials.PolynomialFunction;
import org.apache.commons.math4.analysis.polynomials.PolynomialsUtils;
import org.apache.commons.math4.util.CombinatoricsUtils;
import org.apache.commons.math4.util.FastMath;
import org.apache.commons.math4.util.Precision;
@ -80,6 +78,7 @@ public class PolynomialsUtilsTest {
@Test
public void testChebyshevOrthogonality() {
UnivariateFunction weight = new UnivariateFunction() {
@Override
public double value(double x) {
return 1 / FastMath.sqrt(1 - x * x);
}
@ -131,6 +130,7 @@ public class PolynomialsUtilsTest {
@Test
public void testHermiteOrthogonality() {
UnivariateFunction weight = new UnivariateFunction() {
@Override
public double value(double x) {
return FastMath.exp(-x * x);
}
@ -188,6 +188,7 @@ public class PolynomialsUtilsTest {
@Test
public void testLaguerreOrthogonality() {
UnivariateFunction weight = new UnivariateFunction() {
@Override
public double value(double x) {
return FastMath.exp(-x);
}
@ -239,6 +240,7 @@ public class PolynomialsUtilsTest {
@Test
public void testLegendreOrthogonality() {
UnivariateFunction weight = new UnivariateFunction() {
@Override
public double value(double x) {
return 1;
}
@ -304,6 +306,7 @@ public class PolynomialsUtilsTest {
final int vv = v;
final int ww = w;
UnivariateFunction weight = new UnivariateFunction() {
@Override
public double value(double x) {
return FastMath.pow(1 - x, vv) * FastMath.pow(1 + x, ww);
}
@ -331,7 +334,7 @@ public class PolynomialsUtilsTest {
PolynomialFunction f1xM1
= new PolynomialFunction(PolynomialsUtils.shift(f1x.getCoefficients(), -1));
checkPolynomial(f1xM1, "2 - 3 x + 2 x^2");
PolynomialFunction f1x3
= new PolynomialFunction(PolynomialsUtils.shift(f1x.getCoefficients(), 3));
checkPolynomial(f1x3, "22 + 13 x + 2 x^2");
@ -371,6 +374,7 @@ public class PolynomialsUtilsTest {
final double nonZeroThreshold,
final double zeroThreshold) {
UnivariateFunction f = new UnivariateFunction() {
@Override
public double value(double x) {
return weight.value(x) * p1.value(x) * p2.value(x);
}