std.complex

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Mon Nov 25 00:18:30 PST 2013


On 25/11/13 00:35, Andrei Alexandrescu wrote:
> How many special cases are out there?

Well, if you have two complex numbers, z1 and z2, then

    (z1 * z2).re = (z1.re * z2.re) - (z1.im * z2.im)

and

    (z1 * z2).im = (z1.im * z2.re) + (z2.re * z1.im)

So you have to do if's for all four of z1.im, z2.re, z2.re and z1.im, and then 
you have to decide whether you override the apparent IEEE default just for the 
case of (re * im) or whether you do it for everything.

I mean, it feels a bit weird if you allow 0 * inf = 0 when it's real part times 
imaginary part, but not when it's real part times real part.

Do the IEEE standards cover implementation of complex numbers?  I confess 
complete ignorance here (and the Wikipedia page wasn't any help).

> It sort of does. If you multiply something that goes to 0 with something that
> goes to infinity it could go either way.

I'm not sure I follow.  I mean, if you have two sequences {x_i} --> 0 and {y_i} 
--> inf, then sure, the sequence of the product {x_i * y_i} can go either way. 
But if you just think of 0 as a number, then

      0 * inf = 0 * lim{x --> inf} x
              = lim{x --> inf} (0 * x)
              = lim{x --> inf} 0
              = 0

Or am I missing something about how FP numbers are implemented that either makes 
it convenient to define 0 * inf as not-a-number or that means that there are 
ambiguities that don't exist for "real" real numbers?


More information about the Digitalmars-d mailing list