Blender V2.61 - r43446

scopy_to_ucol.c

Go to the documentation of this file.
00001 
00006 /*
00007  * -- SuperLU routine (version 2.0) --
00008  * Univ. of California Berkeley, Xerox Palo Alto Research Center,
00009  * and Lawrence Berkeley National Lab.
00010  * November 15, 1997
00011  *
00012  */
00013 /*
00014   Copyright (c) 1994 by Xerox Corporation.  All rights reserved.
00015  
00016   THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY
00017   EXPRESSED OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
00018  
00019   Permission is hereby granted to use or copy this program for any
00020   purpose, provided the above notices are retained on all copies.
00021   Permission to modify the code and to distribute modified code is
00022   granted, provided the above notices are retained, and a notice that
00023   the code was modified is included with the above copyright notice.
00024 */
00025 
00026 #include "ssp_defs.h"
00027 #include "util.h"
00028 
00029 int
00030 scopy_to_ucol(
00031           int        jcol,    /* in */
00032           int        nseg,    /* in */
00033           int        *segrep,  /* in */
00034           int        *repfnz,  /* in */
00035           int        *perm_r,  /* in */
00036           float     *dense,   /* modified - reset to zero on return */
00037           GlobalLU_t *Glu      /* modified */
00038           )
00039 {
00040 /* 
00041  * Gather from SPA dense[*] to global ucol[*].
00042  */
00043     int ksub, krep, ksupno;
00044     int i, k, kfnz, segsze;
00045     int fsupc, isub, irow;
00046     int jsupno, nextu;
00047     int new_next, mem_error;
00048     int       *xsup, *supno;
00049     int       *lsub, *xlsub;
00050     float    *ucol;
00051     int       *usub, *xusub;
00052     int       nzumax;
00053 
00054     float zero = 0.0;
00055 
00056     xsup    = Glu->xsup;
00057     supno   = Glu->supno;
00058     lsub    = Glu->lsub;
00059     xlsub   = Glu->xlsub;
00060     ucol    = Glu->ucol;
00061     usub    = Glu->usub;
00062     xusub   = Glu->xusub;
00063     nzumax  = Glu->nzumax;
00064     
00065     jsupno = supno[jcol];
00066     nextu  = xusub[jcol];
00067     k = nseg - 1;
00068     for (ksub = 0; ksub < nseg; ksub++) {
00069     krep = segrep[k--];
00070     ksupno = supno[krep];
00071 
00072     if ( ksupno != jsupno ) { /* Should go into ucol[] */
00073         kfnz = repfnz[krep];
00074         if ( kfnz != EMPTY ) {  /* Nonzero U-segment */
00075 
00076             fsupc = xsup[ksupno];
00077             isub = xlsub[fsupc] + kfnz - fsupc;
00078             segsze = krep - kfnz + 1;
00079 
00080         new_next = nextu + segsze;
00081         while ( new_next > nzumax ) {
00082             if ((mem_error = sLUMemXpand(jcol, nextu, UCOL, &nzumax, Glu)))
00083             return (mem_error);
00084             ucol = Glu->ucol;
00085             if ((mem_error = sLUMemXpand(jcol, nextu, USUB, &nzumax, Glu)))
00086             return (mem_error);
00087             usub = Glu->usub;
00088             lsub = Glu->lsub;
00089         }
00090         
00091         for (i = 0; i < segsze; i++) {
00092             irow = lsub[isub];
00093             usub[nextu] = perm_r[irow];
00094             ucol[nextu] = dense[irow];
00095             dense[irow] = zero;
00096             nextu++;
00097             isub++;
00098         } 
00099 
00100         }
00101 
00102     }
00103 
00104     } /* for each segment... */
00105 
00106     xusub[jcol + 1] = nextu;      /* Close U[*,jcol] */
00107     return 0;
00108 }