SH4ZAM! 0.1.0
Fast math library for the Sega Dreamcast's SH4 CPU
Loading...
Searching...
No Matches
shz_complex.hpp
Go to the documentation of this file.
1/*! \file
2 \brief Complex number C++ API
3 \ingroup complex
4
5 This file contains the C++ layer for wrapping the Complex
6 Number C API. The major thing that it adds in C++ is convenient
7 overloaded operators for performing arithmetic on complex numbers
8 using the regular arithmetic operators, rather than having to make
9 function calls which implement them, as in C.
10
11 \author 2026 Falco Girgis
12 \copyright MIT License
13
14 \todo
15 - custom literals
16 - array index accessors?
17 - iterator support?
18*/
19
20#ifndef SHZ_COMPLEX_HPP
21#define SHZ_COMPLEX_HPP
22
23#include "shz_complex.h"
24
25namespace shz {
26
27 //! C++ wrapper around a floating-point complex number, real/imaginary pair.
28 struct complex: public shz_complex_t {
29
30 /*! \name Constructors
31 \brief Members for initializing and constructing.
32 @{
33 */
34
35 //! Default constructor.
36 complex() noexcept = default;
37
38 //! Default copy constructor.
39 complex(const complex& rhs) noexcept = default;
40
41 //! Value constructor, sets the imaginary component to `0` if none is supplied.
42 SHZ_FORCE_INLINE complex(float re, float im = 0.0f) noexcept:
43 shz_complex_t({ re, im }) {}
44
45 //! Converting constructor for initializing from the C base type.
46 SHZ_FORCE_INLINE complex(const shz_complex_t& cplx) noexcept:
47 complex(cplx.real, cplx.imag) {}
48
49 //! Converting constructor for initialization from a volatile value type.
50 SHZ_FORCE_INLINE complex(const volatile shz_complex_t& cplx) noexcept:
51 complex(cplx.real, cplx.imag) {}
52
53 //! @}
54
55 /*! \name Member Operators
56 \brief Overloaded operators defined as member functions.
57 @{
58 */
59
60 //! Defaulted assignment operator.
61 complex& operator=(const complex& rhs) noexcept = default;
62
63 //! Overloaded assignment operator for assigning to the C base type.
64 SHZ_FORCE_INLINE complex& operator=(const shz_complex_t& rhs) noexcept {
65 real = rhs.real;
66 imag = rhs.imag;
67
68 return *this;
69 }
70
71 //! Overloaded assignment operator for assigning from a volatile C base type.
72 SHZ_FORCE_INLINE volatile complex& operator=(volatile shz_complex_t rhs) volatile noexcept {
73 real = rhs.real;
74 imag = rhs.imag;
75
76 return *this;
77 }
78
79 //! Adds and accumulates \p rhs onto the given complex number.
80 SHZ_FORCE_INLINE complex& operator+=(shz_complex_t rhs) noexcept {
81 return (*this = shz_caddf(*this, rhs));
82 }
83
84 //! Subtracts \p rhs from the given complex number, assigning it to the result.
85 SHZ_FORCE_INLINE complex& operator-=(shz_complex_t rhs) noexcept {
86 return (*this = shz_csubf(*this, rhs));
87 }
88
89 //! Multiplies and accumulates \p rhs by the given complex number.
90 SHZ_FORCE_INLINE complex& operator*=(shz_complex_t rhs) noexcept {
91 return (*this = shz_cmulf(*this, rhs));
92 }
93
94 //! Multiplies and accumulates the given complex number by \p scalar.
95 SHZ_FORCE_INLINE complex& operator*=(float scale) noexcept {
96 return (*this = shz_cscalef(*this, scale));
97 }
98
99 //! Divides the given complex number by \p rhs, assigning it to the result.
100 SHZ_FORCE_INLINE complex& operator/=(shz_complex_t rhs) noexcept {
101 return (*this = shz_cdivf(*this, rhs));
102 }
103
104 //! @}
105 };
106
107 //! POSIX-style C++ alias, for those who dig that kind of type name.
108 using complex_t = complex;
109
110 /*! \name Global Operators
111 \brief Globally-defined overloaded operators.
112 @{
113 */
114
115 //! Adds the two complex numbers, \p lhs and \p rhs, returning the result.
116 SHZ_FORCE_INLINE complex operator+(complex lhs, complex rhs) noexcept {
117 return shz_caddf(lhs, rhs);
118 }
119
120 //! Subtracts \p rhs from \p lhs, returning the complex result.
121 SHZ_FORCE_INLINE complex operator-(complex lhs, complex rhs) noexcept {
122 return shz_csubf(lhs, rhs);
123 }
124
125 //! Multiplies \p lhs by \p rhs, returning the complex result.
126 SHZ_FORCE_INLINE complex operator*(complex lhs, complex rhs) noexcept {
127 return shz_cmulf(lhs, rhs);
128 }
129
130 //! Multiplies \p lhs by a complex number with the real component given as \p rhs and no imaginary component.
131 SHZ_FORCE_INLINE complex operator*(complex lhs, float rhs) noexcept {
132 return shz_cscalef(lhs, rhs);
133 }
134
135 //! Divides \p lhs by \p rhs, returning the complex result.
136 SHZ_FORCE_INLINE complex operator/(complex lhs, complex rhs) noexcept {
137 return shz_cdivf(lhs, rhs);
138 }
139
140 //! Divides \p lhs by a complex number with the real compoonent given as \p rhs and no imaginary component.
141 SHZ_FORCE_INLINE complex operator/(complex lhs, float rhs) noexcept {
142 return shz_cscalef(lhs, shz_invf(rhs));
143 }
144
145 //! Returns true if the two complex numbers are approximately equal.
146 SHZ_FORCE_INLINE bool operator==(complex lhs, complex rhs) noexcept {
147 return shz_cequalf(lhs, rhs);
148 }
149
150 //! Returns true if the two complex numbers are approximately inequal.
151 SHZ_FORCE_INLINE bool operator!=(complex lhs, complex rhs) noexcept {
152 return !(lhs == rhs);
153 }
154
155 //! @}
156
157 /*! \name Basic
158 \brief Basic operations on complex numbers.
159 @{
160 */
161
162 //! Returns a new complex number with the given components.
163 SHZ_FORCE_INLINE complex cinitf(float real, float imag) noexcept {
164 return shz_cinitf(real, imag);
165 }
166
167 //! Converts the given polar coordinates into a complex number.
168 SHZ_FORCE_INLINE complex cpolarf(float r, float theta) noexcept {
169 return shz_cpolarf(r, theta);
170 }
171
172 //! Checks for relative equality between \p lhs and \p rhs.
173 SHZ_FORCE_INLINE bool cequalf(complex lhs, complex rhs) noexcept {
174 return shz_cequalf(lhs, rhs);
175 }
176
177 //! Returns the real component of the given complex number.
178 SHZ_FORCE_INLINE float crealf(complex c) noexcept {
179 return shz_crealf(c);
180 }
181
182 //! Returns the imaginary component of the given complex number.
183 SHZ_FORCE_INLINE float cimagf(complex c) noexcept {
184 return shz_cimagf(c);
185 }
186
187 //! @}
188
189 /*! \name Arithmetic
190 \brief Arithmetic operations on complex numbers.
191 @{
192 */
193
194 //! Adds the two complex numbers together, returning the complex result.
195 SHZ_FORCE_INLINE complex caddf(complex lhs, complex rhs) noexcept {
196 return shz_caddf(lhs, rhs);
197 }
198
199 //! Subtracts \p rhs from \p lhs, returning the complex result.
200 SHZ_FORCE_INLINE complex csubf(complex lhs, complex rhs) noexcept {
201 return shz_csubf(lhs, rhs);
202 }
203
204 //! Multiplies the two complex numbers together, returning the complex result.
205 SHZ_FORCE_INLINE complex cmulf(complex lhs, complex rhs) noexcept {
206 return shz_cmulf(lhs, rhs);
207 }
208
209 //! Divides \p lhs by \p rhs, returning the complex result.
210 SHZ_FORCE_INLINE complex cdivf(complex lhs, complex rhs) noexcept {
211 return shz_cdivf(lhs, rhs);
212 }
213
214 //! Multiplies \p lhs by the complex number created with \p v as its real component's value and no imaginary component value.
215 SHZ_FORCE_INLINE complex cscalef(complex lhs, float v) noexcept {
216 return shz_cscalef(lhs, v);
217 }
218
219 //! Returns the multiplicative reciprocal of the given complex number.
220 SHZ_FORCE_INLINE complex crecipf(complex c) noexcept {
221 return shz_crecipf(c);
222 }
223
224 //! @}
225
226 /*! \name Manipulation
227 \brief Extract or modify complex components.
228 @{
229 */
230
231 //! Returns the absolute value or magnitude of the given complex number.
232 SHZ_FORCE_INLINE float cabsf(complex c) noexcept {
233 return shz_cabsf(c);
234 }
235
236 //! Returns the inverse absolute value or magnitude of the given complex number.
237 SHZ_FORCE_INLINE float inv_cabsf(complex c) noexcept {
238 return shz_inv_cabsf(c);
239 }
240
241 //! Returns the squared magnitude of the given complex number.
242 SHZ_FORCE_INLINE float cnormf(complex c) noexcept {
243 return shz_cnormf(c);
244 }
245
246 //! Returns the phase angle of the given complex number.
247 SHZ_FORCE_INLINE float cargf(complex c) noexcept {
248 return shz_cargf(c);
249 }
250
251 //! Returns the complex conjugate of the given complex number.
252 SHZ_FORCE_INLINE complex conjf(complex c) noexcept {
253 return shz_conjf(c);
254 }
255
256 //! Returns the projection of the complex number onto the Riemann sphere.
257 SHZ_FORCE_INLINE complex cprojf(complex c) noexcept {
258 return shz_cprojf(c);
259 }
260
261 //! @}
262
263 /*! \name Transcendental
264 \brief Complex transcendental functions.
265 @{
266 */
267
268 //! Returns the complex square root of the given complex number.
269 SHZ_FORCE_INLINE complex csqrtf(complex c) noexcept {
270 return shz_csqrtf(c);
271 }
272
273 //! Raises a complex \p base to a complex power given by \p exp, returning a complex result.
274 SHZ_FORCE_INLINE complex cpowf(complex base, complex exp) noexcept {
275 return shz_cpowf(base, exp);
276 }
277
278 //! Returns the complex base `e` exponential of the given complex number.
279 SHZ_FORCE_INLINE complex cexpf(complex c) noexcept {
280 return shz_cexpf(c);
281 }
282
283 //! returns the complex natural logarithm of the given complex number.
284 SHZ_FORCE_INLINE complex clogf(complex c) noexcept {
285 return shz_clogf(c);
286 }
287
288 //! Returns the complex base 10 logarithm of the given complex number.
289 SHZ_FORCE_INLINE complex clog10f(complex c) noexcept {
290 return shz_clog10f(c);
291 }
292
293 //! @}
294
295 /*! \name Spherical Trigonometry
296 \brief Complex spherical trigonometric functions.
297 @{
298 */
299
300 //! Returns the sine of the given complex number.
301 SHZ_FORCE_INLINE complex csinf(complex c) noexcept {
302 return shz_csinf(c);
303 }
304
305 //! Returns the cosine of the given complex number.
306 SHZ_FORCE_INLINE complex ccosf(complex c) noexcept {
307 return shz_ccosf(c);
308 }
309
310 //! Returns the tangent of the given complex number.
311 SHZ_FORCE_INLINE complex ctanf(complex c) noexcept {
312 return shz_ctanf(c);
313 }
314
315 //! Returns the cosecant of the given complex number.
316 SHZ_FORCE_INLINE complex ccscf(complex c) noexcept {
317 return shz_ccscf(c);
318 }
319
320 //! Returns the secant of the given complex number.
321 SHZ_FORCE_INLINE complex csecf(complex c) noexcept {
322 return shz_csecf(c);
323 }
324
325 //! Returns the cotangent of the given complex number.
326 SHZ_FORCE_INLINE complex ccotf(complex c) noexcept {
327 return shz_ccotf(c);
328 }
329
330 //! Returns the arcsine of the given complex number.
331 SHZ_FORCE_INLINE complex casinf(complex c) noexcept {
332 return shz_casinf(c);
333 }
334
335 //! Returns the arccosine of the given complex number.
336 SHZ_FORCE_INLINE complex cacosf(complex c) noexcept {
337 return shz_cacosf(c);
338 }
339
340 //! Returns the arctangent of the given complex number.
341 SHZ_FORCE_INLINE complex catanf(complex c) noexcept {
342 return shz_catanf(c);
343 }
344
345 //! Returns the arccosecant of the given complex number.
346 SHZ_FORCE_INLINE complex cacscf(complex c) noexcept {
347 return shz_cacscf(c);
348 }
349
350 //! Returns the arcsecant of the given complex number.
351 SHZ_FORCE_INLINE complex casecf(complex c) noexcept {
352 return shz_casecf(c);
353 }
354
355 //! Returns the arccotangent of the given complex number.
356 SHZ_FORCE_INLINE complex cacotf(complex c) noexcept {
357 return shz_cacotf(c);
358 }
359
360 //! @}
361
362 /*! \name Hyperbolic Trigonometry
363 \brief Complex hyperbolic trigonometric functions.
364 @{
365 */
366
367 //! Returns the hyperbolic sine of the given complex number.
368 SHZ_FORCE_INLINE complex csinhf(complex c) noexcept {
369 return shz_csinhf(c);
370 }
371
372 //! Returns the hyperbolic cosine of the given complex number.
373 SHZ_FORCE_INLINE complex ccoshf(complex c) noexcept {
374 return shz_ccoshf(c);
375 }
376
377 //! Returns the hyperbolic tangent of the given complex number.
378 SHZ_FORCE_INLINE complex ctanhf(complex c) noexcept {
379 return shz_ctanhf(c);
380 }
381
382 //! Returns the hyperbolic cosecant of the given complex number.
383 SHZ_FORCE_INLINE complex ccschf(complex c) noexcept {
384 return shz_ccschf(c);
385 }
386
387 //! Returns the hyperbolic secant of the given complex number.
388 SHZ_FORCE_INLINE complex csechf(complex c) noexcept {
389 return shz_csechf(c);
390 }
391
392 //! Returns the hyperbolic cotangent of the given complex number.
393 SHZ_FORCE_INLINE complex ccothf(complex c) noexcept {
394 return shz_ccothf(c);
395 }
396
397 //! Returns the hyperbolic arcsine of the given complex number.
398 SHZ_FORCE_INLINE complex casinhf(complex c) noexcept {
399 return shz_casinhf(c);
400 }
401
402 //! Returns the hyperbolic arccosine of the given complex number.
403 SHZ_FORCE_INLINE complex cacoshf(complex c) noexcept {
404 return shz_cacoshf(c);
405 }
406
407 //! Returns the hyperbolic arctangent of the given complex number.
408 SHZ_FORCE_INLINE complex catanhf(complex c) noexcept {
409 return shz_catanhf(c);
410 }
411
412 //! Returns the hyperbolic arccosecant of the given complex number.
413 SHZ_FORCE_INLINE complex cacschf(complex c) noexcept {
414 return shz_cacschf(c);
415 }
416
417 //! Returns the hyperbolic arcsecant of the given complex number.
418 SHZ_FORCE_INLINE complex casechf(complex c) noexcept {
419 return shz_casechf(c);
420 }
421
422 //! Returns the hyperbolic arccotangent of the given complex number.
423 SHZ_FORCE_INLINE complex cacothf(complex c) noexcept {
424 return shz_cacothf(c);
425 }
426
427 //! @}
428
429 /*! \name Signal Processing
430 \brief Functions for processing complex signals.
431 @{
432 */
433
434 //! C++ wrapper around shz_fft(), which computes the FFT of the given buffer. \sa shz_fft()
435 SHZ_FORCE_INLINE void fft(shz_complex_t* s, size_t size) noexcept {
436 return shz_fft(s, size);
437 }
438
439 //! @}
440}
441
442#endif
Namespace enclosing the SH4ZAM C++ API.
Definition shz_cdefs.hpp:21
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.
Definition shz_complex.h:48
float imag
The imaginary portion of the complex number.
Definition shz_complex.h:49