2009-01-14 22:24:10 +08:00
|
|
|
// This file is part of Eigen, a lightweight C++ template library
|
2009-05-23 02:25:33 +08:00
|
|
|
// for linear algebra.
|
2009-01-14 22:24:10 +08:00
|
|
|
//
|
2015-02-08 05:02:14 +08:00
|
|
|
// Copyright (C) 2008-2015 Gael Guennebaud <gael.guennebaud@inria.fr>
|
2009-01-14 22:24:10 +08:00
|
|
|
//
|
2012-07-14 02:42:47 +08:00
|
|
|
// This Source Code Form is subject to the terms of the Mozilla
|
|
|
|
|
// Public License v. 2.0. If a copy of the MPL was not distributed
|
|
|
|
|
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2009-01-14 22:24:10 +08:00
|
|
|
|
|
|
|
|
#ifndef EIGEN_SPARSETRANSPOSE_H
|
|
|
|
|
#define EIGEN_SPARSETRANSPOSE_H
|
|
|
|
|
|
2012-04-15 18:06:28 +08:00
|
|
|
namespace Eigen {
|
|
|
|
|
|
2015-02-08 05:02:14 +08:00
|
|
|
namespace internal {
|
|
|
|
|
template<typename MatrixType,int CompressedAccess=int(MatrixType::Flags&CompressedAccessBit)>
|
|
|
|
|
class SparseTransposeImpl
|
|
|
|
|
: public SparseMatrixBase<Transpose<MatrixType> >
|
|
|
|
|
{};
|
|
|
|
|
|
|
|
|
|
template<typename MatrixType>
|
|
|
|
|
class SparseTransposeImpl<MatrixType,CompressedAccessBit>
|
|
|
|
|
: public SparseCompressedBase<Transpose<MatrixType> >
|
|
|
|
|
{
|
|
|
|
|
typedef SparseCompressedBase<Transpose<MatrixType> > Base;
|
|
|
|
|
public:
|
|
|
|
|
using Base::derived;
|
|
|
|
|
typedef typename Base::Scalar Scalar;
|
2015-02-13 17:03:53 +08:00
|
|
|
typedef typename Base::StorageIndex StorageIndex;
|
2015-02-08 05:02:14 +08:00
|
|
|
|
|
|
|
|
inline const Scalar* valuePtr() const { return derived().nestedExpression().valuePtr(); }
|
2015-02-13 17:03:53 +08:00
|
|
|
inline const StorageIndex* innerIndexPtr() const { return derived().nestedExpression().innerIndexPtr(); }
|
|
|
|
|
inline const StorageIndex* outerIndexPtr() const { return derived().nestedExpression().outerIndexPtr(); }
|
|
|
|
|
inline const StorageIndex* innerNonZeroPtr() const { return derived().nestedExpression().innerNonZeroPtr(); }
|
2015-02-08 05:02:14 +08:00
|
|
|
|
|
|
|
|
inline Scalar* valuePtr() { return derived().nestedExpression().valuePtr(); }
|
2015-02-13 17:03:53 +08:00
|
|
|
inline StorageIndex* innerIndexPtr() { return derived().nestedExpression().innerIndexPtr(); }
|
|
|
|
|
inline StorageIndex* outerIndexPtr() { return derived().nestedExpression().outerIndexPtr(); }
|
|
|
|
|
inline StorageIndex* innerNonZeroPtr() { return derived().nestedExpression().innerNonZeroPtr(); }
|
2015-02-08 05:02:14 +08:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-01 17:49:46 +08:00
|
|
|
template<typename MatrixType> class TransposeImpl<MatrixType,Sparse>
|
2015-02-08 05:02:14 +08:00
|
|
|
: public internal::SparseTransposeImpl<MatrixType>
|
2014-07-01 17:49:46 +08:00
|
|
|
{
|
|
|
|
|
protected:
|
2015-02-08 05:02:14 +08:00
|
|
|
typedef internal::SparseTransposeImpl<MatrixType> Base;
|
2014-07-01 17:49:46 +08:00
|
|
|
};
|
|
|
|
|
|
2014-06-23 16:40:03 +08:00
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
|
|
template<typename ArgType>
|
|
|
|
|
struct unary_evaluator<Transpose<ArgType>, IteratorBased>
|
|
|
|
|
: public evaluator_base<Transpose<ArgType> >
|
|
|
|
|
{
|
|
|
|
|
typedef typename evaluator<ArgType>::InnerIterator EvalIterator;
|
|
|
|
|
typedef typename evaluator<ArgType>::ReverseInnerIterator EvalReverseIterator;
|
|
|
|
|
public:
|
|
|
|
|
typedef Transpose<ArgType> XprType;
|
2015-04-02 04:27:34 +08:00
|
|
|
|
|
|
|
|
inline Index nonZerosEstimate() const {
|
|
|
|
|
return m_argImpl.nonZerosEstimate();
|
|
|
|
|
}
|
2014-06-23 16:40:03 +08:00
|
|
|
|
|
|
|
|
class InnerIterator : public EvalIterator
|
|
|
|
|
{
|
|
|
|
|
public:
|
2014-12-05 05:48:53 +08:00
|
|
|
EIGEN_STRONG_INLINE InnerIterator(const unary_evaluator& unaryOp, Index outer)
|
2014-06-23 16:40:03 +08:00
|
|
|
: EvalIterator(unaryOp.m_argImpl,outer)
|
|
|
|
|
{}
|
|
|
|
|
|
2015-02-14 01:57:41 +08:00
|
|
|
Index row() const { return EvalIterator::col(); }
|
|
|
|
|
Index col() const { return EvalIterator::row(); }
|
2014-06-23 16:40:03 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ReverseInnerIterator : public EvalReverseIterator
|
|
|
|
|
{
|
|
|
|
|
public:
|
2014-12-05 05:48:53 +08:00
|
|
|
EIGEN_STRONG_INLINE ReverseInnerIterator(const unary_evaluator& unaryOp, Index outer)
|
2014-06-23 16:40:03 +08:00
|
|
|
: EvalReverseIterator(unaryOp.m_argImpl,outer)
|
|
|
|
|
{}
|
|
|
|
|
|
2015-02-14 01:57:41 +08:00
|
|
|
Index row() const { return EvalReverseIterator::col(); }
|
|
|
|
|
Index col() const { return EvalReverseIterator::row(); }
|
2014-06-23 16:40:03 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
CoeffReadCost = evaluator<ArgType>::CoeffReadCost,
|
|
|
|
|
Flags = XprType::Flags
|
|
|
|
|
};
|
|
|
|
|
|
2014-09-23 20:28:23 +08:00
|
|
|
explicit unary_evaluator(const XprType& op) :m_argImpl(op.nestedExpression()) {}
|
2014-06-23 16:40:03 +08:00
|
|
|
|
|
|
|
|
protected:
|
2015-09-03 04:10:39 +08:00
|
|
|
evaluator<ArgType> m_argImpl;
|
2014-06-23 16:40:03 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // end namespace internal
|
|
|
|
|
|
2012-04-15 18:06:28 +08:00
|
|
|
} // end namespace Eigen
|
|
|
|
|
|
2009-01-14 22:24:10 +08:00
|
|
|
#endif // EIGEN_SPARSETRANSPOSE_H
|