MOAB
4.9.3pre
|
00001 // This file is part of Eigen, a lightweight C++ template library 00002 // for linear algebra. 00003 // 00004 // Copyright (C) 2008-2015 Gael Guennebaud <[email protected]> 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 typedef typename evaluator<ArgType>::ReverseInnerIterator EvalReverseIterator; 00060 public: 00061 typedef Transpose<ArgType> XprType; 00062 00063 inline Index nonZerosEstimate() const { 00064 return m_argImpl.nonZerosEstimate(); 00065 } 00066 00067 class InnerIterator : public EvalIterator 00068 { 00069 public: 00070 EIGEN_STRONG_INLINE InnerIterator(const unary_evaluator& unaryOp, Index outer) 00071 : EvalIterator(unaryOp.m_argImpl,outer) 00072 {} 00073 00074 Index row() const { return EvalIterator::col(); } 00075 Index col() const { return EvalIterator::row(); } 00076 }; 00077 00078 class ReverseInnerIterator : public EvalReverseIterator 00079 { 00080 public: 00081 EIGEN_STRONG_INLINE ReverseInnerIterator(const unary_evaluator& unaryOp, Index outer) 00082 : EvalReverseIterator(unaryOp.m_argImpl,outer) 00083 {} 00084 00085 Index row() const { return EvalReverseIterator::col(); } 00086 Index col() const { return EvalReverseIterator::row(); } 00087 }; 00088 00089 enum { 00090 CoeffReadCost = evaluator<ArgType>::CoeffReadCost, 00091 Flags = XprType::Flags 00092 }; 00093 00094 explicit unary_evaluator(const XprType& op) :m_argImpl(op.nestedExpression()) {} 00095 00096 protected: 00097 evaluator<ArgType> m_argImpl; 00098 }; 00099 00100 } // end namespace internal 00101 00102 } // end namespace Eigen 00103 00104 #endif // EIGEN_SPARSETRANSPOSE_H