Skip to content

Commit d10c154

Browse files
committed
[Preconditionner] The preconditionner has been fixed in Eigen 3.3.5
1 parent e34f13a commit d10c154

File tree

2 files changed

+2
-63
lines changed

2 files changed

+2
-63
lines changed

include/eigenpy/solvers/LeastSquaresConjugateGradient.hpp

Lines changed: 1 addition & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017, Justin Carpentier, LAAS-CNRS
2+
* Copyright 2017-2018, Justin Carpentier, LAAS-CNRS
33
*
44
* This file is part of eigenpy.
55
* eigenpy is free software: you can redistribute it and/or
@@ -22,67 +22,6 @@
2222

2323
#include "eigenpy/solvers/IterativeSolverBase.hpp"
2424

25-
namespace Eigen
26-
{
27-
template <typename _Scalar>
28-
class LeastSquareDiagonalPreconditionerFix
29-
: public LeastSquareDiagonalPreconditioner<_Scalar>
30-
{
31-
typedef _Scalar Scalar;
32-
typedef typename NumTraits<Scalar>::Real RealScalar;
33-
typedef LeastSquareDiagonalPreconditioner<_Scalar> Base;
34-
using DiagonalPreconditioner<_Scalar>::m_invdiag;
35-
public:
36-
37-
LeastSquareDiagonalPreconditionerFix() : Base() {}
38-
39-
template<typename MatType>
40-
explicit LeastSquareDiagonalPreconditionerFix(const MatType& mat) : Base()
41-
{
42-
compute(mat);
43-
}
44-
45-
template<typename MatType>
46-
LeastSquareDiagonalPreconditionerFix& analyzePattern(const MatType& )
47-
{
48-
return *this;
49-
}
50-
51-
template<typename MatType>
52-
LeastSquareDiagonalPreconditionerFix& factorize(const MatType& mat)
53-
{
54-
// Compute the inverse squared-norm of each column of mat
55-
m_invdiag.resize(mat.cols());
56-
if(MatType::IsRowMajor)
57-
{
58-
m_invdiag.setZero();
59-
for(Index j=0; j<mat.outerSize(); ++j)
60-
{
61-
for(typename MatType::InnerIterator it(mat,j); it; ++it)
62-
m_invdiag(it.index()) += numext::abs2(it.value());
63-
}
64-
for(Index j=0; j<mat.cols(); ++j)
65-
if(numext::real(m_invdiag(j))>RealScalar(0))
66-
m_invdiag(j) = RealScalar(1)/numext::real(m_invdiag(j));
67-
}
68-
else
69-
{
70-
for(Index j=0; j<mat.outerSize(); ++j)
71-
{
72-
RealScalar sum = mat.col(j).squaredNorm();
73-
if(sum>RealScalar(0))
74-
m_invdiag(j) = RealScalar(1)/sum;
75-
else
76-
m_invdiag(j) = RealScalar(1);
77-
}
78-
}
79-
Base::m_isInitialized = true;
80-
return *this;
81-
}
82-
83-
};
84-
}
85-
8625
namespace eigenpy
8726
{
8827

src/solvers/solvers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace eigenpy
3232
using namespace Eigen;
3333
ConjugateGradientVisitor< ConjugateGradient<MatrixXd,Lower|Upper> >::expose();
3434
#if EIGEN_VERSION_AT_LEAST(3,3,5)
35-
LeastSquaresConjugateGradientVisitor< LeastSquaresConjugateGradient<MatrixXd, LeastSquareDiagonalPreconditionerFix<MatrixXd::Scalar> > >::expose();
35+
LeastSquaresConjugateGradientVisitor< LeastSquaresConjugateGradient<MatrixXd, LeastSquareDiagonalPreconditioner<MatrixXd::Scalar> > >::expose();
3636
#endif
3737

3838
// Conjugate gradient with limited BFGS preconditioner

0 commit comments

Comments
 (0)