diff --git a/sample/testAlgo.cpp b/sample/testAlgo.cpp index c7dba56..65614f5 100644 --- a/sample/testAlgo.cpp +++ b/sample/testAlgo.cpp @@ -12,6 +12,7 @@ int main(int argc, char **argv) cout << square(2.1f) << endl; cout << cube(2.1f) << endl; + cout << spower<-2>(2.1f) << endl; cout << spower<2>(2.1f) << endl; cout << spower<3>(2.1f) << endl; cout << spower<4>(2.1f) << endl; diff --git a/src/algo.hpp b/src/algo.hpp index 9b6e892..485db75 100644 --- a/src/algo.hpp +++ b/src/algo.hpp @@ -25,6 +25,10 @@ namespace CosmoTool template static T spower(T a) { + if (N<0) + { + return 1/SPowerBase<-N>::spower(a); + } if ((N%2)==0) { T b = SPowerBase::spower(a);