Skip to content

Commit

Permalink
refine
Browse files Browse the repository at this point in the history
  • Loading branch information
XenoAmess committed Jun 6, 2020
1 parent 4923674 commit 4eae5a2
Showing 1 changed file with 3 additions and 2 deletions.
Expand Up @@ -171,15 +171,16 @@ public DerivativeStructure value(final DerivativeStructure t)

// function value
final double f0 = f[0] = FastMath.log((x - lo) / (hi - x));
final int fLen = f.length;
if (Double.isInfinite(f0)) {
if (f.length > 1) {
if (fLen > 1) {
final double f1 = f[1] = Double.POSITIVE_INFINITY;
// fill the array with infinities
// (for x close to lo the signs will flip between -inf and +inf,
// for x close to hi the signs will always be +inf)
// this is probably overkill, since the call to compose at the end
// of the method will transform most infinities into NaN ...
for (int i = 2; i < f.length; ++i) {
for (int i = 2; i < fLen; ++i) {
f[i] = (i & 1) == 0 ? f0 : f1;
}
}
Expand Down

0 comments on commit 4eae5a2

Please sign in to comment.