
Boost : 
From: John Maddock (jz.maddock_at_[hidden])
Date: 20210205 17:00:00
On 04/02/2021 20:23, Gero Peterhoff via Boost wrote:
> Hello Chris,
> Unfortunately, a few things have come up with me so that I (probably) won't be able to really help in the near future.
> Some other functions (e.g. log, exp) also give incorrect results for some combinations of nan, inf and 0.
The place to check for this is C99 Annex G  but note that this is
nonnormative so there will be implementations of std::complex which do
not do anything in particular in these cases... platforms too with no
infinity or NaN.
> But I saw that gcc libquadmath (https://gcc.gnu.org/onlinedocs/libquadmath/MathLibraryRoutines.html#MathLibraryRoutines) offers some complex functions that work correctly. These could be used. But I don't know if clang, intel and/or other compilers can do that too.
> example
> inline complex<BOOST_CSTDFLOAT_EXTENDED_COMPLEX_FLOAT_TYPE> log(const complex<BOOST_CSTDFLOAT_EXTENDED_COMPLEX_FLOAT_TYPE>& x)
> {
> __complex128
> res = __complex128{x.real(), x.imag()};
> res = clogq(res);
> return complex<BOOST_CSTDFLOAT_EXTENDED_COMPLEX_FLOAT_TYPE>{crealq(res), cimagq(res)};
> }
>
> I also noticed a few basic things, maybe you can say why that is:
>  Why are there explicit complex classes for FP types, why is this not implemented completely via template? The advantage is that builtins can be used, on the other hand, a separate class must be written for each FP type  with the problems we are currently having.
This is all a question for the C++ committee, my speculation would be
that they wished to restrict the scope of std::complex to
float/double/long double.
>  Why are there missing template conversion ctors for the complex<FPType>? That will not do:
> std::complex<int> ci{4711, 23};
> std::complex<double> cd=ci;
> or
> std::complex<double> cd = std::complex<double>{ci};
> but a ctor must be called explicitly
> std::complex<double> cd=std::complex<double>{double(ci.real()), double(ci.imag())}; // prevent warnings
> It's really annoying.
>  Why are many stdmath functions missing for complex; specialfunctions complete (also applies to std::valarray)?
>
> I want to add such things in my mathlib, as far as possible everything constexpr. I also want to provide additional classes for dual and splitcomplex numbers (iÂ²=0, iÂ²=1, but it is far from complete  because it is quite extensive). Maybe these could also be included in boost. To do this, however, it would be necessary to convert the boostmathlib to C++20, since some functions (or the distinction between dual, complex and splitcomplex  classes/functions) is only possible with concepts (otherwise unreasonable effort). I also need some additional typetraits.
If you want to provide implementations for any complex valued special
functions we can take care of the algorithm overload selection 
enable_if will do fine, there's no need for concepts just yet.
Best John.
 This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk