~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2005-11-06 12:40:03 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051106124003-3pgs7tcg5rox96xg
Tags: 2.37a-1.1
* Non-maintainer upload.
* Split out parts of 01_SConstruct_debian.dpatch again: root_build_dir
  really needs to get adjusted before the clean target runs - closes: #333958,
  see #288882 for reference

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
int
 
27
scopy_to_ucol(
 
28
              int        jcol,    /* in */
 
29
              int        nseg,    /* in */
 
30
              int        *segrep,  /* in */
 
31
              int        *repfnz,  /* in */
 
32
              int        *perm_r,  /* in */
 
33
              float     *dense,   /* modified - reset to zero on return */
 
34
              GlobalLU_t *Glu      /* modified */
 
35
              )
 
36
{
 
37
/* 
 
38
 * Gather from SPA dense[*] to global ucol[*].
 
39
 */
 
40
    int ksub, krep, ksupno;
 
41
    int i, k, kfnz, segsze;
 
42
    int fsupc, isub, irow;
 
43
    int jsupno, nextu;
 
44
    int new_next, mem_error;
 
45
    int       *xsup, *supno;
 
46
    int       *lsub, *xlsub;
 
47
    float    *ucol;
 
48
    int       *usub, *xusub;
 
49
    int       nzumax;
 
50
 
 
51
    float zero = 0.0;
 
52
 
 
53
    xsup    = Glu->xsup;
 
54
    supno   = Glu->supno;
 
55
    lsub    = Glu->lsub;
 
56
    xlsub   = Glu->xlsub;
 
57
    ucol    = Glu->ucol;
 
58
    usub    = Glu->usub;
 
59
    xusub   = Glu->xusub;
 
60
    nzumax  = Glu->nzumax;
 
61
    
 
62
    jsupno = supno[jcol];
 
63
    nextu  = xusub[jcol];
 
64
    k = nseg - 1;
 
65
    for (ksub = 0; ksub < nseg; ksub++) {
 
66
        krep = segrep[k--];
 
67
        ksupno = supno[krep];
 
68
 
 
69
        if ( ksupno != jsupno ) { /* Should go into ucol[] */
 
70
            kfnz = repfnz[krep];
 
71
            if ( kfnz != EMPTY ) {      /* Nonzero U-segment */
 
72
 
 
73
                fsupc = xsup[ksupno];
 
74
                isub = xlsub[fsupc] + kfnz - fsupc;
 
75
                segsze = krep - kfnz + 1;
 
76
 
 
77
                new_next = nextu + segsze;
 
78
                while ( new_next > nzumax ) {
 
79
                    if ((mem_error = sLUMemXpand(jcol, nextu, UCOL, &nzumax, Glu)))
 
80
                        return (mem_error);
 
81
                    ucol = Glu->ucol;
 
82
                    if ((mem_error = sLUMemXpand(jcol, nextu, USUB, &nzumax, Glu)))
 
83
                        return (mem_error);
 
84
                    usub = Glu->usub;
 
85
                    lsub = Glu->lsub;
 
86
                }
 
87
                
 
88
                for (i = 0; i < segsze; i++) {
 
89
                    irow = lsub[isub];
 
90
                    usub[nextu] = perm_r[irow];
 
91
                    ucol[nextu] = dense[irow];
 
92
                    dense[irow] = zero;
 
93
                    nextu++;
 
94
                    isub++;
 
95
                } 
 
96
 
 
97
            }
 
98
 
 
99
        }
 
100
 
 
101
    } /* for each segment... */
 
102
 
 
103
    xusub[jcol + 1] = nextu;      /* Close U[*,jcol] */
 
104
    return 0;
 
105
}