9 #ifndef METIS_SUPPORT_H
10 #define METIS_SUPPORT_H
12 #include "./InternalHeaderCheck.h"
23 template <
typename StorageIndex>
30 template <
typename MatrixType>
31 void get_symmetrized_graph(
const MatrixType& A)
34 eigen_assert((A.rows() == A.cols()) &&
"ONLY FOR SQUARED MATRICES");
36 MatrixType At = A.transpose();
41 for (StorageIndex j = 0; j < m; j++)
46 for (
typename MatrixType::InnerIterator it(A, j); it; ++it)
48 Index idx = it.index();
49 if (visited(idx) != j )
56 for (
typename MatrixType::InnerIterator it(At, j); it; ++it)
58 Index idx = it.index();
68 m_innerIndices.
resize(TotNz);
72 StorageIndex CurNz = 0;
73 for (StorageIndex j = 0; j < m; j++)
75 m_indexPtr(j) = CurNz;
79 for (
typename MatrixType::InnerIterator it(A,j); it; ++it)
81 StorageIndex idx = it.index();
82 if (visited(idx) != j )
85 m_innerIndices(CurNz) = idx;
90 for (
typename MatrixType::InnerIterator it(At, j); it; ++it)
92 StorageIndex idx = it.index();
96 m_innerIndices(CurNz) = idx;
101 m_indexPtr(m) = CurNz;
104 template <
typename MatrixType>
107 StorageIndex m = internal::convert_index<StorageIndex>(A.cols());
110 get_symmetrized_graph(A);
114 output_error = METIS_NodeND(&m, m_indexPtr.
data(), m_innerIndices.
data(), NULL, NULL, perm.data(), iperm.
data());
116 if(output_error != METIS_OK)
119 std::cerr <<
"ERROR WHILE CALLING THE METIS PACKAGE \n";
128 for (
int j = 0; j < m; j++)
129 matperm.
indices()(iperm(j)) = j;
Definition: MetisSupport.h:25
void resize(Index newSize)
Definition: PermutationMatrix.h:127
const IndicesType & indices() const
Definition: PermutationMatrix.h:362
void resize(Index rows, Index cols)
Definition: PlainObjectBase.h:283
Derived & setConstant(Index size, const Scalar &val)
Definition: CwiseNullaryOp.h:363
const Scalar * data() const
Definition: PlainObjectBase.h:259
Namespace containing all symbols from the Eigen library.
Definition: Core:139
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:59