dune-common  2.7.0
power.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 #ifndef DUNE_COMMON_POWER_HH
4 #define DUNE_COMMON_POWER_HH
5 
10 #include <dune/common/math.hh>
11 
12 namespace Dune {
13 
22  template <int m, int p>
23  struct StaticPower
24  {
26  enum { power = Dune::power(m,p) };
27  };
28 
29 
36  template <int p>
37  struct Power
38  {
39  template <typename T>
40  static constexpr auto eval(const T & a)
41  {
42  return power(a,p);
43  }
44  };
45 
46 }
47 
48 #endif
Dune::Power
Compute power for a run-time mantissa and a compile-time integer exponent.
Definition: power.hh:37
Dune::StaticPower
Calculates m^p at compile time.
Definition: power.hh:23
Dune::Power::eval
static constexpr auto eval(const T &a)
Definition: power.hh:40
math.hh
Some useful basic math stuff.
Dune::power
constexpr Mantissa power(Mantissa m, Exponent p)
Power method for integer exponents.
Definition: math.hh:73
Dune::StaticPower::power
@ power
Definition: power.hh:26
Dune
Dune namespace.
Definition: alignedallocator.hh:13