2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
20#ifndef SHZ_COMPLEX_HPP
21#define SHZ_COMPLEX_HPP
31
32
33
42 SHZ_FORCE_INLINE
complex(
float re,
float im = 0.0f)
noexcept:
43 shz_complex_t({ re, im }) {}
46 SHZ_FORCE_INLINE
complex(
const shz_complex_t& cplx)
noexcept:
50 SHZ_FORCE_INLINE
complex(
const volatile shz_complex_t& cplx)
noexcept:
56
57
58
72 SHZ_FORCE_INLINE
volatile complex&
operator=(
volatile shz_complex_t rhs)
volatile noexcept {
111
112
113
152 return !(lhs
== rhs);
158
159
160
190
191
192
227
228
229
264
265
266
296
297
298
363
364
365
430
431
432
435 SHZ_FORCE_INLINE
void fft(shz_complex_t* s, size_t size)
noexcept {
Namespace enclosing the SH4ZAM C++ API.
complex cprojf(complex c) noexcept
Returns the projection of the complex number onto the Riemann sphere.
complex cpowf(complex base, complex exp) noexcept
Raises a complex base to a complex power given by exp, returning a complex result.
complex ccscf(complex c) noexcept
Returns the cosecant of the given complex number.
complex casinhf(complex c) noexcept
Returns the hyperbolic arcsine of the given complex number.
complex casechf(complex c) noexcept
Returns the hyperbolic arcsecant of the given complex number.
bool operator==(complex lhs, complex rhs) noexcept
Returns true if the two complex numbers are approximately equal.
bool operator!=(complex lhs, complex rhs) noexcept
Returns true if the two complex numbers are approximately inequal.
complex ccschf(complex c) noexcept
Returns the hyperbolic cosecant of the given complex number.
complex cexpf(complex c) noexcept
Returns the complex base e exponential of the given complex number.
float cimagf(complex c) noexcept
Returns the imaginary component of the given complex number.
complex catanf(complex c) noexcept
Returns the arctangent of the given complex number.
complex crecipf(complex c) noexcept
Returns the multiplicative reciprocal of the given complex number.
complex conjf(complex c) noexcept
Returns the complex conjugate of the given complex number.
complex operator/(complex lhs, float rhs) noexcept
Divides lhs by a complex number with the real compoonent given as rhs and no imaginary component.
complex cacscf(complex c) noexcept
Returns the arccosecant of the given complex number.
complex csecf(complex c) noexcept
Returns the secant of the given complex number.
complex ctanhf(complex c) noexcept
Returns the hyperbolic tangent of the given complex number.
complex cacotf(complex c) noexcept
Returns the arccotangent of the given complex number.
complex csechf(complex c) noexcept
Returns the hyperbolic secant of the given complex number.
complex csinf(complex c) noexcept
Returns the sine of the given complex number.
complex clog10f(complex c) noexcept
Returns the complex base 10 logarithm of the given complex number.
complex ccotf(complex c) noexcept
Returns the cotangent of the given complex number.
complex catanhf(complex c) noexcept
Returns the hyperbolic arctangent of the given complex number.
float cnormf(complex c) noexcept
Returns the squared magnitude of the given complex number.
complex csqrtf(complex c) noexcept
Returns the complex square root of the given complex number.
complex operator/(complex lhs, complex rhs) noexcept
Divides lhs by rhs, returning the complex result.
complex cacosf(complex c) noexcept
Returns the arccosine of the given complex number.
complex clogf(complex c) noexcept
returns the complex natural logarithm of the given complex number.
float cargf(complex c) noexcept
Returns the phase angle of the given complex number.
complex ccosf(complex c) noexcept
Returns the cosine of the given complex number.
complex ccothf(complex c) noexcept
Returns the hyperbolic cotangent of the given complex number.
float crealf(complex c) noexcept
Returns the real component of the given complex number.
bool cequalf(complex lhs, complex rhs) noexcept
Checks for relative equality between lhs and rhs.
complex cmulf(complex lhs, complex rhs) noexcept
Multiplies the two complex numbers together, returning the complex result.
complex cpolarf(float r, float theta) noexcept
Converts the given polar coordinates into a complex number.
complex operator*(complex lhs, float rhs) noexcept
Multiplies lhs by a complex number with the real component given as rhs and no imaginary component.
complex cacschf(complex c) noexcept
Returns the hyperbolic arccosecant of the given complex number.
complex cacoshf(complex c) noexcept
Returns the hyperbolic arccosine of the given complex number.
complex cinitf(float real, float imag) noexcept
Returns a new complex number with the given components.
complex casinf(complex c) noexcept
Returns the arcsine of the given complex number.
complex operator*(complex lhs, complex rhs) noexcept
Multiplies lhs by rhs, returning the complex result.
complex operator+(complex lhs, complex rhs) noexcept
Adds the two complex numbers, lhs and rhs, returning the result.
float inv_cabsf(complex c) noexcept
Returns the inverse absolute value or magnitude of the given complex number.
complex ccoshf(complex c) noexcept
Returns the hyperbolic cosine of the given complex number.
complex csubf(complex lhs, complex rhs) noexcept
Subtracts rhs from lhs, returning the complex result.
complex csinhf(complex c) noexcept
Returns the hyperbolic sine of the given complex number.
complex caddf(complex lhs, complex rhs) noexcept
Adds the two complex numbers together, returning the complex result.
complex operator-(complex lhs, complex rhs) noexcept
Subtracts rhs from lhs, returning the complex result.
complex cacothf(complex c) noexcept
Returns the hyperbolic arccotangent of the given complex number.
complex casecf(complex c) noexcept
Returns the arcsecant of the given complex number.
float cabsf(complex c) noexcept
Returns the absolute value or magnitude of the given complex number.
complex cscalef(complex lhs, float v) noexcept
Multiplies lhs by the complex number created with v as its real component's value and no imaginary co...
void fft(shz_complex_t *s, size_t size) noexcept
C++ wrapper around shz_fft(), which computes the FFT of the given buffer.
complex ctanf(complex c) noexcept
Returns the tangent of the given complex number.
complex cdivf(complex lhs, complex rhs) noexcept
Divides lhs by rhs, returning the complex result.
float shz_inv_cabsf(shz_complex_t c) SHZ_NOEXCEPT
Returns the inverse of the absolute value (or inverse of the magnitude) of the complex number,...
shz_complex_t shz_cacoshf(shz_complex_t c) SHZ_NOEXCEPT
Calculates and returns the complex hyperbolic arccosine of c.
shz_complex_t shz_ccotf(shz_complex_t c) SHZ_NOEXCEPT
Calculates and returns the complex cotangent of c.
shz_complex_t shz_cmulf(shz_complex_t lhs, shz_complex_t rhs) SHZ_NOEXCEPT
Multiplies two complex numbers together, returning the complex result.
void shz_fft(shz_complex_t *s, size_t size) SHZ_NOEXCEPT
Fast Fourier Transform.
float shz_cimagf(shz_complex_t c) SHZ_NOEXCEPT
Returns the imaginary component of a complex number.
shz_complex_t shz_catanf(shz_complex_t c) SHZ_NOEXCEPT
Calculates and returns the complex arctangent of c.
shz_complex_t shz_casinf(shz_complex_t c) SHZ_NOEXCEPT
Calculates and returns the complex arcsine of c.
shz_complex_t shz_csinf(shz_complex_t c) SHZ_NOEXCEPT
Calculates and returns the complex sine of c.
shz_complex_t shz_csechf(shz_complex_t c) SHZ_NOEXCEPT
Calculates and returns the complex hyperbolic secant of c.
shz_complex_t shz_ccschf(shz_complex_t c) SHZ_NOEXCEPT
Calculates and returns the complex hyperbolic cosecant of c.
shz_complex_t shz_crecipf(shz_complex_t c) SHZ_NOEXCEPT
Returns the multiplicative inverse or reciprocal of the complex number, c.
float shz_cabsf(shz_complex_t c) SHZ_NOEXCEPT
Returns the absolute value (or magnitude) of the complex number, c.
shz_complex_t shz_cacothf(shz_complex_t c) SHZ_NOEXCEPT
Calculates and returns the complex hyperbolic arccotangent of c.
shz_complex_t shz_ctanf(shz_complex_t c) SHZ_NOEXCEPT
Calculates and returns the complex tangent of c.
shz_complex_t shz_cscalef(shz_complex_t c, float v) SHZ_NOEXCEPT
Scales both componets of the complex number, c, by the value, v, returning the result.
shz_complex_t shz_cprojf(shz_complex_t c) SHZ_NOEXCEPT
Calculates the projection of the complex number, c, onto the Riemann sphere.
shz_complex_t shz_cdivf(shz_complex_t lhs, shz_complex_t rhs) SHZ_NOEXCEPT
Divides lhs by rhs, returning the complex result.
shz_complex_t shz_csubf(shz_complex_t lhs, shz_complex_t rhs) SHZ_NOEXCEPT
Subtracts rhs from lhs and returns the complex result.
shz_complex_t shz_casechf(shz_complex_t c) SHZ_NOEXCEPT
Calculates and returns the complex hyperbolic arcsecant of c.
shz_complex_t shz_cacotf(shz_complex_t c) SHZ_NOEXCEPT
Calculates and returns the complex arccotangent of c.
shz_complex_t shz_csqrtf(shz_complex_t c) SHZ_NOEXCEPT
Computes and returns the complex square root of c.
shz_complex_t shz_casinhf(shz_complex_t c) SHZ_NOEXCEPT
Calculates and returns the complex hyperbolic arcsine of c.
bool shz_cequalf(shz_complex_t lhs, shz_complex_t rhs) SHZ_NOEXCEPT
Checks for equality between two complex numbers with either an absolute or relative tolerance.
float shz_cnormf(shz_complex_t c) SHZ_NOEXCEPT
Returns the squared magnitude of the complex number, c.
shz_complex_t shz_caddf(shz_complex_t lhs, shz_complex_t rhs) SHZ_NOEXCEPT
Adds two complex numbers together and returns the result.
shz_complex_t shz_casecf(shz_complex_t c) SHZ_NOEXCEPT
Calculates and returns the complex arcsecant of c.
shz_complex_t shz_clogf(shz_complex_t c) SHZ_NOEXCEPT
Computes and returns the complex natural logarithm of c.
float shz_crealf(shz_complex_t c) SHZ_NOEXCEPT
Returns the real component of a complex number.
shz_complex_t shz_csecf(shz_complex_t c) SHZ_NOEXCEPT
Calculates and returns the complex secant of c.
shz_complex_t shz_cpolarf(float r, float theta) SHZ_NOEXCEPT
Returns a complex number with a magnitude of r, and a phase angle of theta (in radians).
shz_complex_t shz_ccoshf(shz_complex_t c) SHZ_NOEXCEPT
Calculates and returns the complex hyperbolic cosine of c.
shz_complex_t shz_cexpf(shz_complex_t c) SHZ_NOEXCEPT
Returns the complex base e exponential of c.
shz_complex_t shz_cinitf(float real, float imag) SHZ_NOEXCEPT
Returns a complex number which has been initialized to contain the given component values.
shz_complex_t shz_conjf(shz_complex_t c) SHZ_NOEXCEPT
Returns the complex conjugate of c.
shz_complex_t shz_catanhf(shz_complex_t c) SHZ_NOEXCEPT
Calculates and returns the complex hyperbolic arctangent of c.
shz_complex_t shz_cpowf(shz_complex_t base, shz_complex_t exp) SHZ_NOEXCEPT
Raises the complex base to the complex exp power, returning a complex result.
shz_complex_t shz_cacschf(shz_complex_t c) SHZ_NOEXCEPT
Calculates and returns the complex hyperbolic arccosecant of c.
float shz_cargf(shz_complex_t c) SHZ_NOEXCEPT
Returns the phase angle of the complex number, c.
shz_complex_t shz_ccosf(shz_complex_t c) SHZ_NOEXCEPT
Calculates and returns the complex cosine of c.
shz_complex_t shz_ctanhf(shz_complex_t c) SHZ_NOEXCEPT
Calculates and returns the complex hyperbolic tangent of c.
shz_complex_t shz_cacosf(shz_complex_t c) SHZ_NOEXCEPT
Calculates and returns the complex arccosine of c.
shz_complex_t shz_csinhf(shz_complex_t c) SHZ_NOEXCEPT
Calculates and returns the complex hyperbolic sine of c.
shz_complex_t shz_clog10f(shz_complex_t c) SHZ_NOEXCEPT
Computes and returns the complex base 10 logarithm of c.
shz_complex_t shz_ccothf(shz_complex_t c) SHZ_NOEXCEPT
Calculates and returns the complex hyperbolic cotangent of c.
shz_complex_t shz_cacscf(shz_complex_t c) SHZ_NOEXCEPT
Calculates and returns the complex arccosecant of c.
shz_complex_t shz_ccscf(shz_complex_t c) SHZ_NOEXCEPT
Calculates and returns the complex cosecant of c.
float shz_invf(float x) SHZ_NOEXCEPT
Takes the inverse of x using a slighty faster approximation than doing a full division,...
C++ wrapper around a floating-point complex number, real/imaginary pair.
complex & operator+=(shz_complex_t rhs) noexcept
Adds and accumulates rhs onto the given complex number.
complex & operator=(const shz_complex_t &rhs) noexcept
Overloaded assignment operator for assigning to the C base type.
complex & operator*=(float scale) noexcept
Multiplies and accumulates the given complex number by scalar.
complex & operator=(const complex &rhs) noexcept=default
Defaulted assignment operator.
complex(const volatile shz_complex_t &cplx) noexcept
Converting constructor for initialization from a volatile value type.
complex(const complex &rhs) noexcept=default
Default copy constructor.
volatile complex & operator=(volatile shz_complex_t rhs) volatile noexcept
Overloaded assignment operator for assigning from a volatile C base type.
complex & operator-=(shz_complex_t rhs) noexcept
Subtracts rhs from the given complex number, assigning it to the result.
complex(float re, float im=0.0f) noexcept
Value constructor, sets the imaginary component to 0 if none is supplied.
complex & operator*=(shz_complex_t rhs) noexcept
Multiplies and accumulates rhs by the given complex number.
complex(const shz_complex_t &cplx) noexcept
Converting constructor for initializing from the C base type.
complex() noexcept=default
Default constructor.
complex & operator/=(shz_complex_t rhs) noexcept
Divides the given complex number by rhs, assigning it to the result.
float real
The real portion of the complex number.
float imag
The imaginary portion of the complex number.