From cf7de6ba70c8ea52ce67abfca82f38ebb3205f17 Mon Sep 17 00:00:00 2001 From: Dag Sverre Seljebotn Date: Mon, 30 Mar 2015 12:13:21 +0200 Subject: [PATCH] sharp_map_size and sharp_alm_count functions --- libsharp/sharp.c | 24 ++++++++++++++++++++++++ libsharp/sharp_lowlevel.h | 9 +++++++++ 2 files changed, 33 insertions(+) diff --git a/libsharp/sharp.c b/libsharp/sharp.c index f430364..e5a5634 100644 --- a/libsharp/sharp.c +++ b/libsharp/sharp.c @@ -169,6 +169,19 @@ ptrdiff_t sharp_alm_index (const sharp_alm_info *self, int l, int mi) return self->mvstart[mi]+self->stride*l; } +ptrdiff_t sharp_alm_count(const sharp_alm_info *self) + { + ptrdiff_t result=0; + for (int im=0; im!=self->nm; ++im) + { + int m=self->mval[im]; + ptrdiff_t x=(self->lmax + 1 - m); + if ((m!=0)&&((self->flags&SHARP_PACKED)!=0)) result+=2*x; + else result+=x; + } + return result; + } + void sharp_destroy_alm_info (sharp_alm_info *info) { DEALLOC (info->mval); @@ -226,6 +239,17 @@ void sharp_make_geom_info (int nrings, const int *nph, const ptrdiff_t *ofs, qsort(info->pair,info->npairs,sizeof(sharp_ringpair),ringpair_compare); } +ptrdiff_t sharp_map_size(const sharp_geom_info *info) + { + ptrdiff_t result = 0; + for (int m=0; mnpairs; ++m) + { + result+=info->pair[m].r1.nph; + result+=(info->pair[m].r2.nph>=0) ? (info->pair[m].r2.nph) : 0; + } + return result; + } + void sharp_destroy_geom_info (sharp_geom_info *geom_info) { DEALLOC (geom_info->pair); diff --git a/libsharp/sharp_lowlevel.h b/libsharp/sharp_lowlevel.h index 129a1b8..0260c37 100644 --- a/libsharp/sharp_lowlevel.h +++ b/libsharp/sharp_lowlevel.h @@ -134,6 +134,10 @@ void sharp_make_general_alm_info (int lmax, int nm, int stride, const int *mval, \note for a \a sharp_alm_info generated by sharp_make_alm_info() this is the index for the coefficient with the quantum numbers \a l, \a mi. */ ptrdiff_t sharp_alm_index (const sharp_alm_info *self, int l, int mi); +/*! Returns the number of alm coefficients described by \a self. If the SHARP_PACKED + flag is set, this is number of "real" coeffecients (for m < 0 and m >= 0), + otherwise it is the number of complex coefficients (with m>=0). */ +ptrdiff_t sharp_alm_count(const sharp_alm_info *self); /*! Deallocates the a_lm info object. */ void sharp_destroy_alm_info (sharp_alm_info *info); @@ -159,6 +163,11 @@ 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 *wgt, sharp_geom_info **geom_info); +/*! Counts the number of grid points needed for (the local part of) a map described + by \a info. + */ +ptrdiff_t sharp_map_size(const sharp_geom_info *info); + /*! Deallocates the geometry information in \a info. */ void sharp_destroy_geom_info (sharp_geom_info *info);