20 #if EIGEN_VERSION_AT_LEAST(3,1,0) // Requires Eigen>=3.1    21 #       include <Eigen/SparseCore>    22 #       include <Eigen/SparseQR>    31         COutputLogger(
"GMRF"),
    32         m_enable_profiler(false)
    91         Eigen::VectorXd & solved_x_inc,                 
    92         Eigen::VectorXd * solved_variances  
    99 #if EIGEN_VERSION_AT_LEAST(3,1,0)   103         solved_x_inc.setZero(
n);
   107         const size_t m = m1 + m2;
   113         std::vector<Eigen::Triplet<double> > A_tri;
   114         A_tri.reserve(m1 + 2 * m2);
   119         int edge_counter = 0;
   124                 const double w = std::sqrt(e->getInformation());
   126                 e->evalJacobian(dr_dx);
   127                 const int node_id = e->node_id;
   128                 A_tri.push_back(Eigen::Triplet<double>(edge_counter, node_id, 
w*dr_dx));
   130                 g[edge_counter] -= 
w*e->evaluateResidual();
   138                 const double w = std::sqrt(e->getInformation());
   139                 double dr_dxi, dr_dxj;
   140                 e->evalJacobian(dr_dxi, dr_dxj);
   141                 const int node_id_i = e->node_id_i, node_id_j = e->node_id_j;
   142                 A_tri.push_back(Eigen::Triplet<double>(edge_counter, node_id_i, 
w*dr_dxi));
   143                 A_tri.push_back(Eigen::Triplet<double>(edge_counter, node_id_j, 
w*dr_dxj));
   145                 g[edge_counter] -= 
w*e->evaluateResidual();
   153         Eigen::SparseMatrix<double> A(m, 
n);
   157                 A.setFromTriplets(A_tri.begin(), A_tri.end());
   163         Eigen::SparseQR<Eigen::SparseMatrix<double>, Eigen::COLAMDOrdering<int> > solver;
   168                 solved_x_inc = solver.solve(
g);
   173         if (solved_variances)
   177                 solved_variances->resize(
n);
   183                 MRPT_TODO(
"Use compressed access instead of coeff() below");
   185                 Eigen::SparseMatrix<double> UT = solver.matrixR();
   186                 Eigen::SparseMatrix<double> solved_covariance(
n,
n);
   187                 solved_covariance.reserve(UT.nonZeros());
   190                 const int show_progress_steps = std::max(
int(20), 
int(
n / 20));
   191                 for (
int l = 
n - 1; l >= 0; l--)
   193                         if (!(l % show_progress_steps))
   197                         double subSigmas = 0.0;
   198                         for (
size_t j = l + 1; j < 
n; j++)
   200                                 if (UT.coeff(l, j) != 0)
   206                                         for (
size_t i = l + 1; i <= j; i++)
   208                                                 if (UT.coeff(l, i) != 0)
   210                                                         sum += UT.coeff(l, i) * solved_covariance.coeff(i, j);
   214                                         for (
size_t i = j + 1; i < 
n; ++i)
   216                                                 if (UT.coeff(l, i) != 0)
   218                                                         sum += UT.coeff(l, i) * solved_covariance.coeff(j, i);
   222                                         solved_covariance.insert(l, j) = (-
sum / UT.coeff(l, l));
   223                                         subSigmas += UT.coeff(l, j) * solved_covariance.coeff(l, j);
   227                         solved_covariance.insert(l, l) = (1 / UT.coeff(l, l)) * (1 / UT.coeff(l, l) - subSigmas);
   232                 for (
unsigned int i = 0; i < 
n; i++)
   234                         const int idx = (int)solver.colsPermutation().indices().coeff(i);
   235                         const double variance = solved_covariance.coeff(i, i);
   236                         (*solved_variances)[idx] = variance;
 void initialize(const size_t nodeCount)
Initialize the GMRF internal state and copy the prior factors. 
 
Simple, scalar (1-dim) constraint (edge) for a GMRF. 
 
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL. 
 
bool eraseConstraint(const FactorBase &c)
Removes a constraint. Return true if found and deleted correctly. 
 
#define THROW_EXCEPTION(msg)
 
Abstract graph and tree data structures, plus generic graph algorithms. 
 
#define MRPT_LOG_DEBUG_FMT(_FMT_STRING,...)
 
std::deque< const BinaryFactorVirtualBase * > m_factors_binary
 
const_iterator find(const KEY &key) const
 
GLubyte GLubyte GLubyte GLubyte w
 
void enable(bool enabled=true)
 
std::deque< const UnaryFactorVirtualBase * > m_factors_unary
 
MRPT_TODO("Modify ping to run on Windows + Test this")
 
CONTAINER::Scalar sum(const CONTAINER &v)
Computes the sum of all the elements. 
 
mrpt::utils::CTimeLogger m_timelogger
 
#define MRPT_LOG_DEBUG(_STRING)
 
void addConstraint(const UnaryFactorVirtualBase &listOfConstraints)
Insert constraints into the GMRF problem. 
 
size_t m_numNodes
number of nodes in the graph 
 
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries. 
 
A safe way to call enter() and leave() of a mrpt::utils::CTimeLogger upon construction and destructio...
 
double leave(const char *func_name)
End of a named section. 
 
void updateEstimation(Eigen::VectorXd &solved_x_inc, Eigen::VectorXd *solved_variances=NULL)
 
void clear()
Reset state: remove all constraints and nodes. 
 
Simple, scalar (1-dim) constraint (edge) for a GMRF. 
 
void enter(const char *func_name)
Start of a named section. 
 
#define MRPT_LOG_DEBUG_STREAM(__CONTENTS)
 
#define ASSERTMSG_(f, __ERROR_MSG)