You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Gilles Sadowski <gi...@harfang.homelinux.org> on 2010/11/01 03:11:32 UTC

Re: [Math] PolynomialFunctionLagrangeForm (continued)

On Sun, Oct 31, 2010 at 01:46:07PM -0700, Ted Dunning wrote:
> This seems like asking for trouble.
> 
> Usually interpolation requires O(n) work since lots of points are going to
> be interpolated.  Adding the O(n) task of checking for sorted data
> to the constructor seems like a better idea than adding a flag.  The O(n log
> n) cost of sorting would only be triggered if it is needed
> anyway so that isn't a real cost.
> 
> On Sun, Oct 31, 2010 at 10:05 AM, Luc Maisonobe <Lu...@free.fr>wrote:
> 
> > Perhaps we could add a boolean parameter isAlreadySorted or needSorting
> > to the constructor and perform the sort only when needed ?

I also think that we should not trust such a parameter ;-)
If its value is wrong (i.e. contradicts the actual state of the array), we
would not know (no precondition check) until some later calculation would
crash.

I think that for now the simplest is to assume that the array is sorted (and
check it as a precondition).
Then, at some point, we can add an independent utility function for sorting
an array while maintaining another in sync.  It would thus be the
responsibility of the user to call this utility beforehand.

Alternatively we could call this utility function from within the
constructor (and in the "evaluate" method), in all cases, in order to make
sure that the array is sorted.  But that has the disadvantage that in some
(most?) cases it will perform a useless sort on an already sorted array.


Gilles

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [Math] PolynomialFunctionLagrangeForm (continued)

Posted by Ted Dunning <te...@gmail.com>.
Not really.

It can check first.  That doesn't take long.

On Sun, Oct 31, 2010 at 7:11 PM, Gilles Sadowski <
gilles@harfang.homelinux.org> wrote:

> Alternatively we could call this utility function from within the
> constructor (and in the "evaluate" method), in all cases, in order to make
> sure that the array is sorted.  But that has the disadvantage that in some
> (most?) cases it will perform a useless sort on an already sorted array.
>