33 #include "quickhvolume.h"
66 static double quickExHVolumeR(
point* zero,
73 static double WrappedExQuickHVolumeR(
point* z,
82 static double quickExHVolumeR(
point* z,
92 WrappedQuickExHVolumeR(z, o, n, idx, PS, exHV);
97 static double WrappedQuickExHVolumeR(
point* z,
132 intercept(&pp, A[k], &(PS[idx[i]]));
142 intercept(A[k+1], A[k], &(PS[idx[j]]));
153 intercept(&pp, o, &(PS[idx[i]]));
154 push(idx[i], classify(&p, &pp));
162 idx =
next(d, &j, &n);
163 projectZero(&newz, &p, j, z);
164 projectOne(&newo, &p, j, o);
172 intercept(&pp, &newo, &(PS[idx[0]]));
173 tp[0] = HV(&newz, &pp);
175 exHV[idx[0]] += tp[0];
179 intercept(&pp, &newo, &(PS[idx[0]]));
180 tp[0] = HV(&newz, &pp);
183 intercept(&ppp, &newo, &(PS[idx[1]]));
184 tp[1] = HV(&newz, &ppp);
187 intercept(&pp, &pp, &ppp);
188 tp[2] = HV(&newz, &pp);
191 exHV[idx[0]] += tp[0] - tp[2];
192 exHV[idx[1]] += tp[1] - tp[2];
197 hv +=
exHSO(&newz, &newo, n, idx, PS, exHV);
208 hv += quickExHVolumeR(&newz, &newo, n, idx, PS, exHV);
219 double quickExHVolume(
int n,
point* PS,
double* exHV)
229 idx = (
int*) malloc(n*
sizeof(
int));
239 res = quickExHVolumeR(&
cZero, &
cOne, n, idx, PS, exHV);
244 printf(
"%d %d %f\n", n,
D, tops);
double exHSO(point *zero, point *one, int n, int *idx, point *PS, double *exHV)
double exInExClusion(point *zero, point *one, int n, int *idx, point *PS, double *exHV)
#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)
This returns iterators for diferent type. WARNING, these objects are singleton, so new overwrites exi...
This struct is public because of splitter. Do not use direct access.
void push(int idx, int tp)
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.
division newDivision(point *PS, point *o, point *p)
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.