[m-dev.] complex numbers

Andrew Bromage bromage at cs.mu.oz.au
Mon Jul 7 11:18:21 AEST 1997


G'day.

Fergus Henderson wrote:

> +	% norm (square of absolute value)
> +	% XXX is `norm' the right terminology?
> +:- func norm(complex) = float.

Uhm... no, it isn't.  But I don't know what it is.  Perhaps sqr_abs
is a better name?

I think it might be useful (for completeness) to provide the following
functions:

<<
:- func conjugate(complex) = complex.
:- mode conjugate(in) = out is det.

conjugate(cmplx(X, Y)) = cmplx(X, -Y).

:- func cis(float) = complex.
:- mode cis(in) = out is det.

	% cis(Theta) is a shorthand for polar_to_complex(1.0, Theta)
cis(Theta) = cmplx(cos(Theta), sin(Theta)).
>>

Cheers,
Andrew Bromage



More information about the developers mailing list