stator
A math, geometry, and utility library
taylor.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2017 Marcus N Campbell Bannerman <[email protected]>
3 
4  This file is part of stator.
5 
6  stator is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  stator is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with stator. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #pragma once
21 
22 // stator
24 
25 namespace sym {
26  namespace detail {
27  template<size_t State, size_t max_Order, class Var>
29  template<class Real>
30  static Null eval(const Null& f, const Real& a)
31  { return Null(); }
32 
33  template<class F, class Real>
34  static auto eval(const F& f, const Real& a)
36  };
37 
38  template<size_t max_Order, class Var>
39  struct TaylorSeriesWorker<max_Order,max_Order, Var> {
40  template<class F, class Real>
41  static auto eval(const F& f, const Real& a)
42  -> STATOR_AUTORETURN((typename InvFactorial<max_Order>::value() * sub(f, Var() = a)));
43 
44  template<class Real>
45  static Null eval(const Null& f, const Real& a)
46  { return Null(); }
47  };
48  }
49 
53  template<size_t Order, class Var, class F, class Real>
54  auto taylor_series(const F& f, Real a, Var)
56 } // namespace symbolic
auto taylor_series(const F &f, Real a, Var) -> STATOR_AUTORETURN(try_simplify(detail::TaylorSeriesWorker< 0, Order, Var >::eval(f, a)))
Generate a Taylor series representation of a Symbolic expression.
auto try_simplify(const T &a) -> decltype(detail::try_simplify_imp< Config >(a, detail::select_overload
A method to apply simplification only if it is available.
Definition: simplify.hpp:84
Symbolic representation of a variable.
Definition: symbolic.hpp:94
static Null eval(const Null &f, const Real &a)
Definition: taylor.hpp:45
C< 0 > Null
A symbolic representation of zero.
Definition: constants.hpp:51
A class representing a compile-time rational constant (i.e., std::ratio).
Definition: constants.hpp:31
Main header for the stator::symbolic library.
#define STATOR_AUTORETURN(EXPR)
A convenience Macro for defining auto return type functions.
Definition: config.hpp:51
The stator symbolic math library.
auto sub(BinaryOp< LHS, Op, RHS > f, Relation< Var, Arg > x) -> STATOR_AUTORETURN_BYVALUE(Op::apply(sub(f._l, x), sub(f._r, x)))
auto derivative(const Expression &)
Performs a symbolic derivative on the expression.
static Null eval(const Null &f, const Real &a)
Definition: taylor.hpp:30