Skip to content

Commit

Permalink
templatized runtime fastpow
Browse files Browse the repository at this point in the history
  • Loading branch information
Iximiel committed May 16, 2024
1 parent 55443b5 commit 8f02d11
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/tools/Tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ class Tools {
/// extension("pippo/.t")="" whereas extension("pippo/a.t")="t"
static std::string extension(const std::string&);
/// Fast int power
static double fastpow(double base,int exp);
template <typename T>
static T fastpow(T base,int exp);
/// Fast int power for power known at compile time
template <int exp, typename T=double>
static inline /*consteval*/ T fastpow(T base);
Expand Down Expand Up @@ -461,9 +462,8 @@ bool Tools::convertNoexcept(T i,std::string & str) {
return true;
}

inline
double Tools::fastpow(double base, int exp)
{
template <typename T>
inline T Tools::fastpow(T base, int exp) {
if(exp<0) {
exp=-exp;
base=1.0/base;
Expand Down

0 comments on commit 8f02d11

Please sign in to comment.