Skip to content

Commit cf7de6b

Browse files
author
Dag Sverre Seljebotn
committed
sharp_map_size and sharp_alm_count functions
1 parent c50c0fe commit cf7de6b

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

libsharp/sharp.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,19 @@ ptrdiff_t sharp_alm_index (const sharp_alm_info *self, int l, int mi)
169169
return self->mvstart[mi]+self->stride*l;
170170
}
171171

172+
ptrdiff_t sharp_alm_count(const sharp_alm_info *self)
173+
{
174+
ptrdiff_t result=0;
175+
for (int im=0; im!=self->nm; ++im)
176+
{
177+
int m=self->mval[im];
178+
ptrdiff_t x=(self->lmax + 1 - m);
179+
if ((m!=0)&&((self->flags&SHARP_PACKED)!=0)) result+=2*x;
180+
else result+=x;
181+
}
182+
return result;
183+
}
184+
172185
void sharp_destroy_alm_info (sharp_alm_info *info)
173186
{
174187
DEALLOC (info->mval);
@@ -226,6 +239,17 @@ void sharp_make_geom_info (int nrings, const int *nph, const ptrdiff_t *ofs,
226239
qsort(info->pair,info->npairs,sizeof(sharp_ringpair),ringpair_compare);
227240
}
228241

242+
ptrdiff_t sharp_map_size(const sharp_geom_info *info)
243+
{
244+
ptrdiff_t result = 0;
245+
for (int m=0; m<info->npairs; ++m)
246+
{
247+
result+=info->pair[m].r1.nph;
248+
result+=(info->pair[m].r2.nph>=0) ? (info->pair[m].r2.nph) : 0;
249+
}
250+
return result;
251+
}
252+
229253
void sharp_destroy_geom_info (sharp_geom_info *geom_info)
230254
{
231255
DEALLOC (geom_info->pair);

libsharp/sharp_lowlevel.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ void sharp_make_general_alm_info (int lmax, int nm, int stride, const int *mval,
134134
\note for a \a sharp_alm_info generated by sharp_make_alm_info() this is
135135
the index for the coefficient with the quantum numbers \a l, \a mi. */
136136
ptrdiff_t sharp_alm_index (const sharp_alm_info *self, int l, int mi);
137+
/*! Returns the number of alm coefficients described by \a self. If the SHARP_PACKED
138+
flag is set, this is number of "real" coeffecients (for m < 0 and m >= 0),
139+
otherwise it is the number of complex coefficients (with m>=0). */
140+
ptrdiff_t sharp_alm_count(const sharp_alm_info *self);
137141
/*! Deallocates the a_lm info object. */
138142
void sharp_destroy_alm_info (sharp_alm_info *info);
139143

@@ -159,6 +163,11 @@ void sharp_make_geom_info (int nrings, const int *nph, const ptrdiff_t *ofs,
159163
const int *stride, const double *phi0, const double *theta,
160164
const double *wgt, sharp_geom_info **geom_info);
161165

166+
/*! Counts the number of grid points needed for (the local part of) a map described
167+
by \a info.
168+
*/
169+
ptrdiff_t sharp_map_size(const sharp_geom_info *info);
170+
162171
/*! Deallocates the geometry information in \a info. */
163172
void sharp_destroy_geom_info (sharp_geom_info *info);
164173

0 commit comments

Comments
 (0)