SRBA: Sparser Relative Bundle Adjustment
srba/impl/sparse_hessian_update_numeric.h
00001 /* +---------------------------------------------------------------------------+
00002    |                     Mobile Robot Programming Toolkit (MRPT)               |
00003    |                          http://www.mrpt.org/                             |
00004    |                                                                           |
00005    | Copyright (c) 2005-2015, Individual contributors, see AUTHORS file        |
00006    | See: http://www.mrpt.org/Authors - All rights reserved.                   |
00007    | Released under BSD License. See details in http://www.mrpt.org/License    |
00008    +---------------------------------------------------------------------------+ */
00009 
00010 #pragma once
00011 
00012 
00013 namespace srba {
00014 
00020 template <class KF2KF_POSE_TYPE,class LM_TYPE,class OBS_TYPE,class RBA_OPTIONS>
00021 template <class SPARSEBLOCKHESSIAN>
00022 size_t RbaEngine<KF2KF_POSE_TYPE,LM_TYPE,OBS_TYPE,RBA_OPTIONS>::sparse_hessian_update_numeric( SPARSEBLOCKHESSIAN & H ) const
00023 {
00024     size_t nInvalid = 0;
00025     const size_t nUnknowns = H.getColCount();
00026     for (size_t i=0;i<nUnknowns;i++)
00027     {
00028         typename SPARSEBLOCKHESSIAN::col_t & col = H.getCol(i);
00029 
00030         for (typename SPARSEBLOCKHESSIAN::col_t::iterator it=col.begin();it!=col.end();++it)
00031         {
00032             typename SPARSEBLOCKHESSIAN::TEntry & entry = it->second;
00033 
00034             // Compute: Hij = \Sum_k  J_{ki}^t * \Lambda_k *  J_{kj}
00035 
00036             typename SPARSEBLOCKHESSIAN::matrix_t Hij;
00037             Hij.setZero();
00038             //const size_t nJacobs = entry.sym.lst_jacob_blocks.size();
00039             //for (size_t k=0;k<nJacobs;k++)
00040             const typename SPARSEBLOCKHESSIAN::symbolic_t::list_jacob_blocks_t::const_iterator itJ_end = entry.sym.lst_jacob_blocks.end();
00041             for (typename SPARSEBLOCKHESSIAN::symbolic_t::list_jacob_blocks_t::const_iterator itJ = entry.sym.lst_jacob_blocks.begin(); itJ!=itJ_end; ++itJ)
00042             {
00043                 const typename SPARSEBLOCKHESSIAN::symbolic_t::THessianSymbolicInfoEntry & sym_k = *itJ;
00044 
00045                 if (*sym_k.J1_valid && *sym_k.J2_valid)
00046                 {
00047                     // Accumulate Hessian sub-blocks:
00048                     RBA_OPTIONS::obs_noise_matrix_t::template accum_JtJ(Hij, *sym_k.J1, *sym_k.J2, sym_k.obs_idx, this->parameters.obs_noise );
00049                 }
00050                 else nInvalid++;
00051             }
00052 
00053             // Do scaling (if applicable):
00054             RBA_OPTIONS::obs_noise_matrix_t::template scale_H(Hij, this->parameters.obs_noise );
00055 
00056             entry.num = Hij;
00057         }
00058     }
00059     return nInvalid;
00060 } // end of sparse_hessian_update_numeric
00061 
00062 } // end NS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends