Beispiel #1
0
int sm_row_dominance(sm_matrix *A)
{
register sm_row *prow, *prow1;
register sm_col *pcol, *least_col;
register sm_element *p, *pnext;
int rowcnt;
rowcnt = A->nrows;
for(prow = A->first_row; prow != 0; prow = prow->next_row) {
least_col = ((( prow->first_col->col_num) >= 0 && ( prow->first_col->col_num) < (A)->cols_size) ? (A)->cols[ prow->first_col->col_num] : (sm_col *) 0);
for(p = prow->first_col->next_col; p != 0; p = p->next_col) {
pcol = ((( p->col_num) >= 0 && ( p->col_num) < (A)->cols_size) ? (A)->cols[ p->col_num] : (sm_col *) 0);
if (pcol->length < least_col->length) {
least_col = pcol;
}
}
for(p = least_col->first_row; p != 0; p = pnext) {
pnext = p->next_row;
prow1 = ((( p->row_num) >= 0 && ( p->row_num) < (A)->rows_size) ? (A)->rows[ p->row_num] : (sm_row *) 0);
if ((prow1->length > prow->length) ||
(prow1->length == prow->length && prow1->row_num > prow->row_num)) {
if (sm_row_contains(prow, prow1)) {
sm_delrow(A, prow1->row_num);
}
}
}
}
return rowcnt - A->nrows;
}
Beispiel #2
0
int
sm_row_dominance(sm_matrix *A)
{
  register sm_row *prow, *prow1;
  register sm_col *pcol, *least_col;
  register sm_element *p, *pnext;
  int rowcnt;

  rowcnt = A->nrows;

  /* Check each row against all other rows */
  for(prow = A->first_row; prow != 0; prow = prow->next_row) {

    /* Among all columns with a 1 in this row, choose smallest */
    least_col = sm_get_col(A, prow->first_col->col_num);
    for(p = prow->first_col->next_col; p != 0; p = p->next_col) {
      pcol = sm_get_col(A, p->col_num);
      if (pcol->length < least_col->length) {
        least_col = pcol;
      }
    }

    /* Only check for containment against rows in this column */
    for(p = least_col->first_row; p != 0; p = pnext) {
      pnext = p->next_row;

      prow1 = sm_get_row(A, p->row_num);
      if ((prow1->length > prow->length) ||
          (prow1->length == prow->length && 
           prow1->row_num > prow->row_num)) {
        if (sm_row_contains(prow, prow1)) {
          sm_delrow(A, prow1->row_num);
        }
      }
    }
  }

  return rowcnt - A->nrows;
}