-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhmat_div.c
More file actions
618 lines (572 loc) · 17.9 KB
/
Copy pathhmat_div.c
File metadata and controls
618 lines (572 loc) · 17.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <sys/time.h>
#include "data/bem_file.h"
#ifdef DEBUG
#include <assert.h>
#endif
#define INPUT_DEFAULT "bem_data/input_10ts.txt"
/*********define cluster************/
typedef struct cluster cluster;
struct cluster{
int ndim;
int nstrt,nsize,ndpth,nnson,nmbr;
int ndscd; //number of descendants
double *bmin; //bounding box
double *bmax;
double zwdth;
cluster **pc_sons;
};
/*********define leafMtx***********/ //information of H-matrix
typedef struct leafmtx leafmtx;
struct leafmtx{
int ltmtx; //kind of the matrix; 1:rk 2:full
int kt; //rank of the partition
int nstrtl,ndl; //the coordination of the first element of partition
int nstrtt,ndt; //the length & width of the partition
double *a1,*a2; //the elements of the partition
};
/*********define leafmtxp*********/ //whole H-matrix
typedef struct leafmtxp leafmtxp;
struct leafmtxp{
int nlf; //number of partitions
int nlfkt; //number ot partitions approximated
};
void supermatrix_construction_cog_leafmtrx(leafmtxp *st_leafmtxp,double (*gmid)[3],double param[],int *lod,int *lnmtx,int nofc,int nffc,int ndim);
void qsort_col_leafmtx(leafmtx *st_leafmtx,int first,int last);
void qsort_row_leafmtx(leafmtx *st_leafmtx,int first,int last);
int med3(int nl,int nr,int nlr2);
void create_leafmtx(leafmtx *st_leafmtx,cluster *st_cltl,cluster *st_cltt,double param[],int *lnmtx,int nffc,int *nlf);
double dist_2cluster(cluster *st_cltl,cluster *st_cltt);
void count_lntmx(cluster *st_cltl,cluster *st_cltt,double param[],int *lnmtx,int nffc);
void cal_bndbox_cog(cluster *st_clt,double (*zgmid)[3],int *lod,int nofc);
void set_bndbox_cog(cluster *st_clt,double (*zgmid)[3],int *lod,int nofc);
cluster * create_cluster(int nmbr,int ndpth,int nstrt,int nsize,int ndim,int nson);
void free_st_clt(cluster *st_clt);
cluster * create_ctree_ssgeom(cluster *st_clt,double (*zgmid)[3],double param[],int *lod,int ndpth,int ndscd,int nsrt,int nd,int md,int ndim,int nclst);
double get_wall_time();
double get_cpu_time();
void checkClusterTree(FILE *f,cluster *st_clt);
int depth_max;
int count_node;
int main(int argc, char **argv){
/******** read file *********/
char *fname;
FILE *file;
int countOfNode=0;
int count = 0;
int i;
double (*coordOfNode)[3];
double (*coordOfFace)[3];
struct bem_input bi;
fname = (argc >= 2)?argv[1]:INPUT_DEFAULT;
file = fopen(fname,"r");
if(file == NULL){
printf("Error: Unable to input file '%s'!\n", fname);
exit (99);
}else{
if (read_bem_input (file, &bi, BI_AUTO) == -1) {
fprintf (stderr, "Bem input file read error!\n");
exit (99);
}
char line[100];
countOfNode = bi.nNode;
coordOfNode = bi.coordOfNode;
count = bi.nFace;
coordOfFace = bi.coordOfFace;
}
fclose(file);
free(coordOfNode);
double param[100];
for(i=0;i<100;i++){
param[i] = 0;
}
param[21] = 10.0;
param[31] = 1.1;
param[41] = 15.0;
param[51] = 2.0;
/***********clustering***********/
leafmtxp *st_leafmtxp;
int *lod;
int *lnmtx;
int nofc = count;
int nffc = 1;
int ndim = 3;
lnmtx = (int *)malloc(3 * sizeof(int));
for(i=0;i<3;i++){
lnmtx[i] = 0;
}
st_leafmtxp = (leafmtxp *)malloc(sizeof(leafmtxp));
lod = (int *)malloc(nofc*sizeof(int));
for(i=0;i<nofc;i++){
lod[i] = 0;
}
//double start,end;
//start = get_wall_time();
supermatrix_construction_cog_leafmtrx(st_leafmtxp,coordOfFace,param,lod,lnmtx,nofc,nffc,ndim); // construction of Leaf-matrix
//end = get_wall_time();
//double spent = end - start;
//printf("total time spent:%.13f\n",spent);
return 0;
}
#ifdef DEBUG
int *lod0;
#endif
void supermatrix_construction_cog_leafmtrx(leafmtxp *st_leafmtxp, //the H-matrix
double (*gmid)[3], //coordination of objects
double param[],int *lod,
int *lnmtx, //1:k-rank 2:dense 3:H-matrix
int nofc,int nffc, //number of elements in same coordination
int ndim){
cluster *st_clt = (cluster *)malloc(sizeof(cluster));
int i,nfl,nflkt,ip,il,ig;
int nd = nofc * nffc;
int *lodfc;
leafmtx *st_leafmtx;
lodfc = (int *)malloc(nofc*sizeof(int));
for(il=0;il<nofc;il++){
lodfc[il] = il;
}
int nsrt = 0;
int ndf = nofc;
int nclst = 0;
int ndpth = 0;
int ndscd = 0;
depth_max = 0;
count_node = 0;
double start,end,spent;
start = get_wall_time();
#ifdef DEBUG
lod0 = lodfc;
#endif
st_clt = create_ctree_ssgeom(st_clt,gmid,param,lodfc,ndpth,ndscd,nsrt,ndf,nofc,ndim,nclst);
end = get_wall_time();
spent = end - start;
printf("cluster tree time spent:%.10f\n",spent);
set_bndbox_cog(st_clt,gmid,lodfc,nofc);
/*FILE *f = fopen("8_sequential.txt", "w");
checkClusterTree(f,st_clt);
fclose(f);*/
ndpth = 0;
start = get_wall_time();
count_lntmx(st_clt,st_clt,param,lnmtx,nffc);
end = get_wall_time();
spent = end - start;
printf("count time:%.10f\n",spent);
st_leafmtxp->nlfkt = lnmtx[0];
int nlf = lnmtx[0] + lnmtx[1];
st_leafmtx = (leafmtx *)malloc(nlf*sizeof(leafmtx));
st_leafmtxp->nlf = nlf;
printf("nlf:%d\n",nlf);
nlf = 0;
start = get_wall_time();
create_leafmtx(st_leafmtx,st_clt,st_clt,param,lnmtx,nffc,&nlf);
end = get_wall_time();
spent = end - start;
printf("nlf:%d\n",nlf);
printf("block cluster tree time spent:%.10f\n",spent);
printf("depth_max:%d count_node:%d\n",depth_max,count_node);
qsort_row_leafmtx(st_leafmtx,0,nlf-1);
int ilp = 0;
int ips = 0;
for(ip=0;ip<nlf;ip++){
il = st_leafmtx[ip].nstrtl;
if(il < ilp){
printf("Error!: supermatrix_construction_cog/leafmtx row_sort\n");
}else if(il > ilp){
qsort_col_leafmtx(st_leafmtx,ips,ip-1);
ilp = il;
ips = ip;
}
if(ip == nlf-1){
qsort_col_leafmtx(st_leafmtx,ips,nlf-1);
}
}
FILE * fp;
fp = fopen ("result_plot.txt","w");
for(i=0;i<st_leafmtxp->nlf;i++){
fprintf(fp,"%ld, %ld, %ld, %ld, %ld, %ld\n",0,st_leafmtx[i].nstrtl,st_leafmtx[i].nstrtt,
st_leafmtx[i].nstrtl+st_leafmtx[i].ndl-1,st_leafmtx[i].nstrtt+st_leafmtx[i].ndt-1,st_leafmtx[i].ltmtx);
}
fclose (fp);
free_st_clt(st_clt);
for(il=0;il<nofc;il++){
for(ig=0;ig<nffc;ig++){
int is = ig + il * nffc;
lod[is] = lodfc[il];
}
}
}
void qsort_row_leafmtx(leafmtx *st_leafmtx,int first,int last){
int i,j,pivot;
leafmtx st_www;
if(first<last){
pivot=first;
i=first;
j=last;
while(i<j){
while(st_leafmtx[i].nstrtl <= st_leafmtx[pivot].nstrtl && i<last)
i++;
while(st_leafmtx[j].nstrtl>st_leafmtx[pivot].nstrtl)
j--;
if(i<j){
st_www = st_leafmtx[i];
st_leafmtx[i]=st_leafmtx[j];
st_leafmtx[j]=st_www;
}
}
st_www = st_leafmtx[pivot];
st_leafmtx[pivot] = st_leafmtx[j];
st_leafmtx[j] = st_www;
qsort_row_leafmtx(st_leafmtx,first,j-1);
qsort_row_leafmtx(st_leafmtx,j+1,last);
}
}
void qsort_col_leafmtx(leafmtx *st_leafmtx,int first,int last){
int i,j,pivot;
leafmtx st_www;
if(first<last){
pivot=first;
i=first;
j=last;
while(i<j){
while(st_leafmtx[i].nstrtt <= st_leafmtx[pivot].nstrtt && i<last)
i++;
while(st_leafmtx[j].nstrtt>st_leafmtx[pivot].nstrtt)
j--;
if(i<j){
st_www = st_leafmtx[i];
st_leafmtx[i]=st_leafmtx[j];
st_leafmtx[j]=st_www;
}
}
st_www = st_leafmtx[pivot];
st_leafmtx[pivot] = st_leafmtx[j];
st_leafmtx[j] = st_www;
qsort_col_leafmtx(st_leafmtx,first,j-1);
qsort_col_leafmtx(st_leafmtx,j+1,last);
}
}
int med3(int nl,int nr,int nlr2){
int med3;
if(nl < nr){
if(nr < nlr2){
med3 = nr;
}else if(nlr2 < nl){
med3 = nl;
}else{
med3 = nlr2;
}
}else{
if(nlr2 < nr){
med3 = nr;
}else if(nl < nlr2){
med3 = nl;
}else{
med3 = nlr2;
}
}
return med3;
}
void create_leafmtx(leafmtx *st_leafmtx,cluster *st_cltl,cluster *st_cltt,
double param[],int *lnmtx,int nffc,int *nlf){
int ndl = st_cltl->nsize * nffc;
int ndt = st_cltt->nsize * nffc;
int nstrtl = st_cltl->nstrt;
int nstrtt = st_cltt->nstrt;
int nnsonl = st_cltl->nnson;
int nnsont = st_cltt->nnson;
int il,it;
double nleaf = param[41];
double zeta = param[51];
double zdistlt = dist_2cluster(st_cltl,st_cltt);
if((st_cltl->zwdth <= zdistlt * zeta || st_cltt->zwdth <= zdistlt * zeta) && (ndl >= nleaf && ndt >= nleaf)){
//st_leafmtx[*nlf] = (leafmtx *)malloc(sizeof(leafmtx));
st_leafmtx[*nlf].nstrtl = nstrtl;
st_leafmtx[*nlf].ndl = ndl;
st_leafmtx[*nlf].nstrtt = nstrtt;
st_leafmtx[*nlf].ndt = ndt;
st_leafmtx[*nlf].kt = 0;
st_leafmtx[*nlf].ltmtx = 1;
*nlf = *nlf + 1;
}else{
if(nnsonl == 0 || nnsont == 0 || ndl <= nleaf || ndt <= nleaf){
//st_leafmtx[*nlf]= (leafmtx *)malloc(sizeof(leafmtx));
st_leafmtx[*nlf].nstrtl = nstrtl;
st_leafmtx[*nlf].ndl = ndl;
st_leafmtx[*nlf].nstrtt = nstrtt;
st_leafmtx[*nlf].ndt = ndt;
st_leafmtx[*nlf].ltmtx = 2;
*nlf = *nlf + 1;
}else{
for(il=0;il<nnsonl;il++){
for(it=0;it<nnsont;it++){
create_leafmtx(st_leafmtx,st_cltl->pc_sons[il],st_cltt->pc_sons[it],param,lnmtx,nffc,nlf);
}
}
}
}
}
double dist_2cluster(cluster *st_cltl,cluster *st_cltt){
double zs = 0.0;
int id;
for(id=0;id<st_cltl->ndim;id++){
if(st_cltl->bmax[id] < st_cltt->bmin[id]){
zs = zs + (st_cltt->bmin[id] - st_cltl->bmax[id]) * (st_cltt->bmin[id] - st_cltl->bmax[id]);
}else if(st_cltt->bmax[id]< st_cltl->bmin[id]){
zs = zs+ (st_cltl->bmin[id] - st_cltt->bmax[id]) * (st_cltl->bmin[id] - st_cltt->bmax[id]);
}
}
return sqrt(zs);
}
void count_lntmx(cluster *st_cltl,cluster *st_cltt,double param[],int *lnmtx,int nffc){
int il,it;
int ndl = st_cltl->nsize * nffc;
int ndt = st_cltt->nsize * nffc;
int nstrtl = st_cltl->nstrt;
int nstrtt = st_cltt->nstrt;
int nnsonl = st_cltl->nnson;
int nnsont = st_cltt->nnson;
double nleaf = param[41];
double zeta = param[51];
double zdistlt = dist_2cluster(st_cltl,st_cltt);
if ((st_cltl->zwdth <= zdistlt * zeta || st_cltt->zwdth <= zdistlt * zeta) && (ndl >= nleaf && ndt >= nleaf)){
lnmtx[0] = lnmtx[0] + 1;
}else{
if(nnsonl == 0 || nnsont == 0 || ndl <= nleaf || ndt <= nleaf){
lnmtx[1] = lnmtx[1] + 1;
}else{
lnmtx[2] = lnmtx[2] + 1;
for(il=0;il<nnsonl;il++){
for(it=0;it<nnsont;it++){
count_lntmx(st_cltl->pc_sons[il],st_cltt->pc_sons[it],param,lnmtx,nffc);
}
}
}
}
}
void cal_bndbox_cog(cluster *st_clt,double (*zgmid)[3],int *lod,int nofc){
int ndim = 3;
int id,il;
st_clt->bmin = (double *)malloc(3*sizeof(double));
st_clt->bmax = (double *)malloc(3*sizeof(double));
double zeps = 1.0e-5;
if(st_clt->nnson > 0){
for(id=0;id<ndim;id++){
st_clt->bmin[id] = st_clt->pc_sons[0]->bmin[id];
st_clt->bmax[id] = st_clt->pc_sons[0]->bmax[id];
}
for(il=1;il<st_clt->nnson;il++){
for(id=0;id<ndim;id++){
if(st_clt->pc_sons[il]->bmin[id] < st_clt->bmin[id]){
st_clt->bmin[id] = st_clt->pc_sons[il]->bmin[id];
}
if(st_clt->bmax[id] < st_clt->pc_sons[il]->bmax[id]){
st_clt->bmax[id] = st_clt->pc_sons[il]->bmax[id];
}
}
}
}else{
for(id=0;id<ndim;id++){
st_clt->bmin[id] = zgmid[lod[0]][id];
st_clt->bmax[id] = zgmid[lod[0]][id];
}
for(id=0;id<ndim;id++){
for(il=1;il<st_clt->nsize;il++){
if(zgmid[lod[il]][id] < st_clt->bmin[id]){
st_clt->bmin[id] = zgmid[lod[il]][id];
}
if(st_clt->bmax[id] < zgmid[lod[il]][id]){
st_clt->bmax[id] = zgmid[lod[il]][id];
}
}
}
}
double zwdth = (st_clt->bmax[0] - st_clt->bmin[0]) * (st_clt->bmax[0] - st_clt->bmin[0]);
for(id=1;id<ndim;id++){
zwdth += (st_clt->bmax[id] - st_clt->bmin[id]) * (st_clt->bmax[id] - st_clt->bmin[id]);
}
zwdth = sqrt(zwdth);
for(id=0;id<ndim;id++){
double bdiff = st_clt->bmax[id] - st_clt->bmin[id];
if(bdiff < zeps * zwdth){
st_clt->bmax[id] += 0.5 * (zeps * zwdth - bdiff);
st_clt->bmin[id] -= 0.5 * (zeps * zwdth - bdiff);
}
}
zwdth = (st_clt->bmax[0] - st_clt->bmin[0]) * (st_clt->bmax[0] - st_clt->bmin[0]);
for(id=1;id<ndim;id++){
zwdth += (st_clt->bmax[id] - st_clt->bmin[id]) * (st_clt->bmax[id] - st_clt->bmin[id]);
}
st_clt->zwdth = sqrt(zwdth);
}
void set_bndbox_cog(cluster *st_clt, double (*zgmid)[3], int *lod, int nofc){
int ic,l;
for(ic=0;ic<st_clt->nnson;ic++){
if(ic == 0){
l = 0;
}else{
l = l + st_clt->pc_sons[ic-1]->nsize;
}
set_bndbox_cog(st_clt->pc_sons[ic],zgmid,&lod[l],nofc);
}
cal_bndbox_cog(st_clt,zgmid,lod,nofc);
}
/*****create a cluster*********/
cluster * create_cluster(int nmbr,int ndpth,int nstrt,int nsize,int ndim,int nson){
cluster *st_clt;
st_clt = (cluster *)malloc(sizeof(cluster));
nmbr = nmbr + 1;
count_node++;
st_clt->nstrt = nstrt;
st_clt->nsize = nsize;
st_clt->ndim = ndim;
st_clt->nnson = nson;
st_clt->nmbr = nmbr;
st_clt->ndpth = ndpth;
st_clt->pc_sons = (cluster **)malloc(nson * sizeof(cluster*));
return st_clt;
}
void free_st_clt(cluster *st_clt){
int ic;
int nnson = st_clt->nnson;
for(ic=0;ic<nnson;ic++){
free_st_clt(st_clt->pc_sons[ic]);
}
free(st_clt->bmin);
free(st_clt->bmax);
free(st_clt->pc_sons);
}
void checkClusterTree(FILE *f,cluster *st_clt){
if(st_clt->ndpth<11){
fprintf(f,"%d %d %d %d %lf\n",st_clt->nstrt,st_clt->nsize,st_clt->ndpth,st_clt->nnson,st_clt->zwdth);
}
if(st_clt->nnson==0){
//fprintf(f,"%lf %lf %lf %lf %lf %lf ",st_clt->bmin[0],st_clt->bmin[1],st_clt->bmin[2],st_clt->bmax[0],st_clt->bmax[1],st_clt->bmax[2]);
//fprintf(f,"%d %d %d %d %lf\n",st_clt->nstrt,st_clt->nsize,st_clt->ndpth,st_clt->nnson,st_clt->zwdth);
return;
}else if(st_clt->nnson==1){
checkClusterTree(f,st_clt->pc_sons[0]);
}else{
checkClusterTree(f,st_clt->pc_sons[0]);
checkClusterTree(f,st_clt->pc_sons[1]);
}
}
/****create cluster tree******/
cluster * create_ctree_ssgeom(cluster *st_clt, //the current node
double (*zgmid)[3],//coordination of objects
double param[], //param[21] is minGroup, param[31] is ?
int *lod, //hash table of pre-index and pro-index
int ndpth, //depth of the tree
int ndscd,
int nsrt, //the start index of list
int nd, //the length of list
int md, //number of data
int ndim, //number of dimension (default is 3)
int nclst){ //number of cluster
int id,il,nson;
double minsz = 50.0;
double zcoef = 1.1;
double zlmin[ndim],zlmax[ndim];
ndpth = ndpth + 1;
#ifdef DEBUG
printf ("ndepth = %ld, nd = %ld, range = %ld-%ld ", ndpth, nd, lod-lod0, lod-lod0+nd);
#endif
if(nd <= minsz){
#ifdef DEBUG
fprintf (stdout, "... leaf\n");
#endif
nson = 0;
st_clt = create_cluster(nclst,ndpth,nsrt,nd,ndim,nson);
if(ndpth > depth_max){
depth_max = ndpth;
}
}else{
for(id=0;id<ndim;id++){
zlmin[id] = zgmid[lod[0]][id];
zlmax[id] = zlmin[id];
for(il=1;il<nd;il++){
double zg = zgmid[lod[il]][id];
if(zg < zlmin[id]){
zlmin[id] = zg;
}else if(zlmax[id] < zg){
zlmax[id] = zg;
}
}
}
double zdiff = zlmax[0] - zlmin[0];
int ncut = 0;
for(id=0;id<ndim;id++){
double zidiff = zlmax[id]-zlmin[id];
if(zidiff > zcoef * zdiff){
zdiff = zidiff;
ncut = id;
}
}
double zlmid = 0.5 * (zlmax[ncut] + zlmin[ncut]);
int nl = 0;
int nr = nd-1;
while(nl < nr){
while(nl < nd && zgmid[lod[nl]][ncut] <= zlmid){
nl = nl + 1;
}
while(nr >= 0 && zgmid[lod[nr]][ncut] > zlmid){
nr = nr - 1;
}
if(nl < nr){
int nh = lod[nl];
lod[nl] = lod[nr];
lod[nr] = nh;
}
}
#ifdef DEBUG
fprintf (stdout, "nl = %ld, nr = %ld\n", nl, nr);
assert ( nl-nr == 1 );
// assert ( nl < nd );
#endif
if(nl == nd || nl == 0){
nson = 0;
st_clt = create_cluster(nclst,ndpth,nsrt,nd,ndim,nson);
if(ndpth > depth_max){
depth_max = ndpth;
}
/* nson = 1; */
/* st_clt = create_cluster(nclst,ndpth,nsrt,nd,ndim,nson); */
/* if(ndpth > depth_max){ */
/* depth_max = ndpth; */
/* } */
/* count_node++; */
/* st_clt->pc_sons[0] = create_ctree_ssgeom(st_clt->pc_sons[0],zgmid,param,lod, */
/* ndpth,ndscd,nsrt,nd,md,ndim,nclst); */
}else{
nson = 2;
st_clt = create_cluster(nclst,ndpth,nsrt,nd,ndim,nson);
if(ndpth > depth_max){
depth_max = ndpth;
}
// count_node++;
int nsrt1 = nsrt;
int nd1 = nl;
st_clt->pc_sons[0] = create_ctree_ssgeom(st_clt->pc_sons[0],zgmid,param,lod,
ndpth,ndscd,nsrt1,nd1,md,ndim,nclst);
nsrt1 = nsrt + nl;
nd1 = nd - nl;
st_clt->pc_sons[1] = create_ctree_ssgeom(st_clt->pc_sons[1],zgmid,param,&lod[nl],
ndpth,ndscd,nsrt1,nd1,md,ndim,nclst);
}
}
st_clt->ndscd = nd;
return st_clt;
}
double get_wall_time(){
struct timeval time;
if (gettimeofday(&time,NULL)){
return 0;
}
return (double)time.tv_sec + (double)time.tv_usec * .000001;
}
double get_cpu_time(){
return (double)clock() / CLOCKS_PER_SEC;
}