[Top][All Lists]

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

[Octave-bug-tracker] [bug #32053] matlab/Octave differences for complex

From: John W. Eaton
Subject: [Octave-bug-tracker] [bug #32053] matlab/Octave differences for complex
Date: Wed, 05 Jan 2011 18:47:21 +0000
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20101028 Iceweasel/3.5.15 (like Firefox/3.5.15)

Follow-up Comment #3, bug #32053 (project octave):

"I understand that cc and cc(1) are real elements of
a complex array. But, they are allocated storage as if
they were complex (a good thing, of course). "

When you do

complex (1, 0)

you create a complex object (real and imaginary parts both allocated).  But
when you write cc(1), the result is subject to a narrowing conversion, so if
the imaginary part is zero, it is discarded and the result is real and the
imaginary part is no longer allocated.  That's what isreal is telling you,
since it tests whether the complex part is allocated, not whether the
imaginary part is zero.  Is that behavior different in Matlab?

The one strange thing is this part:

octave:26> zz(1) = complex(1,0*j)
zz = 1
octave:27> isreal(zz)
ans = 1 

but I think this happens because the narrowing conversion is applied on
assignment.  Is this behavior different in Matlab?

The only differences that I see are that Matlab doesn't print the zero
imaginary parts (something I don't think we should copy) and it shows
"complex" as an attributed in the output of whos.


Reply to this item at:


  Message sent via/by Savannah

reply via email to

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