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-2011 Max-Planck-Society
29  *  \author Martin Reinecke
30  */
31 
32 #include "sharp_almhelpers.h"
33 #include "c_utils.h"
34 
hpsharp_make_triangular_alm_info(int lmax,int mmax,int stride,hpsharp_alm_info ** alm_info)35 void hpsharp_make_triangular_alm_info (int lmax, int mmax, int stride,
36   hpsharp_alm_info **alm_info)
37   {
38   hpsharp_alm_info *info = RALLOC(hpsharp_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   int tval = 2*lmax+1;
45   for (ptrdiff_t m=0; m<=mmax; ++m)
46     {
47     info->mval[m] = m;
48     info->mvstart[m] = stride*((m*(tval-m))>>1);
49     }
50   *alm_info = info;
51   }
52 
hpsharp_make_rectangular_alm_info(int lmax,int mmax,int stride,hpsharp_alm_info ** alm_info)53 void hpsharp_make_rectangular_alm_info (int lmax, int mmax, int stride,
54   hpsharp_alm_info **alm_info)
55   {
56   hpsharp_alm_info *info = RALLOC(hpsharp_alm_info,1);
57   info->lmax = lmax;
58   info->nm = mmax+1;
59   info->mval = RALLOC(int,mmax+1);
60   info->mvstart = RALLOC(ptrdiff_t,mmax+1);
61   info->stride = stride;
62   for (ptrdiff_t m=0; m<=mmax; ++m)
63     {
64     info->mval[m] = m;
65     info->mvstart[m] = stride*m*(lmax+1);
66     }
67   *alm_info = info;
68   }
69