Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 10:03:52

0001 /* specfunc/gsl_sf_alf.h
0002  * 
0003  * Copyright (C) 2023 Patrick Alken
0004  * 
0005  * This program is free software; you can redistribute it and/or modify
0006  * it under the terms of the GNU General Public License as published by
0007  * the Free Software Foundation; either version 3 of the License, or (at
0008  * your option) any later version.
0009  * 
0010  * This program is distributed in the hope that it will be useful, but
0011  * WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  * General Public License for more details.
0014  * 
0015  * You should have received a copy of the GNU General Public License
0016  * along with this program; if not, write to the Free Software
0017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0018  */
0019 
0020 #ifndef __GSL_SF_ALF_H__
0021 #define __GSL_SF_ALF_H__
0022 
0023 #include <stdlib.h>
0024 #include <gsl/gsl_inline.h>
0025 #include <gsl/gsl_sf_result.h>
0026 
0027 #undef __BEGIN_DECLS
0028 #undef __END_DECLS
0029 #ifdef __cplusplus
0030 # define __BEGIN_DECLS extern "C" {
0031 # define __END_DECLS }
0032 #else
0033 # define __BEGIN_DECLS /* empty */
0034 # define __END_DECLS /* empty */
0035 #endif
0036 
0037 __BEGIN_DECLS
0038 
0039 typedef enum
0040 {
0041   GSL_SF_ALF_SCHMIDT,
0042   GSL_SF_ALF_SPHARM,
0043   GSL_SF_ALF_FULL,
0044   GSL_SF_ALF_FOURPI,
0045   GSL_SF_ALF_NONE
0046 } gsl_sf_alf_t;
0047 
0048 #define GSL_SF_ALF_FLG_CSPHASE       (1 << 0) /* include Condon-Shortley phase */
0049 
0050 int gsl_sf_alf_precompute(const gsl_sf_alf_t norm, const size_t lmax,
0051                           const size_t mmax, const size_t flags, double output_array[]);
0052 size_t gsl_sf_alf_array_size(const size_t lmax, const size_t mmax);
0053 int gsl_sf_alf_array(const size_t lmax, const size_t mmax, const double x, double result_array[]);
0054 int gsl_sf_alf_deriv_array(const size_t lmax, const size_t mmax, const double x,
0055                            double result_array[], double result_deriv_array[]);
0056 int gsl_sf_alf_vsh_array(const size_t lmax, const size_t mmax, const double x,
0057                          double result_array[], double result_deriv_array[]);
0058 
0059 INLINE_DECL size_t gsl_sf_alf_nlm(const size_t lmax, const size_t mmax);
0060 INLINE_DECL size_t gsl_sf_alf_array_index(const size_t l, const size_t m, const size_t lmax);
0061 
0062 #ifdef HAVE_INLINE
0063 
0064 /*
0065 gsl_sf_alf_array_index()
0066 This routine computes the index into a result_array[] corresponding
0067 to a given (l,m) using 'M' major indexing:
0068 
0069 (l,m) = (0,0) (1,0) (2,0) ... (L,0) (1,1) (2,1) ... (L,1) ... (L,L)
0070 
0071 index(l,m,L) = m*L - m(m-1)/2 + l
0072 */
0073 
0074 INLINE_FUN
0075 size_t
0076 gsl_sf_alf_array_index(const size_t l, const size_t m, const size_t lmax)
0077 {
0078   return (((m * (2 * lmax + 1 - m)) >> 1) + l);
0079 }
0080 
0081 /* return number of ALFs for a given lmax = (mmax+1)*(lmax+1) - mmax*(mmax+1)/2 */
0082 INLINE_FUN
0083 size_t
0084 gsl_sf_alf_nlm(const size_t lmax, const size_t mmax)
0085 {
0086   const size_t M = (mmax > lmax) ? lmax : mmax;
0087   return ((lmax + 1) * (M + 1) - ((M * (M + 1)) >> 1));
0088 }
0089 
0090 #endif /* HAVE_INLINE */
0091 
0092 __END_DECLS
0093 
0094 #endif /* __GSL_SF_ALF_H__ */