octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: small bug fix in ppval


From: Shai Ayal
Subject: Re: small bug fix in ppval
Date: Fri, 25 Apr 2008 11:07:46 +0300

On Fri, Apr 25, 2008 at 10:44 AM, Jaroslav Hajek <address@hidden> wrote:
> Shai,
>
>  the "l" and "r" options for lookup should be documented in new
>  lookup's inline documentation (via `help lookup'). If it is not clear,
>  blame me (and please report what is broken). Shortly, "l" means extend
>  the leftmost interval to infinity, while "r" means the same for the
>  rightmost interval. Thus, "lr" is frequently used to get indices that
>  are guaranteed to fall inside the table (provided that the table is at
>  least 2 elements long).
>
>  The common expression with the old lookup was to use
>  lookup(x(2:end-1), y)+1. This is dangerous, as it breaks for
>  decreasing tables of length 3
>  (see http://www.nabble.com/binary-lookup-tt16029897.html#a16089657)
>
>  I'm not sure whether this case can occur here, I've replaced all the
>  lookup(x(2:end-1)) expressions I could find since the new form is also
>  faster (no temporary arrays).
>


Hmm...

Maybe this change was not propagated to the dev branch? I'm using the
latest octave graphics release and it was merged with the main octave
repository at Apr 22.

what I'm seeing in my lookup.m:
function idx = lookup (table, xi)

so this is clearly to old version

Shai


>
>
>
>  On Fri, Apr 25, 2008 at 9:17 AM, Shai Ayal <address@hidden> wrote:
>  > this is a trivial on-liner. I think lookup was changed recently. Since
>  >  I don't know the meaning of the "lr" parameter to lookup I tried to
>  >  guess.
>  >  This show up in making the doc/interpreter/interpderiv2.eps figure. It
>  >  looks right to me with the fix, but please double-check.
>  >
>  >  Shai
>  >
>  >
>  >  diff --git a/scripts/polynomial/ppval.m b/scripts/polynomial/ppval.m
>  >  --- a/scripts/polynomial/ppval.m
>  >  +++ b/scripts/polynomial/ppval.m
>  >  @@ -39,7 +39,7 @@ function yi = ppval (pp, xi)
>  >      transposed = (columns (xi) == 1);
>  >      xi = xi(:);
>  >      xn = length (xi);
>  >  -    idx = lookup (pp.x, xi, "lr");
>  >  +    idx = lookup (pp.x(2:end-1), xi)+1;
>  >      dx = (xi - pp.x(idx)).';
>  >      dx = reshape (dx(ones(1,prod(pp.d)),:),[pp.d,xn]);
>  >      c = reshape (pp.P(:,1), pp.n, prod (pp.d));
>  >
>
>
>
>  --
>  RNDr. Jaroslav Hajek
>  computing expert
>  Aeronautical Research and Test Institute (VZLU)
>  Prague, Czech Republic
>  url: www.highegg.matfyz.cz
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]