diff --git a/libsharp/sharp.c b/libsharp/sharp.c index 6daada9..6a15a51 100644 --- a/libsharp/sharp.c +++ b/libsharp/sharp.c @@ -584,16 +584,19 @@ void sharps_build_job (sharp_job *job, sharp_jobtype type, int spin, job->fde=FLOAT; } -void sharp_build_job_ll (sharp_job *job, sharp_jobtype type, int spin, - int add_output, void **alm, void **map, const sharp_geom_info *geom_info, - const sharp_alm_info *alm_info, int ntrans, int dp) +void sharp_execute_ll (sharp_jobtype type, int spin, int add_output, void **alm, + void **map, const sharp_geom_info *geom_info, const sharp_alm_info *alm_info, + int ntrans, int dp) { + sharp_job job; if (dp) - sharpd_build_job (job, type, spin, add_output, (dcmplx **)alm, + sharpd_build_job (&job, type, spin, add_output, (dcmplx **)alm, (double **)map, geom_info, alm_info, ntrans); else - sharps_build_job (job, type, spin, add_output, (fcmplx **)alm, + sharps_build_job (&job, type, spin, add_output, (fcmplx **)alm, (float **)map, geom_info, alm_info, ntrans); + + sharp_execute_job (&job); } int sharp_get_nv_max (void) diff --git a/libsharp/sharp.h b/libsharp/sharp.h index ab7ecf9..fed7361 100644 --- a/libsharp/sharp.h +++ b/libsharp/sharp.h @@ -32,118 +32,13 @@ #ifndef PLANCK_SHARP_H #define PLANCK_SHARP_H -#include -#include - #ifdef __cplusplus -extern "C" { +#error This header file cannot be included from C++, only from C #endif -/*! \internal - Helper type containing information about a single ring. */ -typedef struct - { - double theta, phi0, weight, cth, sth; - ptrdiff_t ofs; - int nph, stride; - } sharp_ringinfo; +#include -/*! \internal - Helper type containing information about a pair of rings with colatitudes - symmetric around the equator. */ -typedef struct - { - sharp_ringinfo r1,r2; - } sharp_ringpair; - -/*! \internal - Type holding all required information about a map geometry. */ -typedef struct - { - sharp_ringpair *pair; - int npairs; - } sharp_geom_info; - -/*! \defgroup almgroup Helpers for dealing with a_lm */ -/*! \{ */ - -/*! \internal - Helper type for index calculation in a_lm arrays. */ -typedef struct - { - /*! Maximum \a l index of the array */ - int lmax; - /*! Number of different \a m values in this object */ - int nm; - /*! Array with \a nm entries containing the individual m values */ - int *mval; - /*! Array with \a nm entries containing the (hypothetical) indices of - the coefficients with quantum numbers 0,\a mval[i] */ - ptrdiff_t *mvstart; - /*! Stride between a_lm and a_(l+1),m */ - ptrdiff_t stride; - } sharp_alm_info; - -/*! Creates an Alm data structure information from the following parameters: - \param lmax maximum \a l quantum number (>=0) - \param mmax maximum \a m quantum number (0<= \a mmax <= \a lmax) - \param stride the stride between consecutive a_lm entries - \param mstart the index of the (hypothetical) coefficient with the - quantum numbers 0,\a m. Must have \a mmax+1 entries. - \param alm_info will hold a pointer to the newly created data structure - */ -void sharp_make_alm_info (int lmax, int mmax, int stride, - const ptrdiff_t *mstart, sharp_alm_info **alm_info); -/*! Creates an Alm data structure information from the following parameters: - \param lmax maximum \a l quantum number (>=0) - \param nm number of different \a m (<=\a lmax+1) - \param stride the stride between consecutive a_lm entries - \param mval array with \a nm entries containing the individual m values - \param mvstart array with \a nm entries containing the (hypothetical) - indices of the coefficients with the quantum numbers 0,\a mval[i] - \param alm_info will hold a pointer to the newly created data structure - */ -void sharp_make_general_alm_info (int lmax, int nm, int stride, const int *mval, - const ptrdiff_t *mvstart, sharp_alm_info **alm_info); -/*! Returns the index of the coefficient with quantum numbers \a l, - \a mval[mi]. */ -ptrdiff_t sharp_alm_index (const sharp_alm_info *self, int l, int mi); -/*! Deallocates the a_lm info object. */ -void sharp_destroy_alm_info (sharp_alm_info *info); - -/*! \} */ - -/*! \defgroup geominfogroup Functions for dealing with geometry information */ -/*! \{ */ - -/*! Creates a geometry information from a set of ring descriptions. - All arrays passed to this function must have \a nrings elements. - \param nrings the number of rings in the map - \param nph the number of pixels in each ring - \param ofs the index of the first pixel in each ring in the map array - \param stride the stride between consecutive pixels - \param phi0 the azimuth (in radians) of the first pixel in each ring - \param theta the colatitude (in radians) of each ring - \param weight the pixel weight to be used for the ring - \param geom_info will hold a pointer to the newly created data structure - */ -void sharp_make_geom_info (int nrings, const int *nph, const ptrdiff_t *ofs, - const int *stride, const double *phi0, const double *theta, - const double *weight, sharp_geom_info **geom_info); - -/*! Deallocates the geometry information in \a info. */ -void sharp_destroy_geom_info (sharp_geom_info *info); - -/*! \} */ - -/*! \defgroup jobgroup Functionality for defining and executing SHTs */ -/*! \{ */ - -/*! Enumeration of SHARP job types. */ -typedef enum { SHARP_MAP2ALM, /*!< analysis */ - SHARP_ALM2MAP, /*!< synthesis */ - SHARP_ALM2MAP_DERIV1 /*!< synthesis of first derivatives */ - } sharp_jobtype; +#include "sharp_lowlevel.h" typedef enum { FLOAT, DOUBLE } sharp_fde; @@ -195,10 +90,6 @@ void sharps_build_job (sharp_job *job, sharp_jobtype type, int spin, int add_output, complex float **alm, float **map, const sharp_geom_info *geom_info, const sharp_alm_info *alm_info, int ntrans); -void sharp_build_job_ll (sharp_job *job, sharp_jobtype type, int spin, - int add_output, void **alm, void **map, const sharp_geom_info *geom_info, - const sharp_alm_info *alm_info, int ntrans, int dp); - /*! Execute the SHT job previously constructed by sharpd_build_job() or sharps_build_job(). */ void sharp_execute_job (sharp_job *job); @@ -210,8 +101,4 @@ int sharp_get_nv_max (void); /*! Internal */ int sharp_nv_oracle (sharp_jobtype type, int spin, int ntrans); -#ifdef __cplusplus -} -#endif - #endif diff --git a/libsharp/sharp_almhelpers.h b/libsharp/sharp_almhelpers.h index c6cb35a..9cf9534 100644 --- a/libsharp/sharp_almhelpers.h +++ b/libsharp/sharp_almhelpers.h @@ -32,7 +32,7 @@ #ifndef PLANCK_SHARP_ALMHELPERS_H #define PLANCK_SHARP_ALMHELPERS_H -#include "sharp.h" +#include "sharp_lowlevel.h" #ifdef __cplusplus extern "C" { diff --git a/libsharp/sharp_cxx.h b/libsharp/sharp_cxx.h index 5a513c0..1372fe0 100644 --- a/libsharp/sharp_cxx.h +++ b/libsharp/sharp_cxx.h @@ -25,14 +25,14 @@ /*! \file sharp_cxx.h * Spherical transform library * - * Copyright (C) 2008, 2009 Max-Planck-Society + * Copyright (C) 2012 Max-Planck-Society * \author Martin Reinecke */ #ifndef PLANCK_SHARP_CXX_H #define PLANCK_SHARP_CXX_H -#include "sharp.h" +#include "sharp_lowlevel.h" #include "sharp_geomhelpers.h" #include "sharp_almhelpers.h" #include "xcomplex.h" @@ -40,7 +40,6 @@ class sharp_base { protected: - sharp_job job; sharp_alm_info *ainfo; sharp_geom_info *ginfo; @@ -99,9 +98,8 @@ template class sharp_cxxjob: public sharp_base void alm2map (const xcomplex *alm, T *map, bool add) { void *aptr=conv(alm), *mptr=conv(map); - sharp_build_job_ll (&job, SHARP_ALM2MAP, 0, add, &aptr, &mptr, ginfo, - ainfo, 1, cxxjobhelper__::val); - sharp_execute_job(&job); + sharp_execute_ll (SHARP_ALM2MAP, 0, add, &aptr, &mptr, ginfo, ainfo, 1, + cxxjobhelper__::val); } void alm2map_spin (const xcomplex *alm1, const xcomplex *alm2, T *map1, T *map2, int spin, bool add) @@ -109,24 +107,21 @@ template class sharp_cxxjob: public sharp_base void *aptr[2], *mptr[2]; aptr[0]=conv(alm1); aptr[1]=conv(alm2); mptr[0]=conv(map1); mptr[1]=conv(map2); - sharp_build_job_ll (&job, SHARP_ALM2MAP, spin, add, aptr, mptr, ginfo, - ainfo, 1, cxxjobhelper__::val); - sharp_execute_job(&job); + sharp_execute_ll (SHARP_ALM2MAP, spin, add, aptr, mptr, ginfo, ainfo, 1, + cxxjobhelper__::val); } void alm2map_der1 (const xcomplex *alm, T *map1, T *map2, bool add) { void *aptr=conv(alm), *mptr[2]; mptr[0]=conv(map1); mptr[1]=conv(map2); - sharp_build_job_ll (&job, SHARP_ALM2MAP_DERIV1, 1, add,&aptr, mptr, ginfo, - ainfo, 1, cxxjobhelper__::val); - sharp_execute_job(&job); + sharp_execute_ll (SHARP_ALM2MAP_DERIV1, 1, add,&aptr, mptr, ginfo, ainfo, + 1, cxxjobhelper__::val); } void map2alm (const T *map, xcomplex *alm, bool add) { void *aptr=conv(alm), *mptr=conv(map); - sharp_build_job_ll (&job, SHARP_MAP2ALM, 0, add, &aptr, &mptr, ginfo, - ainfo, 1, cxxjobhelper__::val); - sharp_execute_job(&job); + sharp_execute_ll (SHARP_MAP2ALM, 0, add, &aptr, &mptr, ginfo, ainfo, 1, + cxxjobhelper__::val); } void map2alm_spin (const T *map1, const T *map2, xcomplex *alm1, xcomplex *alm2, int spin, bool add) @@ -134,9 +129,8 @@ template class sharp_cxxjob: public sharp_base void *aptr[2], *mptr[2]; aptr[0]=conv(alm1); aptr[1]=conv(alm2); mptr[0]=conv(map1); mptr[1]=conv(map2); - sharp_build_job_ll (&job, SHARP_MAP2ALM, spin, add, aptr, mptr, ginfo, - ainfo, 1, cxxjobhelper__::val); - sharp_execute_job(&job); + sharp_execute_ll (SHARP_MAP2ALM, spin, add, aptr, mptr, ginfo, ainfo, 1, + cxxjobhelper__::val); } }; diff --git a/libsharp/sharp_geomhelpers.h b/libsharp/sharp_geomhelpers.h index 8f20f74..28c9235 100644 --- a/libsharp/sharp_geomhelpers.h +++ b/libsharp/sharp_geomhelpers.h @@ -32,7 +32,7 @@ #ifndef PLANCK_SHARP_GEOMHELPERS_H #define PLANCK_SHARP_GEOMHELPERS_H -#include "sharp.h" +#include "sharp_lowlevel.h" #ifdef __cplusplus extern "C" { diff --git a/libsharp/sharp_lowlevel.h b/libsharp/sharp_lowlevel.h new file mode 100644 index 0000000..3899abb --- /dev/null +++ b/libsharp/sharp_lowlevel.h @@ -0,0 +1,155 @@ +/* + * 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_lowlevel.h + * Low-level, portable interface for the spherical transform library. + * + * Copyright (C) 2012 Max-Planck-Society + * \author Martin Reinecke + */ + +#ifndef PLANCK_SHARP_LOWLEVEL_H +#define PLANCK_SHARP_LOWLEVEL_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \internal + Helper type containing information about a single ring. */ +typedef struct + { + double theta, phi0, weight, cth, sth; + ptrdiff_t ofs; + int nph, stride; + } sharp_ringinfo; + +/*! \internal + Helper type containing information about a pair of rings with colatitudes + symmetric around the equator. */ +typedef struct + { + sharp_ringinfo r1,r2; + } sharp_ringpair; + +/*! \internal + Type holding all required information about a map geometry. */ +typedef struct + { + sharp_ringpair *pair; + int npairs; + } sharp_geom_info; + +/*! \defgroup almgroup Helpers for dealing with a_lm */ +/*! \{ */ + +/*! \internal + Helper type for index calculation in a_lm arrays. */ +typedef struct + { + /*! Maximum \a l index of the array */ + int lmax; + /*! Number of different \a m values in this object */ + int nm; + /*! Array with \a nm entries containing the individual m values */ + int *mval; + /*! Array with \a nm entries containing the (hypothetical) indices of + the coefficients with quantum numbers 0,\a mval[i] */ + ptrdiff_t *mvstart; + /*! Stride between a_lm and a_(l+1),m */ + ptrdiff_t stride; + } sharp_alm_info; + +/*! Creates an Alm data structure information from the following parameters: + \param lmax maximum \a l quantum number (>=0) + \param mmax maximum \a m quantum number (0<= \a mmax <= \a lmax) + \param stride the stride between consecutive a_lm entries + \param mstart the index of the (hypothetical) coefficient with the + quantum numbers 0,\a m. Must have \a mmax+1 entries. + \param alm_info will hold a pointer to the newly created data structure + */ +void sharp_make_alm_info (int lmax, int mmax, int stride, + const ptrdiff_t *mstart, sharp_alm_info **alm_info); +/*! Creates an Alm data structure information from the following parameters: + \param lmax maximum \a l quantum number (>=0) + \param nm number of different \a m (<=\a lmax+1) + \param stride the stride between consecutive a_lm entries + \param mval array with \a nm entries containing the individual m values + \param mvstart array with \a nm entries containing the (hypothetical) + indices of the coefficients with the quantum numbers 0,\a mval[i] + \param alm_info will hold a pointer to the newly created data structure + */ +void sharp_make_general_alm_info (int lmax, int nm, int stride, const int *mval, + const ptrdiff_t *mvstart, sharp_alm_info **alm_info); +/*! Returns the index of the coefficient with quantum numbers \a l, + \a mval[mi]. */ +ptrdiff_t sharp_alm_index (const sharp_alm_info *self, int l, int mi); +/*! Deallocates the a_lm info object. */ +void sharp_destroy_alm_info (sharp_alm_info *info); + +/*! \} */ + +/*! \defgroup geominfogroup Functions for dealing with geometry information */ +/*! \{ */ + +/*! Creates a geometry information from a set of ring descriptions. + All arrays passed to this function must have \a nrings elements. + \param nrings the number of rings in the map + \param nph the number of pixels in each ring + \param ofs the index of the first pixel in each ring in the map array + \param stride the stride between consecutive pixels + \param phi0 the azimuth (in radians) of the first pixel in each ring + \param theta the colatitude (in radians) of each ring + \param weight the pixel weight to be used for the ring + \param geom_info will hold a pointer to the newly created data structure + */ +void sharp_make_geom_info (int nrings, const int *nph, const ptrdiff_t *ofs, + const int *stride, const double *phi0, const double *theta, + const double *weight, sharp_geom_info **geom_info); + +/*! Deallocates the geometry information in \a info. */ +void sharp_destroy_geom_info (sharp_geom_info *info); + +/*! \} */ + +/*! \defgroup jobgroup Functionality for defining and executing SHTs */ +/*! \{ */ + +/*! Enumeration of SHARP job types. */ +typedef enum { SHARP_MAP2ALM, /*!< analysis */ + SHARP_ALM2MAP, /*!< synthesis */ + SHARP_ALM2MAP_DERIV1 /*!< synthesis of first derivatives */ + } sharp_jobtype; + +void sharp_execute_ll (sharp_jobtype type, int spin, int add_output, void **alm, + void **map, const sharp_geom_info *geom_info, const sharp_alm_info *alm_info, + int ntrans, int dp); + +#ifdef __cplusplus +} +#endif + +#endif