Go to the documentation of this file.
22 template <
typename Scalar,
class Derived>
26 Derived&
mbDerived() {
return static_cast<Derived&
>(*this); }
29 return static_cast<const Derived&
>(*this);
37 for (
typename Derived::Index r = 0; r <
mbDerived().rows(); r++)
38 for (
typename Derived::Index c = 0; c <
mbDerived().cols(); c++)
53 const std::size_t N = diags.size();
55 for (std::size_t i = 0; i < N; i++)
mbDerived()(i, i) = diags[i];
67 Derived::RowsAtCompileTime > 0 && Derived::ColsAtCompileTime > 0,
68 "Identity() without arguments can be used only for fixed-size "
91 internalAssertEigenDefined<Derived>();
94 auto col(
int colIdx)
const
96 internalAssertEigenDefined<Derived>();
102 internalAssertEigenDefined<Derived>();
103 return mbDerived().asEigen().row(rowIdx);
105 auto row(
int rowIdx)
const
107 internalAssertEigenDefined<Derived>();
108 return mbDerived().asEigen().row(rowIdx);
111 template <
typename VECTOR_LIKE>
116 for (
typename Derived::Index i = 0; i <
mbDerived().cols(); i++)
119 template <
typename VECTOR_LIKE>
127 template <
typename VECTOR_LIKE>
132 for (
typename Derived::Index i = 0; i <
mbDerived().rows(); i++)
135 template <
typename VECTOR_LIKE>
164 bool chol(Derived& U)
const;
178 Derived& eVecs, std::vector<Scalar>& eVals,
bool sorted =
true)
const;
183 Derived& eVecs, std::vector<Scalar>& eVals,
bool sorted =
true)
const;
198 void removeColumns(
const std::vector<std::size_t>& idxsToRemove);
205 void removeRows(
const std::vector<std::size_t>& idxsToRemove);
209 template <
typename OTHERMATVEC>
211 const int row_start,
const int col_start,
const OTHERMATVEC& submat)
215 for (
int r = 0; r < submat.rows(); r++)
216 for (
int c = 0; c < submat.cols(); c++)
217 mbDerived()(r + row_start, c + col_start) = submat(r, c);
220 template <
typename OTHERMATVEC>
222 const int row_start,
const int col_start,
const OTHERMATVEC& submat)
226 for (
int r = 0; r < submat.cols(); r++)
227 for (
int c = 0; c < submat.rows(); c++)
228 mbDerived()(r + row_start, c + col_start) = submat(c, r);
232 template <
int BLOCK_ROWS,
int BLOCK_COLS>
234 int start_row = 0,
int start_col = 0)
const
236 return extractMatrix<BLOCK_ROWS, BLOCK_COLS>(start_row, start_col);
241 int start_row,
int start_col,
int BLOCK_ROWS,
int BLOCK_COLS)
const
243 return extractMatrix(start_row, start_col, BLOCK_ROWS, BLOCK_COLS);
246 template <
int BLOCK_ROWS,
int BLOCK_COLS>
248 const int start_row = 0,
const int start_col = 0)
const
254 for (
int r = 0; r < BLOCK_ROWS; r++)
255 for (
int c = 0; c < BLOCK_COLS; c++)
256 ret(r, c) =
mbDerived()(r + start_row, c + start_col);
261 const int BLOCK_ROWS,
const int BLOCK_COLS,
const int start_row,
262 const int start_col)
const
268 for (
int r = 0; r < BLOCK_ROWS; r++)
269 for (
int c = 0; c < BLOCK_COLS; c++)
270 ret(r, c) =
mbDerived()(r + start_row, c + start_col);
275 template <
typename MAT_A>
278 using Index =
typename Derived::Index;
279 const auto N =
A.rows(), Ninner =
A.cols();
281 for (Index r = 0; r < N; r++)
284 for (Index c = r; c < N; c++)
287 for (Index i = 0; i < Ninner; i++) s +=
A(r, i) *
A(c, i);
294 template <
typename MAT_A>
297 using Index =
typename Derived::Index;
298 const auto N =
A.cols(), Ninner =
A.rows();
300 for (Index r = 0; r < N; r++)
303 for (Index c = r; c < N; c++)
306 for (Index i = 0; i < Ninner; i++) s +=
A(i, r) *
A(i, c);
VECTOR_LIKE extractColumn(int colIdx) const
VECTOR_LIKE extractRow(int rowIdx) const
Scalar minimumDiagonal() const
Returns the minimum value in the diagonal.
Scalar trace() const
Returns the trace of the matrix (not necessarily square).
#define ASSERT_EQUAL_(__A, __B)
Assert comparing two values, reporting their actual values upon failure.
auto row(int rowIdx) const
CMatrixFixed< Scalar, BLOCK_ROWS, BLOCK_COLS > extractMatrix(const int start_row=0, const int start_col=0) const
Base CRTP class for all MRPT matrices.
void unsafeRemoveRows(const std::vector< std::size_t > &idxs)
Removes rows of the matrix.
bool eig_symmetric(Derived &eVecs, std::vector< Scalar > &eVals, bool sorted=true) const
Read: eig()
CMatrixDynamic< Scalar > blockCopy(int start_row, int start_col, int BLOCK_ROWS, int BLOCK_COLS) const
const blockCopy(): Returns a copy of the given block (non templated version, dynamic sizes)
void removeColumns(const std::vector< std::size_t > &idxsToRemove)
Removes columns of the matrix.
auto col(int colIdx) const
bool eig(Derived &eVecs, std::vector< Scalar > &eVals, bool sorted=true) const
Computes the eigenvectors and eigenvalues for a square, general matrix.
Derived inverse_LLt() const
Returns the inverse of a symmetric matrix using LLt.
void matProductOf_AB(const Derived &A, const Derived &B)
this = A*B, with A & B of the same type of this.
void extractRow(int rowIdx, VECTOR_LIKE &v) const
#define ASSERT_BELOW_(__A, __B)
Derived inverse() const
Returns the inverse of a general matrix using LU.
static Derived Identity()
A compile-time fixed-size numeric matrix container.
#define ASSERT_BELOWEQ_(__A, __B)
Scalar det() const
Determinant of matrix.
bool chol(Derived &U) const
Cholesky M=UT * U decomposition for symmetric matrix (upper-half of the matrix is actually ignored.
void matProductOf_AAt(const MAT_A &A)
this = A * AT
Base CRTP class for all MRPT vectors and matrices.
void setIdentity(const std::size_t N)
void insertMatrix(const int row_start, const int col_start, const OTHERMATVEC &submat)
Copies the given input submatrix/vector into this matrix/vector, starting at the given top-left coord...
void setDiagonal(const std::size_t N, const Scalar value)
Resize to NxN, set all entries to zero, except the main diagonal which is set to value
void matProductOf_AtA(const MAT_A &A)
this = AT * A
static Derived Identity(const std::size_t N)
void extractColumn(int colIdx, VECTOR_LIKE &v) const
Scalar maximumDiagonal() const
Returns the maximum value in the diagonal.
const Derived & mbDerived() const
#define ASSERTMSG_(f, __ERROR_MSG)
Defines an assertion mechanism.
CMatrixFixed< Scalar, BLOCK_ROWS, BLOCK_COLS > blockCopy(int start_row=0, int start_col=0) const
const blockCopy(): Returns a copy of the given block
void removeRows(const std::vector< std::size_t > &idxsToRemove)
Removes rows of the matrix.
CMatrixDynamic< Scalar > extractMatrix(const int BLOCK_ROWS, const int BLOCK_COLS, const int start_row, const int start_col) const
This base provides a set of functions for maths stuff.
int rank(Scalar threshold=0) const
Finds the rank of the matrix via LU decomposition.
void insertMatrixTransposed(const int row_start, const int col_start, const OTHERMATVEC &submat)
Like insertMatrix(), but inserts ‘submat’` (transposed)
void unsafeRemoveColumns(const std::vector< std::size_t > &idxs)
Removes columns of the matrix.
This template class provides the basic functionality for a general 2D any-size, resizable container o...
void setDiagonal(const std::vector< Scalar > &diags)
Resizes to NxN, with N the length of the input vector, set all entries to zero, except the main diago...
void setDiagonal(const Scalar value)
Set all entries to zero, except the main diagonal which is set to value
Page generated by Doxygen 1.8.17 for MRPT 2.0.4 at Sun Jul 19 17:54:30 UTC 2020 | |