Fixed use of pow
This commit is contained in:
parent
779aa58900
commit
883d1170e2
@ -9,12 +9,27 @@ using namespace CosmoTool;
|
|||||||
|
|
||||||
//#define VERBOSE
|
//#define VERBOSE
|
||||||
|
|
||||||
|
static uint32_t mypow(uint32_t i, uint32_t p)
|
||||||
|
{
|
||||||
|
if (p == 0)
|
||||||
|
return 1;
|
||||||
|
else if (p == 1)
|
||||||
|
return i;
|
||||||
|
|
||||||
|
uint32_t k = p/2;
|
||||||
|
uint32_t j = mypow(i, k);
|
||||||
|
if (2*k==p)
|
||||||
|
return j*j;
|
||||||
|
else
|
||||||
|
return j*j*i;
|
||||||
|
}
|
||||||
|
|
||||||
OctTree::OctTree(const FCoordinates *particles, octPtr numParticles,
|
OctTree::OctTree(const FCoordinates *particles, octPtr numParticles,
|
||||||
uint32_t maxMeanTreeDepth, uint32_t maxAbsoluteDepth,
|
uint32_t maxMeanTreeDepth, uint32_t maxAbsoluteDepth,
|
||||||
uint32_t threshold)
|
uint32_t threshold)
|
||||||
{
|
{
|
||||||
cout << "MeanTree=" << maxMeanTreeDepth << endl;
|
cout << "MeanTree=" << maxMeanTreeDepth << endl;
|
||||||
numCells = pow(8, maxMeanTreeDepth);
|
numCells = mypow(8, maxMeanTreeDepth);
|
||||||
assert(numCells < invalidOctCell);
|
assert(numCells < invalidOctCell);
|
||||||
//#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
cerr << "Allocating " << numCells << " octtree cells" << endl;
|
cerr << "Allocating " << numCells << " octtree cells" << endl;
|
||||||
|
Loading…
Reference in New Issue
Block a user