SH4ZAM! 0.1.0
Fast math library for the Sega Dreamcast's SH4 CPU
Loading...
Searching...
No Matches
shz::complex Struct Reference

#include <shz_complex.hpp>

Inheritance diagram for shz::complex:
Collaboration diagram for shz::complex:

Public Member Functions

Constructors

Members for initializing and constructing.

 complex () noexcept=default
 
 complex (const complex &rhs) noexcept=default
 
 complex (float re, float im=0.0f) noexcept
 
 complex (const shz_complex_t &cplx) noexcept
 
 complex (const volatile shz_complex_t &cplx) noexcept
 
Member Operators

Overloaded operators defined as member functions.

complexoperator= (const complex &rhs) noexcept=default
 
complexoperator= (const shz_complex_t &rhs) noexcept
 
volatile complexoperator= (volatile shz_complex_t rhs) volatile noexcept
 
complexoperator+= (shz_complex_t rhs) noexcept
 
complexoperator-= (shz_complex_t rhs) noexcept
 
complexoperator*= (shz_complex_t rhs) noexcept
 
complexoperator*= (float scale) noexcept
 
complexoperator/= (shz_complex_t rhs) noexcept
 

Additional Inherited Members

- Data Fields inherited from shz_complex_t
float real
 
float imag
 

Detailed Description

C++ wrapper around a floating-point complex number, real/imaginary pair.

Definition at line 28 of file shz_complex.hpp.

Constructor & Destructor Documentation

◆ complex() [1/5]

shz::complex::complex ( )
defaultnoexcept

Default constructor.

◆ complex() [2/5]

shz::complex::complex ( const complex & rhs)
defaultnoexcept

Default copy constructor.

◆ complex() [3/5]

shz::complex::complex ( float re,
float im = 0.0f )
inlinenoexcept

Value constructor, sets the imaginary component to 0 if none is supplied.

Definition at line 42 of file shz_complex.hpp.

42 :
43 shz_complex_t({ re, im }) {}

◆ complex() [4/5]

shz::complex::complex ( const shz_complex_t & cplx)
inlinenoexcept

Converting constructor for initializing from the C base type.

Definition at line 46 of file shz_complex.hpp.

46 :
47 complex(cplx.real, cplx.imag) {}
complex() noexcept=default
Default constructor.
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

◆ complex() [5/5]

shz::complex::complex ( const volatile shz_complex_t & cplx)
inlinenoexcept

Converting constructor for initialization from a volatile value type.

Definition at line 50 of file shz_complex.hpp.

50 :
51 complex(cplx.real, cplx.imag) {}

Member Function Documentation

◆ operator=() [1/3]

complex & shz::complex::operator= ( const complex & rhs)
defaultnoexcept

Defaulted assignment operator.

◆ operator=() [2/3]

complex & shz::complex::operator= ( const shz_complex_t & rhs)
inlinenoexcept

Overloaded assignment operator for assigning to the C base type.

Definition at line 64 of file shz_complex.hpp.

64 {
65 real = rhs.real;
66 imag = rhs.imag;
67
68 return *this;
69 }

◆ operator=() [3/3]

volatile complex & shz::complex::operator= ( volatile shz_complex_t rhs) volatile
inlinenoexcept

Overloaded assignment operator for assigning from a volatile C base type.

Definition at line 72 of file shz_complex.hpp.

72 {
73 real = rhs.real;
74 imag = rhs.imag;
75
76 return *this;
77 }

◆ operator+=()

complex & shz::complex::operator+= ( shz_complex_t rhs)
inlinenoexcept

Adds and accumulates rhs onto the given complex number.

Definition at line 80 of file shz_complex.hpp.

80 {
81 return (*this = shz_caddf(*this, rhs));
82 }
shz_complex_t shz_caddf(shz_complex_t lhs, shz_complex_t rhs) SHZ_NOEXCEPT
Adds two complex numbers together and returns the result.

◆ operator-=()

complex & shz::complex::operator-= ( shz_complex_t rhs)
inlinenoexcept

Subtracts rhs from the given complex number, assigning it to the result.

Definition at line 85 of file shz_complex.hpp.

85 {
86 return (*this = shz_csubf(*this, rhs));
87 }
shz_complex_t shz_csubf(shz_complex_t lhs, shz_complex_t rhs) SHZ_NOEXCEPT
Subtracts rhs from lhs and returns the complex result.

◆ operator*=() [1/2]

complex & shz::complex::operator*= ( shz_complex_t rhs)
inlinenoexcept

Multiplies and accumulates rhs by the given complex number.

Definition at line 90 of file shz_complex.hpp.

90 {
91 return (*this = shz_cmulf(*this, rhs));
92 }
shz_complex_t shz_cmulf(shz_complex_t lhs, shz_complex_t rhs) SHZ_NOEXCEPT
Multiplies two complex numbers together, returning the complex result.

◆ operator*=() [2/2]

complex & shz::complex::operator*= ( float scale)
inlinenoexcept

Multiplies and accumulates the given complex number by scalar.

Definition at line 95 of file shz_complex.hpp.

95 {
96 return (*this = shz_cscalef(*this, scale));
97 }
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.

◆ operator/=()

complex & shz::complex::operator/= ( shz_complex_t rhs)
inlinenoexcept

Divides the given complex number by rhs, assigning it to the result.

Definition at line 100 of file shz_complex.hpp.

100 {
101 return (*this = shz_cdivf(*this, rhs));
102 }
shz_complex_t shz_cdivf(shz_complex_t lhs, shz_complex_t rhs) SHZ_NOEXCEPT
Divides lhs by rhs, returning the complex result.

The documentation for this struct was generated from the following file: