/* * This file is part of libsharp. * * libsharp is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * libsharp is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with libsharp; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* * libsharp is being developed at the Max-Planck-Institut fuer Astrophysik * and financially supported by the Deutsches Zentrum fuer Luft- und Raumfahrt * (DLR). */ /*! \file sharp_acctest.c Systematic accuracy test for libsharp. Copyright (C) 2006-2012 Max-Planck-Society \author Martin Reinecke */ #include #include #ifdef USE_MPI #include "mpi.h" #endif #include "sharp.h" #include "sharp_geomhelpers.h" #include "sharp_almhelpers.h" #include "c_utils.h" #include "sharp_announce.h" #include "sharp_core.h" typedef complex double dcmplx; static double drand (double min, double max) { return min + (max-min)*rand()/(RAND_MAX+1.0); } static void random_alm (dcmplx *alm, sharp_alm_info *helper, int spin) { for (int mi=0;minm; ++mi) { int m=helper->mval[mi]; for (int l=m;l<=helper->lmax; ++l) { if ((lmaxdiff) maxdiff=fabs(x); if (fabs(y)>maxdiff) maxdiff=fabs(y); } sum=sqrt(sum/nalms); sum2=sqrt(sum2/nalms); UTIL_ASSERT((maxdiff<1e-10)&&(sum/sum2<1e-10),"error"); } } static void check_sign_scale(void) { int lmax=50; int mmax=lmax; sharp_geom_info *tinfo; int nrings=lmax+1; int ppring=2*lmax+2; ptrdiff_t npix=(ptrdiff_t)nrings*ppring; sharp_make_gauss_geom_info (nrings, ppring, 1, ppring, &tinfo); /* flip theta to emulate the "old" Gaussian grid geometry */ for (int i=0; inpairs; ++i) { const double pi=3.141592653589793238462643383279502884197; tinfo->pair[i].r1.cth=-tinfo->pair[i].r1.cth; tinfo->pair[i].r2.cth=-tinfo->pair[i].r2.cth; tinfo->pair[i].r1.theta=pi-tinfo->pair[i].r1.theta; tinfo->pair[i].r2.theta=pi-tinfo->pair[i].r2.theta; } sharp_alm_info *alms; sharp_make_triangular_alm_info(lmax,mmax,1,&alms); ptrdiff_t nalms = ((mmax+1)*(mmax+2))/2 + (mmax+1)*(lmax-mmax); for (int ntrans=1; ntrans<10; ++ntrans) { double **map; ALLOC2D(map,double,2*ntrans,npix); dcmplx **alm; ALLOC2D(alm,dcmplx,2*ntrans,nalms); for (int i=0; i<2*ntrans; ++i) for (int j=0; j