Skip to content

Complex API

Markdown

The complex number API serves as a replacement for C and C++'s <complex.h>, offering fast, accelerated approximations for each routine. The API is mostly modeled after C99's <complex.h>, although it also supports being used from C++ via shz::complex. The API also features shz_fft(), an SH4 optimized fast-fourier transform.

  • C header: #include <sh4zam/shz_complex.h>
  • C++ header: #include <sh4zam/shz_complex.hpp>
  • C++ types: shz::complex
  • Symbols: 52

Suffixes used in this module. The full list is in Naming and Suffixes.

  • _fsrra: Uses FSRRA (fast approximate 1/sqrt(x)). The argument or denominator must be positive. Faster, less precise.

Macros and preprocessor constants.

SymbolDescription
SHZ_CMPLXFInitializes a complex number.
SHZ_CMPLXF32Initializes a complex number.
SHZ_IUnit imaginary constant, 'I'.

Basic operations on complex numbers.

SymbolDescription
shz_cinitfReturns a complex number which has been initialized to contain the given component values.
shz_cpolarfReturns a complex number with a magnitude of r, and a phase angle of theta (in radians).
shz_cequalfChecks for equality between two complex numbers with either an absolute or relative tolerance.
shz_crealfReturns the real component of a complex number.
shz_cimagfReturns the imaginary component of a complex number.

Arithmetic operations on complex numbers.

SymbolDescription
shz_caddfAdds two complex numbers together and returns the result.
shz_csubfSubtracts rhs from lhs and returns the complex result.
shz_cmulfMultiplies two complex numbers together, returning the complex result.
shz_cdivfDivides lhs by rhs, returning the complex result.
shz_cscalefScales both componets of the complex number, c, by the value, v, returning the result.
shz_crecipfReturns the multiplicative inverse or reciprocal of the complex number, c.

Extract or modify complex components.

SymbolDescription
shz_cabsfReturns the absolute value (or magnitude) of the complex number, c.
shz_inv_cabsfReturns the inverse of the absolute value (or inverse of the magnitude) of the complex number, c.
shz_cnormfReturns the squared magnitude of the complex number, c.
shz_cargfReturns the phase angle of the complex number, c.
shz_conjfReturns the complex conjugate of c.
shz_cprojfCalculates the projection of the complex number, c, onto the Riemann sphere.

Complex transcendental functions.

SymbolDescription
shz_csqrtfComputes and returns the complex square root of c.
shz_cpowfRaises the complex base to the complex exp power, returning a complex result.
shz_cexpfReturns the complex base e exponential of c.
shz_clogfComputes and returns the complex natural logarithm of c.
shz_clog10fComputes and returns the complex base 10 logarithm of c.

Complex spherical trigonometric functions.

SymbolDescription
shz_csinfCalculates and returns the complex sine of c.
shz_ccosfCalculates and returns the complex cosine of c.
shz_ctanfCalculates and returns the complex tangent of c.
shz_ccscfCalculates and returns the complex cosecant of c.
shz_csecfCalculates and returns the complex secant of c.
shz_ccotfCalculates and returns the complex cotangent of c.
shz_casinfCalculates and returns the complex arcsine of c.
shz_cacosfCalculates and returns the complex arccosine of c.
shz_catanfCalculates and returns the complex arctangent of c.
shz_cacscfCalculates and returns the complex arccosecant of c.
shz_casecfCalculates and returns the complex arcsecant of c.
shz_cacotfCalculates and returns the complex arccotangent of c.

Complex hyperbolic trigonometric functions.

SymbolDescription
shz_csinhfCalculates and returns the complex hyperbolic sine of c.
shz_ccoshfCalculates and returns the complex hyperbolic cosine of c.
shz_ctanhfCalculates and returns the complex hyperbolic tangent of c.
shz_ccschfCalculates and returns the complex hyperbolic cosecant of c.
shz_csechfCalculates and returns the complex hyperbolic secant of c.
shz_ccothfCalculates and returns the complex hyperbolic cotangent of c.
shz_casinhfCalculates and returns the complex hyperbolic arcsine of c.
shz_cacoshfCalculates and returns the complex hyperbolic arccosine of c.
shz_catanhfCalculates and returns the complex hyperbolic arctangent of c.
shz_cacschfCalculates and returns the complex hyperbolic arccosecant of c.
shz_casechfCalculates and returns the complex hyperbolic arcsecant of c.
shz_cacothfCalculates and returns the complex hyperbolic arccotangent of c.

Functions for processing complex signals.

SymbolDescription
shz_fftFast Fourier Transform.
SymbolDescription
shz_complex_tRepresents a floating-point complex number real/imaginary pair.
shz_complexshz_complex_t alias for those who don't like POSIX-style.