Skip to content

Commit

Permalink
optimised for m=0
Browse files Browse the repository at this point in the history
In this case no checking of solution minimality is needed.
This makes a huge difference, like 1000+-fold speedup.
  • Loading branch information
dimpase committed Mar 19, 2015
1 parent eae88bb commit fd40018
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
## 'make allclean' deletes also *.exe files.
##
CC=gcc
CFLAGS=-O -g -pg
CFLAGS=-O -g # -pg
EXT=.exe

all : oneeq systeq
Expand Down
6 changes: 3 additions & 3 deletions hb.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ int hb(eq *e, int **sols, int savesols) /* return number elts in the basis; */
if (!p[lp].node && lp) /* found a solution */
{
ntests++;
if (ismsol(e,sol,sol_t,p_t,mark_t))
if (e->m==0 || ismsol(e,sol,sol_t,p_t,mark_t))
saves(savesols, &solmax, lsol, ++nsol, sol, sols);
goto getnext;
}
Expand All @@ -84,7 +84,7 @@ int hb(eq *e, int **sols, int savesols) /* return number elts in the basis; */
p[lp+1].node=p[lp].node+sign*x[w];
mark[p[++lp].node]=1;
ntests++;
if (!ismsol(e,sol,sol_t,p_t,mark_t)) goto getnext;
if (e->m>0 && !ismsol(e,sol,sol_t,p_t,mark_t)) goto getnext;
}
else
getnext:
Expand All @@ -106,7 +106,7 @@ int hb(eq *e, int **sols, int savesols) /* return number elts in the basis; */
p[lp].node=p[lp-1].node+sign*x[w];
mark[p[lp].node]=1;
ntests++;
if (!ismsol(e,sol,sol_t,p_t,mark_t)) goto getnext;
if (e->m>0 && !ismsol(e,sol,sol_t,p_t,mark_t)) goto getnext;
goto cont;
}
else
Expand Down
4 changes: 2 additions & 2 deletions p39
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
1
3
1
37
0
37
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 35 37
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37

0 comments on commit fd40018

Please sign in to comment.