Re: [eigen] MathFunctions.h patch |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
At least from my experience, there is a widely used choice for the complex
square root function.
This is defined by having a branch cut on the negative real axis and then
using leaf 0, i.e. for
z = abs{z} exp(I phi) with -Pi < phi <= Pi we have
sqrt(z) = sqrt(abs(z)) exp(I phi/2) and sqrt(abs(z)) >= 0
or alternatively by the condition Re(sqrt(z)) >= 0
The exact position of the branch cut (i.e., whether to include Pi or -Pi) is
debatable, the above is what I would expect when 0 doesn't have a sign; if
there is -0 then no ambiguities can arise. AFAIK, the C++98 and the C99
standard defines it in exactly this way, too, as well as the GNU libc, gsl and
the GiNaC library.
I have a use case where I do analytic approximations to a numerically
calculated space-time in numerical relativity and the branch cut is chosen in
exactly this way, but this is not Eigen-ified yet.
Regards, Markus
Am Donnerstag, 7. Januar 2010 schrieb Benoit Jacob:
> It is on purpose that we excluded sqrt for complex numbers:
> - there is no canonical choice between the 2 determinations of the square
> root. - no important use case was known to us.
>
> Do you have a use case?
>
> Benoit
>
> 2010/1/7 Trevor Irons <trevorirons@xxxxxxxxx>:
> > Any problem adding the following patch, or something similiar, to
> > MathFunctions.h to support std::complex<>.sqrt() ?
> >
> > 218d217
> > < inline std::complex<float> ei_sqrt(std::complex<float>x) { return
> > std::sqrt(x); }
> > 256d254
> > < inline std::complex<double> ei_sqrt(std::complex<double>x) { return
> > std::sqrt(x); }
> >
> >
> > -trevor
>