WaveBlocksND
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
waveblocks::math::ContinuousSqrt< T > Class Template Reference

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...
 
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_
 
state_
 
bool empty_
 

Detailed Description

template<class T>
class waveblocks::math::ContinuousSqrt< T >

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.

Template Parameters
TType of both the real and imaginary components of the complex number.

Constructor & Destructor Documentation

template<class T>
waveblocks::math::ContinuousSqrt< T >::ContinuousSqrt ( )
inline

Delayes initialization of the stored reference solution.

The next call to operator()() yields the principal square root.

template<class T>
waveblocks::math::ContinuousSqrt< T >::ContinuousSqrt ( std::complex< T >  sqrt)
inline

Initializes the stored reference solution to a chosen value.

Parameters
sqrtThe initial reference solution.

Member Function Documentation

template<class T>
static T waveblocks::math::ContinuousSqrt< T >::continuate ( ref,
arg 
)
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).

Parameters
[in]refThe angle of the reference square root. domain = \( [-\pi;\pi] \)
[in]argThe angle of the computed square root. domain = \( [-\pi;\pi] \)
Returns
The angle of the continuating square root. domain = \( [-\pi;\pi] \)
template<class T>
T waveblocks::math::ContinuousSqrt< T >::get_state ( void  ) const
inline

getter for state state

Returns
state_[-pi,pi]
template<class T>
std::complex<T> waveblocks::math::ContinuousSqrt< T >::operator() ( std::complex< T >  input)
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} \)).

Parameters
inputThe right-hand-side \( c \).
Returns
The best solution \( \hat{z} \).
template<class T>
std::complex<T> waveblocks::math::ContinuousSqrt< T >::operator() ( ) const
inline

Retrieve the stored reference solution.

Member Data Documentation

template<class T>
bool waveblocks::math::ContinuousSqrt< T >::empty_
private

false iff a reference solution is stored

template<class T>
std::complex<T> waveblocks::math::ContinuousSqrt< T >::sqrt_
private

stored reference solution

template<class T>
T waveblocks::math::ContinuousSqrt< T >::state_
private

argument (angle) of reference solution domain = [-pi;pi]


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