Go to the documentation of this file.
10 #ifndef _mrpt_math_MatrixBlockSparseCols_H
11 #define _mrpt_math_MatrixBlockSparseCols_H
39 template <
typename Scalar,
int NROWS,
int NCOLS,
typename INFO,
bool HAS_REMAP,
40 typename INDEX_REMAP_MAP_IMPL =
41 mrpt::utils::map_as_vector<size_t, size_t>>
44 using matrix_t = Eigen::Matrix<Scalar, NROWS, NCOLS>;
73 inline const mrpt::utils::map_as_vector<size_t, size_t>&
76 if (!HAS_REMAP) assert(
false);
81 if (!HAS_REMAP) assert(
false);
88 const size_t idx =
cols.size();
99 return *
cols.rbegin();
127 const std::string& filename,
const bool force_symmetry =
false,
128 const bool is_col_compressed =
true)
const
131 getAsDense(D, force_symmetry, is_col_compressed);
132 return D.saveToTextFile(filename);
141 const bool is_col_compressed =
true)
const
143 const size_t nCols =
cols.size();
146 if (is_col_compressed)
147 D.setSize(nRows * NROWS, nCols * NCOLS);
149 D.setSize(nCols * NROWS, nRows * NCOLS);
151 for (
size_t j = 0; j < nCols; j++)
154 itRow !=
cols[j].end(); ++itRow)
156 const size_t row = itRow->first;
157 const size_t row_idx =
158 is_col_compressed ?
row * NROWS : j * NROWS;
159 const size_t col_idx =
160 is_col_compressed ? j * NCOLS :
row * NCOLS;
161 D.block(row_idx, col_idx, NROWS, NCOLS) = itRow->second.num;
162 if (force_symmetry && row_idx != col_idx)
163 D.block(col_idx, row_idx, NCOLS, NROWS) =
164 itRow->second.num.transpose();
174 const size_t nCols =
cols.size();
175 for (
size_t j = 0; j < nCols; j++)
177 itRow !=
cols[j].end(); ++itRow)
185 template <
class MATRIX>
188 const size_t nCols =
cols.size();
190 out.zeros(nRows, nCols);
191 for (
size_t j = 0; j < nCols; j++)
193 itRow !=
cols[j].end(); ++itRow)
195 const size_t row = itRow->first;
205 const size_t nC = o.
cols.size();
206 if (
cols.size() != nC)
210 for (
size_t i = 0; i < nC; i++)
214 it != o.
cols[i].end(); ++it)
215 cols[i][it->first].num = it->second.num;
221 for (
size_t i = 0; i < nC; i++)
227 while (it_src != o.
cols[i].end())
229 if (it_dst->first < it_src->first)
231 it_dst->second.num.setZero();
234 else if (it_dst->first > it_src->first)
236 cols[i][it_src->first].num = it_src->second.num;
241 it_dst->second.num = it_src->second.num;
255 #endif //_mrpt_math_MatrixBlockSparseCols_H
EIGEN_STRONG_INLINE iterator begin()
void clear()
Clear the contents of this container.
const mrpt::utils::map_as_vector< size_t, size_t > & getColInverseRemappedIndices() const
const Scalar * const_iterator
std::vector< size_t > col_remapped_indices
void setColCount(const size_t nCols)
Change the number of columns (keep old contents)
void copyNumericalValuesFrom(const MatrixBlockSparseCols< Scalar, NROWS, NCOLS, INFO, HAS_REMAP > &o)
Clear the current contents of this objects and replicates the sparse structure and numerical values o...
std::map< KEY, VALUE, std::less< KEY >, mrpt::aligned_allocator_cpp11< std::pair< const KEY, VALUE > >> aligned_std_map
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
mrpt::aligned_std_map< size_t, TEntry > col_t
Each compressed sparse column.
const col_t & getCol(const size_t idx) const
std::deque< col_t > cols
-> cols[i]: i'th column.
void saveToTextFileAsDense(const std::string &filename, const bool force_symmetry=false, const bool is_col_compressed=true) const
Builds a dense representation of the matrix and saves to a text file.
void getAsDense(mrpt::math::CMatrixDouble &D, const bool force_symmetry=false, const bool is_col_compressed=true) const
Builds a dense representation of the matrix and saves to a text file.
col_t & getCol(const size_t idx)
void getBinaryBlocksRepresentation(MATRIX &out) const
Builds a binary matrix with 1s where an elementary matrix is stored, 0s elsewhere.
A templated column-indexed efficient storage of block-sparse Jacobian or Hessian matrices,...
void keep_max(T &var, const K test_val)
If the second argument is above the first one, set the first argument to this higher value.
mrpt::utils::map_as_vector< size_t, size_t > col_inverse_remapped_indices
"remapped index" is the index of some global variable, interpreted by the external user of this class...
matrix_t num
Numeric matrix.
size_t cols() const
Get current number of cols.
col_t & appendCol(const size_t remapIndex)
Append one column, returning a ref to the new col_t data.
const std::vector< size_t > & getColRemappedIndices() const
GLenum GLenum GLvoid * row
size_t findCurrentNumberOfRows() const
Goes over all the columns and keep the largest column length.
void clearColEntries()
Clear all the entries in each column (do not change the number of columns, though!...
GLsizei const GLchar ** string
symbolic_t sym
Extra symbolic info.
void clearAll()
Clear all the entries in each column (do not change the number of columns, though!...
Eigen::Matrix< Scalar, NROWS, NCOLS > matrix_t
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST | |