abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
sparse.h
Go to the documentation of this file.
1 /*
2  * Revision Control Information
3  *
4  * $Source$
5  * $Author$
6  * $Revision$
7  * $Date$
8  *
9  */
10 #ifndef ABC__misc__espresso__sparse_h
11 #define ABC__misc__espresso__sparse_h
12 
13 
15 
16 
17 /*
18  * sparse.h -- sparse matrix package header file
19  */
20 
22 typedef struct sm_row_struct sm_row;
23 typedef struct sm_col_struct sm_col;
24 typedef struct sm_matrix_struct sm_matrix;
25 
26 
27 /*
28  * sparse matrix element
29  */
31  int row_num; /* row number of this element */
32  int col_num; /* column number of this element */
33  sm_element *next_row; /* next row in this column */
34  sm_element *prev_row; /* previous row in this column */
35  sm_element *next_col; /* next column in this row */
36  sm_element *prev_col; /* previous column in this row */
37  char *user_word; /* user-defined word */
38 };
39 
40 
41 /*
42  * row header
43  */
44 struct sm_row_struct {
45  int row_num; /* the row number */
46  int length; /* number of elements in this row */
47  int flag; /* user-defined word */
48  sm_element *first_col; /* first element in this row */
49  sm_element *last_col; /* last element in this row */
50  sm_row *next_row; /* next row (in sm_matrix linked list) */
51  sm_row *prev_row; /* previous row (in sm_matrix linked list) */
52  char *user_word; /* user-defined word */
53 };
54 
55 
56 /*
57  * column header
58  */
59 struct sm_col_struct {
60  int col_num; /* the column number */
61  int length; /* number of elements in this column */
62  int flag; /* user-defined word */
63  sm_element *first_row; /* first element in this column */
64  sm_element *last_row; /* last element in this column */
65  sm_col *next_col; /* next column (in sm_matrix linked list) */
66  sm_col *prev_col; /* prev column (in sm_matrix linked list) */
67  char *user_word; /* user-defined word */
68 };
69 
70 
71 /*
72  * A sparse matrix
73  */
75  sm_row **rows; /* pointer to row headers (by row #) */
76  int rows_size; /* alloc'ed size of above array */
77  sm_col **cols; /* pointer to column headers (by col #) */
78  int cols_size; /* alloc'ed size of above array */
79  sm_row *first_row; /* first row (linked list of all rows) */
80  sm_row *last_row; /* last row (linked list of all rows) */
81  int nrows; /* number of rows */
82  sm_col *first_col; /* first column (linked list of columns) */
83  sm_col *last_col; /* last column (linked list of columns) */
84  int ncols; /* number of columns */
85  char *user_word; /* user-defined word */
86 };
87 
88 
89 #define sm_get_col(A, colnum) \
90  (((colnum) >= 0 && (colnum) < (A)->cols_size) ? \
91  (A)->cols[colnum] : (sm_col *) 0)
92 
93 #define sm_get_row(A, rownum) \
94  (((rownum) >= 0 && (rownum) < (A)->rows_size) ? \
95  (A)->rows[rownum] : (sm_row *) 0)
96 
97 #define sm_foreach_row(A, prow) \
98  for(prow = A->first_row; prow != 0; prow = prow->next_row)
99 
100 #define sm_foreach_col(A, pcol) \
101  for(pcol = A->first_col; pcol != 0; pcol = pcol->next_col)
102 
103 #define sm_foreach_row_element(prow, p) \
104  for(p = prow->first_col; p != 0; p = p->next_col)
105 
106 #define sm_foreach_col_element(pcol, p) \
107  for(p = pcol->first_row; p != 0; p = p->next_row)
108 
109 #define sm_put(x, val) \
110  (x->user_word = (char *) val)
111 
112 #define sm_get(type, x) \
113  ((type) (x->user_word))
114 
115 extern sm_matrix *sm_alloc(), *sm_alloc_size(), *sm_dup();
116 extern void sm_free(), sm_delrow(), sm_delcol(), sm_resize();
117 extern void sm_write(), sm_print(), sm_dump(), sm_cleanup();
118 extern void sm_copy_row(), sm_copy_col();
119 extern void sm_remove(), sm_remove_element();
120 extern sm_element *sm_insert(), *sm_find();
121 extern sm_row *sm_longest_row();
122 extern sm_col *sm_longest_col();
123 extern int sm_read(), sm_read_compressed();
124 
125 extern sm_row *sm_row_alloc(), *sm_row_dup(), *sm_row_and();
126 extern void sm_row_free(), sm_row_remove(), sm_row_print();
127 extern sm_element *sm_row_insert(), *sm_row_find();
128 extern int sm_row_contains(), sm_row_intersects();
129 extern int sm_row_compare(), sm_row_hash();
130 
131 extern sm_col *sm_col_alloc(), *sm_col_dup(), *sm_col_and();
132 extern void sm_col_free(), sm_col_remove(), sm_col_print();
133 extern sm_element *sm_col_insert(), *sm_col_find();
134 extern int sm_col_contains(), sm_col_intersects();
135 extern int sm_col_compare(), sm_col_hash();
136 
138 
139 
140 
142 
143 #endif
sm_col * sm_col_alloc()
int length
Definition: sparse.h:46
sm_col ** cols
Definition: sparse.h:77
sm_row * next_row
Definition: sparse.h:50
sm_col * sm_col_and()
sm_element * sm_find()
int sm_col_intersects()
int sm_read()
char * user_word
Definition: sparse.h:37
void sm_copy_col()
char * user_word
Definition: sparse.h:85
void sm_row_free()
int sm_col_dominance()
sm_row * prev_row
Definition: sparse.h:51
sm_row * sm_row_dup()
sm_col * first_col
Definition: sparse.h:82
sm_element * next_row
Definition: sparse.h:33
void sm_free()
void sm_dump()
sm_col * next_col
Definition: sparse.h:65
sm_col * last_col
Definition: sparse.h:83
sm_element * last_col
Definition: sparse.h:49
sm_element * last_row
Definition: sparse.h:64
int sm_row_contains()
sm_row * sm_row_and()
int sm_block_partition()
void sm_print()
sm_element * prev_row
Definition: sparse.h:34
int length
Definition: sparse.h:61
void sm_remove()
void sm_copy_row()
void sm_col_free()
sm_element * next_col
Definition: sparse.h:35
int sm_col_contains()
char * user_word
Definition: sparse.h:67
sm_matrix * sm_alloc()
sm_element * sm_col_insert()
sm_element * sm_col_find()
sm_col * sm_col_dup()
int row_num
Definition: sparse.h:45
sm_element * prev_col
Definition: sparse.h:36
sm_matrix * sm_dup()
int flag
Definition: sparse.h:47
sm_element * first_row
Definition: sparse.h:63
int sm_row_hash()
int flag
Definition: sparse.h:62
void sm_write()
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
Definition: abc_global.h:105
int sm_col_compare()
void sm_row_print()
void sm_resize()
void sm_remove_element()
void sm_delrow()
sm_matrix * sm_alloc_size()
#define ABC_NAMESPACE_HEADER_END
Definition: abc_global.h:106
sm_element * sm_insert()
int col_num
Definition: sparse.h:60
sm_element * sm_row_insert()
void sm_col_remove()
sm_row * first_row
Definition: sparse.h:79
void sm_col_print()
sm_row * sm_row_alloc()
typedefABC_NAMESPACE_HEADER_START struct sm_element_struct sm_element
Definition: sparse.h:21
char * user_word
Definition: sparse.h:52
sm_row * sm_longest_row()
void sm_delcol()
void sm_row_remove()
int sm_row_intersects()
sm_col * prev_col
Definition: sparse.h:66
int sm_read_compressed()
void sm_cleanup()
Definition: matrix.c:552
int sm_row_compare()
sm_row * last_row
Definition: sparse.h:80
sm_col * sm_longest_col()
int sm_col_hash()
int sm_row_dominance()
sm_row ** rows
Definition: sparse.h:75
sm_element * sm_row_find()
sm_element * first_col
Definition: sparse.h:48