cpxd.sa
Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
-------------------------> GNU Sather - sourcefile <-------------------------
-- Copyright (C) 2000 by K Hopper, University of Waikato, New Zealand --
-- This file is part of the GNU Sather library. It is free software; you may --
-- redistribute and/or modify it under the terms of the GNU Library General --
-- Public License (LGPL) as published by the Free Software Foundation; --
-- either version 2 of the license, or (at your option) any later version. --
-- This library is distributed in the hope that it will be useful, but --
-- WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See Doc/LGPL for more details. --
-- The license text is also available from: Free Software Foundation, Inc., --
-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --
--------------> Please email comments to <bug-sather@gnu.org> <--------------
immutable class CPXD < $COMPLEX{FLTD, CPXD}, $FLT_FMT
immutable class CPXD < $COMPLEX{FLTD, CPXD}, $FLT_FMT is
-- This class implements the mathematical notion of a 'double length'
-- complex number within the constraints of the parameter type.
-- Some of the algorithms are taken from:
-- Press, Flannery, Teukolsky, and Vettering, "Numerical Recipes in C",
-- second edition, Cambridge University Press, 1993.
--
-- Some of the choices of branch cut were chosen to be consistent with:
-- Guy L. Steele, "Common Lisp, The Language", second edition,
-- 1990, Digital Press.
-- Version 1.2 Oct 98. Copyright K Hopper, U of Waikato
-- Development History
-- -------------------
-- Date Who By Detail
-- ---- ------ ------
-- 25 Aug 97 kh Original from Sather 1.1 Dist
-- 2 Oct 98 kh Factored out formatting - see CPX{?}
-- 18 Mar 01 djw Fixed bugs as for CPX
include CPX{FLTD,ANGLED} ;
create(
real,
imaginary : FLTD
) : SAME is
-- This routine creates a complex number with a real part `re' and
-- imaginary part `im'.
me : SAME ;
return me.re(real).im(imaginary)
end ;
log : CPXD
post self.is_similar(result.exp)
is
-- This routine returns the complex logarithm of self. The chosen
-- branch is
--
-- log |self| + i phase(self). See Steele p302.
phase : ANGLED := ANGLED::atan2(im,re) ;
magnitude : FLTD := (re * re + im * im).sqrt.log ;
return create(magnitude , phase.radians)
end ;
end ; -- CPXD