/* * This file is part of Healpix_cxx. * * Healpix_cxx 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. * * Healpix_cxx 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 Healpix_cxx; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * For more information about HEALPix, see http://healpix.jpl.nasa.gov */ /* * Healpix_cxx is being developed at the Max-Planck-Institut fuer Astrophysik * and financially supported by the Deutsches Zentrum fuer Luft- und Raumfahrt * (DLR). */ /* * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Max-Planck-Society * Author: Martin Reinecke */ #include "alm_healpix_tools.h" #include "alm.h" #include "healpix_map.h" #include "xcomplex.h" #include "psht_cxx.h" using namespace std; template void map2alm (const Healpix_Map &map, Alm > &alm, const arr &weight, bool add_alm) { planck_assert (map.Scheme()==RING, "map2alm: map must be in RING scheme"); planck_assert (int(weight.size())>=2*map.Nside(), "map2alm: weight array has too few entries"); psht_joblist joblist; joblist.set_weighted_Healpix_geometry (map.Nside(),&weight[0]); joblist.set_triangular_alm_info (alm.Lmax(), alm.Mmax()); joblist.add_map2alm(&map[0], &alm(0,0), add_alm); joblist.execute(); } template void map2alm (const Healpix_Map &map, Alm > &alm, const arr &weight, bool add_alm); template void map2alm (const Healpix_Map &map, Alm > &alm, const arr &weight, bool add_alm); template void map2alm_iter (const Healpix_Map &map, Alm > &alm, int num_iter, const arr &weight) { map2alm(map,alm,weight); for (int iter=1; iter<=num_iter; ++iter) { Healpix_Map map2(map.Nside(),map.Scheme(),SET_NSIDE); alm2map(alm,map2); for (int m=0; m &map, Alm > &alm, int num_iter, const arr &weight); template void map2alm_iter (const Healpix_Map &map, Alm > &alm, int num_iter, const arr &weight); template void map2alm_iter2 (const Healpix_Map &map, Alm > &alm, double err_abs, double err_rel) { double x_err_abs=1./err_abs, x_err_rel=1./err_rel; arr wgt(2*map.Nside()); wgt.fill(1); Healpix_Map map2(map); alm.SetToZero(); while(true) { map2alm(map2,alm,wgt,true); alm2map(alm,map2); double errmeasure=0; for (int m=0; m &map, Alm > &alm, double err_abs, double err_rel); template void map2alm_spin (const Healpix_Map &map1, const Healpix_Map &map2, Alm > &alm1, Alm > &alm2, int spin, const arr &weight, bool add_alm) { planck_assert (map1.Scheme()==RING, "map2alm_spin: maps must be in RING scheme"); planck_assert (map1.conformable(map2), "map2alm_spin: maps are not conformable"); planck_assert (alm1.conformable(alm1), "map2alm_spin: a_lm are not conformable"); planck_assert (int(weight.size())>=2*map1.Nside(), "map2alm_spin: weight array has too few entries"); psht_joblist joblist; joblist.set_weighted_Healpix_geometry (map1.Nside(),&weight[0]); joblist.set_triangular_alm_info (alm1.Lmax(), alm1.Mmax()); joblist.add_map2alm_spin(&map1[0], &map2[0], &alm1(0,0), &alm2(0,0), spin, add_alm); joblist.execute(); } template void map2alm_spin (const Healpix_Map &map1, const Healpix_Map &map2, Alm > &alm1, Alm > &alm2, int spin, const arr &weight, bool add_alm); template void map2alm_spin (const Healpix_Map &map1, const Healpix_Map &map2, Alm > &alm1, Alm > &alm2, int spin, const arr &weight, bool add_alm); template void map2alm_spin_iter2 (const Healpix_Map &map1, const Healpix_Map &map2, Alm > &alm1, Alm > &alm2, int spin, double err_abs, double err_rel) { arr wgt(2*map1.Nside()); wgt.fill(1); Healpix_Map map1b(map1), map2b(map2); alm1.SetToZero(); alm2.SetToZero(); while(true) { map2alm_spin(map1b,map2b,alm1,alm2,spin,wgt,true); alm2map_spin(alm1,alm2,map1b,map2b,spin); double errmeasure=0; for (int m=0; m &map1, const Healpix_Map &map2, Alm > &alm1, Alm > &alm2, int spin, double err_abs, double err_rel); template void map2alm_pol (const Healpix_Map &mapT, const Healpix_Map &mapQ, const Healpix_Map &mapU, Alm > &almT, Alm > &almG, Alm > &almC, const arr &weight, bool add_alm) { planck_assert (mapT.Scheme()==RING, "map2alm_pol: maps must be in RING scheme"); planck_assert (mapT.conformable(mapQ) && mapT.conformable(mapU), "map2alm_pol: maps are not conformable"); planck_assert (almT.conformable(almG) && almT.conformable(almC), "map2alm_pol: a_lm are not conformable"); planck_assert (int(weight.size())>=2*mapT.Nside(), "map2alm_pol: weight array has too few entries"); psht_joblist joblist; joblist.set_weighted_Healpix_geometry (mapT.Nside(),&weight[0]); joblist.set_triangular_alm_info (almT.Lmax(), almT.Mmax()); joblist.add_map2alm_pol(&mapT[0], &mapQ[0], &mapU[0], &almT(0,0), &almG(0,0), &almC(0,0), add_alm); joblist.execute(); } template void map2alm_pol (const Healpix_Map &mapT, const Healpix_Map &mapQ, const Healpix_Map &mapU, Alm > &almT, Alm > &almG, Alm > &almC, const arr &weight, bool add_alm); template void map2alm_pol (const Healpix_Map &mapT, const Healpix_Map &mapQ, const Healpix_Map &mapU, Alm > &almT, Alm > &almG, Alm > &almC, const arr &weight, bool add_alm); template void map2alm_pol_iter (const Healpix_Map &mapT, const Healpix_Map &mapQ, const Healpix_Map &mapU, Alm > &almT, Alm > &almG, Alm > &almC, int num_iter, const arr &weight) { map2alm_pol(mapT,mapQ,mapU,almT,almG,almC,weight); for (int iter=1; iter<=num_iter; ++iter) { Healpix_Map mapT2(mapT.Nside(),mapT.Scheme(),SET_NSIDE), mapQ2(mapT.Nside(),mapT.Scheme(),SET_NSIDE), mapU2(mapT.Nside(),mapT.Scheme(),SET_NSIDE); alm2map_pol(almT,almG,almC,mapT2,mapQ2,mapU2); for (int m=0; m &mapT, const Healpix_Map &mapQ, const Healpix_Map &mapU, Alm > &almT, Alm > &almG, Alm > &almC, int num_iter, const arr &weight); template void map2alm_pol_iter (const Healpix_Map &mapT, const Healpix_Map &mapQ, const Healpix_Map &mapU, Alm > &almT, Alm > &almG, Alm > &almC, int num_iter, const arr &weight); template void map2alm_pol_iter2 (const Healpix_Map &mapT, const Healpix_Map &mapQ, const Healpix_Map &mapU, Alm > &almT, Alm > &almG, Alm > &almC, double err_abs, double err_rel) { arr wgt(2*mapT.Nside()); wgt.fill(1); Healpix_Map mapT2(mapT), mapQ2(mapQ), mapU2(mapU); almT.SetToZero(); almG.SetToZero(); almC.SetToZero(); while(true) { map2alm_pol(mapT2,mapQ2,mapU2,almT,almG,almC,wgt,true); alm2map_pol(almT,almG,almC,mapT2,mapQ2,mapU2); double errmeasure=0; for (int m=0; m &mapT, const Healpix_Map &mapQ, const Healpix_Map &mapU, Alm > &almT, Alm > &almG, Alm > &almC, double err_abs, double err_rel); template void alm2map (const Alm > &alm, Healpix_Map &map) { planck_assert (map.Scheme()==RING, "alm2map: map must be in RING scheme"); psht_joblist joblist; joblist.set_Healpix_geometry (map.Nside()); joblist.set_triangular_alm_info (alm.Lmax(), alm.Mmax()); joblist.add_alm2map(&alm(0,0), &map[0], false); joblist.execute(); } template void alm2map (const Alm > &alm, Healpix_Map &map); template void alm2map (const Alm > &alm, Healpix_Map &map); template void alm2map_spin (const Alm > &alm1, const Alm > &alm2, Healpix_Map &map1, Healpix_Map &map2, int spin) { planck_assert (map1.Scheme()==RING, "alm2map_spin: maps must be in RING scheme"); planck_assert (map1.conformable(map2), "alm2map_spin: maps are not conformable"); planck_assert (alm1.conformable(alm2), "alm2map_spin: a_lm are not conformable"); psht_joblist joblist; joblist.set_Healpix_geometry (map1.Nside()); joblist.set_triangular_alm_info (alm1.Lmax(), alm1.Mmax()); joblist.add_alm2map_spin(&alm1(0,0), &alm2(0,0), &map1[0], &map2[0], spin, false); joblist.execute(); } template void alm2map_spin (const Alm > &alm1, const Alm > &alm2, Healpix_Map &map, Healpix_Map &map2, int spin); template void alm2map_spin (const Alm > &alm1, const Alm > &alm2, Healpix_Map &map, Healpix_Map &map2, int spin); template void alm2map_pol (const Alm > &almT, const Alm > &almG, const Alm > &almC, Healpix_Map &mapT, Healpix_Map &mapQ, Healpix_Map &mapU) { planck_assert (mapT.Scheme()==RING, "alm2map_pol: maps must be in RING scheme"); planck_assert (mapT.conformable(mapQ) && mapT.conformable(mapU), "alm2map_pol: maps are not conformable"); planck_assert (almT.conformable(almG) && almT.conformable(almC), "alm2map_pol: a_lm are not conformable"); psht_joblist joblist; joblist.set_Healpix_geometry (mapT.Nside()); joblist.set_triangular_alm_info (almT.Lmax(), almT.Mmax()); joblist.add_alm2map_pol(&almT(0,0), &almG(0,0), &almC(0,0), &mapT[0], &mapQ[0], &mapU[0], false); joblist.execute(); } template void alm2map_pol (const Alm > &almT, const Alm > &almG, const Alm > &almC, Healpix_Map &mapT, Healpix_Map &mapQ, Healpix_Map &mapU); template void alm2map_pol (const Alm > &almT, const Alm > &almG, const Alm > &almC, Healpix_Map &mapT, Healpix_Map &mapQ, Healpix_Map &mapU); template void alm2map_der1 (const Alm > &alm, Healpix_Map &map, Healpix_Map &mapdth, Healpix_Map &mapdph) { planck_assert (map.Scheme()==RING, "alm2map_der1: maps must be in RING scheme"); planck_assert (map.conformable(mapdth) && map.conformable(mapdph), "alm2map_der1: maps are not conformable"); psht_joblist joblist; joblist.set_Healpix_geometry (map.Nside()); joblist.set_triangular_alm_info (alm.Lmax(), alm.Mmax()); joblist.add_alm2map(&alm(0,0), &map[0], false); joblist.add_alm2map_der1(&alm(0,0), &mapdth[0], &mapdph[0], false); joblist.execute(); } template void alm2map_der1 (const Alm > &alm, Healpix_Map &map, Healpix_Map &map_dth, Healpix_Map &map_dph); template void alm2map_der1 (const Alm > &alm, Healpix_Map &map, Healpix_Map &map_dth, Healpix_Map &map_dph);