34 #include <sys/types.h>
37 #include "quickhvolume.h"
38 #include "constants.h"
50 #warning TODO: There should be a better solution to the initUnion problem.
73 memcpy(&(dst->PS[0]), &(src->PS[0]), (src->n)*
sizeof(
point));
87 memcpy(dst, src, offsetof(
struct taskData, idx));
88 memcpy(&(dst->
idx[0]), &(src->
idx[0]), (src->n)*
sizeof(
int));
105 dst->
r[src->
idx[i]] += src->r[i];
110 void publish(
int jid,
jobData* jd)
117 printf(
"Ex[%d] = %1.10f\t", i, jd->
r[i]);
143 static void drop(
int* idx,
int* n,
int j);
150 static sureInline(
void) swapD(
double* r,
int n,
int j);
154 static sureInline(
void) swapD(
double* r,
int n,
int j)
163 static void drop(
int* idx,
int* n,
int j)
181 intercept(&p, &(d->o), &(jd->PS[d->
idx[0]]));
182 d->r[0] += HV(&(d->z), &p);
185 intercept(&p, &(d->o), &(jd->PS[d->
idx[0]]));
186 tp[0] = HV(&(d->z), &p);
188 intercept(&pp, &(d->o), &(jd->PS[d->
idx[1]]));
189 tp[1] = HV(&(d->z), &pp);
191 intercept(&p, &p, &pp);
192 tp[2] = HV(&(d->z), &p);
194 d->r[0] += tp[0] - tp[2];
195 d->r[1] += tp[1] - tp[2];
205 quickHVolumeR(b, d, jd);
238 intercept(&pp, &(d->o), &(jd->PS[d->
idx[i]]));
247 intercept(A[k+1], A[k], &(jd->PS[d->
idx[j]]));
261 intercept(&pp, &(d->o), &(jd->PS[d->
idx[i]]));
262 push(d->
idx[i], classify(&p, &pp), &(b->spt));
265 di =
newDivision(&(jd->PS[0]), &(d->o), &p, &(b->spt));
270 memcpy(ld.
idx, d->
idx, (d->n)*
sizeof(
int));
271 memcpy(ld.r, d->r, (d->n)*
sizeof(
double));
284 nidx =
next(di, &j, &(d->n));
285 memcpy(d->
idx, nidx, (d->n)*
sizeof(
int));
286 projectZero(&(d->z), &p, j, &(ld.z));
287 projectOne(&(d->o), &p, j, &(ld.o));
288 memset(d->r, 0,
sizeof(
double)*d->n);
295 ld.r[lidx[d->
idx[i]]] += d->r[i];
298 #warning DONE. Regrouping is OK.
305 memcpy(d->
idx, ld.
idx, (d->n)*
sizeof(
int));
306 memcpy(d->r, ld.r, (d->n)*
sizeof(
double));
#define objective(Z, A, O)
void freeDivision(division *d)
New divisions are created in the splitter object.
int * next(division d, int *hypoct, int *n)
division newDivision(point *PS, point *o, point *p, struct spData *sd)
This returns iterators for diferent type. WARNING, these objects are singleton, so new overwrites exi...
void initUnion(int n, struct unionData *ud)
This struct is public because of splitter. Do not use direct access.
void initSplitter(struct spData *sd)
void push(int idx, int tp, struct spData *sd)
A splitter for storing classified points. The splitter is an array that grows dinamically, when all points are inserted they are separeted into classes by sorting. Preferably count sort or hased count sort.
Structure for uniting two sets, without repetition.
Inclusion Exclusion Algorithm better than HSO for high d and small n.
Point is an array of coordinates, in a struct for simple and fast copy.
void destroySplitter(struct spData *sd)
double exInExClusion(point *zero, point *one, int n, int *idx, point *PS, double *exHV, struct iex *ax)