Go to the documentation of this file.
12 #include <CTraitsTest.h>
13 #include <gtest/gtest.h>
19 template class mrpt::CTraitsTest<mrpt::math::CSparseMatrix>;
29 for (
size_t i = 0; i < nEntries; i++)
51 EXPECT_TRUE(dense_out == dense1) <<
"Failed with N=" << N <<
"\n";
54 TEST(SparseMatrix, InitFromDenseUnit)
68 EXPECT_TRUE(dense_out == dense1) <<
"Failed with N=" << N <<
"\n";
71 TEST(SparseMatrix, InitFromDenseRandom)
78 TEST(SparseMatrix, InitFromTriplet)
99 EXPECT_TRUE(dense_out1 == dense_out2);
102 TEST(SparseMatrix, InitFromSparse)
115 EXPECT_TRUE(dense_out == D) <<
"Dense: \n"
117 << dense_out << endl;
120 TEST(SparseMatrix, InitFromRandom)
133 size_t nRows1,
size_t nCols1,
size_t nNonZeros1,
size_t nRows2,
142 (*op1)(SM1, SM2, SM_res);
153 const double err = (RES - Dres).array().abs().maxCoeff();
155 EXPECT_TRUE(err < 1e-10) <<
"M1:\n"
157 << D2 <<
"Real op result:\n"
158 << RES <<
"SM result:\n"
194 TEST(SparseMatrix, Op_Multiply_AB)
208 TEST(SparseMatrix, CholeskyDecomp)
233 const double err = ((Ud.transpose()) - L).array().abs().mean();
234 EXPECT_TRUE(err < 1e-8);
void do_test_init_random(size_t N)
void op_sparse_multiply_AB(const CSparseMatrix &M1, const CSparseMatrix &M2, CSparseMatrix &res)
void op_dense_add(const CMatrixDouble &M1, const CMatrixDouble &M2, CMatrixDouble &res)
void insert_submatrix(const size_t row, const size_t col, const MATRIX &M)
ONLY for TRIPLET matrices: insert a given matrix (in any of the MRPT formats) at a given location of ...
void compressFromTriplet()
ONLY for TRIPLET matrices: convert the matrix in a column-compressed form.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void(*)(const CMatrixDouble &M1, const CMatrixDouble &M2, CMatrixDouble &res) TMatrixDenseOperator
MATRIX drawDefinitePositiveMatrix(const size_t dim, const double std_scale=1.0, const double diagonal_epsilon=1e-8)
Generates a random definite-positive matrix of the given size, using the formula C = v*v^t + epsilon*...
void clear(const size_t nRows=1, const size_t nCols=1)
Erase all previous contents and leave the matrix as a "triplet" ROWS x COLS matrix without any nonzer...
void do_matrix_op_test(size_t nRows1, size_t nCols1, size_t nNonZeros1, size_t nRows2, size_t nCols2, size_t nNonZeros2, TMatrixSMOperator op1, TMatrixDenseOperator op2)
void do_test_init_to_unit(size_t N)
void(*)(const CSparseMatrix &M1, const CSparseMatrix &M2, CSparseMatrix &res) TMatrixSMOperator
A sparse matrix container (with cells of any type), with iterators.
void generateRandomSparseMatrix(size_t N, size_t M, size_t nEntries, CSparseMatrix &MAT)
CMatrixDouble get_L() const
Return the L matrix (L*L' = M), as a dense matrix.
CRandomGenerator & getRandomGenerator()
A static instance of a CRandomGenerator class, for use in single-thread applications.
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
void setColCount(const size_t nCols)
This base provides a set of functions for maths stuff.
void get_dense(CMatrixDouble &outMat) const
Return a dense representation of the sparse matrix.
void op_dense_multiply_AB(const CMatrixDouble &M1, const CMatrixDouble &M2, CMatrixDouble &res)
void setRowCount(const size_t nRows)
Change the number of rows in the matrix (can't be lower than current size)
void op_sparse_add(const CSparseMatrix &M1, const CSparseMatrix &M2, CSparseMatrix &res)
TEST(SparseMatrix, InitFromDenseUnit)
void insert_entry(const size_t row, const size_t col, const double val)
@ Access the matrix, get, set elements, etc.
Auxiliary class to hold the results of a Cholesky factorization of a sparse matrix.
void drawGaussian1DMatrix(MAT &matrix, const double mean=0, const double std=1)
Fills the given matrix with independent, 1D-normally distributed samples.
A sparse matrix structure, wrapping 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 | |