[
https://issues.apache.org/jira/browse/NUMBERS-156?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17344559#comment-17344559
]
Alex Herbert commented on NUMBERS-156:
--------------------------------------
{quote}I'm undecided on whether the extra overhead is worth it. What do you
think?
{quote}
On short vectors it does not seem so. This may be because we are summing only
positive numbers and so there will be no cancellation in the sum where
retaining the compensation (extra bits of the sum) is important.
How hard is it to expand the vectors to larger sizes, e.g. length 100? This
would show bigger differences between the methods.
Note that the Kahan summation method should add the compensation when summing
at the end. I did not do this. It may make a difference where the numbers
partially straddle the scaling thresholds. So the end of the method would be:
{code:java}
// The highest sum is the significant component. Add the next significant.
// Add the scaled compensation then the scaled sum.
if (s1 != 0) {
double y = c2 * 0x1.0p-600 * 0x1.0p-600 - c1;
final double t = s1 + y;
c1 = (t - s1) - y;
y = s2 * 0x1.0p-600 * 0x1.0p-600 - c1;
return Math.sqrt(t + y) * 0x1.0p600;
} else if (s2 != 0) {
double y = c3 * 0x1.0p-600 * 0x1.0p-600 - c2;
final double t = s2 + y;
c2 = (t - s2) - y;
y = s3 * 0x1.0p-600 * 0x1.0p-600 - c2;
return Math.sqrt(t + y);
}
{code}
> SafeNorm 3D overload
> --------------------
>
> Key: NUMBERS-156
> URL: https://issues.apache.org/jira/browse/NUMBERS-156
> Project: Commons Numbers
> Issue Type: Improvement
> Reporter: Matt Juntunen
> Priority: Major
>
> We should create an overload of {{SafeNorm.value}} that accepts 3 arguments
> to potentially improve performance for 3D vectors.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)