5 #ifndef LODESTAR_ADAPTIVEBACKWARDDIFFERENCE_HPP
6 #define LODESTAR_ADAPTIVEBACKWARDDIFFERENCE_HPP
8 #include "BackwardDifference.hpp"
9 #include "Lodestar/aux/ArrayStack.hpp"
10 #include <type_traits>
14 namespace primitives {
15 template<
typename TType,
size_t TOrder,
typename TScalarType =
double>
20 template<
typename TType,
typename TScalarType>
23 static const size_t kOrder = 1;
25 template<
size_t TSamples>
26 static typename std::enable_if<(TSamples > kOrder), TType>::type
27 compute(TScalarType h,
const std::array<TType, TSamples> &a)
29 return computeImpl(h, a);
32 template<
size_t TSamples>
33 static typename std::enable_if<(TSamples > kOrder), TType>::type
34 compute(TScalarType h,
const std::array<TType, TSamples> &a,
const size_t size)
53 return computeImpl(h, a);
56 template<
size_t TSamples>
57 static typename std::enable_if<(TSamples <= kOrder), TType>::type
58 compute(TScalarType h,
const std::array<TType, TSamples> &a,
const size_t size)
60 static_assert(TSamples > kOrder,
"Number of samples must be greater than the differentiation order.");
65 template<
size_t TSamples>
66 static typename std::enable_if<(TSamples > kOrder) && (TSamples > 7), TType>::type
67 compute(TScalarType h,
const std::array<TType, TSamples> &a)
72 template<
size_t TSamples>
73 static typename std::enable_if<(TSamples <= kOrder), TType>::type
74 compute(TScalarType h,
const std::array<TType, TSamples> &a)
76 static_assert(TSamples > kOrder,
"Number of samples must be greater than the differentiation order.");
82 static inline TType computeImpl(TScalarType h,
const std::array<TType, 2> &a)
87 static inline TType computeImpl(TScalarType h,
const std::array<TType, 3> &a)
92 static inline TType computeImpl(TScalarType h,
const std::array<TType, 4> &a)
97 static inline TType computeImpl(TScalarType h,
const std::array<TType, 5> &a)
102 static inline TType computeImpl(TScalarType h,
const std::array<TType, 6> &a)
107 template<
size_t TSamples>
108 static typename std::enable_if<(TSamples > kOrder) && (TSamples >= 7), TType>::type
109 computeImpl(TScalarType h,
const std::array<TType, TSamples> &a)
117 #endif //LODESTAR_ADAPTIVEBACKWARDDIFFERENCE_HPP