Follow-up Comment #20, bug #31974 (project octave):
It seems like this may result from the differences in complex number
representation in Matlab and in Octave? Matlab stores the real and imaginary
components separately whereas octave interleaves them.
If the components are stored separately, it would be trivial to get Matlab's
behavior based on the states of the pointers to the real and imaginary memory
chunks. i.e. NaN*j would create a complex number that only has memory for the
imaginary field allocated. In some cases when Matlab passes the value off to
the blas or whatever in some cases it will be forced to first allocate both
components of the complex value, losing the internal state and resulting in
identical behavior as octave.
So for the "1+Inf*j" Matlab could simply do "(1,unallocated)" +
"(unallocated,Inf)" by letting allocated fields simply replace unallocated
fields. This would work without a special parser rule and copy-on-write means
there is essentially no penalty for behaving this way.
Approaching this from the interleaved representation (used in octave) it's
more difficult because both the real and imaginary parts are allocated
simultaneously as a single region of memory that cannot be separated--i.e.
octave can't hide state inside allocation patterns.
One approach would be to add a state variable to the complex values that
labels the status of the (real,imaginary) components to obtain the semantics
of the separate real/imag representation. Another option would be to add a
pure-imaginary array similar to the pure-real arrays we already have.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?31974>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/