xref: /aosp_15_r20/external/eigen/Eigen/OrderingMethods (revision bf2c37156dfe67e5dfebd6d394bad8b2ab5804d4)
1*bf2c3715SXin Li// This file is part of Eigen, a lightweight C++ template library
2*bf2c3715SXin Li// for linear algebra.
3*bf2c3715SXin Li//
4*bf2c3715SXin Li// This Source Code Form is subject to the terms of the Mozilla
5*bf2c3715SXin Li// Public License v. 2.0. If a copy of the MPL was not distributed
6*bf2c3715SXin Li// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
7*bf2c3715SXin Li
8*bf2c3715SXin Li#ifndef EIGEN_ORDERINGMETHODS_MODULE_H
9*bf2c3715SXin Li#define EIGEN_ORDERINGMETHODS_MODULE_H
10*bf2c3715SXin Li
11*bf2c3715SXin Li#include "SparseCore"
12*bf2c3715SXin Li
13*bf2c3715SXin Li#include "src/Core/util/DisableStupidWarnings.h"
14*bf2c3715SXin Li
15*bf2c3715SXin Li/**
16*bf2c3715SXin Li  * \defgroup OrderingMethods_Module OrderingMethods module
17*bf2c3715SXin Li  *
18*bf2c3715SXin Li  * This module is currently for internal use only
19*bf2c3715SXin Li  *
20*bf2c3715SXin Li  * It defines various built-in and external ordering methods for sparse matrices.
21*bf2c3715SXin Li  * They are typically used to reduce the number of elements during
22*bf2c3715SXin Li  * the sparse matrix decomposition (LLT, LU, QR).
23*bf2c3715SXin Li  * Precisely, in a preprocessing step, a permutation matrix P is computed using
24*bf2c3715SXin Li  * those ordering methods and applied to the columns of the matrix.
25*bf2c3715SXin Li  * Using for instance the sparse Cholesky decomposition, it is expected that
26*bf2c3715SXin Li  * the nonzeros elements in LLT(A*P) will be much smaller than that in LLT(A).
27*bf2c3715SXin Li  *
28*bf2c3715SXin Li  *
29*bf2c3715SXin Li  * Usage :
30*bf2c3715SXin Li  * \code
31*bf2c3715SXin Li  * #include <Eigen/OrderingMethods>
32*bf2c3715SXin Li  * \endcode
33*bf2c3715SXin Li  *
34*bf2c3715SXin Li  * A simple usage is as a template parameter in the sparse decomposition classes :
35*bf2c3715SXin Li  *
36*bf2c3715SXin Li  * \code
37*bf2c3715SXin Li  * SparseLU<MatrixType, COLAMDOrdering<int> > solver;
38*bf2c3715SXin Li  * \endcode
39*bf2c3715SXin Li  *
40*bf2c3715SXin Li  * \code
41*bf2c3715SXin Li  * SparseQR<MatrixType, COLAMDOrdering<int> > solver;
42*bf2c3715SXin Li  * \endcode
43*bf2c3715SXin Li  *
44*bf2c3715SXin Li  * It is possible as well to call directly a particular ordering method for your own purpose,
45*bf2c3715SXin Li  * \code
46*bf2c3715SXin Li  * AMDOrdering<int> ordering;
47*bf2c3715SXin Li  * PermutationMatrix<Dynamic, Dynamic, int> perm;
48*bf2c3715SXin Li  * SparseMatrix<double> A;
49*bf2c3715SXin Li  * //Fill the matrix ...
50*bf2c3715SXin Li  *
51*bf2c3715SXin Li  * ordering(A, perm); // Call AMD
52*bf2c3715SXin Li  * \endcode
53*bf2c3715SXin Li  *
54*bf2c3715SXin Li  * \note Some of these methods (like AMD or METIS), need the sparsity pattern
55*bf2c3715SXin Li  * of the input matrix to be symmetric. When the matrix is structurally unsymmetric,
56*bf2c3715SXin Li  * Eigen computes internally the pattern of \f$A^T*A\f$ before calling the method.
57*bf2c3715SXin Li  * If your matrix is already symmetric (at leat in structure), you can avoid that
58*bf2c3715SXin Li  * by calling the method with a SelfAdjointView type.
59*bf2c3715SXin Li  *
60*bf2c3715SXin Li  * \code
61*bf2c3715SXin Li  *  // Call the ordering on the pattern of the lower triangular matrix A
62*bf2c3715SXin Li  * ordering(A.selfadjointView<Lower>(), perm);
63*bf2c3715SXin Li  * \endcode
64*bf2c3715SXin Li  */
65*bf2c3715SXin Li
66*bf2c3715SXin Li#include "src/OrderingMethods/Amd.h"
67*bf2c3715SXin Li#include "src/OrderingMethods/Ordering.h"
68*bf2c3715SXin Li#include "src/Core/util/ReenableStupidWarnings.h"
69*bf2c3715SXin Li
70*bf2c3715SXin Li#endif // EIGEN_ORDERINGMETHODS_MODULE_H
71