diff options
Diffstat (limited to 'Eigen/src/Sparse/SparseTranspose.h')
-rw-r--r-- | Eigen/src/Sparse/SparseTranspose.h | 43 |
1 files changed, 15 insertions, 28 deletions
diff --git a/Eigen/src/Sparse/SparseTranspose.h b/Eigen/src/Sparse/SparseTranspose.h index 9a702739d..b8c38617a 100644 --- a/Eigen/src/Sparse/SparseTranspose.h +++ b/Eigen/src/Sparse/SparseTranspose.h @@ -1,7 +1,7 @@ // This file is part of Eigen, a lightweight C++ template library // for linear algebra. // -// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr> +// Copyright (C) 2008-2009 Gael Guennebaud <g.gael@free.fr> // // Eigen is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -25,64 +25,51 @@ #ifndef EIGEN_SPARSETRANSPOSE_H #define EIGEN_SPARSETRANSPOSE_H -template<typename MatrixType> -struct ei_traits<SparseTranspose<MatrixType> > : ei_traits<Transpose<MatrixType> > -{}; - -template<typename MatrixType> class SparseTranspose - : public SparseMatrixBase<SparseTranspose<MatrixType> > +template<typename MatrixType> class TransposeImpl<MatrixType,Sparse> + : public SparseMatrixBase<Transpose<MatrixType> > { public: - EIGEN_GENERIC_PUBLIC_INTERFACE(SparseTranspose) + EIGEN_SPARSE_PUBLIC_INTERFACE(Transpose<MatrixType>) class InnerIterator; class ReverseInnerIterator; - inline SparseTranspose(const MatrixType& matrix) : m_matrix(matrix) {} - - //EIGEN_INHERIT_ASSIGNMENT_OPERATORS(SparseTranspose) - - inline int rows() const { return m_matrix.cols(); } - inline int cols() const { return m_matrix.rows(); } - inline int nonZeros() const { return m_matrix.nonZeros(); } + inline int nonZeros() const { return derived().nestedExpression().nonZeros(); } // FIXME should be keep them ? inline Scalar& coeffRef(int row, int col) - { return m_matrix.const_cast_derived().coeffRef(col, row); } + { return const_cast_derived().nestedExpression().coeffRef(col, row); } inline const Scalar coeff(int row, int col) const - { return m_matrix.coeff(col, row); } + { return derived().nestedExpression().coeff(col, row); } inline const Scalar coeff(int index) const - { return m_matrix.coeff(index); } + { return derived().nestedExpression().coeff(index); } inline Scalar& coeffRef(int index) - { return m_matrix.const_cast_derived().coeffRef(index); } - - protected: - const typename MatrixType::Nested m_matrix; + { return const_cast_derived().nestedExpression().coeffRef(index); } }; -template<typename MatrixType> class SparseTranspose<MatrixType>::InnerIterator : public MatrixType::InnerIterator +template<typename MatrixType> class TransposeImpl<MatrixType,Sparse>::InnerIterator : public MatrixType::InnerIterator { typedef typename MatrixType::InnerIterator Base; public: - EIGEN_STRONG_INLINE InnerIterator(const SparseTranspose& trans, int outer) - : Base(trans.m_matrix, outer) + EIGEN_STRONG_INLINE InnerIterator(const TransposeImpl& trans, int outer) + : Base(trans.derived().nestedExpression(), outer) {} inline int row() const { return Base::col(); } inline int col() const { return Base::row(); } }; -template<typename MatrixType> class SparseTranspose<MatrixType>::ReverseInnerIterator : public MatrixType::ReverseInnerIterator +template<typename MatrixType> class TransposeImpl<MatrixType,Sparse>::ReverseInnerIterator : public MatrixType::ReverseInnerIterator { typedef typename MatrixType::ReverseInnerIterator Base; public: - EIGEN_STRONG_INLINE ReverseInnerIterator(const SparseTranspose& xpr, int outer) - : Base(xpr.m_matrix, outer) + EIGEN_STRONG_INLINE ReverseInnerIterator(const TransposeImpl& xpr, int outer) + : Base(xpr.derived().nestedExpression(), outer) {} inline int row() const { return Base::col(); } inline int col() const { return Base::row(); } |