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

« back to all changes in this revision

Viewing changes to KLU/Source/klu_solve.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_solve ============================================================ */
 
2
/* === KLU_solve ============================================================ */
3
3
/* ========================================================================== */
4
4
 
5
 
/* Solve Ax=b using the symbolic and numeric objects from klu_analyze
6
 
 * (or klu_analyze_given) and klu_factor.  Note that no iterative refinement is
 
5
/* Solve Ax=b using the symbolic and numeric objects from KLU_analyze
 
6
 * (or KLU_analyze_given) and KLU_factor.  Note that no iterative refinement is
7
7
 * performed.  Uses Numeric->Xwork as workspace (undefined on input and output),
8
8
 * of size 4n Entry's (note that columns 2 to 4 of Xwork overlap with
9
9
 * Numeric->Iwork).
11
11
 
12
12
#include "klu_internal.h"
13
13
 
14
 
int KLU_solve
 
14
Int KLU_solve
15
15
(
16
16
    /* inputs, not modified */
17
 
    klu_symbolic *Symbolic,
18
 
    klu_numeric *Numeric,
19
 
    int d,                  /* leading dimension of B */
20
 
    int nrhs,               /* number of right-hand-sides */
 
17
    KLU_symbolic *Symbolic,
 
18
    KLU_numeric *Numeric,
 
19
    Int d,                  /* leading dimension of B */
 
20
    Int nrhs,               /* number of right-hand-sides */
21
21
 
22
22
    /* right-hand-side on input, overwritten with solution to Ax=b on output */
23
23
    double B [ ],           /* size n*nrhs, in column-oriented form, with
24
24
                             * leading dimension d. */
25
25
    /* --------------- */
26
 
    klu_common *Common
 
26
    KLU_common *Common
27
27
)
28
28
{
29
29
    Entry x [4], offik, s ;
30
30
    double rs, *Rs ;
31
 
    Entry *Singleton, *Offx, *X, *Bz ;
32
 
    int *Q, *R, *Pnum, *Offp, *Offi ;
33
 
    int **Lbip, **Ubip, **Lblen, **Ublen ;
34
 
    Unit **LUbx, **Udiag ;
35
 
    int k1, k2, nk, k, block, pend, n, p, nblocks, chunk, nr, i ;
 
31
    Entry *Offx, *X, *Bz, *Udiag ;
 
32
    Int *Q, *R, *Pnum, *Offp, *Offi, *Lip, *Uip, *Llen, *Ulen ;
 
33
    Unit **LUbx ;
 
34
    Int k1, k2, nk, k, block, pend, n, p, nblocks, chunk, nr, i ;
 
35
 
 
36
    /* ---------------------------------------------------------------------- */
 
37
    /* check inputs */
 
38
    /* ---------------------------------------------------------------------- */
36
39
 
37
40
    if (Common == NULL)
38
41
    {
39
42
        return (FALSE) ;
40
43
    }
 
44
    if (Numeric == NULL || Symbolic == NULL || d < Symbolic->n || nrhs < 0 ||
 
45
        B == NULL)
 
46
    {
 
47
        Common->status = KLU_INVALID ;
 
48
        return (FALSE) ;
 
49
    }
41
50
    Common->status = KLU_OK ;
42
51
 
43
 
    if (Numeric == NULL)
44
 
    {
45
 
        /* invalid Numeric object */
46
 
        Common->status = KLU_INVALID ;
47
 
        return (FALSE) ;
48
 
    }
 
52
    /* ---------------------------------------------------------------------- */
 
53
    /* get the contents of the Symbolic object */
 
54
    /* ---------------------------------------------------------------------- */
49
55
 
50
56
    Bz = (Entry *) B ;
51
 
 
52
 
    /* ---------------------------------------------------------------------- */
53
 
    /* get the contents of the Symbolic object */
54
 
    /* ---------------------------------------------------------------------- */
55
 
 
56
57
    n = Symbolic->n ;
57
58
    nblocks = Symbolic->nblocks ;
58
59
    Q = Symbolic->Q ;
67
68
    Offp = Numeric->Offp ;
68
69
    Offi = Numeric->Offi ;
69
70
    Offx = (Entry *) Numeric->Offx ;
70
 
    Singleton = (Entry *) Numeric->Singleton ;
71
71
 
72
 
    Lbip = Numeric->Lbip ;
73
 
    Lblen = Numeric->Lblen ;
74
 
    Ubip = Numeric->Ubip ;
75
 
    Ublen = Numeric->Ublen ;
 
72
    Lip  = Numeric->Lip ;
 
73
    Llen = Numeric->Llen ;
 
74
    Uip  = Numeric->Uip ;
 
75
    Ulen = Numeric->Ulen ;
76
76
    LUbx = (Unit **) Numeric->LUbx ;
77
 
    Udiag = (Unit **) Numeric->Udiag ;
 
77
    Udiag = Numeric->Udiag ;
78
78
 
79
79
    Rs = Numeric->Rs ;
80
80
    X = (Entry *) Numeric->Xwork ;
219
219
            /* solve the block system */
220
220
            if (nk == 1)
221
221
            {
222
 
                s = Singleton [block] ;
 
222
                s = Udiag [k1] ;
223
223
                switch (nr)
224
224
                {
225
225
 
249
249
            }
250
250
            else
251
251
            {
252
 
                KLU_lsolve (nk, Lbip [block], Lblen [block], LUbx [block], nr,
 
252
                KLU_lsolve (nk, Lip + k1, Llen + k1, LUbx [block], nr,
253
253
                        X + nr*k1) ;
254
 
                KLU_usolve (nk, Ubip [block], Ublen [block], LUbx [block],
255
 
                        Udiag [block], nr, X + nr*k1) ;
 
254
                KLU_usolve (nk, Uip + k1, Ulen + k1, LUbx [block],
 
255
                        Udiag + k1, nr, X + nr*k1) ;
256
256
            }
257
257
 
258
258
            /* -------------------------------------------------------------- */