1#ifndef CHEMMISOL_HOMOTOPY_H
2#define CHEMMISOL_HOMOTOPY_H
12 const std::function<
X(
const X&)>& f;
13 const std::function<
X(
const X&)>& g;
17 const std::function<
X(
const X&)>& f,
18 const std::function<
X(
const X&)>& g)
22 X operator()(
const X& x) {
23 return typename X::value_type(1-t) * g(x)
24 +
typename X::value_type(t) * f(x);
28 template<
typename X,
typename M>
32 const std::function<
M(
const X&)>& df;
33 const std::function<
M(
const X&)>& dg;
37 const std::function<
M(
const X&)>& df,
38 const std::function<
M(
const X&)>& dg)
39 : t(t), df(df), dg(dg) {
42 M operator()(
const X& x) {
43 return typename X::value_type(1-t) * dg(x)
44 +
typename X::value_type(t) * df(x);
48 template<
typename X,
typename M>
52 std::function<
X(
const X&)> f;
53 std::function<
M(
const X&)> df;
54 std::function<
X(
const X&)> g;
55 std::function<
M(
const X&)> dg;
57 X solve_iter(
double t,
double delta_t,
const X& x, std::size_t n)
const;
61 const std::list<X>& x0,
62 std::function<
X(
const X&)> f,
63 std::function<
M(
const X&)> df,
64 std::function<
X(
const X&)> g,
65 std::function<
M(
const X&)> dg
67 x0(x0), f(f), df(df), g(g), dg(dg) {
70 std::list<X> solve_iter(std::size_t n)
const;
73 template<
typename X,
typename M>
76 for(
const auto& x : x0) {
78 results.push_back(solve_iter(delta, delta, x, n));
83 template<
typename X,
typename M>
84 X Homotopy<X, M>::solve_iter(
85 double t,
double delta_t,
const X& x, std::size_t n
87 CHEM_LOG(TRACE) <<
"[HOMOTOPY] Current X: " << x <<
" (t=" << t <<
")";
93 X xt = newton.solve_iter(n);
96 return solve_iter(t, delta_t, xt, n);
#define CHEM_LOG(LEVEL)
Definition logging.h:21
Definition chemmisol.h:31
std::array< T, N > X
Definition linear.h:26
std::array< std::array< T, P >, N > M
Definition linear.h:34