9 #ifndef METIS_SUPPORT_H 10 #define METIS_SUPPORT_H 13 #include "./InternalHeaderCheck.h" 24 template <
typename StorageIndex>
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;
Definition: MetisSupport.h:25
constexpr void resize(Index rows, Index cols)
Definition: PlainObjectBase.h:268
const IndicesType & indices() const
Definition: PermutationMatrix.h:337
Namespace containing all symbols from the Eigen library.
Definition: B01_Experimental.dox:1
constexpr const Scalar * data() const
Definition: PlainObjectBase.h:247
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:82
Derived & setConstant(Index size, const Scalar &val)
Definition: CwiseNullaryOp.h:363
void resize(Index newSize)
Definition: PermutationMatrix.h:122