WaveBlocksND
|
This class deals with the issue, that the square root of complex numbers is not unique. More...
#include <continuous_sqrt.hpp>
Public Member Functions | |
ContinuousSqrt () | |
Delayes initialization of the stored reference solution. More... | |
ContinuousSqrt (std::complex< T > sqrt) | |
Initializes the stored reference solution to a chosen value. More... | |
std::complex< T > | operator() (std::complex< T > input) |
Solves the quadratic equation \( z^2 = c \). More... | |
std::complex< T > | operator() () const |
Retrieve the stored reference solution. More... | |
T | get_state (void) const |
getter for state state More... | |
Static Public Member Functions | |
static T | continuate (T ref, T arg) |
Private Attributes | |
std::complex< T > | sqrt_ |
T | state_ |
bool | empty_ |
This class deals with the issue, that the square root of complex numbers is not unique.
The equation \( z^2 = r \exp{(i\phi)} \) has two solutions, namely \( z_1=\sqrt{r} \exp{\left(i\frac{\phi}{2}\right)} \) and \( z_2=\sqrt{r} \exp{\left(i(\frac{\phi}{2}+\pi)\right)} \).
This class chooses the solution, that is nearest to the solution of the previous computation ( = reference solution). Then this class overrides the stored reference solution with the current solution.
The distance between the two complex numbers is determined by the angle-distance.
T | Type of both the real and imaginary components of the complex number. |
|
inline |
Delayes initialization of the stored reference solution.
The next call to operator()() yields the principal square root.
|
inline |
Initializes the stored reference solution to a chosen value.
sqrt | The initial reference solution. |
|
inlinestatic |
Chooses the square root angle (argument) that continuates the reference angle the best. Throws an exception if the deviation above an accepted value (by default > pi/4).
[in] | ref | The angle of the reference square root. domain = \( [-\pi;\pi] \) |
[in] | arg | The angle of the computed square root. domain = \( [-\pi;\pi] \) |
|
inline |
getter for state state
|
inline |
Solves the quadratic equation \( z^2 = c \).
Chooses the solution \( \hat{z} \) that best continuates the prior result \( z_0 \) and updates the reference solution ( \( z_0 \gets \hat{z} \)).
input | The right-hand-side \( c \). |
|
inline |
Retrieve the stored reference solution.
|
private |
false iff a reference solution is stored
|
private |
stored reference solution
|
private |
argument (angle) of reference solution domain = [-pi;pi]