Commit 69321e96 authored by Martin Reinecke's avatar Martin Reinecke

add tests (still broken)

parent f9ed3684
......@@ -1182,7 +1182,7 @@ template<typename I> void T_Healpix_Base<I>::neighbors (I pix,
{
for (size_t i=0; i<8; ++i)
{
I x=ix+nb_xoffset[i], y=iy+nb_yoffset[i];
int64_t x=int64_t(ix)+nb_xoffset[i], y=int64_t(iy)+nb_yoffset[i];
I nbnum=4;
if (x<0)
{ x+=nside_; nbnum-=1; }
......@@ -1193,7 +1193,7 @@ template<typename I> void T_Healpix_Base<I>::neighbors (I pix,
else if (y>=nside_)
{ y-=nside_; nbnum+=3; }
I f = nb_facearray[nbnum][face_num];
int f = nb_facearray[nbnum][face_num];
if (f>=0)
{
int bits = nb_swaparray[nbnum][face_num>>2];
......@@ -1203,7 +1203,7 @@ template<typename I> void T_Healpix_Base<I>::neighbors (I pix,
result[i] = (scheme_==RING) ? xyf2ring(x,y,f) : xyf2nest(x,y,f);
}
else
result[i] = -1;
result[i] = ~I(0);
}
}
}
......
......@@ -79,7 +79,7 @@ namespace healpix {
template<typename T> void Healpix_Map<T>::minmax (T &Min, T &Max) const
{
Min = T(1e30); Max = T(-1e30);
for (int m=0; m<npix_; ++m)
for (uint32_t m=0; m<npix_; ++m)
{
T val = map[m];
if (!approx<double>(val,Healpix_undef))
......@@ -111,15 +111,15 @@ template<typename T> Healpix_Map<T> Healpix_Map<T>::median (double rad) const
{
Healpix_Map<T> out(Nside(), Scheme(), SET_NSIDE);
rangeset<int> pixset;
rangeset<uint32_t> pixset;
vector<T> list;
for (int m=0; m<Npix(); ++m)
for (uint32_t m=0; m<Npix(); ++m)
{
query_disc(pix2ang(m),rad,pixset);
list.resize(pixset.nval());
size_t cnt=0;
for (size_t j=0; j<pixset.nranges(); ++j)
for (int i=pixset.ivbegin(j); i<pixset.ivend(j); ++i)
for (uint32_t i=pixset.ivbegin(j); i<pixset.ivend(j); ++i)
if (!approx(map[i], T(Healpix_undef)))
list[cnt++] = map[i];
out[m] = (cnt>0) ? mymedian(list.begin(),list.begin()+cnt)
......
......@@ -56,11 +56,11 @@ template<typename T> class Healpix_Map: public Healpix_Base
Healpix_Map () {}
/*! Constructs a map with a given \a order and the ordering
scheme \a scheme. */
Healpix_Map (int order, Ordering_Scheme scheme)
Healpix_Map (uint32_t order, Ordering_Scheme scheme)
: Healpix_Base (order, scheme), map(npix_) {}
/*! Constructs a map with a given \a nside and the ordering
scheme \a scheme. */
Healpix_Map (int nside, Ordering_Scheme scheme, const nside_dummy)
Healpix_Map (uint32_t nside, Ordering_Scheme scheme, const nside_dummy)
: Healpix_Base (nside, scheme, SET_NSIDE), map(npix_) {}
/*! Constructs a map from the contents of \a data and sets the ordering
scheme to \a Scheme. The size of \a data must be a valid HEALPix
......@@ -80,14 +80,14 @@ template<typename T> class Healpix_Map: public Healpix_Base
/*! Deletes the old map and creates a new map with a given \a order
and the ordering scheme \a scheme. */
void Set (int order, Ordering_Scheme scheme)
void Set (uint32_t order, Ordering_Scheme scheme)
{
Healpix_Base::Set(order, scheme);
map.alloc(npix_);
}
/*! Deletes the old map and creates a new map with a given \a nside
and the ordering scheme \a scheme. */
void SetNside (int nside, Ordering_Scheme scheme)
void SetNside (uint32_t nside, Ordering_Scheme scheme)
{
Healpix_Base::SetNside(nside, scheme);
map.alloc(npix_);
......@@ -105,13 +105,13 @@ template<typename T> class Healpix_Map: public Healpix_Base
MR_assert (nside_==orig.nside_,
"Import_nograde: maps have different nside");
if (orig.scheme_ == scheme_)
for (int m=0; m<npix_; ++m) map[m] = orig.map[m];
for (uint32_t m=0; m<npix_; ++m) map[m] = orig.map[m];
else
{
swapfunc swapper = (scheme_ == NEST) ?
&Healpix_Base::ring2nest : &Healpix_Base::nest2ring;
#pragma omp parallel for schedule (dynamic,5000)
for (int m=0; m<npix_; ++m) map[(this->*swapper)(m)] = orig.map[m];
for (uint32_t m=0; m<npix_; ++m) map[(this->*swapper)(m)] = orig.map[m];
}
}
......@@ -122,19 +122,19 @@ template<typename T> class Healpix_Map: public Healpix_Base
void Import_upgrade (const Healpix_Map<T> &orig)
{
MR_assert(nside_>orig.nside_,"Import_upgrade: this is no upgrade");
int fact = nside_/orig.nside_;
uint32_t fact = nside_/orig.nside_;
MR_assert (nside_==orig.nside_*fact,
"the larger Nside must be a multiple of the smaller one");
#pragma omp parallel for schedule (dynamic,5000)
for (int m=0; m<orig.npix_; ++m)
for (uint32_t m=0; m<orig.npix_; ++m)
{
int x,y,f;
uint32_t x,y,f;
orig.pix2xyf(m,x,y,f);
for (int j=fact*y; j<fact*(y+1); ++j)
for (int i=fact*x; i<fact*(x+1); ++i)
for (uint32_t j=fact*y; j<fact*(y+1); ++j)
for (uint32_t i=fact*x; i<fact*(x+1); ++i)
{
int mypix = xyf2pix(i,j,f);
uint32_t mypix = xyf2pix(i,j,f);
map[mypix] = orig.map[m];
}
}
......@@ -169,9 +169,9 @@ template<typename T> class Healpix_Map: public Healpix_Base
}
/*! Returns a constant reference to the pixel with the number \a pix. */
const T &operator[] (int pix) const { return map[pix]; }
const T &operator[] (uint32_t pix) const { return map[pix]; }
/*! Returns a reference to the pixel with the number \a pix. */
T &operator[] (int pix) { return map[pix]; }
T &operator[] (uint32_t pix) { return map[pix]; }
/*! Swaps the map ordering from RING to NEST and vice versa.
This is done in-place (i.e. with negligible space overhead). */
......@@ -180,15 +180,15 @@ template<typename T> class Healpix_Map: public Healpix_Base
swapfunc swapper = (scheme_ == NEST) ?
&Healpix_Base::ring2nest : &Healpix_Base::nest2ring;
std::vector<int> cycle=swap_cycles();
std::vector<uint32_t> cycle=swap_cycles();
#pragma omp parallel for schedule(dynamic,1)
for (size_t m=0; m<cycle.size(); ++m)
{
int istart = cycle[m];
uint32_t istart = cycle[m];
T pixbuf = map[istart];
int iold = istart, inew = (this->*swapper)(istart);
uint32_t iold = istart, inew = (this->*swapper)(istart);
while (inew != istart)
{
map[iold] = map[inew];
......@@ -201,7 +201,7 @@ template<typename T> class Healpix_Map: public Healpix_Base
}
/*! performs the actual interpolation using \a pix and \a wgt. */
T interpolation (const std::array<int,4> &pix,
T interpolation (const std::array<uint32_t,4> &pix,
const std::array<double,4> &wgt) const
{
double wtot=0;
......@@ -217,7 +217,7 @@ template<typename T> class Healpix_Map: public Healpix_Base
/*! Returns the interpolated map value at \a ptg */
T interpolated_value (const pointing &ptg) const
{
std::array<int,4> pix;
std::array<uint32_t,4> pix;
std::array<double,4> wgt;
get_interpol (ptg, pix, wgt);
return interpolation (pix, wgt);
......@@ -253,7 +253,7 @@ template<typename T> class Healpix_Map: public Healpix_Base
/*! Adds \a val to all defined map pixels. */
void Add (T val)
{
for (int m=0; m<npix_; ++m)
for (uint32_t m=0; m<npix_; ++m)
if (!approx<double>(map[m],Healpix_undef))
{ map[m]+=val; }
}
......@@ -261,7 +261,7 @@ template<typename T> class Healpix_Map: public Healpix_Base
/*! Multiplies all defined map pixels by \a val. */
void Scale (T val)
{
for (int m=0; m<npix_; ++m)
for (uint32_t m=0; m<npix_; ++m)
if (!approx<double>(map[m],Healpix_undef))
{ map[m]*=val; }
}
......@@ -273,8 +273,8 @@ template<typename T> class Healpix_Map: public Healpix_Base
using namespace std;
double result=0;
int pix=0;
for (int m=0; m<npix_; ++m)
uint32_t pix=0;
for (uint32_t m=0; m<npix_; ++m)
if (!approx<double>(map[m],Healpix_undef))
{ ++pix; result+=map[m]*map[m]; }
return (pix>0) ? sqrt(result/pix) : Healpix_undef;
......@@ -286,7 +286,7 @@ template<typename T> class Healpix_Map: public Healpix_Base
using namespace std;
T result=0;
for (int m=0; m<npix_; ++m)
for (uint32_t m=0; m<npix_; ++m)
if (!approx<double>(map[m],Healpix_undef))
{ result = max(result,abs(map[m])); }
return result;
......@@ -295,7 +295,7 @@ template<typename T> class Healpix_Map: public Healpix_Base
else \a false. */
bool fullyDefined() const
{
for (int m=0; m<npix_; ++m)
for (uint32_t m=0; m<npix_; ++m)
if (approx<double>(map[m],Healpix_undef))
return false;
return true;
......@@ -305,7 +305,7 @@ template<typename T> class Healpix_Map: public Healpix_Base
size_t replaceUndefWith0()
{
size_t res=0;
for (int m=0; m<npix_; ++m)
for (uint32_t m=0; m<npix_; ++m)
if (approx<double>(map[m],Healpix_undef))
{ map[m]=0.; ++res; }
return res;
......
......@@ -88,8 +88,8 @@ double frand() { return rrand(engine); }
namespace {
template<typename T>string type2typename() { return "unknown"; }
template<>string type2typename<int>() { return "int"; }
template<>string type2typename<int64_t>() { return "int64_t"; }
template<>string type2typename<uint32_t>() { return "uint32_t"; }
template<>string type2typename<uint64_t>() { return "uint64_t"; }
void random_dir (pointing &ptg)
{
......@@ -832,8 +832,8 @@ template<typename I> void check_neighbors()
base.neighbors(pix,nb);
base2.neighbors(base.nest2ring(pix),nb2);
for (int n=0; n<8; ++n)
if (nb[n]<0)
MR_assert(nb2[n]<0,"neighbor inconsistency");
if (nb[n]==~I(0))
MR_assert(nb2[n]==~I(0),"neighbor inconsistency");
else
MR_assert(base.nest2ring(nb[n])==nb2[n],"neighbor inconsistency");
sort(&nb[0],&nb[0]+8);
......@@ -865,7 +865,7 @@ template<typename I> void check_neighbors()
vec3 pixpt = base.pix2vec(pix);
base.neighbors(pix,nb);
for (int n=0; n<8; ++n)
if ((nb[n]>=0) && (v_angle(base.pix2vec(nb[n]),pixpt)>maxang))
if ((nb[n]!=~I(0)) && (v_angle(base.pix2vec(nb[n]),pixpt)>maxang))
FAIL(cout<<" PROBLEM: nside = "<<nside<<", pix = "<<pix<<endl)
}
}
......@@ -1537,50 +1537,50 @@ void perftest()
{
double dummy=0;
cout << "Measuring performance of Healpix_Base methods." << endl;
perf_pix2zphi<int> ("pix2zphi (RING):int ",RING,dummy);
perf_pix2zphi<int> ("pix2zphi (NEST):int ",NEST,dummy);
perf_pix2zphi<int64_t> ("pix2zphi (RING):int64_t",RING,dummy);
perf_pix2zphi<int64_t> ("pix2zphi (NEST):int64_t",NEST,dummy);
perf_zphi2pix<int> ("zphi2pix (RING):int ",RING,dummy);
perf_zphi2pix<int> ("zphi2pix (NEST):int ",NEST,dummy);
perf_zphi2pix<int64_t> ("zphi2pix (RING):int64_t",RING,dummy);
perf_zphi2pix<int64_t> ("zphi2pix (NEST):int64_t",NEST,dummy);
perf_pix2ang<int> ("pix2ang (RING):int ",RING,dummy);
perf_pix2ang<int> ("pix2ang (NEST):int ",NEST,dummy);
perf_pix2ang<int64_t> ("pix2ang (RING):int64_t",RING,dummy);
perf_pix2ang<int64_t> ("pix2ang (NEST):int64_t",NEST,dummy);
perf_ang2pix<int> ("ang2pix (RING):int ",RING,dummy);
perf_ang2pix<int> ("ang2pix (NEST):int ",NEST,dummy);
perf_ang2pix<int64_t> ("ang2pix (RING):int64_t",RING,dummy);
perf_ang2pix<int64_t> ("ang2pix (NEST):int64_t",NEST,dummy);
perf_pix2vec<int> ("pix2vec (RING):int ",RING,dummy);
perf_pix2vec<int> ("pix2vec (NEST):int ",NEST,dummy);
perf_pix2vec<int64_t> ("pix2vec (RING):int64_t",RING,dummy);
perf_pix2vec<int64_t> ("pix2vec (NEST):int64_t",NEST,dummy);
perf_neighbors<int> ("neighbors(NEST):int ",NEST);
perf_neighbors<int> ("neighbors(RING):int ",RING);
perf_neighbors<int64_t>("neighbors(NEST):int64_t",NEST);
perf_neighbors<int64_t>("neighbors(RING):int64_t",RING);
perf_ring2nest<int> ("ring2nest :int ",dummy);
perf_ring2nest<int64_t>("ring2nest :int64_t",dummy);
perf_nest2ring<int> ("nest2ring :int ",dummy);
perf_nest2ring<int64_t>("nest2ring :int64_t",dummy);
perf_peano2nest<int> ("peano2nest :int ",dummy);
perf_peano2nest<int64_t>("peano2nest :int64_t",dummy);
perf_nest2peano<int> ("nest2peano :int ",dummy);
perf_nest2peano<int64_t>("nest2peano :int64_t",dummy);
perf_query_disc<int> ("query_disc (RING):int ",RING,dummy);
perf_query_disc<int> ("query_disc (NEST):int ",NEST,dummy);
perf_query_disc<int64_t> ("query_disc (RING):int64_t",RING,dummy);
perf_query_disc<int64_t> ("query_disc (NEST):int64_t",NEST,dummy);
perf_query_triangle<int> ("query_triangle(RING):int ",RING,dummy);
perf_query_triangle<int> ("query_triangle(NEST):int ",NEST,dummy);
perf_query_triangle<int64_t>("query_triangle(RING):int64_t",RING,dummy);
perf_query_triangle<int64_t>("query_triangle(NEST):int64_t",NEST,dummy);
perf_query_polygon<int> ("query_polygon (RING):int ",RING,dummy);
perf_query_polygon<int> ("query_polygon (NEST):int ",NEST,dummy);
perf_query_polygon<int64_t> ("query_polygon (RING):int64_t",RING,dummy);
perf_query_polygon<int64_t> ("query_polygon (NEST):int64_t",NEST,dummy);
perf_pix2zphi<uint32_t> ("pix2zphi (RING):int ",RING,dummy);
perf_pix2zphi<uint32_t> ("pix2zphi (NEST):int ",NEST,dummy);
perf_pix2zphi<uint64_t> ("pix2zphi (RING):int64_t",RING,dummy);
perf_pix2zphi<uint64_t> ("pix2zphi (NEST):int64_t",NEST,dummy);
perf_zphi2pix<uint32_t> ("zphi2pix (RING):int ",RING,dummy);
perf_zphi2pix<uint32_t> ("zphi2pix (NEST):int ",NEST,dummy);
perf_zphi2pix<uint64_t> ("zphi2pix (RING):int64_t",RING,dummy);
perf_zphi2pix<uint64_t> ("zphi2pix (NEST):int64_t",NEST,dummy);
perf_pix2ang<uint32_t> ("pix2ang (RING):int ",RING,dummy);
perf_pix2ang<uint32_t> ("pix2ang (NEST):int ",NEST,dummy);
perf_pix2ang<uint64_t> ("pix2ang (RING):int64_t",RING,dummy);
perf_pix2ang<uint64_t> ("pix2ang (NEST):int64_t",NEST,dummy);
perf_ang2pix<uint32_t> ("ang2pix (RING):int ",RING,dummy);
perf_ang2pix<uint32_t> ("ang2pix (NEST):int ",NEST,dummy);
perf_ang2pix<uint64_t> ("ang2pix (RING):int64_t",RING,dummy);
perf_ang2pix<uint64_t> ("ang2pix (NEST):int64_t",NEST,dummy);
perf_pix2vec<uint32_t> ("pix2vec (RING):int ",RING,dummy);
perf_pix2vec<uint32_t> ("pix2vec (NEST):int ",NEST,dummy);
perf_pix2vec<uint64_t> ("pix2vec (RING):int64_t",RING,dummy);
perf_pix2vec<uint64_t> ("pix2vec (NEST):int64_t",NEST,dummy);
perf_neighbors<uint32_t> ("neighbors(NEST):int ",NEST);
perf_neighbors<uint32_t> ("neighbors(RING):int ",RING);
perf_neighbors<uint64_t>("neighbors(NEST):int64_t",NEST);
perf_neighbors<uint64_t>("neighbors(RING):int64_t",RING);
perf_ring2nest<uint32_t> ("ring2nest :int ",dummy);
perf_ring2nest<uint64_t>("ring2nest :int64_t",dummy);
perf_nest2ring<uint32_t> ("nest2ring :int ",dummy);
perf_nest2ring<uint64_t>("nest2ring :int64_t",dummy);
perf_peano2nest<uint32_t> ("peano2nest :int ",dummy);
perf_peano2nest<uint64_t>("peano2nest :int64_t",dummy);
perf_nest2peano<uint32_t> ("nest2peano :int ",dummy);
perf_nest2peano<uint64_t>("nest2peano :int64_t",dummy);
perf_query_disc<uint32_t> ("query_disc (RING):int ",RING,dummy);
perf_query_disc<uint32_t> ("query_disc (NEST):int ",NEST,dummy);
perf_query_disc<uint64_t> ("query_disc (RING):int64_t",RING,dummy);
perf_query_disc<uint64_t> ("query_disc (NEST):int64_t",NEST,dummy);
perf_query_triangle<uint32_t> ("query_triangle(RING):int ",RING,dummy);
perf_query_triangle<uint32_t> ("query_triangle(NEST):int ",NEST,dummy);
perf_query_triangle<uint64_t>("query_triangle(RING):int64_t",RING,dummy);
perf_query_triangle<uint64_t>("query_triangle(NEST):int64_t",NEST,dummy);
perf_query_polygon<uint32_t> ("query_polygon (RING):int ",RING,dummy);
perf_query_polygon<uint32_t> ("query_polygon (NEST):int ",NEST,dummy);
perf_query_polygon<uint64_t> ("query_polygon (RING):int64_t",RING,dummy);
perf_query_polygon<uint64_t> ("query_polygon (NEST):int64_t",NEST,dummy);
if (dummy<0) cout << dummy << endl;
}
......@@ -1590,7 +1590,7 @@ void perftest()
int main(int argc, const char **argv)
{
// module_startup ("hpxtest",argc,argv,1,"");
perftest();
// perftest();
// check_compress<int>();
// check_compress<unsigned>();
// check_compress<int64_t>();
......@@ -1609,27 +1609,27 @@ int main(int argc, const char **argv)
// check_alm2map2alm(620,2,256);
// check_average();
// check_import();
check_ringnestring<int>();
check_ringnestring<int64_t>();
check_nestpeanonest<int>();
check_nestpeanonest<int64_t>();
check_pixzphipix<int>();
check_pixzphipix<int64_t>();
check_zphipixzphi<int>();
check_zphipixzphi<int64_t>();
check_pixangpix<int>();
check_pixangpix<int64_t>();
check_neighbors<int>();
check_neighbors<int64_t>();
check_ringnestring<uint32_t>();
check_ringnestring<uint64_t>();
check_nestpeanonest<uint32_t>();
check_nestpeanonest<uint64_t>();
check_pixzphipix<uint32_t>();
check_pixzphipix<uint64_t>();
check_zphipixzphi<uint32_t>();
check_zphipixzphi<uint64_t>();
check_pixangpix<uint32_t>();
check_pixangpix<uint64_t>();
check_neighbors<uint32_t>();
check_neighbors<uint64_t>();
// check_swap_scheme();
check_query_disc_strict(RING);
check_query_disc_strict(NEST);
check_issue_229(RING);
check_issue_229(NEST);
check_query_disc<int>();
check_query_disc<int64_t>();
check_query_polygon<int>();
check_query_polygon<int64_t>();
check_query_disc<uint32_t>();
check_query_disc<uint64_t>();
check_query_polygon<uint32_t>();
check_query_polygon<uint64_t>();
// check_ringweights();
// check_fullweights();
#ifdef UNITTESTS
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment