aboutsummaryrefslogtreecommitdiff
path: root/src/benchmarks/espresso/dominate.c
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2019-08-24 17:58:18 +0200
committerFlorian Fischer <florian.fl.fischer@fau.de>2019-08-24 17:58:18 +0200
commitde7208a60eca11aa8014e3a9b698e092322aea88 (patch)
tree13323f839f63d0d363517af81de317f0ec17a415 /src/benchmarks/espresso/dominate.c
parent77ac9ce0a5c55d4f79f8fb8f7daa59ddb53cb507 (diff)
downloadallocbench-de7208a60eca11aa8014e3a9b698e092322aea88.tar.gz
allocbench-de7208a60eca11aa8014e3a9b698e092322aea88.zip
add espresso benchmark
Diffstat (limited to 'src/benchmarks/espresso/dominate.c')
-rw-r--r--src/benchmarks/espresso/dominate.c90
1 files changed, 90 insertions, 0 deletions
diff --git a/src/benchmarks/espresso/dominate.c b/src/benchmarks/espresso/dominate.c
new file mode 100644
index 0000000..882a43c
--- /dev/null
+++ b/src/benchmarks/espresso/dominate.c
@@ -0,0 +1,90 @@
+#include "espresso.h"
+#include "mincov_int.h"
+
+
+int
+sm_row_dominance(A)
+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;
+}
+
+int
+sm_col_dominance(A, weight)
+sm_matrix *A;
+int *weight;
+{
+ register sm_row *prow;
+ register sm_col *pcol, *pcol1;
+ register sm_element *p;
+ sm_row *least_row;
+ sm_col *next_col;
+ int colcnt;
+
+ colcnt = A->ncols;
+
+ /* Check each column against all other columns */
+ for(pcol = A->first_col; pcol != 0; pcol = next_col) {
+ next_col = pcol->next_col;
+
+ /* Check all rows to find the one with fewest elements */
+ least_row = sm_get_row(A, pcol->first_row->row_num);
+ for(p = pcol->first_row->next_row; p != 0; p = p->next_row) {
+ prow = sm_get_row(A, p->row_num);
+ if (prow->length < least_row->length) {
+ least_row = prow;
+ }
+ }
+
+ /* Only check for containment against columns in this row */
+ for(p = least_row->first_col; p != 0; p = p->next_col) {
+ pcol1 = sm_get_col(A, p->col_num);
+ if (weight != 0 && weight[pcol1->col_num] > weight[pcol->col_num])
+ continue;
+ if ((pcol1->length > pcol->length) ||
+ (pcol1->length == pcol->length &&
+ pcol1->col_num > pcol->col_num)) {
+ if (sm_col_contains(pcol, pcol1)) {
+ sm_delcol(A, pcol->col_num);
+ break;
+ }
+ }
+ }
+ }
+
+ return colcnt - A->ncols;
+}