Fixed test. Compilation fixes

This commit is contained in:
Guilhem Lavaux 2010-03-02 10:59:41 -06:00
parent f029c037f3
commit 7d39b98db5
5 changed files with 40 additions and 6 deletions

View file

@ -6,7 +6,7 @@
#define __KD_TREE_NUMNODES
#include "mykdtree.hpp"
#define NTRY 3
#define NTRY 100
#define ND 3
using namespace std;
@ -62,11 +62,12 @@ int main()
// Check consistency
cout << "Check consistency..." << endl;
MyCell **ngb = new MyCell *[12];
double *distances = new double[12];
ofstream fngb("nearest.txt");
for (int k = 0; k < NTRY; k++) {
cout << "Seed = " << xc[k][0] << " " << xc[k][1] << " " << xc[k][2] << endl;
tree.getNearestNeighbours(xc[k], 12, ngb);
tree.getNearestNeighbours(xc[k], 12, ngb, distances);
for (uint32_t i = 0; i < 12; i++)
{
@ -75,6 +76,34 @@ int main()
d2 += ({double delta = xc[k][l] - ngb[i]->coord[l]; delta*delta;});
fngb << ngb[i]->coord[0] << " " << ngb[i]->coord[1] << " " << ngb[i]->coord[2] << " " << sqrt(d2) << endl;
}
fngb << endl << endl;
double farther_dist = distances[11];
for (uint32_t i = 0; i < Ncells; i++)
{
bool found = false;
// If the points is not in the list, it means it is farther than the farther point
for (int j =0; j < 12; j++)
{
if (&cells[i] == ngb[j]) {
found = true;
break;
}
}
double dist_to_seed = 0;
for (int l = 0; l < 3; l++)
{ double delta = xc[k][l]-cells[i].coord[l];
dist_to_seed += delta*delta; }
if (!found)
{
if (dist_to_seed <= farther_dist)
abort();
}
else
{
if (dist_to_seed > farther_dist)
abort();
}
}
}
return 0;