...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
#include <boost/math/special_functions/powm1.hpp>
namespace boost{ namespace math{ template <class T1, class T2> calculated-result-type powm1(T1 x, T2 y); template <class T1, class T2, class Policy> calculated-result-type powm1(T1 x, T2 y, const Policy&); }} // namespaces
Returns xy - 1.
The return type of this function is computed using the result type calculation rules when T1 and T2 are dufferent types.
The final Policy argument is optional and can be used to control the behaviour of the function: how it handles errors, what level of precision to use etc. Refer to the policy documentation for more details.
There are two domains where this is useful: when y is very small, or when x is close to 1.
Implemented in terms of expm1
.
The following graph illustrates the behaviour of powm1:
Should have approximately 2-3 epsilon accuracy.
A selection of random high precision test values calculated using NTL::RR at 1000-bit precision.