Go to the documentation of this file.
38 typename Scalar,
int NROWS,
int NCOLS,
typename INFO,
bool HAS_REMAP,
39 typename INDEX_REMAP_MAP_IMPL =
55 using col_t = std::map<size_t, TEntry>;
76 if (!HAS_REMAP) assert(
false);
81 if (!HAS_REMAP) assert(
false);
88 const size_t idx =
m_cols.size();
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);
141 const bool is_col_compressed =
true)
const
143 const size_t nCols =
m_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++)
153 for (
typename col_t::const_iterator itRow =
m_cols[j].
begin();
154 itRow !=
m_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 =
m_cols.size();
175 for (
size_t j = 0; j < nCols; j++)
176 for (
typename col_t::const_iterator itRow =
m_cols[j].
begin();
177 itRow !=
m_cols[j].end(); ++itRow)
185 template <
class MATRIX>
188 const size_t nCols =
m_cols.size();
190 out.setZero(nRows, nCols);
191 for (
size_t j = 0; j < nCols; j++)
192 for (
typename col_t::const_iterator itRow =
m_cols[j].
begin();
193 itRow !=
m_cols[j].end(); ++itRow)
195 const size_t row = itRow->first;
205 const size_t nC = o.
m_cols.size();
210 for (
size_t i = 0; i < nC; i++)
213 for (
typename col_t::const_iterator it = o.
m_cols[i].begin();
214 it != o.
m_cols[i].end(); ++it)
215 m_cols[i][it->first].num = it->second.num;
221 for (
size_t i = 0; i < nC; i++)
225 typename col_t::iterator it_dst =
m_cols[i].begin();
226 typename col_t::const_iterator it_src = o.
m_cols[i].begin();
227 while (it_src != o.
m_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 m_cols[i][it_src->first].num = it_src->second.num;
241 it_dst->second.num = it_src->second.num;
std::map< size_t, TEntry > col_t
Each compressed sparse column.
void clear()
Clear the contents of this container.
std::vector< size_t > col_remapped_indices
std::deque< col_t > m_cols
-> cols[i]: i'th column.
void setColCount(const size_t nCols)
Change the number of columns (keep old contents)
void setSize(size_t row, size_t col, bool zeroNewElements=false)
Changes the size of matrix, maintaining the previous 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...
mrpt::vision::TStereoCalibResults out
mrpt::containers::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 col_t & getCol(const size_t idx) const
const mrpt::containers::map_as_vector< size_t, size_t > & getColInverseRemappedIndices() const
const_iterator begin() const
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 clear()
Clear the contents of this container.
matrix_t num
Numeric matrix.
auto block(int start_row, int start_col)
non-const block(): Returns an Eigen::Block reference to the block
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.
void saveToTextFile(const std::string &file, mrpt::math::TMatrixTextFileFormat fileFormat=mrpt::math::MATRIX_FORMAT_ENG, bool appendMRPTHeader=false, const std::string &userHeader=std::string()) const
Saves the vector/matrix to a file compatible with MATLAB/Octave text format.
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
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!...
This base provides a set of functions for maths stuff.
symbolic_t sym
Extra symbolic info.
void clearAll()
Clear all the entries in each column (do not change the number of columns, though!...
Page generated by Doxygen 1.8.17 for MRPT 2.0.4 at Sun Jul 19 15:15:43 UTC 2020 | |