9 #ifndef METIS_SUPPORT_H 10 #define METIS_SUPPORT_H 21 template <
typename Index>
28 template <
typename MatrixType>
29 void get_symmetrized_graph(
const MatrixType& A)
32 eigen_assert((A.rows() == A.cols()) &&
"ONLY FOR SQUARED MATRICES");
37 IndexVector visited(m);
39 for (
int j = 0; j < m; j++)
44 for (
typename MatrixType::InnerIterator it(A, j); it; ++it)
46 Index idx = it.index();
47 if (visited(idx) != j )
54 for (
typename MatrixType::InnerIterator it(At, j); it; ++it)
56 Index idx = it.index();
66 m_innerIndices.
resize(TotNz);
71 for (
int j = 0; j < m; j++)
73 m_indexPtr(j) = CurNz;
77 for (
typename MatrixType::InnerIterator it(A,j); it; ++it)
79 Index idx = it.index();
80 if (visited(idx) != j )
83 m_innerIndices(CurNz) = idx;
88 for (
typename MatrixType::InnerIterator it(At, j); it; ++it)
90 Index idx = it.index();
94 m_innerIndices(CurNz) = idx;
99 m_indexPtr(m) = CurNz;
102 template <
typename MatrixType>
103 void operator() (
const MatrixType& A, PermutationType& matperm)
106 IndexVector perm(m),iperm(m);
108 get_symmetrized_graph(A);
112 output_error = METIS_NodeND(&m, m_indexPtr.
data(), m_innerIndices.
data(), NULL, NULL, perm.data(), iperm.
data());
114 if(output_error != METIS_OK)
117 std::cerr <<
"ERROR WHILE CALLING THE METIS PACKAGE \n";
126 for (
int j = 0; j < m; j++)
127 matperm.
indices()(iperm(j)) = j;
132 IndexVector m_indexPtr;
133 IndexVector m_innerIndices;
Get the fill-reducing ordering from the METIS package.
Definition: MetisSupport.h:22
EIGEN_STRONG_INLINE const Scalar * data() const
Definition: PlainObjectBase.h:212
iterative scaling algorithm to equilibrate rows and column norms in matrices
Definition: TestIMU_Common.h:87
EIGEN_STRONG_INLINE void resize(Index nbRows, Index nbCols)
Resizes *this to a rows x cols matrix.
Definition: PlainObjectBase.h:235
Derived & setConstant(Index size, const Scalar &value)
Resizes to the given size, and sets all coefficients in this expression to the given value...
Definition: CwiseNullaryOp.h:348
const IndicesType & indices() const
const version of indices().
Definition: PermutationMatrix.h:387
void resize(Index newSize)
Resizes to given size.
Definition: PermutationMatrix.h:142