33 #ifndef __H__UG__CPU_ALGEBRA__PERMUTATION_UTIL__
34 #define __H__UG__CPU_ALGEBRA__PERMUTATION_UTIL__
49 template<
typename TMatrix>
53 PA.resize_and_clear(A.num_rows(), A.num_cols());
55 for(
size_t r=0; r<A.num_rows(); r++)
58 for(
typename TMatrix::const_row_iterator it = A.begin_row(r); it != A.end_row(r); ++it)
60 size_t Pc = perm[it.index()];
61 PA(Pr, Pc) = it.value();
73 template<
typename TVector>
76 if(Pv.size() != v.size()) Pv.resize(v.size());
77 for(
size_t i=0; i<v.size(); i++)
96 template<
typename TSparseMatrix>
97 void GetCuthillMcKeeOrder(
const TSparseMatrix &mat, std::vector<size_t> &newIndex,
bool reverse=
true,
bool bPreserveConsec=
false)
99 std::vector<std::vector<size_t> > neighbors;
100 neighbors.resize(mat.num_rows());
102 for(
size_t i=0; i<mat.num_rows(); i++)
104 for(
typename TSparseMatrix::const_row_iterator i_it = mat.begin_row(i); i_it != mat.end_row(i); ++i_it)
105 neighbors[i].push_back(i_it.index());
131 #ifndef HAVE_IS_PERMUTATION
132 #define HAVE_IS_PERMUTATION
134 template <
typename O_t>
136 std::vector<BOOL> container(o.size(),
false);
137 for(
unsigned i = 0; i < o.size(); ++i){
138 if(!container[o[i]]){
139 container[o[i]] =
true;
146 for(
unsigned i = 0; i < o.size(); ++i){
Definition: permutation_util.h:120
char value_
Definition: permutation_util.h:126
BOOL(bool const &t)
Definition: permutation_util.h:123
BOOL()
Definition: permutation_util.h:122
void ComputeCuthillMcKeeOrder(std::vector< size_t > &vNewIndex, std::vector< std::vector< size_t > > &vvConnection, bool bReverse, bool bPreserveConsec)
returns an array describing the needed index mapping for Cuthill-McKee ordering
Definition: native_cuthill_mckee.cpp:100
void GetCuthillMcKeeOrder(const TSparseMatrix &mat, std::vector< size_t > &newIndex, bool reverse=true, bool bPreserveConsec=false)
Definition: permutation_util.h:97
static void SetVectorAsPermutation(TVector &Pv, const TVector &v, const std::vector< size_t > &perm)
Definition: permutation_util.h:74
bool is_permutation(O_t &o)
Definition: permutation_util.h:135
static void SetMatrixAsPermutation(TMatrix &PA, const TMatrix &A, const std::vector< size_t > &perm)
Definition: permutation_util.h:50
bool GetInversePermutation(const std::vector< size_t > &perm, std::vector< size_t > &invPerm)
Definition: permutation_util.cpp:39
#define PROFILE_FUNC_GROUP(groups)
Definition: profiler.h:258