mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-21 09:09:36 +08:00
fix SparseView: clean the nested matrix type
This commit is contained in:
parent
734469e43f
commit
fa6d36e0f7
@ -31,18 +31,23 @@ struct ei_traits<SparseView<MatrixType> > : ei_traits<MatrixType>
|
||||
{
|
||||
typedef int Index;
|
||||
typedef Sparse StorageKind;
|
||||
enum {
|
||||
Flags = int(ei_traits<MatrixType>::Flags) & (RowMajorBit)
|
||||
};
|
||||
};
|
||||
|
||||
template<typename MatrixType>
|
||||
class SparseView : public SparseMatrixBase<SparseView<MatrixType> >
|
||||
{
|
||||
typedef typename MatrixType::Nested MatrixTypeNested;
|
||||
typedef typename ei_cleantype<MatrixTypeNested>::type _MatrixTypeNested;
|
||||
public:
|
||||
EIGEN_SPARSE_PUBLIC_INTERFACE(SparseView)
|
||||
|
||||
SparseView(const MatrixType& mat, const Scalar& m_reference = Scalar(0),
|
||||
typename NumTraits<Scalar>::Real m_epsilon = NumTraits<Scalar>::dummy_precision()) :
|
||||
m_matrix(mat), m_reference(m_reference), m_epsilon(m_epsilon) {}
|
||||
|
||||
class InnerIterator;
|
||||
|
||||
inline Index rows() const { return m_matrix.rows(); }
|
||||
@ -58,10 +63,10 @@ protected:
|
||||
};
|
||||
|
||||
template<typename MatrixType>
|
||||
class SparseView<MatrixType>::InnerIterator : public MatrixTypeNested::InnerIterator
|
||||
class SparseView<MatrixType>::InnerIterator : public _MatrixTypeNested::InnerIterator
|
||||
{
|
||||
public:
|
||||
typedef typename MatrixTypeNested::InnerIterator IterBase;
|
||||
typedef typename _MatrixTypeNested::InnerIterator IterBase;
|
||||
InnerIterator(const SparseView& view, Index outer) :
|
||||
IterBase(view.m_matrix, outer), m_view(view)
|
||||
{
|
||||
|
@ -250,6 +250,13 @@ template<typename SparseMatrixType> void sparse_basic(const SparseMatrixType& re
|
||||
VERIFY(countTrueNonZero==m2.nonZeros());
|
||||
VERIFY_IS_APPROX(m2, refM2);
|
||||
}
|
||||
|
||||
// test sparseView
|
||||
{
|
||||
DenseMatrix refMat2 = DenseMatrix::Zero(rows, rows);
|
||||
SparseMatrixType m2(rows, rows);
|
||||
VERIFY_IS_APPROX(m2.eval(), refMat2.sparseView().eval());
|
||||
}
|
||||
}
|
||||
|
||||
void test_sparse_basic()
|
||||
|
Loading…
x
Reference in New Issue
Block a user