|
From: | Michael D Godfrey |
Subject: | Re: No isimag() curioso |
Date: | Sat, 08 Sep 2012 00:05:54 -0400 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120828 Thunderbird/15.0 |
On 09/07/2012 05:30 PM, Daniel J Sebald
wrote:
In working with the fftfilt() routine and wanting to know if the inputs were purely imaginary I wondered why there is no such thing as isimag(). It seems as though it would be as useful as or more useful than iscomplex().I also recently noticed some quirks with complex: x = 1 + 0i is treated as real and not complex. but x = 0 + 1i is treated as imag and complex. But, this is consistent with Matlab. However, Matlab has no iscomplex and also differs in its example for help isreal. There, Matlab gives an example: x = magic(3); y = complex(x); which gives: >> y y = 8 1 6 3 5 7 4 9 2 >> isreal(y) ans = 0 but, ~isreal(y) gives: ans = 1 The text in the help messages says that isreal(y) returns false, because COMPLEX returns y with an all zero imaginary part. ------------------------------------------- but Octave gives: y = 8 + 0i 1 + 0i 6 + 0i 3 + 0i 5 + 0i 7 + 0i 4 + 0i 9 + 0i 2 + 0i and: octave:21> isreal(y) ans = 0 and: octave:29> ~isreal(y) ans = 1 The only difference is in the display of y. This hardly qualifies as a bug, but does add a bit to the confusion. Some people would imagine that real and imaginary would be treated "symmetrically." So far I do not see much point in making a change. |
[Prev in Thread] | Current Thread | [Next in Thread] |