~ubuntu-branches/ubuntu/saucy/python-scipy/saucy

« back to all changes in this revision

Viewing changes to Lib/sandbox/pysparse/umfpack/umf_internal.h

  • Committer: Bazaar Package Importer
  • Author(s): Ondrej Certik
  • Date: 2008-06-16 22:58:01 UTC
  • mfrom: (2.1.24 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080616225801-irdhrpcwiocfbcmt
Tags: 0.6.0-12
* The description updated to match the current SciPy (Closes: #489149).
* Standards-Version bumped to 3.8.0 (no action needed)
* Build-Depends: netcdf-dev changed to libnetcdf-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* ========================================================================== */
2
 
/* === umf_internal.h ======================================================= */
3
 
/* ========================================================================== */
4
 
 
5
 
/* -------------------------------------------------------------------------- */
6
 
/* UMFPACK Version 4.1 (Apr. 30, 2003), Copyright (c) 2003 by Timothy A.      */
7
 
/* Davis.  All Rights Reserved.  See ../README for License.                   */
8
 
/* email: davis@cise.ufl.edu    CISE Department, Univ. of Florida.            */
9
 
/* web: http://www.cise.ufl.edu/research/sparse/umfpack                       */
10
 
/* -------------------------------------------------------------------------- */
11
 
 
12
 
/*
13
 
    This file is for internal use in UMFPACK itself, and should not be included
14
 
    in user code.  Use umfpack.h instead.  User-accessible file names and
15
 
    routine names all start with the letters "umfpack_".  Non-user-accessible
16
 
    file names and routine names all start with "umf_".
17
 
*/
18
 
 
19
 
/* -------------------------------------------------------------------------- */
20
 
/* ANSI standard include files */
21
 
/* -------------------------------------------------------------------------- */
22
 
 
23
 
/* from float.h:  DBL_EPSILON */
24
 
#include <float.h>
25
 
 
26
 
/* from string.h: strcmp */
27
 
#include <string.h>
28
 
 
29
 
/* when debugging, assert.h and the assert macro are used (see umf_dump.h) */
30
 
 
31
 
/* -------------------------------------------------------------------------- */
32
 
/* Architecture */
33
 
/* -------------------------------------------------------------------------- */
34
 
 
35
 
#if defined (__sun) || defined (MSOL2) || defined (ARCH_SOL2)
36
 
#define UMF_SOL2
37
 
#define UMFPACK_ARCHITECTURE "Sun Solaris"
38
 
 
39
 
#elif defined (__sgi) || defined (MSGI) || defined (ARCH_SGI)
40
 
#define UMF_SGI
41
 
#define UMFPACK_ARCHITECTURE "SGI Irix"
42
 
 
43
 
#elif defined (__linux) || defined (MGLNX86) || defined (ARCH_GLNX86)
44
 
#define UMF_LINUX
45
 
#define UMFPACK_ARCHITECTURE "Linux"
46
 
 
47
 
#elif defined (_AIX) || defined (MIBM_RS) || defined (ARCH_IBM_RS)
48
 
#define UMF_AIX
49
 
#define UMFPACK_ARCHITECTURE "IBM AIX"
50
 
 
51
 
#elif defined (__alpha) || defined (MALPHA) || defined (ARCH_ALPHA)
52
 
#define UMF_ALPHA
53
 
#define UMFPACK_ARCHITECTURE "Compaq Alpha"
54
 
 
55
 
#elif defined (__WIN32) || defined (_WIN32) || defined (_win32) || defined (__win32) || defined (WIN32)
56
 
#define UMF_WINDOWS
57
 
#define UMFPACK_ARCHITECTURE "Microsoft Windows"
58
 
 
59
 
#elif defined (__hppa) || defined (__hpux) || defined (MHPUX) || defined (ARCH_HPUX)
60
 
#define UMF_HP
61
 
#define UMFPACK_ARCHITECTURE "HP Unix"
62
 
 
63
 
#elif defined (__hp700) || defined (MHP700) || defined (ARCH_HP700)
64
 
#define UMF_HP
65
 
#define UMFPACK_ARCHITECTURE "HP 700 Unix"
66
 
 
67
 
#else
68
 
/* If the architecture is unknown, and you call the BLAS, you may need to */
69
 
/* define BLAS_BY_VALUE, BLAS_NO_UNDERSCORE, and/or BLAS_CHAR_ARG yourself. */
70
 
#define UMFPACK_ARCHITECTURE "unknown"
71
 
#endif
72
 
 
73
 
 
74
 
/* -------------------------------------------------------------------------- */
75
 
/* basic definitions (see also amd_internal.h) */
76
 
/* -------------------------------------------------------------------------- */
77
 
 
78
 
#define ONES_COMPLEMENT(r) (-(r)-1)
79
 
 
80
 
/* -------------------------------------------------------------------------- */
81
 
/* AMD include file */
82
 
/* -------------------------------------------------------------------------- */
83
 
 
84
 
/* stdio.h, stdlib.h, limits.h, and math.h, NDEBUG definition,
85
 
 * assert.h, and MATLAB include files */
86
 
#include "amd_internal.h"
87
 
 
88
 
/* -------------------------------------------------------------------------- */
89
 
/* Real/complex and int/long definitions, double relops */
90
 
/* -------------------------------------------------------------------------- */
91
 
 
92
 
#include "umf_version.h"
93
 
 
94
 
/* -------------------------------------------------------------------------- */
95
 
/* Compile-time configurations */
96
 
/* -------------------------------------------------------------------------- */
97
 
 
98
 
#include "umf_config.h"
99
 
 
100
 
/* -------------------------------------------------------------------------- */
101
 
/* umfpack include file */
102
 
/* -------------------------------------------------------------------------- */
103
 
 
104
 
#include "umfpack.h"
105
 
 
106
 
/* -------------------------------------------------------------------------- */
107
 
/* for contents of Info.  This must correlate with umfpack.h */
108
 
/* -------------------------------------------------------------------------- */
109
 
 
110
 
#define ESTIMATE (UMFPACK_NUMERIC_SIZE_ESTIMATE - UMFPACK_NUMERIC_SIZE)
111
 
#define ACTUAL 0
112
 
 
113
 
/* -------------------------------------------------------------------------- */
114
 
/* get a parameter from the Control array */
115
 
/* -------------------------------------------------------------------------- */
116
 
 
117
 
#define GET_CONTROL(i,default) \
118
 
    ((Control != (double *) NULL) ? \
119
 
        (SCALAR_IS_NAN (Control [i]) ? default : Control [i]) \
120
 
        : default)
121
 
 
122
 
/* -------------------------------------------------------------------------- */
123
 
/* for clearing the external degree counters */
124
 
/* -------------------------------------------------------------------------- */
125
 
 
126
 
#define MAX_MARK(n) Int_MAX - (2*(n)+1)
127
 
 
128
 
/* -------------------------------------------------------------------------- */
129
 
/* convert number of Units to MBytes */
130
 
/* -------------------------------------------------------------------------- */
131
 
 
132
 
#define MBYTES(units) (((units) * sizeof (Unit)) / 1048576.0)
133
 
 
134
 
/* -------------------------------------------------------------------------- */
135
 
/* dense row/column macro */
136
 
/* -------------------------------------------------------------------------- */
137
 
 
138
 
/* In order for a row or column to be treated as "dense", it must have more */
139
 
/* entries than the value returned by this macro.  n is the dimension of the */
140
 
/* matrix, and alpha is the dense row/column control parameter. */
141
 
 
142
 
/* Note: this is not defined if alpha is NaN or Inf: */
143
 
#define UMFPACK_DENSE_DEGREE_THRESHOLD(alpha,n) \
144
 
    ((Int) MAX (16.0, (alpha) * 16.0 * sqrt ((double) (n))))
145
 
 
146
 
/* -------------------------------------------------------------------------- */
147
 
/* PRINTF */
148
 
/* -------------------------------------------------------------------------- */
149
 
 
150
 
#define PRINTFk(k,params) { if (prl >= (k)) { PRINTF (params) ; } }
151
 
#define PRINTF1(params) PRINTFk (1, params)
152
 
#define PRINTF2(params) PRINTFk (2, params)
153
 
#define PRINTF3(params) PRINTFk (3, params)
154
 
#define PRINTF4(params) PRINTFk (4, params)
155
 
#define PRINTF5(params) PRINTFk (5, params)
156
 
#define PRINTF6(params) PRINTFk (6, params)
157
 
 
158
 
/* -------------------------------------------------------------------------- */
159
 
/* Fixed control parameters */
160
 
/* -------------------------------------------------------------------------- */
161
 
 
162
 
/* maximum number of columns to consider at one time, in a single front */
163
 
#define MAX_CANDIDATES 128
164
 
 
165
 
/* reduce Numeric->Memory request by this ratio, if allocation fails */
166
 
#define UMF_REALLOC_REDUCTION (0.95)
167
 
 
168
 
/* increase Numeric->Memory request by this ratio, if we need more */
169
 
#define UMF_REALLOC_INCREASE (1.2)
170
 
 
171
 
/* increase the dimensions of the current frontal matrix by this factor
172
 
 * when it needs to grow. */
173
 
#define UMF_FRONTAL_GROWTH (1.2)
174
 
 
175
 
/* largest BLAS block size permitted */
176
 
#define MAXNB 64
177
 
 
178
 
/* if abs (y) < RECIPROCAL_TOLERANCE, then compute x/y.  Otherwise x*(1/y).
179
 
 * Ignored if NRECIPROCAL is defined */
180
 
#define RECIPROCAL_TOLERANCE 1e-12
181
 
 
182
 
/* -------------------------------------------------------------------------- */
183
 
/* Memory allocator */
184
 
/* -------------------------------------------------------------------------- */
185
 
 
186
 
/* The MATLAB mexFunction uses MATLAB's memory manager, while the C-callable
187
 
 * AMD library uses the ANSI C malloc, free, and realloc routines.  To use
188
 
 * the mx* memory allocation routines, use -DNUTIL when compiling.
189
 
 */
190
 
 
191
 
#undef ALLOCATE
192
 
#undef FREE
193
 
#undef REALLOC
194
 
 
195
 
#ifdef MATLAB_MEX_FILE
196
 
 
197
 
#ifdef NUTIL
198
 
 
199
 
/* These functions simply terminate the mexFunction if they fail to allocate
200
 
 * memory.  That's too restrictive for UMFPACK. */
201
 
#define ALLOCATE mxMalloc
202
 
#define FREE mxFree
203
 
#define REALLOCATE mxRealloc
204
 
 
205
 
#else
206
 
 
207
 
/* Use internal MATLAB memory allocation routines, used by built-in MATLAB
208
 
 * functions.  These are not documented, but are available for use.  Their
209
 
 * prototypes are in util.h, but that file is not provided to the MATLAB user.
210
 
 * The advantage of using these routines is that they return NULL if out of
211
 
 * memory, instead of terminating the mexFunction.  UMFPACK attempts to allocate
212
 
 * extra space for "elbow room", and then reduces its request if the memory is
213
 
 * not available.  That strategy doesn't work with the mx* routines.
214
 
 */
215
 
void *utMalloc (size_t size) ;
216
 
void utFree (void *p) ;
217
 
void *utRealloc (void *p, size_t size) ;
218
 
#define ALLOCATE utMalloc
219
 
#define FREE utFree
220
 
#define REALLOCATE utRealloc
221
 
 
222
 
#endif
223
 
#else
224
 
#ifdef MATHWORKS
225
 
 
226
 
/* Compiling as a built-in routine.  Since out-of-memory conditions are checked
227
 
 * after every allocation, we can use ut* routines here. */
228
 
#define ALLOCATE utMalloc
229
 
#define FREE utFree
230
 
#define REALLOCATE utRealloc
231
 
 
232
 
#else
233
 
 
234
 
/* use the ANSI C memory allocation routines */
235
 
#define ALLOCATE malloc
236
 
#define FREE free
237
 
#define REALLOCATE realloc
238
 
 
239
 
#endif
240
 
#endif
241
 
 
242
 
/* -------------------------------------------------------------------------- */
243
 
/* Memory space definitions */
244
 
/* -------------------------------------------------------------------------- */
245
 
 
246
 
/* for memory alignment - assume double has worst case alignment */
247
 
typedef double Align ;
248
 
 
249
 
/* get number of bytes required to hold n items of a type: */
250
 
/* note that this will not overflow, because sizeof (type) is always */
251
 
/* greater than or equal to sizeof (Int) >= 2 */
252
 
#define BYTES(type,n) (sizeof (type) * (n))
253
 
 
254
 
/* ceiling of (b/u).  Assumes b >= 0 and u > 0 */
255
 
#define CEILING(b,u) (((b) + (u) - 1) / (u))
256
 
 
257
 
/* get number of Units required to hold n items of a type: */
258
 
#define UNITS(type,n) (CEILING (BYTES (type, n), sizeof (Unit)))
259
 
 
260
 
/* same as DUNITS, but use double instead of int to avoid overflow */
261
 
#define DUNITS(type,n) (ceil (BYTES (type, (double) n) / sizeof (Unit)))
262
 
 
263
 
union Unit_union
264
 
{       /* memory is allocated in multiples of Unit */
265
 
    struct
266
 
    {
267
 
        Int
268
 
            size,       /* size, in Units, of the block, excl. header block */
269
 
                        /* size >= 0: block is in use */
270
 
                        /* size < 0: block is free, of |size| Units */
271
 
            prevsize ;  /* size, in Units, of preceding block in S->Memory */
272
 
                        /* during garbage_collection, prevsize is set to -e-1 */
273
 
                        /* for element e, or positive (and thus a free block) */
274
 
                        /* otherwise */
275
 
    } header ;          /* block header */
276
 
    Align  xxxxxx ;     /* force alignment of blocks (xxxxxx is never used) */
277
 
} ;
278
 
 
279
 
typedef union Unit_union Unit ;
280
 
 
281
 
/* get the size of an allocated block */
282
 
#define GET_BLOCK_SIZE(p) (((p)-1)->header.size)
283
 
 
284
 
/* -------------------------------------------------------------------------- */
285
 
/* Numeric */
286
 
/* -------------------------------------------------------------------------- */
287
 
 
288
 
/*
289
 
    NUMERIC_VALID and SYMBOLIC_VALID:
290
 
    The different values of SYBOLIC_VALID and NUMERIC_VALID are chosen as a
291
 
    first defense against corrupted *Symbolic or *Numeric pointers passed to an
292
 
    UMFPACK routine.  They also ensure that the objects are used only by the
293
 
    same version that created them (umfpack_di_*, umfpack_dl_*, umfpack_zi_*,
294
 
    or umfpack_zl_*).  The values have also been changed since prior releases of
295
 
    the code to ensure that all routines that operate on the objects are of the
296
 
    same release.  The values themselves are purely arbitrary.  The are less
297
 
    than the ANSI C required minimums of INT_MAX and LONG_MAX, respectively.
298
 
*/
299
 
 
300
 
#ifdef DINT
301
 
#define NUMERIC_VALID  15974
302
 
#define SYMBOLIC_VALID 41934
303
 
#endif
304
 
#ifdef DLONG
305
 
#define NUMERIC_VALID  399789120
306
 
#define SYMBOLIC_VALID 399192913
307
 
#endif
308
 
#ifdef ZINT
309
 
#define NUMERIC_VALID  17954
310
 
#define SYMBOLIC_VALID 40923
311
 
#endif
312
 
#ifdef ZLONG
313
 
#define NUMERIC_VALID  129987654
314
 
#define SYMBOLIC_VALID 110291234
315
 
#endif
316
 
 
317
 
typedef struct  /* NumericType */
318
 
{
319
 
    double
320
 
        flops,          /* "true" flop count */
321
 
        relpt,          /* relative pivot tolerance used */
322
 
        relpt2,         /* relative pivot tolerance used for sym. */
323
 
        alloc_init,     /* initial allocation of Numeric->memory */
324
 
        front_alloc_init, /* frontal matrix allocation parameter */
325
 
        rsmin,          /* smallest row sum */
326
 
        rsmax,          /* largest row sum  */
327
 
        min_udiag,      /* smallest abs value on diagonal of D */
328
 
        max_udiag,      /* smallest abs value on diagonal of D */
329
 
        rcond ;         /* min (D) / max (D) */
330
 
 
331
 
    Int
332
 
        scale ;
333
 
 
334
 
    Int valid ;         /* set to NUMERIC_VALID, for validity check */
335
 
 
336
 
    /* Memory space for A and LU factors */
337
 
    Unit
338
 
        *Memory ;       /* working memory for A and LU factors */
339
 
    Int
340
 
        ihead,          /* pointer to tail of LU factors, in Numeric->Memory */
341
 
        itail,          /* pointer to top of elements & tuples,  */
342
 
                        /* in Numeric->Memory */
343
 
        ibig,           /* pointer to largest free block seen in tail */
344
 
        size ;          /* size of Memory, in Units */
345
 
 
346
 
    Int
347
 
        *Rperm,         /* pointer to row perm array, size: n+1 */
348
 
                        /* after UMF_kernel:  Rperm [new] = old */
349
 
                        /* during UMF_kernel: Rperm [old] = new */
350
 
        *Cperm,         /* pointer to col perm array, size: n+1 */
351
 
                        /* after UMF_kernel:  Cperm [new] = old */
352
 
                        /* during UMF_kernel: Cperm [old] = new */
353
 
 
354
 
        *Upos,          /* see UMFPACK_get_numeric for a description */
355
 
        *Lpos,
356
 
        *Lip,
357
 
        *Lilen,
358
 
        *Uip,
359
 
        *Uilen,
360
 
        *Upattern ;     /* pattern of last row of U (if singular) */
361
 
 
362
 
    Int
363
 
        ulen,           /* length of Upattern */
364
 
        npiv,           /* number of structural pivots found (sprank approx) */
365
 
        nnzpiv ;        /* number of numerical (nonzero) pivots found */
366
 
 
367
 
    Entry
368
 
        *D ;            /* D [i] is the diagonal entry of U */
369
 
 
370
 
    Int do_recip ;
371
 
    double *Rs ;        /* scale factors for the rows of A and b */
372
 
                        /* do_recip FALSE: Divide row i by Rs [i] */
373
 
                        /* do_recip TRUE:  Multiply row i by Rs [i] */
374
 
 
375
 
    Int
376
 
        n_row, n_col,   /* A is n_row-by-n_row */
377
 
        n1 ;            /* number of singletons */
378
 
 
379
 
    /* for information only: */
380
 
    Int
381
 
        tail_usage,     /* amount of memory allocated in tail */
382
 
                        /* head_usage is Numeric->ihead */
383
 
        init_usage,     /* memory usage just after UMF_kernel_init */
384
 
        max_usage,      /* peak memory usage (excludes internal and external */
385
 
                        /* fragmentation in the tail) */
386
 
        ngarbage,       /* number of garbage collections performed */
387
 
        nrealloc,       /* number of reallocations performed */
388
 
        ncostly,        /* number of costly reallocations performed */
389
 
        isize,          /* size of integer pattern of L and U */
390
 
        nLentries,      /* number of entries in L, excluding diagonal */
391
 
        nUentries,      /* number of entries in U, including diagonal */
392
 
                        /* Some entries may be numerically zero. */
393
 
        lnz,            /* number of nonzero entries in L, excl. diagonal */
394
 
        unz,            /* number of nonzero entries in U, excl. diagonal */
395
 
        maxfrsize ;     /* largest actual front size */
396
 
 
397
 
    Int maxnrows, maxncols ;    /* not the same as Symbolic->maxnrows/cols* */
398
 
 
399
 
} NumericType ;
400
 
 
401
 
 
402
 
 
403
 
/* -------------------------------------------------------------------------- */
404
 
/* Element tuples for connecting elements together in a matrix */
405
 
/* -------------------------------------------------------------------------- */
406
 
 
407
 
typedef struct  /* Tuple */
408
 
{
409
 
    /* The (e,f) tuples for the element lists */
410
 
    Int
411
 
        e,              /* element */
412
 
        f ;             /* contribution to the row/col appears at this offset */
413
 
 
414
 
} Tuple ;
415
 
 
416
 
#define TUPLES(t) MAX (4, (t) + 1)
417
 
 
418
 
/* Col_degree is aliased with Cperm, and Row_degree with Rperm */
419
 
#define NON_PIVOTAL_COL(col) (Col_degree [col] >= 0)
420
 
#define NON_PIVOTAL_ROW(row) (Row_degree [row] >= 0)
421
 
 
422
 
/* -------------------------------------------------------------------------- */
423
 
/* An element */
424
 
/* -------------------------------------------------------------------------- */
425
 
 
426
 
typedef struct  /* Element */
427
 
{
428
 
    Int
429
 
 
430
 
        cdeg,           /* external column degree + cdeg0 offset */
431
 
        rdeg,           /* external row degree    + rdeg0 offset */
432
 
        nrowsleft,      /* number of rows remaining */
433
 
        ncolsleft,      /* number of columns remaining */
434
 
        nrows,          /* number of rows */
435
 
        ncols,          /* number of columns */
436
 
        next ;          /* for list link of sons, used during assembly only */
437
 
 
438
 
    /* followed in memory by:
439
 
    Int
440
 
        col [0..ncols-1],       column indices of this element
441
 
        row [0..nrows-1] ;      row indices of this element
442
 
    Entry                       (suitably aligned, see macro below)
443
 
        C [0...nrows-1, 0...ncols-1] ;
444
 
        size of C is nrows*ncols Entry's
445
 
    */
446
 
 
447
 
} Element ;
448
 
 
449
 
/* macros for computing pointers to row/col indices, and contribution block: */
450
 
 
451
 
#define GET_ELEMENT_SIZE(nr,nc) \
452
 
(UNITS (Element, 1) + UNITS (Int, (nc) + (nr)) + UNITS (Entry, (nc) * (nr)))
453
 
 
454
 
#define DGET_ELEMENT_SIZE(nr,nc) \
455
 
(DUNITS (Element, 1) + DUNITS (Int, (nc) + (nr)) + DUNITS (Entry, (nc) * (nr)))
456
 
 
457
 
#define GET_ELEMENT_COLS(ep,p,Cols) { \
458
 
    ASSERT (p != (Unit *) NULL) ; \
459
 
    ASSERT (p >= Numeric->Memory + Numeric->itail) ; \
460
 
    ASSERT (p <= Numeric->Memory + Numeric->size) ; \
461
 
    ep = (Element *) p ; \
462
 
    p += UNITS (Element, 1) ; \
463
 
    Cols = (Int *) p ; \
464
 
}
465
 
 
466
 
#define GET_ELEMENT_PATTERN(ep,p,Cols,Rows,ncm) { \
467
 
    GET_ELEMENT_COLS (ep, p, Cols) ; \
468
 
    ncm = ep->ncols ; \
469
 
    Rows = Cols + ncm ; \
470
 
}
471
 
 
472
 
#define GET_ELEMENT(ep,p,Cols,Rows,ncm,nrm,C) { \
473
 
    GET_ELEMENT_PATTERN (ep, p, Cols, Rows, ncm) ; \
474
 
    nrm = ep->nrows ; \
475
 
    p += UNITS (Int, ncm + nrm) ; \
476
 
    C = (Entry *) p ; \
477
 
}
478
 
 
479
 
/* -------------------------------------------------------------------------- */
480
 
/* Work data structure */
481
 
/* -------------------------------------------------------------------------- */
482
 
 
483
 
/*
484
 
    This data structure holds items needed only during factorization.
485
 
    All of this is freed when UMFPACK_numeric completes.  Note that some of
486
 
    it is stored in the tail end of Numeric->S (namely, the Tuples and the
487
 
    Elements).
488
 
*/
489
 
 
490
 
typedef struct  /* WorkType */
491
 
{
492
 
 
493
 
    /* ---------------------------------------------------------------------- */
494
 
    /* information about each row and col of A */
495
 
    /* ---------------------------------------------------------------------- */
496
 
 
497
 
    /*
498
 
        Row_tuples:     pointer to tuple list (alias with Numeric->Uip)
499
 
        Row_tlen:       number of tuples (alias with Numeric->Uilen)
500
 
        Col_tuples:     pointer to tuple list (alias with Numeric->Lip)
501
 
        Col_tlen:       number of tuples (alias with Numeric->Lilen)
502
 
        Row_degree:     degree of the row or column (alias Numeric->Rperm)
503
 
        Col_degree:     degree of the row or column (alias Numeric->Cperm)
504
 
 
505
 
        The Row_degree and Col_degree are MATLAB-style colmmd approximations,
506
 
        are equal to the sum of the sizes of the elements (contribution blocks)
507
 
        in each row and column.  They are maintained when elements are created
508
 
        and assembled.  They are used only during the pivot row and column
509
 
        search.  They are not needed to represent the pattern of the remaining
510
 
        matrix.
511
 
    */
512
 
 
513
 
    /* ---------------------------------------------------------------------- */
514
 
    /* information about each element */
515
 
    /* ---------------------------------------------------------------------- */
516
 
 
517
 
    Int *E ;            /* E [0 .. Work->elen-1] element "pointers" */
518
 
                        /* (offsets in Numeric->Memory) */
519
 
 
520
 
    /* ---------------------------------------------------------------------- */
521
 
    /* generic workspace */
522
 
    /* ---------------------------------------------------------------------- */
523
 
 
524
 
    Entry *Wx, *Wy ;    /* each of size maxnrows+1 */
525
 
 
526
 
    Int                 /* Sizes:  nn = MAX (n_row, n_col) */
527
 
        *Wp,            /* nn+1 */
528
 
        *Wrp,           /* n_col+1 */
529
 
        *Wm,            /* maxnrows+1 */
530
 
        *Wio,           /* maxncols+1 */
531
 
        *Woi,           /* maxncols+1 */
532
 
        *Woo,           /* MAX (maxnrows,maxncols)+1 */
533
 
        *Wrow,          /* pointer to Fcols, Wio, or Woi */
534
 
        *NewRows,       /* list of rows to scan */
535
 
        *NewCols ;      /* list of cols to scan */
536
 
 
537
 
    /* ---------------------------------------------------------------------- */
538
 
 
539
 
    Int
540
 
        *Lpattern,      /* pattern of column of L, for one Lchain */
541
 
        *Upattern,      /* pattern of row of U, for one Uchain */
542
 
        ulen, llen ;    /* length of Upattern and Lpattern */
543
 
 
544
 
    Int
545
 
        *Diagonal_map,  /* used for symmetric pivoting, of size nn+1 */
546
 
        *Diagonal_imap ;/* used for symmetric pivoting, of size nn+1 */
547
 
 
548
 
    /* ---------------------------------------------------------------------- */
549
 
 
550
 
    Int
551
 
        n_row, n_col,   /* matrix is n_row-by-n_col */
552
 
        nz,             /* nonzeros in the elements for this matrix */
553
 
        n1,             /* number of row and col singletons */
554
 
        elen,           /* max possible number of elements */
555
 
        npiv,           /* number of pivot rows and columns so far */
556
 
        ndiscard,       /* number of discarded pivot columns */
557
 
        Wrpflag,
558
 
        nel,            /* elements in use are in the range 1..nel */
559
 
        noff_diagonal,
560
 
        prior_element,
561
 
        rdeg0, cdeg0,
562
 
        rrdeg, ccdeg,
563
 
        Candidates [MAX_CANDIDATES],     /* current candidate pivot columns */
564
 
        nCandidates,    /* number of candidates in Candidate set */
565
 
        ksuper,
566
 
        firstsuper,
567
 
        jsuper,
568
 
        ncand,          /* number of candidates (some not in Candidates[ ]) */
569
 
        nextcand,       /* next candidate to place in Candidate search set */
570
 
        lo,
571
 
        hi,
572
 
        pivrow,         /* current pivot row */
573
 
        pivcol,         /* current pivot column */
574
 
        do_extend,      /* true if the next pivot extends the current front */
575
 
        do_update,      /* true if update should be applied */
576
 
        nforced,        /* number of forced updates because of frontal growth */
577
 
        any_skip,
578
 
        do_scan2row,
579
 
        do_scan2col,
580
 
        do_grow,
581
 
        pivot_case,
582
 
        frontid,        /* id of current frontal matrix */
583
 
        nfr ;           /* number of frontal matrices */
584
 
 
585
 
    /* ---------------------------------------------------------------------- */
586
 
    /* For row-merge tree */
587
 
    /* ---------------------------------------------------------------------- */
588
 
 
589
 
    Int
590
 
        *Front_new1strow ;
591
 
 
592
 
    /* ---------------------------------------------------------------------- */
593
 
    /* current frontal matrix, F */
594
 
    /* ---------------------------------------------------------------------- */
595
 
 
596
 
    Int Pivrow [MAXNB],
597
 
        Pivcol [MAXNB] ;
598
 
 
599
 
    Entry
600
 
        *Flublock,      /* LU block, nb-by-nb */
601
 
        *Flblock,       /* L block,  fnr_curr-by-nb */
602
 
        *Fublock,       /* U block,  nb-by-fnc_curr, or U' fnc_curr-by-nb */
603
 
        *Fcblock ;      /* C block,  fnr_curr-by-fnc_curr */
604
 
 
605
 
    Int
606
 
        *Frows,         /* Frows [0.. ]: row indices of F */
607
 
 
608
 
        *Fcols,         /* Fcols [0.. ]: column indices of F */
609
 
 
610
 
        *Frpos,         /* position of row indices in F, or -1 if not present */
611
 
                        /* if Frows[i] == row, then Frpos[row] == i */
612
 
 
613
 
        *Fcpos,         /* position of col indices in F, or -1 if not present */
614
 
                        /* if Fcols[j] == col, then */
615
 
                        /* Fcpos[col] == j*Work->fnr_curr */
616
 
 
617
 
        fnrows,         /* number of rows in contribution block in F */
618
 
        fncols,         /* number of columns in contribution block in F */
619
 
        fnr_curr,       /* maximum # of rows in F (leading dimension) */
620
 
        fnc_curr,       /* maximum # of columns in F */
621
 
        fcurr_size,     /* current size of F */
622
 
        fnrows_max,     /* max possible column-dimension (max # of rows) of F */
623
 
        fncols_max,     /* max possible row-dimension (max # of columns) of F */
624
 
        nb,
625
 
        fnpiv,          /* number of pivots in F */
626
 
        fnzeros,        /* number of explicit zero entries in LU block */
627
 
        fscan_row,      /* where to start scanning rows of F in UMF_assemble */
628
 
        fscan_col,      /* where to start scanning cols of F in UMF_assemble */
629
 
        fnrows_new,     /* number of new row indices in F after pivot added */
630
 
        fncols_new,     /* number of new col indices in F after pivot added */
631
 
        pivrow_in_front,        /* true if current pivot row in Frows */
632
 
        pivcol_in_front ;       /* true if current pivot column in Fcols */
633
 
 
634
 
    /* ----------------------------------------------------------------------
635
 
     * Current frontal matrix
636
 
     * ----------------------------------------------------------------------
637
 
     * The current frontal matrix is held as a single block of memory allocated
638
 
     * from the "tail" end of Numeric->Memory.  It is subdivided into four
639
 
     * parts: an LU block, an L block, a U block, and a C block.
640
 
     *
641
 
     * Let k = fnpiv, r = fnrows, and c = fncols for the following discussion.
642
 
     * Let dr = fnr_curr and dc = fnc_curr.  Note that r <= dr and c <= dc.
643
 
     *
644
 
     * The LU block is of dimension nb-by-nb.  The first k-by-k part holds the
645
 
     * "diagonal" part of the LU factors for these k pivot rows and columns.
646
 
     * The k pivot row and column indices in this part are Pivrow [0..k-1] and
647
 
     * Pivcol [0..k-1], respectively.
648
 
     *
649
 
     * The L block is of dimension dr-by-nb.  It holds the k pivot columns,
650
 
     * except for the leading k-by-k part in the LU block.  Only the leading
651
 
     * r-by-k part is in use.
652
 
     *
653
 
     * The U block is of dimension dc-by-nb.  It holds the k pivot rows,
654
 
     * except for the leading k-by-k part in the LU block.  It is stored in
655
 
     * row-oriented form.  Only the leading c-by-k part is in use.
656
 
     *
657
 
     * The C block is of dimension dr-by-dc.  It holds the current contribution
658
 
     * block.  Only the leading r-by-c part is in use.  The column indices in
659
 
     * the C block are Fcols [0..c-1], and the row indices are Frows [0..r-1].
660
 
     *
661
 
     * dr is always odd, to avoid bad cache behavior.
662
 
     */
663
 
 
664
 
} WorkType ;
665
 
 
666
 
 
667
 
/* -------------------------------------------------------------------------- */
668
 
/* Symbolic */
669
 
/* -------------------------------------------------------------------------- */
670
 
 
671
 
/*
672
 
    This is is constructed by UMFPACK_symbolic, and is needed by UMFPACK_numeric
673
 
    to factor the matrix.
674
 
*/
675
 
 
676
 
typedef struct  /* SymbolicType */
677
 
{
678
 
 
679
 
    double
680
 
        num_mem_usage_est,      /* estimated max Numeric->Memory size */
681
 
        num_mem_size_est,       /* estimated final Numeric->Memory size */
682
 
        peak_sym_usage,         /* peak Symbolic and SymbolicWork usage */
683
 
        sym,                    /* symmetry of pattern */
684
 
        dnum_mem_init_usage,    /* min Numeric->Memory for UMF_kernel_init */
685
 
        amd_lunz,       /* nz in LU for AMD, with symmetric pivoting */
686
 
        lunz_bound ;    /* max nx in LU, for arbitrary row pivoting */
687
 
 
688
 
    Int valid,          /* set to SYMBOLIC_VALID, for validity check */
689
 
        max_nchains,
690
 
        nchains,
691
 
        *Chain_start,
692
 
        *Chain_maxrows,
693
 
        *Chain_maxcols,
694
 
        maxnrows,               /* largest number of rows in any front */
695
 
        maxncols,               /* largest number of columns in any front */
696
 
        *Front_npivcol,         /* Front_npivcol [j] = size of jth supercolumn*/
697
 
        *Front_1strow,          /* first row index in front j */
698
 
        *Front_leftmostdesc,    /* leftmost desc of front j */
699
 
        *Front_parent,          /* super-column elimination tree */
700
 
        *Cperm_init,            /* initial column ordering */
701
 
        *Rperm_init,            /* initial row ordering */
702
 
        *Cdeg, *Rdeg,
703
 
        *Esize,
704
 
        dense_row_threshold,
705
 
        n1,                     /* number of singletons */
706
 
        nempty,                 /* MIN (nempty_row, nempty_col) */
707
 
        *Diagonal_map,          /* initial "diagonal" (after 2by2) */
708
 
        esize,                  /* size of Esize array */
709
 
        nfr,
710
 
        n_row, n_col,           /* matrix A is n_row-by-n_col */
711
 
        nz,                     /* nz of original matrix */
712
 
        nb,                     /* block size for BLAS 3 */
713
 
        num_mem_init_usage,     /* min Numeric->Memory for UMF_kernel_init */
714
 
        nempty_row, nempty_col,
715
 
 
716
 
        strategy,
717
 
        ordering,
718
 
        fixQ,
719
 
        prefer_diagonal,
720
 
        nzaat,
721
 
        nzdiag,
722
 
        amd_dmax ;
723
 
 
724
 
} SymbolicType ;
725
 
 
726
 
 
727
 
/* -------------------------------------------------------------------------- */
728
 
/* for debugging only: */
729
 
/* -------------------------------------------------------------------------- */
730
 
 
731
 
#include "umf_dump.h"
732
 
 
733
 
/* -------------------------------------------------------------------------- */
734
 
/* for statement coverage testing only: */
735
 
/* -------------------------------------------------------------------------- */
736
 
 
737
 
#ifdef TESTING
738
 
 
739
 
/* for testing integer overflow: */
740
 
#ifdef TEST_FOR_INTEGER_OVERFLOW
741
 
#undef MAX_MARK
742
 
#define MAX_MARK(n) (3*(n))
743
 
#endif
744
 
 
745
 
/* for testing out-of-memory conditions: */
746
 
#define UMF_TCOV_TEST
747
 
GLOBAL extern Int umf_fail, umf_fail_lo, umf_fail_hi ;
748
 
GLOBAL extern Int umf_realloc_fail, umf_realloc_lo, umf_realloc_hi ;
749
 
 
750
 
/* for testing malloc count: */
751
 
#define UMF_MALLOC_COUNT
752
 
 
753
 
#endif