1 | // This file is part of Eigen, a lightweight C++ template library |
---|
2 | // for linear algebra. |
---|
3 | // |
---|
4 | // Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr> |
---|
5 | // |
---|
6 | // This Source Code Form is subject to the terms of the Mozilla |
---|
7 | // Public License v. 2.0. If a copy of the MPL was not distributed |
---|
8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. |
---|
9 | |
---|
10 | #ifndef EIGEN_SPARSETRANSPOSE_H |
---|
11 | #define EIGEN_SPARSETRANSPOSE_H |
---|
12 | |
---|
13 | namespace Eigen { |
---|
14 | |
---|
15 | template<typename MatrixType> class TransposeImpl<MatrixType,Sparse> |
---|
16 | : public SparseMatrixBase<Transpose<MatrixType> > |
---|
17 | { |
---|
18 | typedef typename internal::remove_all<typename MatrixType::Nested>::type _MatrixTypeNested; |
---|
19 | public: |
---|
20 | |
---|
21 | EIGEN_SPARSE_PUBLIC_INTERFACE(Transpose<MatrixType>) |
---|
22 | |
---|
23 | class InnerIterator; |
---|
24 | class ReverseInnerIterator; |
---|
25 | |
---|
26 | inline Index nonZeros() const { return derived().nestedExpression().nonZeros(); } |
---|
27 | }; |
---|
28 | |
---|
29 | // NOTE: VC10 trigger an ICE if don't put typename TransposeImpl<MatrixType,Sparse>:: in front of Index, |
---|
30 | // a typedef typename TransposeImpl<MatrixType,Sparse>::Index Index; |
---|
31 | // does not fix the issue. |
---|
32 | // An alternative is to define the nested class in the parent class itself. |
---|
33 | template<typename MatrixType> class TransposeImpl<MatrixType,Sparse>::InnerIterator |
---|
34 | : public _MatrixTypeNested::InnerIterator |
---|
35 | { |
---|
36 | typedef typename _MatrixTypeNested::InnerIterator Base; |
---|
37 | public: |
---|
38 | |
---|
39 | EIGEN_STRONG_INLINE InnerIterator(const TransposeImpl& trans, typename TransposeImpl<MatrixType,Sparse>::Index outer) |
---|
40 | : Base(trans.derived().nestedExpression(), outer) |
---|
41 | {} |
---|
42 | inline typename TransposeImpl<MatrixType,Sparse>::Index row() const { return Base::col(); } |
---|
43 | inline typename TransposeImpl<MatrixType,Sparse>::Index col() const { return Base::row(); } |
---|
44 | }; |
---|
45 | |
---|
46 | template<typename MatrixType> class TransposeImpl<MatrixType,Sparse>::ReverseInnerIterator |
---|
47 | : public _MatrixTypeNested::ReverseInnerIterator |
---|
48 | { |
---|
49 | typedef typename _MatrixTypeNested::ReverseInnerIterator Base; |
---|
50 | public: |
---|
51 | |
---|
52 | EIGEN_STRONG_INLINE ReverseInnerIterator(const TransposeImpl& xpr, typename TransposeImpl<MatrixType,Sparse>::Index outer) |
---|
53 | : Base(xpr.derived().nestedExpression(), outer) |
---|
54 | {} |
---|
55 | inline typename TransposeImpl<MatrixType,Sparse>::Index row() const { return Base::col(); } |
---|
56 | inline typename TransposeImpl<MatrixType,Sparse>::Index col() const { return Base::row(); } |
---|
57 | }; |
---|
58 | |
---|
59 | } // end namespace Eigen |
---|
60 | |
---|
61 | #endif // EIGEN_SPARSETRANSPOSE_H |
---|