72 const QSharedPointer<MatrixXd> matDistanceTable,
73 double (*interpolationFunction) (
double),
74 const double dCancelDist,
75 const QVector<int> &vecExcludeIndex)
78 if(matDistanceTable->rows() == 0 && matDistanceTable->cols() == 0) {
79 qDebug() <<
"[WARNING] Interpolation::createInterpolationMat - received an empty distance table.";
80 return QSharedPointer<SparseMatrix<float> >::create();
84 QSharedPointer<Eigen::SparseMatrix<float> > matInterpolationMatrix = QSharedPointer<SparseMatrix<float> >::create(matDistanceTable->rows(), vecProjectedSensors.size());
87 QVector<Triplet<float> > vecNonZeroEntries;
88 const qint32 iRows = matInterpolationMatrix->rows();
89 const qint32 iCols = matInterpolationMatrix->cols();
92 QSet<qint32> sensorLookup;
95 for(
const qint32& s : vecProjectedSensors){
96 if(!vecExcludeIndex.contains(idx)){
97 sensorLookup.insert(s);
103 for (qint32 r = 0; r < iRows; ++r) {
104 if (sensorLookup.contains(r) ==
false) {
107 QVector<QPair<qint32, float> > vecBelowThresh;
108 float dWeightsSum = 0.0;
109 const RowVectorXd& rowVec = matDistanceTable->row(r);
111 for (qint32 c = 0; c < iCols; ++c) {
112 const float dDist = rowVec[c];
114 if (dDist < dCancelDist) {
115 const float dValueWeight = std::fabs(1.0 / interpolationFunction(dDist));
116 dWeightsSum += dValueWeight;
117 vecBelowThresh.push_back(qMakePair(c, dValueWeight));
121 for (
const QPair<qint32, float> &qp : vecBelowThresh) {
122 vecNonZeroEntries.push_back(Eigen::Triplet<float> (r, qp.first, qp.second / dWeightsSum));
127 const int iIndexInSubset = vecProjectedSensors.indexOf(r);
129 vecNonZeroEntries.push_back(Eigen::Triplet<float> (r, iIndexInSubset, 1));
133 matInterpolationMatrix->setFromTriplets(vecNonZeroEntries.begin(), vecNonZeroEntries.end());
135 return matInterpolationMatrix;
static QSharedPointer< Eigen::SparseMatrix< float > > createInterpolationMat(const QVector< int > &vecProjectedSensors, const QSharedPointer< Eigen::MatrixXd > matDistanceTable, double(*interpolationFunction)(double), const double dCancelDist=FLOAT_INFINITY, const QVector< int > &vecExcludeIndex=QVector< int >())