Agar Logo

Agar 1.7 Manual

(Printable Version)
M_Complex(3)

SYNOPSIS

#include <agar/core.h>
#include <agar/gui.h>
#include <agar/math/m.h>

DESCRIPTION

ScreenshotThe M_Complex object describes a complex number (without requiring an ISO C90 compiler). It is a simple structure defined as:
typedef struct m_complex {
	M_Real r;    /* Real part */
	M_Real i;    /* "Imaginary" part */
} M_Complex;

INITIALIZATION


M_Complex M_ComplexGet (M_Real r, M_Real i)

M_Complex M_ReadComplex (AG_DataSource *ds)

void M_CopyComplex (AG_DataSource *ds, M_Complex *z)

void M_WriteComplex (AG_DataSource *ds, M_Complex z)


The M_ComplexGet() routine returns a M_Complex structure describing a complex number with real part r and imaginary part i.

M_ComplexI() returns the complex number for i. M_ComplexMinusI() returns the complex number for -i.

The M_ReadComplex() function reads a complex number from an AG_DataSource(3) and returns it. M_CopyComplex() returns the number in z. M_WriteComplex() writes a complex number to a data source.

BASIC OPERATIONS


M_Real M_ComplexReal (M_Complex z)

M_Real M_ComplexImag (M_Complex z)

M_Real M_ComplexModulus (M_Complex z)

M_Real M_ComplexArg (M_Complex z)

M_Complex M_ComplexAdditiveInverse (M_Complex z)

M_Complex M_ComplexMultiplicativeInverse (M_Complex z)

void M_ComplexPolar (M_Complex z, M_Real *r, M_Real *theta)


The M_ComplexReal() routine extracts and return the real part of complex number z. M_ComplexImag() returns the imaginary part.

M_ComplexModulus() returns the modulus of z, which is computed as sqrt(r^2 + i^2). M_ComplexArg() returns the argument of z, computed as atan2(i,r);

M_ComplexAdditiveInverse() returns the additive inverse of z.

M_ComplexMultiplicativeInverse() returns the multiplicative inverse of z.

M_ComplexPolar() returns the polar form of z into r (corresponding to the modulus) and theta (corresponding to the argument).

ARITHMETIC OPERATIONS


M_Complex M_ComplexAdd (M_Complex a, M_Complex b)

M_Complex M_ComplexSub (M_Complex a, M_Complex b)

M_Complex M_ComplexMult (M_Complex a, M_Complex b)

M_Complex M_ComplexDiv (M_Complex a, M_Complex b)

M_Real M_ComplexAbs (M_Complex z)


The M_ComplexAdd() routine returns the sum of complex numbers a and b. M_ComplexSub() returns the difference.

M_ComplexMult() computes the product of complex numbers a and b. M_ComplexDiv() divides a by b and returns the result.

The M_ComplexAbs() function computes the complex absolute value (i.e., sqrt(r^2 + i^2)). If the magnitude of either real or imaginary parts differs with zero up to 50% of machine precision, both parts are rescaled prior to squaring.

M_ComplexSqrt() computes the complex square root of z.

M_ComplexLog() computes the complex natural logarithm of z.

M_ComplexExp() computes the exponential of z.

M_ComplexPow() returns a raised to the complex power z.

TRIGONOMETRIC AND HYPERBOLIC OPERATIONS


M_Complex M_ComplexSin (M_Complex z)

M_Complex M_ComplexCos (M_Complex z)

M_Complex M_ComplexTan (M_Complex z)

M_Complex M_ComplexCot (M_Complex z)

M_Complex M_ComplexAsin (M_Complex z)

M_Complex M_ComplexAcos (M_Complex z)

M_Complex M_ComplexAtan (M_Complex z)

M_Complex M_ComplexSinh (M_Complex z)

M_Complex M_ComplexAsinh (M_Complex z)

M_Complex M_ComplexCosh (M_Complex z)

M_Complex M_ComplexAcosh (M_Complex z)

M_Complex M_ComplexTanh (M_Complex z)

M_Complex M_ComplexAtanh (M_Complex z)


The M_ComplexSin() function returns the complex sine of z. M_ComplexCos() returns the complex cosine, M_ComplexTan() returns the complex tangent and M_ComplexCot() returns the complex cotangent.

M_ComplexAsin(), M_ComplexAcos() and M_ComplexAtan() compute the complex arc sine, arc cosine and arc tangent of z, respectively.

M_ComplexSinh(), M_ComplexAsinh(), M_ComplexCosh(), M_ComplexAcosh(), M_ComplexTanh(), M_ComplexAtanh() compute the complex hyperbolic sine, arc sine, cosine, arc cosine, tangent and arc tangent of z, respectively.

SEE ALSO


HISTORY

The M_Complex structure first appeared in Agar 1.3.4.

Csoft.net ElectronTubeStore