#include "mincov_int.h"
Go to the source code of this file.
Functions | |
static int | visit_col () |
static void | copy_row (sm_matrix *A, sm_row *prow) |
static int | visit_row (sm_matrix *A, sm_row *prow, int *rows_visited, int *cols_visited) |
static int | visit_col (sm_matrix *A, sm_col *pcol, int *rows_visited, int *cols_visited) |
int | sm_block_partition (sm_matrix *A, sm_matrix **L, sm_matrix **R) |
Definition at line 85 of file part.c.
00088 { 00089 int cols_visited, rows_visited; 00090 register sm_row *prow; 00091 register sm_col *pcol; 00092 00093 /* Avoid the trivial case */ 00094 if (A->nrows == 0) { 00095 return 0; 00096 } 00097 00098 /* Reset the visited flags for each row and column */ 00099 for(prow = A->first_row; prow != 0; prow = prow->next_row) { 00100 prow->flag = 0; 00101 } 00102 for(pcol = A->first_col; pcol != 0; pcol = pcol->next_col) { 00103 pcol->flag = 0; 00104 } 00105 00106 cols_visited = rows_visited = 0; 00107 if (visit_row(A, A->first_row, &rows_visited, &cols_visited)) { 00108 /* we found all of the rows */ 00109 return 0; 00110 } else { 00111 *L = sm_alloc(); 00112 *R = sm_alloc(); 00113 for(prow = A->first_row; prow != 0; prow = prow->next_row) { 00114 if (prow->flag) { 00115 copy_row(*L, prow); 00116 } else { 00117 copy_row(*R, prow); 00118 } 00119 } 00120 return 1; 00121 } 00122 }
static int visit_col | ( | sm_matrix * | A, | |
sm_col * | pcol, | |||
int * | rows_visited, | |||
int * | cols_visited | |||
) | [static] |
Definition at line 57 of file part.c.
00062 { 00063 sm_element *p; 00064 sm_row *prow; 00065 00066 if (! pcol->flag) { 00067 pcol->flag = 1; 00068 (*cols_visited)++; 00069 if (*cols_visited == A->ncols) { 00070 return 1; 00071 } 00072 for(p = pcol->first_row; p != 0; p = p->next_row) { 00073 prow = sm_get_row(A, p->row_num); 00074 if (! prow->flag) { 00075 if (visit_row(A, prow, rows_visited, cols_visited)) { 00076 return 1; 00077 } 00078 } 00079 } 00080 } 00081 return 0; 00082 }
static int visit_col | ( | ) | [static] |
static int visit_row | ( | sm_matrix * | A, | |
sm_row * | prow, | |||
int * | rows_visited, | |||
int * | cols_visited | |||
) | [static] |
Definition at line 28 of file part.c.
00033 { 00034 sm_element *p; 00035 sm_col *pcol; 00036 00037 if (! prow->flag) { 00038 prow->flag = 1; 00039 (*rows_visited)++; 00040 if (*rows_visited == A->nrows) { 00041 return 1; 00042 } 00043 for(p = prow->first_col; p != 0; p = p->next_col) { 00044 pcol = sm_get_col(A, p->col_num); 00045 if (! pcol->flag) { 00046 if (visit_col(A, pcol, rows_visited, cols_visited)) { 00047 return 1; 00048 } 00049 } 00050 } 00051 } 00052 return 0; 00053 }