/[ascend]/trunk/base/generic/solver/mtx_use_only.h
ViewVC logotype

Contents of /trunk/base/generic/solver/mtx_use_only.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1015 - (show annotations) (download) (as text)
Wed Jan 3 05:03:43 2007 UTC (13 years, 1 month ago) by johnpye
File MIME type: text/x-chdr
File size: 27969 byte(s)
Trying doxygen comments once again
1 #ifdef __MTX_C_SEEN__
2 /*
3 * mtx2: Ascend Sparse Matrix Package
4 * by Benjamin Andrew Allan
5 * Derived from mtx by Karl Michael Westerberg
6 * Created: 5/3/90
7 * Version: $Revision: 1.9 $
8 * Version control file: $RCSfile: mtx_use_only.h,v $
9 * Date last modified: $Date: 2000/01/25 02:27:13 $
10 * Last modified by: $Author: ballan $
11 *
12 * This file is part of the SLV solver.
13 *
14 * Copyright (C) 1996 Benjamin Andrew Allan
15 * based (loosely) on mtx
16 * Copyright (C) 1990 Karl Michael Westerberg
17 * Copyright (C) 1993 Joseph Zaher
18 * Copyright (C) 1994 Joseph Zaher, Benjamin Andrew Allan
19 * Copyright (C) 1995 Kirk Andre Abbott, Benjamin Andrew Allan
20 *
21 * The SLV solver is free software; you can redistribute
22 * it and/or modify it under the terms of the GNU General Public License as
23 * published by the Free Software Foundation; either version 2 of the
24 * License, or (at your option) any later version.
25 *
26 * The SLV solver is distributed in hope that it will be
27 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 * General Public License for more details.
30 *
31 * You should have received a copy of the GNU General Public License along with
32 * the program; if not, write to the Free Software Foundation, Inc., 675
33 * Mass Ave, Cambridge, MA 02139 USA. Check the file named COPYING.
34 * COPYING is found in ../compiler.
35 */
36
37 /** @file
38 * mtx2: Ascend Sparse Matrix Package (Private).
39 *
40 * This file defines the private parts of an mtx and is only for mtx*.c
41 * consumption. Any temptation to include this header in a linear or
42 * nonlinear solver package is a symptom of extremely bad programming
43 * and lack of proper task analysis. This header should be regarded as
44 * highly unstable. We make ABSOLUTELY NO commitment to maintain
45 * consistency between any two versions of this file.<br><br>
46 *
47 * Note to third parties:
48 * mtx is PRODUCTION code in very long use at Carnegie Mellon University.
49 * * As such, we maintain a very tight hold of the internals of our data
50 * structure so that we can easily prove the code when apparent bugs arise.
51 * 99.44% of "bugs" experienced in using mtx are the result of not
52 * reading the public headers carefully.<br><br>
53 *
54 * The material in this file was never a part of any header until the
55 * old mtx.c file got so big that we had to split it up to make it
56 * manageable.<br><br>
57 *
58 * Note to future developers of the mtx module. If you change ANYTHING
59 * in this file it is YOUR job to:
60 * a) clear that change with all the other developers using this header
61 * b) fix ALL the other mtx*.c files that depend on it.
62 * If you are not willing to do that much work, why the hell are you
63 * dabbling in sparse matrix math? go work on GUIs.
64 * <pre>
65 * requires: #include <stdio.h>
66 * requires: #include "utilities/ascConfig.h"
67 * requires: #include "mem.h"
68 * requires: #include "mtx.h"
69 * <pre>
70 */
71
72 #ifndef __MTX_INTERNAL_USE_ONLY_H__
73 #define __MTX_INTERNAL_USE_ONLY_H__
74
75 /** @addtogroup linear
76 * @{
77 */
78
79 #ifndef FALSE
80 /** These should have come in from ascConfig.h.
81 * @todo Remove redefines of FALSE & TRUE to enforce pre-inclusion of ascCenfig.h? */
82 #define FALSE 0
83 #define TRUE 1
84 #endif
85
86 #define MTX_DEBUG FALSE
87 /**< MTX_DEBUG is a no holds barred sanity checking flag for use when
88 * nothing else is giving a clue why something is going wrong. It
89 * slows down the code to a crawl. Do not under any conditions change
90 * its value or undefine it except at this location. If you need some
91 * other sort of debugging flag for debugging a particular function,
92 * use some personal debugging flag.
93 */
94
95 #define EVEN FALSE
96 #define ODD TRUE
97 #define SWAPS_PRESERVE_ORDER TRUE
98 /**<
99 *** Do row and column swaps preserve the ordering of non-zeros in rows
100 *** and columns? Setting this to TRUE means swapping only entails the
101 *** movement of integer row or column numbers and NOT the exchange of
102 *** entire row or columns.
103 **/
104 #define WIDTHMAGIC 2048
105 /**<
106 *** WIDTHMAGIC is the byte size to aim for in allocating groups of elements.
107 **/
108 #define LENMAGIC 10
109 /**<
110 *** LENMAGIC initial # of groups of elements, hence the smallest
111 *** possible number of elements a matrix will ever have is LENM*WIDTHM/eltsize.
112 **/
113
114 extern FILE *g_mtxerr;
115 /**<
116 *** Global file pointer to which errors are reported. Should never be
117 *** NULL. Also useful when running ascend in gdb and you can't find
118 *** any other file pointer to use.
119 **/
120
121 /** just a struct to make resulting code more readable. */
122 struct next_element_t {
123 struct element_t *row;
124 struct element_t *col;
125 };
126
127 /**
128 *** This is the basic jacobian element of an mtx.
129 *** It's size is 24 bytes on 4 byte pointer machines and
130 *** 32 bytes on 8 byte pointer machines.
131 *** The elements form a bidirectional singly linked list.
132 *** The row and col indices in an element refer back to
133 *** the header positions of the two lists that element is in.
134 *** That is, each element knows its orgrow and orgcol.
135 **/
136 struct element_t {
137 real64 value;
138 int32 row;
139 int32 col;
140 struct next_element_t next;
141 };
142
143 /**
144 *** Each matrix is really just a pair of arrays of pointers to
145 *** elements. The index of a row or column in THESE arrays is
146 *** what is referred to as an org index. A value of NULL in
147 *** either array means that that row (or col) is empty.<br><br>
148 ***
149 *** When we insert elements in the matrix, we simply shove the
150 *** element in at the head of the its row/column lists.
151 *** When we delete an element in the matrix, we search in one
152 *** direction and unlink the element, marking it "dead". Then a
153 *** general pass in the other direction unlinks all the "dead"
154 *** elements.<br><br>
155 ***
156 *** Special note: The -1th element of nz_header arrays is NOT allocated.
157 **/
158 struct nz_headers_t {
159 struct element_t **row;
160 struct element_t **col;
161 };
162
163 /**<
164 *** We maintain, rather than rederiving, the information required to
165 *** answer all possible permutation questions.
166 *** This is a policy decision based on the fact that mtx is research
167 *** code that needs maximal flexibility at reasonable speed.<br><br>
168 ***
169 *** The -1th element of org_to_cur and cur_to_org are defined because
170 *** -1 is used all over mtx as an error return. It's easier to debug
171 *** things without the memory access errors that would happen if
172 *** -1 were not allocated or were part of memory in some other object.<br><br>
173 ***
174 *** Special note: The -1th element of nz_header arrays is NOT allocated.<br><br>
175 ***
176 *** Do not access the parity field of a slave matrix, refer to its master.
177 *** Conduct all permuting operations on the master.
178 **/
179 struct permutation_t {
180 int32 *org_to_cur; /**< org_to_cur[-1] = -1 */
181 int32 *cur_to_org; /**< cur_to_org[-1] = -1 */
182 boolean parity;
183 };
184
185 struct permutations_t {
186 struct permutation_t row;
187 struct permutation_t col;
188 int32 transpose;
189 };
190
191 /**<
192 *** There is a list of blocks associated with a matrix.
193 *** This is an artifact of POOR solver API design between
194 *** Peter Piela and Karl Westerberg. The blockwise decomposition
195 *** information properly belongs to a linear or nonlinear solver
196 *** and not to the mtx.
197 ***
198 *** @todo We intend to fix this soon.
199 **/
200 struct structural_data_t {
201 int32 symbolic_rank; /**< Symbolic rank (< 0 if invalid) */
202 int32 nblocks; /**< # blocks in matrix */
203 mtx_region_t *block; /**< Pointer to array of blocks */
204 };
205
206 /**<
207 *** capacity may be > order.
208 *** A matrix of capacity 0 doesn't have a mem_store_t yet and elements
209 *** cannot be queried about without a core dump.
210 **/
211 struct mtx_header {
212 int integrity; /**< Integrity integer */
213 int32 order; /**< Order of the matrix */
214 int32 capacity; /**< Capacity of all the arrays */
215 int32 nslaves; /**< number of slave matrices */
216 struct nz_headers_t hdr; /**< Non-zero headers of the matrix */
217 struct element_t *last_value; /**< value/set_value memory */
218 mem_store_t ms; /**< element cache memory */
219 struct permutations_t perm; /**< Permutation vectors */
220 struct structural_data_t *data; /**< Pointer to structural information */
221 mtx_matrix_t master; /**< the master of this mtx, if slave */
222 mtx_matrix_t *slaves; /**< array of slave matrices */
223 };
224
225 /**<
226 *** If you want to save a permutation for restoration, you
227 *** have to make a copy of that data, eh? Here's the place you
228 *** put it. Note that the block list should be disappearing from
229 *** from the structural data soon.
230 **/
231 struct mtx_block_perm_structure {
232 int integrity;
233 int32 order; /**< Order of the matrix */
234 int32 capacity; /**< Capacity of all the arrays */
235 mtx_matrix_t mtx; /**< matrix of origin */
236 struct permutations_t perm; /**< Permutation vectors */
237 struct structural_data_t *data; /**< Pointers to structural information */
238 };
239
240 #define OK ((int)201539237)
241 /**< Matrix integrity (ok) value. */
242 #define DESTROYED ((int)531503871)
243 /**< matrix integrity (destroyed) value. */
244
245 #define ZERO ((int32)0)
246 #define D_ZERO ((real64)0.0)
247 #define D_ONE ((real64)1.0)
248 /**< useful constants if your C compiler is not too bright about ANSI */
249
250 #define ISSLAVE(m) ((m)->master!=NULL)
251 /**< Returns 1 if m is a slave matrix, 0 if not. */
252
253 #define ordered3(a,b,c) ((a) <= (b) && (b) <= (c))
254 #define in_range(rng,ndx) ordered3((rng)->low,ndx,(rng)->high)
255 #define legal(mtx,ndx) ordered3(ZERO,ndx,(mtx)->order-1)
256 /**<
257 *** Boolean operators to compare a row or column
258 *** index with some specified range or the maximum
259 *** range of the matrix in which it is used.
260 **/
261
262 #define fast_in_range(l,h,i) ( ordered3(l,i,h) )
263 #define not_in_range(l,h,i) ( (i)<(l) || (i)>(h) )
264 /**<
265 *** Boolean operators to compare 3 integers.
266 *** l <= h must be TRUE or these will lie. In many cases,
267 *** this condition can (or should) be met before in_range
268 *** is called. Sometimes these are not faster since the lo,hi vals cost.
269 *** In particular, queries like next_col do not profit while calls
270 *** which must traverse an entire row/col do.
271 *** Gains in cycle count on dec alphas+cc are about 10% per function,
272 *** but the gains in time are more like 1%, so alpha pixie is lying a little.
273 *** For compilers which are not as clever as Decs, (gcc, sun acc) the
274 *** gains should be much more visible. (some do not realize rng->low
275 *** is invariant even with -O.)
276 *** Note that these are 'loose' comparisons if !(l<=h)
277 **/
278
279 #define zero(ptr,nelts,type) \
280 mem_zero_byte_cast((ptr),0,(nelts)*sizeof(type))
281 /**<
282 *** Zeros a vector of specified length and type.
283 *** It is inefficient to use, however, if you know the type
284 *** is one of the basic types (int,double,ptr,char)
285 **/
286
287
288 /* ************************************************************************ *\
289 Private check routines
290 \* ************************************************************************ */
291 extern int super_check_matrix(mtx_matrix_t mtx);
292 /**<
293 *** After somevery extensive checking, returns an error count.
294 *** More or less assume MTX_DEBUG is TRUE, and that is the only
295 *** condition under which this should be called.
296 **/
297
298 /* ************************************************************************ *\
299 Element CREATE/find routines. Please try to confine use of these to
300 mtx_basic.c as much as possible.
301 Use of find should be avoided at all costs, and in particular
302 absolutely noone outside mtx should put their fingers on elements.
303
304 These functions are not exported to generic users because they are
305 on the critical path and we cannot afford the sanity checking required.
306 They should only be called in contexts where the arguments are
307 guaranteed valid.
308 \* ************************************************************************ */
309
310 struct element_t *mtx_find_element(mtx_matrix_t mtx,
311 int32 org_row,
312 int32 org_col);
313 /**<
314 *** Searches for a given element of the matrix and returns a pointer to it
315 *** if it exists, or NULL if it doesn't exist.
316 *** It is *ASSUMED* that org_row
317 *** and org_col are legal indices. May crash if they are not.
318 **/
319
320 struct element_t *mtx_create_element(mtx_matrix_t mtx,
321 int32 org_row,
322 int32 org_col);
323 /**<
324 *** Creates the given element and returns a pointer to it. The value is
325 *** initially zero.
326 *** It is *ASSUMED* that org_row
327 *** and org_col are legal indices. May crash if they are not.
328 *** If mtx_DEBUG is TRUE, then we will whine if the element already
329 *** exists, but go ahead and create it anyway.
330 **/
331
332 struct element_t *mtx_create_element_value(mtx_matrix_t mtx,
333 int32 org_row,
334 int32 org_col,
335 real64 val);
336 /**<
337 *** Creates the given element and returns a pointer to it. The value is
338 *** initialzed to val.
339 *** It is *ASSUMED* that org_row
340 *** and org_col are legal indices. May crash if they are not.
341 *** If mtx_DEBUG is TRUE, then we will whine if the element already
342 *** exists, but go ahead and create it anyway.
343 **/
344
345 /* ************************************************************************ *\
346 Element list traversals. No linear algebra programmer with an ounce of
347 intelligence would ever need to use these in critical path functions.
348 \* ************************************************************************ */
349 extern struct element_t *mtx_next_col(register struct element_t *elt,
350 mtx_range_t *rng,
351 int32 *tocur);
352 /**<
353 *** Returns the next element after elt that is in the range
354 *** rng according to the permutation vector tocur given. May return NULL.
355 **/
356
357 extern struct element_t *mtx_next_row(register struct element_t *elt,
358 mtx_range_t *rng,
359 int32 *tocur);
360 /**<
361 *** Returns the next element after elt that is in the range
362 *** rng according to the permutation vector tocur given. May return NULL.
363 **/
364
365 /* ************************************************************************ *\
366 Permutation memory management.
367 \* ************************************************************************ */
368 extern int32 *mtx_alloc_perm(int32 cap);
369 /**<
370 *** Allocates a permutation vector. The user need
371 *** not concern himself with the -1st element, which does exist.
372 **/
373
374 extern void mtx_copy_perm(int32 *tarperm, int32 *srcperm, int32 cap);
375 /**<
376 *** Copies srcperm to tarperm given the capacity of srcperm.
377 *** If tarperm was obtained from alloc_perm(), the -1 has already been copied.
378 **/
379
380 extern void mtx_free_perm(int32 *perm);
381 /**<
382 *** Frees resources used by a permutation vector.
383 **/
384
385 /* ************************************************************************ *\
386 It is advantageous in an interactive system to introduce reusable
387 memory and monitor its integrity rather than to repeatedly allocate
388 and zero it. The following code accomplishes this for mtx.
389 A null_vector is an array of objects (size s, length n) with value 0.
390 This sort of memory management is needed because there is always the chance
391 that a floating point exception could cause premature return of an mtx
392 client. This way we have a safe place to store pointers to the memory
393 even if the user's algorithm loses them.
394 \* ************************************************************************ */
395
396 struct reusable_data_vector {
397 void *arr; /**< pointer to array of objects size entrysize */
398 int capacity; /**< number of object slots in array */
399 size_t entry_size; /**< size of slots */
400 int last_line; /**< line most recently associated with this structure,
401 should be 0 if the array is not in use. */
402 };
403
404 extern struct reusable_data_vector
405 g_mtx_null_index_data, /**< bunch of int32 */
406 g_mtx_null_sum_data, /**< bunch of mtx_value_t */
407 g_mtx_null_mark_data, /**< bunch of char */
408 g_mtx_null_vector_data, /**< bunch of element pointers */
409 g_mtx_null_col_vector_data, /**< bunch of element pointers */
410 g_mtx_null_row_vector_data; /**< bunch of element pointers */
411
412 /* OLD GROUP COMMENTS */
413 /*
414 *** vec = mtx_null_vector(nptrs);
415 *** vec = mtx_null_col_vector(nptrs);
416 *** vec = mtx_null_row_vector(nptrs);
417 *** marks = mtx_null_mark(nchar);
418 *** sums = mtx_null_sum(nnums);
419 *** indexes = mtx_null_index(ninds);
420 ***
421 *** struct element_t **vec;
422 *** char *marks;
423 *** real64 *sums;
424 *** int32 *indexes;
425 *** int32 nptrs, nchar, nnums, ninds;
426 ***
427 *** Returns an array of chars, elt pointers, indexes or numbers all NULL/0.
428 *** We need these a lot, but seldom simultaneously, and we know generally
429 *** how to rezero them when done with them.
430 *** These functions should not be
431 *** called again until the vector is re-NULLED and out of use.
432 *** If we detect a double call, we will whine loudly, renull
433 *** the array ourselves, and give it to you again.
434 *** To avoid whining, call the corresponding release functions
435 *** each time you are done with one of these vectors.
436 ***
437 *** In the event of insufficient memory (alloc failed) we will
438 *** return NULL. If we return NULL, you needn't call the release function.
439 ***
440 *** mtx_null_vector_release();
441 *** mtx_null_col_vector_release();
442 *** mtx_null_row_vector_release();
443 *** mtx_null_mark_release();
444 *** mtx_null_sum_release();
445 *** mtx_null_index_release();
446 ***
447 *** These are a memory reuse promoter.
448 *** Calling with cap==0 frees any memory in use.
449 *** Clientlists -- PLEASE KEEP THIS UP TO DATE --
450 *** mtx_null_vector:
451 *** expand_row,expand_col, mtx_assemble
452 *** mtx_householder_transform
453 *** mtx_null_row_vector:
454 *** expand_row_series
455 *** mtx_null_col_vector:
456 *** expand_col_series
457 *** mtx_null_mark:
458 *** mtx_householder_transform
459 *** mtx_null_sum:
460 *** mtx_householder_transform
461 *** mtx_null_index:
462 *** mtx_householder_transform
463 **/
464 #define mtx_null_vector(cap) \
465 ((struct element_t **)mtx_null_vector_f(cap,__LINE__,__FILE__, \
466 &g_mtx_null_vector_data,"null_vector"))
467 /**<
468 * Returns an array of elt pointers all NULL/0.
469 * This function should not be called again until the vector is
470 * re-NULLED and out of use. If we detect a double call, we will
471 * whine loudly, renull the array ourselves, and give it to you again.
472 * To avoid whining, call mtx_null_vector_release()
473 * each time you are done with the returned vector.<br><br>
474 *
475 * In the event of insufficient memory (alloc failed) we will
476 * return NULL. If we return NULL, you needn't call the release function.
477 * @param cap int32, the capacity of the matrix (0 to free memory).
478 * @return No return value.
479 * @see mtx_null_vector_f()
480 */
481 #define mtx_null_row_vector(cap) \
482 ((struct element_t **)mtx_null_vector_f(cap,__LINE__,__FILE__, \
483 &g_mtx_null_row_vector_data,\
484 "null_row_vector"))
485 /**<
486 * Returns an array of elt pointers all NULL/0.
487 * See mtx_null_vector() for more details.
488 * @param cap int32, the capacity of the matrix (0 to free memory).
489 * @return No return value.
490 * @see mtx_null_vector_f()
491 */
492 #define mtx_null_col_vector(cap) \
493 ((struct element_t **)mtx_null_vector_f(cap,__LINE__,__FILE__, \
494 &g_mtx_null_col_vector_data,\
495 "null_col_vector"))
496 /**<
497 * Returns an array of elt pointers all NULL/0.
498 * See mtx_null_vector() for more details.
499 * @param cap int32, the capacity of the matrix (0 to free memory).
500 * @return No return value.
501 * @see mtx_null_vector_f()
502 */
503 #define mtx_null_mark(cap) \
504 ((char *)mtx_null_vector_f(cap,__LINE__,__FILE__, \
505 &g_mtx_null_mark_data,"null_mark"))
506 /**<
507 * Returns an array of chars all NULL/0.
508 * This function should not be called again until the vector is
509 * re-NULLED and out of use. If we detect a double call, we will
510 * whine loudly, renull the array ourselves, and give it to you again.
511 * To avoid whining, call mtx_null_mark_release()
512 * each time you are done with the returned vector.<br><br>
513 *
514 * In the event of insufficient memory (alloc failed) we will
515 * return NULL. If we return NULL, you needn't call the release function.
516 * @param cap int32, the capacity of the array (0 to free memory).
517 * @return No return value.
518 * @see mtx_null_vector_f()
519 */
520 #define mtx_null_sum(cap) \
521 ((real64 *)mtx_null_vector_f(cap,__LINE__,__FILE__, \
522 &g_mtx_null_sum_data,"null_sum"))
523 /**<
524 * Returns an array of real64 numbers all NULL/0.
525 * This function should not be called again until the vector is
526 * re-NULLED and out of use. If we detect a double call, we will
527 * whine loudly, renull the array ourselves, and give it to you again.
528 * To avoid whining, call mtx_null_sum_release()
529 * each time you are done with the returned array.<br><br>
530 *
531 * In the event of insufficient memory (alloc failed) we will
532 * return NULL. If we return NULL, you needn't call the release function.
533 * @param cap int32, the capacity of the array (0 to free memory).
534 * @return No return value.
535 * @see mtx_null_vector_f()
536 */
537 #define mtx_null_index(cap) \
538 ((int32 *)mtx_null_vector_f(cap,__LINE__,__FILE__, \
539 &g_mtx_null_index_data,"null_index"))
540
541 /**<
542 * Returns an array of int32 indexes all NULL/0.
543 * This function should not be called again until the vector is
544 * re-NULLED and out of use. If we detect a double call, we will
545 * whine loudly, renull the array ourselves, and give it to you again.
546 * To avoid whining, call mtx_null_index_release()
547 * each time you are done with the returned array.<br><br>
548 *
549 * In the event of insufficient memory (alloc failed) we will
550 * return NULL. If we return NULL, you needn't call the release function.
551 * @param cap int32, the capacity of the array (0 to free memory).
552 * @return No return value.
553 * @see mtx_null_vector_f()
554 */
555 #define mtx_null_vector_release() \
556 mtx_null_vector_release_f(__LINE__,__FILE__, \
557 &g_mtx_null_vector_data,"null_vector")
558 /**<
559 * Marks a vector as not in use, or whines if it wasn't.
560 * @param None.
561 * @return No return value.
562 * @see mtx_null_vector_release_f()
563 */
564 #define mtx_null_col_vector_release() \
565 mtx_null_vector_release_f(__LINE__,__FILE__, \
566 &g_mtx_null_col_vector_data,"null_col_vector")
567 /**<
568 * Marks a vector as not in use, or whines if it wasn't.
569 * @param None.
570 * @return No return value.
571 * @see mtx_null_vector_release_f()
572 */
573 #define mtx_null_row_vector_release() \
574 mtx_null_vector_release_f(__LINE__,__FILE__, \
575 &g_mtx_null_row_vector_data,"null_row_vector")
576 /**<
577 * Marks a vector as not in use, or whines if it wasn't.
578 * @param None.
579 * @return No return value.
580 * @see mtx_null_vector_release_f()
581 */
582 #define mtx_null_mark_release() \
583 mtx_null_vector_release_f(__LINE__,__FILE__, \
584 &g_mtx_null_mark_data,"null_mark")
585 /**<
586 * Marks a char array as not in use, or whines if it wasn't.
587 * @param None.
588 * @return No return value.
589 * @see mtx_null_vector_release_f()
590 */
591 #define mtx_null_sum_release() \
592 mtx_null_vector_release_f(__LINE__,__FILE__, \
593 &g_mtx_null_sum_data,"null_sum")
594 /**<
595 * Marks a number array as not in use, or whines if it wasn't.
596 * @param None.
597 * @return No return value.
598 * @see mtx_null_vector_release_f()
599 */
600 #define mtx_null_index_release() \
601 mtx_null_vector_release_f(__LINE__,__FILE__, \
602 &g_mtx_null_index_data,"null_index")
603 /**<
604 * Marks an index array as not in use, or whines if it wasn't.
605 * @param None.
606 * @return No return value.
607 * @see mtx_null_vector_release_f()
608 */
609
610 extern void *mtx_null_vector_f(int32 cap, int line, CONST char *file,
611 struct reusable_data_vector *ptr, char *fn);
612 /**<
613 *** Implementation function for macros generating vectors of NULL
614 *** elements. This includes:
615 *** - mtx_null_vector()
616 *** - mtx_null_col_vector()
617 *** - mtx_null_row_vector()
618 *** - mtx_null_mark()
619 *** - mtx_null_sum()
620 *** - mtx_null_index()
621 ***
622 *** Do not call this function directly - use the appropriate macro
623 *** instead.
624 *** Returns a pointer to cap*ptr->entry_size bytes, which must be cast.
625 *** The memory pointed at is believed to be zero, and will be if the
626 *** user is properly rezeroing the vector before it is released.
627 *** If insufficient memory is available, this whines and returns NULL.
628 *** Calling this with cap==0 causes the reused memory to be deallocated and
629 *** returns NULL.
630 **/
631
632 extern void mtx_null_vector_release_f(int line,
633 CONST char *file,
634 struct reusable_data_vector *ptr,
635 char *fn);
636 /**<
637 *** Implementation function for macros releasing reusable vectors.
638 *** This includes:
639 *** - mtx_null_vector_release()
640 *** - mtx_null_col_vector_release()
641 *** - mtx_null_row_vector_release()
642 *** - mtx_null_mark_release()
643 *** - mtx_null_sum_release()
644 *** - mtx_null_index_release()
645 ***
646 *** Do not call this function directly - use the appropriate macro
647 *** instead.
648 *** Marks a vector as not in use, or whines if it wasn't.
649 *** Does no other checking. Uses line, file and fn in error reporting.
650 **/
651
652 extern void mtx_reset_null_vectors(void);
653 /**<
654 *** This resets the reusable arrays of zeroes to zero in the event
655 *** that they may have been corrupted.
656 **/
657
658 /*
659 * INTERNAL element vector operations of some utility.
660 */
661
662 extern struct element_t **mtx_expand_row(mtx_matrix_t mtx, int32 orgrow);
663 /**<
664 *** Expands the given row into an array of pointers, indexed on original
665 *** col number. The array is obtained from mtx_null_vector().
666 *** Be sure to call mtx_null_vector_release() when done with the vector and
667 *** you have rezeroed it.
668 *** You cannot call this twice without releasing first or call
669 *** mtx_expand_col().
670 **/
671
672 extern struct element_t **mtx_expand_col(mtx_matrix_t mtx, int32 orgcol);
673 /**<
674 *** Expands the given col into an array of pointers, indexed on original
675 *** row number. The array is obtained from mtx_null_vector().
676 *** Be sure to call mtx_null_vector_release() when done with the vector and
677 *** you have rezeroed it.
678 *** You cannot call this twice without releasing first or call
679 *** mtx_expand_row().
680 **/
681
682 extern void mtx_renull_using_row(mtx_matrix_t mtx,
683 int32 orgrow,
684 struct element_t **arr);
685 /**<
686 *** Makes arr NULLed again, assuming that the only non-NULL elements
687 *** must correspond to original col numbers that exist in the given
688 *** orgrow.
689 **/
690
691 extern void mtx_renull_using_col(mtx_matrix_t mtx,
692 int32 orgcol,
693 struct element_t **arr);
694 /**<
695 *** Makes arr NULLed again, assuming that the only non-NULL elements
696 *** must correspond to original row numbers that exist in the given
697 *** orgcol.
698 **/
699
700 extern void mtx_renull_all(mtx_matrix_t mtx, struct element_t **arr);
701 /**<
702 *** Makes arr NULLed again, assuming it is size mtx->order.
703 **/
704
705 /** @} */
706
707 #endif /* __MTX_INTERNAL_USE_ONLY_H__ */
708 #endif /* none of your business if you aren't mtx_*.c */
709

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22