More tests

This commit is contained in:
Guilhem Lavaux 2009-12-07 15:47:36 +01:00
parent 1213155222
commit 31ecbe79d7

View File

@ -2,10 +2,12 @@
#include <cassert> #include <cassert>
#include <cstdlib> #include <cstdlib>
#include <iostream> #include <iostream>
#include <fstream>
#define __KD_TREE_NUMNODES
#include "mykdtree.hpp" #include "mykdtree.hpp"
#define NTRY 3 #define NTRY 3
#define ND 2 #define ND 3
using namespace std; using namespace std;
using namespace CosmoTool; using namespace CosmoTool;
@ -61,6 +63,7 @@ int main()
cout << "Check consistency..." << endl; cout << "Check consistency..." << endl;
MyCell **ngb = new MyCell *[12]; MyCell **ngb = new MyCell *[12];
ofstream fngb("nearest.txt");
for (int k = 0; k < NTRY; k++) { for (int k = 0; k < NTRY; k++) {
cout << "Seed = " << xc[k][0] << " " << xc[k][1] << " " << xc[k][2] << endl; cout << "Seed = " << xc[k][0] << " " << xc[k][1] << " " << xc[k][2] << endl;
tree.getNearestNeighbours(xc[k], 12, ngb); tree.getNearestNeighbours(xc[k], 12, ngb);
@ -70,9 +73,9 @@ int main()
double d2 = 0; double d2 = 0;
for (int l = 0; l < 3; l++) for (int l = 0; l < 3; l++)
d2 += ({double delta = xc[k][l] - ngb[i]->coord[l]; delta*delta;}); d2 += ({double delta = xc[k][l] - ngb[i]->coord[l]; delta*delta;});
cout << ngb[i]->coord[0] << " " << ngb[i]->coord[1] << " " << ngb[i]->coord[2] << " " << sqrt(d2) << endl; fngb << ngb[i]->coord[0] << " " << ngb[i]->coord[1] << " " << ngb[i]->coord[2] << " " << sqrt(d2) << endl;
} }
} }
return 0; return 0;
} }