enbid-ananke 0.3.0__cp310-cp310-manylinux_2_39_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- .cpython-310-x86_64-linux-gnu.so +0 -0
- enbid_ananke/Enbid-2.0/.DS_Store +0 -0
- enbid_ananke/Enbid-2.0/COPYING +341 -0
- enbid_ananke/Enbid-2.0/COPYRIGHT +18 -0
- enbid_ananke/Enbid-2.0/Documentation/enbid.pdf +0 -0
- enbid_ananke/Enbid-2.0/Documentation/users-guide.pdf +0 -0
- enbid_ananke/Enbid-2.0/Documentation/users-guide.tex +679 -0
- enbid_ananke/Enbid-2.0/Documentation/users-guide.tex.flc +4 -0
- enbid_ananke/Enbid-2.0/Enbid +0 -0
- enbid_ananke/Enbid-2.0/Examples/hernquist1_small/snapshot_ici +0 -0
- enbid_ananke/Enbid-2.0/Examples/hernquist1_small/snapshot_ici_typelist +2 -0
- enbid_ananke/Enbid-2.0/Examples/uniform_6d_box_4/snapshot_ici +0 -0
- enbid_ananke/Enbid-2.0/Examples/uniform_6d_box_4/snapshot_ici_3d.ascii +10000 -0
- enbid_ananke/Enbid-2.0/Examples/uniform_6d_box_4/snapshot_ici_6d.ascii +10000 -0
- enbid_ananke/Enbid-2.0/parameterfiles/myparameterfile1 +37 -0
- enbid_ananke/Enbid-2.0/parameterfiles/myparameterfile2 +37 -0
- enbid_ananke/Enbid-2.0/parameterfiles/myparameterfile3 +37 -0
- enbid_ananke/Enbid-2.0/parameterfiles/myparameterfile4 +37 -0
- enbid_ananke/Enbid-2.0/periodic_lengths.txt +5 -0
- enbid_ananke/Enbid-2.0/src/Makefile +43 -0
- enbid_ananke/Enbid-2.0/src/allocate.cpp +47 -0
- enbid_ananke/Enbid-2.0/src/allocate.o +0 -0
- enbid_ananke/Enbid-2.0/src/allvars.cpp +62 -0
- enbid_ananke/Enbid-2.0/src/allvars.h +263 -0
- enbid_ananke/Enbid-2.0/src/allvars.o +0 -0
- enbid_ananke/Enbid-2.0/src/begrun.cpp +361 -0
- enbid_ananke/Enbid-2.0/src/begrun.o +0 -0
- enbid_ananke/Enbid-2.0/src/density_nd.cpp +130 -0
- enbid_ananke/Enbid-2.0/src/density_nd.o +0 -0
- enbid_ananke/Enbid-2.0/src/functions.cpp +256 -0
- enbid_ananke/Enbid-2.0/src/functions.h +20 -0
- enbid_ananke/Enbid-2.0/src/functions.o +0 -0
- enbid_ananke/Enbid-2.0/src/init.cpp +299 -0
- enbid_ananke/Enbid-2.0/src/init.o +0 -0
- enbid_ananke/Enbid-2.0/src/io.cpp +255 -0
- enbid_ananke/Enbid-2.0/src/io.o +0 -0
- enbid_ananke/Enbid-2.0/src/main.cpp +108 -0
- enbid_ananke/Enbid-2.0/src/main.o +0 -0
- enbid_ananke/Enbid-2.0/src/ngb_search.cpp +2315 -0
- enbid_ananke/Enbid-2.0/src/ngb_search.h +35 -0
- enbid_ananke/Enbid-2.0/src/ngb_search.o +0 -0
- enbid_ananke/Enbid-2.0/src/nr.cpp +186 -0
- enbid_ananke/Enbid-2.0/src/nr.h +13 -0
- enbid_ananke/Enbid-2.0/src/nr.o +0 -0
- enbid_ananke/Enbid-2.0/src/proto.h +22 -0
- enbid_ananke/Enbid-2.0/src/read_ic.cpp +434 -0
- enbid_ananke/Enbid-2.0/src/read_ic.o +0 -0
- enbid_ananke/Enbid-2.0/src/tree.cpp +973 -0
- enbid_ananke/Enbid-2.0/src/tree.h +34 -0
- enbid_ananke/Enbid-2.0/src/tree.o +0 -0
- enbid_ananke/Enbid-2.0/src/tree_search.cpp +597 -0
- enbid_ananke/Enbid-2.0/src/tree_search.o +0 -0
- enbid_ananke/__init__.py +318 -0
- enbid_ananke/__license__/LICENSE +339 -0
- enbid_ananke/__license__/__init__.py +9 -0
- enbid_ananke/__metadata__.py +160 -0
- enbid_ananke/_builtin_utils.py +62 -0
- enbid_ananke/_constants.py +56 -0
- enbid_ananke/_defaults.py +36 -0
- enbid_ananke/_name.py +10 -0
- enbid_ananke/_templates.py +71 -0
- enbid_ananke/_version.py +21 -0
- enbid_ananke/utils.py +11 -0
- enbid_ananke-0.3.0.dist-info/METADATA +44 -0
- enbid_ananke-0.3.0.dist-info/RECORD +68 -0
- enbid_ananke-0.3.0.dist-info/WHEEL +5 -0
- enbid_ananke-0.3.0.dist-info/licenses/LICENSE +339 -0
- enbid_ananke-0.3.0.dist-info/top_level.txt +2 -0
@@ -0,0 +1,973 @@
|
|
1
|
+
/***************************************************************************
|
2
|
+
tree.cpp - description
|
3
|
+
-------------------
|
4
|
+
begin : Mon Jan 16 2006
|
5
|
+
copyright : (C) 2006 by Sanjib Sharma
|
6
|
+
email : ssharma@aip.de
|
7
|
+
***************************************************************************/
|
8
|
+
|
9
|
+
/***************************************************************************
|
10
|
+
* *
|
11
|
+
* This program is free software; you can redistribute it and/or modify *
|
12
|
+
* it under the terms of the GNU General Public License as published by *
|
13
|
+
* the Free Software Foundation; either version 2 of the License, or *
|
14
|
+
* (at your option) any later version. *
|
15
|
+
* *
|
16
|
+
***************************************************************************/
|
17
|
+
#include <stdio.h>
|
18
|
+
#include <stdlib.h>
|
19
|
+
#include <string.h>
|
20
|
+
#include <math.h>
|
21
|
+
#include "allvars.h"
|
22
|
+
#include "tree.h"
|
23
|
+
#include "functions.h"
|
24
|
+
|
25
|
+
#define NULL_N -1
|
26
|
+
// #define real double
|
27
|
+
// #define real1 float
|
28
|
+
|
29
|
+
|
30
|
+
static int numnodestree[150],NumPart1; /* number of (internal) nodes in each tree */
|
31
|
+
static int numnodestotal,nfree1; /* total number of internal nodes */
|
32
|
+
static int MaxNodes; /* maximum allowed number of internal nodes */
|
33
|
+
static int nnodes,pi,rootnode;
|
34
|
+
static int eno;
|
35
|
+
static float **rho,***rhox,***rhov;
|
36
|
+
static real dx[ND];
|
37
|
+
#ifdef PERIODIC
|
38
|
+
static int perbnd[ND];
|
39
|
+
#endif
|
40
|
+
|
41
|
+
/* gives the particle data (starting at offset 0) */
|
42
|
+
|
43
|
+
|
44
|
+
// Create trees for all particle types 0-5, use typelist[6] to control
|
45
|
+
// which particles to be combined if needed for tree generation
|
46
|
+
int treebuild_all(void)
|
47
|
+
{
|
48
|
+
int i, tr;
|
49
|
+
int nfree;
|
50
|
+
int numnodes,startnode;
|
51
|
+
|
52
|
+
startnode=1;
|
53
|
+
// Box= All.BoxSize;
|
54
|
+
// BoxHalf= All.BoxSize/2;
|
55
|
+
nodes= nodes_base-startnode;
|
56
|
+
snodes=snodes_base-startnode;
|
57
|
+
if(All.TypeOfSmoothing==1)
|
58
|
+
pnodes=pnodes_base;
|
59
|
+
|
60
|
+
xnodes= xnodes_base-startnode;
|
61
|
+
numnodestotal=0;
|
62
|
+
pi=0;
|
63
|
+
|
64
|
+
#ifdef PERIODIC
|
65
|
+
for(i=0;i<ND;i++)
|
66
|
+
{
|
67
|
+
if(All.boxh[i]>0)
|
68
|
+
perbnd[i]=1;
|
69
|
+
if(All.boxh[i]<0)
|
70
|
+
perbnd[i]=-1;
|
71
|
+
if(All.boxh[i]==0)
|
72
|
+
perbnd[i]=0;
|
73
|
+
}
|
74
|
+
#endif
|
75
|
+
|
76
|
+
trees.clear();
|
77
|
+
for(i=0;i<int(npart.size());i++)
|
78
|
+
trees.push_back(0);
|
79
|
+
|
80
|
+
|
81
|
+
// 'nfree' gives the next free internal tree node.
|
82
|
+
for(tr=0, nfree=startnode, numnodestotal=0; tr<int(npart.size()); tr++)
|
83
|
+
{
|
84
|
+
if(npart[tr]>0)
|
85
|
+
{
|
86
|
+
trees[tr]= nfree;
|
87
|
+
cout<<"\nParticle Type = "<<tr<<" First node number = "<<nfree<<endl;
|
88
|
+
nfree = treebuild_single(trees[tr], npart,tr, &numnodes);
|
89
|
+
numnodestree[tr]= numnodes;
|
90
|
+
cout<<" Last node number = "<<nfree-1<<endl;
|
91
|
+
}
|
92
|
+
else
|
93
|
+
{
|
94
|
+
trees[tr]= -1;
|
95
|
+
numnodestree[tr]= 0;
|
96
|
+
}
|
97
|
+
}
|
98
|
+
for(i=1;i<nfree;++i)
|
99
|
+
nodes[i].bnd=xnodes+i;
|
100
|
+
|
101
|
+
|
102
|
+
cout<<"Total number of nodes = "<<numnodestotal<<endl;
|
103
|
+
if(All.NodeSplittingCriterion==1)
|
104
|
+
{
|
105
|
+
if(All.CubicCells!=1)
|
106
|
+
{
|
107
|
+
for(int i=0;i<ND;i++)
|
108
|
+
delete [] rho[i];
|
109
|
+
delete [] rho;
|
110
|
+
}
|
111
|
+
|
112
|
+
if(All.CubicCells==1)
|
113
|
+
{
|
114
|
+
// int rows=int(pow(All.MaxPart,0.3333));
|
115
|
+
for(int i=0;i<2;i++)
|
116
|
+
{
|
117
|
+
for(int j=0;j<2;j++)
|
118
|
+
{
|
119
|
+
delete [] rhox[i][j];
|
120
|
+
delete [] rhov[i][j];
|
121
|
+
}
|
122
|
+
delete [] rhox[i];
|
123
|
+
delete [] rhov[i];
|
124
|
+
}
|
125
|
+
delete [] rhox;
|
126
|
+
delete [] rhov;
|
127
|
+
}
|
128
|
+
}
|
129
|
+
|
130
|
+
return numnodestotal;
|
131
|
+
}
|
132
|
+
|
133
|
+
// Create tree starting at index startnode with particles specified in typelist[6]
|
134
|
+
// creates a list of particles with given typelist
|
135
|
+
// and generates a root node for it
|
136
|
+
// output next available free node index, upadate total cumulative number of nodes created
|
137
|
+
// numnodestotal and provide nodes created for this typelist in creatednodes
|
138
|
+
int treebuild_single(int startnode, vector<int> &npart, int type,int *creatednodes)
|
139
|
+
{
|
140
|
+
int i, j,fp,fp1;
|
141
|
+
int nfree, numnodes;
|
142
|
+
real x[ND][2],temp;
|
143
|
+
struct NODE *nfreep; struct SNODE *snfreep; struct XNODE *xnfreep;
|
144
|
+
nnodes= startnode; nfreep= &nodes[nnodes]; snfreep= &snodes[nnodes]; xnfreep= &xnodes[nnodes];
|
145
|
+
nfree=nnodes;
|
146
|
+
/* find first and last particle of this type */
|
147
|
+
for(i=0,fp=0; i<type; i++)
|
148
|
+
fp+=npart[i];
|
149
|
+
fp1=fp+npart[type];
|
150
|
+
NumPart1=npart[type];
|
151
|
+
|
152
|
+
rootnode=nnodes-1;
|
153
|
+
list_kd[fp]=fp;
|
154
|
+
nfreep->count=1;
|
155
|
+
snfreep->lid=fp;
|
156
|
+
nfreep->lid=fp;
|
157
|
+
|
158
|
+
#ifndef MEDIAN
|
159
|
+
nfreep->parent=0;
|
160
|
+
#endif
|
161
|
+
|
162
|
+
/* find enclosing rectangle */
|
163
|
+
for(j=0; j<ND; j++)
|
164
|
+
x[j][0]= x[j][1]= Part[fp].Pos[j];
|
165
|
+
|
166
|
+
|
167
|
+
for(i=fp+1; i<fp1; i++)
|
168
|
+
{
|
169
|
+
list_kd[i]=i;
|
170
|
+
nfreep->count++;
|
171
|
+
for(j=0; j<ND; j++)
|
172
|
+
{
|
173
|
+
if(Part[i].Pos[j]>x[j][1])
|
174
|
+
x[j][1]= Part[i].Pos[j];
|
175
|
+
if(Part[i].Pos[j]<x[j][0])
|
176
|
+
x[j][0]= Part[i].Pos[j];
|
177
|
+
}
|
178
|
+
}
|
179
|
+
|
180
|
+
|
181
|
+
/* determine maxmimum extension */
|
182
|
+
/* if (All.PartBoundary==-1) temp=1e-6;
|
183
|
+
else */
|
184
|
+
// temp=0.5e-6;
|
185
|
+
// temp=0.5/(pow(NumPart1*1.0,1.0/ND)+1);
|
186
|
+
temp=0.5/(NumPart1*1.0-1.0);
|
187
|
+
// temp=2.0;
|
188
|
+
if (All.PartBoundary==0) temp=1.0/(NumPart1*1.0-1.0);
|
189
|
+
|
190
|
+
for(j=0; j<ND; j++)
|
191
|
+
{
|
192
|
+
kbuf[j]=(x[j][1]-x[j][0])*temp;
|
193
|
+
xbmax[j]=x[j][1]+kbuf[j];
|
194
|
+
xbmin[j]=x[j][0]-kbuf[j];
|
195
|
+
#ifdef PERIODIC
|
196
|
+
if(perbnd[j]==0)
|
197
|
+
{
|
198
|
+
if(All.boxh[j]<((xbmax[j]-xbmin[j])*0.5))
|
199
|
+
All.boxh[j]=(xbmax[j]-xbmin[j])*0.5;
|
200
|
+
}
|
201
|
+
if(perbnd[j]==1)
|
202
|
+
{
|
203
|
+
if((2*All.boxh[j])<(xbmax[j]-xbmin[j]-2*kbuf[j]))
|
204
|
+
{
|
205
|
+
cout<<"Specified periodic length in "<<j<<" th dimension is too small"<<endl;
|
206
|
+
cout<<"Try setting it to at least "<<(xbmax[j]-xbmin[j]-2*kbuf[j])*All.hs[j]<<endl;
|
207
|
+
cout<<"Or let it be scaled automatically by setting it to 0.0"<<endl;
|
208
|
+
endrun(10);
|
209
|
+
}
|
210
|
+
}
|
211
|
+
if(perbnd[j]==(-1))
|
212
|
+
{
|
213
|
+
if(All.boxh[j]<((xbmax[j]-xbmin[j])*100))
|
214
|
+
All.boxh[j]=(xbmax[j]-xbmin[j])*100;
|
215
|
+
|
216
|
+
}
|
217
|
+
#endif
|
218
|
+
|
219
|
+
}
|
220
|
+
|
221
|
+
/* create a root node and insert first particle of correct type as its leaf */
|
222
|
+
for(j=0; j<ND; j++)
|
223
|
+
{
|
224
|
+
xnfreep->x[j][1]=xbmax[j];
|
225
|
+
xnfreep->x[j][0]=xbmin[j];
|
226
|
+
snfreep->bleft[j]=1;
|
227
|
+
snfreep->bright[j]=1;
|
228
|
+
}
|
229
|
+
|
230
|
+
|
231
|
+
snfreep->k0=ND;
|
232
|
+
|
233
|
+
numnodes=numnodestotal;
|
234
|
+
numnodestotal++;
|
235
|
+
nfree1=nfree;
|
236
|
+
treebuild(nfree);
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
if(numnodestotal>=MaxNodes)
|
241
|
+
{
|
242
|
+
printf("maximum number %d of tree-nodes reached. \n", numnodestotal);
|
243
|
+
printf("for particle %d\n", fp);
|
244
|
+
endrun(1);
|
245
|
+
}
|
246
|
+
*creatednodes= numnodestotal-numnodes;
|
247
|
+
|
248
|
+
i=1;j=1;
|
249
|
+
while(i<nfreep->count)
|
250
|
+
{
|
251
|
+
i=i<<1;
|
252
|
+
j=j+i;
|
253
|
+
}
|
254
|
+
|
255
|
+
// return nfree+numnodestotal-numnodes;
|
256
|
+
// return nfree+j;
|
257
|
+
return nfree1+1;
|
258
|
+
}
|
259
|
+
|
260
|
+
|
261
|
+
// Recursive routine to create a tree from an existing node
|
262
|
+
// needs strctures nodes,snodes,xnodees,pnodes and arrays list,list_kdt and father
|
263
|
+
void treebuild(int startnode)
|
264
|
+
{
|
265
|
+
int i,j,k,l,ii,jl,jr,jmin,jmax,nfree;
|
266
|
+
int pleft=0,pright=0,ks=0,k00,left,right;
|
267
|
+
real kmean[ND],ksig[ND],kmax[ND],kmin[ND],m_tot;//,kmax1[ND],kmin1[ND];
|
268
|
+
real kleft,kright,kcut,smin,smax;
|
269
|
+
real ex=0,ev=0,e[ND];
|
270
|
+
real temp=0.0,temp1=0.0,temp2=0.0,temp3=0.0;
|
271
|
+
struct NODE *nfreep,*nfreepl,*nfreepr; struct SNODE *snfreep,*snfreepl,*snfreepr;
|
272
|
+
struct XNODE *xnfreep,*xnfreepl,*xnfreepr;
|
273
|
+
// struct PNODE *pnfreep;
|
274
|
+
nfree= startnode;
|
275
|
+
nfreep= &nodes[nfree]; snfreep= &snodes[nfree]; xnfreep= &xnodes[nfree];
|
276
|
+
// if(All.TypeOfSmoothing==1)
|
277
|
+
// pnfreep= &pnodes[nfree];
|
278
|
+
|
279
|
+
// nfree= startnode-rootnode;
|
280
|
+
// cout<<startnode<<" "<<nfree<<endl;
|
281
|
+
|
282
|
+
/* Calculate kmin.kmax,kmean */
|
283
|
+
/*Check if leaf or not */
|
284
|
+
if(nfreep->count > 1)
|
285
|
+
{
|
286
|
+
|
287
|
+
#ifndef MEDIAN
|
288
|
+
numnodestotal+=2;
|
289
|
+
#endif
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
for(j=0; j<ND; j++)
|
294
|
+
{
|
295
|
+
ksig[j] =0;
|
296
|
+
kmean[j]=0;
|
297
|
+
}
|
298
|
+
|
299
|
+
if(All.PartBoundary>1)
|
300
|
+
{
|
301
|
+
i=list_kd[snfreep->lid];
|
302
|
+
for(j=0; j<ND; j++)
|
303
|
+
{
|
304
|
+
kmin[j]=Part[i].Pos[j];
|
305
|
+
kmax[j]=Part[i].Pos[j];
|
306
|
+
}
|
307
|
+
}
|
308
|
+
|
309
|
+
for(ii=0,m_tot=0;ii<nfreep->count;ii++)
|
310
|
+
{
|
311
|
+
i=list_kd[snfreep->lid+ii];
|
312
|
+
for(j=0; j<ND; j++)
|
313
|
+
{
|
314
|
+
kmean[j]+=Part[i].Pos[j];
|
315
|
+
}
|
316
|
+
m_tot+=Part[i].Mass;
|
317
|
+
// if(All.PartBoundary>1)
|
318
|
+
for(j=0; j<ND; j++)
|
319
|
+
{
|
320
|
+
if(kmin[j]>=Part[i].Pos[j])
|
321
|
+
kmin[j]=Part[i].Pos[j];
|
322
|
+
if(kmax[j]<=Part[i].Pos[j])
|
323
|
+
kmax[j]=Part[i].Pos[j];
|
324
|
+
}
|
325
|
+
}
|
326
|
+
|
327
|
+
for(j=0; j<ND; j++)
|
328
|
+
kmean[j]=kmean[j]/nfreep->count;
|
329
|
+
|
330
|
+
|
331
|
+
// new boundary here
|
332
|
+
/* Apply Boundary condition */
|
333
|
+
|
334
|
+
|
335
|
+
if((All.PartBoundary>1)&&(nfreep->count>=All.PartBoundary))
|
336
|
+
{
|
337
|
+
// decrease temp to correct underestimation in outer parts
|
338
|
+
// decrease temp1 to correct underestimation in inner parts
|
339
|
+
if(All.CubicCells)
|
340
|
+
{
|
341
|
+
temp=2.5*pow(NumPart1,1.0/ND);temp2=1.0*temp/5; temp3=2.0;
|
342
|
+
}
|
343
|
+
else
|
344
|
+
{
|
345
|
+
temp=10*pow(NumPart1,1.0/ND); temp2=1.0*temp/5; temp3=2.0;
|
346
|
+
|
347
|
+
}
|
348
|
+
|
349
|
+
for(j=0;j<ND;j++)
|
350
|
+
{
|
351
|
+
|
352
|
+
#ifdef PERIODIC
|
353
|
+
if(perbnd[j]<0)
|
354
|
+
{
|
355
|
+
#endif
|
356
|
+
|
357
|
+
if((kmax[j]-kmin[j])/(xnfreep->x[j][1]-xnfreep->x[j][0])> 1.0/NumPart1)
|
358
|
+
{
|
359
|
+
|
360
|
+
temp1=(kmax[j]-kmin[j])/(nfreep->count-1);
|
361
|
+
if(((xnfreep->x[j][1]-kmax[j])>(temp2*temp1))&&((kmin[j]-xnfreep->x[j][0])>(temp2*temp1)))
|
362
|
+
{
|
363
|
+
xnfreep->x[j][1]=kmax[j]+temp3*temp1;
|
364
|
+
xnfreep->x[j][0]=kmin[j]-temp3*temp1;
|
365
|
+
}
|
366
|
+
else
|
367
|
+
{
|
368
|
+
if((xnfreep->x[j][1]-kmax[j])>(temp*temp1))
|
369
|
+
xnfreep->x[j][1]=kmax[j]+temp3*temp1;
|
370
|
+
if((kmin[j]-xnfreep->x[j][0])>(temp*temp1))
|
371
|
+
xnfreep->x[j][0]=kmin[j]-temp3*temp1;
|
372
|
+
}
|
373
|
+
|
374
|
+
}
|
375
|
+
#ifdef PERIODIC
|
376
|
+
}
|
377
|
+
#endif
|
378
|
+
|
379
|
+
|
380
|
+
}
|
381
|
+
}
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
|
386
|
+
/** Calculate the entropy */
|
387
|
+
if((All.NodeSplittingCriterion==1)&&(All.CubicCells==1))
|
388
|
+
if(ND > 3)
|
389
|
+
{
|
390
|
+
|
391
|
+
eno=int(pow(nfreep->count,0.333));
|
392
|
+
// eno=int(pow(eno*1.0,0.333));
|
393
|
+
if(nfreep->count<=8)
|
394
|
+
eno=2;
|
395
|
+
|
396
|
+
for(i=0;i<eno;i++)
|
397
|
+
for(j=0;j<eno;j++)
|
398
|
+
for(k=0;k<eno;k++)
|
399
|
+
{
|
400
|
+
rhox[i][j][k]=0;
|
401
|
+
rhov[i][j][k]=0;
|
402
|
+
}
|
403
|
+
for(j=0;j<ND;j++)
|
404
|
+
dx[j]=(xnfreep->x[j][1]-xnfreep->x[j][0])/eno;
|
405
|
+
// cout<<nfree<<" "<<nfreep->count<<" "<<snfreep->ex<<" "<<snfreep->ev<<endl;
|
406
|
+
for(ii=0;ii<nfreep->count;ii++)
|
407
|
+
{
|
408
|
+
i=list_kd[snfreep->lid+ii];
|
409
|
+
j=int((Part[i].Pos[0]-xnfreep->x[0][0])/dx[0]);
|
410
|
+
k=int((Part[i].Pos[1]-xnfreep->x[1][0])/dx[1]);
|
411
|
+
l=int((Part[i].Pos[2]-xnfreep->x[2][0])/dx[2]);
|
412
|
+
rhox[j][k][l]+=Part[i].Mass;
|
413
|
+
j=int((Part[i].Pos[3]-xnfreep->x[3][0])/dx[3]);
|
414
|
+
k=int((Part[i].Pos[4]-xnfreep->x[4][0])/dx[4]);
|
415
|
+
l=int((Part[i].Pos[5]-xnfreep->x[5][0])/dx[5]);
|
416
|
+
rhov[j][k][l]+=Part[i].Mass;
|
417
|
+
// cout<<j<<" "<<k<<" "<<l<<" rhov="<<rhov[j][k][l]<<" ii="<<ii<<" en="<<eno<<endl;
|
418
|
+
}
|
419
|
+
|
420
|
+
ex=0;ev=0;
|
421
|
+
for(i=0;i<eno;i++)
|
422
|
+
for(j=0;j<eno;j++)
|
423
|
+
for(k=0;k<eno;k++)
|
424
|
+
{
|
425
|
+
if(rhox[i][j][k]>0)
|
426
|
+
{
|
427
|
+
rhox[i][j][k]/=m_tot;
|
428
|
+
ex-=rhox[i][j][k]*log10(rhox[i][j][k]);
|
429
|
+
}
|
430
|
+
if(rhov[i][j][k]>0)
|
431
|
+
{
|
432
|
+
rhov[i][j][k]/=m_tot;
|
433
|
+
ev-=rhov[i][j][k]*log10(rhov[i][j][k]);
|
434
|
+
}
|
435
|
+
}
|
436
|
+
}
|
437
|
+
|
438
|
+
|
439
|
+
/* choose the splitting dimension */
|
440
|
+
if((All.NodeSplittingCriterion==1)&&(All.CubicCells!=1))
|
441
|
+
{
|
442
|
+
eno=nfreep->count;
|
443
|
+
for(j=0;j<ND;j++)
|
444
|
+
for(k=0;k<eno;k++)
|
445
|
+
rho[j][k]=0;
|
446
|
+
|
447
|
+
for(j=0;j<ND;j++)
|
448
|
+
dx[j]=(xnfreep->x[j][1]-xnfreep->x[j][0])/eno;
|
449
|
+
|
450
|
+
|
451
|
+
for(ii=0;ii<nfreep->count;ii++)
|
452
|
+
{
|
453
|
+
i=list_kd[snfreep->lid+ii];
|
454
|
+
for(j=0;j<ND;j++)
|
455
|
+
{
|
456
|
+
k=int((Part[i].Pos[j]-xnfreep->x[j][0])/dx[j]);
|
457
|
+
rho[j][k]+=Part[i].Mass;
|
458
|
+
}
|
459
|
+
}
|
460
|
+
for(j=0;j<ND;j++)
|
461
|
+
e[j]=0;
|
462
|
+
for(k=0;k<eno;k++)
|
463
|
+
{
|
464
|
+
for(j=0;j<ND;j++)
|
465
|
+
{
|
466
|
+
if(rho[j][k]>0)
|
467
|
+
{
|
468
|
+
rho[j][k]/=m_tot;
|
469
|
+
e[j]-=rho[j][k]*log10(rho[j][k]);
|
470
|
+
}
|
471
|
+
}
|
472
|
+
}
|
473
|
+
|
474
|
+
}
|
475
|
+
|
476
|
+
|
477
|
+
|
478
|
+
|
479
|
+
for(ii=0;ii<nfreep->count;ii++)
|
480
|
+
{
|
481
|
+
i=list_kd[snfreep->lid+ii];
|
482
|
+
for(j=0; j<ND; j++)
|
483
|
+
{
|
484
|
+
ksig[j]+=(Part[i].Pos[j]-kmean[j])*(Part[i].Pos[j]-kmean[j]);
|
485
|
+
}
|
486
|
+
|
487
|
+
}
|
488
|
+
|
489
|
+
for(j=0; j<ND; j++)
|
490
|
+
ksig[j]=ksig[j]/nfreep->count;
|
491
|
+
|
492
|
+
|
493
|
+
//! check for spurious entropy of lattice like systems
|
494
|
+
if((All.NodeSplittingCriterion==1)&&(All.CubicCells==1))
|
495
|
+
{
|
496
|
+
jmin=0; jmax=3;
|
497
|
+
|
498
|
+
if(ND >3)
|
499
|
+
{
|
500
|
+
|
501
|
+
for(j=0,temp1=1.0;j<3;j++)
|
502
|
+
temp1*=((kmax[j]-kmin[j])/dx[j]);
|
503
|
+
for(j=3,temp2=1.0;j<6;j++)
|
504
|
+
temp2*=((kmax[j]-kmin[j])/dx[j]);
|
505
|
+
|
506
|
+
if(nfreep->count<=2)
|
507
|
+
{temp1=2;temp2=2;}
|
508
|
+
if((temp1<1)&&(temp2<1))
|
509
|
+
if(snfreep->k0 < 3){jmin=3;jmax=ND;}
|
510
|
+
|
511
|
+
if((temp1>=1)&&(temp2>=1))
|
512
|
+
{
|
513
|
+
if(ev==ex)
|
514
|
+
{
|
515
|
+
if(snfreep->k0 < 3)
|
516
|
+
{
|
517
|
+
jmin=3; jmax=ND;
|
518
|
+
}
|
519
|
+
}
|
520
|
+
else
|
521
|
+
{
|
522
|
+
if(ev<ex)
|
523
|
+
{
|
524
|
+
jmin=3;
|
525
|
+
jmax=ND;
|
526
|
+
}
|
527
|
+
}
|
528
|
+
}
|
529
|
+
if((temp2>=1)&&(temp1<1))
|
530
|
+
{jmin=3;jmax=ND;}
|
531
|
+
}
|
532
|
+
|
533
|
+
|
534
|
+
for(j=jmin,smin=0.0,smax=ksig[jmin]; j<jmax; j++)
|
535
|
+
{
|
536
|
+
if(ksig[j]>=smax)
|
537
|
+
{
|
538
|
+
smax=ksig[j]; ks=j;
|
539
|
+
}
|
540
|
+
}
|
541
|
+
}
|
542
|
+
if((All.NodeSplittingCriterion==1)&&(All.CubicCells!=1))
|
543
|
+
{
|
544
|
+
if(nfreep->count>=2)
|
545
|
+
{
|
546
|
+
jmax=0;smin=-log10(1.0/nfreep->count);
|
547
|
+
for(j=0; j<ND; j++)
|
548
|
+
{
|
549
|
+
if((kmax[j]-kmin[j])/(xnfreep->x[j][1]-xnfreep->x[j][0])>=eno*0.01/NumPart1)
|
550
|
+
{
|
551
|
+
if((e[j]==smin)&&(snfreep->k0==ks)) {smin=e[j]; ks=j;temp1=temp1+1;}
|
552
|
+
if(e[j]<smin) {smin=e[j]; ks=j;}
|
553
|
+
jmax=1;
|
554
|
+
}
|
555
|
+
// else
|
556
|
+
// cout<<" Lattice like structure or sparsely populated node, Check parameter PartBoundary "<<nfree<<" "<<j<<" "<<nfreep->count<<" "<<(kmax[j]-kmin[j])/(xnfreep->x[j][1]-xnfreep->x[j][0])<<endl;
|
557
|
+
|
558
|
+
}
|
559
|
+
|
560
|
+
if(jmax==0)
|
561
|
+
{
|
562
|
+
cout<<" Warning:Lattice like structure or sparsely populated node, Check parameter PartBoundary "<<nfree<<" "<<j<<" "<<nfreep->count<<" "<<smin<<endl;
|
563
|
+
k00=1+int(drand48()*ND);
|
564
|
+
while(k00==ND) k00=1+int(drand48()*ND);
|
565
|
+
ks=(snfreep->k0+k00)%ND;
|
566
|
+
}
|
567
|
+
}
|
568
|
+
else
|
569
|
+
{
|
570
|
+
ks=(snfreep->k0+1)%ND;
|
571
|
+
}
|
572
|
+
}
|
573
|
+
|
574
|
+
if(All.NodeSplittingCriterion==0)
|
575
|
+
{
|
576
|
+
if(All.CubicCells==1)
|
577
|
+
{
|
578
|
+
jmin=0;jmax=3;
|
579
|
+
if((ND>3)&&(snfreep->k0 < 3))
|
580
|
+
{ jmin=3;jmax=ND;}
|
581
|
+
for(j=jmin,smin=0.0,smax=ksig[jmin]; j<jmax; j++)
|
582
|
+
{
|
583
|
+
if(ksig[j]>=smax)
|
584
|
+
{ smax=ksig[j]; ks=j; }
|
585
|
+
}
|
586
|
+
}
|
587
|
+
if(All.CubicCells!=1)
|
588
|
+
{
|
589
|
+
ks=(snfreep->k0+1)%ND;
|
590
|
+
// cout<<snfreep->k0<<" "<<ks<<" "<<(snfreep->k0+1)%ND-1<<endl;
|
591
|
+
}
|
592
|
+
|
593
|
+
|
594
|
+
}
|
595
|
+
|
596
|
+
// old boundary here
|
597
|
+
|
598
|
+
|
599
|
+
int jj=0;
|
600
|
+
jl=-1;
|
601
|
+
jr=nfreep->count;
|
602
|
+
while((jl==-1)||(jr==nfreep->count))
|
603
|
+
{
|
604
|
+
|
605
|
+
k=ks;
|
606
|
+
|
607
|
+
|
608
|
+
/* Calculate kcut */
|
609
|
+
if(All.MedianSplittingOn==1)
|
610
|
+
{
|
611
|
+
for(ii=0;ii<nfreep->count;ii++)
|
612
|
+
{
|
613
|
+
i=list_kd[snfreep->lid+ii];
|
614
|
+
listr[snfreep->lid+ii]=Part[i].Pos[k];
|
615
|
+
}
|
616
|
+
float *lr;
|
617
|
+
int * li;
|
618
|
+
lr=listr+snfreep->lid-1;
|
619
|
+
li=list_kd+snfreep->lid-1;
|
620
|
+
sort2(nfreep->count,lr,li);
|
621
|
+
jl=nfreep->count/2; jr=jl+1;
|
622
|
+
kleft=*(lr+jl); kright=*(lr+jr);
|
623
|
+
jl--;jr--;
|
624
|
+
}
|
625
|
+
else
|
626
|
+
{
|
627
|
+
kleft =xnfreep->x[k][0];
|
628
|
+
kright=xnfreep->x[k][1];
|
629
|
+
|
630
|
+
for(ii=0,jl=-1,jr=nfreep->count;ii<nfreep->count;ii++)
|
631
|
+
{
|
632
|
+
i=list_kd[snfreep->lid+ii];
|
633
|
+
if(Part[i].Pos[k]<= kmean[k])
|
634
|
+
{
|
635
|
+
if(Part[i].Pos[k] >= kleft)
|
636
|
+
{
|
637
|
+
kleft=Part[i].Pos[k];
|
638
|
+
pleft=i;
|
639
|
+
}
|
640
|
+
list_kdt[++jl]=i;
|
641
|
+
}
|
642
|
+
else
|
643
|
+
{
|
644
|
+
if(Part[i].Pos[k]<= kright)
|
645
|
+
{
|
646
|
+
kright=Part[i].Pos[k];
|
647
|
+
pright=i;
|
648
|
+
}
|
649
|
+
list_kdt[--jr]=i;
|
650
|
+
}
|
651
|
+
}
|
652
|
+
|
653
|
+
|
654
|
+
}
|
655
|
+
//------------------------------------------------------
|
656
|
+
|
657
|
+
|
658
|
+
if(jl==-1)
|
659
|
+
{
|
660
|
+
//corrected 2007 Jan 11
|
661
|
+
// i=pright;
|
662
|
+
i=list_kdt[jr];
|
663
|
+
cout<<"particles too close left par no = 0 "<<k<<" "<<numnodestotal<<" "<<kmean[k]<<" "<<kleft<<" "<<nfreep->count<<endl;
|
664
|
+
if(jj==ND)
|
665
|
+
{
|
666
|
+
#ifdef WARN
|
667
|
+
checkrun("Particles have identical co-ordinates","exit","correct it");
|
668
|
+
#else
|
669
|
+
cout<<"Particles have identical co-ordinates correcting it"<<endl;
|
670
|
+
#endif
|
671
|
+
// bug fixed
|
672
|
+
Part[i].Pos[k]=xnfreep->x[k][0]+(kmean[k]-xnfreep->x[k][0])/2.0;
|
673
|
+
kleft=Part[i].Pos[k];
|
674
|
+
jl++;
|
675
|
+
jr++;
|
676
|
+
}
|
677
|
+
else
|
678
|
+
ks=(ks+1)%ND;
|
679
|
+
|
680
|
+
}
|
681
|
+
|
682
|
+
if(jr==nfreep->count)
|
683
|
+
{
|
684
|
+
//corrected 2007 Jan 11
|
685
|
+
// i=pleft;
|
686
|
+
i=list_kdt[jl];
|
687
|
+
|
688
|
+
cout<<"particles too close right par no = 0 "<<k<<" "<<numnodestotal<<" "<<kmean[k]<<" "<<kleft<<" "<<nfreep->count<<endl;
|
689
|
+
if(jj==ND)
|
690
|
+
{
|
691
|
+
#ifdef WARN
|
692
|
+
checkrun("WARNING! Particles have identical co-ordinates","exit","correct it");
|
693
|
+
#else
|
694
|
+
cout<<"Particles have identical co-ordinates correcting it"<<endl;
|
695
|
+
#endif
|
696
|
+
// bug fixed
|
697
|
+
Part[i].Pos[k]=xnfreep->x[k][1]-(xnfreep->x[k][1]-kmean[k])/2.0;
|
698
|
+
kright=Part[i].Pos[k];
|
699
|
+
jr--;
|
700
|
+
jl--;
|
701
|
+
}
|
702
|
+
else
|
703
|
+
ks=(ks+1)%ND;
|
704
|
+
|
705
|
+
}
|
706
|
+
|
707
|
+
jj++;
|
708
|
+
}
|
709
|
+
|
710
|
+
|
711
|
+
if(All.MedianSplittingOn!=1)
|
712
|
+
for(ii=0;ii<nfreep->count;ii++)
|
713
|
+
list_kd[snfreep->lid+ii]=list_kdt[ii];
|
714
|
+
|
715
|
+
|
716
|
+
|
717
|
+
kcut=(kleft+kright)/2.0;
|
718
|
+
|
719
|
+
// cout<<nfree<<" "<<ks<<" "<<kcut<<nfreep->count<<" "<<ev<<" "<<ex<<endl;
|
720
|
+
|
721
|
+
/* create and update the left right nodes */
|
722
|
+
nfreep->kcut=kcut;
|
723
|
+
nfreep->k1=k;
|
724
|
+
|
725
|
+
|
726
|
+
|
727
|
+
|
728
|
+
|
729
|
+
#ifdef MEDIAN
|
730
|
+
left= LOWER(nfree,nodes1)+rootnode;
|
731
|
+
right = UPPER(nfree,nodes1)+rootnode;
|
732
|
+
#else
|
733
|
+
++nnodes;left= nnodes;
|
734
|
+
nfreep->left= left-rootnode;
|
735
|
+
++nnodes;right = nnodes;
|
736
|
+
#endif
|
737
|
+
nfreepl=&nodes[left]; snfreepl=&snodes[left]; xnfreepl=&xnodes[left];
|
738
|
+
nfreepr=&nodes[right]; snfreepr=&snodes[right]; xnfreepr=&xnodes[right];
|
739
|
+
|
740
|
+
|
741
|
+
if(nfree1<right) nfree1=right;
|
742
|
+
#ifdef MEDIAN
|
743
|
+
numnodestotal=nfree1;
|
744
|
+
#endif
|
745
|
+
|
746
|
+
for(j=0;j<ND;j++)
|
747
|
+
{
|
748
|
+
if(j==k)
|
749
|
+
{
|
750
|
+
xnfreepl->x[j][1]=kcut;
|
751
|
+
xnfreepl->x[j][0]=xnfreep->x[j][0];
|
752
|
+
xnfreepr->x[j][1]=xnfreep->x[j][1];
|
753
|
+
xnfreepr->x[j][0]=kcut;
|
754
|
+
snfreepl->bright[j]=0;
|
755
|
+
snfreepl->bleft[j]=snfreep->bleft[j];
|
756
|
+
snfreepr->bleft[j]=0;
|
757
|
+
snfreepr->bright[j]=snfreep->bright[j];
|
758
|
+
}
|
759
|
+
else
|
760
|
+
{
|
761
|
+
xnfreepl->x[j][1]=xnfreep->x[j][1];
|
762
|
+
xnfreepl->x[j][0]=xnfreep->x[j][0];
|
763
|
+
xnfreepr->x[j][1]=xnfreep->x[j][1];
|
764
|
+
xnfreepr->x[j][0]=xnfreep->x[j][0];
|
765
|
+
snfreepl->bleft[j] =snfreep->bleft[j];
|
766
|
+
snfreepl->bright[j]=snfreep->bright[j];
|
767
|
+
snfreepr->bright[j]=snfreep->bright[j];
|
768
|
+
snfreepr->bleft[j] =snfreep->bleft[j];
|
769
|
+
}
|
770
|
+
}
|
771
|
+
snfreepl->k0=k;
|
772
|
+
snfreepr->k0=k;
|
773
|
+
|
774
|
+
|
775
|
+
#ifndef MEDIAN
|
776
|
+
{
|
777
|
+
nfreepl->left=NULL_N;
|
778
|
+
nfreepr->left=NULL_N;
|
779
|
+
nfreepl->parent=nfree-rootnode;
|
780
|
+
nfreepr->parent=nfree-rootnode;
|
781
|
+
}
|
782
|
+
#endif
|
783
|
+
snfreepl->lid=snfreep->lid;
|
784
|
+
snfreepr->lid=snfreep->lid+jl+1;
|
785
|
+
|
786
|
+
nfreepl->lid=snfreep->lid;
|
787
|
+
nfreepr->lid=snfreep->lid+jl+1;
|
788
|
+
|
789
|
+
nfreepl->count=jl+1;
|
790
|
+
nfreepr->count=nfreep->count-jl-1;
|
791
|
+
treebuild(left);
|
792
|
+
treebuild(right);
|
793
|
+
}
|
794
|
+
else
|
795
|
+
{
|
796
|
+
/* if leaf wind up */
|
797
|
+
nfreep->kcut=0.0;
|
798
|
+
i=list_kd[snfreep->lid];
|
799
|
+
|
800
|
+
if(All.PartBoundary==1)
|
801
|
+
for(j=0; j<ND; j++)
|
802
|
+
{
|
803
|
+
#ifdef PERIODIC
|
804
|
+
if(perbnd[j]<0)
|
805
|
+
{
|
806
|
+
#endif
|
807
|
+
if(snfreep->bright[j]==1)
|
808
|
+
xnfreep->x[j][1]=Part[i].Pos[j]+(Part[i].Pos[j]-xnfreep->x[j][0]);
|
809
|
+
if(snfreep->bleft[j]==1)
|
810
|
+
xnfreep->x[j][0]=Part[i].Pos[j]-(xnfreep->x[j][1]-Part[i].Pos[j]);
|
811
|
+
#ifdef PERIODIC
|
812
|
+
}
|
813
|
+
#endif
|
814
|
+
}
|
815
|
+
|
816
|
+
if(All.TypeOfSmoothing==1)
|
817
|
+
for(j=0;j<ND;j++)
|
818
|
+
{
|
819
|
+
pnodes[pi].x[j][0]=xnfreep->x[j][0]; pnodes[pi].x[j][1]=xnfreep->x[j][1];
|
820
|
+
}
|
821
|
+
nfreep->k1=pi; pi++;
|
822
|
+
|
823
|
+
}
|
824
|
+
}
|
825
|
+
|
826
|
+
|
827
|
+
// Allocate memory
|
828
|
+
void treeallocate(int maxpart) /* for median maxnodes=4*maxpart is sufficient */
|
829
|
+
{
|
830
|
+
int bytes=0,i,j,rows;
|
831
|
+
float allbytes=0;
|
832
|
+
#ifdef MEDIAN
|
833
|
+
MaxNodes=4*maxpart;
|
834
|
+
#else
|
835
|
+
MaxNodes=2*maxpart;
|
836
|
+
#endif
|
837
|
+
|
838
|
+
if(!(list_kd=new int4byte[maxpart]))
|
839
|
+
{
|
840
|
+
fprintf(stdout,"Failed to allocate %d spaces for 'list' array (%d bytes)\n", maxpart, bytes);
|
841
|
+
exit(0);
|
842
|
+
}
|
843
|
+
allbytes+=maxpart*sizeof(int4byte);
|
844
|
+
|
845
|
+
if(!(list_kdt=new int4byte[maxpart]))
|
846
|
+
{
|
847
|
+
fprintf(stdout,"Failed to allocate %d spaces for 'list_kdt' array (%d bytes)\n", maxpart, bytes);
|
848
|
+
exit(0);
|
849
|
+
}
|
850
|
+
allbytes+=maxpart*sizeof(int4byte);
|
851
|
+
|
852
|
+
|
853
|
+
if(!(nodes_base=new NODE[MaxNodes+1]))
|
854
|
+
{
|
855
|
+
printf("failed to allocate memory for %d tree-nodes (%d bytes).\n", MaxNodes, bytes);
|
856
|
+
endrun(3);
|
857
|
+
}
|
858
|
+
allbytes+=MaxNodes*sizeof(struct NODE);
|
859
|
+
|
860
|
+
|
861
|
+
if(!(xnodes_base=new XNODE[MaxNodes+1]))
|
862
|
+
{
|
863
|
+
printf("failed to allocate memory for %d tree-nodes (%d bytes).\n", MaxNodes, bytes);
|
864
|
+
endrun(3);
|
865
|
+
}
|
866
|
+
allbytes+=MaxNodes*sizeof(struct XNODE);
|
867
|
+
|
868
|
+
|
869
|
+
if(!(snodes_base=new SNODE[MaxNodes+1]))
|
870
|
+
{
|
871
|
+
printf("failed to allocate memory for %d tree-nodes (%d bytes).\n", MaxNodes, bytes);
|
872
|
+
endrun(3);
|
873
|
+
}
|
874
|
+
allbytes+=MaxNodes*sizeof(struct SNODE);
|
875
|
+
|
876
|
+
|
877
|
+
if(All.TypeOfSmoothing==1)
|
878
|
+
{
|
879
|
+
if(!(pnodes_base=new PNODE[maxpart+1]))
|
880
|
+
{
|
881
|
+
printf("failed to allocate memory for %d tree-nodes (%d bytes).\n", MaxNodes, bytes);
|
882
|
+
endrun(3);
|
883
|
+
}
|
884
|
+
allbytes+=maxpart*sizeof(struct PNODE);
|
885
|
+
}
|
886
|
+
|
887
|
+
if(All.NodeSplittingCriterion==1)
|
888
|
+
{
|
889
|
+
if(All.CubicCells!=1)
|
890
|
+
{
|
891
|
+
rho=new float* [ND];
|
892
|
+
for(i=0;i<ND;i++)
|
893
|
+
if(!(rho[i]=new float [maxpart]))
|
894
|
+
{
|
895
|
+
fprintf(stdout,"Failed to allocate %d spaces for 'entropy' bins (%d bytes)\n", maxpart, bytes);
|
896
|
+
exit(0);
|
897
|
+
}
|
898
|
+
allbytes+=maxpart*ND*sizeof(float);
|
899
|
+
}
|
900
|
+
|
901
|
+
if(All.CubicCells==1)
|
902
|
+
{
|
903
|
+
rows=int(pow(maxpart,0.3333));
|
904
|
+
rhox=new float** [rows];
|
905
|
+
for(i=0;i<rows;i++)
|
906
|
+
if(!(rhox[i]=new float* [rows]))
|
907
|
+
{
|
908
|
+
fprintf(stdout,"Failed to allocate %d spaces for 'entropy' bins (%d bytes)\n", maxpart, bytes);
|
909
|
+
exit(0);
|
910
|
+
}
|
911
|
+
else
|
912
|
+
{
|
913
|
+
for(j=0;j<rows;j++)
|
914
|
+
if(!(rhox[i][j]=new float [rows]))
|
915
|
+
{
|
916
|
+
fprintf(stdout,"Failed to allocate %d spaces for 'entropy' bins (%d bytes)\n", maxpart, bytes);
|
917
|
+
exit(0);
|
918
|
+
}
|
919
|
+
}
|
920
|
+
allbytes+=rows*rows*rows*sizeof(float);
|
921
|
+
|
922
|
+
rhov=new float** [rows];
|
923
|
+
for(i=0;i<rows;i++)
|
924
|
+
if(!(rhov[i]=new float* [rows]))
|
925
|
+
{
|
926
|
+
fprintf(stdout,"Failed to allocate %d spaces for 'entropy' bins (%d bytes)\n", maxpart, bytes);
|
927
|
+
exit(0);
|
928
|
+
}
|
929
|
+
else
|
930
|
+
{
|
931
|
+
for(j=0;j<rows;j++)
|
932
|
+
if(!(rhov[i][j]=new float [rows]))
|
933
|
+
{
|
934
|
+
fprintf(stdout,"Failed to allocate %d spaces for 'entropy' bins (%d bytes)\n", maxpart, bytes);
|
935
|
+
exit(0);
|
936
|
+
}
|
937
|
+
}
|
938
|
+
allbytes+=rows*rows*rows*sizeof(float);
|
939
|
+
}
|
940
|
+
}
|
941
|
+
|
942
|
+
if(!(listr=new float[maxpart]))
|
943
|
+
{
|
944
|
+
fprintf(stdout,"Failed to allocate %d spaces for 'list' array (%d bytes)\n", maxpart, bytes);
|
945
|
+
exit(0);
|
946
|
+
}
|
947
|
+
allbytes+=maxpart*sizeof(float);
|
948
|
+
|
949
|
+
// cout<<" a "<<maxpart<<MaxNodes<<endl;
|
950
|
+
|
951
|
+
|
952
|
+
|
953
|
+
|
954
|
+
printf("Allocated %g MByte for Binary-Tree and Entropy bins.\n\n",allbytes/(1024.0*1024.0));
|
955
|
+
// cout<<MaxNodes<<" "<<maxpart<<endl;
|
956
|
+
|
957
|
+
}
|
958
|
+
|
959
|
+
|
960
|
+
// free the allocated memory
|
961
|
+
void treefree(void)
|
962
|
+
{
|
963
|
+
delete [] nodes_base;
|
964
|
+
delete [] snodes_base;
|
965
|
+
delete [] xnodes_base;
|
966
|
+
delete [] list_kd;
|
967
|
+
delete [] list_kdt;
|
968
|
+
delete [] listr;
|
969
|
+
delete [] pnodes_base;
|
970
|
+
}
|
971
|
+
|
972
|
+
|
973
|
+
|