10#ifndef EIGEN_SPARSE_PERMUTATION_H
11#define EIGEN_SPARSE_PERMUTATION_H
19template<
typename ExpressionType,
int S
ide,
bool Transposed>
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);
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);
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);
145template<
typename SparseDerived,
typename PermDerived>
152template<
typename SparseDerived,
typename PermDerived>
153inline const Product<PermDerived, SparseDerived, AliasFreeProduct>
154operator*(
const PermutationBase<PermDerived>& perm,
const SparseMatrixBase<SparseDerived>& matrix)
155{
return Product<PermDerived, SparseDerived, AliasFreeProduct>(perm.derived(), matrix.derived()); }
160template<
typename SparseDerived,
typename PermutationType>
161inline const Product<SparseDerived, Inverse<PermutationType>, AliasFreeProduct>
162operator*(
const SparseMatrixBase<SparseDerived>& matrix,
const InverseImpl<PermutationType, PermutationStorage>& tperm)
164 return Product<SparseDerived, Inverse<PermutationType>, AliasFreeProduct>(matrix.derived(), tperm.derived());
169template<
typename SparseDerived,
typename PermutationType>
170inline const Product<Inverse<PermutationType>, SparseDerived, AliasFreeProduct>
171operator*(
const InverseImpl<PermutationType,PermutationStorage>& tperm,
const SparseMatrixBase<SparseDerived>& matrix)
173 return Product<Inverse<PermutationType>, SparseDerived, AliasFreeProduct>(tperm.derived(), matrix.derived());
Expression of the product of two arbitrary matrices or vectors.
Definition Product.h:111
Pseudo expression representing a solving operation.
Definition Solve.h:63
A versatible sparse matrix representation.
Definition SparseMatrix.h:94
@ ColMajor
Storage order is column major (see TopicStorageOrders).
Definition Constants.h:320
@ RowMajor
Storage order is row major (see TopicStorageOrders).
Definition Constants.h:322
@ OnTheLeft
Apply transformation on the left.
Definition Constants.h:333
@ OnTheRight
Apply transformation on the right.
Definition Constants.h:335
const unsigned int EvalBeforeNestingBit
means the expression should be evaluated by the calling expression
Definition Constants.h:65
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition Constants.h:61
Definition Constants.h:518
The type used to identify a permutation storage.
Definition Constants.h:499
Definition Constants.h:520
The type used to identify a general sparse storage.
Definition Constants.h:493
Definition CoreEvaluators.h:82
Definition ProductEvaluators.h:81
Definition ProductEvaluators.h:880
Definition ForwardDeclarations.h:165