mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Cleaning and add more unit tests for Ref<SparseMatrix> and Map<SparseMatrix>
This commit is contained in:
@@ -408,6 +408,26 @@ template<typename SparseMatrixType> void sparse_basic(const SparseMatrixType& re
|
||||
m.setFromTriplets(triplets.begin(), triplets.end());
|
||||
VERIFY_IS_APPROX(m, refMat);
|
||||
}
|
||||
|
||||
// test Map
|
||||
{
|
||||
DenseMatrix refMat2(rows, cols), refMat3(rows, cols);
|
||||
SparseMatrixType m2(rows, cols), m3(rows, cols);
|
||||
initSparse<Scalar>(density, refMat2, m2);
|
||||
initSparse<Scalar>(density, refMat3, m3);
|
||||
{
|
||||
Map<SparseMatrixType> mapMat2(m2.rows(), m2.cols(), m2.nonZeros(), m2.outerIndexPtr(), m2.innerIndexPtr(), m2.valuePtr(), m2.innerNonZeroPtr());
|
||||
Map<SparseMatrixType> mapMat3(m3.rows(), m3.cols(), m3.nonZeros(), m3.outerIndexPtr(), m3.innerIndexPtr(), m3.valuePtr(), m3.innerNonZeroPtr());
|
||||
VERIFY_IS_APPROX(mapMat2+mapMat3, refMat2+refMat3);
|
||||
VERIFY_IS_APPROX(mapMat2+mapMat3, refMat2+refMat3);
|
||||
}
|
||||
{
|
||||
MappedSparseMatrix<Scalar,SparseMatrixType::Options,Index> mapMat2(m2.rows(), m2.cols(), m2.nonZeros(), m2.outerIndexPtr(), m2.innerIndexPtr(), m2.valuePtr(), m2.innerNonZeroPtr());
|
||||
MappedSparseMatrix<Scalar,SparseMatrixType::Options,Index> mapMat3(m3.rows(), m3.cols(), m3.nonZeros(), m3.outerIndexPtr(), m3.innerIndexPtr(), m3.valuePtr(), m3.innerNonZeroPtr());
|
||||
VERIFY_IS_APPROX(mapMat2+mapMat3, refMat2+refMat3);
|
||||
VERIFY_IS_APPROX(mapMat2+mapMat3, refMat2+refMat3);
|
||||
}
|
||||
}
|
||||
|
||||
// test triangularView
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user