Imported Healpix, cfitsio, cosmotool. Added cmake tool to build dependencies (cfitsio, hdf5, netcdf, boost, healpix, gsl, ..). Adjusted CMakeLists.txt

This commit is contained in:
Guilhem Lavaux 2012-10-30 14:17:11 -04:00
parent 4bfb62f177
commit 51f6798f88
241 changed files with 243806 additions and 0 deletions

View file

@ -0,0 +1,7 @@
6
14.8253 -6.4243 7.8746 -1.2498 10.2733 10.2733
-6.4243 15.1024 -1.1155 -0.2761 -8.2117 -8.2117
7.8746 -1.1155 51.8519 -23.3482 12.5902 12.5902
-1.2498 -0.2761 -23.3482 22.7962 -9.8958 -9.8958
10.2733 -8.2117 12.5902 -9.8958 21.0656 21.0656
10.2733 -8.2117 12.5902 -9.8958 21.0656 21.0656

21
external/cosmotool/sample/testAlgo.cpp vendored Normal file
View file

@ -0,0 +1,21 @@
#include <iostream>
#include <stdio.h>
#include "algo.hpp"
using namespace CosmoTool;
using namespace std;
int main(int argc, char **argv)
{
cout << square(2) << endl;
cout << cube(2) << endl;
cout << square(2.1f) << endl;
cout << cube(2.1f) << endl;
cout << spower<-2>(2.1f) << endl;
cout << spower<2>(2.1f) << endl;
cout << spower<3>(2.1f) << endl;
cout << spower<4>(2.1f) << endl;
cout << spower<5>(2.1f) << endl;
return 0;
}

View file

@ -0,0 +1,33 @@
#include <iostream>
#include "bqueue.hpp"
using namespace std;
int main(int argc, char **argv)
{
CosmoTool::BoundedQueue<int,int> bq(4, 100000.);
for (int i = 10; i >= 0; i--)
{
bq.push(i, i);
int *prio = bq.getPriorities();
for (int j = 0; j < 4; j++)
cout << prio[j] << " ";
cout << endl;
}
for (int i = 1; i >= -2; i--)
{
bq.push(i, i);
int *prio = bq.getPriorities();
for (int j = 0; j < 4; j++)
cout << prio[j] << " ";
cout << endl;
}
return 0;
}

15
external/cosmotool/sample/testBSP.cpp vendored Normal file
View file

@ -0,0 +1,15 @@
#if 0
#include "bsp_simple.hpp"
int main(int argc, char **argv)
{
CosmoTool::simple_bsp::BSP<int, double, 2> bsp;
double p[5][2] = { { 0, 0}, {1, 0}, {1, 1}, {0, 1}, {0, 0} };
for (int q = 0; q < 4; q++)
bsp.insert(p+q, p+q+2, q);
return 0;
}
#endif
int main() {}

View file

@ -0,0 +1,30 @@
#include <fstream>
#include <iostream>
#include "dinterpolate.hpp"
#define NX 30
#define NY 30
using namespace std;
using namespace CosmoTool;
typedef DelaunayInterpolate<double,double,2> myTriangle;
int main()
{
myTriangle::CoordType pos[] = { {0,0}, {1,0}, {0,1}, {1, 1}, {2, 0}, {2, 1} } ;
double vals[] = { 0, 1, 1, 0, -0.5, 2.0 };
uint32_t simplex[] = { 0, 1, 2, 3, 1, 2, 1, 3, 4, 4, 5, 3 };
myTriangle t(&pos[0], &vals[0], &simplex[0], 6, 4);
ofstream f("output.txt");
for (uint32_t iy = 0; iy <= NY; iy++) {
for (uint32_t ix = 0; ix <= NX; ix++) {
myTriangle::CoordType inter = { ix *2.0/ NX, iy *1.0/NY };
f << inter[1] << " " << inter[0] << " " << t.computeValue(inter) << endl;
}
f << endl;
}
return 0;
}

67
external/cosmotool/sample/testEskow.cpp vendored Normal file
View file

@ -0,0 +1,67 @@
#include <fstream>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <vector>
#include "eskow.hpp"
using namespace std;
double Hartmann_Matrix[6][6] = {
{ 14.8253, -6.4243, 7.8746, -1.2498, 10.2733, 10.2733 },
{ -6.4243, 15.1024, -1.1155, -0.2761, -8.2117, -8.2117 },
{ 7.8746, -1.1155, 51.8519, -23.3482, 12.5902, 12.5902 },
{ -1.2498, -0.2761, -23.3482, 22.7962, -9.8958, -9.8958 },
{ 10.2733, -8.2117, 12.5902, -9.8958, 21.0656, 21.0656 },
{ 10.2733, -8.2117, 12.5902, -9.8958, 21.0656, 21.0656 }
};
struct MatrixOp
{
vector<double> M;
int N;
double& operator()(int i, int j)
{
return M[i*N + j];
}
};
int main(int argc, char **argv)
{
MatrixOp M;
double norm_E;
ifstream fi(argv[1]);
ofstream f("eskowed.txt");
CholeskyEskow<double,MatrixOp> chol;
fi >> M.N;
M.M.resize(M.N*M.N);
for (int i = 0; i < M.N; i++)
{
for (int j = 0; j < M.N; j++)
{
fi >> M(i,j);
if (j > i)
M(i,j) =0;
}
}
chol.cholesky(M, M.N, norm_E);
cout << "norm_E = " << norm_E << endl;
for (int i = 0; i < M.N; i++)
{
for (int j = 0; j < M.N; j++)
{
if (j > i)
f << "0 ";
else
f << setprecision(25) << M(i,j) << " ";
}
f << endl;
}
return 0;
}

View file

@ -0,0 +1,31 @@
#include <iostream>
#include "interpolate3d.hpp"
using namespace std;
using namespace CosmoTool;
int main()
{
VectorField<float,3> *vectors = new VectorField<float,3>[27];
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
for (int k = 0; k < 3; k++)
{
int idx = i + 3*(j + 3*k);
vectors[idx].vec[0] = i;
vectors[idx].vec[1] = j;
vectors[idx].vec[2] = k;
}
GridSampler<VectorField<float,3> > sampler(vectors, 3, 3, 3, 1);
Interpolate3D<GridSampler<VectorField<float,3> > > inter(sampler);
VectorField<float,3> v = inter.get(0.5,0.15,0.5);
VectorField<float,3> v2 = inter.get(1.5,1.65,1.5);
cout << v.vec[0] << " " << v.vec[1] << " " << v.vec[2] << endl;
cout << v2.vec[0] << " " << v2.vec[1] << " " << v2.vec[2] << endl;
return 0;
}

View file

@ -0,0 +1,27 @@
#include <iostream>
#include <cmath>
using namespace std;
#include "newton.hpp"
using namespace CosmoTool;
struct SimplePolynom
{
double eval(double x) { return x*x*x+2*x-1; }
double derivative(double x) { return 3*x*x+2; }
};
int main()
{
SimplePolynom poly;
double r;
double solution = -2*pow(2./(3*(9+sqrt(177.))), 1./3) + (pow(0.5*(9+sqrt(177.))/9, 1./3));
r = newtonSolver(3.0, poly);
cout << "Result = " << r << " delta = " << r-solution << endl;
return 0;
}

19
external/cosmotool/sample/testPool.cpp vendored Normal file
View file

@ -0,0 +1,19 @@
#include "pool.hpp"
using namespace CosmoTool;
int main(int argc, char **argv)
{
MemoryPool<int> pool(1024);
int **j = new int *[3000];
for (int i = 0; i < 3000; i++)
{
j[i] = pool.alloc();
j[i][0] = i;
}
pool.free_all();
return 0;
}

View file

@ -0,0 +1,17 @@
#include <iostream>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include "loadFlash.hpp"
using namespace CosmoTool;
using namespace std;
int main () {
const char* filename = "lss_read_hdf5_chk_0000";
SimuData* data = CosmoTool::loadFlashMulti(filename, 0, 0);
return 0;
}

View file

@ -0,0 +1,68 @@
#include <iostream>
#include "sphSmooth.hpp"
#include "yorick.hpp"
#include "mykdtree.hpp"
using namespace std;
using namespace CosmoTool;
#define NX 1024
#define ND 2
typedef SPHSmooth<char,ND> MySmooth;
typedef MySmooth::SPHTree MyTree;
typedef MySmooth::SPHNode MyNode;
typedef MySmooth::SPHCell MyCell;
double unit_fun(const char& c)
{
return 1.0;
}
int main()
{
uint32_t Ncells = 10000;
MyCell *cells = new MyCell[Ncells];
for (int i = 0; i < Ncells; i++)
{
cells[i].active = true;
for (int l = 0; l < ND; l++)
cells[i].coord[l] = drand48();
cells[i].val.weight = 0;
}
MyTree tree(cells, Ncells);
MySmooth smooth(&tree, 16);
for (uint32_t iy = 0; iy < NX; iy++)
{
cout << "iy=" << iy << endl;
for (uint32_t ix = 0; ix < NX; ix++)
{
MyTree::coords c = { 1.0*ix/NX, 1.0*iy/NX };
smooth.fetchNeighbours(c);
smooth.addGridSite(c);
}
}
uint32_t dims[] = { NX, NX };
ProgressiveOutput<ComputePrecision> out =
ProgressiveOutput<ComputePrecision>::saveArrayProgressive("out.nc", dims, 2);
for (uint32_t iy = 0; iy < NX; iy++)
{
cout << "iy=" << iy << endl;
for (uint32_t ix = 0; ix < NX; ix++)
{
MyTree::coords c = { 1.0*ix/NX, 1.0*iy/NX };
smooth.fetchNeighbours(c);
out.put(smooth.computeSmoothedValue(c, unit_fun));
}
}
return 0;
}

View file

@ -0,0 +1,12 @@
#include "fourier/euclidian.hpp"
using namespace CosmoTool;
int main()
{
EuclidianFourierTransform_2d<double> dft(128,128,1.0,1.0);
dft.realSpace().eigen().setRandom();
dft.analysis();
return 0;
}

123
external/cosmotool/sample/testkd.cpp vendored Normal file
View file

@ -0,0 +1,123 @@
#define __KD_TREE_SAVE_ON_DISK
#include <ctime>
#include <cassert>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include "mykdtree.hpp"
#define NTRY 50000
#define ND 2
using namespace std;
using namespace CosmoTool;
typedef KDTree<ND,char> MyTree;
typedef MyTree::Cell MyCell;
MyCell *findNearest(MyTree::coords& xc, MyCell *cells, uint32_t Ncells)
{
MyCell *near2 = 0;
double R2 = INFINITY;
for (int i = 0; i < Ncells; i++)
{
double d2 = 0;
for (int j = 0; j < ND; j++)
{
double delta = xc[j]-cells[i].coord[j];
d2 += delta*delta;
}
if (d2 < R2)
{
near2 = &cells[i];
near2->val = i;
R2 = d2;
}
}
return near2;
}
int main()
{
uint32_t Ncells = 3000;
MyCell *cells = new MyCell[Ncells];
for (int i = 0; i < Ncells; i++)
{
cells[i].active = true;
for (int l = 0; l < ND; l++)
cells[i].coord[l] = drand48();
}
MyTree tree(cells, Ncells);
MyTree::coords *xc = new MyTree::coords[NTRY];
cout << "Generating seeds..." << endl;
for (int k = 0; k < NTRY; k++)
{
for (int l = 0; l < ND; l++)
xc[k][l] = drand48();
}
// Check consistency
cout << "Check consistency..." << endl;
#if 0
for (int k = 0; k < NTRY; k++) {
MyCell *near = tree.getNearestNeighbour(xc[k]);
MyCell *near2 = findNearest(xc[k], cells, Ncells);
assert(near == near2);
}
#endif
cout << "Check timing..." << endl;
// Check timing
clock_t startTimer = clock();
for (int k = 0; k < NTRY; k++) {
MyCell *near = tree.getNearestNeighbour(xc[k]);
near->val = 0;
}
clock_t endTimer = clock();
clock_t delta = endTimer-startTimer;
double myTime = delta*1.0/CLOCKS_PER_SEC * 1000000.0;
cout << "KDTree search/sec = " << myTime/NTRY << " us" << endl;
startTimer = clock();
for (int k = 0; k < NTRY; k++) {
MyCell *near = findNearest(xc[k], cells, Ncells);
}
endTimer = clock();
delta = endTimer-startTimer;
myTime = delta*1.0/CLOCKS_PER_SEC * 1000000.0;
cout << "Direct search/sec = " << myTime/NTRY << " us" << endl;
{
ofstream f("kd.dat");
tree.saveTree(f);
}
cout << "Trying to reload the tree" << endl;
{
ifstream f("kd.dat");
MyTree tree2(f, cells, Ncells);
cout << "Check timing..." << endl;
// Check timing
clock_t startTimer = clock();
for (int k = 0; k < NTRY; k++) {
MyCell *near = tree.getNearestNeighbour(xc[k]);
}
clock_t endTimer = clock();
clock_t delta = endTimer-startTimer;
double myTime = delta*1.0/CLOCKS_PER_SEC * 1000000.0;
cout << "KDTree search/sec = " << myTime/NTRY << " us" << endl;
}
return 0;
}

128
external/cosmotool/sample/testkd2.cpp vendored Normal file
View file

@ -0,0 +1,128 @@
#include <ctime>
#include <cassert>
#include <cstdlib>
#include <iostream>
#include <fstream>
#define __KD_TREE_NUMNODES
#include "mykdtree.hpp"
#include "kdtree_splitters.hpp"
#define NTRY 10
#define ND 3
using namespace std;
using namespace CosmoTool;
typedef KDTree<ND,char,ComputePrecision,KD_homogeneous_cell_splitter<ND, char> > MyTree;
//typedef KDTree<ND,char,ComputePrecision > MyTree;
typedef KDCell<ND,char> MyCell;
MyCell *findNearest(MyTree::coords& xc, MyCell *cells, uint32_t Ncells)
{
MyCell *near2 = 0;
double R2 = INFINITY;
for (int i = 0; i < Ncells; i++)
{
double d2 = 0;
for (int j = 0; j < ND; j++)
{
double delta = xc[j]-cells[i].coord[j];
d2 += delta*delta;
}
if (d2 < R2)
{
near2 = &cells[i];
R2 = d2;
}
}
return near2;
}
int main()
{
uint32_t Ncells = 10000000;
MyCell *cells = new MyCell[Ncells];
for (int i = 0; i < Ncells; i++)
{
cells[i].active = true;
for (int l = 0; l < ND; l++)
cells[i].coord[l] = drand48();
}
// Check timing
clock_t startTimer = clock();
MyTree tree(cells, Ncells);
clock_t endTimer = clock();
clock_t delta = endTimer-startTimer;
double myTime = delta*1.0/CLOCKS_PER_SEC * 1.0;
cout << "KDTree build = " << myTime << " s" << endl;
MyTree::coords *xc = new MyTree::coords[NTRY];
cout << "Generating seeds..." << endl;
for (int k = 0; k < NTRY; k++)
{
for (int l = 0; l < ND; l++)
xc[k][l] = drand48();
}
// 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, distances);
int last = -1;
for (uint32_t i = 0; i < 12; i++)
{
if (ngb[i] == 0)
continue;
last = i;
double d2 = 0;
for (int l = 0; l < 3; l++)
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[last];
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 farthest 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;
}