LevelS SHT library  3.50
sharp_almhelpers.c
Go to the documentation of this file.
1 /*
2  * This file is part of libsharp.
3  *
4  * libsharp is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * libsharp is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with libsharp; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 /*
20  * libsharp is being developed at the Max-Planck-Institut fuer Astrophysik
21  * and financially supported by the Deutsches Zentrum fuer Luft- und Raumfahrt
22  * (DLR).
23  */
24 
25 /*! \file sharp_almhelpers.c
26  * Spherical transform library
27  *
28  * Copyright (C) 2008-2016 Max-Planck-Society
29  * \author Martin Reinecke
30  */
31 
32 #include "sharp_almhelpers.h"
33 #include "c_utils.h"
34 
35 void sharp_make_triangular_alm_info (int lmax, int mmax, int stride,
36  sharp_alm_info **alm_info)
37  {
38  sharp_alm_info *info = RALLOC(sharp_alm_info,1);
39  info->lmax = lmax;
40  info->nm = mmax+1;
41  info->mval = RALLOC(int,mmax+1);
42  info->mvstart = RALLOC(ptrdiff_t,mmax+1);
43  info->stride = stride;
44  info->flags = 0;
45  ptrdiff_t tval = 2*lmax+1;
46  for (ptrdiff_t m=0; m<=mmax; ++m)
47  {
48  info->mval[m] = m;
49  info->mvstart[m] = stride*((m*(tval-m))>>1);
50  }
51  *alm_info = info;
52  }
53 
54 void sharp_make_rectangular_alm_info (int lmax, int mmax, int stride,
55  sharp_alm_info **alm_info)
56  {
57  sharp_alm_info *info = RALLOC(sharp_alm_info,1);
58  info->lmax = lmax;
59  info->nm = mmax+1;
60  info->mval = RALLOC(int,mmax+1);
61  info->mvstart = RALLOC(ptrdiff_t,mmax+1);
62  info->stride = stride;
63  info->flags = 0;
64  for (ptrdiff_t m=0; m<=mmax; ++m)
65  {
66  info->mval[m] = m;
67  info->mvstart[m] = stride*m*(lmax+1);
68  }
69  *alm_info = info;
70  }
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  }
#define RALLOC(type, num)
void sharp_make_triangular_alm_info(int lmax, int mmax, int stride, sharp_alm_info **alm_info)
void sharp_make_mmajor_real_packed_alm_info(int lmax, int stride, int nm, const int *ms, sharp_alm_info **alm_info)
void sharp_make_rectangular_alm_info(int lmax, int mmax, int stride, sharp_alm_info **alm_info)

Generated on Mon Dec 10 2018 10:24:20 for LevelS SHT library