All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
csparse.h
1 #ifndef _CS_H
2 #define _CS_H
3 
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7 
8 #include <stdio.h>
9 
10 #ifdef MATLAB_MEX_FILE
11 #include "mex.h"
12 #endif
13 #define CS_VER 1 /* CSparse Version 1.2.0 */
14 #define CS_SUBVER 2
15 #define CS_SUBSUB 0
16 #define CS_DATE "Mar 6, 2006" /* CSparse release date */
17 #define CS_COPYRIGHT "Copyright (c) Timothy A. Davis, 2006"
18 
19 /* --- primary CSparse routines and data structures ------------------------- */
20 typedef struct cs_sparse /* matrix in compressed-column or triplet form */
21 {
22  int nzmax ; /* maximum number of entries */
23  int m ; /* number of rows */
24  int n ; /* number of columns */
25  int *p ; /* column pointers (size n+1) or col indices (size nzmax) */
26  int *i ; /* row indices, size nzmax */
27  double *x ; /* numerical values, size nzmax */
28  int nz ; /* # of entries in triplet matrix, -1 for compressed-col */
29 } cs ;
30 
31 cs *cs_add (const cs *A, const cs *B, double alpha, double beta) ;
32 int cs_cholsol (const cs *A, double *b, int order) ;
33 int cs_dupl (cs *A) ;
34 int cs_entry (cs *T, int i, int j, double x) ;
35 int cs_lusol (const cs *A, double *b, int order, double tol) ;
36 int cs_gaxpy (const cs *A, const double *x, double *y) ;
37 cs *cs_multiply (const cs *A, const cs *B) ;
38 int cs_qrsol (const cs *A, double *b, int order) ;
39 cs *cs_transpose (const cs *A, int values) ;
40 cs *cs_triplet (const cs *T) ;
41 cs *cs_compress_LLM(const double *ele, const int lda, const int m, const int n, const int nz, const int I1, const int TwoD);
42 double cs_norm (const cs *A) ;
43 int cs_print (const cs *A, int brief) ;
44 cs *cs_load (FILE *f) ;
45 /* utilities */
46 void *cs_calloc (int n, size_t size) ;
47 void *cs_free (void *p) ;
48 void *cs_realloc (void *p, int n, size_t size, int *ok) ;
49 cs *cs_spalloc (int m, int n, int nzmax, int values, int triplet) ;
50 cs *cs_spfree (cs *A) ;
51 int cs_sprealloc (cs *A, int nzmax) ;
52 void *cs_malloc (int n, size_t size) ;
53 
54 /* --- secondary CSparse routines and data structures ----------------------- */
55 typedef struct cs_symbolic /* symbolic Cholesky, LU, or QR analysis */
56 {
57  int *Pinv ; /* inverse row perm. for QR, fill red. perm for Chol */
58  int *Q ; /* fill-reducing column permutation for LU and QR */
59  int *parent ; /* elimination tree for Cholesky and QR */
60  int *cp ; /* column pointers for Cholesky, row counts for QR */
61  int m2 ; /* # of rows for QR, after adding fictitious rows */
62  int lnz ; /* # entries in L for LU or Cholesky; in V for QR */
63  int unz ; /* # entries in U for LU; in R for QR */
64 } css ;
65 
66 typedef struct cs_numeric /* numeric Cholesky, LU, or QR factorization */
67 {
68  cs *L ; /* L for LU and Cholesky, V for QR */
69  cs *U ; /* U for LU, R for QR, not used for Cholesky */
70  int *Pinv ; /* partial pivoting for LU */
71  double *B ; /* beta [0..n-1] for QR */
72 } csn ;
73 
74 typedef struct cs_dmperm_results /* cs_dmperm or cs_scc output */
75 {
76  int *P ; /* size m, row permutation */
77  int *Q ; /* size n, column permutation */
78  int *R ; /* size nb+1, block k is rows R[k] to R[k+1]-1 in A(P,Q) */
79  int *S ; /* size nb+1, block k is cols S[k] to S[k+1]-1 in A(P,Q) */
80  int nb ; /* # of blocks in fine dmperm decomposition */
81  int rr [5] ; /* coarse row decomposition */
82  int cc [5] ; /* coarse column decomposition */
83 } csd ;
84 
85 int *cs_amd (const cs *A, int order) ;
86 csn *cs_chol (const cs *A, const css *S) ;
87 csd *cs_dmperm (const cs *A) ;
88 int cs_droptol (cs *A, double tol) ;
89 int cs_dropzeros (cs *A) ;
90 int cs_happly (const cs *V, int i, double beta, double *x) ;
91 int cs_ipvec (int n, const int *P, const double *b, double *x) ;
92 int cs_lsolve (const cs *L, double *x) ;
93 int cs_ltsolve (const cs *L, double *x) ;
94 csn *cs_lu (const cs *A, const css *S, double tol) ;
95 cs *cs_permute (const cs *A, const int *P, const int *Q, int values) ;
96 int *cs_pinv (const int *P, int n) ;
97 int cs_pvec (int n, const int *P, const double *b, double *x) ;
98 csn *cs_qr (const cs *A, const css *S) ;
99 css *cs_schol (const cs *A, int order) ;
100 css *cs_sqr (const cs *A, int order, int qr) ;
101 cs *cs_symperm (const cs *A, const int *Pinv, int values) ;
102 int cs_usolve (const cs *U, double *x) ;
103 int cs_utsolve (const cs *U, double *x) ;
104 int cs_updown (cs *L, int sigma, const cs *C, const int *parent) ;
105 /* utilities */
106 css *cs_sfree (css *S) ;
107 csn *cs_nfree (csn *N) ;
108 csd *cs_dfree (csd *D) ;
109 
110 /* --- tertiary CSparse routines -------------------------------------------- */
111 int *cs_counts (const cs *A, const int *parent, const int *post, int ata) ;
112 int cs_cumsum (int *p, int *c, int n) ;
113 int cs_dfs (int j, cs *L, int top, int *xi, int *pstack, const int *Pinv) ;
114 int *cs_etree (const cs *A, int ata) ;
115 int cs_fkeep (cs *A, int (*fkeep) (int, int, double, void *), void *other) ;
116 double cs_house (double *x, double *beta, int n) ;
117 int *cs_maxtrans (const cs *A) ;
118 int *cs_post (int n, const int *parent) ;
119 int cs_reach (cs *L, const cs *B, int k, int *xi, const int *Pinv) ;
120 csd *cs_scc (cs *A) ;
121 int cs_scatter (const cs *A, int j, double beta, int *w, double *x, int mark,
122  cs *C, int nz) ;
123 int cs_splsolve (cs *L, const cs *B, int k, int *xi, double *x,
124  const int *Pinv) ;
125 int cs_tdfs (int j, int k, int *head, const int *next, int *post,
126  int *stack) ;
127 /* utilities */
128 csd *cs_dalloc (int m, int n) ;
129 cs *cs_done (cs *C, void *w, void *x, int ok) ;
130 int *cs_idone (int *p, cs *C, void *w, int ok) ;
131 csn *cs_ndone (csn *N, cs *C, void *w, void *x, int ok) ;
132 csd *cs_ddone (csd *D, cs *C, void *w, int ok) ;
133 
134 #define CS_MAX(a,b) (((a) > (b)) ? (a) : (b))
135 #define CS_MIN(a,b) (((a) < (b)) ? (a) : (b))
136 #define CS_FLIP(i) (-(i)-2)
137 #define CS_UNFLIP(i) (((i) < 0) ? CS_FLIP(i) : (i))
138 #define CS_MARKED(Ap,j) (Ap [j] < 0)
139 #define CS_MARK(Ap,j) { Ap [j] = CS_FLIP (Ap [j]) ; }
140 #define CS_OVERFLOW(n,size) (n > INT_MAX / (int) size)
141 
142 #ifdef __cplusplus
143 }
144 #endif
145 
146 #endif
147 
Definition: csparse.h:66
Definition: csparse.h:74
Definition: csparse.h:20
Definition: csparse.h:55

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML