Skip to content

Commit c50c0fe

Browse files
author
Dag Sverre Seljebotn
committed
Added sharp_make_mmajor_real_packed_alm_info
1 parent e364889 commit c50c0fe

4 files changed

Lines changed: 53 additions & 15 deletions

File tree

libsharp/sharp.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,8 @@ static void sharp_build_job_common (sharp_job *job, sharp_jobtype type,
859859
job->flags = flags;
860860
if ((job->flags&SHARP_NVMAX)==0)
861861
job->flags|=sharp_nv_oracle (type, spin, ntrans);
862+
if (alm_info->flags&SHARP_REAL_HARMONICS)
863+
job->flags|=SHARP_REAL_HARMONICS;
862864
job->time = 0.;
863865
job->opcnt = 0;
864866
job->ntrans = ntrans;

libsharp/sharp_almhelpers.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,27 @@ void sharp_make_rectangular_alm_info (int lmax, int mmax, int stride,
6868
}
6969
*alm_info = info;
7070
}
71+
72+
void sharp_make_mmajor_real_packed_alm_info (int lmax, int stride,
73+
int nm, const int *ms, sharp_alm_info **alm_info)
74+
{
75+
ptrdiff_t idx;
76+
int f;
77+
sharp_alm_info *info = RALLOC(sharp_alm_info,1);
78+
info->lmax = lmax;
79+
info->nm = nm;
80+
info->mval = RALLOC(int,nm);
81+
info->mvstart = RALLOC(ptrdiff_t,nm);
82+
info->stride = stride;
83+
info->flags = SHARP_PACKED | SHARP_REAL_HARMONICS;
84+
idx = 0; /* tracks the number of 'consumed' elements so far; need to correct by m */
85+
for (int im=0; im!=nm; ++im)
86+
{
87+
int m=(ms==NULL)?im:ms[im];
88+
f = (m==0) ? 1 : 2;
89+
info->mval[im] = m;
90+
info->mvstart[im] = stride * (idx - f * m);
91+
idx += f * (lmax + 1 - m);
92+
}
93+
*alm_info = info;
94+
}

libsharp/sharp_almhelpers.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ void sharp_make_triangular_alm_info (int lmax, int mmax, int stride,
5050
void sharp_make_rectangular_alm_info (int lmax, int mmax, int stride,
5151
sharp_alm_info **alm_info);
5252

53+
/*! Initialises alm_info for mmajor, real, packed spherical harmonics.
54+
Pass \a mmax + 1 to nm and NULL to \a ms in order to use everything;
55+
otherwise you can pick a subset of m to process (should only be used
56+
for MPI parallelization).
57+
\ingroup almgroup */
58+
void sharp_make_mmajor_real_packed_alm_info (int lmax, int stride,
59+
int nm, const int *ms, sharp_alm_info **alm_info);
60+
5361
#ifdef __cplusplus
5462
}
5563
#endif

libsharp/sharp_lowlevel.h

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,21 @@ typedef struct
8686
} sharp_alm_info;
8787

8888
/*! alm_info flags */
89-
typedef enum { SHARP_PACKED = 1
90-
/*< m=0-coefficients are packed so that the (zero) imaginary part is
91-
not present. mvstart is in units of *real* float/double for all
92-
m; stride is in units of reals for m=0 and complex for m!=0 */
89+
typedef enum { SHARP_PACKED = 1,
90+
/*!< m=0-coefficients are packed so that the (zero) imaginary part is
91+
not present. mvstart is in units of *real* float/double for all
92+
m; stride is in units of reals for m=0 and complex for m!=0 */
93+
SHARP_REAL_HARMONICS = 1<<6
94+
/*!< Use the real spherical harmonic convention. For
95+
m==0, the alm are treated exactly the same as in
96+
the complex case. For m!=0, alm[i] represent a
97+
pair (+abs(m), -abs(m)) instead of (real, imag),
98+
and the coefficients are scaled by a factor of
99+
sqrt(2) relative to the complex case. In other
100+
words, (sqrt(.5) * alm[i]) recovers the
101+
corresponding complex coefficient (when accessed
102+
as complex).
103+
*/
93104
} sharp_almflags;
94105

95106

@@ -172,17 +183,10 @@ typedef enum { SHARP_DP = 1<<4,
172183
SHARP_ADD = 1<<5,
173184
/*!< results are added to the output arrays, instead of
174185
overwriting them */
175-
SHARP_REAL_HARMONICS = 1<<6,
176-
/*!< Use the real spherical harmonic convention. For
177-
m==0, the alm are treated exactly the same as in
178-
the complex case. For m!=0, alm[i] represent a
179-
pair (+abs(m), -abs(m)) instead of (real, imag),
180-
and the coefficients are scaled by a factor of
181-
sqrt(2) relative to the complex case. In other
182-
words, (sqrt(.5) * alm[i]) recovers the
183-
corresponding complex coefficient (when accessed
184-
as complex).
185-
*/
186+
187+
/* NOTE: SHARP_REAL_HARMONICS, 1<<6, is also available in sharp_jobflags,
188+
but its use here is deprecated in favor of having it in the sharp_alm_info */
189+
186190
SHARP_NO_FFT = 1<<7,
187191

188192
SHARP_USE_WEIGHTS = 1<<20, /* internal use only */

0 commit comments

Comments
 (0)