"Fossies" - the Fresh Open Source Software Archive

Member "heaplayers-351/benchmarks/espresso/sparse.h" (19 Sep 2003, 4137 Bytes) of package /linux/misc/old/heaplayers_3_5_1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "sparse.h" see the Fossies "Dox" file reference documentation.

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