30 template <
typename MatrixType>
31 void get_symmetrized_graph(
const MatrixType& A) {
33 eigen_assert((A.rows() == A.cols()) &&
"ONLY FOR SQUARED MATRICES");
38 IndexVector visited(m);
40 for (StorageIndex j = 0; j < m; j++) {
44 for (
typename MatrixType::InnerIterator it(A, j); it; ++it) {
45 Index idx = it.index();
46 if (visited(idx) != j) {
52 for (
typename MatrixType::InnerIterator it(At, j); it; ++it) {
53 Index idx = it.index();
54 if (visited(idx) != j) {
61 m_indexPtr.resize(m + 1);
62 m_innerIndices.resize(TotNz);
66 StorageIndex CurNz = 0;
67 for (StorageIndex j = 0; j < m; j++) {
68 m_indexPtr(j) = CurNz;
72 for (
typename MatrixType::InnerIterator it(A, j); it; ++it) {
73 StorageIndex idx = it.index();
74 if (visited(idx) != j) {
76 m_innerIndices(CurNz) = idx;
81 for (
typename MatrixType::InnerIterator it(At, j); it; ++it) {
82 StorageIndex idx = it.index();
83 if (visited(idx) != j) {
85 m_innerIndices(CurNz) = idx;
90 m_indexPtr(m) = CurNz;
93 template <
typename MatrixType>
94 void operator()(
const MatrixType& A, PermutationType& matperm) {
95 StorageIndex m = internal::convert_index<StorageIndex>(
97 IndexVector perm(m), iperm(m);
99 get_symmetrized_graph(A);
103 output_error = METIS_NodeND(&m, m_indexPtr.data(), m_innerIndices.data(), NULL, NULL, perm.data(), iperm.
data());
105 if (output_error != METIS_OK) {
107 std::cerr <<
"ERROR WHILE CALLING THE METIS PACKAGE \n";
116 for (
int j = 0; j < m; j++) matperm.
indices()(iperm(j)) = j;
120 IndexVector m_indexPtr;
121 IndexVector m_innerIndices;