00001 /* 00002 * This file is part of libsharp. 00003 * 00004 * libsharp is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * libsharp is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with libsharp; if not, write to the Free Software 00016 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00017 */ 00018 00019 /* 00020 * libsharp is being developed at the Max-Planck-Institut fuer Astrophysik 00021 * and financially supported by the Deutsches Zentrum fuer Luft- und Raumfahrt 00022 * (DLR). 00023 */ 00024 00025 /*! \file sharp_ylmgen_c.h 00026 * Code for efficient calculation of Y_lm(phi=0,theta) 00027 * 00028 * Copyright (C) 2005-2012 Max-Planck-Society 00029 * \author Martin Reinecke 00030 */ 00031 00032 #ifndef SHARP_YLMGEN_C_H 00033 #define SHARP_YLMGEN_C_H 00034 00035 #ifdef __cplusplus 00036 extern "C" { 00037 #endif 00038 00039 enum { sharp_minscale=0, sharp_limscale=1, sharp_maxscale=1 }; 00040 static const double sharp_fbig=0x1p+800,sharp_fsmall=0x1p-800; 00041 static const double sharp_ftol=0x1p-60; 00042 static const double sharp_fbighalf=0x1p+400; 00043 00044 typedef struct { double f[2]; } sharp_ylmgen_dbl2; 00045 typedef struct { double f[3]; } sharp_ylmgen_dbl3; 00046 00047 typedef struct 00048 { 00049 /* for public use; immutable during lifetime */ 00050 int lmax, mmax, s; 00051 double *cf; 00052 00053 /* for public use; will typically change after call to Ylmgen_prepare() */ 00054 int m; 00055 00056 /* used if s==0 */ 00057 double *mfac; 00058 sharp_ylmgen_dbl2 *rf; 00059 00060 /* used if s!=0 */ 00061 int sinPow, cosPow, preMinus_p, preMinus_m; 00062 double *prefac; 00063 int *fscale; 00064 sharp_ylmgen_dbl3 *fx; 00065 00066 /* internal usage only */ 00067 /* used if s==0 */ 00068 double *root, *iroot; 00069 00070 /* used if s!=0 */ 00071 double *flm1, *flm2, *inv; 00072 int mlo, mhi; 00073 } sharp_Ylmgen_C; 00074 00075 /*! Creates a generator which will calculate helper data for Y_lm calculation 00076 up to \a l=l_max and \a m=m_max. */ 00077 void sharp_Ylmgen_init (sharp_Ylmgen_C *gen, int l_max, int m_max, int spin); 00078 00079 /*! Deallocates a generator previously initialised by Ylmgen_init(). */ 00080 void sharp_Ylmgen_destroy (sharp_Ylmgen_C *gen); 00081 00082 /*! Prepares the object for the calculation at \a m. */ 00083 void sharp_Ylmgen_prepare (sharp_Ylmgen_C *gen, int m); 00084 00085 /*! Returns a pointer to an array with \a lmax+1 entries containing 00086 normalisation factors that must be applied to Y_lm values computed for 00087 \a spin. The array must be deallocated (using free()) by the user. */ 00088 double *sharp_Ylmgen_get_norm (int lmax, int spin); 00089 00090 /*! Returns a pointer to an array with \a lmax+1 entries containing 00091 normalisation factors that must be applied to Y_lm values computed for 00092 first derivatives. The array must be deallocated (using free()) by the 00093 user. */ 00094 double *sharp_Ylmgen_get_d1norm (int lmax); 00095 00096 #ifdef __cplusplus 00097 } 00098 #endif 00099 00100 #endif