Skip to content

Commit 5f61bdc

Browse files
authored
Merge pull request #38 from jcarpent/devel
Fix compatibility issue with Eigen 3.3.5
2 parents 2c23887 + 5369b63 commit 5f61bdc

File tree

4 files changed

+8
-69
lines changed

4 files changed

+8
-69
lines changed

cmake

include/eigenpy/exception.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014, Nicolas Mansard, LAAS-CNRS
2+
* Copyright 2014,2018 Nicolas Mansard and Justin Carpentier, LAAS-CNRS
33
*
44
* This file is part of eigenpy.
55
* eigenpy is free software: you can redistribute it and/or
@@ -18,8 +18,8 @@
1818
#include <exception>
1919
#include <string>
2020

21-
#ifndef __eigenpy_Exception_hpp__
22-
#define __eigenpy_Exception_hpp__
21+
#ifndef __eigenpy_exception_hpp__
22+
#define __eigenpy_exception_hpp__
2323

2424
namespace eigenpy
2525
{
@@ -30,7 +30,7 @@ namespace eigenpy
3030
{
3131
public:
3232
Exception() : message() {}
33-
Exception(std::string msg) : message(msg) {}
33+
Exception(const std::string & msg) : message(msg) {}
3434
const char *what() const throw()
3535
{
3636
return this->getMessage().c_str();
@@ -51,4 +51,4 @@ namespace eigenpy
5151

5252
} // namespace eigenpy
5353

54-
#endif // ifndef __eigenpy_Exception_hpp__
54+
#endif // ifndef __eigenpy_exception_hpp__

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)