GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GSparseSymbolic.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GSparseSymbolic.hpp - Sparse matrix symbolic analysis class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2006-2013 by Juergen Knoedlseder *
5  * ----------------------------------------------------------------------- *
6  * *
7  * This program is free software: you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation, either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19  * *
20  ***************************************************************************/
21 /**
22  * @file GSparseSymbolic.hpp
23  * @brief Sparse matrix symbolic analysis class definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GSPARSESYMBOLIC_HPP
28 #define GSPARSESYMBOLIC_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 
32 /* __ Definitions ________________________________________________________ */
33 
34 /* __ Enumerators ________________________________________________________ */
35 
36 /* __ Structures _________________________________________________________ */
37 
38 /* __ Prototypes (implementions in GMatrixSparse) ________________________ */
39 GMatrixSparse cs_symperm(const GMatrixSparse& matrix, const int* pinv);
40 GMatrixSparse cs_transpose(const GMatrixSparse& matrix, int values);
41 double cs_cumsum(int* p, int* c, int n);
42 
43 
44 /***********************************************************************//**
45  * @class GSparseSymbolic
46  *
47  * @brief Sparse matrix symbolic analysis class
48  *
49  * This class implements the symbolic analysis of a sparse matrix.
50  ***************************************************************************/
52 
53  // I/O friends
54  friend std::ostream& operator<< (std::ostream& os, const GSparseSymbolic& s);
55 
56  // Friend classes
57  friend class GMatrixSparse;
58  friend class GSparseNumeric;
59 
60 public:
61  // Constructors and destructors
62  GSparseSymbolic(void);
63  virtual ~GSparseSymbolic(void);
64 
65  // Assignment operator
67 
68  // Methods
69  void cholesky_symbolic_analysis(int order, const GMatrixSparse& m);
70 
71 private:
72  // Private methods
73  int* cs_amd (int order, const GMatrixSparse* A);
74  int* cs_counts(const GMatrixSparse* A, const int* parent, const int* post, int ata);
75  int* cs_etree(const GMatrixSparse* A, int ata);
76  int cs_fkeep(GMatrixSparse* A, int(*fkeep)(int, int, double, void*), void* other);
77  int cs_leaf(int i, int j, const int* first, int* maxfirst, int* prevleaf, int* ancestor, int* jleaf);
78  int* cs_pinv(int const* p, int n);
79  int* cs_post(const int* parent, int n);
80  int cs_tdfs(int j, int k, int* head, const int* next, int* post, int* stack);
81  static void init_ata(const GMatrixSparse* AT, const int* post, int* wrk_int, int** head, int** next);
82  static int cs_diag(int i, int j, double aij, void* other);
83  static int cs_wclear(int mark, int lemax, int* w, int n);
84 
85  // Data
86  int* m_pinv; //!< Inverse row permutation for QR, fill reduce permutation for Cholesky
87  int* m_q; //!< Fill-reducing column permutation for LU and QR
88  int* m_parent; //!< elimination tree for Cholesky and QR
89  int* m_cp; //!< column pointers for Cholesky, row counts for QR
90  int* m_leftmost; //!< leftmost[i] = min(find(A(i,:))), for QR
91  int m_m2; //!< # of rows for QR, after adding fictitious rows
92  double m_lnz; //!< # entries in L for LU or Cholesky; in V for QR
93  double m_unz; //!< # entries in U for LU; in R for QR
94  int m_n_pinv; //!< Number of elements in m_pinv
95  int m_n_q; //!< Number of elements in m_q
96  int m_n_parent; //!< Number of elements in m_parent
97  int m_n_cp; //!< Number of elements in m_cp
98  int m_n_leftmost; //!< Number of elements in m_leftmost
99 };
100 
101 #endif /* GSPARSESYMBOLIC_HPP */
static void init_ata(const GMatrixSparse *AT, const int *post, int *wrk_int, int **head, int **next)
GMatrixSparse cs_symperm(const GMatrixSparse &matrix, const int *pinv)
cs_symperm
void cholesky_symbolic_analysis(int order, const GMatrixSparse &m)
int * cs_post(const int *parent, int n)
int * m_parent
elimination tree for Cholesky and QR
int * m_cp
column pointers for Cholesky, row counts for QR
double m_lnz
entries in L for LU or Cholesky; in V for QR
Sparse matrix class interface definition.
int * m_leftmost
leftmost[i] = min(find(A(i,:))), for QR
GMatrixSparse cs_transpose(const GMatrixSparse &matrix, int values)
int cs_leaf(int i, int j, const int *first, int *maxfirst, int *prevleaf, int *ancestor, int *jleaf)
int cs_tdfs(int j, int k, int *head, const int *next, int *post, int *stack)
int m_n_cp
Number of elements in m_cp.
int m_n_parent
Number of elements in m_parent.
static int cs_wclear(int mark, int lemax, int *w, int n)
virtual ~GSparseSymbolic(void)
Destructor.
Sparse matrix symbolic analysis class.
GSparseSymbolic(void)
Void constructor.
int m_n_leftmost
Number of elements in m_leftmost.
int * m_pinv
Inverse row permutation for QR, fill reduce permutation for Cholesky.
GSparseSymbolic & operator=(const GSparseSymbolic &s)
double cs_cumsum(int *p, int *c, int n)
cs_cumsum
int * m_q
Fill-reducing column permutation for LU and QR.
int * cs_amd(int order, const GMatrixSparse *A)
int * cs_counts(const GMatrixSparse *A, const int *parent, const int *post, int ata)
Sparse matrix numeric analysis class.
int m_n_q
Number of elements in m_q.
int * cs_etree(const GMatrixSparse *A, int ata)
int * cs_pinv(int const *p, int n)
double m_unz
entries in U for LU; in R for QR
int m_n_pinv
Number of elements in m_pinv.
int cs_fkeep(GMatrixSparse *A, int(*fkeep)(int, int, double, void *), void *other)
cs_fkeep
friend std::ostream & operator<<(std::ostream &os, const GSparseSymbolic &s)
int m_m2
of rows for QR, after adding fictitious rows
static int cs_diag(int i, int j, double aij, void *other)