Math-707
Renamed "TrivariateRealFunction" to "TrivariateFunction". git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1236932 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a7e7419446
commit
4fdd797b3b
|
@ -23,7 +23,7 @@ package org.apache.commons.math.analysis;
|
||||||
* @since 2.2
|
* @since 2.2
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public interface TrivariateRealFunction {
|
public interface TrivariateFunction {
|
||||||
/**
|
/**
|
||||||
* Compute the value for the function.
|
* Compute the value for the function.
|
||||||
*
|
*
|
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.commons.math.analysis.interpolation;
|
package org.apache.commons.math.analysis.interpolation;
|
||||||
|
|
||||||
import org.apache.commons.math.analysis.TrivariateRealFunction;
|
import org.apache.commons.math.analysis.TrivariateFunction;
|
||||||
import org.apache.commons.math.exception.DimensionMismatchException;
|
import org.apache.commons.math.exception.DimensionMismatchException;
|
||||||
import org.apache.commons.math.exception.NoDataException;
|
import org.apache.commons.math.exception.NoDataException;
|
||||||
import org.apache.commons.math.exception.OutOfRangeException;
|
import org.apache.commons.math.exception.OutOfRangeException;
|
||||||
|
@ -36,7 +36,7 @@ import org.apache.commons.math.util.MathArrays;
|
||||||
* @since 2.2
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
public class TricubicSplineInterpolatingFunction
|
public class TricubicSplineInterpolatingFunction
|
||||||
implements TrivariateRealFunction {
|
implements TrivariateFunction {
|
||||||
/**
|
/**
|
||||||
* Matrix to compute the spline coefficients from the function values
|
* Matrix to compute the spline coefficients from the function values
|
||||||
* and function derivatives values
|
* and function derivatives values
|
||||||
|
@ -421,7 +421,7 @@ public class TricubicSplineInterpolatingFunction
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
class TricubicSplineFunction
|
class TricubicSplineFunction
|
||||||
implements TrivariateRealFunction {
|
implements TrivariateFunction {
|
||||||
/** Number of points. */
|
/** Number of points. */
|
||||||
private static final short N = 4;
|
private static final short N = 4;
|
||||||
/** Coefficients */
|
/** Coefficients */
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.commons.math.analysis.interpolation;
|
package org.apache.commons.math.analysis.interpolation;
|
||||||
|
|
||||||
import org.apache.commons.math.analysis.TrivariateRealFunction;
|
import org.apache.commons.math.analysis.TrivariateFunction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface representing a trivariate real interpolating function where the
|
* Interface representing a trivariate real interpolating function where the
|
||||||
|
@ -43,6 +43,6 @@ public interface TrivariateRealGridInterpolator {
|
||||||
* @throws org.apache.commons.math.exception.DimensionMismatchException
|
* @throws org.apache.commons.math.exception.DimensionMismatchException
|
||||||
* if the array lengths are inconsistent.
|
* if the array lengths are inconsistent.
|
||||||
*/
|
*/
|
||||||
TrivariateRealFunction interpolate(double[] xval, double[] yval, double[] zval,
|
TrivariateFunction interpolate(double[] xval, double[] yval, double[] zval,
|
||||||
double[][][] fval);
|
double[][][] fval);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.math.analysis.interpolation;
|
||||||
import org.apache.commons.math.exception.DimensionMismatchException;
|
import org.apache.commons.math.exception.DimensionMismatchException;
|
||||||
import org.apache.commons.math.exception.MathIllegalArgumentException;
|
import org.apache.commons.math.exception.MathIllegalArgumentException;
|
||||||
import org.apache.commons.math.util.FastMath;
|
import org.apache.commons.math.util.FastMath;
|
||||||
import org.apache.commons.math.analysis.TrivariateRealFunction;
|
import org.apache.commons.math.analysis.TrivariateFunction;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ public final class TricubicSplineInterpolatingFunctionTest {
|
||||||
double[][][] fval = new double[xval.length][yval.length][zval.length];
|
double[][][] fval = new double[xval.length][yval.length][zval.length];
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
TrivariateRealFunction tcf = new TricubicSplineInterpolatingFunction(xval, yval, zval,
|
TrivariateFunction tcf = new TricubicSplineInterpolatingFunction(xval, yval, zval,
|
||||||
fval, fval, fval, fval,
|
fval, fval, fval, fval,
|
||||||
fval, fval, fval, fval);
|
fval, fval, fval, fval);
|
||||||
|
|
||||||
|
@ -281,7 +281,7 @@ public final class TricubicSplineInterpolatingFunctionTest {
|
||||||
double[] zval = new double[] {-12, -8, -5.5, -3, 0, 2.5};
|
double[] zval = new double[] {-12, -8, -5.5, -3, 0, 2.5};
|
||||||
|
|
||||||
// Function values
|
// Function values
|
||||||
TrivariateRealFunction f = new TrivariateRealFunction() {
|
TrivariateFunction f = new TrivariateFunction() {
|
||||||
public double value(double x, double y, double z) {
|
public double value(double x, double y, double z) {
|
||||||
return 2 * x - 3 * y - 4 * z + 5;
|
return 2 * x - 3 * y - 4 * z + 5;
|
||||||
}
|
}
|
||||||
|
@ -340,7 +340,7 @@ public final class TricubicSplineInterpolatingFunctionTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TrivariateRealFunction tcf = new TricubicSplineInterpolatingFunction(xval, yval, zval,
|
TrivariateFunction tcf = new TricubicSplineInterpolatingFunction(xval, yval, zval,
|
||||||
fval, dFdX, dFdY, dFdZ,
|
fval, dFdX, dFdY, dFdZ,
|
||||||
d2FdXdY, d2FdXdZ, d2FdYdZ,
|
d2FdXdY, d2FdXdZ, d2FdYdZ,
|
||||||
d3FdXdYdZ);
|
d3FdXdYdZ);
|
||||||
|
@ -391,7 +391,7 @@ public final class TricubicSplineInterpolatingFunctionTest {
|
||||||
final double ky = 1;
|
final double ky = 1;
|
||||||
|
|
||||||
// Function values
|
// Function values
|
||||||
TrivariateRealFunction f = new TrivariateRealFunction() {
|
TrivariateFunction f = new TrivariateFunction() {
|
||||||
public double value(double x, double y, double z) {
|
public double value(double x, double y, double z) {
|
||||||
return a * FastMath.cos(omega * z - kx * x - ky * y);
|
return a * FastMath.cos(omega * z - kx * x - ky * y);
|
||||||
}
|
}
|
||||||
|
@ -408,7 +408,7 @@ public final class TricubicSplineInterpolatingFunctionTest {
|
||||||
|
|
||||||
// Partial derivatives with respect to x
|
// Partial derivatives with respect to x
|
||||||
double[][][] dFdX = new double[xval.length][yval.length][zval.length];
|
double[][][] dFdX = new double[xval.length][yval.length][zval.length];
|
||||||
TrivariateRealFunction dFdX_f = new TrivariateRealFunction() {
|
TrivariateFunction dFdX_f = new TrivariateFunction() {
|
||||||
public double value(double x, double y, double z) {
|
public double value(double x, double y, double z) {
|
||||||
return a * FastMath.sin(omega * z - kx * x - ky * y) * kx;
|
return a * FastMath.sin(omega * z - kx * x - ky * y) * kx;
|
||||||
}
|
}
|
||||||
|
@ -423,7 +423,7 @@ public final class TricubicSplineInterpolatingFunctionTest {
|
||||||
|
|
||||||
// Partial derivatives with respect to y
|
// Partial derivatives with respect to y
|
||||||
double[][][] dFdY = new double[xval.length][yval.length][zval.length];
|
double[][][] dFdY = new double[xval.length][yval.length][zval.length];
|
||||||
TrivariateRealFunction dFdY_f = new TrivariateRealFunction() {
|
TrivariateFunction dFdY_f = new TrivariateFunction() {
|
||||||
public double value(double x, double y, double z) {
|
public double value(double x, double y, double z) {
|
||||||
return a * FastMath.sin(omega * z - kx * x - ky * y) * ky;
|
return a * FastMath.sin(omega * z - kx * x - ky * y) * ky;
|
||||||
}
|
}
|
||||||
|
@ -438,7 +438,7 @@ public final class TricubicSplineInterpolatingFunctionTest {
|
||||||
|
|
||||||
// Partial derivatives with respect to z
|
// Partial derivatives with respect to z
|
||||||
double[][][] dFdZ = new double[xval.length][yval.length][zval.length];
|
double[][][] dFdZ = new double[xval.length][yval.length][zval.length];
|
||||||
TrivariateRealFunction dFdZ_f = new TrivariateRealFunction() {
|
TrivariateFunction dFdZ_f = new TrivariateFunction() {
|
||||||
public double value(double x, double y, double z) {
|
public double value(double x, double y, double z) {
|
||||||
return -a * FastMath.sin(omega * z - kx * x - ky * y) * omega;
|
return -a * FastMath.sin(omega * z - kx * x - ky * y) * omega;
|
||||||
}
|
}
|
||||||
|
@ -453,7 +453,7 @@ public final class TricubicSplineInterpolatingFunctionTest {
|
||||||
|
|
||||||
// Partial second derivatives w.r.t. (x, y)
|
// Partial second derivatives w.r.t. (x, y)
|
||||||
double[][][] d2FdXdY = new double[xval.length][yval.length][zval.length];
|
double[][][] d2FdXdY = new double[xval.length][yval.length][zval.length];
|
||||||
TrivariateRealFunction d2FdXdY_f = new TrivariateRealFunction() {
|
TrivariateFunction d2FdXdY_f = new TrivariateFunction() {
|
||||||
public double value(double x, double y, double z) {
|
public double value(double x, double y, double z) {
|
||||||
return -a * FastMath.cos(omega * z - kx * x - ky * y) * kx * ky;
|
return -a * FastMath.cos(omega * z - kx * x - ky * y) * kx * ky;
|
||||||
}
|
}
|
||||||
|
@ -468,7 +468,7 @@ public final class TricubicSplineInterpolatingFunctionTest {
|
||||||
|
|
||||||
// Partial second derivatives w.r.t. (x, z)
|
// Partial second derivatives w.r.t. (x, z)
|
||||||
double[][][] d2FdXdZ = new double[xval.length][yval.length][zval.length];
|
double[][][] d2FdXdZ = new double[xval.length][yval.length][zval.length];
|
||||||
TrivariateRealFunction d2FdXdZ_f = new TrivariateRealFunction() {
|
TrivariateFunction d2FdXdZ_f = new TrivariateFunction() {
|
||||||
public double value(double x, double y, double z) {
|
public double value(double x, double y, double z) {
|
||||||
return a * FastMath.cos(omega * z - kx * x - ky * y) * kx * omega;
|
return a * FastMath.cos(omega * z - kx * x - ky * y) * kx * omega;
|
||||||
}
|
}
|
||||||
|
@ -483,7 +483,7 @@ public final class TricubicSplineInterpolatingFunctionTest {
|
||||||
|
|
||||||
// Partial second derivatives w.r.t. (y, z)
|
// Partial second derivatives w.r.t. (y, z)
|
||||||
double[][][] d2FdYdZ = new double[xval.length][yval.length][zval.length];
|
double[][][] d2FdYdZ = new double[xval.length][yval.length][zval.length];
|
||||||
TrivariateRealFunction d2FdYdZ_f = new TrivariateRealFunction() {
|
TrivariateFunction d2FdYdZ_f = new TrivariateFunction() {
|
||||||
public double value(double x, double y, double z) {
|
public double value(double x, double y, double z) {
|
||||||
return a * FastMath.cos(omega * z - kx * x - ky * y) * ky * omega;
|
return a * FastMath.cos(omega * z - kx * x - ky * y) * ky * omega;
|
||||||
}
|
}
|
||||||
|
@ -498,7 +498,7 @@ public final class TricubicSplineInterpolatingFunctionTest {
|
||||||
|
|
||||||
// Partial third derivatives
|
// Partial third derivatives
|
||||||
double[][][] d3FdXdYdZ = new double[xval.length][yval.length][zval.length];
|
double[][][] d3FdXdYdZ = new double[xval.length][yval.length][zval.length];
|
||||||
TrivariateRealFunction d3FdXdYdZ_f = new TrivariateRealFunction() {
|
TrivariateFunction d3FdXdYdZ_f = new TrivariateFunction() {
|
||||||
public double value(double x, double y, double z) {
|
public double value(double x, double y, double z) {
|
||||||
return a * FastMath.sin(omega * z - kx * x - ky * y) * kx * ky * omega;
|
return a * FastMath.sin(omega * z - kx * x - ky * y) * kx * ky * omega;
|
||||||
}
|
}
|
||||||
|
@ -511,7 +511,7 @@ public final class TricubicSplineInterpolatingFunctionTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TrivariateRealFunction tcf = new TricubicSplineInterpolatingFunction(xval, yval, zval,
|
TrivariateFunction tcf = new TricubicSplineInterpolatingFunction(xval, yval, zval,
|
||||||
fval, dFdX, dFdY, dFdZ,
|
fval, dFdX, dFdY, dFdZ,
|
||||||
d2FdXdY, d2FdXdZ, d2FdYdZ,
|
d2FdXdY, d2FdXdZ, d2FdYdZ,
|
||||||
d3FdXdYdZ);
|
d3FdXdYdZ);
|
||||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.math.analysis.interpolation;
|
||||||
import org.apache.commons.math.exception.DimensionMismatchException;
|
import org.apache.commons.math.exception.DimensionMismatchException;
|
||||||
import org.apache.commons.math.exception.MathIllegalArgumentException;
|
import org.apache.commons.math.exception.MathIllegalArgumentException;
|
||||||
import org.apache.commons.math.util.FastMath;
|
import org.apache.commons.math.util.FastMath;
|
||||||
import org.apache.commons.math.analysis.TrivariateRealFunction;
|
import org.apache.commons.math.analysis.TrivariateFunction;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ public final class TricubicSplineInterpolatorTest {
|
||||||
TrivariateRealGridInterpolator interpolator = new TricubicSplineInterpolator();
|
TrivariateRealGridInterpolator interpolator = new TricubicSplineInterpolator();
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
TrivariateRealFunction p = interpolator.interpolate(xval, yval, zval, fval);
|
TrivariateFunction p = interpolator.interpolate(xval, yval, zval, fval);
|
||||||
|
|
||||||
double[] wxval = new double[] {3, 2, 5, 6.5};
|
double[] wxval = new double[] {3, 2, 5, 6.5};
|
||||||
try {
|
try {
|
||||||
|
@ -98,7 +98,7 @@ public final class TricubicSplineInterpolatorTest {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testPlane() {
|
public void testPlane() {
|
||||||
TrivariateRealFunction f = new TrivariateRealFunction() {
|
TrivariateFunction f = new TrivariateFunction() {
|
||||||
public double value(double x, double y, double z) {
|
public double value(double x, double y, double z) {
|
||||||
return 2 * x - 3 * y - z + 5;
|
return 2 * x - 3 * y - z + 5;
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ public final class TricubicSplineInterpolatorTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TrivariateRealFunction p = interpolator.interpolate(xval, yval, zval, fval);
|
TrivariateFunction p = interpolator.interpolate(xval, yval, zval, fval);
|
||||||
double x, y, z;
|
double x, y, z;
|
||||||
double expected, result;
|
double expected, result;
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ public final class TricubicSplineInterpolatorTest {
|
||||||
final double ky = 1;
|
final double ky = 1;
|
||||||
|
|
||||||
// Function values
|
// Function values
|
||||||
TrivariateRealFunction f = new TrivariateRealFunction() {
|
TrivariateFunction f = new TrivariateFunction() {
|
||||||
public double value(double x, double y, double z) {
|
public double value(double x, double y, double z) {
|
||||||
return a * FastMath.cos(omega * z - kx * x - ky * y);
|
return a * FastMath.cos(omega * z - kx * x - ky * y);
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,7 @@ public final class TricubicSplineInterpolatorTest {
|
||||||
|
|
||||||
TrivariateRealGridInterpolator interpolator = new TricubicSplineInterpolator();
|
TrivariateRealGridInterpolator interpolator = new TricubicSplineInterpolator();
|
||||||
|
|
||||||
TrivariateRealFunction p = interpolator.interpolate(xval, yval, zval, fval);
|
TrivariateFunction p = interpolator.interpolate(xval, yval, zval, fval);
|
||||||
double x, y, z;
|
double x, y, z;
|
||||||
double expected, result;
|
double expected, result;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue