DGtal  1.5.beta
ConstExpressions.h
1 
17 #pragma once
18 
31 #if defined(ConstExpressions_RECURSES)
32 #error Recursive header files inclusion detected in ConstExpressions.h
33 #else // defined(ConstExpressions_RECURSES)
35 #define ConstExpressions_RECURSES
36 
37 #if !defined ConstExpressions_h
39 #define ConstExpressions_h
40 
42 // Inclusions
43 #include <iostream>
44 #include "DGtal/base/Common.h"
46 
47 namespace DGtal
48 {
49 
50  namespace functions {
59  template< typename T >
60  constexpr T const_pow( T b, unsigned int e) {
61  return e == 0 ? T(1) : b * const_pow( b, e - 1 );
62  }
63 
74  template< typename T >
75  constexpr T const_middle( T K, unsigned int e ) {
76  return e <= 1
77  ? T( K )
78  : K * const_pow( 2 * K + 1, e - 1 ) + const_middle( K, e - 1 );
79  }
80  } // namespace functions
81 
82 } // namespace DGtal
83 
84 
85 // //
87 
88 #endif // !defined ConstExpressions_h
89 
90 #undef ConstExpressions_RECURSES
91 #endif // else defined(ConstExpressions_RECURSES)
constexpr T const_pow(T b, unsigned int e)
constexpr T const_middle(T K, unsigned int e)
DGtal is the top-level namespace which contains all DGtal functions and types.
KSpace K