libMesh
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
libMesh::Utility::do_pow< N, T > Struct Template Reference

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

#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 255 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 256 of file utility.h.

257 {
258 libmesh_assert(N>1);
259
260 if (N%2) // odd exponent
261 return x * do_pow<N-1,T>::apply(x);
262
263 const T xNover2 = do_pow<N/2,T>::apply(x);
264
265 return xNover2*xNover2;
266 }
libmesh_assert(ctx)
static T apply(const T &x)
Definition utility.h:256

References libMesh::Utility::do_pow< N, T >::apply(), and libMesh::libmesh_assert().

Referenced by libMesh::Utility::do_pow< N, T >::apply(), and libMesh::Utility::pow().


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