00001 // This file is part of Eigen, a lightweight C++ template library 00002 // for linear algebra. 00003 // 00004 // Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr> 00005 // 00006 // Eigen is free software; you can redistribute it and/or 00007 // modify it under the terms of the GNU Lesser General Public 00008 // License as published by the Free Software Foundation; either 00009 // version 3 of the License, or (at your option) any later version. 00010 // 00011 // Alternatively, you can redistribute it and/or 00012 // modify it under the terms of the GNU General Public License as 00013 // published by the Free Software Foundation; either version 2 of 00014 // the License, or (at your option) any later version. 00015 // 00016 // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY 00017 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00018 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the 00019 // GNU General Public License for more details. 00020 // 00021 // You should have received a copy of the GNU Lesser General Public 00022 // License and a copy of the GNU General Public License along with 00023 // Eigen. If not, see <http://www.gnu.org/licenses/>. 00024 00025 #ifndef EIGEN_SPARSETRANSPOSE_H 00026 #define EIGEN_SPARSETRANSPOSE_H 00027 00028 template<typename MatrixType> class TransposeImpl<MatrixType,Sparse> 00029 : public SparseMatrixBase<Transpose<MatrixType> > 00030 { 00031 typedef typename internal::remove_all<typename MatrixType::Nested>::type _MatrixTypeNested; 00032 public: 00033 00034 EIGEN_SPARSE_PUBLIC_INTERFACE(Transpose<MatrixType>) 00035 00036 class InnerIterator; 00037 class ReverseInnerIterator; 00038 00039 inline Index nonZeros() const { return derived().nestedExpression().nonZeros(); } 00040 }; 00041 00042 template<typename MatrixType> class TransposeImpl<MatrixType,Sparse>::InnerIterator 00043 : public _MatrixTypeNested::InnerIterator 00044 { 00045 typedef typename _MatrixTypeNested::InnerIterator Base; 00046 public: 00047 00048 EIGEN_STRONG_INLINE InnerIterator(const TransposeImpl& trans, Index outer) 00049 : Base(trans.derived().nestedExpression(), outer) 00050 {} 00051 inline Index row() const { return Base::col(); } 00052 inline Index col() const { return Base::row(); } 00053 }; 00054 00055 template<typename MatrixType> class TransposeImpl<MatrixType,Sparse>::ReverseInnerIterator 00056 : public _MatrixTypeNested::ReverseInnerIterator 00057 { 00058 typedef typename _MatrixTypeNested::ReverseInnerIterator Base; 00059 public: 00060 00061 EIGEN_STRONG_INLINE ReverseInnerIterator(const TransposeImpl& xpr, Index outer) 00062 : Base(xpr.derived().nestedExpression(), outer) 00063 {} 00064 inline Index row() const { return Base::col(); } 00065 inline Index col() const { return Base::row(); } 00066 }; 00067 00068 #endif // EIGEN_SPARSETRANSPOSE_H