Complex.mesa
Last edited by Michael Plass, January 4, 1984 11:53 am
Written by Michael Plass, 28-Sep-81
DIRECTORY
Real USING [SqRt],
Vector USING [Vec];
Complex: DEFINITIONS IMPORTS Real =
BEGIN
Add:
PROCEDURE [a: Vec, b: Vec]
RETURNS [Vec] =
INLINE
{RETURN[[a.x+b.x,a.y+b.y]]}; -- same as vector sum
Sub:
PROCEDURE [a: Vec, b: Vec]
RETURNS [Vec] =
INLINE
{RETURN[[a.x-b.x,a.y-b.y]]}; -- same as vector difference
Neg:
PROCEDURE [a: Vec]
RETURNS [Vec] =
INLINE
{RETURN[[-a.x,-a.y]]}; -- same as vector complement
Mul:
PROCEDURE [a: Vec, b: Vec]
RETURNS [Vec];
-- complex product
Div:
PROCEDURE [a: Vec, b: Vec]
RETURNS [Vec]
;
-- complex quotient
Conjugate:
PROCEDURE [a: Vec]
RETURNS [Vec] =
INLINE
{RETURN[[a.x,-a.y]]}; -- complex conjugate
AlmostEqual: PROCEDURE [a: Vec, b: Vec, mag:[-126..0] ← -20] RETURNS [BOOLEAN];
FromPolar:
PROCEDURE [r:
REAL, radians:
REAL]
RETURNS [Vec];
Abs:
PROCEDURE [a: Vec]
RETURNS [
REAL] =
INLINE
{RETURN[Real.SqRt[a.x*a.x+a.y*a.y]]}; -- same as Vector.Mag
SqrAbs:
PROCEDURE [a: Vec]
RETURNS [
REAL] =
INLINE
{RETURN[a.x*a.x+a.y*a.y]}; -- good for checking tolerance
Arg:
PROCEDURE [a: Vec]
RETURNS [
REAL];
returns the angle from the x axis to a, in radians.
Exp:
PROCEDURE [a: Vec]
RETURNS [Vec];
complex exponential function
Ln:
PROCEDURE [a: Vec]
RETURNS [Vec];
complex natural logarithm
Sqr:
PROCEDURE [a: Vec]
RETURNS [Vec];
-- like Mul[a,a]
SqRt:
PROCEDURE [a: Vec]
RETURNS [Vec];
-- complex square root
END.