File: testFS.c

package info (click to toggle)
spooles 2.2-5
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 18,824 kB
  • ctags: 3,665
  • sloc: ansic: 146,828; csh: 3,615; makefile: 2,045; perl: 70
file content (280 lines) | stat: -rw-r--r-- 7,965 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
/*  testFS.c  */

#include "../../ETree.h"
#include "../../SymbFac.h"
#include "../../timings.h"

/*--------------------------------------------------------------------*/
int
main ( int argc, char *argv[] )
/*
   -------------------------------------------------------
   read in an ETree object. compute the heights of the nodes 
   in the tree w.r.t. an out-of-core forward sparse factorization. 
   draw the tree.
   
   created -- 99jan07, cca
   -------------------------------------------------------
*/
{
char     *firstEPSfilename, *inETreeFileName, *secondEPSfilename ;
double   nfops1, radius, t1, t2 ;
double   *x, *y ;
double   bbox[4], bounds[4], frame[4] ;
DV       *xDV, *yDV ;
IV       *dmetricIV, *hmetricIV, *vmetricIV ;
int      bndJ, J, K, labelflag, maxdepth, maxnent, msglvl, 
         nfent1, nfind1, nfront, nleaves1, nnode1, rc ;
int      *bndwghts, *depths, *heights, *nzfs, *par ;
ETree    *etree ;
FILE     *msgFile ;
Tree     *tree ;

if ( argc != 8 ) {
   fprintf(stdout, 
"\n\n usage : %s msglvl msgFile inETreeFile labelflag radius"
"\n         firstEPSfileName secondEPSfileName"
"\n    msglvl            -- message level"
"\n    msgFile           -- message file"
"\n    inETreeFile       -- input file, must be *.etreef or *.etreeb"
"\n    labelflag         -- flag to draw labels"
"\n    radius            -- radius of node"
"\n    firstEPSfilename  -- EPS file for subtree working storage"
"\n    secondEPSfilename -- EPS file for node working storage"
"\n", argv[0]) ;
   return(0) ;
}
msglvl = atoi(argv[1]) ;
if ( strcmp(argv[2], "stdout") == 0 ) {
   msgFile = stdout ;
} else if ( (msgFile = fopen(argv[2], "a")) == NULL ) {
   fprintf(stderr, "\n fatal error in %s"
           "\n unable to open file %s\n",
           argv[0], argv[2]) ;
   return(-1) ;
}
inETreeFileName   = argv[3] ;
labelflag         = atoi(argv[4]) ;
radius            = atof(argv[5]) ;
firstEPSfilename  = argv[6] ;
secondEPSfilename = argv[7] ;
fprintf(msgFile, 
        "\n %s "
        "\n msglvl        -- %d" 
        "\n msgFile       -- %s" 
        "\n inETreeFile   -- %s" 
        "\n firstEPSfilename    -- %s" 
        "\n labelflag     -- %d" 
        "\n radius        -- %f" 
        "\n",
        argv[0], msglvl, argv[2], inETreeFileName, firstEPSfilename,
        labelflag, radius) ;
fflush(msgFile) ;
/*
   ------------------------
   read in the ETree object
   ------------------------
*/
if ( strcmp(inETreeFileName, "none") == 0 ) {
   fprintf(msgFile, "\n no file to read from") ;
   exit(0) ;
}
etree = ETree_new() ;
MARKTIME(t1) ;
rc = ETree_readFromFile(etree, inETreeFileName) ;
MARKTIME(t2) ;
fprintf(msgFile, "\n CPU %9.5f : read in etree from file %s",
        t2 - t1, inETreeFileName) ;
if ( rc != 1 ) {
   fprintf(msgFile, "\n return value %d from ETree_readFromFile(%p,%s)",
           rc, etree, inETreeFileName) ;
   exit(-1) ;
}
fprintf(msgFile, "\n\n after reading ETree object from file %s",
        inETreeFileName) ;
if ( msglvl > 2 ) {
   ETree_writeForHumanEye(etree, msgFile) ;
} else {
   ETree_writeStats(etree, msgFile) ;
}
ETree_leftJustify(etree) ;
fprintf(msgFile, "\n\n %d LU entries", ETree_nFactorEntries(etree, 2)) ;
fflush(msgFile) ;
/*
   ----------------------
   compute the statistics
   ----------------------
*/
tree   = etree->tree   ;
nfront = etree->nfront ;
nnode1 = etree->tree->n ;
nfind1 = ETree_nFactorIndices(etree) ;
nfent1 = ETree_nFactorEntries(etree, 1) ;
nfops1 = ETree_nFactorOps(etree, SPOOLES_REAL, SPOOLES_SYMMETRIC) ;
nleaves1 = Tree_nleaves(etree->tree) ;
fprintf(msgFile, "\n root front %d has %d vertices",
        etree->tree->root,
        etree->nodwghtsIV->vec[etree->tree->root]) ;
fprintf(msgFile, "\n %d fronts, %d indices, %d entries, %.0f ops",
        nfront, nfind1, nfent1, nfops1) ;
fprintf(msgFile, "\n max front size = %d",
        IV_max(ETree_nodwghtsIV(etree))) ;
fprintf(msgFile, "\n max boundary size = %d",
        IV_max(ETree_bndwghtsIV(etree))) ;
/*
   ------------------------------
   get the # of entries per front
   ------------------------------
*/
vmetricIV = ETree_factorEntriesIV(etree, SPOOLES_SYMMETRIC) ;
if ( msglvl > 1 ) {
   fprintf(msgFile, "\n\n entries per front") ;
   IV_writeForHumanEye(vmetricIV, msgFile) ;
   fflush(msgFile) ;
}
maxnent = IV_max(vmetricIV) ;
fprintf(msgFile, "\n\n max entries per front = %d", maxnent) ;
fflush(msgFile) ;
/*
   --------------------------------
   get the simple (x,y) coordinates
   --------------------------------
*/
xDV = DV_new() ;
yDV = DV_new() ;
rc = Tree_getSimpleCoords(tree, 'H', 'C', xDV, yDV) ;
if ( rc != 1 ) {
   fprintf(stderr, "\n error in %s",
           "\n return value %d from Tree_getSimpleCoords()\n",
           argv[0], rc) ;
   exit(-1) ;
}
x = DV_entries(xDV) ;
y = DV_entries(yDV) ;
/*
   ----------------------
   get the height profile
   ----------------------
*/
hmetricIV = Tree_setHeightImetric(tree, vmetricIV) ;
if ( msglvl > 1 ) {
   fprintf(msgFile, "\n\n entries height per front") ;
   IV_writeForHumanEye(hmetricIV, msgFile) ;
   fflush(msgFile) ;
}
/*
   -----------------------------------------------
   compute y[J] = heights[J] + |bndJ|*(|bndJ|+1)/2
   -----------------------------------------------
*/
heights = IV_entries(hmetricIV) ;
bndwghts = ETree_bndwghts(etree) ;
for ( J = 0 ; J < nfront ; J++ ) {
   bndJ = bndwghts[J] ;
   y[J] = heights[J] + (bndJ*(bndJ+1))/2 ;
}
if ( msglvl > 0 ) {
   fprintf(msgFile, "\n\n  J    x    y") ;
   for ( J = 0 ; J < nfront ; J++ ) {
      fprintf(msgFile, "\n %5d %12.3f %12.0f", J, x[J], y[J]) ;
   }
}
/*
   ------------------
   compute the bounds
   ------------------
*/
bounds[0] = 0.0 ;
bounds[1] = 0.0 ;
bounds[2] = DV_max(xDV) ;
bounds[3] = DV_max(yDV) ;
fprintf(stdout, "\n\n bounds = [ %.3g %.3g %.3g %.3g ] ",
        bounds[0], bounds[1], bounds[2], bounds[3]) ;
/*
   -------------
   draw the tree
   -------------
*/
bbox[0]  = 50.0 ; 
bbox[1]  = 50.0 ; 
bbox[2]  = 500.0 ; 
bbox[3]  = 500.0 ;
frame[0] = bbox[0] + 10 ;
frame[1] = bbox[1] + 10 ;
frame[2] = bbox[2] - 10 ;
frame[3] = bbox[3] - 10 ;
rc = Tree_drawToEPS(tree, firstEPSfilename, xDV, yDV, radius, NULL,
                    labelflag, radius, NULL, bbox, frame, bounds) ;
if ( rc != 1 ) {
   fprintf(stderr, "\n error in %s"
           "\n return value %d from Tree_drawToEPS()\n",
           argv[0], rc) ;
   exit(-1) ;
}
/*
   ---------------------
   get the depth profile
   ---------------------
*/
dmetricIV = Tree_setDepthImetric(tree, vmetricIV) ;
if ( msglvl > 1 ) {
   fprintf(msgFile, "\n\n entries depth per front") ;
   IV_writeForHumanEye(dmetricIV, msgFile) ;
   fflush(msgFile) ;
}
/*
   ----------------------------------------
   compute y[J] = depths[par(J)] + nfent[J]
   ----------------------------------------
*/
par    = Tree_par(tree) ;
depths = IV_entries(dmetricIV) ;
nzfs   = IV_entries(vmetricIV) ;
for ( J = 0 ; J < nfront ; J++ ) {
   y[J] = nzfs[J] ;
   if ( (K = par[J]) != -1 ) {
      y[J] += depths[K] ;
    }
}
if ( msglvl > 0 ) {
   fprintf(msgFile, "\n\n  J    x    y") ;
   for ( J = 0 ; J < nfront ; J++ ) {
      fprintf(msgFile, "\n %5d %12.3f %12.0f", J, x[J], y[J]) ;
   }
}
/*
   -------------
   draw the tree
   -------------
*/
bbox[0]  = 50.0 ; 
bbox[1]  = 50.0 ; 
bbox[2]  = 500.0 ; 
bbox[3]  = 500.0 ;
frame[0] = bbox[0] + 10 ;
frame[1] = bbox[1] + 10 ;
frame[2] = bbox[2] - 10 ;
frame[3] = bbox[3] - 10 ;
rc = Tree_drawToEPS(tree, secondEPSfilename, xDV, yDV, radius, NULL,
                    labelflag, radius, NULL, bbox, frame, bounds) ;
if ( rc != 1 ) {
   fprintf(stderr, "\n error in %s"
           "\n return value %d from Tree_drawToEPSfile()\n",
           argv[0], rc) ;
   exit(-1) ;
}
/*
   ----------------
   free the objects
   ----------------
*/
ETree_free(etree) ;
IV_free(vmetricIV) ;
IV_free(hmetricIV) ;

fprintf(msgFile, "\n") ;
fclose(msgFile) ;

return(1) ; }

/*--------------------------------------------------------------------*/