From d10c1548da4b06b0c15b52e9af113bb155a711f0 Mon Sep 17 00:00:00 2001
From: Justin Carpentier <jcarpent@laas.fr>
Date: Wed, 29 Aug 2018 13:19:32 +0200
Subject: [PATCH] [Preconditionner] The preconditionner has been fixed in Eigen
 3.3.5

---
 .../solvers/LeastSquaresConjugateGradient.hpp | 63 +------------------
 src/solvers/solvers.cpp                       |  2 +-
 2 files changed, 2 insertions(+), 63 deletions(-)

diff --git a/include/eigenpy/solvers/LeastSquaresConjugateGradient.hpp b/include/eigenpy/solvers/LeastSquaresConjugateGradient.hpp
index 43957f1b..2d9e7617 100644
--- a/include/eigenpy/solvers/LeastSquaresConjugateGradient.hpp
+++ b/include/eigenpy/solvers/LeastSquaresConjugateGradient.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017, Justin Carpentier, LAAS-CNRS
+ * Copyright 2017-2018, Justin Carpentier, LAAS-CNRS
  *
  * This file is part of eigenpy.
  * eigenpy is free software: you can redistribute it and/or
@@ -22,67 +22,6 @@
 
 #include "eigenpy/solvers/IterativeSolverBase.hpp"
 
-namespace Eigen
-{
-  template <typename _Scalar>
-  class LeastSquareDiagonalPreconditionerFix
-  : public LeastSquareDiagonalPreconditioner<_Scalar>
-  {
-    typedef _Scalar Scalar;
-    typedef typename NumTraits<Scalar>::Real RealScalar;
-    typedef LeastSquareDiagonalPreconditioner<_Scalar> Base;
-    using DiagonalPreconditioner<_Scalar>::m_invdiag;
-  public:
-    
-    LeastSquareDiagonalPreconditionerFix() : Base() {}
-    
-    template<typename MatType>
-    explicit LeastSquareDiagonalPreconditionerFix(const MatType& mat) : Base()
-    {
-      compute(mat);
-    }
-    
-    template<typename MatType>
-    LeastSquareDiagonalPreconditionerFix& analyzePattern(const MatType& )
-    {
-      return *this;
-    }
-    
-    template<typename MatType>
-    LeastSquareDiagonalPreconditionerFix& factorize(const MatType& mat)
-    {
-      // Compute the inverse squared-norm of each column of mat
-      m_invdiag.resize(mat.cols());
-      if(MatType::IsRowMajor)
-      {
-        m_invdiag.setZero();
-        for(Index j=0; j<mat.outerSize(); ++j)
-        {
-          for(typename MatType::InnerIterator it(mat,j); it; ++it)
-            m_invdiag(it.index()) += numext::abs2(it.value());
-        }
-        for(Index j=0; j<mat.cols(); ++j)
-          if(numext::real(m_invdiag(j))>RealScalar(0))
-            m_invdiag(j) = RealScalar(1)/numext::real(m_invdiag(j));
-      }
-      else
-      {
-        for(Index j=0; j<mat.outerSize(); ++j)
-        {
-          RealScalar sum = mat.col(j).squaredNorm();
-          if(sum>RealScalar(0))
-            m_invdiag(j) = RealScalar(1)/sum;
-          else
-            m_invdiag(j) = RealScalar(1);
-        }
-      }
-      Base::m_isInitialized = true;
-      return *this;
-    }
-    
-  };
-}
-
 namespace eigenpy
 {
   
diff --git a/src/solvers/solvers.cpp b/src/solvers/solvers.cpp
index 8a30217d..1317b2dc 100644
--- a/src/solvers/solvers.cpp
+++ b/src/solvers/solvers.cpp
@@ -32,7 +32,7 @@ namespace eigenpy
     using namespace Eigen;
     ConjugateGradientVisitor< ConjugateGradient<MatrixXd,Lower|Upper> >::expose();
 #if EIGEN_VERSION_AT_LEAST(3,3,5)
-    LeastSquaresConjugateGradientVisitor< LeastSquaresConjugateGradient<MatrixXd, LeastSquareDiagonalPreconditionerFix<MatrixXd::Scalar> > >::expose();
+    LeastSquaresConjugateGradientVisitor< LeastSquaresConjugateGradient<MatrixXd, LeastSquareDiagonalPreconditioner<MatrixXd::Scalar> > >::expose();
 #endif
     
     // Conjugate gradient with limited BFGS preconditioner
-- 
GitLab