File indexing completed on 2025-02-22 10:34:44
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef EIGEN_SPARSETRANSPOSE_H
0011 #define EIGEN_SPARSETRANSPOSE_H
0012
0013 namespace Eigen {
0014
0015 namespace internal {
0016 template<typename MatrixType,int CompressedAccess=int(MatrixType::Flags&CompressedAccessBit)>
0017 class SparseTransposeImpl
0018 : public SparseMatrixBase<Transpose<MatrixType> >
0019 {};
0020
0021 template<typename MatrixType>
0022 class SparseTransposeImpl<MatrixType,CompressedAccessBit>
0023 : public SparseCompressedBase<Transpose<MatrixType> >
0024 {
0025 typedef SparseCompressedBase<Transpose<MatrixType> > Base;
0026 public:
0027 using Base::derived;
0028 typedef typename Base::Scalar Scalar;
0029 typedef typename Base::StorageIndex StorageIndex;
0030
0031 inline Index nonZeros() const { return derived().nestedExpression().nonZeros(); }
0032
0033 inline const Scalar* valuePtr() const { return derived().nestedExpression().valuePtr(); }
0034 inline const StorageIndex* innerIndexPtr() const { return derived().nestedExpression().innerIndexPtr(); }
0035 inline const StorageIndex* outerIndexPtr() const { return derived().nestedExpression().outerIndexPtr(); }
0036 inline const StorageIndex* innerNonZeroPtr() const { return derived().nestedExpression().innerNonZeroPtr(); }
0037
0038 inline Scalar* valuePtr() { return derived().nestedExpression().valuePtr(); }
0039 inline StorageIndex* innerIndexPtr() { return derived().nestedExpression().innerIndexPtr(); }
0040 inline StorageIndex* outerIndexPtr() { return derived().nestedExpression().outerIndexPtr(); }
0041 inline StorageIndex* innerNonZeroPtr() { return derived().nestedExpression().innerNonZeroPtr(); }
0042 };
0043 }
0044
0045 template<typename MatrixType> class TransposeImpl<MatrixType,Sparse>
0046 : public internal::SparseTransposeImpl<MatrixType>
0047 {
0048 protected:
0049 typedef internal::SparseTransposeImpl<MatrixType> Base;
0050 };
0051
0052 namespace internal {
0053
0054 template<typename ArgType>
0055 struct unary_evaluator<Transpose<ArgType>, IteratorBased>
0056 : public evaluator_base<Transpose<ArgType> >
0057 {
0058 typedef typename evaluator<ArgType>::InnerIterator EvalIterator;
0059 public:
0060 typedef Transpose<ArgType> XprType;
0061
0062 inline Index nonZerosEstimate() const {
0063 return m_argImpl.nonZerosEstimate();
0064 }
0065
0066 class InnerIterator : public EvalIterator
0067 {
0068 public:
0069 EIGEN_STRONG_INLINE InnerIterator(const unary_evaluator& unaryOp, Index outer)
0070 : EvalIterator(unaryOp.m_argImpl,outer)
0071 {}
0072
0073 Index row() const { return EvalIterator::col(); }
0074 Index col() const { return EvalIterator::row(); }
0075 };
0076
0077 enum {
0078 CoeffReadCost = evaluator<ArgType>::CoeffReadCost,
0079 Flags = XprType::Flags
0080 };
0081
0082 explicit unary_evaluator(const XprType& op) :m_argImpl(op.nestedExpression()) {}
0083
0084 protected:
0085 evaluator<ArgType> m_argImpl;
0086 };
0087
0088 }
0089
0090 }
0091
0092 #endif