std.complex
Lars T. Kyllingstad
public at kyllingen.net
Wed Jan 1 15:12:31 PST 2014
On Wednesday, 1 January 2014 at 12:29:35 UTC, Stewart Gordon
wrote:
> [...]
>
> Or even more exotically, use Complex!(Complex!real) to
> implement hypercomplex numbers.
This is an extremely marginal use case. Currently
Complex!(Complex!T) folds to Complex!T. I thought this was
specified in the module documentation, but if it was, it's been
removed. It is explained in a comment in the source code, though:
/* 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:
---
Complex!T addI(T)(T x)
{
return x + Complex!T(0.0, 1.0);
}
---
The above will work if T is both real and complex.
*/
template Complex(T) if (is(T R == Complex!R))
{
alias T Complex;
}
More information about the Digitalmars-d
mailing list