#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);
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.
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| )) < fracholds.
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.