complexSP - a complex numbers library

NAME

AddComplex, ArgComplex, ConsComplex, ConsModArgComplex, DivComplex, DupComplex, IsApproxEqualComplex, IsEqualComplex, ModComplex, ModSqrComplex, MulComplex, PowComplex, Real2Complex, ScalComplex, SqrComplex, SqrtComplex, SubComplex

SYNOPSIS

#include ''complexSP.h''

t_Complex ConsComplex(double re, double im);
t_Complex Real2Complex(double re);
t_Complex ConsModArgComplex(double mod, double arg);
t_Complex *DupComplex(t_Complex z1);

int IsEqualComplex(t_Complex z1, t_Complex z2);
int IsApproxEqualComplex(t_Complex z1, t_Complex z2, double frac);

t_Complex AddComplex(t_Complex z1, t_Complex z2);
t_Complex SubComplex(t_Complex z1, t_Complex z2);
t_Complex MulComplex(t_Complex z1, t_Complex z2);
t_Complex DivComplex(t_Complex z1, t_Complex z2);

t_Complex SqrComplex(t_Complex z1);
t_Complex SqrtComplex(t_Complex z1);
t_Complex PowComplex(t_Complex z1, double power);
t_Complex ScalComplex(t_Complex z1, double factor);

double ModComplex(t_Complex z1);
double ModSqrComplex(t_Complex z1);
double ArgComplex(t_Complex z1);

DESCRIPTION

Introduction

The 'complex' library provides a set of function for manipulating complex numbers. A complex number is represented by a structure:

typedef struct { double re, im; } t_Complex;

They two components are accessed directly:

t_Complex z; z.re = 10.0; z.im = 2.0;

Numbers are passed in and returned out of functions by value. Unless explicitly requested by the user (by a call to DupComplex), no dynamic memory is allocated.

Functions

ConsComplex(re, im) sets the two components of the number. Real2Complex(re) is identical to ConsComplex(re, 0.0), but neater. ConsModArgComplex(mod, arg) calculates the real and imaginary components of the number from the specified modulus and argument. DupComplex(z1) allocates space for a new number and copies its argument to this new space. The caller of the function is responsible for freeing the memory.

IsEqualComplex(z1, z2) returns true (a non-zero value) if the two complex numbers are EXACTLY identical. This function should not be used to compare the results of calculations - use IsApproxEqualComplex instead. IsApproxEqualComplex(z1, z2, frac) returns true (a non-zero value) if the inequality

(( |z1-z2| * |z1-z2| ) / ( |z1| * |z1| + |z2| * |z2| )) < frac
holds.

AddComplex(z1, z2), SubComplex(z1, z2), MulComplex(z1, z2) and DivComplex(z1, z2) return the (complex) result of adding, subtracting, multiplying and dividing their two arguments, respectively.

SqrComplex(z1) returns the square of its argument. SqrComplex(z1) returns the square root of its argument. PowComplex(z1, power) raises a complex number to a real power. ScalComplex(z1, factor) scales the complex number by a real factor.

ModComplex(z1) and ArgComplex(z1) return the modulus and argument of the complex number respectively. ModSqrComplex(z1) returns the squared modulus of its argument and is faster than ModComplex.

SEE ALSO

AUTHOR

Copyright (C) 1994 by Steve Procter.
06-May-97. Automatically converted by man2html, written by G.Matas (g.matas@ee.surrey.ac.uk)