dio | next_combo_b | next_combo_ss | |
next_combo_a | next_combo_c | p_ac_basis |
int dio(int ab[MAX_COEF], int m, int n, int constraints[MAX_COEF], int basis[MAX_BASIS][MAX_COEF], int *num_basis);This routine generates the basis of solutions to the homogeneous linear diophantine equation given by ab, m, n. It uses Huet's algorithm (Information Processing Letters 7(3) 1978).
The equation has the form a1x1 + ... + amxm = b1y1 + ... + bnyn.
int next_combo_a(int length, int basis[MAX_BASIS][MAX_COEF], int num_basis, int constraints[MAX_COEF], int combo[MAX_BASIS], int sum[MAX_COEF], int start_flag);This routine gets the first or next appropriate subset of the basis of solutions. "Appropriate" means that each variable gets instantiated to something, and there are no top-level rigid symbol clashes. I think of this as a potential unifier, because he caller still has to worry about recursive unification of subterms.
int next_combo_b(int length, int basis[MAX_BASIS][MAX_COEF], int num_basis, int constraints[MAX_COEF], int combo[MAX_BASIS], int sum[MAX_COEF], int start_flag);This routine gets the first or next appropriate subset of the basis of solutions. This implements algorithm B. See next_combo_a() for a description.
int next_combo_c(int length, int basis[MAX_BASIS][MAX_COEF], int num_basis, int constraints[MAX_COEF], int combo[MAX_BASIS], int sum[MAX_COEF], int start_flag);This routine gets the first or next appropriate subset of the basis of solutions. This implements algorithm C. See next_combo_a() for a description.
int next_combo_ss(int length, int basis[MAX_BASIS][MAX_COEF], int num_basis, int constraints[MAX_COEF], int combo[MAX_BASIS], int sum[MAX_COEF], int start_flag, int combos[MAX_COMBOS][MAX_BASIS], int *np, int ss_parm);This routine gets the first or next appropriate subset of the basis of solutions, subject to the "supserset restriction". It appears to work like the other next_combo routines, but it is not really incremental. To implement the superset restriction, we collect, in combos[] during the first call, up to MAX_COMBOS subsets satisfying the restriction, then give them out in the subsequent calls. The first bunch of parameters are the same as for the other next_combo routines.
void p_ac_basis(int basis[MAX_BASIS][MAX_COEF], int num_basis, int m, int n);This routine prints (to stdout) a basis of solutions.
#define MAX_COEF 250 /* total # of coef. from both sides */ #define MAX_BASIS 100 /* must be <= MAX_VARS, because rows are indexed */ #define MAX_COMBOS 200 /* for superset-restricted AC unif. */
The file dioph.c has a main() program, and it can be compiled and linked by itself for testing. The command for doing so is "gcc -DSOLO dioph.c".