00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef PLANCK_SHARP_CXX_H
00033 #define PLANCK_SHARP_CXX_H
00034
00035 #include "sharp_lowlevel.h"
00036 #include "sharp_geomhelpers.h"
00037 #include "sharp_almhelpers.h"
00038
00039 class sharp_base
00040 {
00041 protected:
00042 sharp_alm_info *ainfo;
00043 sharp_geom_info *ginfo;
00044
00045 public:
00046 sharp_base()
00047 : ainfo(0), ginfo(0) {}
00048 ~sharp_base()
00049 {
00050 sharp_destroy_geom_info(ginfo);
00051 sharp_destroy_alm_info(ainfo);
00052 }
00053
00054 void set_general_geometry (int nrings, const int *nph, const ptrdiff_t *ofs,
00055 const int *stride, const double *phi0, const double *theta,
00056 const double *wgt)
00057 {
00058 if (ginfo) sharp_destroy_geom_info(ginfo);
00059 sharp_make_geom_info (nrings, nph, ofs, stride, phi0, theta, wgt, &ginfo);
00060 }
00061
00062 void set_ECP_geometry (int nrings, int nphi)
00063 {
00064 if (ginfo) sharp_destroy_geom_info(ginfo);
00065 sharp_make_ecp_geom_info (nrings, nphi, 0., 1, nphi, &ginfo);
00066 }
00067
00068 void set_Gauss_geometry (int nrings, int nphi)
00069 {
00070 if (ginfo) sharp_destroy_geom_info(ginfo);
00071 sharp_make_gauss_geom_info (nrings, nphi, 0., 1, nphi, &ginfo);
00072 }
00073
00074 void set_Healpix_geometry (int nside)
00075 {
00076 if (ginfo) sharp_destroy_geom_info(ginfo);
00077 sharp_make_healpix_geom_info (nside, 1, &ginfo);
00078 }
00079
00080 void set_weighted_Healpix_geometry (int nside, const double *weight)
00081 {
00082 if (ginfo) sharp_destroy_geom_info(ginfo);
00083 sharp_make_weighted_healpix_geom_info (nside, 1, weight, &ginfo);
00084 }
00085
00086 void set_triangular_alm_info (int lmax, int mmax)
00087 {
00088 if (ainfo) sharp_destroy_alm_info(ainfo);
00089 sharp_make_triangular_alm_info (lmax, mmax, 1, &ainfo);
00090 }
00091 };
00092
00093 template<typename T> struct cxxjobhelper__ {};
00094
00095 template<> struct cxxjobhelper__<double>
00096 { enum {val=SHARP_DP}; };
00097
00098 template<> struct cxxjobhelper__<float>
00099 { enum {val=0}; };
00100
00101
00102 template<typename T> class sharp_cxxjob: public sharp_base
00103 {
00104 private:
00105 static void *conv (T *ptr)
00106 { return reinterpret_cast<void *>(ptr); }
00107 static void *conv (const T *ptr)
00108 { return const_cast<void *>(reinterpret_cast<const void *>(ptr)); }
00109
00110 public:
00111 void alm2map (const T *alm, T *map, bool add)
00112 {
00113 void *aptr=conv(alm), *mptr=conv(map);
00114 int flags=cxxjobhelper__<T>::val | (add ? SHARP_ADD : 0);
00115 sharp_execute (SHARP_ALM2MAP, 0, &aptr, &mptr, ginfo, ainfo, 1,
00116 flags,0,0);
00117 }
00118 void alm2map_spin (const T *alm1, const T *alm2, T *map1, T *map2,
00119 int spin, bool add)
00120 {
00121 void *aptr[2], *mptr[2];
00122 aptr[0]=conv(alm1); aptr[1]=conv(alm2);
00123 mptr[0]=conv(map1); mptr[1]=conv(map2);
00124 int flags=cxxjobhelper__<T>::val | (add ? SHARP_ADD : 0);
00125 sharp_execute (SHARP_ALM2MAP,spin,aptr,mptr,ginfo,ainfo,1,flags,0,0);
00126 }
00127 void alm2map_der1 (const T *alm, T *map1, T *map2, bool add)
00128 {
00129 void *aptr=conv(alm), *mptr[2];
00130 mptr[0]=conv(map1); mptr[1]=conv(map2);
00131 int flags=cxxjobhelper__<T>::val | (add ? SHARP_ADD : 0);
00132 sharp_execute (SHARP_ALM2MAP_DERIV1,1,&aptr,mptr,ginfo,ainfo,1,flags,0,0);
00133 }
00134 void map2alm (const T *map, T *alm, bool add)
00135 {
00136 void *aptr=conv(alm), *mptr=conv(map);
00137 int flags=cxxjobhelper__<T>::val | (add ? SHARP_ADD : 0);
00138 sharp_execute (SHARP_MAP2ALM,0,&aptr,&mptr,ginfo,ainfo,1,flags,0,0);
00139 }
00140 void map2alm_spin (const T *map1, const T *map2, T *alm1, T *alm2,
00141 int spin, bool add)
00142 {
00143 void *aptr[2], *mptr[2];
00144 aptr[0]=conv(alm1); aptr[1]=conv(alm2);
00145 mptr[0]=conv(map1); mptr[1]=conv(map2);
00146 int flags=cxxjobhelper__<T>::val | (add ? SHARP_ADD : 0);
00147 sharp_execute (SHARP_MAP2ALM,spin,aptr,mptr,ginfo,ainfo,1,flags,0,0);
00148 }
00149 };
00150
00151 #endif