HPCombi
High Performance Combinatorics in C++ using vector instructions v1.0.0
Loading...
Searching...
No Matches
Classes | Namespaces | Functions
power.hpp File Reference

Generic compile time power. More...

Go to the source code of this file.

Classes

struct  HPCombi::power_helper::Monoid< T >
 Algebraic monoid structure used by default for type T by the pow function and prod function. More...
 

Namespaces

namespace  HPCombi
 
namespace  HPCombi::power_helper
 

Functions

template<typename T , typename M = power_helper::Monoid<T>>
const T HPCombi::square (const T x)
 A generic compile time squaring function.
 
template<unsigned exp, typename T , typename M = power_helper::Monoid<T>>
const T HPCombi::pow (const T x)
 A generic compile time exponentiation function.
 

Detailed Description

Generic compile time power.

The goal of this file is to be able to write expressions such as pow<23>(2.5) or pow<n>(x) where the first expression is entirely computed as compile time and the second one is expanded also as compile time to a O(log n) long sequence of multiplication. Furthermore such expression not only works for numbers for for any type where there is a neutral element and an associative (non necessarily commutative) product, namely what mathematicians call monoids. These include for example, strings where the neutral element is the empty string and the product is the concatenation.

see HPCombi::power_helper::Monoid<std::string>