File |
Line |
org/apache/commons/numbers/core/Norm.java |
289 |
org/apache/commons/numbers/core/Norm.java |
348 |
}
// compute the scale and rescale values
final double scale;
final double rescale;
if (max > LARGE_THRESH) {
scale = SCALE_DOWN;
rescale = SCALE_UP;
} else if (max < SAFE_SCALE_UP_THRESH) {
scale = SCALE_UP;
rescale = SCALE_DOWN;
} else {
scale = 1d;
rescale = 1d;
}
// initialise sum and compensation using scaled x
final double sx = xabs * scale;
double sum = sx * sx;
double comp = DD.twoSquareLow(sx, sum);
// add scaled y
final double sy = yabs * scale;
final double py = sy * sy;
comp += DD.twoSquareLow(sy, py);
final double sumPy = sum + py;
comp += DD.twoSumLow(sum, py, sumPy);
sum = sumPy; |