~logan/ubuntu/trusty/suitesparse/4.2.1-3ubuntu1

« back to all changes in this revision

Viewing changes to CXSparse/Source/cs.h

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Prud'homme
  • Date: 2007-05-29 09:36:29 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070529093629-zowquo0b7slkk6nc
Tags: 3.0.0-2
* suitesparse builds properly twice in a row
* Bug fix: "suitesparse - FTBFS: Broken build depens: libgfortran1-dev",
  thanks to Bastian Blank (Closes: #426349).
* Bug fix: "suitesparse_3.0.0-1: FTBFS: build-depends on
  libgfortran1-dev", thanks to Steve Langasek (Closes: #426354).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef _CXS_H
2
 
#define _CXS_H
3
 
#include <stdlib.h>
4
 
#include <limits.h>
5
 
#include <math.h>
6
 
#include <stdio.h>
7
 
#ifdef MATLAB_MEX_FILE
8
 
#include "mex.h"
9
 
#endif
10
 
 
11
 
#ifdef __cplusplus
12
 
extern "C" {
13
 
#else
14
 
#include <complex.h>
15
 
#endif
16
 
 
17
 
#define CS_VER 2                    /* CXSparse Version 2.0.6 */
18
 
#define CS_SUBVER 0
19
 
#define CS_SUBSUB 6
20
 
#define CS_DATE "Dec 7, 2006"       /* CXSparse release date */
21
 
#define CS_COPYRIGHT "Copyright (c) Timothy A. Davis, 2006"
22
 
#define CXSPARSE
23
 
 
24
 
/* define UF_long */
25
 
#include "UFconfig.h"
26
 
 
27
 
/* -------------------------------------------------------------------------- */
28
 
/* double/int version of CXSparse */
29
 
/* -------------------------------------------------------------------------- */
30
 
 
31
 
/* --- primary CSparse routines and data structures ------------------------- */
32
 
 
33
 
typedef struct cs_di_sparse  /* matrix in compressed-column or triplet form */
34
 
{
35
 
    int nzmax ;     /* maximum number of entries */
36
 
    int m ;         /* number of rows */
37
 
    int n ;         /* number of columns */
38
 
    int *p ;        /* column pointers (size n+1) or col indices (size nzmax) */
39
 
    int *i ;        /* row indices, size nzmax */
40
 
    double *x ;     /* numerical values, size nzmax */
41
 
    int nz ;        /* # of entries in triplet matrix, -1 for compressed-col */
42
 
} cs_di ;
43
 
 
44
 
cs_di *cs_di_add (const cs_di *A, const cs_di *B, double alpha, double beta) ;
45
 
int cs_di_cholsol (int order, const cs_di *A, double *b) ;
46
 
int cs_di_dupl (cs_di *A) ;
47
 
int cs_di_entry (cs_di *T, int i, int j, double x) ;
48
 
int cs_di_lusol (int order, const cs_di *A, double *b, double tol) ;
49
 
int cs_di_gaxpy (const cs_di *A, const double *x, double *y) ;
50
 
cs_di *cs_di_multiply (const cs_di *A, const cs_di *B) ;
51
 
int cs_di_qrsol (int order, const cs_di *A, double *b) ;
52
 
cs_di *cs_di_transpose (const cs_di *A, int values) ;
53
 
cs_di *cs_di_compress (const cs_di *T) ;
54
 
double cs_di_norm (const cs_di *A) ;
55
 
int cs_di_print (const cs_di *A, int brief) ;
56
 
cs_di *cs_di_load (FILE *f) ;
57
 
 
58
 
/* utilities */
59
 
void *cs_di_calloc (int n, size_t size) ;
60
 
void *cs_di_free (void *p) ;
61
 
void *cs_di_realloc (void *p, int n, size_t size, int *ok) ;
62
 
cs_di *cs_di_spalloc (int m, int n, int nzmax, int values, int t) ;
63
 
cs_di *cs_di_spfree (cs_di *A) ;
64
 
int cs_di_sprealloc (cs_di *A, int nzmax) ;
65
 
void *cs_di_malloc (int n, size_t size) ;
66
 
 
67
 
/* --- secondary CSparse routines and data structures ----------------------- */
68
 
 
69
 
typedef struct cs_di_symbolic  /* symbolic Cholesky, LU, or QR analysis */
70
 
{
71
 
    int *pinv ;     /* inverse row perm. for QR, fill red. perm for Chol */
72
 
    int *q ;        /* fill-reducing column permutation for LU and QR */
73
 
    int *parent ;   /* elimination tree for Cholesky and QR */
74
 
    int *cp ;       /* column pointers for Cholesky, row counts for QR */
75
 
    int *leftmost ; /* leftmost[i] = min(find(A(i,:))), for QR */
76
 
    int m2 ;        /* # of rows for QR, after adding fictitious rows */
77
 
    double lnz ;    /* # entries in L for LU or Cholesky; in V for QR */
78
 
    double unz ;    /* # entries in U for LU; in R for QR */
79
 
} cs_dis ;
80
 
 
81
 
typedef struct cs_di_numeric   /* numeric Cholesky, LU, or QR factorization */
82
 
{
83
 
    cs_di *L ;      /* L for LU and Cholesky, V for QR */
84
 
    cs_di *U ;      /* U for LU, r for QR, not used for Cholesky */
85
 
    int *pinv ;     /* partial pivoting for LU */
86
 
    double *B ;     /* beta [0..n-1] for QR */
87
 
} cs_din ;
88
 
 
89
 
typedef struct cs_di_dmperm_results    /* cs_di_dmperm or cs_di_scc output */
90
 
{
91
 
    int *p ;        /* size m, row permutation */
92
 
    int *q ;        /* size n, column permutation */
93
 
    int *r ;        /* size nb+1, block k is rows r[k] to r[k+1]-1 in A(p,q) */
94
 
    int *s ;        /* size nb+1, block k is cols s[k] to s[k+1]-1 in A(p,q) */
95
 
    int nb ;        /* # of blocks in fine dmperm decomposition */
96
 
    int rr [5] ;    /* coarse row decomposition */
97
 
    int cc [5] ;    /* coarse column decomposition */
98
 
} cs_did ;
99
 
 
100
 
int *cs_di_amd (int order, const cs_di *A) ;
101
 
cs_din *cs_di_chol (const cs_di *A, const cs_dis *S) ;
102
 
cs_did *cs_di_dmperm (const cs_di *A, int seed) ;
103
 
int cs_di_droptol (cs_di *A, double tol) ;
104
 
int cs_di_dropzeros (cs_di *A) ;
105
 
int cs_di_happly (const cs_di *V, int i, double beta, double *x) ;
106
 
int cs_di_ipvec (const int *p, const double *b, double *x, int n) ;
107
 
int cs_di_lsolve (const cs_di *L, double *x) ;
108
 
int cs_di_ltsolve (const cs_di *L, double *x) ;
109
 
cs_din *cs_di_lu (const cs_di *A, const cs_dis *S, double tol) ;
110
 
cs_di *cs_di_permute (const cs_di *A, const int *p, const int *q, int values) ;
111
 
int *cs_di_pinv (const int *p, int n) ;
112
 
int cs_di_pvec (const int *p, const double *b, double *x, int n) ;
113
 
cs_din *cs_di_qr (const cs_di *A, const cs_dis *S) ;
114
 
cs_dis *cs_di_schol (int order, const cs_di *A) ;
115
 
cs_dis *cs_di_sqr (int order, const cs_di *A, int qr) ;
116
 
cs_di *cs_di_symperm (const cs_di *A, const int *pinv, int values) ;
117
 
int cs_di_usolve (const cs_di *U, double *x) ;
118
 
int cs_di_utsolve (const cs_di *U, double *x) ;
119
 
int cs_di_updown (cs_di *L, int sigma, const cs_di *C, const int *parent) ;
120
 
 
121
 
/* utilities */
122
 
cs_dis *cs_di_sfree (cs_dis *S) ;
123
 
cs_din *cs_di_nfree (cs_din *N) ;
124
 
cs_did *cs_di_dfree (cs_did *D) ;
125
 
 
126
 
/* --- tertiary CSparse routines -------------------------------------------- */
127
 
 
128
 
int *cs_di_counts (const cs_di *A, const int *parent, const int *post,
129
 
    int ata) ;
130
 
double cs_di_cumsum (int *p, int *c, int n) ;
131
 
int cs_di_dfs (int j, cs_di *G, int top, int *xi, int *pstack,
132
 
    const int *pinv) ;
133
 
int *cs_di_etree (const cs_di *A, int ata) ;
134
 
int cs_di_fkeep (cs_di *A, int (*fkeep) (int, int, double, void *),
135
 
    void *other) ;
136
 
double cs_di_house (double *x, double *beta, int n) ;
137
 
int *cs_di_maxtrans (const cs_di *A, int seed) ;
138
 
int *cs_di_post (const int *parent, int n) ;
139
 
cs_did *cs_di_scc (cs_di *A) ;
140
 
int cs_di_scatter (const cs_di *A, int j, double beta, int *w, double *x,
141
 
    int mark, cs_di *C, int nz) ;
142
 
int cs_di_tdfs (int j, int k, int *head, const int *next, int *post,
143
 
    int *stack) ;
144
 
int cs_di_leaf (int i, int j, const int *first, int *maxfirst, int *prevleaf,
145
 
    int *ancestor, int *jleaf) ;
146
 
int cs_di_reach (cs_di *G, const cs_di *B, int k, int *xi, const int *pinv) ;
147
 
int cs_di_spsolve (cs_di *L, const cs_di *B, int k, int *xi, double *x,
148
 
    const int *pinv, int lo) ;
149
 
int cs_di_ereach (const cs_di *A, int k, const int *parent, int *s, int *w) ;
150
 
int *cs_di_randperm (int n, int seed) ;
151
 
 
152
 
/* utilities */
153
 
cs_did *cs_di_dalloc (int m, int n) ;
154
 
cs_di *cs_di_done (cs_di *C, void *w, void *x, int ok) ;
155
 
int *cs_di_idone (int *p, cs_di *C, void *w, int ok) ;
156
 
cs_din *cs_di_ndone (cs_din *N, cs_di *C, void *w, void *x, int ok) ;
157
 
cs_did *cs_di_ddone (cs_did *D, cs_di *C, void *w, int ok) ;
158
 
 
159
 
 
160
 
/* -------------------------------------------------------------------------- */
161
 
/* double/UF_long version of CXSparse */
162
 
/* -------------------------------------------------------------------------- */
163
 
 
164
 
/* --- primary CSparse routines and data structures ------------------------- */
165
 
 
166
 
typedef struct cs_dl_sparse  /* matrix in compressed-column or triplet form */
167
 
{
168
 
    UF_long nzmax ; /* maximum number of entries */
169
 
    UF_long m ;     /* number of rows */
170
 
    UF_long n ;     /* number of columns */
171
 
    UF_long *p ;    /* column pointers (size n+1) or col indlces (size nzmax) */
172
 
    UF_long *i ;    /* row indices, size nzmax */
173
 
    double *x ;     /* numerical values, size nzmax */
174
 
    UF_long nz ;    /* # of entries in triplet matrix, -1 for compressed-col */
175
 
} cs_dl ;
176
 
 
177
 
cs_dl *cs_dl_add (const cs_dl *A, const cs_dl *B, double alpha, double beta) ;
178
 
UF_long cs_dl_cholsol (UF_long order, const cs_dl *A, double *b) ;
179
 
UF_long cs_dl_dupl (cs_dl *A) ;
180
 
UF_long cs_dl_entry (cs_dl *T, UF_long i, UF_long j, double x) ;
181
 
UF_long cs_dl_lusol (UF_long order, const cs_dl *A, double *b, double tol) ;
182
 
UF_long cs_dl_gaxpy (const cs_dl *A, const double *x, double *y) ;
183
 
cs_dl *cs_dl_multiply (const cs_dl *A, const cs_dl *B) ;
184
 
UF_long cs_dl_qrsol (UF_long order, const cs_dl *A, double *b) ;
185
 
cs_dl *cs_dl_transpose (const cs_dl *A, UF_long values) ;
186
 
cs_dl *cs_dl_compress (const cs_dl *T) ;
187
 
double cs_dl_norm (const cs_dl *A) ;
188
 
UF_long cs_dl_print (const cs_dl *A, UF_long brief) ;
189
 
cs_dl *cs_dl_load (FILE *f) ;
190
 
 
191
 
/* utilities */
192
 
void *cs_dl_calloc (UF_long n, size_t size) ;
193
 
void *cs_dl_free (void *p) ;
194
 
void *cs_dl_realloc (void *p, UF_long n, size_t size, UF_long *ok) ;
195
 
cs_dl *cs_dl_spalloc (UF_long m, UF_long n, UF_long nzmax, UF_long values,
196
 
    UF_long t) ;
197
 
cs_dl *cs_dl_spfree (cs_dl *A) ;
198
 
UF_long cs_dl_sprealloc (cs_dl *A, UF_long nzmax) ;
199
 
void *cs_dl_malloc (UF_long n, size_t size) ;
200
 
 
201
 
/* --- secondary CSparse routines and data structures ----------------------- */
202
 
 
203
 
typedef struct cs_dl_symbolic  /* symbolic Cholesky, LU, or QR analysis */
204
 
{
205
 
    UF_long *pinv ;     /* inverse row perm. for QR, fill red. perm for Chol */
206
 
    UF_long *q ;        /* fill-reducing column permutation for LU and QR */
207
 
    UF_long *parent ;   /* elimination tree for Cholesky and QR */
208
 
    UF_long *cp ;       /* column pointers for Cholesky, row counts for QR */
209
 
    UF_long *leftmost ; /* leftmost[i] = min(find(A(i,:))), for QR */
210
 
    UF_long m2 ;        /* # of rows for QR, after adding fictitious rows */
211
 
    double lnz ;        /* # entries in L for LU or Cholesky; in V for QR */
212
 
    double unz ;        /* # entries in U for LU; in R for QR */
213
 
} cs_dls ;
214
 
 
215
 
typedef struct cs_dl_numeric   /* numeric Cholesky, LU, or QR factorization */
216
 
{
217
 
    cs_dl *L ;      /* L for LU and Cholesky, V for QR */
218
 
    cs_dl *U ;      /* U for LU, r for QR, not used for Cholesky */
219
 
    UF_long *pinv ; /* partial pivoting for LU */
220
 
    double *B ;     /* beta [0..n-1] for QR */
221
 
} cs_dln ;
222
 
 
223
 
typedef struct cs_dl_dmperm_results    /* cs_dl_dmperm or cs_dl_scc output */
224
 
{
225
 
    UF_long *p ;    /* size m, row permutation */
226
 
    UF_long *q ;    /* size n, column permutation */
227
 
    UF_long *r ;    /* size nb+1, block k is rows r[k] to r[k+1]-1 in A(p,q) */
228
 
    UF_long *s ;    /* size nb+1, block k is cols s[k] to s[k+1]-1 in A(p,q) */
229
 
    UF_long nb ;    /* # of blocks in fine dmperm decomposition */
230
 
    UF_long rr [5] ;    /* coarse row decomposition */
231
 
    UF_long cc [5] ;    /* coarse column decomposition */
232
 
} cs_dld ;
233
 
 
234
 
UF_long *cs_dl_amd (UF_long order, const cs_dl *A) ;
235
 
cs_dln *cs_dl_chol (const cs_dl *A, const cs_dls *S) ;
236
 
cs_dld *cs_dl_dmperm (const cs_dl *A, UF_long seed) ;
237
 
UF_long cs_dl_droptol (cs_dl *A, double tol) ;
238
 
UF_long cs_dl_dropzeros (cs_dl *A) ;
239
 
UF_long cs_dl_happly (const cs_dl *V, UF_long i, double beta, double *x) ;
240
 
UF_long cs_dl_ipvec (const UF_long *p, const double *b, double *x, UF_long n) ;
241
 
UF_long cs_dl_lsolve (const cs_dl *L, double *x) ;
242
 
UF_long cs_dl_ltsolve (const cs_dl *L, double *x) ;
243
 
cs_dln *cs_dl_lu (const cs_dl *A, const cs_dls *S, double tol) ;
244
 
cs_dl *cs_dl_permute (const cs_dl *A, const UF_long *p, const UF_long *q,
245
 
    UF_long values) ;
246
 
UF_long *cs_dl_pinv (const UF_long *p, UF_long n) ;
247
 
UF_long cs_dl_pvec (const UF_long *p, const double *b, double *x, UF_long n) ;
248
 
cs_dln *cs_dl_qr (const cs_dl *A, const cs_dls *S) ;
249
 
cs_dls *cs_dl_schol (UF_long order, const cs_dl *A) ;
250
 
cs_dls *cs_dl_sqr (UF_long order, const cs_dl *A, UF_long qr) ;
251
 
cs_dl *cs_dl_symperm (const cs_dl *A, const UF_long *pinv, UF_long values) ;
252
 
UF_long cs_dl_usolve (const cs_dl *U, double *x) ;
253
 
UF_long cs_dl_utsolve (const cs_dl *U, double *x) ;
254
 
UF_long cs_dl_updown (cs_dl *L, UF_long sigma, const cs_dl *C,
255
 
    const UF_long *parent) ;
256
 
 
257
 
/* utilities */
258
 
cs_dls *cs_dl_sfree (cs_dls *S) ;
259
 
cs_dln *cs_dl_nfree (cs_dln *N) ;
260
 
cs_dld *cs_dl_dfree (cs_dld *D) ;
261
 
 
262
 
/* --- tertiary CSparse routines -------------------------------------------- */
263
 
 
264
 
UF_long *cs_dl_counts (const cs_dl *A, const UF_long *parent,
265
 
    const UF_long *post, UF_long ata) ;
266
 
double cs_dl_cumsum (UF_long *p, UF_long *c, UF_long n) ;
267
 
UF_long cs_dl_dfs (UF_long j, cs_dl *G, UF_long top, UF_long *xi,
268
 
    UF_long *pstack, const UF_long *pinv) ;
269
 
UF_long *cs_dl_etree (const cs_dl *A, UF_long ata) ;
270
 
UF_long cs_dl_fkeep (cs_dl *A,
271
 
    UF_long (*fkeep) (UF_long, UF_long, double, void *), void *other) ;
272
 
double cs_dl_house (double *x, double *beta, UF_long n) ;
273
 
UF_long *cs_dl_maxtrans (const cs_dl *A, UF_long seed) ;
274
 
UF_long *cs_dl_post (const UF_long *parent, UF_long n) ;
275
 
cs_dld *cs_dl_scc (cs_dl *A) ;
276
 
UF_long cs_dl_scatter (const cs_dl *A, UF_long j, double beta, UF_long *w,
277
 
    double *x, UF_long mark,cs_dl *C, UF_long nz) ;
278
 
UF_long cs_dl_tdfs (UF_long j, UF_long k, UF_long *head, const UF_long *next,
279
 
    UF_long *post, UF_long *stack) ;
280
 
UF_long cs_dl_leaf (UF_long i, UF_long j, const UF_long *first,
281
 
    UF_long *maxfirst, UF_long *prevleaf, UF_long *ancestor, UF_long *jleaf) ;
282
 
UF_long cs_dl_reach (cs_dl *G, const cs_dl *B, UF_long k, UF_long *xi,
283
 
    const UF_long *pinv) ;
284
 
UF_long cs_dl_spsolve (cs_dl *L, const cs_dl *B, UF_long k, UF_long *xi,
285
 
    double *x, const UF_long *pinv, UF_long lo) ;
286
 
UF_long cs_dl_ereach (const cs_dl *A, UF_long k, const UF_long *parent,
287
 
    UF_long *s, UF_long *w) ;
288
 
UF_long *cs_dl_randperm (UF_long n, UF_long seed) ;
289
 
 
290
 
/* utilities */
291
 
cs_dld *cs_dl_dalloc (UF_long m, UF_long n) ;
292
 
cs_dl *cs_dl_done (cs_dl *C, void *w, void *x, UF_long ok) ;
293
 
UF_long *cs_dl_idone (UF_long *p, cs_dl *C, void *w, UF_long ok) ;
294
 
cs_dln *cs_dl_ndone (cs_dln *N, cs_dl *C, void *w, void *x, UF_long ok) ;
295
 
cs_dld *cs_dl_ddone (cs_dld *D, cs_dl *C, void *w, UF_long ok) ;
296
 
 
297
 
 
298
 
/* -------------------------------------------------------------------------- */
299
 
/* complex/int version of CXSparse */
300
 
/* -------------------------------------------------------------------------- */
301
 
 
302
 
/* --- primary CSparse routines and data structures ------------------------- */
303
 
 
304
 
typedef struct cs_ci_sparse  /* matrix in compressed-column or triplet form */
305
 
{
306
 
    int nzmax ;     /* maximum number of entries */
307
 
    int m ;         /* number of rows */
308
 
    int n ;         /* number of columns */
309
 
    int *p ;        /* column pointers (size n+1) or col indices (size nzmax) */
310
 
    int *i ;        /* row indices, size nzmax */
311
 
    double _Complex *x ;    /* numerical values, size nzmax */
312
 
    int nz ;        /* # of entries in triplet matrix, -1 for compressed-col */
313
 
} cs_ci ;
314
 
 
315
 
cs_ci *cs_ci_add (const cs_ci *A, const cs_ci *B, double _Complex alpha,
316
 
    double _Complex beta) ;
317
 
int cs_ci_cholsol (int order, const cs_ci *A, double _Complex *b) ;
318
 
int cs_ci_dupl (cs_ci *A) ;
319
 
int cs_ci_entry (cs_ci *T, int i, int j, double _Complex x) ;
320
 
int cs_ci_lusol (int order, const cs_ci *A, double _Complex *b, double tol) ;
321
 
int cs_ci_gaxpy (const cs_ci *A, const double _Complex *x, double _Complex *y) ;
322
 
cs_ci *cs_ci_multiply (const cs_ci *A, const cs_ci *B) ;
323
 
int cs_ci_qrsol (int order, const cs_ci *A, double _Complex *b) ;
324
 
cs_ci *cs_ci_transpose (const cs_ci *A, int values) ;
325
 
cs_ci *cs_ci_compress (const cs_ci *T) ;
326
 
double cs_ci_norm (const cs_ci *A) ;
327
 
int cs_ci_print (const cs_ci *A, int brief) ;
328
 
cs_ci *cs_ci_load (FILE *f) ;
329
 
 
330
 
/* utilities */
331
 
void *cs_ci_calloc (int n, size_t size) ;
332
 
void *cs_ci_free (void *p) ;
333
 
void *cs_ci_realloc (void *p, int n, size_t size, int *ok) ;
334
 
cs_ci *cs_ci_spalloc (int m, int n, int nzmax, int values, int t) ;
335
 
cs_ci *cs_ci_spfree (cs_ci *A) ;
336
 
int cs_ci_sprealloc (cs_ci *A, int nzmax) ;
337
 
void *cs_ci_malloc (int n, size_t size) ;
338
 
 
339
 
/* --- secondary CSparse routines and data structures ----------------------- */
340
 
 
341
 
typedef struct cs_ci_symbolic  /* symbolic Cholesky, LU, or QR analysis */
342
 
{
343
 
    int *pinv ;     /* inverse row perm. for QR, fill red. perm for Chol */
344
 
    int *q ;        /* fill-reducing column permutation for LU and QR */
345
 
    int *parent ;   /* elimination tree for Cholesky and QR */
346
 
    int *cp ;       /* column pointers for Cholesky, row counts for QR */
347
 
    int *leftmost ; /* leftmost[i] = min(find(A(i,:))), for QR */
348
 
    int m2 ;        /* # of rows for QR, after adding fictitious rows */
349
 
    double lnz ;    /* # entries in L for LU or Cholesky; in V for QR */
350
 
    double unz ;    /* # entries in U for LU; in R for QR */
351
 
} cs_cis ;
352
 
 
353
 
typedef struct cs_ci_numeric   /* numeric Cholesky, LU, or QR factorization */
354
 
{
355
 
    cs_ci *L ;      /* L for LU and Cholesky, V for QR */
356
 
    cs_ci *U ;      /* U for LU, r for QR, not used for Cholesky */
357
 
    int *pinv ;     /* partial pivoting for LU */
358
 
    double _Complex *B ;            /* beta [0..n-1] for QR */
359
 
} cs_cin ;
360
 
 
361
 
typedef struct cs_ci_dmperm_results    /* cs_ci_dmperm or cs_ci_scc output */
362
 
{
363
 
    int *p ;        /* size m, row permutation */
364
 
    int *q ;        /* size n, column permutation */
365
 
    int *r ;        /* size nb+1, block k is rows r[k] to r[k+1]-1 in A(p,q) */
366
 
    int *s ;        /* size nb+1, block k is cols s[k] to s[k+1]-1 in A(p,q) */
367
 
    int nb ;        /* # of blocks in fine dmperm decomposition */
368
 
    int rr [5] ;    /* coarse row decomposition */
369
 
    int cc [5] ;    /* coarse column decomposition */
370
 
} cs_cid ;
371
 
 
372
 
int *cs_ci_amd (int order, const cs_ci *A) ;
373
 
cs_cin *cs_ci_chol (const cs_ci *A, const cs_cis *S) ;
374
 
cs_cid *cs_ci_dmperm (const cs_ci *A, int seed) ;
375
 
int cs_ci_droptol (cs_ci *A, double tol) ;
376
 
int cs_ci_dropzeros (cs_ci *A) ;
377
 
int cs_ci_happly (const cs_ci *V, int i, double _Complex beta,
378
 
    double _Complex *x) ;
379
 
int cs_ci_ipvec (const int *p, const double _Complex *b,
380
 
    double _Complex *x, int n) ;
381
 
int cs_ci_lsolve (const cs_ci *L, double _Complex *x) ;
382
 
int cs_ci_ltsolve (const cs_ci *L, double _Complex *x) ;
383
 
cs_cin *cs_ci_lu (const cs_ci *A, const cs_cis *S, double tol) ;
384
 
cs_ci *cs_ci_permute (const cs_ci *A, const int *p, const int *q, int values) ;
385
 
int *cs_ci_pinv (const int *p, int n) ;
386
 
int cs_ci_pvec (const int *p, const double _Complex *b,
387
 
    double _Complex *x, int n) ;
388
 
cs_cin *cs_ci_qr (const cs_ci *A, const cs_cis *S) ;
389
 
cs_cis *cs_ci_schol (int order, const cs_ci *A) ;
390
 
cs_cis *cs_ci_sqr (int order, const cs_ci *A, int qr) ;
391
 
cs_ci *cs_ci_symperm (const cs_ci *A, const int *pinv, int values) ;
392
 
int cs_ci_usolve (const cs_ci *U, double _Complex *x) ;
393
 
int cs_ci_utsolve (const cs_ci *U, double _Complex *x) ;
394
 
int cs_ci_updown (cs_ci *L, int sigma, const cs_ci *C, const int *parent) ;
395
 
 
396
 
/* utilities */
397
 
cs_cis *cs_ci_sfree (cs_cis *S) ;
398
 
cs_cin *cs_ci_nfree (cs_cin *N) ;
399
 
cs_cid *cs_ci_dfree (cs_cid *D) ;
400
 
 
401
 
/* --- tertiary CSparse routines -------------------------------------------- */
402
 
 
403
 
int *cs_ci_counts (const cs_ci *A, const int *parent, const int *post,
404
 
    int ata) ;
405
 
double cs_ci_cumsum (int *p, int *c, int n) ;
406
 
int cs_ci_dfs (int j, cs_ci *G, int top, int *xi, int *pstack,
407
 
    const int *pinv) ;
408
 
int *cs_ci_etree (const cs_ci *A, int ata) ;
409
 
int cs_ci_fkeep (cs_ci *A, int (*fkeep) (int, int, double _Complex, void *),
410
 
    void *other) ;
411
 
double _Complex cs_ci_house (double _Complex *x, double _Complex *beta, int n) ;
412
 
int *cs_ci_maxtrans (const cs_ci *A, int seed) ;
413
 
int *cs_ci_post (const int *parent, int n) ;
414
 
cs_cid *cs_ci_scc (cs_ci *A) ;
415
 
int cs_ci_scatter (const cs_ci *A, int j, double _Complex beta, int *w, 
416
 
    double _Complex *x, int mark,cs_ci *C, int nz) ;
417
 
int cs_ci_tdfs (int j, int k, int *head, const int *next, int *post,
418
 
    int *stack) ;
419
 
int cs_ci_leaf (int i, int j, const int *first, int *maxfirst, int *prevleaf,
420
 
    int *ancestor, int *jleaf) ;
421
 
int cs_ci_reach (cs_ci *G, const cs_ci *B, int k, int *xi, const int *pinv) ;
422
 
int cs_ci_spsolve (cs_ci *L, const cs_ci *B, int k, int *xi, 
423
 
    double _Complex *x, const int *pinv, int lo) ;
424
 
int cs_ci_ereach (const cs_ci *A, int k, const int *parent, int *s, int *w) ;
425
 
int *cs_ci_randperm (int n, int seed) ;
426
 
 
427
 
/* utilities */
428
 
cs_cid *cs_ci_dalloc (int m, int n) ;
429
 
cs_ci *cs_ci_done (cs_ci *C, void *w, void *x, int ok) ;
430
 
int *cs_ci_idone (int *p, cs_ci *C, void *w, int ok) ;
431
 
cs_cin *cs_ci_ndone (cs_cin *N, cs_ci *C, void *w, void *x, int ok) ;
432
 
cs_cid *cs_ci_ddone (cs_cid *D, cs_ci *C, void *w, int ok) ;
433
 
 
434
 
 
435
 
/* -------------------------------------------------------------------------- */
436
 
/* complex/UF_long version of CXSparse */
437
 
/* -------------------------------------------------------------------------- */
438
 
 
439
 
/* --- primary CSparse routines and data structures ------------------------- */
440
 
 
441
 
typedef struct cs_cl_sparse  /* matrix in compressed-column or triplet form */
442
 
{
443
 
    UF_long nzmax ; /* maximum number of entries */
444
 
    UF_long m ;     /* number of rows */
445
 
    UF_long n ;     /* number of columns */
446
 
    UF_long *p ;    /* column pointers (size n+1) or col indlces (size nzmax) */
447
 
    UF_long *i ;    /* row indices, size nzmax */
448
 
    double _Complex *x ;    /* numerical values, size nzmax */
449
 
    UF_long nz ;    /* # of entries in triplet matrix, -1 for compressed-col */
450
 
} cs_cl ;
451
 
 
452
 
cs_cl *cs_cl_add (const cs_cl *A, const cs_cl *B, double _Complex alpha,
453
 
    double _Complex beta) ;
454
 
UF_long cs_cl_cholsol (UF_long order, const cs_cl *A, double _Complex *b) ;
455
 
UF_long cs_cl_dupl (cs_cl *A) ;
456
 
UF_long cs_cl_entry (cs_cl *T, UF_long i, UF_long j, double _Complex x) ;
457
 
UF_long cs_cl_lusol (UF_long order, const cs_cl *A, double _Complex *b,
458
 
    double tol) ;
459
 
UF_long cs_cl_gaxpy (const cs_cl *A, const double _Complex *x,
460
 
    double _Complex *y) ;
461
 
cs_cl *cs_cl_multiply (const cs_cl *A, const cs_cl *B) ;
462
 
UF_long cs_cl_qrsol (UF_long order, const cs_cl *A, double _Complex *b) ;
463
 
cs_cl *cs_cl_transpose (const cs_cl *A, UF_long values) ;
464
 
cs_cl *cs_cl_compress (const cs_cl *T) ;
465
 
double cs_cl_norm (const cs_cl *A) ;
466
 
UF_long cs_cl_print (const cs_cl *A, UF_long brief) ;
467
 
cs_cl *cs_cl_load (FILE *f) ;
468
 
 
469
 
/* utilities */
470
 
void *cs_cl_calloc (UF_long n, size_t size) ;
471
 
void *cs_cl_free (void *p) ;
472
 
void *cs_cl_realloc (void *p, UF_long n, size_t size, UF_long *ok) ;
473
 
cs_cl *cs_cl_spalloc (UF_long m, UF_long n, UF_long nzmax, UF_long values,
474
 
    UF_long t) ;
475
 
cs_cl *cs_cl_spfree (cs_cl *A) ;
476
 
UF_long cs_cl_sprealloc (cs_cl *A, UF_long nzmax) ;
477
 
void *cs_cl_malloc (UF_long n, size_t size) ;
478
 
 
479
 
/* --- secondary CSparse routines and data structures ----------------------- */
480
 
 
481
 
typedef struct cs_cl_symbolic  /* symbolic Cholesky, LU, or QR analysis */
482
 
{
483
 
    UF_long *pinv ;     /* inverse row perm. for QR, fill red. perm for Chol */
484
 
    UF_long *q ;        /* fill-reducing column permutation for LU and QR */
485
 
    UF_long *parent ;   /* elimination tree for Cholesky and QR */
486
 
    UF_long *cp ;       /* column pointers for Cholesky, row counts for QR */
487
 
    UF_long *leftmost ; /* leftmost[i] = min(find(A(i,:))), for QR */
488
 
    UF_long m2 ;        /* # of rows for QR, after adding fictitious rows */
489
 
    double lnz ;        /* # entries in L for LU or Cholesky; in V for QR */
490
 
    double unz ;        /* # entries in U for LU; in R for QR */
491
 
} cs_cls ;
492
 
 
493
 
typedef struct cs_cl_numeric   /* numeric Cholesky, LU, or QR factorization */
494
 
{
495
 
    cs_cl *L ;          /* L for LU and Cholesky, V for QR */
496
 
    cs_cl *U ;          /* U for LU, r for QR, not used for Cholesky */
497
 
    UF_long *pinv ;     /* partial pivoting for LU */
498
 
    double _Complex *B ;            /* beta [0..n-1] for QR */
499
 
} cs_cln ;
500
 
 
501
 
typedef struct cs_cl_dmperm_results    /* cs_cl_dmperm or cs_cl_scc output */
502
 
{
503
 
    UF_long *p ;    /* size m, row permutation */
504
 
    UF_long *q ;    /* size n, column permutation */
505
 
    UF_long *r ;    /* size nb+1, block k is rows r[k] to r[k+1]-1 in A(p,q) */
506
 
    UF_long *s ;    /* size nb+1, block k is cols s[k] to s[k+1]-1 in A(p,q) */
507
 
    UF_long nb ;    /* # of blocks in fine dmperm decomposition */
508
 
    UF_long rr [5] ;   /* coarse row decomposition */
509
 
    UF_long cc [5] ;   /* coarse column decomposition */
510
 
} cs_cld ;
511
 
 
512
 
UF_long *cs_cl_amd (UF_long order, const cs_cl *A) ;
513
 
cs_cln *cs_cl_chol (const cs_cl *A, const cs_cls *S) ;
514
 
cs_cld *cs_cl_dmperm (const cs_cl *A, UF_long seed) ;
515
 
UF_long cs_cl_droptol (cs_cl *A, double tol) ;
516
 
UF_long cs_cl_dropzeros (cs_cl *A) ;
517
 
UF_long cs_cl_happly (const cs_cl *V, UF_long i, double _Complex beta,
518
 
    double _Complex *x) ;
519
 
UF_long cs_cl_ipvec (const UF_long *p, const double _Complex *b,
520
 
    double _Complex *x, UF_long n) ;
521
 
UF_long cs_cl_lsolve (const cs_cl *L, double _Complex *x) ;
522
 
UF_long cs_cl_ltsolve (const cs_cl *L, double _Complex *x) ;
523
 
cs_cln *cs_cl_lu (const cs_cl *A, const cs_cls *S, double tol) ;
524
 
cs_cl *cs_cl_permute (const cs_cl *A, const UF_long *p, const UF_long *q,
525
 
    UF_long values) ;
526
 
UF_long *cs_cl_pinv (const UF_long *p, UF_long n) ;
527
 
UF_long cs_cl_pvec (const UF_long *p, const double _Complex *b,
528
 
    double _Complex *x, UF_long n) ;
529
 
cs_cln *cs_cl_qr (const cs_cl *A, const cs_cls *S) ;
530
 
cs_cls *cs_cl_schol (UF_long order, const cs_cl *A) ;
531
 
cs_cls *cs_cl_sqr (UF_long order, const cs_cl *A, UF_long qr) ;
532
 
cs_cl *cs_cl_symperm (const cs_cl *A, const UF_long *pinv, UF_long values) ;
533
 
UF_long cs_cl_usolve (const cs_cl *U, double _Complex *x) ;
534
 
UF_long cs_cl_utsolve (const cs_cl *U, double _Complex *x) ;
535
 
UF_long cs_cl_updown (cs_cl *L, UF_long sigma, const cs_cl *C,
536
 
    const UF_long *parent) ;
537
 
 
538
 
/* utilities */
539
 
cs_cls *cs_cl_sfree (cs_cls *S) ;
540
 
cs_cln *cs_cl_nfree (cs_cln *N) ;
541
 
cs_cld *cs_cl_dfree (cs_cld *D) ;
542
 
 
543
 
/* --- tertiary CSparse routines -------------------------------------------- */
544
 
 
545
 
UF_long *cs_cl_counts (const cs_cl *A, const UF_long *parent,
546
 
    const UF_long *post, UF_long ata) ;
547
 
double cs_cl_cumsum (UF_long *p, UF_long *c, UF_long n) ;
548
 
UF_long cs_cl_dfs (UF_long j, cs_cl *G, UF_long top, UF_long *xi,
549
 
    UF_long *pstack, const UF_long *pinv) ;
550
 
UF_long *cs_cl_etree (const cs_cl *A, UF_long ata) ;
551
 
UF_long cs_cl_fkeep (cs_cl *A,
552
 
    UF_long (*fkeep) (UF_long, UF_long, double _Complex, void *), void *other) ;
553
 
double _Complex cs_cl_house (double _Complex *x, double _Complex *beta,
554
 
    UF_long n) ;
555
 
UF_long *cs_cl_maxtrans (const cs_cl *A, UF_long seed) ;
556
 
UF_long *cs_cl_post (const UF_long *parent, UF_long n) ;
557
 
cs_cld *cs_cl_scc (cs_cl *A) ;
558
 
UF_long cs_cl_scatter (const cs_cl *A, UF_long j, double _Complex beta,
559
 
    UF_long *w, double _Complex *x, UF_long mark,cs_cl *C, UF_long nz) ;
560
 
UF_long cs_cl_tdfs (UF_long j, UF_long k, UF_long *head, const UF_long *next,
561
 
    UF_long *post, UF_long *stack) ;
562
 
UF_long cs_cl_leaf (UF_long i, UF_long j, const UF_long *first,
563
 
    UF_long *maxfirst, UF_long *prevleaf, UF_long *ancestor, UF_long *jleaf) ;
564
 
UF_long cs_cl_reach (cs_cl *G, const cs_cl *B, UF_long k, UF_long *xi,
565
 
    const UF_long *pinv) ;
566
 
UF_long cs_cl_spsolve (cs_cl *L, const cs_cl *B, UF_long k, UF_long *xi, 
567
 
    double _Complex *x, const UF_long *pinv, UF_long lo) ;
568
 
UF_long cs_cl_ereach (const cs_cl *A, UF_long k, const UF_long *parent,
569
 
    UF_long *s, UF_long *w) ;
570
 
UF_long *cs_cl_randperm (UF_long n, UF_long seed) ;
571
 
 
572
 
/* utilities */
573
 
cs_cld *cs_cl_dalloc (UF_long m, UF_long n) ;
574
 
cs_cl *cs_cl_done (cs_cl *C, void *w, void *x, UF_long ok) ;
575
 
UF_long *cs_cl_idone (UF_long *p, cs_cl *C, void *w, UF_long ok) ;
576
 
cs_cln *cs_cl_ndone (cs_cln *N, cs_cl *C, void *w, void *x, UF_long ok) ;
577
 
cs_cld *cs_cl_ddone (cs_cld *D, cs_cl *C, void *w, UF_long ok) ;
578
 
 
579
 
 
580
 
/* -------------------------------------------------------------------------- */
581
 
/* Macros for constructing each version of CSparse */
582
 
/* -------------------------------------------------------------------------- */
583
 
 
584
 
#ifdef CS_LONG
585
 
#define CS_INT UF_long
586
 
#define CS_INT_MAX UF_long_max
587
 
#define CS_ID UF_long_id
588
 
#ifdef CS_COMPLEX
589
 
#define CS_ENTRY double _Complex
590
 
#define CS_NAME(nm) cs_cl ## nm
591
 
#else
592
 
#define CS_ENTRY double
593
 
#define CS_NAME(nm) cs_dl ## nm
594
 
#endif
595
 
#else
596
 
#define CS_INT int
597
 
#define CS_INT_MAX INT_MAX
598
 
#define CS_ID "%d"
599
 
#ifdef CS_COMPLEX
600
 
#define CS_ENTRY double _Complex
601
 
#define CS_NAME(nm) cs_ci ## nm
602
 
#else
603
 
#define CS_ENTRY double
604
 
#define CS_NAME(nm) cs_di ## nm
605
 
#endif
606
 
#endif
607
 
 
608
 
#ifdef CS_COMPLEX
609
 
#define CS_REAL(x) creal(x)
610
 
#define CS_IMAG(x) cimag(x)
611
 
#define CS_CONJ(x) conj(x)
612
 
#define CS_ABS(x) cabs(x)
613
 
#else
614
 
#define CS_REAL(x) (x)
615
 
#define CS_IMAG(x) (0.)
616
 
#define CS_CONJ(x) (x)
617
 
#define CS_ABS(x) fabs(x)
618
 
#endif
619
 
 
620
 
#define CS_MAX(a,b) (((a) > (b)) ? (a) : (b))
621
 
#define CS_MIN(a,b) (((a) < (b)) ? (a) : (b))
622
 
#define CS_FLIP(i) (-(i)-2)
623
 
#define CS_UNFLIP(i) (((i) < 0) ? CS_FLIP(i) : (i))
624
 
#define CS_MARKED(w,j) (w [j] < 0)
625
 
#define CS_MARK(w,j) { w [j] = CS_FLIP (w [j]) ; }
626
 
#define CS_CSC(A) (A && (A->nz == -1))
627
 
#define CS_TRIPLET(A) (A && (A->nz >= 0))
628
 
 
629
 
/* --- primary CSparse routines and data structures ------------------------- */
630
 
 
631
 
#define cs CS_NAME ()
632
 
 
633
 
#define cs_add CS_NAME (_add)
634
 
#define cs_cholsol CS_NAME (_cholsol)
635
 
#define cs_dupl CS_NAME (_dupl)
636
 
#define cs_entry CS_NAME (_entry)
637
 
#define cs_lusol CS_NAME (_lusol)
638
 
#define cs_gaxpy CS_NAME (_gaxpy)
639
 
#define cs_multiply CS_NAME (_multiply)
640
 
#define cs_qrsol CS_NAME (_qrsol)
641
 
#define cs_transpose CS_NAME (_transpose)
642
 
#define cs_compress CS_NAME (_compress)
643
 
#define cs_norm CS_NAME (_norm)
644
 
#define cs_print CS_NAME (_print)
645
 
#define cs_load CS_NAME (_load)
646
 
 
647
 
/* utilities */
648
 
#define cs_calloc CS_NAME (_calloc)
649
 
#define cs_free CS_NAME (_free)
650
 
#define cs_realloc CS_NAME (_realloc)
651
 
#define cs_spalloc CS_NAME (_spalloc)
652
 
#define cs_spfree CS_NAME (_spfree)
653
 
#define cs_sprealloc CS_NAME (_sprealloc)
654
 
#define cs_malloc CS_NAME (_malloc)
655
 
 
656
 
/* --- secondary CSparse routines and data structures ----------------------- */
657
 
#define css CS_NAME (s)
658
 
#define csn CS_NAME (n)
659
 
#define csd CS_NAME (d)
660
 
 
661
 
#define cs_amd CS_NAME (_amd)
662
 
#define cs_chol CS_NAME (_chol)
663
 
#define cs_dmperm CS_NAME (_dmperm)
664
 
#define cs_droptol CS_NAME (_droptol)
665
 
#define cs_dropzeros CS_NAME (_dropzeros)
666
 
#define cs_happly CS_NAME (_happly)
667
 
#define cs_ipvec CS_NAME (_ipvec)
668
 
#define cs_lsolve CS_NAME (_lsolve)
669
 
#define cs_ltsolve CS_NAME (_ltsolve)
670
 
#define cs_lu CS_NAME (_lu)
671
 
#define cs_permute CS_NAME (_permute)
672
 
#define cs_pinv CS_NAME (_pinv)
673
 
#define cs_pvec CS_NAME (_pvec)
674
 
#define cs_qr CS_NAME (_qr)
675
 
#define cs_schol CS_NAME (_schol)
676
 
#define cs_sqr CS_NAME (_sqr)
677
 
#define cs_symperm CS_NAME (_symperm)
678
 
#define cs_usolve CS_NAME (_usolve)
679
 
#define cs_utsolve CS_NAME (_utsolve)
680
 
#define cs_updown CS_NAME (_updown)
681
 
 
682
 
/* utilities */
683
 
#define cs_sfree CS_NAME (_sfree)
684
 
#define cs_nfree CS_NAME (_nfree)
685
 
#define cs_dfree CS_NAME (_dfree)
686
 
 
687
 
/* --- tertiary CSparse routines -------------------------------------------- */
688
 
#define cs_counts CS_NAME (_counts)
689
 
#define cs_cumsum CS_NAME (_cumsum)
690
 
#define cs_dfs CS_NAME (_dfs)
691
 
#define cs_etree CS_NAME (_etree)
692
 
#define cs_fkeep CS_NAME (_fkeep)
693
 
#define cs_house CS_NAME (_house)
694
 
#define cs_invmatch CS_NAME (_invmatch)
695
 
#define cs_maxtrans CS_NAME (_maxtrans)
696
 
#define cs_post CS_NAME (_post)
697
 
#define cs_scc CS_NAME (_scc)
698
 
#define cs_scatter CS_NAME (_scatter)
699
 
#define cs_tdfs CS_NAME (_tdfs)
700
 
#define cs_reach CS_NAME (_reach)
701
 
#define cs_spsolve CS_NAME (_spsolve)
702
 
#define cs_ereach CS_NAME (_ereach)
703
 
#define cs_randperm CS_NAME (_randperm)
704
 
#define cs_leaf CS_NAME (_leaf)
705
 
 
706
 
/* utilities */
707
 
#define cs_dalloc CS_NAME (_dalloc)
708
 
#define cs_done CS_NAME (_done)
709
 
#define cs_idone CS_NAME (_idone)
710
 
#define cs_ndone CS_NAME (_ndone)
711
 
#define cs_ddone CS_NAME (_ddone)
712
 
 
713
 
/* -------------------------------------------------------------------------- */
714
 
/* Conversion routines */
715
 
/* -------------------------------------------------------------------------- */
716
 
 
717
 
cs_di *cs_i_real (cs_ci *A, int real) ;
718
 
cs_ci *cs_i_complex (cs_di *A, int real) ;
719
 
cs_dl *cs_l_real (cs_cl *A, UF_long real) ;
720
 
cs_cl *cs_l_complex (cs_dl *A, UF_long real) ;
721
 
 
722
 
#ifdef __cplusplus
723
 
}
724
 
#endif
725
 
#endif