1 /* This software was developed by Bruce Hendrickson and Robert Leland   *
2  * at Sandia National Laboratories under US Department of Energy        *
3  * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
4 
5 #include <stdio.h>
6 #include <math.h>
7 #include "structs.h"
8 
9 
makevwsqrt(vwsqrt,graph,nvtxs)10 void      makevwsqrt(vwsqrt, graph, nvtxs)
11 /* Make vector of square roots of vertex weights. */
12 double   *vwsqrt;		/* vector returned */
13 struct vtx_data **graph;	/* graph data structure */
14 int       nvtxs;		/* number of vertices in graph */
15 {
16     extern int NSQRTS;		/* number of sqrts already computed */
17     extern double *SQRTS;	/* values computed */
18     int       vwgt;		/* vertex weight */
19     int       i;		/* loop counter */
20 
21     for (i = 1; i <= nvtxs; i++) {
22 	vwgt = graph[i]->vwgt;
23 	if (vwgt <= NSQRTS)
24 	    vwsqrt[i] = SQRTS[vwgt];
25 	else
26 	    vwsqrt[i] = sqrt((double) vwgt);
27     }
28 }
29 
30 
31 /* Extract the subgraph vwsqrt values */
make_subvector(vec,subvec,subnvtxs,loc2glob)32 void      make_subvector(vec, subvec, subnvtxs, loc2glob)
33 double   *vec;			/* vector for all vertices */
34 double   *subvec;		/* vector for vertices in subgraph */
35 int       subnvtxs;		/* number of vtxs in subgraph */
36 int      *loc2glob;		/* subgraph -> graph numbering map */
37 {
38     int       i;
39 
40     for (i = 1; i <= subnvtxs; i++) {
41 	++subvec;
42 	(*subvec) = vec[loc2glob[i]];
43     }
44 }
45