#include "espresso.h"
Go to the source code of this file.
Functions | |
static pcover | reduce_gasp (pcover F, pcover D) |
pcover | expand_gasp (INOUT pcover F, IN pcover D, IN pcover R, IN pcover Foriginal) |
void | expand1_gasp (pcover F, pcover D, pcover R, pcover Foriginal, int c1index, pcover *G) |
pcover | irred_gasp (pcover F, pcover D, pcover G) |
pcover | last_gasp (pcover F, pcover D, pcover R, cost_t *cost) |
pcover | super_gasp (pcover F, pcover D, pcover R, cost_t *cost) |
void expand1_gasp | ( | pcover | F, | |
pcover | D, | |||
pcover | R, | |||
pcover | Foriginal, | |||
int | c1index, | |||
pcover * | G | |||
) |
Definition at line 104 of file gasp.c.
00111 { 00112 register int c2index; 00113 register pcube p, last, c2under; 00114 pcube RAISE, FREESET, temp, *FD, c2essential; 00115 pcover F1; 00116 00117 if (debug & EXPAND1) { 00118 printf("\nEXPAND1_GASP: \t%s\n", pc1(GETSET(F, c1index))); 00119 } 00120 00121 RAISE = new_cube(); 00122 FREESET = new_cube(); 00123 temp = new_cube(); 00124 00125 /* Initialize the OFF-set */ 00126 R->active_count = R->count; 00127 foreach_set(R, last, p) { 00128 SET(p, ACTIVE); 00129 } 00130 /* Initialize the reduced ON-set, all nonprime cubes become active */ 00131 F->active_count = F->count; 00132 foreachi_set(F, c2index, c2under) { 00133 if (c1index == c2index || TESTP(c2under, PRIME)) { 00134 F->active_count--; 00135 RESET(c2under, ACTIVE); 00136 } else { 00137 SET(c2under, ACTIVE); 00138 } 00139 } 00140 00141 /* Initialize the raising and unassigned sets */ 00142 (void) set_copy(RAISE, GETSET(F, c1index)); 00143 (void) set_diff(FREESET, cube.fullset, RAISE); 00144 00145 /* Determine parts which must be lowered */ 00146 essen_parts(R, F, RAISE, FREESET); 00147 00148 /* Determine parts which can always be raised */ 00149 essen_raising(R, RAISE, FREESET); 00150 00151 /* See which, if any, of the reduced cubes we can cover */ 00152 foreachi_set(F, c2index, c2under) { 00153 if (TESTP(c2under, ACTIVE)) { 00154 /* See if this cube can be covered by an expansion */ 00155 if (setp_implies(c2under, RAISE) || 00156 feasibly_covered(R, c2under, RAISE, temp)) { 00157 00158 /* See if c1under can expanded to cover c2 reduced against 00159 * (F - c1) u c1under; if so, c2 can definitely be removed ! 00160 */ 00161 00162 /* Copy F and replace c1 with c1under */ 00163 F1 = sf_save(Foriginal); 00164 (void) set_copy(GETSET(F1, c1index), GETSET(F, c1index)); 00165 00166 /* Reduce c2 against ((F - c1) u c1under) */ 00167 FD = cube2list(F1, D); 00168 c2essential = reduce_cube(FD, GETSET(F1, c2index)); 00169 free_cubelist(FD); 00170 sf_free(F1); 00171 00172 /* See if c2essential is covered by an expansion of c1under */ 00173 if (feasibly_covered(R, c2essential, RAISE, temp)) { 00174 (void) set_or(temp, RAISE, c2essential); 00175 RESET(temp, PRIME); /* cube not prime */ 00176 *G = sf_addset(*G, temp); 00177 } 00178 set_free(c2essential); 00179 } 00180 } 00181 } 00182 00183 free_cube(RAISE); 00184 free_cube(FREESET); 00185 free_cube(temp); 00186 }
pcover expand_gasp | ( | INOUT pcover | F, | |
IN pcover | D, | |||
IN pcover | R, | |||
IN pcover | Foriginal | |||
) |
Definition at line 80 of file gasp.c.
00085 { 00086 int c1index; 00087 pcover G; 00088 00089 /* Try to expand each nonprime and noncovered cube */ 00090 G = new_cover(10); 00091 for(c1index = 0; c1index < F->count; c1index++) { 00092 expand1_gasp(F, D, R, Foriginal, c1index, &G); 00093 } 00094 G = sf_dupl(G); 00095 G = expand(G, R, /*nonsparse*/ FALSE); /* Make them prime ! */ 00096 return G; 00097 }
pcover irred_gasp | ( | pcover | F, | |
pcover | D, | |||
pcover | G | |||
) |
Definition at line 189 of file gasp.c.
00191 { 00192 if (G->count != 0) 00193 F = irredundant(sf_append(F, G), D); 00194 else 00195 free_cover(G); 00196 return F; 00197 }
pcover last_gasp | ( | pcover | F, | |
pcover | D, | |||
pcover | R, | |||
cost_t * | cost | |||
) |
Definition at line 201 of file gasp.c.
00204 { 00205 pcover G, G1; 00206 00207 EXECUTE(G = reduce_gasp(F, D), GREDUCE_TIME, G, *cost); 00208 EXECUTE(G1 = expand_gasp(G, D, R, F), GEXPAND_TIME, G1, *cost); 00209 free_cover(G); 00210 EXECUTE(F = irred_gasp(F, D, G1), GIRRED_TIME, F, *cost); 00211 return F; 00212 }
static pcover reduce_gasp | ( | pcover | F, | |
pcover | D | |||
) | [static] |
Definition at line 41 of file gasp.c.
00043 { 00044 pcube p, last, cunder, *FD; 00045 pcover G; 00046 00047 G = new_cover(F->count); 00048 FD = cube2list(F, D); 00049 00050 /* Reduce cubes of F without replacement */ 00051 foreach_set(F, last, p) { 00052 cunder = reduce_cube(FD, p); 00053 if (setp_empty(cunder)) { 00054 fatal("empty reduction in reduce_gasp, shouldn't happen"); 00055 } else if (setp_equal(cunder, p)) { 00056 SET(cunder, PRIME); /* just to make sure */ 00057 G = sf_addset(G, p); /* it did not reduce ... */ 00058 } else { 00059 RESET(cunder, PRIME); /* it reduced ... */ 00060 G = sf_addset(G, cunder); 00061 } 00062 if (debug & GASP) { 00063 printf("REDUCE_GASP: %s reduced to %s\n", pc1(p), pc2(cunder)); 00064 } 00065 free_cube(cunder); 00066 } 00067 00068 free_cubelist(FD); 00069 return G; 00070 }
pcover super_gasp | ( | pcover | F, | |
pcover | D, | |||
pcover | R, | |||
cost_t * | cost | |||
) |
Definition at line 216 of file gasp.c.
00219 { 00220 pcover G, G1; 00221 00222 EXECUTE(G = reduce_gasp(F, D), GREDUCE_TIME, G, *cost); 00223 EXECUTE(G1 = all_primes(G, R), GEXPAND_TIME, G1, *cost); 00224 free_cover(G); 00225 EXEC(G = sf_dupl(sf_append(F, G1)), "NEWPRIMES", G); 00226 EXECUTE(F = irredundant(G, D), IRRED_TIME, F, *cost); 00227 return F; 00228 }