30 template <
typename MatrixType>
31 void get_symmetrized_graph(
const MatrixType& A) {
33 eigen_assert((A.rows() == A.cols()) &&
"ONLY FOR SQUARED MATRICES");
35 MatrixType At = A.transpose();
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) {
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>
95 StorageIndex m = internal::convert_index<StorageIndex>(
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;