本文整理汇总了C++中eigen::Matrix::inv_fast方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix::inv_fast方法的具体用法?C++ Matrix::inv_fast怎么用?C++ Matrix::inv_fast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eigen::Matrix
的用法示例。
在下文中一共展示了Matrix::inv_fast方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: joint_pdf_metric
double joint_pdf_metric (
const CMatrixTemplateNumeric<T> &Z_observations_mean,
const CMatrixTemplateNumeric<T> &Y_predictions_mean,
const CMatrixTemplateNumeric<T> &Y_predictions_cov,
const TAuxDataRecursiveJCBB &info,
const TDataAssociationResults &aux_data)
{
MRPT_UNUSED_PARAM(aux_data);
// Make a list of the indices of the predictions that appear in "currentAssociation":
const size_t N = info.currentAssociation.size();
ASSERT_(N>0)
vector_size_t indices_pred(N); // Appearance order indices in the std::maps
vector_size_t indices_obs(N);
{
size_t i=0;
for (map<size_t,size_t>::const_iterator it=info.currentAssociation.begin();it!=info.currentAssociation.end();++it)
{
indices_obs[i] = it->first;
indices_pred[i] = it->second;
i++;
}
}
// ----------------------------------------------------------------------
// Extract submatrix of the covariances involved here:
// COV = PREDICTIONS_COV(INDX,INDX) + OBSERVATIONS_COV(INDX2,INDX2)
// ----------------------------------------------------------------------
Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic> COV;
Y_predictions_cov.extractSubmatrixSymmetricalBlocks(
info.length_O, // dims of cov. submatrices
indices_pred,
COV );
// ----------------------------------------------------------------------
// Mean:
// The same for the vector of "errors" or "innovation" between predictions and observations:
// ----------------------------------------------------------------------
Eigen::Matrix<T,Eigen::Dynamic,1> innovations(N * info.length_O);
T *dst_ptr= &innovations[0];
for (map<size_t,size_t>::const_iterator it=info.currentAssociation.begin();it!=info.currentAssociation.end();++it)
{
const T *pred_i_mean = Y_predictions_mean.get_unsafe_row( it->second );
const T *obs_i_mean = Z_observations_mean.get_unsafe_row( it->first );
for (unsigned int k=0;k<info.length_O;k++)
*dst_ptr++ = pred_i_mean[k]-obs_i_mean[k];
}
// Compute mahalanobis distance squared:
CMatrixTemplateNumeric<T> COV_inv;
COV.inv_fast(COV_inv);
const double d2 = mrpt::math::multiply_HCHt_scalar(innovations, COV_inv);
if (METRIC==metricMaha)
return d2;
ASSERT_(METRIC==metricML);
// Matching likelihood: The evaluation at 0 of the PDF of the difference between the two Gaussians:
const T cov_det = COV.det();
const double ml = exp(-0.5*d2) / ( std::pow(M_2PI, info.length_O * 0.5) * std::sqrt(cov_det) );
return ml;
}