[phobos] Is anyone working on std.complex?

Andrei Alexandrescu andrei at erdani.com
Thu Mar 25 18:51:30 PDT 2010


Sounds good to me.

Walter, what steps do we need to take to extricate complex from the 
language and put the related code in the stdlib with Don's help?


Thanks,

Andrei

On 03/25/2010 08:34 PM, Don Clugston wrote:
> On 25 March 2010 22:54, Andrei Alexandrescu<andrei at erdani.com>  wrote:
>> Good call! Walter mentioned he should transfer some knowledge to Don in the
>> matter. Walter, please let us know how we can plan this.
>>
>> Don suggested that the polar representation is very seldom used so we may as
>> well throw it away.
>
> That's not the direct reason. The issue is that it's difficult to do
> polar representation in a way which preserves numerically desirable
> properties. For instance, the invariant   if (x==x) assert( x == -
> (-x)); MUST be preserved, but isn't true for a naive polar
> representation. This rules out the use of floating point for the arg
> -- you probably want to use some form of fixed point. Then you have
> the problem that PI isn't exactly representable as a floating-point
> number. And it's downhill from there.
> And this is the reason why polar representation is seldom used -- it's
> virtually always a bad idea.
> Generally speaking the best way of doing polar representation is to
> put a wrapper over a cartesian complex type!
>
>> I like it because it illustrates how library is more
>> flexible than built-in...
>
> More convincing I think will be when we have things like BigFloat
> implemented, and can do complex!(BigFloat).
>
>
>>
>>
>> Andrei
>>
>> On 03/25/2010 04:03 PM, Lars Tandle Kyllingstad wrote:
>>>
>>> Is anyone working, or planning to do work, on std.complex?  If not, and
>>> if it is desirable, I could take a look at it. I guess the main thing
>>> that is needed is to add overloaded operators. Is there anything else?
>>>
>>> Also, I wonder: How do you feel about renaming "modulus" and "angle" to
>>> "mod" and "arg"? I seldom hear or use the term "angle" in relation to
>>> complex numbers. "Argument" and "phase" are much more common, and the
>>> standard mathematical notation for the argument of a complex number is
>>> Arg(z). Also, "mod" and "arg" are nice and short, like "re" and "im".
>>>
>>> -Lars
>>>
>>>
>> _______________________________________________
>> phobos mailing list
>> phobos at puremagic.com
>> http://lists.puremagic.com/mailman/listinfo/phobos
>>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos


More information about the phobos mailing list