Ordering.h
Go to the documentation of this file.
1 
2 // This file is part of Eigen, a lightweight C++ template library
3 // for linear algebra.
4 //
5 // Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>
6 //
7 // This Source Code Form is subject to the terms of the Mozilla
8 // Public License v. 2.0. If a copy of the MPL was not distributed
9 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 
11 #ifndef EIGEN_ORDERING_H
12 #define EIGEN_ORDERING_H
13 
14 namespace Eigen {
15 
16 #include "Eigen_Colamd.h"
17 
18 namespace internal {
19 
25 template<typename MatrixType>
26 void ordering_helper_at_plus_a(const MatrixType& mat, MatrixType& symmat)
27 {
28  MatrixType C;
29  C = mat.transpose(); // NOTE: Could be costly
30  for (int i = 0; i < C.rows(); i++)
31  {
32  for (typename MatrixType::InnerIterator it(C, i); it; ++it)
33  it.valueRef() = 0.0;
34  }
35  symmat = C + mat;
36 }
37 
38 }
39 
40 #ifndef EIGEN_MPL2_ONLY
41 
50 template <typename Index>
52 {
53  public:
55 
59  template <typename MatrixType>
60  void operator()(const MatrixType& mat, PermutationType& perm)
61  {
62  // Compute the symmetric pattern
65 
66  // Call the AMD routine
67  //m_mat.prune(keep_diag());
69  }
70 
72  template <typename SrcType, unsigned int SrcUpLo>
73  void operator()(const SparseSelfAdjointView<SrcType, SrcUpLo>& mat, PermutationType& perm)
74  {
75  SparseMatrix<typename SrcType::Scalar, ColMajor, Index> C; C = mat;
76 
77  // Call the AMD routine
78  // m_mat.prune(keep_diag()); //Remove the diagonal elements
80  }
81 };
82 
83 #endif // EIGEN_MPL2_ONLY
84 
93 template <typename Index>
94 class NaturalOrdering
95 {
96  public:
97  typedef PermutationMatrix<Dynamic, Dynamic, Index> PermutationType;
98 
100  template <typename MatrixType>
101  void operator()(const MatrixType& /*mat*/, PermutationType& perm)
102  {
103  perm.resize(0);
104  }
105 
106 };
114 template<typename Index>
116 {
117  public:
120 
122  template <typename MatrixType>
123  void operator() (const MatrixType& mat, PermutationType& perm)
124  {
125  Index m = mat.rows();
126  Index n = mat.cols();
127  Index nnz = mat.nonZeros();
128  // Get the recommended value of Alen to be used by colamd
129  Index Alen = internal::colamd_recommended(nnz, m, n);
130  // Set the default parameters
131  double knobs [COLAMD_KNOBS];
132  Index stats [COLAMD_STATS];
134 
135  Index info;
136  IndexVector p(n+1), A(Alen);
137  for(Index i=0; i <= n; i++) p(i) = mat.outerIndexPtr()[i];
138  for(Index i=0; i < nnz; i++) A(i) = mat.innerIndexPtr()[i];
139  // Call Colamd routine to compute the ordering
140  info = internal::colamd(m, n, Alen, A.data(), p.data(), knobs, stats);
141  eigen_assert( info && "COLAMD failed " );
142 
143  perm.resize(n);
144  for (Index i = 0; i < n; i++) perm.indices()(p(i)) = i;
145  }
146 };
148 } // end namespace Eigen
150 #endif
A versatible sparse matrix representation.
Definition: SparseMatrix.h:85
static bool colamd(Index n_row, Index n_col, Index Alen, Index *A, Index *p, double knobs[COLAMD_KNOBS], Index stats[COLAMD_STATS])
Computes a column ordering using the column approximate minimum degree ordering.
Definition: Ordering.h:330
Matrix< Index, Dynamic, 1 > IndexVector
Definition: Ordering.h:119
void operator()(const MatrixType &mat, PermutationType &perm)
Definition: Ordering.h:60
Definition: LDLT.h:16
Pseudo expression to manipulate a triangular sparse matrix as a selfadjoint matrix.
void operator()(const SparseSelfAdjointView< SrcType, SrcUpLo > &mat, PermutationType &perm)
Definition: Ordering.h:73
void operator()(const MatrixType &, PermutationType &perm)
Definition: Ordering.h:101
EIGEN_STRONG_INLINE Index rows() const
void minimum_degree_ordering(SparseMatrix< Scalar, ColMajor, Index > &C, PermutationMatrix< Dynamic, Dynamic, Index > &perm)
Definition: Amd.h:91
static void colamd_set_defaults(double knobs[COLAMD_KNOBS])
set default parameters The use of this routine is optional.
Definition: Ordering.h:294
PermutationMatrix< Dynamic, Dynamic, Index > PermutationType
Definition: Ordering.h:54
const IndicesType & indices() const
#define COLAMD_KNOBS
void ordering_helper_at_plus_a(const MatrixType &mat, MatrixType &symmat)
Definition: Ordering.h:26
Index colamd_recommended(Index nnz, Index n_row, Index n_col)
Returns the recommended value of Alen.
Definition: Ordering.h:265
#define eigen_assert(x)
void resize(Index newSize)
PermutationMatrix< Dynamic, Dynamic, Index > PermutationType
Definition: Ordering.h:118
#define COLAMD_STATS


tuw_aruco
Author(s): Lukas Pfeifhofer
autogenerated on Mon Jun 10 2019 15:40:54