[
https://issues.apache.org/jira/browse/NUMBERS-156?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17348653#comment-17348653
]
Alex Herbert commented on NUMBERS-156:
--------------------------------------
{quote}I still think that that it can be useful that an application is able to
switch implementations
{quote}
This could be done by programming to compute the norm using the
ToDoubleFunction interface:
{code:java}
java.util.function.ToDoubleFunction<double[]>
ToDoubleFunction<double[]> calc = Norms::norm;
double n = calc.applyAsDouble(new double[]{1, 2, 3});
{code}
Then you can pass the implementation as a lambda or method reference. Do you
wish to have something more formal with a concrete class to do the computation
with configurable implementation? For example:
{code:java}
public class NormCalculator {
public double norm(double[] x);
public void setImplementation( ... );
}
{code}
This effectively is just a wrapper around the implementation. So would some
standard implementations be provided, or just the one default implementation?
This is a similar prospect to NUMBERS-142 where a LinearCombination interface
was discussed (see [this
comment|https://issues.apache.org/jira/browse/NUMBERS-142?focusedCommentId=17020233&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-17020233]
(and the discussion around it)).
[~mattjuntunen]: The enormModExt is getting close to the performance of
extLinear at long lengths. It is only at short lengths that enormModExt does
better. This makes me think that it would be worth trying to modify the
extLinear method to bring its performance closer to enormModExt at short
lengths. You then would have a class implementing a 2-fold precision
dot-product on the scaled vector and the final square root. Since the extLinear
method does a single pass over the array to find the scale this means that all
the safety checks for overflow in the LinearCombination class can be dropped.
It can also drop some work done to split the terms as there is only one input
vector.
Would you like me to create a better extLinear implementation to try this?
> 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
> Attachments: performance-all.png, performance-len-1-5.png,
> performance2-1-5.png, performance2-all.png
>
>
> 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)