octave-maintainers
[Top][All Lists]
Advanced

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

Re: Patch for erfinv.m


From: Alois Schloegl
Subject: Re: Patch for erfinv.m
Date: Wed, 23 Jan 2008 10:06:06 +0100
User-agent: Icedove 1.5.0.14pre (X11/20071018)

John W. Eaton wrote:
On 21-Jan-2008, Alois Schloegl wrote:

| >> Consider the following patch for erfinv.
| >>
| >> It (1) replaces z_old and z_new by a single variable z, and
| >> (2) makes the initial checks simpler.
| >>
| >> The code becomes leaner, and a bit faster.

I applied the patch but used

  ## x < 1 or x > 1 ==> NaN
  y(abs (x) >= 1) = NaN;

instead of

| +  y(~(abs(x) < 1)) = NaN;  %% x<1, x>1, x=NaN

Any reason not to make this change?

In the latter case, x=NaN is not properly handled.

The comment line should be

- ## x < 1 or x > 1 ==> NaN
+ ## x < 1 or x > 1 or isnan(x) ==> NaN

Either use the version of the patch, or add an extra check using isnan.
The solution in the patch is simpler, and perhaps faster, too.

Checking it again, I see that an even better solution is

- y(~(abs(x) < 1)) = NaN; + y(~(abs(x) <= 1)) = NaN; because no NaN should be assigned in case of abs(x)==1.
Alois

Thanks,

jwe



reply via email to

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