Main MRPT website > C++ reference
MRPT logo
sparse_hessian_update_numeric.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2015, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
10 #pragma once
11 
12 
13 namespace mrpt { namespace srba {
14 
15 /** Rebuild the Hessian symbolic information from the internal pointers to blocks of Jacobians.
16  * Only the upper triangle is filled-in (all what is needed for Cholesky) for square Hessians, in whole for rectangular ones (it depends on the symbolic decomposition, done elsewhere).
17  * \tparam SPARSEBLOCKHESSIAN can be: TSparseBlocksHessian_6x6, TSparseBlocksHessian_3x3 or TSparseBlocksHessian_6x3
18  * \return The number of Jacobian multiplications skipped due to its observation being marked as "invalid"
19  */
20 template <class KF2KF_POSE_TYPE,class LM_TYPE,class OBS_TYPE,class RBA_OPTIONS>
21 template <class SPARSEBLOCKHESSIAN>
23 {
24  size_t nInvalid = 0;
25  const size_t nUnknowns = H.getColCount();
26  for (size_t i=0;i<nUnknowns;i++)
27  {
28  typename SPARSEBLOCKHESSIAN::col_t & col = H.getCol(i);
29 
30  for (typename SPARSEBLOCKHESSIAN::col_t::iterator it=col.begin();it!=col.end();++it)
31  {
32  typename SPARSEBLOCKHESSIAN::TEntry & entry = it->second;
33 
34  // Compute: Hij = \Sum_k J_{ki}^t * \Lambda_k * J_{kj}
35 
36  typename SPARSEBLOCKHESSIAN::matrix_t Hij;
37  Hij.setZero();
38  //const size_t nJacobs = entry.sym.lst_jacob_blocks.size();
39  //for (size_t k=0;k<nJacobs;k++)
40  const typename SPARSEBLOCKHESSIAN::symbolic_t::list_jacob_blocks_t::const_iterator itJ_end = entry.sym.lst_jacob_blocks.end();
41  for (typename SPARSEBLOCKHESSIAN::symbolic_t::list_jacob_blocks_t::const_iterator itJ = entry.sym.lst_jacob_blocks.begin(); itJ!=itJ_end; ++itJ)
42  {
43  const typename SPARSEBLOCKHESSIAN::symbolic_t::THessianSymbolicInfoEntry & sym_k = *itJ;
44 
45  if (*sym_k.J1_valid && *sym_k.J2_valid)
46  {
47  // Accumulate Hessian sub-blocks:
48  RBA_OPTIONS::obs_noise_matrix_t::template accum_JtJ(Hij, *sym_k.J1, *sym_k.J2, sym_k.obs_idx, this->parameters.obs_noise );
49  }
50  else nInvalid++;
51  }
52 
53  // Do scaling (if applicable):
54  RBA_OPTIONS::obs_noise_matrix_t::template scale_H(Hij, this->parameters.obs_noise );
55 
56  entry.num = Hij;
57  }
58  }
59  return nInvalid;
60 } // end of sparse_hessian_update_numeric
61 
62 } } // end NS
size_t sparse_hessian_update_numeric(SPARSEBLOCKHESSIAN &H) const
Rebuild the Hessian symbolic information from the internal pointers to blocks of Jacobians.
Scalar * iterator
Definition: eigen_plugins.h:23
const Scalar * const_iterator
Definition: eigen_plugins.h:24
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.



Page generated by Doxygen 1.8.9.1 for MRPT 1.3.0 SVN: at Sun Sep 13 03:55:12 UTC 2015