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.
But I saw that gcc libquadmath (https://gcc.gnu.org/onlinedocs/libquadmath/Math-Library-Routines.html#Math-L...) 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
log(const complex & x) { __complex128 res = __complex128{x.real(), x.imag()}; res = clogq(res); return complex {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 built-ins 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
The place to check for this is C99 Annex G - but note that this is non-normative 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. 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<FP-Type>? 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 std-math functions missing for complex; special-functions complete (also applies to std::valarray)?
I want to add such things in my math-lib, 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 boost-math-lib 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