From d3cbb7f2bff33caabc6be8053f5d7e5ada43d2d1 Mon Sep 17 00:00:00 2001
From: Christoph Lehmann <christoph.lehmann@ufz.de>
Date: Thu, 18 Feb 2016 10:39:12 +0100
Subject: [PATCH] [NL] init -delta x

---
 NumLib/ODESolver/NonlinearSolver-impl.h | 8 +++++---
 NumLib/ODESolver/NonlinearSolver.h      | 2 +-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/NumLib/ODESolver/NonlinearSolver-impl.h b/NumLib/ODESolver/NonlinearSolver-impl.h
index 96d8f9f87ef..93283f85337 100644
--- a/NumLib/ODESolver/NonlinearSolver-impl.h
+++ b/NumLib/ODESolver/NonlinearSolver-impl.h
@@ -101,7 +101,10 @@ solve(NonlinearSystem<Matrix, Vector, NonlinearSolverTag::Newton> &sys, Vector &
 
     bool success = false;
 
-    // TODO init _minus_delta_x to right size and 0.0
+    // TODO be more efficient
+    // init _minus_delta_x to the right size and 0.0
+    BLAS::copy(x, _minus_delta_x);
+    _minus_delta_x.setZero();
 
     for (unsigned iteration=1; iteration<_maxiter; ++iteration)
     {
@@ -110,7 +113,7 @@ solve(NonlinearSystem<Matrix, Vector, NonlinearSolverTag::Newton> &sys, Vector &
 
         // std::cout << "  res:\n" << res << std::endl;
 
-        // TODO streamline the, make consistent with Picard.
+        // TODO streamline that, make consistent with Picard.
         if (norm(_res) < _tol) {
             success = true;
             break;
@@ -118,7 +121,6 @@ solve(NonlinearSystem<Matrix, Vector, NonlinearSolverTag::Newton> &sys, Vector &
 
         sys.assembleJacobian(x);
         sys.getJacobian(_J);
-        // TODO _minus_delta_x might not have been initialized
         sys.applyKnownComponentsNewton(_J, _res, _minus_delta_x);
 
         // std::cout << "  J:\n" << Eigen::MatrixXd(J) << std::endl;
diff --git a/NumLib/ODESolver/NonlinearSolver.h b/NumLib/ODESolver/NonlinearSolver.h
index 896e8d44107..0077fc3cf8f 100644
--- a/NumLib/ODESolver/NonlinearSolver.h
+++ b/NumLib/ODESolver/NonlinearSolver.h
@@ -84,7 +84,7 @@ private:
     Matrix _J;               //!< The Jacobian of the residual.
     Vector _minus_delta_x;   //!< The Newton-Raphson method solves the linearized equation
                              //!< \f$ J \cdot (-\Delta x) = r \f$ repeatedly.
-    double const _alpha = 1; //!< damping factor
+    double const _alpha = 1; //!< Damping factor. \todo Add constructor parameter.
 };
 
 
-- 
GitLab