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_ylmgen_c.h
26  *  Code for efficient calculation of Y_lm(phi=0,theta)
27  *
28  *  Copyright (C) 2005-2012 Max-Planck-Society
29  *  \author Martin Reinecke
30  */
31 
32 #ifndef SHARP_YLMGEN_C_H
33 #define SHARP_YLMGEN_C_H
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 enum { sharp_minscale=0, sharp_limscale=1, sharp_maxscale=1 };
40 static const double sharp_fbig=0x1p+800,sharp_fsmall=0x1p-800;
41 static const double sharp_ftol=0x1p-60;
42 static const double sharp_fbighalf=0x1p+400;
43 
44 typedef struct { double f[2]; } sharp_ylmgen_dbl2;
45 typedef struct { double f[3]; } sharp_ylmgen_dbl3;
46 
47 typedef struct
48   {
49 /* for public use; immutable during lifetime */
50   int lmax, mmax, s;
51   double *cf;
52 
53 /* for public use; will typically change after call to Ylmgen_prepare() */
54   int m;
55 
56 /* used if s==0 */
57   double *mfac;
58   sharp_ylmgen_dbl2 *rf;
59 
60 /* used if s!=0 */
61   int sinPow, cosPow, preMinus_p, preMinus_m;
62   double *prefac;
63   int *fscale;
64   sharp_ylmgen_dbl3 *fx;
65 
66 /* internal usage only */
67 /* used if s==0 */
68   double *root, *iroot;
69 
70 /* used if s!=0 */
71   double *flm1, *flm2, *inv;
72   int mlo, mhi;
73   } sharp_Ylmgen_C;
74 
75 /*! Creates a generator which will calculate helper data for Y_lm calculation
76     up to \a l=l_max and \a m=m_max. */
77 void sharp_Ylmgen_init (sharp_Ylmgen_C *gen, int l_max, int m_max, int spin);
78 
79 /*! Deallocates a generator previously initialised by Ylmgen_init(). */
80 void sharp_Ylmgen_destroy (sharp_Ylmgen_C *gen);
81 
82 /*! Prepares the object for the calculation at \a m. */
83 void sharp_Ylmgen_prepare (sharp_Ylmgen_C *gen, int m);
84 
85 /*! Returns a pointer to an array with \a lmax+1 entries containing
86     normalisation factors that must be applied to Y_lm values computed for
87     \a spin. The array must be deallocated (using free()) by the user. */
88 double *sharp_Ylmgen_get_norm (int lmax, int spin);
89 
90 /*! Returns a pointer to an array with \a lmax+1 entries containing
91     normalisation factors that must be applied to Y_lm values computed for
92     first derivatives. The array must be deallocated (using free()) by the
93     user. */
94 double *sharp_Ylmgen_get_d1norm (int lmax);
95 
96 #ifdef __cplusplus
97 }
98 #endif
99 
100 #endif
101