10#ifndef EIGEN_SPARSE_PERMUTATION_H
11#define EIGEN_SPARSE_PERMUTATION_H
19template<
typename ExpressionType,
int S
ide,
bool Transposed>
23 typedef typename remove_all<MatrixType>::type MatrixTypeCleaned;
25 typedef typename MatrixTypeCleaned::Scalar Scalar;
26 typedef typename MatrixTypeCleaned::StorageIndex StorageIndex;
37 template<
typename Dest,
typename PermutationType>
38 static inline void run(Dest& dst,
const PermutationType& perm,
const ExpressionType& xpr)
45 for(
Index j=0; j<mat.outerSize(); ++j)
47 Index jp = perm.indices().coeff(j);
48 sizes[((Side==
OnTheLeft) ^ Transposed) ? jp : j] = StorageIndex(mat.innerVector(((Side==
OnTheRight) ^ Transposed) ? jp : j).nonZeros());
51 for(
Index j=0; j<mat.outerSize(); ++j)
53 Index jp = perm.indices().coeff(j);
56 for(
typename MatrixTypeCleaned::InnerIterator it(mat,jsrc); it; ++it)
57 tmp.insertByOuterInner(jdst,it.index()) = it.value();
72 for(
Index j=0; j<mat.outerSize(); ++j)
73 for(
typename MatrixTypeCleaned::InnerIterator it(mat,j); it; ++it)
74 sizes[perm_cpy.
indices().coeff(it.index())]++;
76 for(
Index j=0; j<mat.outerSize(); ++j)
77 for(
typename MatrixTypeCleaned::InnerIterator it(mat,j); it; ++it)
78 tmp.insertByOuterInner(perm_cpy.
indices().coeff(it.index()),j) = it.value();
95template<
typename Lhs,
typename Rhs,
int ProductTag>
97 :
public evaluator<typename permutation_matrix_product<Rhs,OnTheLeft,false,SparseShape>::ReturnType>
108 : m_result(xpr.rows(), xpr.cols())
110 ::new (
static_cast<Base*
>(
this))
Base(m_result);
115 PlainObject m_result;
118template<
typename Lhs,
typename Rhs,
int ProductTag>
120 :
public evaluator<typename permutation_matrix_product<Lhs,OnTheRight,false,SparseShape>::ReturnType>
131 : m_result(xpr.rows(), xpr.cols())
133 ::new (
static_cast<Base*
>(
this))
Base(m_result);
138 PlainObject m_result;
145template<
typename SparseDerived,
typename PermDerived>
152template<
typename SparseDerived,
typename PermDerived>
153inline const Product<PermDerived, SparseDerived, AliasFreeProduct>
160template<
typename SparseDerived,
typename PermutationType>
161inline const Product<SparseDerived, Inverse<PermutationType>, AliasFreeProduct>
169template<
typename SparseDerived,
typename PermutationType>
170inline const Product<Inverse<PermutationType>, SparseDerived, AliasFreeProduct>
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:180
Base class for permutations.
Definition PermutationMatrix.h:47
InverseReturnType transpose() const
Definition PermutationMatrix.h:191
EIGEN_DEVICE_FUNC Derived & derived()
Definition EigenBase.h:46
Permutation matrix.
Definition PermutationMatrix.h:298
const IndicesType & indices() const
Definition PermutationMatrix.h:360
EIGEN_DEVICE_FUNC Derived & setZero(Index size)
Definition CwiseNullaryOp.h:562
Expression of the product of two arbitrary matrices or vectors.
Definition Product.h:75
Base class of any sparse matrices or sparse expressions.
Definition SparseMatrixBase.h:28
A versatible sparse matrix representation.
Definition SparseMatrix.h:98
void reserve(Index reserveSize)
Definition SparseMatrix.h:264
@ ColMajor
Definition Constants.h:319
@ RowMajor
Definition Constants.h:321
@ OnTheLeft
Definition Constants.h:332
@ OnTheRight
Definition Constants.h:334
const unsigned int EvalBeforeNestingBit
Definition Constants.h:70
const unsigned int RowMajorBit
Definition Constants.h:66
Namespace containing all symbols from the Eigen library.
Definition common.h:81
EIGEN_DEVICE_FUNC const Product< MatrixDerived, PermutationDerived, AliasFreeProduct > operator*(const MatrixBase< MatrixDerived > &matrix, const PermutationBase< PermutationDerived > &permutation)
Definition PermutationMatrix.h:515
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:74
Definition Constants.h:535
Definition Constants.h:516
Definition Constants.h:537
Definition Constants.h:510
Definition CoreEvaluators.h:91
Definition ProductEvaluators.h:86
Definition ProductEvaluators.h:998
Definition ForwardDeclarations.h:164