10#define METIS_SUPPORT_H
21template <
typename StorageIndex>
28 template <
typename MatrixType>
29 void get_symmetrized_graph(
const MatrixType& A)
32 eigen_assert((A.rows() == A.cols()) &&
"ONLY FOR SQUARED MATRICES");
34 MatrixType At = A.transpose();
39 for (StorageIndex 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);
70 StorageIndex CurNz = 0;
71 for (StorageIndex j = 0; j < m; j++)
73 m_indexPtr(j) = CurNz;
77 for (
typename MatrixType::InnerIterator it(A,j); it; ++it)
79 StorageIndex idx = it.index();
80 if (visited(idx) != j )
83 m_innerIndices(CurNz) = idx;
88 for (
typename MatrixType::InnerIterator it(At, j); it; ++it)
90 StorageIndex idx = it.index();
94 m_innerIndices(CurNz) = idx;
99 m_indexPtr(m) = CurNz;
102 template <
typename MatrixType>
105 StorageIndex m = internal::convert_index<StorageIndex>(A.cols());
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;
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:180
Definition: MetisSupport.h:23
void resize(Index newSize)
Definition: PermutationMatrix.h:125
Permutation matrix.
Definition: PermutationMatrix.h:298
const IndicesType & indices() const
Definition: PermutationMatrix.h:360
void resize(Index rows, Index cols)
Definition: PlainObjectBase.h:271
Derived & setConstant(Index size, const Scalar &val)
Definition: CwiseNullaryOp.h:361
const Scalar * data() const
Definition: PlainObjectBase.h:247
Namespace containing all symbols from the Eigen library.
Definition: Core:141
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74