octave-maintainers
[Top][All Lists]
Advanced

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

Re: unary mapper system redesigned + a few questions


From: John W. Eaton
Subject: Re: unary mapper system redesigned + a few questions
Date: Tue, 17 Nov 2009 07:54:14 -0500

On 13-Nov-2009, Jaroslav Hajek wrote:

| > So it seems you made this change so that 0*(-i) produces a 0 - 0i. I think
| > it's a good time to rethink this decision.
| > First, you probably overlooked the fact that 0 - 0i is constructible with
| > complex (0, -0) - because complex() is the (only) function that bypasses the
| > narrowing. So the primary motivation is not strong - these numbers *would
| > be* constructible, albeit less conveniently.

It's not only about the construction of -0 imaginary parts.  It's also
about preserving the result of a computation that generates a -0
imaginary part.

| > On the other hand, there are disadvantages:
| >
| > 1. It's not Matlab-compatible. Matlab seems to discard all zero imaginary
| > parts.

We do a number of other things that are not completely compatible.

| > 2. isreal produces confusing results (isreal (i*i) vs. isreal (-i*i)).
| > 3. When numbers like x-0i are excluded from simplifying, you want real-only
| > mappers (erf, gamma etc) to still work on them. Currently that requires each
| > real-only mapper to have a complex wrapper counterpart. That's cumbersome
| > and easy to forget when new mappers are added.
| > 4. a' * a is not always real if a is a complex scalar. On the contrary, if
| > a is a complex vector, the result *is* always real, as computed by BLAS.
| > Should we try to fix BLAS?

I'm still not convinced that we should discard -0 when it appears as
the imaginary part of a complex number but not -0 when it appears as a
real number.

I think the real problem here is that we have no pure imaginary type.

Perhaps instead of changing the narrowing operation so that it always
drops -0 imaginary parts we should have the negation operation for
complex (0, y) generate complex (0, -y) instead of (-0, -y).  If we
had a way of narrowing to pure imaginary, this is the result we would
get, isn't it?.  Then at least we would not thow away zero imaginary
parts in all cases (for example, something like (1+i)/(-inf)).  Or
would that cause more problems than it solves?

jwe


reply via email to

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