[SciPy-user] Syntax for assigning to a complex matrix via weave?
Fernando Perez
fperez at colorado.edu
Wed May 14 16:09:24 EDT 2003
eric jones wrote:
>>From the paper that discusses a superior complex<T> implementation:
>
> """
> <talks about implementation>
> This proposal is already implemented and used in the GNU
> Implementation of the C++ standard library.
> """
>
> I guess we could simply use this implementation in weave. The only
> issue is that it is GPLed and so it can't just be dropped into the
> distrbution. A second option is just to overload the real() and imag()
> methods to return T& instead of T in a weave specific implementation of
> complex. Thoughts? Is it really worth breaking with the standard
> interface?
I'd say -0.5. Breaking standards is in most cases a road I'd rather not
travel, if nothing else because of how it can cause subtle problems in the
future. This seems to be under discussion by the C++ standards people, so it
might be worth chiming in with a voice pushing for a sane solution in the
standard itself.
On the other hand, the current situation is ugly enough that having a sane
syntax which allows one to simply do:
complex_array(i,j,k).real() = something;
complex_array(i,j,k).imag() = something_else;
would definitely be nice (even better if the parens weren't necessary, but
that's _really_ breaking the standard).
I can't understand why they didn't settle on complex numbers being by default
equivalent to struct { <type> real; <type> imag; }. This would address a
large majority of the usage cases, enable interoperability with every
Fortran/C code out there, and one could always write a PolarComplex class for
the situations where a native polar representation is truly necessary.
Oh well...
Cheers,
f.
More information about the SciPy-User
mailing list