3rdparty/Eigen/Eigen/src/OrderingMethods/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 
26 template<typename MatrixType>
28 {
29  MatrixType C;
30  C = A.transpose(); // NOTE: Could be costly
31  for (int i = 0; i < C.rows(); i++)
32  {
33  for (typename MatrixType::InnerIterator it(C, i); it; ++it)
34  it.valueRef() = typename MatrixType::Scalar(0);
35  }
36  symmat = C + A;
37 }
38 
39 }
40 
49 template <typename StorageIndex>
51 {
52  public:
54 
58  template <typename MatrixType>
60  {
61  // Compute the symmetric pattern
64 
65  // Call the AMD routine
66  //m_mat.prune(keep_diag());
68  }
69 
71  template <typename SrcType, unsigned int SrcUpLo>
73  {
75 
76  // Call the AMD routine
77  // m_mat.prune(keep_diag()); //Remove the diagonal elements
79  }
80 };
81 
90 template <typename StorageIndex>
92 {
93  public:
95 
97  template <typename MatrixType>
98  void operator()(const MatrixType& /*mat*/, PermutationType& perm)
99  {
100  perm.resize(0);
101  }
102 
103 };
104 
113 template<typename StorageIndex>
115 {
116  public:
119 
123  template <typename MatrixType>
125  {
126  eigen_assert(mat.isCompressed() && "COLAMDOrdering requires a sparse matrix in compressed mode. Call .makeCompressed() before passing it to COLAMDOrdering");
127 
128  StorageIndex m = StorageIndex(mat.rows());
129  StorageIndex n = StorageIndex(mat.cols());
130  StorageIndex nnz = StorageIndex(mat.nonZeros());
131  // Get the recommended value of Alen to be used by colamd
132  StorageIndex Alen = internal::Colamd::recommended(nnz, m, n);
133  // Set the default parameters
134  double knobs [internal::Colamd::NKnobs];
135  StorageIndex stats [internal::Colamd::NStats];
137 
138  IndexVector p(n+1), A(Alen);
139  for(StorageIndex i=0; i <= n; i++) p(i) = mat.outerIndexPtr()[i];
140  for(StorageIndex i=0; i < nnz; i++) A(i) = mat.innerIndexPtr()[i];
141  // Call Colamd routine to compute the ordering
142  StorageIndex info = internal::Colamd::compute_ordering(m, n, Alen, A.data(), p.data(), knobs, stats);
144  eigen_assert( info && "COLAMD failed " );
145 
146  perm.resize(n);
147  for (StorageIndex i = 0; i < n; i++) perm.indices()(p(i)) = i;
148  }
149 };
150 
151 } // end namespace Eigen
152 
153 #endif
perm
idx_t idx_t idx_t idx_t idx_t * perm
Definition: include/metis.h:223
Eigen
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
Eigen::SparseMatrix
A versatible sparse matrix representation.
Definition: SparseMatrix.h:96
MatrixType
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52
Eigen::COLAMDOrdering::PermutationType
PermutationMatrix< Dynamic, Dynamic, StorageIndex > PermutationType
Definition: 3rdparty/Eigen/Eigen/src/OrderingMethods/Ordering.h:117
symm
int EIGEN_BLAS_FUNC() symm(const char *side, const char *uplo, const int *m, const int *n, const RealScalar *palpha, const RealScalar *pa, const int *lda, const RealScalar *pb, const int *ldb, const RealScalar *pbeta, RealScalar *pc, const int *ldc)
Definition: level3_impl.h:287
Eigen::COLAMDOrdering::operator()
void operator()(const MatrixType &mat, PermutationType &perm)
Definition: 3rdparty/Eigen/Eigen/src/OrderingMethods/Ordering.h:124
eigen_assert
#define eigen_assert(x)
Definition: Macros.h:1037
Eigen::AMDOrdering::PermutationType
PermutationMatrix< Dynamic, Dynamic, StorageIndex > PermutationType
Definition: 3rdparty/Eigen/Eigen/src/OrderingMethods/Ordering.h:53
Eigen::NaturalOrdering::operator()
void operator()(const MatrixType &, PermutationType &perm)
Definition: 3rdparty/Eigen/Eigen/src/OrderingMethods/Ordering.h:98
internal::Colamd::recommended
IndexType recommended(IndexType nnz, IndexType n_row, IndexType n_col)
Returns the recommended value of Alen.
Definition: Eigen_Colamd.h:277
mat
MatrixXf mat
Definition: Tutorial_AdvancedInitialization_CommaTemporary.cpp:1
Eigen::AMDOrdering::operator()
void operator()(const SparseSelfAdjointView< SrcType, SrcUpLo > &mat, PermutationType &perm)
Definition: 3rdparty/Eigen/Eigen/src/OrderingMethods/Ordering.h:72
Eigen::AMDOrdering::operator()
void operator()(const MatrixType &mat, PermutationType &perm)
Definition: 3rdparty/Eigen/Eigen/src/OrderingMethods/Ordering.h:59
n
int n
Definition: BiCGSTAB_simple.cpp:1
Eigen::internal::ordering_helper_at_plus_a
void ordering_helper_at_plus_a(const MatrixType &A, MatrixType &symmat)
Definition: 3rdparty/Eigen/Eigen/src/OrderingMethods/Ordering.h:27
A
Definition: test_numpy_dtypes.cpp:298
EIGEN_UNUSED_VARIABLE
#define EIGEN_UNUSED_VARIABLE(var)
Definition: Macros.h:1076
stats
bool stats
Definition: SolverComparer.cpp:100
internal::Colamd::compute_ordering
static bool compute_ordering(IndexType n_row, IndexType n_col, IndexType Alen, IndexType *A, IndexType *p, double knobs[NKnobs], IndexType stats[NStats])
Computes a column ordering using the column approximate minimum degree ordering.
Definition: Eigen_Colamd.h:342
Eigen::AMDOrdering
Definition: 3rdparty/Eigen/Eigen/src/OrderingMethods/Ordering.h:50
Eigen::PlainObjectBase::rows
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: PlainObjectBase.h:143
info
else if n * info
Definition: 3rdparty/Eigen/lapack/cholesky.cpp:18
m
Matrix3f m
Definition: AngleAxis_mimic_euler.cpp:1
internal::Colamd::NKnobs
const int NKnobs
Definition: Eigen_Colamd.h:65
internal::Colamd::set_defaults
static void set_defaults(double knobs[NKnobs])
set default parameters The use of this routine is optional.
Definition: Eigen_Colamd.h:306
C
Matrix< Scalar, Dynamic, Dynamic > C
Definition: bench_gemm.cpp:50
Eigen::COLAMDOrdering
Definition: 3rdparty/Eigen/Eigen/src/OrderingMethods/Ordering.h:114
Eigen::COLAMDOrdering::IndexVector
Matrix< StorageIndex, Dynamic, 1 > IndexVector
Definition: 3rdparty/Eigen/Eigen/src/OrderingMethods/Ordering.h:118
internal::Colamd::NStats
const int NStats
Definition: Eigen_Colamd.h:68
Eigen::PermutationMatrix< Dynamic, Dynamic, StorageIndex >
p
float * p
Definition: Tutorial_Map_using.cpp:9
Eigen::internal::minimum_degree_ordering
void minimum_degree_ordering(SparseMatrix< Scalar, ColMajor, StorageIndex > &C, PermutationMatrix< Dynamic, Dynamic, StorageIndex > &perm)
Definition: Amd.h:84
Eigen_Colamd.h
Eigen::SparseSelfAdjointView
Pseudo expression to manipulate a triangular sparse matrix as a selfadjoint matrix.
Definition: SparseSelfAdjointView.h:43
Eigen::Matrix< StorageIndex, Dynamic, 1 >
internal
Definition: BandTriangularSolver.h:13
Eigen::NaturalOrdering::PermutationType
PermutationMatrix< Dynamic, Dynamic, StorageIndex > PermutationType
Definition: 3rdparty/Eigen/Eigen/src/OrderingMethods/Ordering.h:94
Eigen::NaturalOrdering
Definition: 3rdparty/Eigen/Eigen/src/OrderingMethods/Ordering.h:91
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Scalar
SCALAR Scalar
Definition: bench_gemm.cpp:46


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:03:13