Skip to content
Snippets Groups Projects
Commit ce910d61 authored by Norihiro Watanabe's avatar Norihiro Watanabe
Browse files

rename template parameter names and add documententation

parent 23dcafc6
No related branches found
No related tags found
No related merge requests found
......@@ -27,8 +27,8 @@ Picard::Picard()
{
}
template<class F_PROBLEM, class T_VALUE>
bool Picard::solve(F_PROBLEM &g, const T_VALUE &x0, T_VALUE &x_new)
template<class T_FUNCTOR, class T_VALUE>
bool Picard::solve(T_FUNCTOR &functor, const T_VALUE &x0, T_VALUE &x_new)
{
T_VALUE x_old(x0);
T_VALUE dx(x0);
......@@ -45,7 +45,7 @@ bool Picard::solve(F_PROBLEM &g, const T_VALUE &x0, T_VALUE &x_new)
double abs_error = -1.;
double rel_error = -1.;
for (itr_cnt=0; itr_cnt<_max_itr; itr_cnt++) {
g(x_old, x_new);
functor(x_old, x_new);
dx = x_new;
dx -= x_old;
......
......@@ -49,13 +49,21 @@ public:
/**
* solve a nonlinear problem
*
* \param g Fixed point function object (x=g(x))
* \tparam T_FUNCTOR Function object type which supports an
* operator ()(\f$x_k\f$, \f$x_{k+1}\f$). \f$x_k\f$ is a previous iteration
* step value. \f$x_{k+1}\f$ is a new solution.
* \tparam T_VALUE Data type of \f$x_k\f$ and \f$x_{k+1}\f$.
* Both scalar and vector types are available as far as the following conditions
* are satisfied
* - T_VALUE has a copy constructor (for non-primitive data types)
* - MathLib::norm(T_VALUE) exists
* \param functor Fixed point function object (\f$x_{k+1}=g(x_k)\f$)
* \param x0 Initial guess
* \param x_new Solution
* \return true if converged
*/
template<class F_PROBLEM, class T_VALUE>
bool solve(F_PROBLEM &g, const T_VALUE &x0, T_VALUE &x_new);
template<class T_FUNCTOR, class T_VALUE>
bool solve(T_FUNCTOR &functor, const T_VALUE &x0, T_VALUE &x_new);
/// return the number of iterations
std::size_t getNIterations() const {return _n_iterations; }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment