[m-dev.] complex numbers

Fergus Henderson fjh at cs.mu.oz.au
Wed Jul 16 17:58:19 AEST 1997


Andrew Bromage, you wrote:
> 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 called it `abs2'.

> 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)).
> >>

Done, except I called it `conj' rather than `conjugate'.
(For consistency with the other short names used in this module:
arg[ument], imag[inary_part] real[_part], and sqrt [instead of square_root].
Mathematicians seem to prefer short names. :-)

-- 
Fergus Henderson <fjh at cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3         |     -- the last words of T. S. Garp.



More information about the developers mailing list