Eigen  5.0.1
 
Loading...
Searching...
No Matches
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// SPDX-License-Identifier: MPL-2.0
10
11#ifndef EIGEN_SPARSETRANSPOSE_H
12#define EIGEN_SPARSETRANSPOSE_H
13
14// IWYU pragma: private
15#include "./InternalHeaderCheck.h"
16
17namespace Eigen {
18
19namespace internal {
20template <typename MatrixType, int CompressedAccess = int(MatrixType::Flags & CompressedAccessBit)>
21class SparseTransposeImpl : public SparseMatrixBase<Transpose<MatrixType> > {};
22
23template <typename MatrixType>
24class SparseTransposeImpl<MatrixType, CompressedAccessBit> : public SparseCompressedBase<Transpose<MatrixType> > {
25 using Base = SparseCompressedBase<Transpose<MatrixType>>;
26
27 public:
28 using Base::derived;
29 using Scalar = typename Base::Scalar;
30 using StorageIndex = typename Base::StorageIndex;
31
32 inline Index nonZeros() const { return derived().nestedExpression().nonZeros(); }
33
34 inline const Scalar* valuePtr() const { return derived().nestedExpression().valuePtr(); }
35 inline const StorageIndex* innerIndexPtr() const { return derived().nestedExpression().innerIndexPtr(); }
36 inline const StorageIndex* outerIndexPtr() const { return derived().nestedExpression().outerIndexPtr(); }
37 inline const StorageIndex* innerNonZeroPtr() const { return derived().nestedExpression().innerNonZeroPtr(); }
38
39 inline Scalar* valuePtr() { return derived().nestedExpression().valuePtr(); }
40 inline StorageIndex* innerIndexPtr() { return derived().nestedExpression().innerIndexPtr(); }
41 inline StorageIndex* outerIndexPtr() { return derived().nestedExpression().outerIndexPtr(); }
42 inline StorageIndex* innerNonZeroPtr() { return derived().nestedExpression().innerNonZeroPtr(); }
43};
44} // namespace internal
45
46template <typename MatrixType>
47class TransposeImpl<MatrixType, Sparse> : public internal::SparseTransposeImpl<MatrixType> {
48 protected:
49 using Base = internal::SparseTransposeImpl<MatrixType>;
50};
51
52namespace internal {
53
54template <typename ArgType>
55struct unary_evaluator<Transpose<ArgType>, IteratorBased> : public evaluator_base<Transpose<ArgType> > {
56 using EvalIterator = typename evaluator<ArgType>::InnerIterator;
57
58 public:
59 using XprType = Transpose<ArgType>;
60
61 inline Index nonZerosEstimate() const { return m_argImpl.nonZerosEstimate(); }
62
63 class InnerIterator : public EvalIterator {
64 public:
65 EIGEN_STRONG_INLINE InnerIterator(const unary_evaluator& unaryOp, Index outer)
66 : EvalIterator(unaryOp.m_argImpl, outer) {}
67
68 Index row() const { return EvalIterator::col(); }
69 Index col() const { return EvalIterator::row(); }
70 };
71
72 enum { CoeffReadCost = evaluator<ArgType>::CoeffReadCost, Flags = XprType::Flags };
73
74 explicit unary_evaluator(const XprType& op) : m_argImpl(op.nestedExpression()) {}
75
76 protected:
77 evaluator<ArgType> m_argImpl;
78};
79
80} // end namespace internal
81
82} // end namespace Eigen
83
84#endif // EIGEN_SPARSETRANSPOSE_H
typename internal::traits< Transpose< MatrixType > >::StorageIndex StorageIndex
Definition SparseMatrixBase.h:45
constexpr unsigned int CompressedAccessBit
Definition Constants.h:196
constexpr Transpose< MatrixType > & derived()
Definition EigenBase.h:50
Eigen::Index Index
Definition EigenBase.h:44
Definition Constants.h:545