Eigen  3.3.3
SparseTranspose.h
00001 // This file is part of Eigen, a lightweight C++ template library
00002 // for linear algebra.
00003 //
00004 // Copyright (C) 2008-2015 Gael Guennebaud <gael.guennebaud@inria.fr>
00005 //
00006 // This Source Code Form is subject to the terms of the Mozilla
00007 // Public License v. 2.0. If a copy of the MPL was not distributed
00008 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
00009 
00010 #ifndef EIGEN_SPARSETRANSPOSE_H
00011 #define EIGEN_SPARSETRANSPOSE_H
00012 
00013 namespace Eigen { 
00014 
00015 namespace internal {
00016   template<typename MatrixType,int CompressedAccess=int(MatrixType::Flags&CompressedAccessBit)>
00017   class SparseTransposeImpl
00018     : public SparseMatrixBase<Transpose<MatrixType> >
00019   {};
00020   
00021   template<typename MatrixType>
00022   class SparseTransposeImpl<MatrixType,CompressedAccessBit>
00023     : public SparseCompressedBase<Transpose<MatrixType> >
00024   {
00025     typedef SparseCompressedBase<Transpose<MatrixType> > Base;
00026   public:
00027     using Base::derived;
00028     typedef typename Base::Scalar Scalar;
00029     typedef typename Base::StorageIndex StorageIndex;
00030 
00031     inline Index nonZeros() const { return derived().nestedExpression().nonZeros(); }
00032     
00033     inline const Scalar* valuePtr() const { return derived().nestedExpression().valuePtr(); }
00034     inline const StorageIndex* innerIndexPtr() const { return derived().nestedExpression().innerIndexPtr(); }
00035     inline const StorageIndex* outerIndexPtr() const { return derived().nestedExpression().outerIndexPtr(); }
00036     inline const StorageIndex* innerNonZeroPtr() const { return derived().nestedExpression().innerNonZeroPtr(); }
00037 
00038     inline Scalar* valuePtr() { return derived().nestedExpression().valuePtr(); }
00039     inline StorageIndex* innerIndexPtr() { return derived().nestedExpression().innerIndexPtr(); }
00040     inline StorageIndex* outerIndexPtr() { return derived().nestedExpression().outerIndexPtr(); }
00041     inline StorageIndex* innerNonZeroPtr() { return derived().nestedExpression().innerNonZeroPtr(); }
00042   };
00043 }
00044   
00045 template<typename MatrixType> class TransposeImpl<MatrixType,Sparse>
00046   : public internal::SparseTransposeImpl<MatrixType>
00047 {
00048   protected:
00049     typedef internal::SparseTransposeImpl<MatrixType> Base;
00050 };
00051 
00052 namespace internal {
00053   
00054 template<typename ArgType>
00055 struct unary_evaluator<Transpose<ArgType>, IteratorBased>
00056   : public evaluator_base<Transpose<ArgType> >
00057 {
00058     typedef typename evaluator<ArgType>::InnerIterator        EvalIterator;
00059   public:
00060     typedef Transpose<ArgType> XprType;
00061     
00062     inline Index nonZerosEstimate() const {
00063       return m_argImpl.nonZerosEstimate();
00064     }
00065 
00066     class InnerIterator : public EvalIterator
00067     {
00068     public:
00069       EIGEN_STRONG_INLINE InnerIterator(const unary_evaluator& unaryOp, Index outer)
00070         : EvalIterator(unaryOp.m_argImpl,outer)
00071       {}
00072       
00073       Index row() const { return EvalIterator::col(); }
00074       Index col() const { return EvalIterator::row(); }
00075     };
00076     
00077     enum {
00078       CoeffReadCost = evaluator<ArgType>::CoeffReadCost,
00079       Flags = XprType::Flags
00080     };
00081     
00082     explicit unary_evaluator(const XprType& op) :m_argImpl(op.nestedExpression()) {}
00083 
00084   protected:
00085     evaluator<ArgType> m_argImpl;
00086 };
00087 
00088 } // end namespace internal
00089 
00090 } // end namespace Eigen
00091 
00092 #endif // EIGEN_SPARSETRANSPOSE_H
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends