Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Eigen::MetisOrdering< StorageIndex > Class Template Reference

#include <src/eigen/Eigen/src/MetisSupport/MetisSupport.h>

+ Collaboration diagram for Eigen::MetisOrdering< StorageIndex >:

Public Types

typedef PermutationMatrix< Dynamic, Dynamic, StorageIndex > PermutationType
 
typedef Matrix< StorageIndex, Dynamic, 1 > IndexVector
 

Public Member Functions

template<typename MatrixType >
void get_symmetrized_graph (const MatrixType &A)
 
template<typename MatrixType >
void operator() (const MatrixType &A, PermutationType &matperm)
 

Protected Attributes

IndexVector m_indexPtr
 
IndexVector m_innerIndices
 

Detailed Description

template<typename StorageIndex>
class Eigen::MetisOrdering< StorageIndex >

Get the fill-reducing ordering from the METIS package

If A is the original matrix and Ap is the permuted matrix, the fill-reducing permutation is defined as follows : Row (column) i of A is the matperm(i) row (column) of Ap. WARNING: As computed by METIS, this corresponds to the vector iperm (instead of perm)

Member Typedef Documentation

◆ IndexVector

template<typename StorageIndex >
typedef Matrix<StorageIndex,Dynamic,1> Eigen::MetisOrdering< StorageIndex >::IndexVector

◆ PermutationType

template<typename StorageIndex >
typedef PermutationMatrix<Dynamic,Dynamic,StorageIndex> Eigen::MetisOrdering< StorageIndex >::PermutationType

Member Function Documentation

◆ get_symmetrized_graph()

template<typename StorageIndex >
template<typename MatrixType >
void Eigen::MetisOrdering< StorageIndex >::get_symmetrized_graph ( const MatrixType &  A)
inline
30 {
31 Index m = A.cols();
32 eigen_assert((A.rows() == A.cols()) && "ONLY FOR SQUARED MATRICES");
33 // Get the transpose of the input matrix
34 MatrixType At = A.transpose();
35 // Get the number of nonzeros elements in each row/col of At+A
36 Index TotNz = 0;
37 IndexVector visited(m);
38 visited.setConstant(-1);
39 for (StorageIndex j = 0; j < m; j++)
40 {
41 // Compute the union structure of of A(j,:) and At(j,:)
42 visited(j) = j; // Do not include the diagonal element
43 // Get the nonzeros in row/column j of A
44 for (typename MatrixType::InnerIterator it(A, j); it; ++it)
45 {
46 Index idx = it.index(); // Get the row index (for column major) or column index (for row major)
47 if (visited(idx) != j )
48 {
49 visited(idx) = j;
50 ++TotNz;
51 }
52 }
53 //Get the nonzeros in row/column j of At
54 for (typename MatrixType::InnerIterator it(At, j); it; ++it)
55 {
56 Index idx = it.index();
57 if(visited(idx) != j)
58 {
59 visited(idx) = j;
60 ++TotNz;
61 }
62 }
63 }
64 // Reserve place for A + At
65 m_indexPtr.resize(m+1);
66 m_innerIndices.resize(TotNz);
67
68 // Now compute the real adjacency list of each column/row
69 visited.setConstant(-1);
70 StorageIndex CurNz = 0;
71 for (StorageIndex j = 0; j < m; j++)
72 {
73 m_indexPtr(j) = CurNz;
74
75 visited(j) = j; // Do not include the diagonal element
76 // Add the pattern of row/column j of A to A+At
77 for (typename MatrixType::InnerIterator it(A,j); it; ++it)
78 {
79 StorageIndex idx = it.index(); // Get the row index (for column major) or column index (for row major)
80 if (visited(idx) != j )
81 {
82 visited(idx) = j;
83 m_innerIndices(CurNz) = idx;
84 CurNz++;
85 }
86 }
87 //Add the pattern of row/column j of At to A+At
88 for (typename MatrixType::InnerIterator it(At, j); it; ++it)
89 {
90 StorageIndex idx = it.index();
91 if(visited(idx) != j)
92 {
93 visited(idx) = j;
94 m_innerIndices(CurNz) = idx;
95 ++CurNz;
96 }
97 }
98 }
99 m_indexPtr(m) = CurNz;
100 }
#define eigen_assert(x)
Definition Macros.h:579
IndexVector m_indexPtr
Definition MetisSupport.h:132
IndexVector m_innerIndices
Definition MetisSupport.h:133
Matrix< StorageIndex, Dynamic, 1 > IndexVector
Definition MetisSupport.h:26
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void resize(Index rows, Index cols)
Definition PlainObjectBase.h:279
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:33

References eigen_assert, Eigen::MetisOrdering< StorageIndex >::m_indexPtr, Eigen::MetisOrdering< StorageIndex >::m_innerIndices, Eigen::PlainObjectBase< Derived >::resize(), and Eigen::PlainObjectBase< Derived >::setConstant().

Referenced by Eigen::MetisOrdering< StorageIndex >::operator()().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator()()

template<typename StorageIndex >
template<typename MatrixType >
void Eigen::MetisOrdering< StorageIndex >::operator() ( const MatrixType &  A,
PermutationType matperm 
)
inline
104 {
105 StorageIndex m = internal::convert_index<StorageIndex>(A.cols()); // must be StorageIndex, because it is passed by address to METIS
106 IndexVector perm(m),iperm(m);
107 // First, symmetrize the matrix graph.
109 int output_error;
110
111 // Call the fill-reducing routine from METIS
112 output_error = METIS_NodeND(&m, m_indexPtr.data(), m_innerIndices.data(), NULL, NULL, perm.data(), iperm.data());
113
114 if(output_error != METIS_OK)
115 {
116 //FIXME The ordering interface should define a class of possible errors
117 std::cerr << "ERROR WHILE CALLING THE METIS PACKAGE \n";
118 return;
119 }
120
121 // Get the fill-reducing permutation
122 //NOTE: If Ap is the permuted matrix then perm and iperm vectors are defined as follows
123 // Row (column) i of Ap is the perm(i) row(column) of A, and row (column) i of A is the iperm(i) row(column) of Ap
124
125 matperm.resize(m);
126 for (int j = 0; j < m; j++)
127 matperm.indices()(iperm(j)) = j;
128
129 }
void get_symmetrized_graph(const MatrixType &A)
Definition MetisSupport.h:29
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar * data() const
Definition PlainObjectBase.h:255

References Eigen::PlainObjectBase< Derived >::data(), Eigen::MetisOrdering< StorageIndex >::get_symmetrized_graph(), Eigen::PermutationMatrix< SizeAtCompileTime, MaxSizeAtCompileTime, _StorageIndex >::indices(), Eigen::MetisOrdering< StorageIndex >::m_indexPtr, Eigen::MetisOrdering< StorageIndex >::m_innerIndices, and Eigen::PermutationBase< Derived >::resize().

+ Here is the call graph for this function:

Member Data Documentation

◆ m_indexPtr

template<typename StorageIndex >
IndexVector Eigen::MetisOrdering< StorageIndex >::m_indexPtr
protected

◆ m_innerIndices

template<typename StorageIndex >
IndexVector Eigen::MetisOrdering< StorageIndex >::m_innerIndices
protected

The documentation for this class was generated from the following file: