File: proto.tex

package info (click to toggle)
spooles 2.2-11
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 19,656 kB
  • ctags: 3,690
  • sloc: ansic: 146,836; sh: 7,571; csh: 3,615; makefile: 1,968; perl: 74
file content (453 lines) | stat: -rw-r--r-- 17,951 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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
\par
\section{Prototypes and descriptions of {\tt DSTree} methods}
\label{section:DSTree:proto}
\par
This section contains brief descriptions including prototypes
of all methods that belong to the {\tt DSTree} object.
\par
\subsection{Basic methods}
\label{subsection:DSTree:proto:basics}
\par
As usual, there are four basic methods to support object creation,
setting default fields, clearing any allocated data, and free'ing
the object.
\par
%=======================================================================
\begin{enumerate}
%-----------------------------------------------------------------------
\item
\begin{verbatim}
DSTree * DSTree_new ( void ) ;
\end{verbatim}
\index{DSTree_new@{\tt DSTree\_new()}}
This method allocates storage for an instance of 
the {\tt DSTree} object. 
The default fields are set by a call to 
{\tt DSTree\_setDefaultFields()}.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
void DSTree_setDefaultFields ( DSTree *dstree ) ;
\end{verbatim}
\index{DSTree_setDefaultFields@{\tt DSTree\_setDefaultFields()}}
This method sets the data fields to default values:
{\tt tree} and {\tt mapIV} are set to {\tt NULL} ;
\par \noindent {\it Error checking:}
If {\tt dstree} is {\tt NULL},
an error message is printed and the program exits.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
void DSTree_clearData ( DSTree *dstree ) ;
\end{verbatim}
\index{DSTree_clearData@{\tt DSTree\_clearData()}}
This method clears the data fields, free'ing storage that has
been allocated by the object and free'ing objects that it owns.
This method checks to see whether {\tt dstree} is {\tt NULL}.
If {\tt tree} is not {\tt NULL}, then {\tt Tree\_free(tree)} is
called.
If {\tt mapIV} is not {\tt NULL}, then {\tt IV\_free(mapIV)} is
called.
Then the structure's default fields are set
via a call to {\tt DSTree\_setDefaultFields()}.
\par \noindent {\it Error checking:}
If {\tt dstree} is {\tt NULL},
an error message is printed and the program exits.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
void DSTree_free ( DSTree *dstree ) ;
\end{verbatim}
\index{DSTree_free@{\tt DSTree\_free()}}
This method checks to see whether {\tt dstree} is {\tt NULL}.
If so, an error message is printed and the program exits.
Otherwise, it releases any storage by a call to 
{\tt DSTree\_clearData()} then free's the storage for the 
structure with a call to {\tt free()}.
\par \noindent {\it Error checking:}
If {\tt dstree} is {\tt NULL},
an error message is printed and the program exits.
%-----------------------------------------------------------------------
\end{enumerate}
\par
\subsection{Instance methods}
\label{subsection:DSTree:proto:instance}
\par
%=======================================================================
\begin{enumerate}
%-----------------------------------------------------------------------
\item
\begin{verbatim}
Tree * DSTree_tree ( DSTree *dstree ) ;
\end{verbatim}
\index{DSTree_tree@{\tt DSTree\_tree()}}
This method returns a pointer to its {\tt Tree} object.
\par \noindent {\it Error checking:}
If {\tt dstree} is {\tt NULL}, 
an error message is printed and the program exits.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
IV * DSTree_mapIV ( DSTree *dstree ) ;
\end{verbatim}
\index{DSTree_mapIV@{\tt DSTree\_mapIV()}}
This method returns a pointer to its {\tt IV} object
that maps vertices to domains and separators.
\par \noindent {\it Error checking:}
If {\tt dstree} is {\tt NULL}, 
an error message is printed and the program exits.
%-----------------------------------------------------------------------
\end{enumerate}
\par
\subsection{Initializer methods}
\label{subsection:DSTree:proto:initializers}
\par
There are three initializers and two helper functions to set the
dimensions of the dstree, allocate the three vectors, and fill the
information.
\par
%=======================================================================
\begin{enumerate}
%-----------------------------------------------------------------------
\item
\begin{verbatim}
void DSTree_init1 ( DSTree *dstree, int ndomsep, int nvtx ) ;
\end{verbatim}
\index{DSTree_init1@{\tt DSTree\_init1()}}
This method initializes an object given the number of vertices,
(the dimension of {\tt mapIV})
and domains and separators (the number of nodes in {\tt tree}).
It then clears any previous data with a call to 
{\tt DSTree\_clearData()}. 
The {\tt tree} field is created and initialized via a call to {\tt
Tree\_init1()}.
The {\tt mapIV} field is created and initialized via a call to {\tt
IV\_init1()}.
\par \noindent {\it Error checking:}
If {\tt dstree} is {\tt NULL}, 
or {\tt ndomsep} or {\tt nvtx} are negative, 
an error message is printed and the program exits.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
void DSTree_init2 ( DSTree *dstree, Tree *tree, IV *mapIV) ;
\end{verbatim}
\index{DSTree_init2@{\tt DSTree\_init2()}}
Any previous data is cleared with a call to 
{\tt DSTree\_clearData()}. 
Then the {\tt tree} and {\tt mapIV} fields are set to the pointers
in the calling sequence.
\par \noindent {\it Error checking:}
If {\tt dstree}, {\tt tree} or {\tt mapIV} are {\tt NULL},
an error message is printed and the program exits.
%-----------------------------------------------------------------------
\end{enumerate}
\par
\subsection{Stage methods}
\label{subsection:DSTree:proto:stages}
\par
The only active function of a {\tt DSTree} object is to construct
the stages vector needed as input to the multi-stage
minimum degree {\tt MSMD} object.
Each domain and separator has a particular level associated with it.
A domain is a leaf of the domain/separator tree, and has level zero.
Each separator has a level that is one greater than the maximum
level of its children.
\par
%=======================================================================
\begin{enumerate}
\item
\begin{verbatim}
IV * DSTree_NDstages ( DSTree *dstree )  ;
\end{verbatim}
\index{DSTree_NDstages@{\tt DSTree\_NDstages()}}
This method returns the stages for natural nested dissection.
The levels of the domains and separators are obtained via a call to
{\tt Tree\_setHeightImetric()}.
A {\tt stagesIV} {\tt IV} object is created of size 
{\tt nvtx = mapIV->size}, filled and then returned.
The stage of a vertex is the level of the domain or separator which
contains the vertex.
\par \noindent {\it Error checking:}
If {\tt dstree} is {\tt NULL},
or if the object has not been initialized,
an error message is printed and the program exits.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
IV * DSTree_ND2stages ( DSTree *dstree )  ;
\end{verbatim}
\index{DSTree_ND2stages@{\tt DSTree\_ND2stages()}}
This method returns the stages for a nested dissection variant,
separators on two adjacent levels are put into the same stage.
The levels of the domains and separators are obtained via a call to
{\tt Tree\_setHeightImetric()}.
A {\tt stagesIV} {\tt IV} object is created of size 
{\tt nvtx = mapIV->size}, filled 
and then returned.
If a vertex is found in a domain, its stage is zero.
If a vertex is found in a separator at level k, its stage is
$\lceil k/2 \rceil$.
\par \noindent {\it Error checking:}
If {\tt dstree} is {\tt NULL},
or if the object has not been initialized,
an error message is printed and the program exits.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
IV * DSTree_MS2stages ( DSTree *dstree )  ;
\end{verbatim}
\index{DSTree_MS2stages@{\tt DSTree\_MS2stages()}}
This method returns the stages for the standard multisection
ordering.
The levels of the domains and separators are obtained via a call to
{\tt Tree\_setHeightImetric()}.
A {\tt stagesIV} {\tt IV} object is created of size 
{\tt nvtx = mapIV->size}, filled 
and then returned.
If a vertex is found in a domain, its stage is zero.
If a vertex is found in a separator, its stage is one.
\par \noindent {\it Error checking:}
If {\tt dstree} is {\tt NULL},
or if the object has not been initialized,
an error message is printed and the program exits.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
IV * DSTree_MS3stages ( DSTree *dstree )  ;
\end{verbatim}
\index{DSTree_MS3stages@{\tt DSTree\_MS3stages()}}
This method returns the stages for a three-stage variant 
of the multisection ordering.
The levels of the domains and separators are obtained via a call to
{\tt Tree\_setHeightImetric()}.
A {\tt stagesIV} {\tt IV} object is created of size 
{\tt nvtx = mapIV->size}, filled 
and then returned.
If a vertex is found in a domain, its stage is zero.
The levels of the separators are split into two sets, the lower
levels and the upper levels.
The stage of a vertex that is found in a separator is either 
one (if the separator is in the lower levels)
or two (if the separator is in the upper levels).
\par \noindent {\it Error checking:}
If {\tt dstree} is {\tt NULL},
or if the object has not been initialized,
an error message is printed and the program exits.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
IV * DSTree_stagesViaDomainWeight ( DSTree *dstree, 
                                    int *vwghts, DV *cutoffDV )  ;
\end{verbatim}
\index{DSTree_stagesViaDomainWeight@{\tt DSTree\_stagesViaDomainWeight()}}
This method sets the stages vector based on subtree (or domain) weights.
Each vertex is mapped to a node in the tree.
We generate the {\it subtree weights} for each subtree, the
fraction of the total vertex weight (based on {\tt vwghts[]})
that is contained in the subtree.
For each node in the tree, its fraction of the node weights lies
between two consectutive values in the {\tt cutoff[]} vector,
and that is the stage for all vertices contained in the node.
\par \noindent {\it Error checking:}
If {\tt dstree} or {\tt cutoffDV} is {\tt NULL},
or if the object has not been initialized,
an error message is printed and the program exits.
%-----------------------------------------------------------------------
\end{enumerate}
\par
\par
\subsection{Utility methods}
\label{subsection:DSTree:proto:utilities}
\par
There is one 
utility method that returns the number of bytes taken by the object.
\par
%=======================================================================
\begin{enumerate}
%-----------------------------------------------------------------------
\item
\begin{verbatim}
int DSTree_sizeOf ( DSTree *dstree ) ;
\end{verbatim}
\index{DSTree_sizeOf@{\tt DSTree\_sizeOf()}}
If {\tt dstree} is {\tt NULL},
an error message is printed and the program exits.
Otherwise, the number of bytes taken by this object is returned.
\par \noindent {\it Error checking:}
If {\tt dstree} is {\tt NULL},
an error message is printed and the program exits.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
void DSTree_renumberViaPostOT ( DSTree *dstree ) ;
\end{verbatim}
\index{DSTree_renumberViaPostOT@{\tt DSTree\_renumberViaPostOT()}}
This method renumbers the fronts in the tree via  a post-order
traversal.
\par \noindent {\it Error checking:}
If {\tt dstree} is {\tt NULL},
or if the object has not been initialized,
an error message is printed and the program exits.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
int DSTree_domainWeight ( DSTree *dstree, int vwghts[] ) ;
\end{verbatim}
\index{DSTree_domainWeight@{\tt DSTree\_domainWeight()}}
This method returns the weight of the vertices in the domains.
If {\tt vwghts} is {\tt NULL}, the vertices have unit weight.
\par \noindent {\it Error checking:}
If {\tt dstree} is {\tt NULL},
an error message is printed and the program exits.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
int DSTree_separatorWeight ( DSTree *dstree, int vwghts[] ) ;
\end{verbatim}
\index{DSTree_separatorWeight@{\tt DSTree\_separatorWeight()}}
This method returns the weight of the vertices in the separators.
If {\tt vwghts} is {\tt NULL}, the vertices have unit weight.
\par \noindent {\it Error checking:}
If {\tt dstree} is {\tt NULL},
an error message is printed and the program exits.
%-----------------------------------------------------------------------
\end{enumerate}
\par
\subsection{IO methods}
\label{subsection:DSTree:proto:IO}
\par
There are the usual eight IO routines.
The file structure of a dstree object is simple:
the structure for a {\tt Tree} object
followed by the structure for an {\tt IV} object.
\par
%=======================================================================
\begin{enumerate}
%-----------------------------------------------------------------------
\item
\begin{verbatim}
int DSTree_readFromFile ( DSTree *dstree, char *fn ) ;
\end{verbatim}
\index{DSTree_readFromFile@{\tt DSTree\_readFromFile()}}
\par
This method reads a {\tt DSTree} object from a file.
It tries to open the file and if it is successful, 
it then calls {\tt DSTree\_readFromFormattedFile()} or
{\tt DSTree\_readFromBinaryFile()}, 
closes the file
and returns the value returned from the called routine.
\par \noindent {\it Error checking:}
If {\tt dstree} or {\tt fn} are {\tt NULL}, 
or if {\tt fn} is not of the form
{\tt *.dstreef} (for a formatted file) 
or {\tt *.dstreeb} (for a binary file),
an error message is printed and the method returns zero.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
int DSTree_readFromFormattedFile ( DSTree *dstree, FILE *fp ) ;
\end{verbatim}
\index{DSTree_readFromFormattedFile@{\tt DSTree\_readFromFormattedFile()}}
\par
This method reads in a {\tt DSTree} object from a formatted file.
If there are no errors in reading the data, 
the value {\tt 1} is returned.
If an IO error is encountered from {\tt fscanf}, zero is returned.
\par \noindent {\it Error checking:}
If {\tt dstree} or {\tt fp} is {\tt NULL}, 
an error message is printed and zero is returned.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
int DSTree_readFromBinaryFile ( DSTree *dstree, FILE *fp ) ;
\end{verbatim}
\index{DSTree_readFromBinaryFile@{\tt DSTree\_readFromBinaryFile()}}
\par
This method reads in a {\tt DSTree} object from a binary file.
If there are no errors in reading the data, 
the value {\tt 1} is returned.
If an IO error is encountered from {\tt fread}, zero is returned.
\par \noindent {\it Error checking:}
If {\tt dstree} or {\tt fp} is {\tt NULL}, 
an error message is printed and zero is returned.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
int DSTree_writeToFile ( DSTree *dstree, char *fn ) ;
\end{verbatim}
\index{DSTree_writeToFile@{\tt DSTree\_writeToFile()}}
\par
This method writes a {\tt DSTree} object to a file.
It tries to open the file and if it is successful, 
it then calls {\tt DSTree\_writeFromFormattedFile()} or
{\tt DSTree\_writeFromBinaryFile()},
closes the file
and returns the value returned from the called routine.
\par \noindent {\it Error checking:}
If {\tt dstree} or {\tt fn} are {\tt NULL}, 
or if {\tt fn} is not of the form
{\tt *.dstreef} (for a formatted file) 
or {\tt *.dstreeb} (for a binary file),
an error message is printed and the method returns zero.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
int DSTree_writeToFormattedFile ( DSTree *dstree, FILE *fp ) ;
\end{verbatim}
\index{DSTree_writeToFormattedFile@{\tt DSTree\_writeToFormattedFile()}}
\par
This method writes a {\tt DSTree} object to a formatted file.
If there are no errors in writing the data, 
the value {\tt 1} is returned.
If an IO error is encountered from {\tt fprintf}, zero is returned.
\par \noindent {\it Error checking:}
If {\tt dstree} or {\tt fp} is {\tt NULL}, 
an error message is printed and zero is returned.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
int DSTree_writeToBinaryFile ( DSTree *dstree, FILE *fp ) ;
\end{verbatim}
\index{DSTree_writeToBinaryFile@{\tt DSTree\_writeToBinaryFile()}}
\par
This method writes a {\tt DSTree} object to a binary file.
If there are no errors in writing the data, 
the value {\tt 1} is returned.
If an IO error is encountered from {\tt fwrite}, zero is returned.
\par \noindent {\it Error checking:}
If {\tt dstree} or {\tt fp} is {\tt NULL}, 
an error message is printed and zero is returned.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
int DSTree_writeForHumanEye ( DSTree *dstree, FILE *fp ) ;
\end{verbatim}
\index{DSTree_writeForHumanEye@{\tt DSTree\_writeForHumanEye()}}
\par
This method writes a {\tt DSTree} object to a file in a human
readable format.
The method {\tt DSTree\_writeStats()} is called to write out the
header and statistics. 
Then the tree structure is printed via a call to
{\tt Tree\_writeForHumanEye}, followed by the map structure via a
call to
{\tt IV\_writeForHumanEye}.
The value {\tt 1} is returned.
\par \noindent {\it Error checking:}
If {\tt dstree} or {\tt fp} is {\tt NULL}, 
an error message is printed and zero is returned.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
int DSTree_writeStats ( DSTree *dstree, FILE *fp ) ;
\end{verbatim}
\index{DSTree_writeStats@{\tt DSTree\_writeStats()}}
\par
This method write the header and statistics to a file.
The value {\tt 1} is returned.
\par \noindent {\it Error checking:}
If {\tt dstree} or {\tt fp} is {\tt NULL}, 
an error message is printed and zero is returned.
%-----------------------------------------------------------------------
\end{enumerate}