10 #ifndef _mrpt_math_MatrixBlockSparseCols_H 11 #define _mrpt_math_MatrixBlockSparseCols_H 43 typedef Eigen::Matrix<Scalar,NROWS,NCOLS>
matrix_t;
75 const size_t idx =
cols.size();
86 return *
cols.rbegin();
113 const bool force_symmetry=
false,
114 const bool is_col_compressed =
true )
const 117 getAsDense(D,force_symmetry,is_col_compressed);
118 return D.saveToTextFile(filename);
126 const bool force_symmetry=
false,
127 const bool is_col_compressed =
true )
const 129 const size_t nCols =
cols.size();
132 if (is_col_compressed)
133 D.setSize(nRows*NROWS,nCols*NCOLS);
134 else D.setSize(nCols*NROWS,nRows*NCOLS);
136 for (
size_t j=0;j<nCols;j++)
140 const size_t row = itRow->first;
141 const size_t row_idx = is_col_compressed ?
row*NROWS : j*NROWS;
142 const size_t col_idx = is_col_compressed ? j*NCOLS :
row*NCOLS;
143 D.block(row_idx,col_idx, NROWS,NCOLS) = itRow->second.num;
144 if (force_symmetry && row_idx!=col_idx)
145 D.block(col_idx,row_idx, NCOLS,NROWS) = itRow->second.num.transpose();
154 const size_t nCols =
cols.size();
155 for (
size_t j=0;j<nCols;j++)
162 template <
class MATRIX>
165 const size_t nCols =
cols.size();
167 out.zeros(nRows,nCols);
168 for (
size_t j=0;j<nCols;j++)
171 const size_t row = itRow->first;
179 const size_t nC = o.
cols.size();
184 for (
size_t i=0;i<nC;i++)
188 cols[i][it->first].num = it->second.num;
194 for (
size_t i=0;i<nC;i++)
199 while (it_src!=o.
cols[i].end())
201 if (it_dst->first < it_src->first)
203 it_dst->second.num.setZero();
206 else if (it_dst->first > it_src->first)
208 cols[i][it_src->first].num = it_src->second.num;
213 it_dst->second.num = it_src->second.num;
227 #endif //_mrpt_math_MatrixBlockSparseCols_H mrpt::aligned_containers< size_t, TEntry >::map_t col_t
Each compressed sparse column.
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.
symbolic_t sym
Extra symbolic info.
void getBinaryBlocksRepresentation(MATRIX &out) const
Builds a binary matrix with 1s where an elementary matrix is stored, 0s elsewhere.
const col_t & getCol(const size_t idx) const
EIGEN_STRONG_INLINE iterator begin()
std::map< TYPE1, TYPE2, std::less< TYPE1 >, Eigen::aligned_allocator< std::pair< const TYPE1, TYPE2 > > > map_t
col_t & appendCol(const size_t remapIndex)
Append one column, returning a ref to the new col_t data.
const Scalar * const_iterator
void clear()
Clear the contents of this container.
void clear()
Clear the contents of this container.
matrix_t num
Numeric matrix.
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.
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...
const mrpt::utils::map_as_vector< size_t, size_t > & getColInverseRemappedIndices() const
void setColCount(const size_t nCols)
Change the number of columns (keep old contents)
GLsizei const GLchar ** string
std::deque< col_t > cols
-> cols[i]: i'th column.
A templated column-indexed efficient storage of block-sparse Jacobian or Hessian matrices, together with other arbitrary information.
size_t findCurrentNumberOfRows() const
Goes over all the columns and keep the largest column length.
col_t & getCol(const size_t idx)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void clearColEntries()
Clear all the entries in each column (do not change the number of columns, though!) ...
const std::vector< size_t > & getColRemappedIndices() const
GLenum GLenum GLvoid * row
Eigen::Matrix< Scalar, NROWS, NCOLS > matrix_t
void clearAll()
Clear all the entries in each column (do not change the number of columns, though!) ...
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::vector< size_t > col_remapped_indices
size_t getColCount() const
Get current number of cols.
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...