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: Thu, 24 Jan 2008 11:08:35 +0100
User-agent: Icedove 1.5.0.14pre (X11/20071018)

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

| The test is on x and the assignment in y.

Doh, I was completely missing that detail.

| So the problem is
| x = [NaN, -2, -1, 0, 1, 2];
| y = zeros(size(x));
| y(abs (x) > 1) = NaN
| | y =
|      0   NaN     0     0     0   NaN
| | The is no NaN in y for the case of isnan(x). | | The yields the (incorrect) result
| erfinv(x)
| ans =
|      0   NaN  -Inf    -0   Inf   NaN
| | | The correct result should be | | ans =
|    NaN   NaN  -Inf    -0   Inf   NaN

OK, then how about

  ## x(i) < -1 or x(i) > 1 or isnan (x(i))  ==>  y(i) = NaN
  y(abs (x) > 1 | isnan (x)) = NaN;
  y(x == -1) = -Inf;
  y(x == +1) = +Inf;

Yes, this is working, too. That's also closer to the original test
 i = find ((x < -1) | (x > 1) | isnan(x));

Why do you prefer

  y(abs (x) > 1 | isnan (x)) = NaN;

to y(~(abs(x) <= 1)) = NaN;
?

Is it just the readability of the code, or do you expect some performance gain ?

Alois


Please reply on the list.

Thanks,

jwe



reply via email to

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