libMesh::Utility::do_pow< N, T > Struct Template Reference

#include <utility.h>

Static Public Member Functions

static T apply (const T &x)
 

Detailed Description

template<int N, typename T>
struct libMesh::Utility::do_pow< N, T >

An efficient template instantiation for raising to an arbitrary integer power.

Definition at line 157 of file utility.h.

Member Function Documentation

◆ apply()

template<int N, typename T >
static T libMesh::Utility::do_pow< N, T >::apply ( const T &  x)
inlinestatic

Definition at line 158 of file utility.h.

Referenced by libMesh::Utility::pow().

159  {
160  libmesh_assert(N>1);
161 
162  if (N%2) // odd exponent
163  return x * do_pow<N-1,T>::apply(x);
164 
165  const T xNover2 = do_pow<N/2,T>::apply(x);
166 
167  return xNover2*xNover2;
168  }
static T apply(const T &x)
Definition: utility.h:158

The documentation for this struct was generated from the following file: