// the SUNDIALS::KINSOL class that are of type `std::function`, i.e.,
// they are objects to which we can assign a pointer to a function or,
// as we do here, a "lambda function" that takes the appropriate
- // arguments and returns the appropriate information. By convention,
- // KINSOL wants that functions doing something nontrivial return an
- // integer where zero indicates success. It turns out that we can do
- // all of this in just 25 lines of code.
+ // arguments and returns the appropriate information. It turns out
+ // that we can do all of this in just over 20 lines of code.
//
// (If you're not familiar what "lambda functions" are, take
// a look at step-12 or at the
[&](const Vector<double> &evaluation_point,
Vector<double> & residual) {
compute_residual(evaluation_point, residual);
-
- return 0;
};
nonlinear_solver.setup_jacobian =
[&](const Vector<double> ¤t_u,
const Vector<double> & /*current_f*/) {
compute_and_factorize_jacobian(current_u);
-
- return 0;
};
nonlinear_solver.solve_with_jacobian = [&](const Vector<double> &rhs,
Vector<double> & dst,
const double tolerance) {
this->solve(rhs, dst, tolerance);
-
- return 0;
};
nonlinear_solver.solve(current_solution);