SparseTranspose.h
Go to the documentation of this file.
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 namespace Eigen { 
00029 
00030 template<typename MatrixType> class TransposeImpl<MatrixType,Sparse>
00031   : public SparseMatrixBase<Transpose<MatrixType> >
00032 {
00033     typedef typename internal::remove_all<typename MatrixType::Nested>::type _MatrixTypeNested;
00034   public:
00035 
00036     EIGEN_SPARSE_PUBLIC_INTERFACE(Transpose<MatrixType>)
00037 
00038     class InnerIterator;
00039     class ReverseInnerIterator;
00040 
00041     inline Index nonZeros() const { return derived().nestedExpression().nonZeros(); }
00042 };
00043 
00044 // NOTE: VC10 trigger an ICE if don't put typename TransposeImpl<MatrixType,Sparse>:: in front of Index,
00045 // a typedef typename TransposeImpl<MatrixType,Sparse>::Index Index;
00046 // does not fix the issue.
00047 // An alternative is to define the nested class in the parent class itself.
00048 template<typename MatrixType> class TransposeImpl<MatrixType,Sparse>::InnerIterator
00049   : public _MatrixTypeNested::InnerIterator
00050 {
00051     typedef typename _MatrixTypeNested::InnerIterator Base;
00052   public:
00053 
00054     EIGEN_STRONG_INLINE InnerIterator(const TransposeImpl& trans, typename TransposeImpl<MatrixType,Sparse>::Index outer)
00055       : Base(trans.derived().nestedExpression(), outer)
00056     {}
00057     inline typename TransposeImpl<MatrixType,Sparse>::Index row() const { return Base::col(); }
00058     inline typename TransposeImpl<MatrixType,Sparse>::Index col() const { return Base::row(); }
00059 };
00060 
00061 template<typename MatrixType> class TransposeImpl<MatrixType,Sparse>::ReverseInnerIterator
00062   : public _MatrixTypeNested::ReverseInnerIterator
00063 {
00064     typedef typename _MatrixTypeNested::ReverseInnerIterator Base;
00065   public:
00066 
00067     EIGEN_STRONG_INLINE ReverseInnerIterator(const TransposeImpl& xpr, typename TransposeImpl<MatrixType,Sparse>::Index outer)
00068       : Base(xpr.derived().nestedExpression(), outer)
00069     {}
00070     inline typename TransposeImpl<MatrixType,Sparse>::Index row() const { return Base::col(); }
00071     inline typename TransposeImpl<MatrixType,Sparse>::Index col() const { return Base::row(); }
00072 };
00073 
00074 } // end namespace Eigen
00075 
00076 #endif // EIGEN_SPARSETRANSPOSE_H