Fix DerivativeStructure.pow for 0 argument and power less than 1.
This commit is contained in:
parent
c64856ff7f
commit
540564e190
|
@ -893,6 +893,12 @@ public class DSCompiler {
|
|||
return;
|
||||
}
|
||||
|
||||
if (operand[operandOffset] == 0) {
|
||||
// special case, 0^p = 0 for all p
|
||||
Arrays.fill(result, resultOffset, resultOffset + getSize(), 0);
|
||||
return;
|
||||
}
|
||||
|
||||
// create the function value and derivatives
|
||||
// [x^p, px^(p-1), p(p-1)x^(p-2), ... ]
|
||||
double[] function = new double[1 + order];
|
||||
|
|
|
@ -345,6 +345,18 @@ public class DerivativeStructureTest extends ExtendedFieldElementAbstractTest<De
|
|||
Assert.assertEquals(0.0, d, Precision.SAFE_MIN);
|
||||
}
|
||||
}
|
||||
|
||||
// 0^p with p smaller than 1.0
|
||||
DerivativeStructure u = new DerivativeStructure(3, maxOrder, 1, -0.0).pow(0.25);
|
||||
for (int i0 = 0; i0 <= maxOrder; ++i0) {
|
||||
for (int i1 = 0; i1 <= maxOrder; ++i1) {
|
||||
for (int i2 = 0; i2 <= maxOrder; ++i2) {
|
||||
if (i0 + i1 + i2 <= maxOrder) {
|
||||
Assert.assertEquals(0.0, u.getPartialDerivative(i0, i1, i2), 1.0e-10);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue