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

« back to all changes in this revision

Viewing changes to scipy/linsolve/SuperLU/SRC/zcopy_to_ucol.c

  • 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
 
 
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 "zsp_defs.h"
 
24
#include "util.h"
 
25
 
 
26
int
 
27
zcopy_to_ucol(
 
28
              int        jcol,    /* in */
 
29
              int        nseg,    /* in */
 
30
              int        *segrep,  /* in */
 
31
              int        *repfnz,  /* in */
 
32
              int        *perm_r,  /* in */
 
33
              doublecomplex     *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
    doublecomplex    *ucol;
 
48
    int       *usub, *xusub;
 
49
    int       nzumax;
 
50
 
 
51
    doublecomplex zero = {0.0, 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 = zLUMemXpand(jcol, nextu, UCOL, &nzumax, Glu))
 
80
                        return (mem_error);
 
81
                    ucol = Glu->ucol;
 
82
                    if (mem_error = zLUMemXpand(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
}