octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #31974] Interpreter fails to create complex nu


From: John W. Eaton
Subject: [Octave-bug-tracker] [bug #31974] Interpreter fails to create complex numbers with Inf complex parts
Date: Wed, 05 Jan 2011 19:04:12 +0000
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.15) Gecko/20101028 Iceweasel/3.5.15 (like Firefox/3.5.15)

Follow-up Comment #21, bug #31974 (project octave):

Judd, I think that Matlab always allocates storage for the real part.  If you
have access to Matlab, try this mex file:


#include "mex.h"

void
mexFunction (int nlhs, mxArray* plhs[], int nrhs, 
             const mxArray* prhs[])
{
  double *pr = mxGetPr (prhs[0]);
  double *pi = mxGetPi (prhs[0]);

  if (pr)
    mexPrintf ("real part is allocated; its value is %gn", pr[0]);


  if (pi)
    mexPrintf ("imaginary part is allocated, its value is %gn", pi[0]);
}


and call it with


foo (i)
foo (1)
foo (complex (1, 0))


etc.  Can you come up with a way to make Matlab not allocate the real part of
a numeric value?  That would be interesting, because it would mean that
implemented pure imaginary values.  But I don't think they have done that. 
Instead, I think there are some limited number of places where values with
zero real parts are treated as if they are pure imaginary.  Unfortunately, I
think this special treatment also applies to computed values, not just ones
explicitly defined with the special values "i" or "j".  For example, what
happens with


x = 1 + i
y = -1 + i
z = x + y
Inf * z


Do you still see the special treatment of the zero imaginary part here, or do
you get NaN + Infi?

This topic of having a pure imaginary type has come up before.  If it is
really important to have this behavior for pure imaginary values, then I think
we need to have it consistently in Fortran, C++, C, etc., not just in some
portions of programs like Octave or Matlab.  Do we really want that kind of
inconsistent behavior?

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?31974>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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