commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles Sadowski <gil...@harfang.homelinux.org>
Subject Re: [Math] PolynomialFunctionLagrangeForm (continued)
Date Mon, 01 Nov 2010 02:11:32 GMT
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 <Luc.Maisonobe@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


Mime
View raw message