~diresu/blender/blender-command-port

« back to all changes in this revision

Viewing changes to intern/opennl/superlu/spruneL.c

  • Committer: theeth
  • Date: 2008-10-14 16:52:04 UTC
  • Revision ID: vcs-imports@canonical.com-20081014165204-r32w2gm6s0osvdhn
copy back trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
 
 
3
/*
 
4
 * -- SuperLU routine (version 2.0) --
 
5
 * Univ. of California Berkeley, Xerox Palo Alto Research Center,
 
6
 * and Lawrence Berkeley National Lab.
 
7
 * November 15, 1997
 
8
 *
 
9
 */
 
10
/*
 
11
  Copyright (c) 1994 by Xerox Corporation.  All rights reserved.
 
12
 
 
13
  THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY
 
14
  EXPRESSED OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
 
15
 
 
16
  Permission is hereby granted to use or copy this program for any
 
17
  purpose, provided the above notices are retained on all copies.
 
18
  Permission to modify the code and to distribute modified code is
 
19
  granted, provided the above notices are retained, and a notice that
 
20
  the code was modified is included with the above copyright notice.
 
21
*/
 
22
 
 
23
#include "ssp_defs.h"
 
24
#include "util.h"
 
25
 
 
26
void
 
27
spruneL(
 
28
       const int  jcol,      /* in */
 
29
       const int  *perm_r,   /* in */
 
30
       const int  pivrow,    /* in */
 
31
       const int  nseg,      /* in */
 
32
       const int  *segrep,   /* in */
 
33
       const int  *repfnz,   /* in */
 
34
       int        *xprune,   /* out */
 
35
       GlobalLU_t *Glu       /* modified - global LU data structures */
 
36
       )
 
37
{
 
38
/*
 
39
 * Purpose
 
40
 * =======
 
41
 *   Prunes the L-structure of supernodes whose L-structure
 
42
 *   contains the current pivot row "pivrow"
 
43
 *
 
44
 */
 
45
    float     utemp;
 
46
    int        jsupno, irep, irep1, kmin, kmax, krow, movnum;
 
47
    int        i, ktemp, minloc, maxloc;
 
48
    int        do_prune; /* logical variable */
 
49
    int        *xsup, *supno;
 
50
    int        *lsub, *xlsub;
 
51
    float     *lusup;
 
52
    int        *xlusup;
 
53
 
 
54
    xsup       = Glu->xsup;
 
55
    supno      = Glu->supno;
 
56
    lsub       = Glu->lsub;
 
57
    xlsub      = Glu->xlsub;
 
58
    lusup      = Glu->lusup;
 
59
    xlusup     = Glu->xlusup;
 
60
    
 
61
    /*
 
62
     * For each supernode-rep irep in U[*,j]
 
63
     */
 
64
    jsupno = supno[jcol];
 
65
    for (i = 0; i < nseg; i++) {
 
66
 
 
67
        irep = segrep[i];
 
68
        irep1 = irep + 1;
 
69
        do_prune = FALSE;
 
70
 
 
71
        /* Don't prune with a zero U-segment */
 
72
        if ( repfnz[irep] == EMPTY )
 
73
                continue;
 
74
 
 
75
        /* If a snode overlaps with the next panel, then the U-segment 
 
76
         * is fragmented into two parts -- irep and irep1. We should let
 
77
         * pruning occur at the rep-column in irep1's snode. 
 
78
         */
 
79
        if ( supno[irep] == supno[irep1] )      /* Don't prune */
 
80
                continue;
 
81
 
 
82
        /*
 
83
         * If it has not been pruned & it has a nonz in row L[pivrow,i]
 
84
         */
 
85
        if ( supno[irep] != jsupno ) {
 
86
            if ( xprune[irep] >= xlsub[irep1] ) {
 
87
                kmin = xlsub[irep];
 
88
                kmax = xlsub[irep1] - 1;
 
89
                for (krow = kmin; krow <= kmax; krow++) 
 
90
                    if ( lsub[krow] == pivrow ) {
 
91
                        do_prune = TRUE;
 
92
                        break;
 
93
                    }
 
94
            }
 
95
            
 
96
            if ( do_prune ) {
 
97
 
 
98
                /* Do a quicksort-type partition
 
99
                 * movnum=TRUE means that the num values have to be exchanged.
 
100
                 */
 
101
                movnum = FALSE;
 
102
                if ( irep == xsup[supno[irep]] ) /* Snode of size 1 */
 
103
                        movnum = TRUE;
 
104
 
 
105
                while ( kmin <= kmax ) {
 
106
 
 
107
                    if ( perm_r[lsub[kmax]] == EMPTY ) 
 
108
                        kmax--;
 
109
                    else if ( perm_r[lsub[kmin]] != EMPTY )
 
110
                        kmin++;
 
111
                    else { /* kmin below pivrow, and kmax above pivrow: 
 
112
                            *   interchange the two subscripts
 
113
                            */
 
114
                        ktemp = lsub[kmin];
 
115
                        lsub[kmin] = lsub[kmax];
 
116
                        lsub[kmax] = ktemp;
 
117
 
 
118
                        /* If the supernode has only one column, then we
 
119
                         * only keep one set of subscripts. For any subscript 
 
120
                         * interchange performed, similar interchange must be 
 
121
                         * done on the numerical values.
 
122
                         */
 
123
                        if ( movnum ) {
 
124
                            minloc = xlusup[irep] + (kmin - xlsub[irep]);
 
125
                            maxloc = xlusup[irep] + (kmax - xlsub[irep]);
 
126
                            utemp = lusup[minloc];
 
127
                            lusup[minloc] = lusup[maxloc];
 
128
                            lusup[maxloc] = utemp;
 
129
                        }
 
130
 
 
131
                        kmin++;
 
132
                        kmax--;
 
133
 
 
134
                    }
 
135
 
 
136
                } /* while */
 
137
 
 
138
                xprune[irep] = kmin;    /* Pruning */
 
139
 
 
140
#ifdef CHK_PRUNE
 
141
        printf("    After spruneL(),using col %d:  xprune[%d] = %d\n", 
 
142
                        jcol, irep, kmin);
 
143
#endif
 
144
            } /* if do_prune */
 
145
 
 
146
        } /* if */
 
147
 
 
148
    } /* for each U-segment... */
 
149
}