Complex number functions for std.math

Don Clugston dac at nospam.com.au
Thu Mar 30 11:21:26 PST 2006


Some time ago I wrote some complex number functions for std.math, but 
they were not really usable because of the implicit real->creal 
conversion issue. Now that that problem has been removed in DMD 0.150, 
several could be added.

There are a few issues to be addressed, though:
* The function cos(x) + I*sin(x), which on x86 machines is very 
efficient, and available through the FSINCOS asm instruction (the only 
CPU support for complex numbers!) is important for many of these 
functions, and it could usefully become an intrinsic.
What should it be called? Ideas I've had
creal exp(ireal x)  -- It's correct, but I don't think this 'feels' like
		      an intrinsic.
creal cis(real x)   -- namespace pollution could be an issue
creal cosisin(real x) -- doesn't this look a bit silly?
creal fcis(real x)  -- mirrors fabs(), this is what I put into Ares,
                     but is it too obscure?

* DDoc comments.
Should sin(creal) be with sin(real) ? Or should the complex trig 
functions be put together?




More information about the Digitalmars-d mailing list