~ubuntu-branches/ubuntu/natty/suitesparse/natty

« back to all changes in this revision

Viewing changes to KLU/Source/klu_factor.c

  • 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
1
/* ========================================================================== */
2
 
/* === klu_factor =========================================================== */
 
2
/* === KLU_factor =========================================================== */
3
3
/* ========================================================================== */
4
4
 
5
 
/* Factor the matrix, after ordering and analyzing it with klu_analyze
6
 
 * or klu_analyze_given.
 
5
/* Factor the matrix, after ordering and analyzing it with KLU_analyze
 
6
 * or KLU_analyze_given.
7
7
 */
8
8
 
9
9
#include "klu_internal.h"
10
10
 
11
11
/* ========================================================================== */
12
 
/* === klu_factor2 ========================================================== */
 
12
/* === KLU_factor2 ========================================================== */
13
13
/* ========================================================================== */
14
14
 
15
 
static void klu_factor2
 
15
static void factor2
16
16
(
17
17
    /* inputs, not modified */
18
 
    int Ap [ ],         /* size n+1, column pointers */
19
 
    int Ai [ ],         /* size nz, row indices */
 
18
    Int Ap [ ],         /* size n+1, column pointers */
 
19
    Int Ai [ ],         /* size nz, row indices */
20
20
    Entry Ax [ ],
21
 
    klu_symbolic *Symbolic,
 
21
    KLU_symbolic *Symbolic,
22
22
 
23
23
    /* inputs, modified on output: */
24
 
    klu_numeric *Numeric,
25
 
    klu_common *Common
 
24
    KLU_numeric *Numeric,
 
25
    KLU_common *Common
26
26
)
27
27
{
28
28
    double lsize ;
29
29
    double *Lnz, *Rs ;
30
 
    int *P, *Q, *R, *Pnum, *Offp, *Offi, *Pblock, *Pinv, *Iwork ;
31
 
    int **Lbip, **Ubip, **Lblen, **Ublen ;
32
 
    Entry *Offx, *Singleton, *X, s ;
33
 
    Unit **LUbx, **Udiag ;
34
 
    int k1, k2, nk, k, block, oldcol, pend, oldrow, n, lnz, unz, p, newrow,
 
30
    Int *P, *Q, *R, *Pnum, *Offp, *Offi, *Pblock, *Pinv, *Iwork,
 
31
        *Lip, *Uip, *Llen, *Ulen ;
 
32
    Entry *Offx, *X, s, *Udiag ;
 
33
    Unit **LUbx ;
 
34
    Int k1, k2, nk, k, block, oldcol, pend, oldrow, n, lnz, unz, p, newrow,
35
35
        nblocks, poff, nzoff, lnz_block, unz_block, scale, max_lnz_block,
36
36
        max_unz_block ;
37
37
 
52
52
    Offp = Numeric->Offp ;
53
53
    Offi = Numeric->Offi ;
54
54
    Offx = (Entry *) Numeric->Offx ;
55
 
    Singleton = (Entry *) Numeric->Singleton ;
56
55
 
57
 
    Lbip = Numeric->Lbip ;
58
 
    Ubip = Numeric->Ubip ;
59
 
    Lblen = Numeric->Lblen ;
60
 
    Ublen = Numeric->Ublen ;
 
56
    Lip = Numeric->Lip ;
 
57
    Uip = Numeric->Uip ;
 
58
    Llen = Numeric->Llen ;
 
59
    Ulen = Numeric->Ulen ;
61
60
    LUbx = (Unit **) Numeric->LUbx ;
62
 
    Udiag = (Unit **) Numeric->Udiag ;
 
61
    Udiag = Numeric->Udiag ;
63
62
 
64
63
    Rs = Numeric->Rs ;
65
64
    Pinv = Numeric->Pinv ;
66
65
    X = (Entry *) Numeric->Xwork ;              /* X is of size n */
67
 
    Iwork = Numeric->Iwork ;                    /* 5*maxblock for klu_factor */
 
66
    Iwork = Numeric->Iwork ;                    /* 5*maxblock for KLU_factor */
68
67
                                                /* 1*maxblock for Pblock */
69
68
    Pblock = Iwork + 5*((size_t) Symbolic->maxblock) ;
70
69
    Common->nrealloc = 0 ;
74
73
 
75
74
    /* compute the inverse of P from symbolic analysis.  Will be updated to
76
75
     * become the inverse of the numerical factorization when the factorization
77
 
     * is done, for use in klu_refactor */
 
76
     * is done, for use in KLU_refactor */
78
77
#ifndef NDEBUG
79
78
    for (k = 0 ; k < n ; k++)
80
79
    {
90
89
    for (k = 0 ; k < n ; k++) ASSERT (Pinv [k] != EMPTY) ;
91
90
#endif
92
91
 
93
 
    for (block = 0 ; block < nblocks ; block++)
94
 
    {
95
 
        /* Singleton [block] = 0 ; */
96
 
        CLEAR (Singleton [block]) ;
97
 
    }
98
 
 
99
92
    lnz = 0 ;
100
93
    unz = 0 ;
101
94
    Common->noffdiag = 0 ;
107
100
 
108
101
    if (scale >= 0)
109
102
    {
110
 
        /* use Pnum as workspace */
 
103
        /* use Pnum as workspace. NOTE: scale factors are not yet permuted
 
104
         * according to the final pivot row ordering, so Rs [oldrow] is the
 
105
         * scale factor for A (oldrow,:), for the user's matrix A.  Pnum is
 
106
         * used as workspace in KLU_scale.  When the factorization is done,
 
107
         * the scale factors are permuted according to the final pivot row
 
108
         * permutation, so that Rs [k] is the scale factor for the kth row of
 
109
         * A(p,q) where p and q are the final row and column permutations. */
111
110
        KLU_scale (scale, n, Ap, Ai, (double *) Ax, Rs, Pnum, Common) ;
112
111
        if (Common->status < KLU_OK)
113
112
        {
167
166
                    else
168
167
                    {
169
168
                        ASSERT (newrow == k1) ;
170
 
                        PRINTF (("Singleton block %d", block)) ;
 
169
                        PRINTF (("singleton block %d", block)) ;
171
170
                        PRINT_ENTRY (Ax [p]) ;
172
171
                        s = Ax [p] ;
173
172
                    }
175
174
            }
176
175
            else
177
176
            {
178
 
                /* row scaling */
 
177
                /* row scaling.  NOTE: scale factors are not yet permuted
 
178
                 * according to the pivot row permutation, so Rs [oldrow] is
 
179
                 * used below.  When the factorization is done, the scale
 
180
                 * factors are permuted, so that Rs [newrow] will be used in
 
181
                 * klu_solve, klu_tsolve, and klu_rgrowth */
179
182
                for (p = Ap [oldcol] ; p < pend ; p++)
180
183
                {
181
184
                    oldrow = Ai [p] ;
183
186
                    if (newrow < k1)
184
187
                    {
185
188
                        Offi [poff] = oldrow ;
186
 
                        /*Offx [poff] = Ax [p] / Rs [oldrow] ; */
 
189
                        /* Offx [poff] = Ax [p] / Rs [oldrow] ; */
187
190
                        SCALE_DIV_ASSIGN (Offx [poff], Ax [p], Rs [oldrow]) ;
188
191
                        poff++ ;
189
192
                    }
190
193
                    else
191
194
                    {
192
195
                        ASSERT (newrow == k1) ;
193
 
                        PRINTF (("Singleton block %d ", block)) ;
 
196
                        PRINTF (("singleton block %d ", block)) ;
194
197
                        PRINT_ENTRY (Ax[p]) ;
195
198
                        SCALE_DIV_ASSIGN (s, Ax [p], Rs [oldrow]) ;
196
199
                    }
197
200
                }
198
201
            }
199
202
 
200
 
            Singleton [block] = s ;
 
203
            Udiag [k1] = s ;
201
204
 
202
205
            if (IS_ZERO (s))
203
206
            {
235
238
                lsize = Common->initmem_amd * Lnz [block] + nk ;
236
239
            }
237
240
 
238
 
            /* allocates 5 arrays:
239
 
             * Lbip [block], Ubip [block], Lblen [block], Ublen [block],
240
 
             * LUbx [block] */
241
 
            KLU_kernel_factor (nk, Ap, Ai, Ax, Q, lsize,
242
 
                    &LUbx [block], Udiag [block], Lblen [block], Ublen [block],
243
 
                    Lbip [block], Ubip [block], Pblock, &lnz_block, &unz_block,
244
 
                    X, Iwork,
245
 
                    /* BTF and scale-related arguments: */
246
 
                    k1, Pinv, Rs, Offp, Offi, Offx, Common) ;
 
241
            /* allocates 1 arrays: LUbx [block] */
 
242
            Numeric->LUsize [block] = KLU_kernel_factor (nk, Ap, Ai, Ax, Q,
 
243
                    lsize, &LUbx [block], Udiag + k1, Llen + k1, Ulen + k1,
 
244
                    Lip + k1, Uip + k1, Pblock, &lnz_block, &unz_block,
 
245
                    X, Iwork, k1, Pinv, Rs, Offp, Offi, Offx, Common) ;
247
246
 
248
247
            if (Common->status < KLU_OK ||
249
248
               (Common->status == KLU_SINGULAR && Common->halt_if_singular))
253
252
            }
254
253
 
255
254
            PRINTF (("\n----------------------- L %d:\n", block)) ;
256
 
            ASSERT (KLU_valid_LU (nk, TRUE, Lbip [block],
257
 
                    Lblen [block], LUbx [block])) ;
 
255
            ASSERT (KLU_valid_LU (nk, TRUE, Lip+k1, Llen+k1, LUbx [block])) ;
258
256
            PRINTF (("\n----------------------- U %d:\n", block)) ;
259
 
            ASSERT (KLU_valid_LU (nk, FALSE, Ubip [block],
260
 
                    Ublen [block], LUbx [block])) ;
 
257
            ASSERT (KLU_valid_LU (nk, FALSE, Uip+k1, Ulen+k1, LUbx [block])) ;
261
258
 
262
259
            /* -------------------------------------------------------------- */
263
260
            /* get statistics */
300
297
    Numeric->max_lnz_block = max_lnz_block ;
301
298
    Numeric->max_unz_block = max_unz_block ;
302
299
 
303
 
    /* Numeric->flops = EMPTY ;         TODO not yet computed */
304
 
 
305
300
    /* compute the inverse of Pnum */
306
301
#ifndef NDEBUG
307
302
    for (k = 0 ; k < n ; k++)
347
342
#ifndef NDEBUG
348
343
    {
349
344
        PRINTF (("\n ############# KLU_BTF_FACTOR done, nblocks %d\n",nblocks));
350
 
        Entry *singleton = Numeric->Singleton ;
 
345
        Entry ss, *Udiag = Numeric->Udiag ;
351
346
        for (block = 0 ; block < nblocks && Common->status == KLU_OK ; block++)
352
347
        {
353
348
            k1 = R [block] ;
354
349
            k2 = R [block+1] ;
355
350
            nk = k2 - k1 ;
356
 
            PRINTF (("\n======================klu_factor output: k1 %d k2 %d nk %d\n",k1,k2,nk)) ;
 
351
            PRINTF (("\n======================KLU_factor output: k1 %d k2 %d nk %d\n",k1,k2,nk)) ;
357
352
            if (nk == 1)
358
353
            {
359
354
                PRINTF (("singleton  ")) ;
360
355
                /* ENTRY_PRINT (singleton [block]) ; */
361
 
                PRINT_ENTRY (singleton [block]) ;
 
356
                ss = Udiag [k1] ;
 
357
                PRINT_ENTRY (ss) ;
362
358
            }
363
359
            else
364
360
            {
365
 
                int *Lip, *Uip, *Llen, *Ulen ;
 
361
                Int *Lip, *Uip, *Llen, *Ulen ;
366
362
                Unit *LU ;
367
 
                Lip = Lbip [block] ;
368
 
                Llen = Lblen [block] ;
 
363
                Lip = Numeric->Lip + k1 ;
 
364
                Llen = Numeric->Llen + k1 ;
369
365
                LU = (Unit *) Numeric->LUbx [block] ;
370
366
                PRINTF (("\n---- L block %d\n", block));
371
367
                ASSERT (KLU_valid_LU (nk, TRUE, Lip, Llen, LU)) ;
372
 
                Uip = Ubip [block] ;
373
 
                Ulen = Ublen [block] ;
 
368
                Uip = Numeric->Uip + k1 ;
 
369
                Ulen = Numeric->Ulen + k1 ;
374
370
                PRINTF (("\n---- U block %d\n", block)) ;
375
371
                ASSERT (KLU_valid_LU (nk, FALSE, Uip, Ulen, LU)) ;
376
372
            }
380
376
}
381
377
 
382
378
 
383
 
/* ========================================================================== */
384
 
/* === CLEAR_PTR ============================================================ */
385
 
/* ========================================================================== */
386
 
 
387
 
/* Set an array of pointers to NULL */
388
 
 
389
 
#define CLEAR_PTR(Ptr,size) \
390
 
{ \
391
 
    int ii ; \
392
 
    if (Ptr != NULL) \
393
 
    { \
394
 
        for (ii = 0 ; ii < size ; ii++) \
395
 
        { \
396
 
            Ptr [ii] = NULL ; \
397
 
        } \
398
 
    } \
399
 
}
400
 
 
401
 
 
402
 
/* ========================================================================== */
403
 
/* === klu_factor =========================================================== */
404
 
/* ========================================================================== */
405
 
 
406
 
klu_numeric *KLU_factor         /* returns NULL if error, or a valid
407
 
                                   klu_numeric object if successful */
 
379
 
 
380
/* ========================================================================== */
 
381
/* === KLU_factor =========================================================== */
 
382
/* ========================================================================== */
 
383
 
 
384
KLU_numeric *KLU_factor         /* returns NULL if error, or a valid
 
385
                                   KLU_numeric object if successful */
408
386
(
409
387
    /* --- inputs --- */
410
 
    int Ap [ ],         /* size n+1, column pointers */
411
 
    int Ai [ ],         /* size nz, row indices */
 
388
    Int Ap [ ],         /* size n+1, column pointers */
 
389
    Int Ai [ ],         /* size nz, row indices */
412
390
    double Ax [ ],
413
 
    klu_symbolic *Symbolic,
 
391
    KLU_symbolic *Symbolic,
414
392
    /* -------------- */
415
 
    klu_common *Common
 
393
    KLU_common *Common
416
394
)
417
395
{
418
 
    int n, nzoff, nblocks, maxblock, block, k1, k2, nk, ok = TRUE ;
419
 
    int *R ;
420
 
    int **Lbip, **Ubip, **Lblen, **Ublen ;
421
 
    klu_numeric *Numeric ;
422
 
    Unit **Udiag ;
423
 
    size_t n1, nzoff1, nunits, s, b6, n3, nk1 ;
 
396
    Int n, nzoff, nblocks, maxblock, k, ok = TRUE ;
 
397
    Int *R ;
 
398
    KLU_numeric *Numeric ;
 
399
    size_t n1, nzoff1, s, b6, n3 ;
424
400
 
425
401
    if (Common == NULL)
426
402
    {
446
422
    nblocks = Symbolic->nblocks ;
447
423
    maxblock = Symbolic->maxblock ;
448
424
    R = Symbolic->R ;
449
 
    PRINTF (("klu_factor:  n %d nzoff %d nblocks %d maxblock %d\n",
 
425
    PRINTF (("KLU_factor:  n %d nzoff %d nblocks %d maxblock %d\n",
450
426
        n, nzoff, nblocks, maxblock)) ;
451
427
 
452
428
    /* ---------------------------------------------------------------------- */
457
433
    Common->initmem = MAX (1.0, Common->initmem) ;
458
434
    Common->tol = MIN (Common->tol, 1.0) ;
459
435
    Common->tol = MAX (0.0, Common->tol) ;
460
 
    Common->growth = MAX (1.0, Common->growth) ;
 
436
    Common->memgrow = MAX (1.0, Common->memgrow) ;
461
437
 
462
438
    /* ---------------------------------------------------------------------- */
463
439
    /* allocate the Numeric object  */
464
440
    /* ---------------------------------------------------------------------- */
465
441
 
466
 
    /* this will not cause size_t overflow (already checked by klu_symbolic) */
 
442
    /* this will not cause size_t overflow (already checked by KLU_symbolic) */
467
443
    n1 = ((size_t) n) + 1 ;
468
444
    nzoff1 = ((size_t) nzoff) + 1 ;
469
445
 
470
 
    Numeric = klu_malloc (sizeof (klu_numeric), 1, Common) ;
 
446
    Numeric = KLU_malloc (sizeof (KLU_numeric), 1, Common) ;
471
447
    if (Common->status < KLU_OK)
472
448
    {
473
449
        /* out of memory */
474
450
        Common->status = KLU_OUT_OF_MEMORY ;
475
451
        return (NULL) ;
476
452
    }
 
453
    Numeric->n = n ;
477
454
    Numeric->nblocks = nblocks ;
478
 
    Numeric->Pnum = klu_malloc (n, sizeof (int), Common) ;
479
 
    Numeric->Offp = klu_malloc (n1, sizeof (int), Common) ;
480
 
    Numeric->Offi = klu_malloc (nzoff1, sizeof (int), Common) ;
481
 
    Numeric->Offx = klu_malloc (nzoff1, sizeof (Entry), Common) ;
482
 
    Numeric->Singleton = klu_malloc (nblocks, sizeof (Entry), Common) ;
483
 
 
484
 
    Numeric->Lbip  = klu_malloc (nblocks, sizeof (int *), Common) ;
485
 
    Numeric->Ubip  = klu_malloc (nblocks, sizeof (int *), Common) ;
486
 
    Numeric->Lblen = klu_malloc (nblocks, sizeof (int *), Common) ;
487
 
    Numeric->Ublen = klu_malloc (nblocks, sizeof (int *), Common) ;
488
 
    Numeric->LUbx  = klu_malloc (nblocks, sizeof (Unit *), Common) ;
489
 
    Numeric->Udiag = klu_malloc (nblocks, sizeof (Unit *), Common) ;
 
455
    Numeric->nzoff = nzoff ;
 
456
    Numeric->Pnum = KLU_malloc (n, sizeof (Int), Common) ;
 
457
    Numeric->Offp = KLU_malloc (n1, sizeof (Int), Common) ;
 
458
    Numeric->Offi = KLU_malloc (nzoff1, sizeof (Int), Common) ;
 
459
    Numeric->Offx = KLU_malloc (nzoff1, sizeof (Entry), Common) ;
 
460
 
 
461
    Numeric->Lip  = KLU_malloc (n, sizeof (Int), Common) ;
 
462
    Numeric->Uip  = KLU_malloc (n, sizeof (Int), Common) ;
 
463
    Numeric->Llen = KLU_malloc (n, sizeof (Int), Common) ;
 
464
    Numeric->Ulen = KLU_malloc (n, sizeof (Int), Common) ;
 
465
 
 
466
    Numeric->LUsize = KLU_malloc (nblocks, sizeof (size_t), Common) ;
 
467
 
 
468
    Numeric->LUbx = KLU_malloc (nblocks, sizeof (Unit *), Common) ;
 
469
    if (Numeric->LUbx != NULL)
 
470
    {
 
471
        for (k = 0 ; k < nblocks ; k++)
 
472
        {
 
473
            Numeric->LUbx [k] = NULL ;
 
474
        }
 
475
    }
 
476
 
 
477
    Numeric->Udiag = KLU_malloc (n, sizeof (Entry), Common) ;
490
478
 
491
479
    if (Common->scale > 0)
492
480
    {
493
 
        Numeric->Rs = klu_malloc (n, sizeof (double), Common) ;
 
481
        Numeric->Rs = KLU_malloc (n, sizeof (double), Common) ;
494
482
    }
495
483
    else
496
484
    {
498
486
        Numeric->Rs = NULL ;
499
487
    }
500
488
 
501
 
    Numeric->Pinv = klu_malloc (n, sizeof (int), Common) ;
502
 
 
503
 
    /* allocate permanent workspace for factorization and solve.
504
 
     * Note that the solver will use an Xwork of size 4n, whereas
505
 
     * the factorization codes use an Xwork of size n and integer space
506
 
     * (Iwork) of size 6n. klu_condest uses an Xwork of size 2n. */
507
 
 
508
 
    s = klu_mult_size_t (n, sizeof (Entry), &ok) ;
509
 
    n3 = klu_mult_size_t (n, 3 * sizeof (Entry), &ok) ;
510
 
    b6 = klu_mult_size_t (maxblock, 6 * sizeof (int), &ok) ;
511
 
    Numeric->worksize = klu_add_size_t (s, MAX (n3, b6), &ok) ;
512
 
    if (!ok)
513
 
    {
514
 
        /* problem too large (almost impossible to happen here) */
515
 
        Common->status = KLU_TOO_LARGE ;
516
 
        KLU_free_numeric (&Numeric, Common) ;
517
 
        return (NULL) ;
518
 
    }
519
 
 
520
 
/*
521
 
    Numeric->worksize = n * sizeof (Entry) +
522
 
        MAX (n * 3 *sizeof (Entry), 6*maxblock * sizeof (int)) ;
523
 
*/
524
 
 
525
 
    Numeric->Work = klu_malloc (Numeric->worksize, 1, Common) ;
 
489
    Numeric->Pinv = KLU_malloc (n, sizeof (Int), Common) ;
 
490
 
 
491
    /* allocate permanent workspace for factorization and solve.  Note that the
 
492
     * solver will use an Xwork of size 4n, whereas the factorization codes use
 
493
     * an Xwork of size n and integer space (Iwork) of size 6n. KLU_condest
 
494
     * uses an Xwork of size 2n.  Total size is:
 
495
     *
 
496
     *    n*sizeof(Entry) + max (6*maxblock*sizeof(Int), 3*n*sizeof(Entry))
 
497
     */
 
498
    s = KLU_mult_size_t (n, sizeof (Entry), &ok) ;
 
499
    n3 = KLU_mult_size_t (n, 3 * sizeof (Entry), &ok) ;
 
500
    b6 = KLU_mult_size_t (maxblock, 6 * sizeof (Int), &ok) ;
 
501
    Numeric->worksize = KLU_add_size_t (s, MAX (n3, b6), &ok) ;
 
502
    Numeric->Work = KLU_malloc (Numeric->worksize, 1, Common) ;
526
503
    Numeric->Xwork = Numeric->Work ;
527
 
    Numeric->Iwork = (int *) ((Entry *) Numeric->Xwork + n) ;
528
 
 
529
 
    if (Common->status < KLU_OK)
 
504
    Numeric->Iwork = (Int *) ((Entry *) Numeric->Xwork + n) ;
 
505
    if (!ok || Common->status < KLU_OK)
530
506
    {
531
 
        /* out of memory */
 
507
        /* out of memory or problem too large */
 
508
        Common->status = ok ? KLU_OUT_OF_MEMORY : KLU_TOO_LARGE ;
532
509
        KLU_free_numeric (&Numeric, Common) ;
533
510
        return (NULL) ;
534
511
    }
535
512
 
536
 
    /* clear the pointer arrays, so that klu_free_numeric works OK */
537
 
    CLEAR_PTR (Numeric->Lbip,  nblocks) ;
538
 
    CLEAR_PTR (Numeric->Ubip,  nblocks) ;
539
 
    CLEAR_PTR (Numeric->Lblen, nblocks) ;
540
 
    CLEAR_PTR (Numeric->Ublen, nblocks) ;
541
 
    CLEAR_PTR (Numeric->LUbx,  nblocks) ;
542
 
    CLEAR_PTR (Numeric->Udiag, nblocks) ;
543
 
 
544
 
    /* allocate the column pointer arrays for each block */
545
 
    Lbip = Numeric->Lbip ;
546
 
    Ubip = Numeric->Ubip ;
547
 
    Lblen = Numeric->Lblen ;
548
 
    Ublen = Numeric->Ublen ;
549
 
    Udiag = (Unit **) Numeric->Udiag ;
550
 
 
551
 
    for (block = 0 ; block < nblocks ; block++)
552
 
    {
553
 
        k1 = R [block] ;
554
 
        k2 = R [block+1] ;
555
 
        nk = k2 - k1 ;
556
 
        nk1 = ((size_t) nk) + 1 ;   /* cannot overflow */
557
 
        if (nk > 1)
558
 
        {
559
 
            nunits = UNITS (Entry, nk) ;
560
 
            Lbip [block]  = klu_malloc (nk1, sizeof (int), Common) ;
561
 
            Ubip [block]  = klu_malloc (nk1, sizeof (int), Common) ;
562
 
            Lblen [block] = klu_malloc (nk1, sizeof (int), Common) ;
563
 
            Ublen [block] = klu_malloc (nk1, sizeof (int), Common) ;
564
 
            Udiag [block] = klu_malloc (nunits, sizeof (Unit), Common) ;
565
 
            if (Common->status < KLU_OK)
566
 
            {
567
 
                /* out of memory */
568
 
                KLU_free_numeric (&Numeric, Common) ;
569
 
                return (NULL) ;
570
 
            }
571
 
        }
572
 
    }
573
 
 
574
513
    /* ---------------------------------------------------------------------- */
575
514
    /* factorize the blocks */
576
515
    /* ---------------------------------------------------------------------- */
577
516
 
578
 
    klu_factor2 (Ap, Ai, (Entry *) Ax, Symbolic, Numeric, Common) ;
 
517
    factor2 (Ap, Ai, (Entry *) Ax, Symbolic, Numeric, Common) ;
579
518
 
580
519
    /* ---------------------------------------------------------------------- */
581
520
    /* return or free the Numeric object */