std.complex

Stewart Gordon smjg_1998 at yahoo.com
Thu Jan 2 10:19:33 PST 2014


On 01/01/2014 23:12, Lars T. Kyllingstad wrote:
<snip>
> /*  Makes Complex!(Complex!T) fold to Complex!T.
>
>      The rationale for this is that just like the real line is a
>      subspace of the complex plane, the complex plane is a subspace
>      of itself. Example of usage:

This doesn't seem to make sense - _any_ set is a subspace of itself.

But I suppose one way to look at it is that Complex!T means the minimal 
vector space containing x and i*x for all x in T.

>      ---
>      Complex!T addI(T)(T x)
>      {
>          return x + Complex!T(0.0, 1.0);
>      }
>      ---

So the point is to enable templated functions to accept a real or 
complex argument and return a complex number.

>      The above will work if T is both real and complex.
> */

T is "both real and complex"?  How is this possible?

Stewart.


More information about the Digitalmars-d mailing list