22 #include <sys/resource.h> 29 static const int INT_BITS = (8 *
sizeof(int));
31 static void divide_cell_and_objects(
struct CELL *oya);
32 static void set_direct_adjacency(
struct CELL *cell);
33 static void undo_divide_cell(
struct CELL *cell);
34 static void set_cell_range(
struct CELL *cell,
struct CELL *oya);
35 static void make_clusters(
void);
36 static void finish_clusters(
void);
38 static void calculate_cell_path(
unsigned int *,
struct CELL *,
40 static void merge_clusters(
struct CLUSTER *x0,
struct CLUSTER *y0);
41 static void link_cells_to_cluster(
struct CLUSTER *cluster,
struct CELL *cell);
43 static void setup_flexdice(
struct CELL *top);
44 static void print_depth_limit(
void);
45 static void output_statistics(
void);
46 static double my_clock(
void);
48 #define BITSET(V,I) ((V)[(I)/INT_BITS] |= (1U << ((I)%INT_BITS))) 49 #define BITXOR(V,I) ((V)[(I)/INT_BITS] ^= (1U << ((I)%INT_BITS))) 50 #define BITGET(V,I) (((V)[(I)/INT_BITS] >> ((I)%INT_BITS)) & 1) 51 #define MIN(a,b) (((a)<(b))?(a):(b)) 52 #define MAX(a,b) (((a)>(b))?(a):(b)) 59 fprintf(stderr,
"Insufficient Memory.\n");
67 bits_equal(
unsigned int *a,
unsigned int *b)
69 for (
int i = 0; i < fxd.CODE_SIZE; i++) {
77 bits_clear(
unsigned int *a)
79 for (
int i = 0; i < fxd.CODE_SIZE; i++) {
85 bits_copy(
unsigned int *a,
unsigned int *b)
87 for (
int i = 0; i < fxd.CODE_SIZE; i++) {
93 hash_bits(
unsigned int *p,
int m,
struct INPARA *para)
102 int cc = getrusage(RUSAGE_SELF, &ru);
104 return (ru.ru_utime.tv_sec + (
double)ru.ru_utime.tv_usec * 1e-6);
125 if (src->head != NULL) {
126 assert(src->tail != NULL && src->count != 0);
127 src->tail->next = dst->head;
128 dst->head = src->head;
129 if (dst->tail == NULL) {
130 assert(dst->count == 0);
131 dst->tail = src->tail;
133 dst->count += src->count;
142 setup_object(
struct OBJECT *o,
int id)
145 o->value = malloc_safe(
sizeof(DATATYPE) * fxd.DIM);
150 setup_celllist(
struct CELLS *cs)
157 setup_object_queue(
struct OBJECTQ *data)
168 c->v_next = fxd.clusters;
174 setup_cluster(
struct CLUSTER *cluster,
int id)
177 cluster->v_next = NULL;
178 cluster->n_next = cluster;
180 cluster->object_count = 0;
181 cluster->active =
true;
182 put_cluster(cluster);
186 setup_layer(
struct LAYER *layer)
188 layer->object_count = 0;
189 layer->cell_count = 0;
190 layer->child_cell_count = 0;
196 take_object_from_cell(
struct CELL *cell)
198 struct OBJECT *o = cell->objects.head;
200 assert(cell->objects.count > 0);
201 cell->objects.head = cell->objects.head->next;
202 if (cell->objects.head == NULL) {
203 assert(cell->objects.count == 1);
204 cell->objects.tail = NULL;
206 cell->objects.count--;
213 update_layer_stat(
struct LAYER *layer,
struct CELL *c)
216 layer->child_cell_count += c->child_count;
217 layer->object_count += c->total_object_count;
221 setup_cell_queue(
struct CELLQ *q)
231 put_cell_in_queue(
struct CELL *c)
233 assert(c->q_next == NULL);
234 if (fxd.queue.count == 0) {
235 assert(fxd.queue.head == NULL);
238 fxd.queue.tail->q_next = c;
247 take_cell_from_queue(
void)
249 assert(fxd.queue.count != 0);
250 struct CELL *c = fxd.queue.head;
251 fxd.queue.head = c->q_next;
257 link_cell_list(
struct CELLS *h,
struct CELL *cell)
259 cell->d_next = h->head;
267 assert(o->next == NULL);
268 if (data->head == NULL) {
269 assert(data->tail == NULL && data->count == 0);
272 assert(data->tail != NULL && data->count != 0);
273 data->tail->next = o;
280 put_cell_in_cluster(
struct CLUSTER *cluster,
struct CELL *p)
282 assert(p->cluster == NULL && p->x_next == NULL);
283 p->cluster = cluster;
284 p->x_next = cluster->cells;
288 static struct CELLS *
291 int hashsize = fxd.para->hashsize;
292 struct CELLS *h = malloc_safe(
sizeof(
struct CELLS) * hashsize);
293 for (
int i = 0; i < hashsize; i++) {
294 setup_celllist(&h[i]);
303 find_child(
struct CELL *oya,
unsigned int *path)
305 int hv = hash_bits(path, fxd.para->hashsize, fxd.para);
306 struct CELLS *hashbin = &(oya->hashed_children[hv]);
308 for (cell = hashbin->head; cell != NULL; cell = cell->d_next) {
309 assert(cell->density != DEBRIS);
310 if (bits_equal(path, cell->path)) {
318 put_child(
struct CELL *oya,
unsigned int *path,
struct CELL *cell)
320 int hv = hash_bits(path, fxd.para->hashsize, fxd.para);
321 struct CELLS *hashbin = &(oya->hashed_children[hv]);
322 link_cell_list(hashbin, cell);
323 cell->c_next = oya->children;
324 oya->children = cell;
329 setup_cell(
struct CELL *cell,
unsigned int *path)
336 cell->density = MADA;
337 cell->child_count = 0;
338 cell->total_object_count = 0;
340 cell->path = malloc_safe(
sizeof(
unsigned int) * fxd.CODE_SIZE);
342 bits_clear(cell->path);
344 bits_copy(cell->path, path);
346 cell->cluster = NULL;
347 cell->children = NULL;
348 cell->hashed_children = NULL;
349 cell->adjacents = malloc_safe(
sizeof(
struct CELL *) * 2 * fxd.DIM);
350 for (
int dir = 0; dir < fxd.DIM_UPDN; dir++) {
351 cell->adjacents[dir] = NULL;
353 cell->min = malloc_safe(
sizeof(DATATYPE) * fxd.DIM);
354 cell->max = malloc_safe(
sizeof(DATATYPE) * fxd.DIM);
355 cell->cen = malloc_safe(
sizeof(DATATYPE) * fxd.DIM);
356 for (
int attr = 0; attr < fxd.DIM; attr++) {
361 setup_object_queue(&cell->objects);
368 create_cell(
struct CELL *oya,
unsigned int *path)
370 struct CELL *cell = malloc_safe(
sizeof(
struct CELL));
371 setup_cell(cell, path);
375 cell->level = (oya->level + 1);
376 bits_copy(cell->path, path);
377 put_child(oya, path, cell);
383 put_cell_to_dense_list(
struct CELL *c)
385 assert(c->d_next == NULL);
386 c->d_next = fxd.dense_cells;
392 put_cell_to_noise_list(
struct CELL *c)
394 assert(c->d_next == NULL);
395 c->d_next = fxd.noise_cells;
398 fxd.n_noise_objects += c->objects.count;
404 flexdice(
struct CELL *top,
struct INPARA *para)
407 init_flexdice(argv, para);
408 print_parameters(para);
409 struct CELL *top = create_cell(NULL, NULL);
410 read_input(top, para);
418 fxd.t[0] = my_clock();
422 put_cell_in_queue(top);
427 while (fxd.queue.count != 0) {
429 for (
struct CELL *p = fxd.queue.head; p != NULL; p = p->q_next) {
432 assert(count == fxd.queue.count);
433 assert(fxd.layers[level].cell_count == 0);
435 printf(
"layer-info: " 436 "level=%d #cells-at-level=%ld #dense-cells=%ld\n",
437 level, fxd.queue.count, fxd.n_dense_cells);
439 for (
struct CELL *p = fxd.queue.head; p != NULL; p = p->q_next) {
440 assert((p->level == level) && (p->density == MADA));
441 if (p->objects.count < fxd.para->dmin) {
443 }
else if (level == (fxd.para->nlayers - 1)) {
447 divide_cell_and_objects(p);
449 update_layer_stat(&fxd.layers[level], p);
451 assert(fxd.layers[level].cell_count == fxd.queue.count);
455 assert(fxd.layers[level].cell_count != 0);
456 double ratio = (1.0 * fxd.layers[level].child_cell_count
457 / fxd.layers[level].cell_count);
458 int threshold = (int)(fxd.para->dfac * ratio);
460 int n = fxd.queue.count;
461 for (
int i = 0; i < n; i++) {
462 struct CELL *p = take_cell_from_queue();
463 assert(p->level == level);
464 set_direct_adjacency(p);
465 if (p->child_count > threshold) {
469 assert(p->density != MADA);
470 if (p->density == SPARSE) {
471 put_cell_to_noise_list(p);
472 }
else if (p->density == DENSE) {
473 put_cell_to_dense_list(p);
475 assert(p->density == MIDDLE);
476 fxd.n_middle_cells++;
477 for (
struct CELL *c = p->children; c != NULL; c = c->c_next) {
478 put_cell_in_queue(c);
493 for (
struct CELL *c = fxd.noise_cells; c != NULL; c = c->d_next) {
494 assert(c->objects.count != 0 && c->child_count == 0);
495 no += c->objects.count;
500 for (
struct CELL *c = fxd.dense_cells; c != NULL; c = c->d_next) {
501 assert(c->density == DENSE);
502 assert(c->objects.count != 0);
503 oo += c->objects.count;
506 assert(fxd.n_objects == (oo + no));
507 assert(fxd.n_noise_objects == no);
508 assert(fxd.n_noise_cells == nc);
509 assert(fxd.n_dense_cells == dc);
510 assert(fxd.n_cells == (fxd.n_middle_cells + fxd.n_debris_cells
514 fxd.t[1] = my_clock();
516 printf(
"result: " "#dense-cells=%ld #noise-objects=%ld\n",
517 fxd.n_dense_cells, fxd.n_noise_objects);
519 if (fxd.dense_cells == NULL) {
520 fprintf(stderr,
"All objects are noise.\n");
538 for (
struct CLUSTER *p = fxd.clusters; p != NULL; p = p->v_next) {
542 oo += p->object_count;
546 for (
struct CELL *c = q->cells; c != NULL; c = c->x_next) {
547 if (c->density == DENSE) {
555 assert(fxd.n_objects == (oo + fxd.n_noise_objects));
556 assert(fxd.n_dense_cells == dc);
559 fxd.t[2] = my_clock();
565 delete_cell(
struct CELL *c)
573 if (c->hashed_children != NULL) {
574 free(c->hashed_children);
583 free(fxd.depth_limits);
589 init_flexdice(
int argc,
char **argv,
struct INPARA *para)
592 fxd.DIM = fxd.para->dim;
593 fxd.DIM_UPDN = (2 * fxd.para->dim);
594 fxd.CODE_SIZE = ((fxd.para->dim - 1) / INT_BITS) + 1;
604 read_input(
struct CELL *input,
struct INPARA *para)
607 DATATYPE max[fxd.DIM];
608 DATATYPE min[fxd.DIM];
610 input->parent = NULL;
611 for (
int dir = 0; dir < fxd.DIM_UPDN; dir++) {
612 input->adjacents[dir] = NULL;
614 for (
int attr = 0; attr < fxd.DIM; attr++) {
619 max[attr] = -DBL_MAX;
624 FILE *f = fopen(para->infile,
"r");
639 cc = fscanf(f, FMT, &val);
644 #define BAD_DATA_IN_INPUT 0 645 assert(BAD_DATA_IN_INPUT);
648 o = malloc_safe(
sizeof(
struct OBJECT));
649 setup_object(o, nobjects);
652 o->value[attr] = val;
653 max[attr] = MAX(max[attr], val);
654 min[attr] = MIN(min[attr], val);
655 if (attr == (fxd.DIM - 1)) {
656 put_object_in_cell(&(input->objects), o);
667 assert(input->objects.count == nobjects);
668 for (
int attr = 0; attr < fxd.DIM; attr++) {
669 input->max[attr] = max[attr];
670 input->min[attr] = min[attr];
671 input->cen[attr] = (min[attr] + (max[attr] - min[attr]) / 2);
678 set_input(
struct CELL *input,
struct INPARA *para,
int *data,
long count)
680 assert(DATA == DATA_Z);
684 input->parent = NULL;
685 for (
int dir = 0; dir < fxd.DIM_UPDN; dir++) {
686 input->adjacents[dir] = NULL;
688 for (
int attr = 0; attr < fxd.DIM; attr++) {
692 for (
long i = 0; i < count; i++) {
695 for (
int attr = 0; attr < fxd.DIM; attr++) {
696 int val = data[(fxd.DIM * i) + attr];
697 o->value[attr] = val;
698 max[attr] = MAX(max[attr], val);
699 min[attr] = MIN(min[attr], val);
701 put_object_in_cell(&(input->objects), o);
703 for (
int attr = 0; attr < fxd.DIM; attr++) {
704 assert(max[attr] != INT_MIN);
705 assert(min[attr] != INT_MAX);
707 for (
int attr = 0; attr < fxd.DIM; attr++) {
708 input->max[attr] = max[attr];
709 input->min[attr] = min[attr];
710 input->cen[attr] = (min[attr] + (max[attr] - min[attr]) / 2);
718 output_statistics(
void)
723 cc = snprintf(name,
sizeof(name),
"%s/datamax", fxd.para->outdir);
724 assert(cc < (
int)
sizeof(name));
725 FILE *f0 = fopen(name,
"w");
728 struct CELL *top = fxd.top;
729 for (
int attr = 0; attr < fxd.DIM; attr++) {
731 cc = fprintf(f0,
"%s%d", (attr == 0 ?
"" :
" "), top->max[attr]);
734 cc = fprintf(f0,
"%s%f", (attr == 0 ?
"" :
" "), top->max[attr]);
738 cc = fprintf(f0,
"\n");
743 cc = snprintf(name,
sizeof(name),
"%s/datamin", fxd.para->outdir);
744 assert(cc < (
int)
sizeof(name));
745 FILE *f1 = fopen(name,
"w");
747 for (
int attr = 0; attr < fxd.DIM; attr++) {
749 cc = fprintf(f1,
"%s%d", (attr == 0 ?
"" :
" "), top->min[attr]);
752 cc = fprintf(f1,
"%s%f", (attr == 0 ?
"" :
" "), top->min[attr]);
756 cc = fprintf(f1,
"\n");
763 output_object(FILE *f,
struct OBJECT *o)
766 cc = fprintf(f,
"%d ", o->id);
768 for (
int attr = 0; attr < fxd.DIM; attr++) {
770 cc = fprintf(f,
" %d", o->value[attr]);
773 cc = fprintf(f,
" %f", o->value[attr]);
777 cc = fprintf(f,
"\n");
782 output_clusters(
void)
788 int digits = ((int)log10((
double)fxd.n_clusters) + 1);
790 cc = snprintf(command,
sizeof(command),
"mkdir -p %s", fxd.para->outdir);
791 assert(cc < (
int)
sizeof(command));
792 cc = system(command);
798 for (
struct CLUSTER *p = fxd.clusters; p != NULL; p = p->v_next) {
802 cc = snprintf(name,
sizeof(name),
"%s/C%0*d",
803 fxd.para->outdir, digits, count);
804 assert(cc < (
int)
sizeof(name));
805 FILE *f0 = fopen(name,
"w");
807 for (
struct CELL *c = p->cells; c != NULL; c = c->x_next) {
808 for (
struct OBJECT *o = c->objects.head; o != NULL; o = o->next) {
809 output_object(f0, o);
816 assert(count == fxd.n_clusters);
818 _Bool noise[fxd.para->nlayers];
819 for (
int i = 0; i < fxd.para->nlayers; i++) {
823 for (
int i = 0; i < fxd.para->nlayers; i++) {
824 cc = snprintf(name,
sizeof(name),
"%s/NL%d", fxd.para->outdir, i);
825 assert(cc < (
int)
sizeof(name));
826 FILE *f1 = fopen(name,
"w");
828 for (
struct CELL *c = fxd.noise_cells; c != NULL; c = c->d_next) {
833 for (
struct OBJECT *o = c->objects.head; o != NULL; o = o->next) {
834 output_object(f1, o);
842 if (fxd.para->dim == 2) {
843 cc = snprintf(name,
sizeof(name),
"%s/plot", fxd.para->outdir);
844 assert(cc < (
int)
sizeof(name));
845 FILE *f2 = fopen(name,
"w");
847 cc = fprintf(f2,
"plot 'NL'notitle");
850 for (
struct CLUSTER *p = fxd.clusters; p != NULL; p = p->v_next) {
851 if (p->active && (fxd.para->plot_cut_off < p->object_count)) {
852 cc = fprintf(f2,
",'C%0*d'notitle", digits, cnt2);
862 if (fxd.para->dim >= 2) {
863 cc = snprintf(name,
sizeof(name),
"%s/plot2d", fxd.para->outdir);
864 assert(cc < (
int)
sizeof(name));
865 FILE *f3 = fopen(name,
"w");
867 cc = fprintf(f3,
"plot ");
871 for (
struct CLUSTER *p = fxd.clusters; p != NULL; p = p->v_next) {
872 if (p->active && (p->object_count > fxd.para->plot_cut_off)) {
873 cc = fprintf(f3,
"%s'C%0*d' u 2:3 w d", fsep, digits, cnt3);
879 assert(fsep[0] != 0);
880 if (fxd.para->plot_noise) {
881 for (
int i = 1; i < fxd.para->nlayers; i++) {
883 cc = fprintf(f3,
"%s'NL%d' u 2:3 w d", fsep, i);
891 if (fxd.para->dim >= 3) {
892 cc = snprintf(name,
sizeof(name),
"%s/plot3d", fxd.para->outdir);
893 assert(cc < (
int)
sizeof(name));
894 FILE *f4 = fopen(name,
"w");
896 cc = fprintf(f4,
"splot ");
900 for (
struct CLUSTER *p = fxd.clusters; p != NULL; p = p->v_next) {
901 if (p->active && (p->object_count > fxd.para->plot_cut_off)) {
902 cc = fprintf(f4,
"%s'C%0*d' u 2:3:4 w d", fsep, digits, cnt4);
908 assert(fsep[0] != 0);
909 if (fxd.para->plot_noise) {
910 for (
int i = 1; i < fxd.para->nlayers; i++) {
912 cc = fprintf(f4,
"%s'NL%d' u 2:3:4 w d", fsep, i);
924 cc = snprintf(name,
sizeof(name),
"%s/inputdata.dat",
926 assert(cc < (
int)
sizeof(name));
927 FILE *f5 = fopen(name,
"w");
930 for (
struct CLUSTER *p = fxd.clusters; p != NULL; p = p->v_next) {
931 if (p->active && fxd.para->plot_cut_off < p->object_count) {
932 cc = fprintf(f5,
"C%0*d\n", digits, cnt5);
937 cc = fprintf(f5,
"NL\n");
948 setup_flexdice(
struct CELL *top)
950 fxd.depth_limits = malloc_safe(
sizeof(
int) * fxd.para->dim);
951 int botmax = INT_MIN;
952 for (
int attr = 0; attr < fxd.DIM; attr++) {
954 DATATYPE w = (top->max[attr] - top->min[attr]);
955 fxd.depth_limits[attr] = log2i(w + 1);
957 fxd.depth_limits[attr] = (fxd.para->nlayers - 1);
959 assert(fxd.depth_limits[attr] > 0);
960 botmax = MAX(botmax, fxd.depth_limits[attr]);
962 if (botmax < (fxd.para->nlayers - 1)) {
963 fprintf(stderr,
"input parameter error; layers be %d.\n", botmax);
969 fxd.n_objects = top->objects.count;
970 fxd.n_middle_cells = 0;
971 fxd.n_dense_cells = 0;
973 fxd.n_noise_cells = 0;
974 fxd.n_debris_cells = 0;
975 fxd.n_noise_objects = 0;
977 fxd.layers = malloc_safe(
sizeof(
struct LAYER) * fxd.para->nlayers);
978 for (
int i = 0; i < fxd.para->nlayers; i++) {
979 setup_layer(&fxd.layers[i]);
981 fxd.layers[0].object_count = top->objects.count;
982 fxd.layers[0].cell_count = 0;
983 fxd.layers[0].child_cell_count = 0;
986 fxd.cluster_count = 0;
991 setup_cell_queue(&(fxd.queue));
993 fxd.noise_cells = NULL;
994 fxd.dense_cells = NULL;
1005 divide_cell_and_objects(
struct CELL *cell)
1007 unsigned int path[fxd.CODE_SIZE];
1008 assert(cell->child_count == 0 && cell->hashed_children == NULL);
1009 cell->total_object_count = cell->objects.count;
1010 cell->hashed_children = make_hashtable();
1013 while ((o = take_object_from_cell(cell)) != NULL) {
1014 calculate_cell_path(path, cell, o);
1015 struct CELL *c = find_child(cell, path);
1017 c = create_cell(cell, path);
1018 set_cell_range(c, cell);
1021 put_object_in_cell(&(c->objects), o);
1023 assert(cell->objects.count == 0);
1024 assert(cell->child_count == nchildren);
1030 set_cell_range(
struct CELL *cell,
struct CELL *oya)
1032 for (
int attr = 0; attr < fxd.DIM; attr++) {
1033 if (oya->level < fxd.depth_limits[attr]) {
1035 int updn = BITGET(cell->path, attr);
1037 cell->min[attr] = oya->min[attr];
1038 cell->max[attr] = oya->cen[attr];
1040 cell->min[attr] = oya->cen[attr];
1041 cell->max[attr] = oya->max[attr];
1043 cell->cen[attr] = (cell->min[attr]
1044 + ((cell->max[attr] - cell->min[attr]) / 2));
1047 cell->min[attr] = oya->min[attr];
1048 cell->max[attr] = oya->max[attr];
1049 cell->cen[attr] = oya->cen[attr];
1055 undo_divide_cell(
struct CELL *cell)
1057 assert(cell->objects.count == 0);
1058 for (
struct CELL *c = cell->children; c != NULL; c = c->c_next) {
1059 assert(c->density == MADA);
1060 relink_object_lists(&(cell->objects), &(c->objects));
1061 c->density = DEBRIS;
1062 fxd.n_debris_cells++;
1071 calculate_cell_path(
unsigned int *path,
struct CELL *oya,
struct OBJECT *obj)
1074 for (
int attr = 0; attr < fxd.DIM; attr++) {
1075 if (oya->level < fxd.depth_limits[attr]) {
1077 if (oya->cen[attr] < obj->value[attr]) {
1085 flip_path(
unsigned int *xpath,
unsigned int *path,
int attr)
1087 bits_copy(xpath, path);
1088 BITXOR(xpath, attr);
1096 set_direct_adjacency(
struct CELL *cell)
1098 unsigned int xpath[fxd.CODE_SIZE];
1099 struct CELL *oya = cell->parent;
1101 for (
int dir = 0; dir < fxd.DIM_UPDN; dir++) {
1102 assert(cell->adjacents[dir] == NULL);
1103 int attr = (dir / 2);
1104 int updn = BITGET(cell->path, attr);
1105 if ((oya->level < fxd.depth_limits[attr]) && updn != (dir & 1)) {
1107 flip_path(xpath, cell->path, attr);
1108 struct CELL *c = find_child(oya, xpath);
1109 if (c != NULL && c->density != SPARSE) {
1110 cell->adjacents[dir] = c;
1114 struct CELL *ac = oya->adjacents[dir];
1116 switch (ac->density) {
1118 assert(ac->density != MADA);
1124 cell->adjacents[dir] = ac;
1127 if (oya->level < fxd.depth_limits[attr]) {
1128 flip_path(xpath, cell->path, attr);
1130 bits_copy(xpath, cell->path);
1132 struct CELL *c = find_child(ac, xpath);
1133 if (c != NULL && c->density != SPARSE) {
1134 cell->adjacents[dir] = c;
1138 assert(ac->density != DEBRIS);
1159 for (
struct CELL *p = fxd.dense_cells; p != NULL; p = p->d_next) {
1160 if (p->cluster == NULL) {
1162 setup_cluster(cluster,
id);
1163 link_cells_to_cluster(cluster, p);
1170 link_cells_to_cluster(
struct CLUSTER *cluster,
struct CELL *cell)
1172 assert(cell->cluster == NULL);
1173 assert(cell->density == DENSE);
1174 assert(cell->density != DENSE || cell->objects.count != 0);
1175 put_cell_in_cluster(cluster, cell);
1176 for (
int dir = 0; dir < fxd.DIM_UPDN; dir++) {
1177 struct CELL *ac = cell->adjacents[dir];
1178 assert(ac == NULL || (ac->density != MADA && ac->density != DEBRIS));
1181 }
else if (ac->density == SPARSE || ac->density == MIDDLE) {
1183 }
else if (ac->cluster == NULL) {
1184 link_cells_to_cluster(cluster, ac);
1186 merge_clusters(cluster, ac->cluster);
1195 for (
struct CLUSTER *p = x0->n_next; p != x0; p = p->n_next) {
1200 struct CLUSTER *x1 = x0->n_next;
1201 struct CLUSTER *y1 = y0->n_next;
1212 finish_clusters(
void)
1215 for (
struct CLUSTER *pp = fxd.clusters; pp != NULL; pp = pp->v_next) {
1228 for (
struct CELL *c = q->cells; c != NULL; c = c->x_next) {
1229 oo += c->objects.count;
1234 assert(pp->object_count == 0);
1235 pp->object_count = oo;
1237 assert(fxd.n_clusters == 0);
1238 fxd.n_clusters = nclusters;
1244 print_depth_limit(
void)
1246 printf(
"bottom-levels:");
1247 for (
int attr = 0; attr < fxd.DIM; attr++) {
1248 printf(
" [%d]=%d", attr, fxd.depth_limits[attr]);
1254 print_parameters(
struct INPARA *para)
1256 printf(
"input-file: %s\n", para->infile);
1257 printf(
"parameters:" 1258 " dense-min=%d dense-factor=%.2f bottom-level=%d hash-size=%d\n",
1259 para->dmin , para->dfac, para->nlayers, para->hashsize);
1263 print_input(
struct CELL *top)
1265 printf(
"-----Input Cell information-----\n");
1266 printf(
"The number of data objects = %ld\n", top->objects.count);
1267 printf(
"top->nighbor.dl\n");
1268 printf(
"(attribute#, min, center, max)\n");
1269 for (
int i = 0; i < fxd.DIM; i++) {
1270 printf(
"(%s%3d, ", (i == 0 ?
"" :
" "), i);
1271 #if (DATA == DATA_Z) 1272 printf(
"%4d, ", top->min[i]);
1273 printf(
"%4d, ", top->cen[i]);
1274 printf(
"%4d)", top->max[i]);
1276 printf(
"%f, ", top->min[i]);
1277 printf(
"%f, ", top->cen[i]);
1278 printf(
"%f)", top->max[i]);