Eigen  3.2.91
SparseTranspose.h
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2008-2015 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 namespace internal {
16  template<typename MatrixType,int CompressedAccess=int(MatrixType::Flags&CompressedAccessBit)>
17  class SparseTransposeImpl
18  : public SparseMatrixBase<Transpose<MatrixType> >
19  {};
20 
21  template<typename MatrixType>
22  class SparseTransposeImpl<MatrixType,CompressedAccessBit>
23  : public SparseCompressedBase<Transpose<MatrixType> >
24  {
25  typedef SparseCompressedBase<Transpose<MatrixType> > Base;
26  public:
27  using Base::derived;
28  typedef typename Base::Scalar Scalar;
29  typedef typename Base::StorageIndex StorageIndex;
30 
31  inline const Scalar* valuePtr() const { return derived().nestedExpression().valuePtr(); }
32  inline const StorageIndex* innerIndexPtr() const { return derived().nestedExpression().innerIndexPtr(); }
33  inline const StorageIndex* outerIndexPtr() const { return derived().nestedExpression().outerIndexPtr(); }
34  inline const StorageIndex* innerNonZeroPtr() const { return derived().nestedExpression().innerNonZeroPtr(); }
35 
36  inline Scalar* valuePtr() { return derived().nestedExpression().valuePtr(); }
37  inline StorageIndex* innerIndexPtr() { return derived().nestedExpression().innerIndexPtr(); }
38  inline StorageIndex* outerIndexPtr() { return derived().nestedExpression().outerIndexPtr(); }
39  inline StorageIndex* innerNonZeroPtr() { return derived().nestedExpression().innerNonZeroPtr(); }
40  };
41 }
42 
43 template<typename MatrixType> class TransposeImpl<MatrixType,Sparse>
44  : public internal::SparseTransposeImpl<MatrixType>
45 {
46  protected:
47  typedef internal::SparseTransposeImpl<MatrixType> Base;
48 };
49 
50 namespace internal {
51 
52 template<typename ArgType>
53 struct unary_evaluator<Transpose<ArgType>, IteratorBased>
54  : public evaluator_base<Transpose<ArgType> >
55 {
56  typedef typename evaluator<ArgType>::InnerIterator EvalIterator;
57  typedef typename evaluator<ArgType>::ReverseInnerIterator EvalReverseIterator;
58  public:
59  typedef Transpose<ArgType> XprType;
60 
61  inline Index nonZerosEstimate() const {
62  return m_argImpl.nonZerosEstimate();
63  }
64 
65  class InnerIterator : public EvalIterator
66  {
67  public:
68  EIGEN_STRONG_INLINE InnerIterator(const unary_evaluator& unaryOp, Index outer)
69  : EvalIterator(unaryOp.m_argImpl,outer)
70  {}
71 
72  Index row() const { return EvalIterator::col(); }
73  Index col() const { return EvalIterator::row(); }
74  };
75 
76  class ReverseInnerIterator : public EvalReverseIterator
77  {
78  public:
79  EIGEN_STRONG_INLINE ReverseInnerIterator(const unary_evaluator& unaryOp, Index outer)
80  : EvalReverseIterator(unaryOp.m_argImpl,outer)
81  {}
82 
83  Index row() const { return EvalReverseIterator::col(); }
84  Index col() const { return EvalReverseIterator::row(); }
85  };
86 
87  enum {
88  CoeffReadCost = evaluator<ArgType>::CoeffReadCost,
89  Flags = XprType::Flags
90  };
91 
92  explicit unary_evaluator(const XprType& op) :m_argImpl(op.nestedExpression()) {}
93 
94  protected:
95  evaluator<ArgType> m_argImpl;
96 };
97 
98 } // end namespace internal
99 
100 } // end namespace Eigen
101 
102 #endif // EIGEN_SPARSETRANSPOSE_H
const unsigned int CompressedAccessBit
Definition: Constants.h:177
Definition: LDLT.h:16
Derived & derived()
Definition: EigenBase.h:44
Definition: Eigen_Colamd.h:54