|
@@ -262,6 +262,22 @@ template <class Real> inline std::ostream& ostream_insertion_generic(std::ostrea
|
|
|
return output;
|
|
|
}
|
|
|
|
|
|
+template <Integer e, class Real> static inline constexpr Real pow_helper(Real b) {
|
|
|
+ return (e > 0) ? ((e & 1) ? b : Real(1)) * pow_helper<(e>>1),Real>(b*b) : Real(1);
|
|
|
+}
|
|
|
+
|
|
|
+template <Integer e, class Real> inline constexpr Real pow(Real b) {
|
|
|
+ return (e > 0) ? pow_helper<e,Real>(b) : 1/pow_helper<-e,Real>(b);
|
|
|
+}
|
|
|
+
|
|
|
+template <class Real> static inline constexpr Real pow_helper(Real b, Integer e) {
|
|
|
+ return (e > 0) ? ((e & 1) ? b : Real(1)) * pow_helper(b*b, e>>1) : Real(1);
|
|
|
+}
|
|
|
+
|
|
|
+template <class Real> inline constexpr Real pow(Real b, Integer e) {
|
|
|
+ return (e > 0) ? pow_helper(b, e) : 1/pow_helper(b, -e);
|
|
|
+}
|
|
|
+
|
|
|
} // end namespace
|
|
|
|
|
|
namespace SCTL_NAMESPACE {
|