gsl_sf_legendre.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. /* specfunc/gsl_sf_legendre.h
  2. *
  3. * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004 Gerard Jungman
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. */
  19. /* Author: G. Jungman */
  20. #ifndef __GSL_SF_LEGENDRE_H__
  21. #define __GSL_SF_LEGENDRE_H__
  22. #include "gsl_sf_result.h"
  23. #undef __BEGIN_DECLS
  24. #undef __END_DECLS
  25. #ifdef __cplusplus
  26. # define __BEGIN_DECLS extern "C" {
  27. # define __END_DECLS }
  28. #else
  29. # define __BEGIN_DECLS /* empty */
  30. # define __END_DECLS /* empty */
  31. #endif
  32. __BEGIN_DECLS
  33. /* P_l(x) l >= 0; |x| <= 1
  34. *
  35. * exceptions: GSL_EDOM
  36. */
  37. int gsl_sf_legendre_Pl_e(const int l, const double x, gsl_sf_result * result);
  38. double gsl_sf_legendre_Pl(const int l, const double x);
  39. /* P_l(x) for l=0,...,lmax; |x| <= 1
  40. *
  41. * exceptions: GSL_EDOM
  42. */
  43. int gsl_sf_legendre_Pl_array(
  44. const int lmax, const double x,
  45. double * result_array
  46. );
  47. /* P_l(x) and P_l'(x) for l=0,...,lmax; |x| <= 1
  48. *
  49. * exceptions: GSL_EDOM
  50. */
  51. int gsl_sf_legendre_Pl_deriv_array(
  52. const int lmax, const double x,
  53. double * result_array,
  54. double * result_deriv_array
  55. );
  56. /* P_l(x), l=1,2,3
  57. *
  58. * exceptions: none
  59. */
  60. int gsl_sf_legendre_P1_e(double x, gsl_sf_result * result);
  61. int gsl_sf_legendre_P2_e(double x, gsl_sf_result * result);
  62. int gsl_sf_legendre_P3_e(double x, gsl_sf_result * result);
  63. double gsl_sf_legendre_P1(const double x);
  64. double gsl_sf_legendre_P2(const double x);
  65. double gsl_sf_legendre_P3(const double x);
  66. /* Q_0(x), x > -1, x != 1
  67. *
  68. * exceptions: GSL_EDOM
  69. */
  70. int gsl_sf_legendre_Q0_e(const double x, gsl_sf_result * result);
  71. double gsl_sf_legendre_Q0(const double x);
  72. /* Q_1(x), x > -1, x != 1
  73. *
  74. * exceptions: GSL_EDOM
  75. */
  76. int gsl_sf_legendre_Q1_e(const double x, gsl_sf_result * result);
  77. double gsl_sf_legendre_Q1(const double x);
  78. /* Q_l(x), x > -1, x != 1, l >= 0
  79. *
  80. * exceptions: GSL_EDOM
  81. */
  82. int gsl_sf_legendre_Ql_e(const int l, const double x, gsl_sf_result * result);
  83. double gsl_sf_legendre_Ql(const int l, const double x);
  84. /* P_l^m(x) m >= 0; l >= m; |x| <= 1.0
  85. *
  86. * Note that this function grows combinatorially with l.
  87. * Therefore we can easily generate an overflow for l larger
  88. * than about 150.
  89. *
  90. * There is no trouble for small m, but when m and l are both large,
  91. * then there will be trouble. Rather than allow overflows, these
  92. * functions refuse to calculate when they can sense that l and m are
  93. * too big.
  94. *
  95. * If you really want to calculate a spherical harmonic, then DO NOT
  96. * use this. Instead use legendre_sphPlm() below, which uses a similar
  97. * recursion, but with the normalized functions.
  98. *
  99. * exceptions: GSL_EDOM, GSL_EOVRFLW
  100. */
  101. int gsl_sf_legendre_Plm_e(const int l, const int m, const double x, gsl_sf_result * result);
  102. double gsl_sf_legendre_Plm(const int l, const int m, const double x);
  103. /* P_l^m(x) m >= 0; l >= m; |x| <= 1.0
  104. * l=|m|,...,lmax
  105. *
  106. * exceptions: GSL_EDOM, GSL_EOVRFLW
  107. */
  108. int gsl_sf_legendre_Plm_array(
  109. const int lmax, const int m, const double x,
  110. double * result_array
  111. );
  112. /* P_l^m(x) and d(P_l^m(x))/dx; m >= 0; lmax >= m; |x| <= 1.0
  113. * l=|m|,...,lmax
  114. *
  115. * exceptions: GSL_EDOM, GSL_EOVRFLW
  116. */
  117. int gsl_sf_legendre_Plm_deriv_array(
  118. const int lmax, const int m, const double x,
  119. double * result_array,
  120. double * result_deriv_array
  121. );
  122. /* P_l^m(x), normalized properly for use in spherical harmonics
  123. * m >= 0; l >= m; |x| <= 1.0
  124. *
  125. * There is no overflow problem, as there is for the
  126. * standard normalization of P_l^m(x).
  127. *
  128. * Specifically, it returns:
  129. *
  130. * sqrt((2l+1)/(4pi)) sqrt((l-m)!/(l+m)!) P_l^m(x)
  131. *
  132. * exceptions: GSL_EDOM
  133. */
  134. int gsl_sf_legendre_sphPlm_e(const int l, int m, const double x, gsl_sf_result * result);
  135. double gsl_sf_legendre_sphPlm(const int l, const int m, const double x);
  136. /* sphPlm(l,m,x) values
  137. * m >= 0; l >= m; |x| <= 1.0
  138. * l=|m|,...,lmax
  139. *
  140. * exceptions: GSL_EDOM
  141. */
  142. int gsl_sf_legendre_sphPlm_array(
  143. const int lmax, int m, const double x,
  144. double * result_array
  145. );
  146. /* sphPlm(l,m,x) and d(sphPlm(l,m,x))/dx values
  147. * m >= 0; l >= m; |x| <= 1.0
  148. * l=|m|,...,lmax
  149. *
  150. * exceptions: GSL_EDOM
  151. */
  152. int gsl_sf_legendre_sphPlm_deriv_array(
  153. const int lmax, const int m, const double x,
  154. double * result_array,
  155. double * result_deriv_array
  156. );
  157. /* size of result_array[] needed for the array versions of Plm
  158. * (lmax - m + 1)
  159. */
  160. int gsl_sf_legendre_array_size(const int lmax, const int m);
  161. /* Irregular Spherical Conical Function
  162. * P^{1/2}_{-1/2 + I lambda}(x)
  163. *
  164. * x > -1.0
  165. * exceptions: GSL_EDOM
  166. */
  167. int gsl_sf_conicalP_half_e(const double lambda, const double x, gsl_sf_result * result);
  168. double gsl_sf_conicalP_half(const double lambda, const double x);
  169. /* Regular Spherical Conical Function
  170. * P^{-1/2}_{-1/2 + I lambda}(x)
  171. *
  172. * x > -1.0
  173. * exceptions: GSL_EDOM
  174. */
  175. int gsl_sf_conicalP_mhalf_e(const double lambda, const double x, gsl_sf_result * result);
  176. double gsl_sf_conicalP_mhalf(const double lambda, const double x);
  177. /* Conical Function
  178. * P^{0}_{-1/2 + I lambda}(x)
  179. *
  180. * x > -1.0
  181. * exceptions: GSL_EDOM
  182. */
  183. int gsl_sf_conicalP_0_e(const double lambda, const double x, gsl_sf_result * result);
  184. double gsl_sf_conicalP_0(const double lambda, const double x);
  185. /* Conical Function
  186. * P^{1}_{-1/2 + I lambda}(x)
  187. *
  188. * x > -1.0
  189. * exceptions: GSL_EDOM
  190. */
  191. int gsl_sf_conicalP_1_e(const double lambda, const double x, gsl_sf_result * result);
  192. double gsl_sf_conicalP_1(const double lambda, const double x);
  193. /* Regular Spherical Conical Function
  194. * P^{-1/2-l}_{-1/2 + I lambda}(x)
  195. *
  196. * x > -1.0, l >= -1
  197. * exceptions: GSL_EDOM
  198. */
  199. int gsl_sf_conicalP_sph_reg_e(const int l, const double lambda, const double x, gsl_sf_result * result);
  200. double gsl_sf_conicalP_sph_reg(const int l, const double lambda, const double x);
  201. /* Regular Cylindrical Conical Function
  202. * P^{-m}_{-1/2 + I lambda}(x)
  203. *
  204. * x > -1.0, m >= -1
  205. * exceptions: GSL_EDOM
  206. */
  207. int gsl_sf_conicalP_cyl_reg_e(const int m, const double lambda, const double x, gsl_sf_result * result);
  208. double gsl_sf_conicalP_cyl_reg(const int m, const double lambda, const double x);
  209. /* The following spherical functions are specializations
  210. * of Legendre functions which give the regular eigenfunctions
  211. * of the Laplacian on a 3-dimensional hyperbolic space.
  212. * Of particular interest is the flat limit, which is
  213. * Flat-Lim := {lambda->Inf, eta->0, lambda*eta fixed}.
  214. */
  215. /* Zeroth radial eigenfunction of the Laplacian on the
  216. * 3-dimensional hyperbolic space.
  217. *
  218. * legendre_H3d_0(lambda,eta) := sin(lambda*eta)/(lambda*sinh(eta))
  219. *
  220. * Normalization:
  221. * Flat-Lim legendre_H3d_0(lambda,eta) = j_0(lambda*eta)
  222. *
  223. * eta >= 0.0
  224. * exceptions: GSL_EDOM
  225. */
  226. int gsl_sf_legendre_H3d_0_e(const double lambda, const double eta, gsl_sf_result * result);
  227. double gsl_sf_legendre_H3d_0(const double lambda, const double eta);
  228. /* First radial eigenfunction of the Laplacian on the
  229. * 3-dimensional hyperbolic space.
  230. *
  231. * legendre_H3d_1(lambda,eta) :=
  232. * 1/sqrt(lambda^2 + 1) sin(lam eta)/(lam sinh(eta))
  233. * (coth(eta) - lambda cot(lambda*eta))
  234. *
  235. * Normalization:
  236. * Flat-Lim legendre_H3d_1(lambda,eta) = j_1(lambda*eta)
  237. *
  238. * eta >= 0.0
  239. * exceptions: GSL_EDOM
  240. */
  241. int gsl_sf_legendre_H3d_1_e(const double lambda, const double eta, gsl_sf_result * result);
  242. double gsl_sf_legendre_H3d_1(const double lambda, const double eta);
  243. /* l'th radial eigenfunction of the Laplacian on the
  244. * 3-dimensional hyperbolic space.
  245. *
  246. * Normalization:
  247. * Flat-Lim legendre_H3d_l(l,lambda,eta) = j_l(lambda*eta)
  248. *
  249. * eta >= 0.0, l >= 0
  250. * exceptions: GSL_EDOM
  251. */
  252. int gsl_sf_legendre_H3d_e(const int l, const double lambda, const double eta, gsl_sf_result * result);
  253. double gsl_sf_legendre_H3d(const int l, const double lambda, const double eta);
  254. /* Array of H3d(ell), 0 <= ell <= lmax
  255. */
  256. int gsl_sf_legendre_H3d_array(const int lmax, const double lambda, const double eta, double * result_array);
  257. #ifdef HAVE_INLINE
  258. extern inline
  259. int
  260. gsl_sf_legendre_array_size(const int lmax, const int m)
  261. {
  262. return lmax-m+1;
  263. }
  264. #endif /* HAVE_INLINE */
  265. __END_DECLS
  266. #endif /* __GSL_SF_LEGENDRE_H__ */