The following document contains the results of PMD's CPD 4.1.
| File | Line |
|---|---|
| org\apache\commons\nabla\NablaMath.java | 354 |
| org\apache\commons\nabla\NablaStrictMath.java | 354 |
return DifferentialPair.newConstant(StrictMath.signum(a.getValue()));
}
/** Sign copy function.
* @param magnitude function input value
* @param sign sign reference
* @return either magnitude or -magnitude to match sign
*/
public static DifferentialPair copySign(final DifferentialPair magnitude,
final double sign) {
final long mBits = Double.doubleToLongBits(magnitude.getValue());
final long sBits = Double.doubleToLongBits(sign);
return (((mBits ^ sBits) & 0x8000000000000000L) == 0) ?
magnitude : DifferentialPair.negate(magnitude);
}
/** Sign copy function.
* @param magnitude function input value
* @param sign sign reference
* @return either magnitude or -magnitude to match sign
*/
public static DifferentialPair copySign(final double magnitude,
final DifferentialPair sign) {
final long mBits = Double.doubleToLongBits(magnitude);
final long sBits = Double.doubleToLongBits(sign.getValue());
return (((mBits ^ sBits) & 0x8000000000000000L) == 0) ?
DifferentialPair.newConstant(magnitude) :
DifferentialPair.newConstant(-magnitude);
}
/** Sign copy function.
* @param magnitude function input value
* @param sign sign reference
* @return either magnitude or -magnitude to match sign
*/
public static DifferentialPair copySign(final DifferentialPair magnitude,
final DifferentialPair sign) {
final long mBits = Double.doubleToLongBits(magnitude.getValue());
final long sBits = Double.doubleToLongBits(sign.getValue());
return (((mBits ^ sBits) & 0x8000000000000000L) == 0) ?
magnitude : DifferentialPair.negate(magnitude);
}
////////////////////////////
// neighborhood functions //
////////////////////////////
/** Floor function.
* @param a function input value
* @return largest integer value smaller than a or equal to a
*/
public static DifferentialPair floor(final DifferentialPair a) {
return DifferentialPair.newConstant(StrictMath.floor(a.getValue()));
| |
| File | Line |
|---|---|
| org\apache\commons\nabla\NablaMath.java | 545 |
| org\apache\commons\nabla\NablaStrictMath.java | 545 |
return new DifferentialPair(StrictMath.toRadians(a.getValue()), StrictMath.toRadians(a.getFirstDerivative()));
}
//////////////////////////
// comparison functions //
//////////////////////////
/** Max function.
* @param a first function input value
* @param b second function input value
* @return maximal value from the (a, b) pair
*/
public static DifferentialPair max(final DifferentialPair a,
final double b) {
return (a.getValue() >= b) ? a : DifferentialPair.newConstant(b);
}
/** Max function.
* @param a first function input value
* @param b second function input value
* @return maximal value from the (a, b) pair
*/
public static DifferentialPair max(final double a,
final DifferentialPair b) {
return (b.getValue() >= a) ? b : DifferentialPair.newConstant(a);
}
/** Max function.
* @param a first function input value
* @param b second function input value
* @return maximal value from the (a, b) pair
*/
public static DifferentialPair max(final DifferentialPair a,
final DifferentialPair b) {
return (a.getValue() >= b.getValue()) ? a : b;
}
/** Min function.
* @param a first function input value
* @param b second function input value
* @return minimal value from the (a, b) pair
*/
public static DifferentialPair min(final DifferentialPair a,
final double b) {
return (a.getValue() <= b) ? a : DifferentialPair.newConstant(b);
}
/** Min function.
* @param a first function input value
* @param b second function input value
* @return minimal value from the (a, b) pair
*/
public static DifferentialPair min(final double a,
final DifferentialPair b) {
return (b.getValue() <= a) ? b : DifferentialPair.newConstant(a);
}
/** Min function.
* @param a first function input value
* @param b second function input value
* @return minimal value from the (a, b) pair
*/
public static DifferentialPair min(final DifferentialPair a,
final DifferentialPair b) {
return (a.getValue() <= b.getValue()) ? a : b;
}
}
| |
| File | Line |
|---|---|
| org\apache\commons\nabla\automatic\arithmetic\DDivTransformer12.java | 45 |
| org\apache\commons\nabla\automatic\arithmetic\DMulTransformer12.java | 45 |
private DMulTransformer12() {
}
/** Get the singleton instance.
* <p>We use here the Initialization on Demand Holder idiom.</p>
* @return the singleton instance
*/
public static InstructionsTransformer getInstance() {
return LazyHolder.INSTANCE;
}
/** {@inheritDoc} */
public InsnList getReplacement(final AbstractInsnNode insn,
final MethodDifferentiator methodDifferentiator)
throws DifferentiationException {
final int tmp1 = methodDifferentiator.getTmp(1);
final int tmp2 = methodDifferentiator.getTmp(2);
final int tmp3 = methodDifferentiator.getTmp(3);
final InsnList list = new InsnList();
// operand stack initial state: a0, a1, b0, b1
list.add(new VarInsnNode(Opcodes.DSTORE, tmp1)); // => a0, a1, b0
list.add(new InsnNode(Opcodes.DUP2)); // => a0, a1, b0, b0
list.add(new VarInsnNode(Opcodes.DSTORE, tmp2)); // => a0, a1, b0
list.add(new InsnNode(Opcodes.DMUL)); // => a0, a1*b0
list.add(new VarInsnNode(Opcodes.DSTORE, tmp3)); // => a0
list.add(new InsnNode(Opcodes.DUP2)); // => a0, a0
list.add(new VarInsnNode(Opcodes.DLOAD, tmp1)); // => a0, a0, b1
list.add(new InsnNode(Opcodes.DMUL)); // => a0, a0*b1
list.add(new VarInsnNode(Opcodes.DLOAD, tmp3)); // => a0, a0*b1, a1*b0
| |
| File | Line |
|---|---|
| org\apache\commons\nabla\automatic\functions\AcosTransformer.java | 28 |
| org\apache\commons\nabla\automatic\functions\AsinTransformer.java | 27 |
public class AsinTransformer implements MathInvocationTransformer {
/** {@inheritDoc} */
public InsnList getReplacementList(final String owner, final MethodDifferentiator methodDifferentiator) {
// generate differential code
// ... u0, u1 --> ... asin(u0), u1 / sqrt(1 - u0 * u0)
final InsnList list = new InsnList();
list.add(new InsnNode(Opcodes.DUP2_X2));
list.add(new InsnNode(Opcodes.POP2));
list.add(new InsnNode(Opcodes.DUP2_X2));
list.add(new InsnNode(Opcodes.DUP2));
list.add(new InsnNode(Opcodes.DMUL));
list.add(new InsnNode(Opcodes.DCONST_1));
list.add(new InsnNode(Opcodes.DSUB));
list.add(new InsnNode(Opcodes.DNEG));
list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, owner, "sqrt", D_RETURN_D_DESCRIPTOR));
list.add(new InsnNode(Opcodes.DDIV));
list.add(new InsnNode(Opcodes.DUP2_X2));
| |
| File | Line |
|---|---|
| org\apache\commons\nabla\automatic\arithmetic\DRemTransformer12.java | 58 |
| org\apache\commons\nabla\automatic\functions\HypotTransformer12.java | 32 |
public InsnList getReplacementList(final String owner, final MethodDifferentiator methodDifferentiator)
throws DifferentiationException {
final int tmp1 = methodDifferentiator.getTmp(1);
final int tmp2 = methodDifferentiator.getTmp(2);
final int tmp3 = methodDifferentiator.getTmp(3);
final int tmp4 = methodDifferentiator.getTmp(4);
// generate differential code
// ... x0, x1, y0, y1 --> ... hypot(x0,y0), (x0*x1+y0*y1)/hypot(x0,y0)
final InsnList list = new InsnList();
list.add(new VarInsnNode(Opcodes.DSTORE, tmp1)); // => x0, x1, y0
list.add(new VarInsnNode(Opcodes.DSTORE, tmp2)); // => x0, x1
list.add(new VarInsnNode(Opcodes.DSTORE, tmp3)); // => x0
list.add(new VarInsnNode(Opcodes.DSTORE, tmp4)); // =>
list.add(new VarInsnNode(Opcodes.DLOAD, tmp4)); // => x0
list.add(new VarInsnNode(Opcodes.DLOAD, tmp2)); // => x0, y0
list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, owner, "hypot", DD_RETURN_D_DESCRIPTOR)); // => hypot(x0,y0)
| |
| File | Line |
|---|---|
| org\apache\commons\nabla\differences\EightPointsScheme.java | 40 |
| org\apache\commons\nabla\differences\SixPointsScheme.java | 40 |
denominator = 60 * h;
}
/** {@inheritDoc} */
public UnivariateDerivative differentiate(final UnivariateDifferentiable d) {
return new UnivariateDerivative() {
public UnivariateDifferentiable getPrimitive() {
return d;
}
public DifferentialPair f(final DifferentialPair t) {
final double h = getStepSize();
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);
| |
| File | Line |
|---|---|
| org\apache\commons\nabla\automatic\functions\AcosTransformer.java | 28 |
| org\apache\commons\nabla\automatic\functions\AtanhTransformer.java | 31 |
public class AtanhTransformer implements MathInvocationTransformer {
/** {@inheritDoc} */
public InsnList getReplacementList(final String owner, final MethodDifferentiator methodDifferentiator) {
// generate differential code
// ... u0, u1 --> ... atanh(u0), u1 / (1 - u0 * u0)
final InsnList list = new InsnList();
list.add(new InsnNode(Opcodes.DUP2_X2));
list.add(new InsnNode(Opcodes.POP2));
list.add(new InsnNode(Opcodes.DUP2_X2));
list.add(new InsnNode(Opcodes.DUP2));
list.add(new InsnNode(Opcodes.DMUL));
list.add(new InsnNode(Opcodes.DCONST_1));
list.add(new InsnNode(Opcodes.DSUB));
list.add(new InsnNode(Opcodes.DNEG));
list.add(new InsnNode(Opcodes.DDIV));
| |
| File | Line |
|---|---|
| org\apache\commons\nabla\automatic\arithmetic\DRemTransformer2.java | 46 |
| org\apache\commons\nabla\automatic\instructions\Dup2X2Transformer12.java | 42 |
private Dup2X2Transformer12() {
}
/** Get the singleton instance.
* <p>We use here the Initialization on Demand Holder idiom.</p>
* @return the singleton instance
*/
public static InstructionsTransformer getInstance() {
return LazyHolder.INSTANCE;
}
/** {@inheritDoc} */
public InsnList getReplacement(final AbstractInsnNode insn,
final MethodDifferentiator methodDifferentiator)
throws DifferentiationException {
final int tmp1 = methodDifferentiator.getTmp(1);
final int tmp2 = methodDifferentiator.getTmp(2);
final int tmp3 = methodDifferentiator.getTmp(3);
final InsnList list = new InsnList();
// operand stack initial state: a0, a1, b0, b1
list.add(new VarInsnNode(Opcodes.DSTORE, tmp1)); // => a0, a1, b0
list.add(new VarInsnNode(Opcodes.DSTORE, tmp2)); // => a0, a1
list.add(new VarInsnNode(Opcodes.DSTORE, tmp3)); // => a0
list.add(new VarInsnNode(Opcodes.DLOAD, tmp2)); // => a0, b0
| |
| File | Line |
|---|---|
| org\apache\commons\nabla\automatic\functions\Atan2Transformer1.java | 43 |
| org\apache\commons\nabla\automatic\functions\Atan2Transformer2.java | 41 |
final InsnList list = new InsnList();
list.add(new VarInsnNode(Opcodes.DSTORE, tmp3)); // => y, x0
list.add(new VarInsnNode(Opcodes.DSTORE, tmp2)); // => y
list.add(new VarInsnNode(Opcodes.DSTORE, tmp1)); // =>
list.add(new VarInsnNode(Opcodes.DLOAD, tmp1)); // => y
list.add(new VarInsnNode(Opcodes.DLOAD, tmp2)); // => y, x0
list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, owner, "atan2", DD_RETURN_D_DESCRIPTOR)); // => atan2(y,x0)
list.add(new VarInsnNode(Opcodes.DLOAD, tmp3)); // => atan2(y,x0), x1
list.add(new VarInsnNode(Opcodes.DLOAD, tmp1)); // => atan2(y,x0), x1, y
| |
| File | Line |
|---|---|
| org\apache\commons\nabla\automatic\functions\AsinhTransformer.java | 31 |
| org\apache\commons\nabla\automatic\functions\AtanTransformer.java | 27 |
public class AtanTransformer implements MathInvocationTransformer {
/** {@inheritDoc} */
public InsnList getReplacementList(final String owner, final MethodDifferentiator methodDifferentiator) {
// generate differential code
// ... u0, u1 --> ... atan(u0), u1 / (1 + u0 * u0)
final InsnList list = new InsnList();
list.add(new InsnNode(Opcodes.DUP2_X2));
list.add(new InsnNode(Opcodes.POP2));
list.add(new InsnNode(Opcodes.DUP2_X2));
list.add(new InsnNode(Opcodes.DUP2));
list.add(new InsnNode(Opcodes.DMUL));
list.add(new InsnNode(Opcodes.DCONST_1));
list.add(new InsnNode(Opcodes.DADD));
list.add(new InsnNode(Opcodes.DDIV));
| |
| File | Line |
|---|---|
| org\apache\commons\nabla\automatic\functions\AcoshTransformer.java | 31 |
| org\apache\commons\nabla\automatic\functions\AcosTransformer.java | 28 |
public class AcosTransformer implements MathInvocationTransformer {
/** {@inheritDoc} */
public InsnList getReplacementList(final String owner, final MethodDifferentiator methodDifferentiator) {
// generate differential code
// ... u0, u1 --> ... acos(u0), -u1 / sqrt(1 - u0 * u0)
final InsnList list = new InsnList();
list.add(new InsnNode(Opcodes.DUP2_X2));
list.add(new InsnNode(Opcodes.POP2));
list.add(new InsnNode(Opcodes.DUP2_X2));
list.add(new InsnNode(Opcodes.DUP2));
list.add(new InsnNode(Opcodes.DMUL));
list.add(new InsnNode(Opcodes.DCONST_1));
list.add(new InsnNode(Opcodes.DSUB));
list.add(new InsnNode(Opcodes.DNEG));
| |
| File | Line |
|---|---|
| org\apache\commons\nabla\automatic\arithmetic\DAddTransformer12.java | 45 |
| org\apache\commons\nabla\automatic\arithmetic\DSubTransformer12.java | 45 |
private DSubTransformer12() {
}
/** Get the singleton instance.
* <p>We use here the Initialization on Demand Holder idiom.</p>
* @return the singleton instance
*/
public static InstructionsTransformer getInstance() {
return LazyHolder.INSTANCE;
}
/** {@inheritDoc} */
public InsnList getReplacement(final AbstractInsnNode insn,
final MethodDifferentiator methodDifferentiator)
throws DifferentiationException {
final int tmp = methodDifferentiator.getTmp(1);
final InsnList list = new InsnList();
// operand stack initial state: a0, a1, b0, b1
list.add(new VarInsnNode(Opcodes.DSTORE, tmp)); // => a0, a1, b0
list.add(new InsnNode(Opcodes.DUP2_X2)); // => a0, b0, a1, b0
list.add(new InsnNode(Opcodes.POP2)); // => a0, b0, a1
list.add(new VarInsnNode(Opcodes.DLOAD, tmp)); // => a0, b0, a1, b1
list.add(new InsnNode(Opcodes.DSUB)); // => a0, b0, a1-b1
| |
| File | Line |
|---|---|
| org\apache\commons\nabla\differences\EightPointsScheme.java | 40 |
| org\apache\commons\nabla\differences\FourPointsScheme.java | 40 |
denominator = 12 * h;
}
/** {@inheritDoc} */
public UnivariateDerivative differentiate(final UnivariateDifferentiable d) {
return new UnivariateDerivative() {
public UnivariateDifferentiable getPrimitive() {
return d;
}
public DifferentialPair f(final DifferentialPair t) {
final double h = getStepSize();
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);
| |
| File | Line |
|---|---|
| org\apache\commons\nabla\automatic\arithmetic\DDivTransformer2.java | 45 |
| org\apache\commons\nabla\automatic\instructions\Dup2X1Transformer.java | 42 |
private Dup2X2Transformer2() {
}
/** Get the singleton instance.
* <p>We use here the Initialization on Demand Holder idiom.</p>
* @return the singleton instance
*/
public static InstructionsTransformer getInstance() {
return LazyHolder.INSTANCE;
}
/** {@inheritDoc} */
public InsnList getReplacement(final AbstractInsnNode insn,
final MethodDifferentiator methodDifferentiator)
throws DifferentiationException {
final int tmp1 = methodDifferentiator.getTmp(1);
final int tmp2 = methodDifferentiator.getTmp(2);
final InsnList list = new InsnList();
// operand stack initial state: w, a0, a1
list.add(new VarInsnNode(Opcodes.DSTORE, tmp1)); // => w, a0
list.add(new InsnNode(Opcodes.DUP2)); // => w, a0, a0
list.add(new VarInsnNode(Opcodes.DSTORE, tmp2)); // => w, a0
list.add(new InsnNode(Opcodes.DUP2_X2)); // => a0, w, a0
| |
| File | Line |
|---|---|
| org\apache\commons\nabla\automatic\functions\Atan2Transformer1.java | 50 |
| org\apache\commons\nabla\automatic\functions\Atan2Transformer2.java | 51 |
list.add(new InsnNode(Opcodes.DNEG)); // => atan2(y,x0), -x1*y
list.add(new VarInsnNode(Opcodes.DLOAD, tmp2)); // => atan2(y,x0), -x1*y, x0
list.add(new InsnNode(Opcodes.DUP2)); // => atan2(y,x0), -x1*y, x0, x0
list.add(new InsnNode(Opcodes.DMUL)); // => atan2(y,x0), -x1*y, x0^2
list.add(new VarInsnNode(Opcodes.DLOAD, tmp1)); // => atan2(y,x0), -x1*y, x0^2, y
list.add(new InsnNode(Opcodes.DUP2)); // => atan2(y,x0), -x1*y, x0^2, y, y
list.add(new InsnNode(Opcodes.DMUL)); // => atan2(y,x0), -x1*y, x0^2, y^2
list.add(new InsnNode(Opcodes.DADD)); // => atan2(y,x0), -x1*y, x0^2+y^2
list.add(new InsnNode(Opcodes.DDIV)); // => atan2(y,x0), -x1*y/(x0^2+y^2)
return list;
}
}
| |
| File | Line |
|---|---|
| org\apache\commons\nabla\automatic\functions\AcoshTransformer.java | 31 |
| org\apache\commons\nabla\automatic\functions\AsinhTransformer.java | 31 |
public class AsinhTransformer implements MathInvocationTransformer {
/** {@inheritDoc} */
public InsnList getReplacementList(final String owner, final MethodDifferentiator methodDifferentiator) {
// generate differential code
// ... u0, u1 --> ... asinh(u0), u1 / sqrt(u0 * u0 + 1)
final InsnList list = new InsnList();
list.add(new InsnNode(Opcodes.DUP2_X2));
list.add(new InsnNode(Opcodes.POP2));
list.add(new InsnNode(Opcodes.DUP2_X2));
list.add(new InsnNode(Opcodes.DUP2));
list.add(new InsnNode(Opcodes.DMUL));
list.add(new InsnNode(Opcodes.DCONST_1));
list.add(new InsnNode(Opcodes.DADD));
| |