SparseTranspose.h
Go to the documentation of this file.
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 // IWYU pragma: private
14 #include "./InternalHeaderCheck.h"
15 
16 namespace Eigen {
17 
18 namespace internal {
19 template <typename MatrixType, int CompressedAccess = int(MatrixType::Flags & CompressedAccessBit)>
20 class SparseTransposeImpl : public SparseMatrixBase<Transpose<MatrixType> > {};
21 
22 template <typename MatrixType>
23 class SparseTransposeImpl<MatrixType, CompressedAccessBit> : public SparseCompressedBase<Transpose<MatrixType> > {
25 
26  public:
27  using Base::derived;
28  typedef typename Base::Scalar Scalar;
29  typedef typename Base::StorageIndex StorageIndex;
30 
31  inline Index nonZeros() const { return derived().nestedExpression().nonZeros(); }
32 
33  inline const Scalar* valuePtr() const { return derived().nestedExpression().valuePtr(); }
34  inline const StorageIndex* innerIndexPtr() const { return derived().nestedExpression().innerIndexPtr(); }
35  inline const StorageIndex* outerIndexPtr() const { return derived().nestedExpression().outerIndexPtr(); }
36  inline const StorageIndex* innerNonZeroPtr() const { return derived().nestedExpression().innerNonZeroPtr(); }
37 
38  inline Scalar* valuePtr() { return derived().nestedExpression().valuePtr(); }
39  inline StorageIndex* innerIndexPtr() { return derived().nestedExpression().innerIndexPtr(); }
40  inline StorageIndex* outerIndexPtr() { return derived().nestedExpression().outerIndexPtr(); }
41  inline StorageIndex* innerNonZeroPtr() { return derived().nestedExpression().innerNonZeroPtr(); }
42 };
43 } // namespace internal
44 
45 template <typename MatrixType>
47  protected:
49 };
50 
51 namespace internal {
52 
53 template <typename ArgType>
54 struct unary_evaluator<Transpose<ArgType>, IteratorBased> : public evaluator_base<Transpose<ArgType> > {
56 
57  public:
59 
60  inline Index nonZerosEstimate() const { return m_argImpl.nonZerosEstimate(); }
61 
62  class InnerIterator : public EvalIterator {
63  public:
65  : EvalIterator(unaryOp.m_argImpl, outer) {}
66 
67  Index row() const { return EvalIterator::col(); }
68  Index col() const { return EvalIterator::row(); }
69  };
70 
71  enum { CoeffReadCost = evaluator<ArgType>::CoeffReadCost, Flags = XprType::Flags };
72 
73  explicit unary_evaluator(const XprType& op) : m_argImpl(op.nestedExpression()) {}
74 
75  protected:
77 };
78 
79 } // end namespace internal
80 
81 } // end namespace Eigen
82 
83 #endif // EIGEN_SPARSETRANSPOSE_H
#define EIGEN_STRONG_INLINE
Definition: Macros.h:834
m col(1)
m row(1)
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52
An InnerIterator allows to loop over the element of any matrix expression.
Definition: CoreIterators.h:37
Common base class for sparse [compressed]-{row|column}-storage format.
Definition: SparseCompressedBase.h:43
Base class of any sparse matrices or sparse expressions.
Definition: SparseMatrixBase.h:30
internal::traits< Transpose< MatrixType > >::StorageIndex StorageIndex
Definition: SparseMatrixBase.h:44
internal::traits< Transpose< MatrixType > >::Scalar Scalar
Definition: SparseMatrixBase.h:32
const Transpose< MatrixType > & derived() const
Definition: SparseMatrixBase.h:144
internal::SparseTransposeImpl< MatrixType > Base
Definition: SparseTranspose.h:48
Definition: Transpose.h:104
Expression of the transpose of a matrix.
Definition: Transpose.h:56
const StorageIndex * outerIndexPtr() const
Definition: SparseTranspose.h:35
const Scalar * valuePtr() const
Definition: SparseTranspose.h:33
const StorageIndex * innerIndexPtr() const
Definition: SparseTranspose.h:34
Base::StorageIndex StorageIndex
Definition: SparseTranspose.h:29
const StorageIndex * innerNonZeroPtr() const
Definition: SparseTranspose.h:36
Index nonZeros() const
Definition: SparseTranspose.h:31
StorageIndex * innerNonZeroPtr()
Definition: SparseTranspose.h:41
StorageIndex * innerIndexPtr()
Definition: SparseTranspose.h:39
StorageIndex * outerIndexPtr()
Definition: SparseTranspose.h:40
SparseCompressedBase< Transpose< MatrixType > > Base
Definition: SparseTranspose.h:24
Definition: SparseTranspose.h:20
EIGEN_STRONG_INLINE InnerIterator(const unary_evaluator &unaryOp, Index outer)
Definition: SparseTranspose.h:64
const unsigned int CompressedAccessBit
Definition: Constants.h:195
char char * op
Definition: level2_impl.h:374
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
Extend namespace for flags.
Definition: fsi_chan_precond_driver.cc:56
Definition: Eigen_Colamd.h:49
constexpr EIGEN_DEVICE_FUNC Transpose< MatrixType > & derived()
Definition: EigenBase.h:49
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:43
Definition: Constants.h:522
Definition: Constants.h:580
Definition: CoreEvaluators.h:118
Definition: CoreEvaluators.h:104
evaluator< ArgType > m_argImpl
Definition: SparseTranspose.h:76
unary_evaluator(const XprType &op)
Definition: SparseTranspose.h:73
Index nonZerosEstimate() const
Definition: SparseTranspose.h:60
evaluator< ArgType >::InnerIterator EvalIterator
Definition: SparseTranspose.h:55
Transpose< ArgType > XprType
Definition: SparseTranspose.h:58
Definition: CoreEvaluators.h:82