You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2008/04/17 21:21:25 UTC
svn commit: r649240 - in /commons/sandbox/nabla/trunk/src:
main/java/org/apache/commons/nabla/
main/java/org/apache/commons/nabla/automatic/analysis/
main/java/org/apache/commons/nabla/core/
main/java/org/apache/commons/nabla/differences/ test/java/org...
Author: luc
Date: Thu Apr 17 12:21:19 2008
New Revision: 649240
URL: http://svn.apache.org/viewvc?rev=649240&view=rev
Log:
renamed getU0() by getValue() and getU1() by getFirstDerivative()
for easier understanding of the DifferentialPair class
Modified:
commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/NablaMath.java
commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/NablaStrictMath.java
commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/analysis/MethodDifferentiator.java
commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/core/DifferentialPair.java
commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/EightPointsScheme.java
commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/FourPointsScheme.java
commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/SixPointsScheme.java
commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/TwoPointsScheme.java
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/AbstractStaticFunctionsTest.java
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/AbstractMathTest.java
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/core/DifferentialPairTest.java
commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/differences/AbstractFiniteDifferencesTest.java
Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/NablaMath.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/NablaMath.java?rev=649240&r1=649239&r2=649240&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/NablaMath.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/NablaMath.java Thu Apr 17 12:21:19 2008
@@ -41,8 +41,8 @@
* @return e<sup>a</sup>
*/
public static DifferentialPair exp(final DifferentialPair a) {
- final double e = Math.exp(a.getU0());
- return new DifferentialPair(e, a.getU1() * e);
+ final double e = Math.exp(a.getValue());
+ return new DifferentialPair(e, a.getFirstDerivative() * e);
}
/** Exponential minus 1 function.
@@ -50,8 +50,8 @@
* @return e<sup>a</sup>-1
*/
public static DifferentialPair expm1(final DifferentialPair a) {
- final double e = Math.expm1(a.getU0());
- return new DifferentialPair(e, a.getU1() * (e + 1));
+ final double e = Math.expm1(a.getValue());
+ return new DifferentialPair(e, a.getFirstDerivative() * (e + 1));
}
/** Natural logarithm function.
@@ -59,8 +59,8 @@
* @return log(a)
*/
public static DifferentialPair log(final DifferentialPair a) {
- final double a0 = a.getU0();
- return new DifferentialPair(Math.log(a0), a.getU1() / a0);
+ final double a0 = a.getValue();
+ return new DifferentialPair(Math.log(a0), a.getFirstDerivative() / a0);
}
/** Shifted natural logarithm function.
@@ -68,8 +68,8 @@
* @return log(1+a)
*/
public static DifferentialPair log1p(final DifferentialPair a) {
- final double a0 = a.getU0();
- return new DifferentialPair(Math.log1p(a0), a.getU1() / (1 + a0));
+ final double a0 = a.getValue();
+ return new DifferentialPair(Math.log1p(a0), a.getFirstDerivative() / (1 + a0));
}
/** Base 10 logarithm function.
@@ -77,8 +77,8 @@
* @return log<sub>10</sub>(a)
*/
public static DifferentialPair log10(final DifferentialPair a) {
- final double a0 = a.getU0();
- return new DifferentialPair(Math.log10(a0), a.getU1() / (a0 * Math.log(10)));
+ final double a0 = a.getValue();
+ return new DifferentialPair(Math.log10(a0), a.getFirstDerivative() / (a0 * Math.log(10)));
}
@@ -91,8 +91,8 @@
* @return cos(a)
*/
public static DifferentialPair cos(final DifferentialPair a) {
- final double a0 = a.getU0();
- return new DifferentialPair(Math.cos(a0), -a.getU1() * Math.sin(a0));
+ final double a0 = a.getValue();
+ return new DifferentialPair(Math.cos(a0), -a.getFirstDerivative() * Math.sin(a0));
}
/** Sine function.
@@ -100,8 +100,8 @@
* @return sin(a)
*/
public static DifferentialPair sin(final DifferentialPair a) {
- final double a0 = a.getU0();
- return new DifferentialPair(Math.sin(a0), a.getU1() * Math.cos(a0));
+ final double a0 = a.getValue();
+ return new DifferentialPair(Math.sin(a0), a.getFirstDerivative() * Math.cos(a0));
}
/** Tangent function.
@@ -109,8 +109,8 @@
* @return tan(a)
*/
public static DifferentialPair tan(final DifferentialPair a) {
- final double t = Math.tan(a.getU0());
- return new DifferentialPair(t, a.getU1() * (1 + t * t));
+ final double t = Math.tan(a.getValue());
+ return new DifferentialPair(t, a.getFirstDerivative() * (1 + t * t));
}
/** Inverse cosine function.
@@ -118,8 +118,8 @@
* @return acos(a)
*/
public static DifferentialPair acos(final DifferentialPair a) {
- final double a0 = a.getU0();
- return new DifferentialPair(Math.acos(a0), -a.getU1() / Math.sqrt(1 - a0 * a0));
+ final double a0 = a.getValue();
+ return new DifferentialPair(Math.acos(a0), -a.getFirstDerivative() / Math.sqrt(1 - a0 * a0));
}
/** Inverse sine function.
@@ -127,8 +127,8 @@
* @return asin(a)
*/
public static DifferentialPair asin(final DifferentialPair a) {
- final double a0 = a.getU0();
- return new DifferentialPair(Math.asin(a0), a.getU1() / Math.sqrt(1 - a0 * a0));
+ final double a0 = a.getValue();
+ return new DifferentialPair(Math.asin(a0), a.getFirstDerivative() / Math.sqrt(1 - a0 * a0));
}
/** Inverse tangent function.
@@ -136,8 +136,8 @@
* @return atan(a)
*/
public static DifferentialPair atan(final DifferentialPair a) {
- final double a0 = a.getU0();
- return new DifferentialPair(Math.atan(a0), a.getU1() / (1 + a0 * a0));
+ final double a0 = a.getValue();
+ return new DifferentialPair(Math.atan(a0), a.getFirstDerivative() / (1 + a0 * a0));
}
@@ -151,9 +151,9 @@
* @return angular part of the polar coordinates of the point
*/
public static DifferentialPair atan2(final DifferentialPair y, final double x) {
- final double y0 = y.getU0();
+ final double y0 = y.getValue();
return new DifferentialPair(Math.atan2(y0, x),
- x * y.getU1() / (x * x + y0 * y0));
+ x * y.getFirstDerivative() / (x * x + y0 * y0));
}
/** Cartesian to polar conversion function.
@@ -162,9 +162,9 @@
* @return angular part of the polar coordinates of the point
*/
public static DifferentialPair atan2(final double y, final DifferentialPair x) {
- final double x0 = x.getU0();
+ final double x0 = x.getValue();
return new DifferentialPair(Math.atan2(y, x0),
- -y * x.getU1() / (x0 * x0 + y * y));
+ -y * x.getFirstDerivative() / (x0 * x0 + y * y));
}
/** Cartesian to polar conversion function.
@@ -173,10 +173,10 @@
* @return angular part of the polar coordinates of the point
*/
public static DifferentialPair atan2(final DifferentialPair y, final DifferentialPair x) {
- final double y0 = y.getU0();
- final double x0 = x.getU0();
+ final double y0 = y.getValue();
+ final double x0 = x.getValue();
return new DifferentialPair(Math.atan2(y0, x0),
- (x0 * y.getU1() - y0 * x.getU1()) / (x0 * x0 + y0 * y0));
+ (x0 * y.getFirstDerivative() - y0 * x.getFirstDerivative()) / (x0 * x0 + y0 * y0));
}
/** Cartesian to polar conversion function.
@@ -185,9 +185,9 @@
* @return radius part of the polar coordinates of the point
*/
public static DifferentialPair hypot(final DifferentialPair x, final double y) {
- final double x0 = x.getU0();
+ final double x0 = x.getValue();
final double h = Math.hypot(x0, y);
- return new DifferentialPair(h, x0 * x.getU1() / h);
+ return new DifferentialPair(h, x0 * x.getFirstDerivative() / h);
}
/** Cartesian to polar conversion function.
@@ -196,9 +196,9 @@
* @return radius part of the polar coordinates of the point
*/
public static DifferentialPair hypot(final double x, final DifferentialPair y) {
- final double y0 = y.getU0();
+ final double y0 = y.getValue();
final double h = Math.hypot(x, y0);
- return new DifferentialPair(h, y0 * y.getU1() / h);
+ return new DifferentialPair(h, y0 * y.getFirstDerivative() / h);
}
/** Cartesian to polar conversion function.
@@ -207,10 +207,10 @@
* @return radius part of the polar coordinates of the point
*/
public static DifferentialPair hypot(final DifferentialPair x, final DifferentialPair y) {
- final double x0 = x.getU0();
- final double y0 = y.getU0();
+ final double x0 = x.getValue();
+ final double y0 = y.getValue();
final double h = Math.hypot(x0, y0);
- return new DifferentialPair(h, (x0 * x.getU1() + y0 * y.getU1()) / h);
+ return new DifferentialPair(h, (x0 * x.getFirstDerivative() + y0 * y.getFirstDerivative()) / h);
}
@@ -223,8 +223,8 @@
* @return cosh(a)
*/
public static DifferentialPair cosh(final DifferentialPair a) {
- final double a0 = a.getU0();
- return new DifferentialPair(Math.cosh(a0), a.getU1() * Math.sinh(a0));
+ final double a0 = a.getValue();
+ return new DifferentialPair(Math.cosh(a0), a.getFirstDerivative() * Math.sinh(a0));
}
/** Hyperbolic sine function.
@@ -232,8 +232,8 @@
* @return sinh(a)
*/
public static DifferentialPair sinh(final DifferentialPair a) {
- final double a0 = a.getU0();
- return new DifferentialPair(Math.sinh(a0), a.getU1() * Math.cosh(a0));
+ final double a0 = a.getValue();
+ return new DifferentialPair(Math.sinh(a0), a.getFirstDerivative() * Math.cosh(a0));
}
/** Hyperbolic tangent function.
@@ -241,8 +241,8 @@
* @return tanh(a)
*/
public static DifferentialPair tanh(final DifferentialPair a) {
- final double t = Math.tanh(a.getU0());
- return new DifferentialPair(t, a.getU1() * (1 - t * t));
+ final double t = Math.tanh(a.getValue());
+ return new DifferentialPair(t, a.getFirstDerivative() * (1 - t * t));
}
/** Inverse hyperbolic cosine function.
@@ -251,9 +251,9 @@
*/
public static DifferentialPair acosh(final DifferentialPair a) {
// the acosh function is not provided by java.lang.Math as of Java6
- final double a0 = a.getU0();
+ final double a0 = a.getValue();
final double root = Math.sqrt(a0 - 1) * Math.sqrt(a0 + 1);
- return new DifferentialPair(Math.log(a0 + root), a.getU1() / root);
+ return new DifferentialPair(Math.log(a0 + root), a.getFirstDerivative() / root);
}
/** Inverse hyperbolic sine function.
@@ -262,9 +262,9 @@
*/
public static DifferentialPair asinh(final DifferentialPair a) {
// the asinh function is not provided by java.lang.Math as of Java6
- final double a0 = a.getU0();
+ final double a0 = a.getValue();
final double root = Math.sqrt(a0 * a0 + 1);
- return new DifferentialPair(Math.log(a0 + root), a.getU1() / root);
+ return new DifferentialPair(Math.log(a0 + root), a.getFirstDerivative() / root);
}
/** Inverse hyperbolic tangent function.
@@ -273,9 +273,9 @@
*/
public static DifferentialPair atanh(final DifferentialPair a) {
// the atanh function is not provided by java.lang.Math as of Java6
- final double a0 = a.getU0();
+ final double a0 = a.getValue();
final double ath = (Math.log1p(a0) - Math.log1p(-a0)) / 2;
- return new DifferentialPair(ath, a.getU1() / (1 - a0 * a0));
+ return new DifferentialPair(ath, a.getFirstDerivative() / (1 - a0 * a0));
}
/////////////////////
@@ -287,8 +287,8 @@
* @return &sqrt;a
*/
public static DifferentialPair sqrt(final DifferentialPair a) {
- final double root = Math.sqrt(a.getU0());
- return new DifferentialPair(root, a.getU1() / (2 * root));
+ final double root = Math.sqrt(a.getValue());
+ return new DifferentialPair(root, a.getFirstDerivative() / (2 * root));
}
/** Cubic root function.
@@ -296,8 +296,8 @@
* @return cbrt(a)
*/
public static DifferentialPair cbrt(final DifferentialPair a) {
- final double root = Math.cbrt(a.getU0());
- return new DifferentialPair(root, a.getU1() / (3 * root * root));
+ final double root = Math.cbrt(a.getValue());
+ return new DifferentialPair(root, a.getFirstDerivative() / (3 * root * root));
}
/** Power function.
@@ -306,9 +306,9 @@
* @return a<sup>b</sup>
*/
public static DifferentialPair pow(final DifferentialPair a, final double b) {
- final double a0 = a.getU0();
+ final double a0 = a.getValue();
final double p = Math.pow(a0, b);
- return new DifferentialPair(p, a.getU1() * b * p / a0);
+ return new DifferentialPair(p, a.getFirstDerivative() * b * p / a0);
}
/** Power function.
@@ -317,8 +317,8 @@
* @return a<sup>b</sup>
*/
public static DifferentialPair pow(final double a, final DifferentialPair b) {
- final double p = Math.pow(a, b.getU0());
- return new DifferentialPair(p, b.getU1() * Math.log(a) * p);
+ final double p = Math.pow(a, b.getValue());
+ return new DifferentialPair(p, b.getFirstDerivative() * Math.log(a) * p);
}
/** Power function.
@@ -327,10 +327,10 @@
* @return a<sup>b</sup>
*/
public static DifferentialPair pow(final DifferentialPair a, final DifferentialPair b) {
- final double a0 = a.getU0();
- final double b0 = b.getU0();
+ final double a0 = a.getValue();
+ final double b0 = b.getValue();
final double p = Math.pow(a0, b0);
- return new DifferentialPair(p, (a.getU1() * b0 / a0 + b.getU1() * Math.log(a0)) * p);
+ return new DifferentialPair(p, (a.getFirstDerivative() * b0 / a0 + b.getFirstDerivative() * Math.log(a0)) * p);
}
@@ -343,7 +343,7 @@
* @return |a|
*/
public static DifferentialPair abs(final DifferentialPair a) {
- return (a.getU0() >= 0) ? a : DifferentialPair.negate(a);
+ return (a.getValue() >= 0) ? a : DifferentialPair.negate(a);
}
/** Sign function.
@@ -351,7 +351,7 @@
* @return -1, 0 or +1 according to the sign of a
*/
public static DifferentialPair signum(final DifferentialPair a) {
- return DifferentialPair.newConstant(Math.signum(a.getU0()));
+ return DifferentialPair.newConstant(Math.signum(a.getValue()));
}
/** Sign copy function.
@@ -361,7 +361,7 @@
*/
public static DifferentialPair copySign(final DifferentialPair magnitude,
final double sign) {
- final long mBits = Double.doubleToLongBits(magnitude.getU0());
+ final long mBits = Double.doubleToLongBits(magnitude.getValue());
final long sBits = Double.doubleToLongBits(sign);
return (((mBits ^ sBits) & 0x8000000000000000L) == 0) ?
magnitude : DifferentialPair.negate(magnitude);
@@ -375,7 +375,7 @@
public static DifferentialPair copySign(final double magnitude,
final DifferentialPair sign) {
final long mBits = Double.doubleToLongBits(magnitude);
- final long sBits = Double.doubleToLongBits(sign.getU0());
+ final long sBits = Double.doubleToLongBits(sign.getValue());
return (((mBits ^ sBits) & 0x8000000000000000L) == 0) ?
DifferentialPair.newConstant(magnitude) :
DifferentialPair.newConstant(-magnitude);
@@ -388,8 +388,8 @@
*/
public static DifferentialPair copySign(final DifferentialPair magnitude,
final DifferentialPair sign) {
- final long mBits = Double.doubleToLongBits(magnitude.getU0());
- final long sBits = Double.doubleToLongBits(sign.getU0());
+ final long mBits = Double.doubleToLongBits(magnitude.getValue());
+ final long sBits = Double.doubleToLongBits(sign.getValue());
return (((mBits ^ sBits) & 0x8000000000000000L) == 0) ?
magnitude : DifferentialPair.negate(magnitude);
}
@@ -404,7 +404,7 @@
* @return largest integer value smaller than a or equal to a
*/
public static DifferentialPair floor(final DifferentialPair a) {
- return DifferentialPair.newConstant(Math.floor(a.getU0()));
+ return DifferentialPair.newConstant(Math.floor(a.getValue()));
}
/** Rounding function.
@@ -412,7 +412,7 @@
* @return closest integer value to a
*/
public static DifferentialPair rint(final DifferentialPair a) {
- return DifferentialPair.newConstant(Math.rint(a.getU0()));
+ return DifferentialPair.newConstant(Math.rint(a.getValue()));
}
/** Ceil function.
@@ -420,7 +420,7 @@
* @return smallest integer value greater than a or equal to a
*/
public static DifferentialPair ceil(final DifferentialPair a) {
- return DifferentialPair.newConstant(Math.ceil(a.getU0()));
+ return DifferentialPair.newConstant(Math.ceil(a.getValue()));
}
/** Neighbor function.
@@ -428,7 +428,7 @@
* @return smallest representable double value ly greater than a
*/
public static DifferentialPair nextUp(final DifferentialPair a) {
- return new DifferentialPair(Math.nextUp(a.getU0()), a.getU1());
+ return new DifferentialPair(Math.nextUp(a.getValue()), a.getFirstDerivative());
}
/** Neighbor function.
@@ -438,8 +438,8 @@
*/
public static DifferentialPair nextAfter(final DifferentialPair start,
final double direction) {
- return new DifferentialPair(Math.nextAfter(start.getU0(), direction),
- start.getU1());
+ return new DifferentialPair(Math.nextAfter(start.getValue(), direction),
+ start.getFirstDerivative());
}
/** Neighbor function.
@@ -449,7 +449,7 @@
*/
public static DifferentialPair nextAfter(final double start,
final DifferentialPair direction) {
- return DifferentialPair.newConstant(Math.nextAfter(start, direction.getU0()));
+ return DifferentialPair.newConstant(Math.nextAfter(start, direction.getValue()));
}
/** Neighbor function.
@@ -459,7 +459,7 @@
*/
public static DifferentialPair nextAfter(final DifferentialPair start,
final DifferentialPair direction) {
- return new DifferentialPair(Math.nextAfter(start.getU0(), direction.getU0()), start.getU1());
+ return new DifferentialPair(Math.nextAfter(start.getValue(), direction.getValue()), start.getFirstDerivative());
}
@@ -472,7 +472,7 @@
* @return value of the least significant bit of a
*/
public static DifferentialPair ulp(final DifferentialPair a) {
- return DifferentialPair.newConstant(Math.ulp(a.getU0()));
+ return DifferentialPair.newConstant(Math.ulp(a.getValue()));
}
/** Binary rescaling function.
@@ -482,8 +482,8 @@
*/
public static DifferentialPair scalb(final DifferentialPair a,
final int scale) {
- return new DifferentialPair(Math.scalb(a.getU0(), scale),
- Math.scalb(a.getU1(), scale));
+ return new DifferentialPair(Math.scalb(a.getValue(), scale),
+ Math.scalb(a.getFirstDerivative(), scale));
}
/** Remainder function.
@@ -493,8 +493,8 @@
*/
public static DifferentialPair IEEEremainder(final DifferentialPair f1,
final double f2) {
- final double r = Math.IEEEremainder(f1.getU0(), f2);
- return new DifferentialPair(r, f1.getU1());
+ final double r = Math.IEEEremainder(f1.getValue(), f2);
+ return new DifferentialPair(r, f1.getFirstDerivative());
}
/** Remainder function.
@@ -504,10 +504,10 @@
*/
public static DifferentialPair IEEEremainder(final double f1,
final DifferentialPair f2) {
- final double f20 = f2.getU0();
+ final double f20 = f2.getValue();
final double r = Math.IEEEremainder(f1, f20);
final int n = (int) ((r - f1) / f20);
- return new DifferentialPair(r, n * f2.getU1());
+ return new DifferentialPair(r, n * f2.getFirstDerivative());
}
/** Remainder function.
@@ -517,11 +517,11 @@
*/
public static DifferentialPair IEEEremainder(final DifferentialPair f1,
final DifferentialPair f2) {
- final double f10 = f1.getU0();
- final double f20 = f2.getU0();
+ final double f10 = f1.getValue();
+ final double f20 = f2.getValue();
final double r = Math.IEEEremainder(f10, f20);
final int n = (int) ((r - f10) / f20);
- return new DifferentialPair(r, f1.getU1() + n * f2.getU1());
+ return new DifferentialPair(r, f1.getFirstDerivative() + n * f2.getFirstDerivative());
}
@@ -534,7 +534,7 @@
* @return angle converted to degrees
*/
public static DifferentialPair toDegrees(final DifferentialPair a) {
- return new DifferentialPair(Math.toDegrees(a.getU0()), Math.toDegrees(a.getU1()));
+ return new DifferentialPair(Math.toDegrees(a.getValue()), Math.toDegrees(a.getFirstDerivative()));
}
/** Angular conversion function.
@@ -542,7 +542,7 @@
* @return angle converted to radians
*/
public static DifferentialPair toRadians(final DifferentialPair a) {
- return new DifferentialPair(Math.toRadians(a.getU0()), Math.toRadians(a.getU1()));
+ return new DifferentialPair(Math.toRadians(a.getValue()), Math.toRadians(a.getFirstDerivative()));
}
@@ -557,7 +557,7 @@
*/
public static DifferentialPair max(final DifferentialPair a,
final double b) {
- return (a.getU0() >= b) ? a : DifferentialPair.newConstant(b);
+ return (a.getValue() >= b) ? a : DifferentialPair.newConstant(b);
}
/** Max function.
@@ -567,7 +567,7 @@
*/
public static DifferentialPair max(final double a,
final DifferentialPair b) {
- return (b.getU0() >= a) ? b : DifferentialPair.newConstant(a);
+ return (b.getValue() >= a) ? b : DifferentialPair.newConstant(a);
}
/** Max function.
@@ -577,7 +577,7 @@
*/
public static DifferentialPair max(final DifferentialPair a,
final DifferentialPair b) {
- return (a.getU0() >= b.getU0()) ? a : b;
+ return (a.getValue() >= b.getValue()) ? a : b;
}
/** Min function.
@@ -587,7 +587,7 @@
*/
public static DifferentialPair min(final DifferentialPair a,
final double b) {
- return (a.getU0() <= b) ? a : DifferentialPair.newConstant(b);
+ return (a.getValue() <= b) ? a : DifferentialPair.newConstant(b);
}
/** Min function.
@@ -597,7 +597,7 @@
*/
public static DifferentialPair min(final double a,
final DifferentialPair b) {
- return (b.getU0() <= a) ? b : DifferentialPair.newConstant(a);
+ return (b.getValue() <= a) ? b : DifferentialPair.newConstant(a);
}
/** Min function.
@@ -607,7 +607,7 @@
*/
public static DifferentialPair min(final DifferentialPair a,
final DifferentialPair b) {
- return (a.getU0() <= b.getU0()) ? a : b;
+ return (a.getValue() <= b.getValue()) ? a : b;
}
}
Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/NablaStrictMath.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/NablaStrictMath.java?rev=649240&r1=649239&r2=649240&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/NablaStrictMath.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/NablaStrictMath.java Thu Apr 17 12:21:19 2008
@@ -41,8 +41,8 @@
* @return e<sup>a</sup>
*/
public static DifferentialPair exp(final DifferentialPair a) {
- final double e = StrictMath.exp(a.getU0());
- return new DifferentialPair(e, a.getU1() * e);
+ final double e = StrictMath.exp(a.getValue());
+ return new DifferentialPair(e, a.getFirstDerivative() * e);
}
/** Exponential minus 1 function.
@@ -50,8 +50,8 @@
* @return e<sup>a</sup>-1
*/
public static DifferentialPair expm1(final DifferentialPair a) {
- final double e = StrictMath.expm1(a.getU0());
- return new DifferentialPair(e, a.getU1() * (e + 1));
+ final double e = StrictMath.expm1(a.getValue());
+ return new DifferentialPair(e, a.getFirstDerivative() * (e + 1));
}
/** Natural logarithm function.
@@ -59,8 +59,8 @@
* @return log(a)
*/
public static DifferentialPair log(final DifferentialPair a) {
- final double a0 = a.getU0();
- return new DifferentialPair(StrictMath.log(a0), a.getU1() / a0);
+ final double a0 = a.getValue();
+ return new DifferentialPair(StrictMath.log(a0), a.getFirstDerivative() / a0);
}
/** Shifted natural logarithm function.
@@ -68,8 +68,8 @@
* @return log(1+a)
*/
public static DifferentialPair log1p(final DifferentialPair a) {
- final double a0 = a.getU0();
- return new DifferentialPair(StrictMath.log1p(a0), a.getU1() / (1 + a0));
+ final double a0 = a.getValue();
+ return new DifferentialPair(StrictMath.log1p(a0), a.getFirstDerivative() / (1 + a0));
}
/** Base 10 logarithm function.
@@ -77,8 +77,8 @@
* @return log<sub>10</sub>(a)
*/
public static DifferentialPair log10(final DifferentialPair a) {
- final double a0 = a.getU0();
- return new DifferentialPair(StrictMath.log10(a0), a.getU1() / (a0 * StrictMath.log(10)));
+ final double a0 = a.getValue();
+ return new DifferentialPair(StrictMath.log10(a0), a.getFirstDerivative() / (a0 * StrictMath.log(10)));
}
@@ -91,8 +91,8 @@
* @return cos(a)
*/
public static DifferentialPair cos(final DifferentialPair a) {
- final double a0 = a.getU0();
- return new DifferentialPair(StrictMath.cos(a0), -a.getU1() * StrictMath.sin(a0));
+ final double a0 = a.getValue();
+ return new DifferentialPair(StrictMath.cos(a0), -a.getFirstDerivative() * StrictMath.sin(a0));
}
/** Sine function.
@@ -100,8 +100,8 @@
* @return sin(a)
*/
public static DifferentialPair sin(final DifferentialPair a) {
- final double a0 = a.getU0();
- return new DifferentialPair(StrictMath.sin(a0), a.getU1() * StrictMath.cos(a0));
+ final double a0 = a.getValue();
+ return new DifferentialPair(StrictMath.sin(a0), a.getFirstDerivative() * StrictMath.cos(a0));
}
/** Tangent function.
@@ -109,8 +109,8 @@
* @return tan(a)
*/
public static DifferentialPair tan(final DifferentialPair a) {
- final double t = StrictMath.tan(a.getU0());
- return new DifferentialPair(t, a.getU1() * (1 + t * t));
+ final double t = StrictMath.tan(a.getValue());
+ return new DifferentialPair(t, a.getFirstDerivative() * (1 + t * t));
}
/** Inverse cosine function.
@@ -118,8 +118,8 @@
* @return acos(a)
*/
public static DifferentialPair acos(final DifferentialPair a) {
- final double a0 = a.getU0();
- return new DifferentialPair(StrictMath.acos(a0), -a.getU1() / StrictMath.sqrt(1 - a0 * a0));
+ final double a0 = a.getValue();
+ return new DifferentialPair(StrictMath.acos(a0), -a.getFirstDerivative() / StrictMath.sqrt(1 - a0 * a0));
}
/** Inverse sine function.
@@ -127,8 +127,8 @@
* @return asin(a)
*/
public static DifferentialPair asin(final DifferentialPair a) {
- final double a0 = a.getU0();
- return new DifferentialPair(StrictMath.asin(a0), a.getU1() / StrictMath.sqrt(1 - a0 * a0));
+ final double a0 = a.getValue();
+ return new DifferentialPair(StrictMath.asin(a0), a.getFirstDerivative() / StrictMath.sqrt(1 - a0 * a0));
}
/** Inverse tangent function.
@@ -136,8 +136,8 @@
* @return atan(a)
*/
public static DifferentialPair atan(final DifferentialPair a) {
- final double a0 = a.getU0();
- return new DifferentialPair(StrictMath.atan(a0), a.getU1() / (1 + a0 * a0));
+ final double a0 = a.getValue();
+ return new DifferentialPair(StrictMath.atan(a0), a.getFirstDerivative() / (1 + a0 * a0));
}
@@ -151,9 +151,9 @@
* @return angular part of the polar coordinates of the point
*/
public static DifferentialPair atan2(final DifferentialPair y, final double x) {
- final double y0 = y.getU0();
+ final double y0 = y.getValue();
return new DifferentialPair(StrictMath.atan2(y0, x),
- x * y.getU1() / (x * x + y0 * y0));
+ x * y.getFirstDerivative() / (x * x + y0 * y0));
}
/** Cartesian to polar conversion function.
@@ -162,9 +162,9 @@
* @return angular part of the polar coordinates of the point
*/
public static DifferentialPair atan2(final double y, final DifferentialPair x) {
- final double x0 = x.getU0();
+ final double x0 = x.getValue();
return new DifferentialPair(StrictMath.atan2(y, x0),
- -y * x.getU1() / (x0 * x0 + y * y));
+ -y * x.getFirstDerivative() / (x0 * x0 + y * y));
}
/** Cartesian to polar conversion function.
@@ -173,10 +173,10 @@
* @return angular part of the polar coordinates of the point
*/
public static DifferentialPair atan2(final DifferentialPair y, final DifferentialPair x) {
- final double y0 = y.getU0();
- final double x0 = x.getU0();
+ final double y0 = y.getValue();
+ final double x0 = x.getValue();
return new DifferentialPair(StrictMath.atan2(y0, x0),
- (x0 * y.getU1() - y0 * x.getU1()) / (x0 * x0 + y0 * y0));
+ (x0 * y.getFirstDerivative() - y0 * x.getFirstDerivative()) / (x0 * x0 + y0 * y0));
}
/** Cartesian to polar conversion function.
@@ -185,9 +185,9 @@
* @return radius part of the polar coordinates of the point
*/
public static DifferentialPair hypot(final DifferentialPair x, final double y) {
- final double x0 = x.getU0();
+ final double x0 = x.getValue();
final double h = StrictMath.hypot(x0, y);
- return new DifferentialPair(h, x0 * x.getU1() / h);
+ return new DifferentialPair(h, x0 * x.getFirstDerivative() / h);
}
/** Cartesian to polar conversion function.
@@ -196,9 +196,9 @@
* @return radius part of the polar coordinates of the point
*/
public static DifferentialPair hypot(final double x, final DifferentialPair y) {
- final double y0 = y.getU0();
+ final double y0 = y.getValue();
final double h = StrictMath.hypot(x, y0);
- return new DifferentialPair(h, y0 * y.getU1() / h);
+ return new DifferentialPair(h, y0 * y.getFirstDerivative() / h);
}
/** Cartesian to polar conversion function.
@@ -207,10 +207,10 @@
* @return radius part of the polar coordinates of the point
*/
public static DifferentialPair hypot(final DifferentialPair x, final DifferentialPair y) {
- final double x0 = x.getU0();
- final double y0 = y.getU0();
+ final double x0 = x.getValue();
+ final double y0 = y.getValue();
final double h = StrictMath.hypot(x0, y0);
- return new DifferentialPair(h, (x0 * x.getU1() + y0 * y.getU1()) / h);
+ return new DifferentialPair(h, (x0 * x.getFirstDerivative() + y0 * y.getFirstDerivative()) / h);
}
@@ -223,8 +223,8 @@
* @return cosh(a)
*/
public static DifferentialPair cosh(final DifferentialPair a) {
- final double a0 = a.getU0();
- return new DifferentialPair(StrictMath.cosh(a0), a.getU1() * StrictMath.sinh(a0));
+ final double a0 = a.getValue();
+ return new DifferentialPair(StrictMath.cosh(a0), a.getFirstDerivative() * StrictMath.sinh(a0));
}
/** Hyperbolic sine function.
@@ -232,8 +232,8 @@
* @return sinh(a)
*/
public static DifferentialPair sinh(final DifferentialPair a) {
- final double a0 = a.getU0();
- return new DifferentialPair(StrictMath.sinh(a0), a.getU1() * StrictMath.cosh(a0));
+ final double a0 = a.getValue();
+ return new DifferentialPair(StrictMath.sinh(a0), a.getFirstDerivative() * StrictMath.cosh(a0));
}
/** Hyperbolic tangent function.
@@ -241,8 +241,8 @@
* @return tanh(a)
*/
public static DifferentialPair tanh(final DifferentialPair a) {
- final double t = StrictMath.tanh(a.getU0());
- return new DifferentialPair(t, a.getU1() * (1 - t * t));
+ final double t = StrictMath.tanh(a.getValue());
+ return new DifferentialPair(t, a.getFirstDerivative() * (1 - t * t));
}
/** Inverse hyperbolic cosine function.
@@ -251,9 +251,9 @@
*/
public static DifferentialPair acosh(final DifferentialPair a) {
// the acosh function is not provided by java.lang.StrictMath as of Java6
- final double a0 = a.getU0();
+ final double a0 = a.getValue();
final double root = StrictMath.sqrt(a0 - 1) * StrictMath.sqrt(a0 + 1);
- return new DifferentialPair(StrictMath.log(a0 + root), a.getU1() / root);
+ return new DifferentialPair(StrictMath.log(a0 + root), a.getFirstDerivative() / root);
}
/** Inverse hyperbolic sine function.
@@ -262,9 +262,9 @@
*/
public static DifferentialPair asinh(final DifferentialPair a) {
// the asinh function is not provided by java.lang.StrictMath as of Java6
- final double a0 = a.getU0();
+ final double a0 = a.getValue();
final double root = StrictMath.sqrt(a0 * a0 + 1);
- return new DifferentialPair(StrictMath.log(a0 + root), a.getU1() / root);
+ return new DifferentialPair(StrictMath.log(a0 + root), a.getFirstDerivative() / root);
}
/** Inverse hyperbolic tangent function.
@@ -273,9 +273,9 @@
*/
public static DifferentialPair atanh(final DifferentialPair a) {
// the atanh function is not provided by java.lang.StrictMath as of Java6
- final double a0 = a.getU0();
+ final double a0 = a.getValue();
final double ath = (StrictMath.log1p(a0) - StrictMath.log1p(-a0)) / 2;
- return new DifferentialPair(ath, a.getU1() / (1 - a0 * a0));
+ return new DifferentialPair(ath, a.getFirstDerivative() / (1 - a0 * a0));
}
/////////////////////
@@ -287,8 +287,8 @@
* @return &sqrt;a
*/
public static DifferentialPair sqrt(final DifferentialPair a) {
- final double root = StrictMath.sqrt(a.getU0());
- return new DifferentialPair(root, a.getU1() / (2 * root));
+ final double root = StrictMath.sqrt(a.getValue());
+ return new DifferentialPair(root, a.getFirstDerivative() / (2 * root));
}
/** Cubic root function.
@@ -296,8 +296,8 @@
* @return cbrt(a)
*/
public static DifferentialPair cbrt(final DifferentialPair a) {
- final double root = StrictMath.cbrt(a.getU0());
- return new DifferentialPair(root, a.getU1() / (3 * root * root));
+ final double root = StrictMath.cbrt(a.getValue());
+ return new DifferentialPair(root, a.getFirstDerivative() / (3 * root * root));
}
/** Power function.
@@ -306,9 +306,9 @@
* @return a<sup>b</sup>
*/
public static DifferentialPair pow(final DifferentialPair a, final double b) {
- final double a0 = a.getU0();
+ final double a0 = a.getValue();
final double p = StrictMath.pow(a0, b);
- return new DifferentialPair(p, a.getU1() * b * p / a0);
+ return new DifferentialPair(p, a.getFirstDerivative() * b * p / a0);
}
/** Power function.
@@ -317,8 +317,8 @@
* @return a<sup>b</sup>
*/
public static DifferentialPair pow(final double a, final DifferentialPair b) {
- final double p = StrictMath.pow(a, b.getU0());
- return new DifferentialPair(p, b.getU1() * StrictMath.log(a) * p);
+ final double p = StrictMath.pow(a, b.getValue());
+ return new DifferentialPair(p, b.getFirstDerivative() * StrictMath.log(a) * p);
}
/** Power function.
@@ -327,10 +327,10 @@
* @return a<sup>b</sup>
*/
public static DifferentialPair pow(final DifferentialPair a, final DifferentialPair b) {
- final double a0 = a.getU0();
- final double b0 = b.getU0();
+ final double a0 = a.getValue();
+ final double b0 = b.getValue();
final double p = StrictMath.pow(a0, b0);
- return new DifferentialPair(p, (a.getU1() * b0 / a0 + b.getU1() * StrictMath.log(a0)) * p);
+ return new DifferentialPair(p, (a.getFirstDerivative() * b0 / a0 + b.getFirstDerivative() * StrictMath.log(a0)) * p);
}
@@ -343,7 +343,7 @@
* @return |a|
*/
public static DifferentialPair abs(final DifferentialPair a) {
- return (a.getU0() >= 0) ? a : DifferentialPair.negate(a);
+ return (a.getValue() >= 0) ? a : DifferentialPair.negate(a);
}
/** Sign function.
@@ -351,7 +351,7 @@
* @return -1, 0 or +1 according to the sign of a
*/
public static DifferentialPair signum(final DifferentialPair a) {
- return DifferentialPair.newConstant(StrictMath.signum(a.getU0()));
+ return DifferentialPair.newConstant(StrictMath.signum(a.getValue()));
}
/** Sign copy function.
@@ -361,7 +361,7 @@
*/
public static DifferentialPair copySign(final DifferentialPair magnitude,
final double sign) {
- final long mBits = Double.doubleToLongBits(magnitude.getU0());
+ final long mBits = Double.doubleToLongBits(magnitude.getValue());
final long sBits = Double.doubleToLongBits(sign);
return (((mBits ^ sBits) & 0x8000000000000000L) == 0) ?
magnitude : DifferentialPair.negate(magnitude);
@@ -375,7 +375,7 @@
public static DifferentialPair copySign(final double magnitude,
final DifferentialPair sign) {
final long mBits = Double.doubleToLongBits(magnitude);
- final long sBits = Double.doubleToLongBits(sign.getU0());
+ final long sBits = Double.doubleToLongBits(sign.getValue());
return (((mBits ^ sBits) & 0x8000000000000000L) == 0) ?
DifferentialPair.newConstant(magnitude) :
DifferentialPair.newConstant(-magnitude);
@@ -388,8 +388,8 @@
*/
public static DifferentialPair copySign(final DifferentialPair magnitude,
final DifferentialPair sign) {
- final long mBits = Double.doubleToLongBits(magnitude.getU0());
- final long sBits = Double.doubleToLongBits(sign.getU0());
+ final long mBits = Double.doubleToLongBits(magnitude.getValue());
+ final long sBits = Double.doubleToLongBits(sign.getValue());
return (((mBits ^ sBits) & 0x8000000000000000L) == 0) ?
magnitude : DifferentialPair.negate(magnitude);
}
@@ -404,7 +404,7 @@
* @return largest integer value smaller than a or equal to a
*/
public static DifferentialPair floor(final DifferentialPair a) {
- return DifferentialPair.newConstant(StrictMath.floor(a.getU0()));
+ return DifferentialPair.newConstant(StrictMath.floor(a.getValue()));
}
/** Rounding function.
@@ -412,7 +412,7 @@
* @return closest integer value to a
*/
public static DifferentialPair rint(final DifferentialPair a) {
- return DifferentialPair.newConstant(StrictMath.rint(a.getU0()));
+ return DifferentialPair.newConstant(StrictMath.rint(a.getValue()));
}
/** Ceil function.
@@ -420,7 +420,7 @@
* @return smallest integer value greater than a or equal to a
*/
public static DifferentialPair ceil(final DifferentialPair a) {
- return DifferentialPair.newConstant(StrictMath.ceil(a.getU0()));
+ return DifferentialPair.newConstant(StrictMath.ceil(a.getValue()));
}
/** Neighbor function.
@@ -428,7 +428,7 @@
* @return smallest representable double value ly greater than a
*/
public static DifferentialPair nextUp(final DifferentialPair a) {
- return new DifferentialPair(StrictMath.nextUp(a.getU0()), a.getU1());
+ return new DifferentialPair(StrictMath.nextUp(a.getValue()), a.getFirstDerivative());
}
/** Neighbor function.
@@ -438,8 +438,8 @@
*/
public static DifferentialPair nextAfter(final DifferentialPair start,
final double direction) {
- return new DifferentialPair(StrictMath.nextAfter(start.getU0(), direction),
- start.getU1());
+ return new DifferentialPair(StrictMath.nextAfter(start.getValue(), direction),
+ start.getFirstDerivative());
}
/** Neighbor function.
@@ -449,7 +449,7 @@
*/
public static DifferentialPair nextAfter(final double start,
final DifferentialPair direction) {
- return DifferentialPair.newConstant(StrictMath.nextAfter(start, direction.getU0()));
+ return DifferentialPair.newConstant(StrictMath.nextAfter(start, direction.getValue()));
}
/** Neighbor function.
@@ -459,7 +459,7 @@
*/
public static DifferentialPair nextAfter(final DifferentialPair start,
final DifferentialPair direction) {
- return new DifferentialPair(StrictMath.nextAfter(start.getU0(), direction.getU0()), start.getU1());
+ return new DifferentialPair(StrictMath.nextAfter(start.getValue(), direction.getValue()), start.getFirstDerivative());
}
@@ -472,7 +472,7 @@
* @return value of the least significant bit of a
*/
public static DifferentialPair ulp(final DifferentialPair a) {
- return DifferentialPair.newConstant(StrictMath.ulp(a.getU0()));
+ return DifferentialPair.newConstant(StrictMath.ulp(a.getValue()));
}
/** Binary rescaling function.
@@ -482,8 +482,8 @@
*/
public static DifferentialPair scalb(final DifferentialPair a,
final int scale) {
- return new DifferentialPair(StrictMath.scalb(a.getU0(), scale),
- StrictMath.scalb(a.getU1(), scale));
+ return new DifferentialPair(StrictMath.scalb(a.getValue(), scale),
+ StrictMath.scalb(a.getFirstDerivative(), scale));
}
/** Remainder function.
@@ -493,8 +493,8 @@
*/
public static DifferentialPair IEEEremainder(final DifferentialPair f1,
final double f2) {
- final double r = StrictMath.IEEEremainder(f1.getU0(), f2);
- return new DifferentialPair(r, f1.getU1());
+ final double r = StrictMath.IEEEremainder(f1.getValue(), f2);
+ return new DifferentialPair(r, f1.getFirstDerivative());
}
/** Remainder function.
@@ -504,10 +504,10 @@
*/
public static DifferentialPair IEEEremainder(final double f1,
final DifferentialPair f2) {
- final double f20 = f2.getU0();
+ final double f20 = f2.getValue();
final double r = StrictMath.IEEEremainder(f1, f20);
final int n = (int) ((r - f1) / f20);
- return new DifferentialPair(r, n * f2.getU1());
+ return new DifferentialPair(r, n * f2.getFirstDerivative());
}
/** Remainder function.
@@ -517,11 +517,11 @@
*/
public static DifferentialPair IEEEremainder(final DifferentialPair f1,
final DifferentialPair f2) {
- final double f10 = f1.getU0();
- final double f20 = f2.getU0();
+ final double f10 = f1.getValue();
+ final double f20 = f2.getValue();
final double r = StrictMath.IEEEremainder(f10, f20);
final int n = (int) ((r - f10) / f20);
- return new DifferentialPair(r, f1.getU1() + n * f2.getU1());
+ return new DifferentialPair(r, f1.getFirstDerivative() + n * f2.getFirstDerivative());
}
@@ -534,7 +534,7 @@
* @return angle converted to degrees
*/
public static DifferentialPair toDegrees(final DifferentialPair a) {
- return new DifferentialPair(StrictMath.toDegrees(a.getU0()), StrictMath.toDegrees(a.getU1()));
+ return new DifferentialPair(StrictMath.toDegrees(a.getValue()), StrictMath.toDegrees(a.getFirstDerivative()));
}
/** Angular conversion function.
@@ -542,7 +542,7 @@
* @return angle converted to radians
*/
public static DifferentialPair toRadians(final DifferentialPair a) {
- return new DifferentialPair(StrictMath.toRadians(a.getU0()), StrictMath.toRadians(a.getU1()));
+ return new DifferentialPair(StrictMath.toRadians(a.getValue()), StrictMath.toRadians(a.getFirstDerivative()));
}
@@ -557,7 +557,7 @@
*/
public static DifferentialPair max(final DifferentialPair a,
final double b) {
- return (a.getU0() >= b) ? a : DifferentialPair.newConstant(b);
+ return (a.getValue() >= b) ? a : DifferentialPair.newConstant(b);
}
/** Max function.
@@ -567,7 +567,7 @@
*/
public static DifferentialPair max(final double a,
final DifferentialPair b) {
- return (b.getU0() >= a) ? b : DifferentialPair.newConstant(a);
+ return (b.getValue() >= a) ? b : DifferentialPair.newConstant(a);
}
/** Max function.
@@ -577,7 +577,7 @@
*/
public static DifferentialPair max(final DifferentialPair a,
final DifferentialPair b) {
- return (a.getU0() >= b.getU0()) ? a : b;
+ return (a.getValue() >= b.getValue()) ? a : b;
}
/** Min function.
@@ -587,7 +587,7 @@
*/
public static DifferentialPair min(final DifferentialPair a,
final double b) {
- return (a.getU0() <= b) ? a : DifferentialPair.newConstant(b);
+ return (a.getValue() <= b) ? a : DifferentialPair.newConstant(b);
}
/** Min function.
@@ -597,7 +597,7 @@
*/
public static DifferentialPair min(final double a,
final DifferentialPair b) {
- return (b.getU0() <= a) ? b : DifferentialPair.newConstant(a);
+ return (b.getValue() <= a) ? b : DifferentialPair.newConstant(a);
}
/** Min function.
@@ -607,7 +607,7 @@
*/
public static DifferentialPair min(final DifferentialPair a,
final DifferentialPair b) {
- return (a.getU0() <= b.getU0()) ? a : b;
+ return (a.getValue() <= b.getValue()) ? a : b;
}
}
Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/analysis/MethodDifferentiator.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/analysis/MethodDifferentiator.java?rev=649240&r1=649239&r2=649240&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/analysis/MethodDifferentiator.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/automatic/analysis/MethodDifferentiator.java Thu Apr 17 12:21:19 2008
@@ -460,10 +460,14 @@
final InsnList list = new InsnList();
list.add(new VarInsnNode(Opcodes.ALOAD, 1));
list.add(new InsnNode(Opcodes.DUP));
- list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, AutomaticDifferentiator.DP_NAME, "getU0",
+ list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL,
+ AutomaticDifferentiator.DP_NAME,
+ "getValue",
VOID_RETURN_D_DESCRIPTOR));
list.add(new VarInsnNode(Opcodes.DSTORE, 1));
- list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, AutomaticDifferentiator.DP_NAME, "getU1",
+ list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL,
+ AutomaticDifferentiator.DP_NAME,
+ "getFirstDerivative",
VOID_RETURN_D_DESCRIPTOR));
list.add(new VarInsnNode(Opcodes.DSTORE, 3));
Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/core/DifferentialPair.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/core/DifferentialPair.java?rev=649240&r1=649239&r2=649240&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/core/DifferentialPair.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/core/DifferentialPair.java Thu Apr 17 12:21:19 2008
@@ -66,18 +66,18 @@
/** Value part of the differential pair. */
- private final double u0;
+ private final double value;
- /** First differential part of the differential pair. */
- private final double u1;
+ /** First derivative part of the differential pair. */
+ private final double firstDerivative;
/** Build a new instance from its components.
* @param u0 value part of the differential pair
- * @param u1 first differential part of the differential pair
+ * @param u1 first derivative part of the differential pair
*/
public DifferentialPair(final double u0, final double u1) {
- this.u0 = u0;
- this.u1 = u1;
+ this.value = u0;
+ this.firstDerivative = u1;
}
/** Build an instance representing a univariate variable.
@@ -106,16 +106,18 @@
/** Get the value part of the differential pair.
* @return value part of the differential pair
+ * @see #getFirstDerivative()
*/
- public double getU0() {
- return u0;
+ public double getValue() {
+ return value;
}
- /** Get the first differential part of the differential pair.
- * @return first differential part of the differential pair
+ /** Get the first derivative part of the differential pair.
+ * @return first derivative part of the differential pair
+ * @see #getValue()
*/
- public double getU1() {
- return u1;
+ public double getFirstDerivative() {
+ return firstDerivative;
}
/** '+' operator, for differential pairs.
@@ -125,7 +127,7 @@
*/
public static DifferentialPair add(final DifferentialPair a,
final int b) {
- return new DifferentialPair(a.u0 + b, a.u1);
+ return new DifferentialPair(a.value + b, a.firstDerivative);
}
/** '+' operator, for differential pairs.
@@ -135,7 +137,7 @@
*/
public static DifferentialPair add(final int a,
final DifferentialPair b) {
- return new DifferentialPair(a + b.u0, b.u1);
+ return new DifferentialPair(a + b.value, b.firstDerivative);
}
/** '+' operator, for differential pairs.
@@ -145,7 +147,7 @@
*/
public static DifferentialPair add(final DifferentialPair a,
final long b) {
- return new DifferentialPair(a.u0 + b, a.u1);
+ return new DifferentialPair(a.value + b, a.firstDerivative);
}
/** '+' operator, for differential pairs.
@@ -155,7 +157,7 @@
*/
public static DifferentialPair add(final long a,
final DifferentialPair b) {
- return new DifferentialPair(a + b.u0, b.u1);
+ return new DifferentialPair(a + b.value, b.firstDerivative);
}
/** '+' operator, for differential pairs.
@@ -165,7 +167,7 @@
*/
public static DifferentialPair add(final DifferentialPair a,
final double b) {
- return new DifferentialPair(a.u0 + b, a.u1);
+ return new DifferentialPair(a.value + b, a.firstDerivative);
}
/** '+' operator, for differential pairs.
@@ -175,7 +177,7 @@
*/
public static DifferentialPair add(final double a,
final DifferentialPair b) {
- return new DifferentialPair(a + b.u0, b.u1);
+ return new DifferentialPair(a + b.value, b.firstDerivative);
}
/** '+' operator, for differential pairs.
@@ -185,7 +187,7 @@
*/
public static DifferentialPair add(final DifferentialPair a,
final DifferentialPair b) {
- return new DifferentialPair(a.u0 + b.u0, a.u1 + b.u1);
+ return new DifferentialPair(a.value + b.value, a.firstDerivative + b.firstDerivative);
}
/** '-' operator, for differential pairs.
@@ -195,7 +197,7 @@
*/
public static DifferentialPair subtract(final DifferentialPair a,
final int b) {
- return new DifferentialPair(a.u0 - b, a.u1);
+ return new DifferentialPair(a.value - b, a.firstDerivative);
}
/** '-' operator, for differential pairs.
@@ -205,7 +207,7 @@
*/
public static DifferentialPair subtract(final int a,
final DifferentialPair b) {
- return new DifferentialPair(a - b.u0, -b.u1);
+ return new DifferentialPair(a - b.value, -b.firstDerivative);
}
/** '-' operator, for differential pairs.
@@ -215,7 +217,7 @@
*/
public static DifferentialPair subtract(final DifferentialPair a,
final long b) {
- return new DifferentialPair(a.u0 - b, a.u1);
+ return new DifferentialPair(a.value - b, a.firstDerivative);
}
/** '-' operator, for differential pairs.
@@ -225,7 +227,7 @@
*/
public static DifferentialPair subtract(final long a,
final DifferentialPair b) {
- return new DifferentialPair(a - b.u0, -b.u1);
+ return new DifferentialPair(a - b.value, -b.firstDerivative);
}
/** '-' operator, for differential pairs.
@@ -235,7 +237,7 @@
*/
public static DifferentialPair subtract(final DifferentialPair a,
final double b) {
- return new DifferentialPair(a.u0 - b, a.u1);
+ return new DifferentialPair(a.value - b, a.firstDerivative);
}
/** '-' operator, for differential pairs.
@@ -245,7 +247,7 @@
*/
public static DifferentialPair subtract(final double a,
final DifferentialPair b) {
- return new DifferentialPair(a - b.u0, -b.u1);
+ return new DifferentialPair(a - b.value, -b.firstDerivative);
}
/** '-' operator, for differential pairs.
@@ -255,7 +257,7 @@
*/
public static DifferentialPair subtract(final DifferentialPair a,
final DifferentialPair b) {
- return new DifferentialPair(a.u0 - b.u0, a.u1 - b.u1);
+ return new DifferentialPair(a.value - b.value, a.firstDerivative - b.firstDerivative);
}
/** '×' operator, for differential pairs.
@@ -265,7 +267,7 @@
*/
public static DifferentialPair multiply(final DifferentialPair a,
final int b) {
- return new DifferentialPair(a.u0 * b, a.u1 * b);
+ return new DifferentialPair(a.value * b, a.firstDerivative * b);
}
/** '×' operator, for differential pairs.
@@ -275,7 +277,7 @@
*/
public static DifferentialPair multiply(final int a,
final DifferentialPair b) {
- return new DifferentialPair(a * b.u0, a * b.u1);
+ return new DifferentialPair(a * b.value, a * b.firstDerivative);
}
/** '×' operator, for differential pairs.
@@ -285,7 +287,7 @@
*/
public static DifferentialPair multiply(final DifferentialPair a,
final long b) {
- return new DifferentialPair(a.u0 * b, a.u1 * b);
+ return new DifferentialPair(a.value * b, a.firstDerivative * b);
}
/** '×' operator, for differential pairs.
@@ -295,7 +297,7 @@
*/
public static DifferentialPair multiply(final long a,
final DifferentialPair b) {
- return new DifferentialPair(a * b.u0, a * b.u1);
+ return new DifferentialPair(a * b.value, a * b.firstDerivative);
}
/** '×' operator, for differential pairs.
@@ -305,7 +307,7 @@
*/
public static DifferentialPair multiply(final DifferentialPair a,
final double b) {
- return new DifferentialPair(a.u0 * b, a.u1 * b);
+ return new DifferentialPair(a.value * b, a.firstDerivative * b);
}
/** '×' operator, for differential pairs.
@@ -315,7 +317,7 @@
*/
public static DifferentialPair multiply(final double a,
final DifferentialPair b) {
- return new DifferentialPair(a * b.u0, a * b.u1);
+ return new DifferentialPair(a * b.value, a * b.firstDerivative);
}
/** '×' operator, for differential pairs.
@@ -325,7 +327,7 @@
*/
public static DifferentialPair multiply(final DifferentialPair a,
final DifferentialPair b) {
- return new DifferentialPair(a.u0 * b.u0, a.u1 * b.u0 + a.u0 * b.u1);
+ return new DifferentialPair(a.value * b.value, a.firstDerivative * b.value + a.value * b.firstDerivative);
}
/** '÷s;' operator, for differential pairs.
@@ -335,7 +337,7 @@
*/
public static DifferentialPair divide(final DifferentialPair a,
final int b) {
- return new DifferentialPair(a.u0 / b, a.u1 / b);
+ return new DifferentialPair(a.value / b, a.firstDerivative / b);
}
/** '÷s;' operator, for differential pairs.
@@ -345,7 +347,7 @@
*/
public static DifferentialPair divide(final int a,
final DifferentialPair b) {
- return new DifferentialPair(a / b.u0, -a * b.u1 / (b.u0 * b.u0));
+ return new DifferentialPair(a / b.value, -a * b.firstDerivative / (b.value * b.value));
}
/** '÷s;' operator, for differential pairs.
@@ -355,7 +357,7 @@
*/
public static DifferentialPair divide(final DifferentialPair a,
final long b) {
- return new DifferentialPair(a.u0 / b, a.u1 / b);
+ return new DifferentialPair(a.value / b, a.firstDerivative / b);
}
/** '÷s;' operator, for differential pairs.
@@ -365,7 +367,7 @@
*/
public static DifferentialPair divide(final long a,
final DifferentialPair b) {
- return new DifferentialPair(a / b.u0, -a * b.u1 / (b.u0 * b.u0));
+ return new DifferentialPair(a / b.value, -a * b.firstDerivative / (b.value * b.value));
}
/** '÷s;' operator, for differential pairs.
@@ -375,7 +377,7 @@
*/
public static DifferentialPair divide(final DifferentialPair a,
final double b) {
- return new DifferentialPair(a.u0 / b, a.u1 / b);
+ return new DifferentialPair(a.value / b, a.firstDerivative / b);
}
/** '÷s;' operator, for differential pairs.
@@ -385,7 +387,7 @@
*/
public static DifferentialPair divide(final double a,
final DifferentialPair b) {
- return new DifferentialPair(a / b.u0, -a * b.u1 / (b.u0 * b.u0));
+ return new DifferentialPair(a / b.value, -a * b.firstDerivative / (b.value * b.value));
}
/** '÷s;' operator, for differential pairs.
@@ -395,7 +397,7 @@
*/
public static DifferentialPair divide(final DifferentialPair a,
final DifferentialPair b) {
- return new DifferentialPair(a.u0 / b.u0, (a.u1 * b.u0 - a.u0 * b.u1) / (b.u0 * b.u0));
+ return new DifferentialPair(a.value / b.value, (a.firstDerivative * b.value - a.value * b.firstDerivative) / (b.value * b.value));
}
/** '%' operator, for differential pairs.
@@ -405,8 +407,8 @@
*/
public static DifferentialPair remainder(final int a,
final DifferentialPair b) {
- final double remainder = a % b.u0;
- return new DifferentialPair(remainder, (remainder - a) * b.u1 / b.u0);
+ final double remainder = a % b.value;
+ return new DifferentialPair(remainder, (remainder - a) * b.firstDerivative / b.value);
}
/** '%' operator, for differential pairs.
@@ -416,7 +418,7 @@
*/
public static DifferentialPair remainder(final DifferentialPair a,
final int b) {
- return new DifferentialPair(a.u0 % b, a.u1);
+ return new DifferentialPair(a.value % b, a.firstDerivative);
}
/** '%' operator, for differential pairs.
@@ -426,8 +428,8 @@
*/
public static DifferentialPair remainder(final long a,
final DifferentialPair b) {
- final double remainder = a % b.u0;
- return new DifferentialPair(remainder, (remainder - a) * b.u1 / b.u0);
+ final double remainder = a % b.value;
+ return new DifferentialPair(remainder, (remainder - a) * b.firstDerivative / b.value);
}
/** '%' operator, for differential pairs.
@@ -437,7 +439,7 @@
*/
public static DifferentialPair remainder(final DifferentialPair a,
final long b) {
- return new DifferentialPair(a.u0 % b, a.u1);
+ return new DifferentialPair(a.value % b, a.firstDerivative);
}
/** '%' operator, for differential pairs.
@@ -447,8 +449,8 @@
*/
public static DifferentialPair remainder(final double a,
final DifferentialPair b) {
- final double remainder = a % b.u0;
- return new DifferentialPair(remainder, (remainder - a) * b.u1 / b.u0);
+ final double remainder = a % b.value;
+ return new DifferentialPair(remainder, (remainder - a) * b.firstDerivative / b.value);
}
/** '%' operator, for differential pairs.
@@ -458,7 +460,7 @@
*/
public static DifferentialPair remainder(final DifferentialPair a,
final double b) {
- return new DifferentialPair(a.u0 % b, a.u1);
+ return new DifferentialPair(a.value % b, a.firstDerivative);
}
/** '%' operator, for differential pairs.
@@ -468,8 +470,8 @@
*/
public static DifferentialPair remainder(final DifferentialPair a,
final DifferentialPair b) {
- final double remainder = a.u0 % b.u0;
- return new DifferentialPair(remainder, (remainder - a.u0) * b.u1 / b.u0 + a.u1);
+ final double remainder = a.value % b.value;
+ return new DifferentialPair(remainder, (remainder - a.value) * b.firstDerivative / b.value + a.firstDerivative);
}
/** unary '-' operator, for differential pairs.
@@ -477,7 +479,7 @@
* @return -a
*/
public static DifferentialPair negate(final DifferentialPair a) {
- return new DifferentialPair(-a.u0 , -a.u1);
+ return new DifferentialPair(-a.value , -a.firstDerivative);
}
/** squaring operation, for differential pairs.
@@ -485,7 +487,7 @@
* @return a<sup>2</sup>
*/
public static DifferentialPair square(final DifferentialPair a) {
- return new DifferentialPair(a.u0 * a.u0, 2 * a.u0 * a.u1);
+ return new DifferentialPair(a.value * a.value, 2 * a.value * a.firstDerivative);
}
/** cubing operation, for differential pairs.
@@ -493,8 +495,8 @@
* @return a<sup>3</sup>
*/
public static DifferentialPair cube(final DifferentialPair a) {
- final double u02 = a.u0 * a.u0;
- return new DifferentialPair(a.u0 * u02, 3 * u02 * a.u1);
+ final double u02 = a.value * a.value;
+ return new DifferentialPair(a.value * u02, 3 * u02 * a.firstDerivative);
}
}
Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/EightPointsScheme.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/EightPointsScheme.java?rev=649240&r1=649239&r2=649240&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/EightPointsScheme.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/EightPointsScheme.java Thu Apr 17 12:21:19 2008
@@ -48,13 +48,13 @@
}
public DifferentialPair f(final DifferentialPair t) {
final double h = getStepSize();
- final double u0 = t.getU0();
+ final double u0 = t.getValue();
final double ft = d.f(u0);
final double d1 = d.f(u0 + h) - d.f(u0 - h);
final double d2 = d.f(u0 + 2 * h) - d.f(u0 - 2 * h);
final double d3 = d.f(u0 + 3 * h) - d.f(u0 - 3 * h);
final double d4 = d.f(u0 + 4 * h) - d.f(u0 - 4 * h);
- return new DifferentialPair(ft, t.getU1() * (-3 * d4 + 32 * d3 - 168 * d2 + 672 * d1) / denominator);
+ return new DifferentialPair(ft, t.getFirstDerivative() * (-3 * d4 + 32 * d3 - 168 * d2 + 672 * d1) / denominator);
}
};
}
Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/FourPointsScheme.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/FourPointsScheme.java?rev=649240&r1=649239&r2=649240&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/FourPointsScheme.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/FourPointsScheme.java Thu Apr 17 12:21:19 2008
@@ -48,11 +48,11 @@
}
public DifferentialPair f(final DifferentialPair t) {
final double h = getStepSize();
- final double u0 = t.getU0();
+ final double u0 = t.getValue();
final double ft = d.f(u0);
final double d1 = d.f(u0 + h) - d.f(u0 - h);
final double d2 = d.f(u0 + 2 * h) - d.f(u0 - 2 * h);
- return new DifferentialPair(ft, t.getU1() * (8 * d1 - d2) / denominator);
+ return new DifferentialPair(ft, t.getFirstDerivative() * (8 * d1 - d2) / denominator);
}
};
}
Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/SixPointsScheme.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/SixPointsScheme.java?rev=649240&r1=649239&r2=649240&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/SixPointsScheme.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/SixPointsScheme.java Thu Apr 17 12:21:19 2008
@@ -48,12 +48,12 @@
}
public DifferentialPair f(final DifferentialPair t) {
final double h = getStepSize();
- final double u0 = t.getU0();
+ final double u0 = t.getValue();
final double ft = d.f(u0);
final double d1 = d.f(u0 + h) - d.f(u0 - h);
final double d2 = d.f(u0 + 2 * h) - d.f(u0 - 2 * h);
final double d3 = d.f(u0 + 3 * h) - d.f(u0 - 3 * h);
- return new DifferentialPair(ft, t.getU1() * (d3 - 9 * d2 + 45 * d1) / denominator);
+ return new DifferentialPair(ft, t.getFirstDerivative() * (d3 - 9 * d2 + 45 * d1) / denominator);
}
};
}
Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/TwoPointsScheme.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/TwoPointsScheme.java?rev=649240&r1=649239&r2=649240&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/TwoPointsScheme.java (original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/TwoPointsScheme.java Thu Apr 17 12:21:19 2008
@@ -48,10 +48,10 @@
}
public DifferentialPair f(final DifferentialPair t) {
final double h = getStepSize();
- final double u0 = t.getU0();
+ final double u0 = t.getValue();
final double ft = d.f(u0);
final double d1 = d.f(u0 + h) - d.f(u0 - h);
- return new DifferentialPair(ft, t.getU1() * d1 / denominator);
+ return new DifferentialPair(ft, t.getFirstDerivative() * d1 / denominator);
}
};
}
Modified: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/AbstractStaticFunctionsTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/AbstractStaticFunctionsTest.java?rev=649240&r1=649239&r2=649240&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/AbstractStaticFunctionsTest.java (original)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/AbstractStaticFunctionsTest.java Thu Apr 17 12:21:19 2008
@@ -180,7 +180,7 @@
double d = ((Double) javaMethod.invoke(null, javaArgs)).doubleValue();
// check the nabla and java classes compute the same function
- assertEquals(d, dp.getU0(), valueTolerance);
+ assertEquals(d, dp.getValue(), valueTolerance);
} catch (InvocationTargetException ite) {
fail(ite.getMessage());
@@ -213,7 +213,7 @@
for (int i = 0; i < converted.length; ++i) {
if (converted[i] instanceof DifferentialPair) {
DifferentialPair a = (DifferentialPair) converted[i];
- changed[i] = new Double(a.getU0() + x * a.getU1());
+ changed[i] = new Double(a.getValue() + x * a.getFirstDerivative());
} else {
changed[i] = converted[i];
}
@@ -226,7 +226,7 @@
}).f(DifferentialPair.newVariable(0.0));
// check the nabla and java classes compute the same differential
- assertEquals(differencesDP.getU1(), nablaDP.getU1(),
+ assertEquals(differencesDP.getFirstDerivative(), nablaDP.getFirstDerivative(),
differentialTolerance);
} catch (InvocationTargetException ite) {
Modified: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/AbstractMathTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/AbstractMathTest.java?rev=649240&r1=649239&r2=649240&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/AbstractMathTest.java (original)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/automatic/AbstractMathTest.java Thu Apr 17 12:21:19 2008
@@ -36,7 +36,7 @@
for (int i = 0; i < n; ++i) {
double t = ((n - 1 - i) * t0 + i * t1) / (n - 1);
DifferentialPair dpT = DifferentialPair.newVariable(t);
- assertEquals(reference.fPrime(t), derivative.f(dpT).getU1(), threshold);
+ assertEquals(reference.fPrime(t), derivative.f(dpT).getFirstDerivative(), threshold);
}
} catch (DifferentiationException de) {
fail(de.getMessage());
Modified: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/core/DifferentialPairTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/core/DifferentialPairTest.java?rev=649240&r1=649239&r2=649240&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/core/DifferentialPairTest.java (original)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/core/DifferentialPairTest.java Thu Apr 17 12:21:19 2008
@@ -23,20 +23,20 @@
public void testConstant() {
DifferentialPair p = DifferentialPair.newConstant(1.5);
- assertEquals(1.5, p.getU0(), 1.0e-15);
- assertEquals(0.0, p.getU1(), 1.0e-15);
+ assertEquals(1.5, p.getValue(), 1.0e-15);
+ assertEquals(0.0, p.getFirstDerivative(), 1.0e-15);
}
public void testVariable() {
DifferentialPair p = DifferentialPair.newVariable(1.5);
- assertEquals(1.5, p.getU0(), 1.0e-15);
- assertEquals(1.0, p.getU1(), 1.0e-15);
+ assertEquals(1.5, p.getValue(), 1.0e-15);
+ assertEquals(1.0, p.getFirstDerivative(), 1.0e-15);
}
public void testConstructor() {
DifferentialPair p = new DifferentialPair(1.5, -1.3);
- assertEquals(1.5, p.getU0(), 1.0e-15);
- assertEquals(-1.3, p.getU1(), 1.0e-15);
+ assertEquals(1.5, p.getValue(), 1.0e-15);
+ assertEquals(-1.3, p.getFirstDerivative(), 1.0e-15);
}
public void testMonadicOperations() {
Modified: commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/differences/AbstractFiniteDifferencesTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/differences/AbstractFiniteDifferencesTest.java?rev=649240&r1=649239&r2=649240&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/differences/AbstractFiniteDifferencesTest.java (original)
+++ commons/sandbox/nabla/trunk/src/test/java/org/apache/commons/nabla/differences/AbstractFiniteDifferencesTest.java Thu Apr 17 12:21:19 2008
@@ -61,8 +61,8 @@
ReferenceFunction reference = Polynomial.randomPolynomial(random, k);
UnivariateDerivative derivative = buildDifferentiator(0.1).differentiate(reference);
for (DifferentialPair t : transcendentals) {
- double error = derivative.f(t).getU1() - reference.fPrime(t.getU0());
- assertEquals(0, error, 1.0e-13 * Math.abs(reference.fPrime(t.getU0())));
+ double error = derivative.f(t).getFirstDerivative() - reference.fPrime(t.getValue());
+ assertEquals(0, error, 1.0e-13 * Math.abs(reference.fPrime(t.getValue())));
}
}
}
@@ -84,7 +84,7 @@
for (int i = 0; i < transcendentals.length; ++i) {
DifferentialPair t = transcendentals[i];
beforeChange[i] = derivative.f(t);
- assertEquals(0, beforeChange[i].getU1() - reference.fPrime(t.getU0()), 100 * Math.abs(errorScaleFactor));
+ assertEquals(0, beforeChange[i].getFirstDerivative() - reference.fPrime(t.getValue()), 100 * Math.abs(errorScaleFactor));
}
// change the primitive WITHOUT recomputing the differential
@@ -96,15 +96,15 @@
for (int i = 0; i < transcendentals.length; ++i) {
DifferentialPair t = transcendentals[i];
afterChange[i] = derivative.f(t);
- assertEquals(0, afterChange[i].getU1() - reference.fPrime(t.getU0()), 100 * Math.abs(errorScaleFactor));
+ assertEquals(0, afterChange[i].getFirstDerivative() - reference.fPrime(t.getValue()), 100 * Math.abs(errorScaleFactor));
}
// check the change was important
for (int i = 0; i < transcendentals.length; ++i) {
DifferentialPair change =
DifferentialPair.subtract(beforeChange[i], afterChange[i]);
- assertTrue(Math.abs(change.getU0()) > 10000.0 * Math.abs(errorScaleFactor));
- assertTrue(Math.abs(change.getU1()) > 10000.0 * Math.abs(errorScaleFactor));
+ assertTrue(Math.abs(change.getValue()) > 10000.0 * Math.abs(errorScaleFactor));
+ assertTrue(Math.abs(change.getFirstDerivative()) > 10000.0 * Math.abs(errorScaleFactor));
}
}
@@ -126,7 +126,7 @@
for (int i = 0; i < n; ++i) {
double t = ((n1 - i) * lower + i * upper) / n1;
assertEquals(reference.fPrime(t),
- derivative.f(DifferentialPair.newVariable(t)).getU1(),
+ derivative.f(DifferentialPair.newVariable(t)).getFirstDerivative(),
epsilon);
}
} catch (DifferentiationException de) {
@@ -153,7 +153,7 @@
FiniteDifferencesDifferentiator fds = buildDifferentiator(h);
UnivariateDerivative derivative = fds.differentiate(reference);
double rawError =
- derivative.f(DifferentialPair.newVariable(t)).getU1() - reference.fPrime(t);
+ derivative.f(DifferentialPair.newVariable(t)).getFirstDerivative() - reference.fPrime(t);
double orderNormalizedError = Math.abs(rawError / fds.getSignedErrorScaleFactor());
assertEquals(error, orderNormalizedError, epsilon);
}