Skip to content
Snippets Groups Projects
Unverified Commit 5f61bdc6 authored by Justin Carpentier's avatar Justin Carpentier Committed by GitHub
Browse files

Merge pull request #38 from jcarpent/devel

Fix compatibility issue with Eigen 3.3.5
parents 2c238879 5369b63e
No related branches found
No related tags found
No related merge requests found
Pipeline #5440 passed with warnings
Subproject commit 7fc695158a31cd57f2c389b6964ec104b3284467
Subproject commit 52d25e05c3b5dfd70c79b3e75787fdc78c6f695e
/*
* Copyright 2014, Nicolas Mansard, LAAS-CNRS
* Copyright 2014,2018 Nicolas Mansard and Justin Carpentier, LAAS-CNRS
*
* This file is part of eigenpy.
* eigenpy is free software: you can redistribute it and/or
......@@ -18,8 +18,8 @@
#include <exception>
#include <string>
#ifndef __eigenpy_Exception_hpp__
#define __eigenpy_Exception_hpp__
#ifndef __eigenpy_exception_hpp__
#define __eigenpy_exception_hpp__
namespace eigenpy
{
......@@ -30,7 +30,7 @@ namespace eigenpy
{
public:
Exception() : message() {}
Exception(std::string msg) : message(msg) {}
Exception(const std::string & msg) : message(msg) {}
const char *what() const throw()
{
return this->getMessage().c_str();
......@@ -51,4 +51,4 @@ namespace eigenpy
} // namespace eigenpy
#endif // ifndef __eigenpy_Exception_hpp__
#endif // ifndef __eigenpy_exception_hpp__
/*
* 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
{
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment