tr1.qbk 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. [template tr1_overview[]
  2. Many of the special functions included in this library are also a part
  3. of the either the [C99] or the [tr1]. Therefore this library
  4. includes a thin wrapper header `boost/math/tr1.hpp` that provides
  5. compatibility with these two standards.
  6. There are various pros and cons to using the library in this way:
  7. Pros:
  8. * The header to include is lightweight (i.e. fast to compile).
  9. * The functions have extern "C" linkage,
  10. and so are usable from other languages (not just C and C++).
  11. * C99 and C++ TR1 Standard compatibility.
  12. Cons:
  13. * You will need to compile and link to the external Boost.Math libraries.
  14. * Limited to support for the types, `float`, `double` and `long double`.
  15. * Error handling is handled via setting ::errno and returning NaN's and
  16. infinities: this may be less flexible than an C++ exception based approach.
  17. [note The separate libraries are required *only* if you choose to use
  18. boost/math/tr1.hpp rather than some other Boost.Math header, the rest
  19. of Boost.Math remains header-only.]
  20. The separate libraries required in order to use tr1.hpp can be compiled
  21. using bjam from within the libs/math/build directory, or from the Boost
  22. root directory using the usual Boost-wide install procedure.
  23. Alternatively the source files are located in libs/math/src and each have
  24. the same name as the function they implement. The various libraries are
  25. named as follows:
  26. [table
  27. [[Name][Type][Functions]]
  28. [[boost_math_c99f-<suffix>][float][C99 Functions]]
  29. [[boost_math_c99-<suffix>][double][C99 Functions]]
  30. [[boost_math_c99l-<suffix>][long double][C99 Functions]]
  31. [[boost_math_tr1f-<suffix>][float][TR1 Functions]]
  32. [[boost_math_tr1-<suffix>][double][TR1 Functions]]
  33. [[boost_math_tr1l-<suffix>][long double][TR1 Functions]]
  34. ]
  35. Where `<suffix>` encodes the compiler and build options used to
  36. build the libraries: for example "libboost_math_tr1-vc80-mt-gd.lib"
  37. would be the statically linked TR1 library to use with Visual C++ 8.0,
  38. in multithreading debug mode, with the DLL VC++ runtime, where as
  39. "boost_math_tr1-vc80-mt.lib" would be import library for the TR1 DLL
  40. to be used with Visual C++ 8.0 with the release multithreaded DLL
  41. VC++ runtime.
  42. Refer to the getting started guide for a
  43. [@http://www.boost.org/doc/libs/1_35_0/more/getting_started/windows.html#library-naming
  44. full explanation of the `<suffix>` meanings].
  45. [note
  46. Visual C++ users will typically have the correct library variant to link
  47. against selected for them by boost/math/tr1.hpp based on your compiler
  48. settings.
  49. Users will need to define BOOST_MATH_TR1_DYN_LINK when building
  50. their code if they want to link against the DLL versions of these libraries
  51. rather than the static versions.
  52. Users can disable auto-linking by defining BOOST_MATH_TR1_NO_LIB when
  53. building: this is typically only used when linking against a customised
  54. build of the libraries.]
  55. [note Linux and Unix users will generally only have one variant of
  56. these libraries installed, and can generally just link against
  57. -lboost_math_tr1 etc.]
  58. [h4 Usage Recomendations]
  59. This library now presents the user with a choice:
  60. * To include the header only versions of the functions and have
  61. an easier time linking, but a longer compile time.
  62. * To include the TR1 headers and link against an external library.
  63. Which option you choose depends largely on how you prefer to work
  64. and how your system is set up.
  65. For example a casual user who just needs the acosh function, would
  66. probably be better off including `<boost/math/special_functions/acosh.hpp>`
  67. and using `boost::math::acosh(x)` in their code.
  68. However, for large scale
  69. software development where compile times are significant, and where the
  70. Boost libraries are already built and installed on the system, then
  71. including `<boost/math/tr1.hpp>` and using `boost::math::tr1::acosh(x)`
  72. will speed up compile times, reduce object files sizes (since there are
  73. no templates being instantiated any more), and also speed up debugging
  74. runtimes - since the externally compiled libraries can be
  75. compiler optimised, rather than built using full settings - the difference
  76. in performance between
  77. [link math_toolkit.getting_best
  78. release and debug builds can be as much as 20 times],
  79. so for complex applications this can be a big win.
  80. [h4 Supported C99 Functions]
  81. See also the [link math_toolkit.c99
  82. quick reference guide for these functions].
  83. namespace boost{ namespace math{ namespace tr1{ extern "C"{
  84. typedef unspecified float_t;
  85. typedef unspecified double_t;
  86. double acosh(double x);
  87. float acoshf(float x);
  88. long double acoshl(long double x);
  89. double asinh(double x);
  90. float asinhf(float x);
  91. long double asinhl(long double x);
  92. double atanh(double x);
  93. float atanhf(float x);
  94. long double atanhl(long double x);
  95. double cbrt(double x);
  96. float cbrtf(float x);
  97. long double cbrtl(long double x);
  98. double copysign(double x, double y);
  99. float copysignf(float x, float y);
  100. long double copysignl(long double x, long double y);
  101. double erf(double x);
  102. float erff(float x);
  103. long double erfl(long double x);
  104. double erfc(double x);
  105. float erfcf(float x);
  106. long double erfcl(long double x);
  107. double expm1(double x);
  108. float expm1f(float x);
  109. long double expm1l(long double x);
  110. double fmax(double x, double y);
  111. float fmaxf(float x, float y);
  112. long double fmaxl(long double x, long double y);
  113. double fmin(double x, double y);
  114. float fminf(float x, float y);
  115. long double fminl(long double x, long double y);
  116. double hypot(double x, double y);
  117. float hypotf(float x, float y);
  118. long double hypotl(long double x, long double y);
  119. double lgamma(double x);
  120. float lgammaf(float x);
  121. long double lgammal(long double x);
  122. long long llround(double x);
  123. long long llroundf(float x);
  124. long long llroundl(long double x);
  125. double log1p(double x);
  126. float log1pf(float x);
  127. long double log1pl(long double x);
  128. long lround(double x);
  129. long lroundf(float x);
  130. long lroundl(long double x);
  131. double nextafter(double x, double y);
  132. float nextafterf(float x, float y);
  133. long double nextafterl(long double x, long double y);
  134. double nexttoward(double x, long double y);
  135. float nexttowardf(float x, long double y);
  136. long double nexttowardl(long double x, long double y);
  137. double round(double x);
  138. float roundf(float x);
  139. long double roundl(long double x);
  140. double tgamma(double x);
  141. float tgammaf(float x);
  142. long double tgammal(long double x);
  143. double trunc(double x);
  144. float truncf(float x);
  145. long double truncl(long double x);
  146. }}}} // namespaces
  147. [h4 Supported TR1 Functions]
  148. See also the [link math_toolkit.main_tr1
  149. quick reference guide for these functions].
  150. namespace boost{ namespace math{ namespace tr1{ extern "C"{
  151. // [5.2.1.1] associated Laguerre polynomials:
  152. double assoc_laguerre(unsigned n, unsigned m, double x);
  153. float assoc_laguerref(unsigned n, unsigned m, float x);
  154. long double assoc_laguerrel(unsigned n, unsigned m, long double x);
  155. // [5.2.1.2] associated Legendre functions:
  156. double assoc_legendre(unsigned l, unsigned m, double x);
  157. float assoc_legendref(unsigned l, unsigned m, float x);
  158. long double assoc_legendrel(unsigned l, unsigned m, long double x);
  159. // [5.2.1.3] beta function:
  160. double beta(double x, double y);
  161. float betaf(float x, float y);
  162. long double betal(long double x, long double y);
  163. // [5.2.1.4] (complete) elliptic integral of the first kind:
  164. double comp_ellint_1(double k);
  165. float comp_ellint_1f(float k);
  166. long double comp_ellint_1l(long double k);
  167. // [5.2.1.5] (complete) elliptic integral of the second kind:
  168. double comp_ellint_2(double k);
  169. float comp_ellint_2f(float k);
  170. long double comp_ellint_2l(long double k);
  171. // [5.2.1.6] (complete) elliptic integral of the third kind:
  172. double comp_ellint_3(double k, double nu);
  173. float comp_ellint_3f(float k, float nu);
  174. long double comp_ellint_3l(long double k, long double nu);
  175. // [5.2.1.8] regular modified cylindrical Bessel functions:
  176. double cyl_bessel_i(double nu, double x);
  177. float cyl_bessel_if(float nu, float x);
  178. long double cyl_bessel_il(long double nu, long double x);
  179. // [5.2.1.9] cylindrical Bessel functions (of the first kind):
  180. double cyl_bessel_j(double nu, double x);
  181. float cyl_bessel_jf(float nu, float x);
  182. long double cyl_bessel_jl(long double nu, long double x);
  183. // [5.2.1.10] irregular modified cylindrical Bessel functions:
  184. double cyl_bessel_k(double nu, double x);
  185. float cyl_bessel_kf(float nu, float x);
  186. long double cyl_bessel_kl(long double nu, long double x);
  187. // [5.2.1.11] cylindrical Neumann functions;
  188. // cylindrical Bessel functions (of the second kind):
  189. double cyl_neumann(double nu, double x);
  190. float cyl_neumannf(float nu, float x);
  191. long double cyl_neumannl(long double nu, long double x);
  192. // [5.2.1.12] (incomplete) elliptic integral of the first kind:
  193. double ellint_1(double k, double phi);
  194. float ellint_1f(float k, float phi);
  195. long double ellint_1l(long double k, long double phi);
  196. // [5.2.1.13] (incomplete) elliptic integral of the second kind:
  197. double ellint_2(double k, double phi);
  198. float ellint_2f(float k, float phi);
  199. long double ellint_2l(long double k, long double phi);
  200. // [5.2.1.14] (incomplete) elliptic integral of the third kind:
  201. double ellint_3(double k, double nu, double phi);
  202. float ellint_3f(float k, float nu, float phi);
  203. long double ellint_3l(long double k, long double nu, long double phi);
  204. // [5.2.1.15] exponential integral:
  205. double expint(double x);
  206. float expintf(float x);
  207. long double expintl(long double x);
  208. // [5.2.1.16] Hermite polynomials:
  209. double hermite(unsigned n, double x);
  210. float hermitef(unsigned n, float x);
  211. long double hermitel(unsigned n, long double x);
  212. // [5.2.1.18] Laguerre polynomials:
  213. double laguerre(unsigned n, double x);
  214. float laguerref(unsigned n, float x);
  215. long double laguerrel(unsigned n, long double x);
  216. // [5.2.1.19] Legendre polynomials:
  217. double legendre(unsigned l, double x);
  218. float legendref(unsigned l, float x);
  219. long double legendrel(unsigned l, long double x);
  220. // [5.2.1.20] Riemann zeta function:
  221. double riemann_zeta(double);
  222. float riemann_zetaf(float);
  223. long double riemann_zetal(long double);
  224. // [5.2.1.21] spherical Bessel functions (of the first kind):
  225. double sph_bessel(unsigned n, double x);
  226. float sph_besself(unsigned n, float x);
  227. long double sph_bessell(unsigned n, long double x);
  228. // [5.2.1.22] spherical associated Legendre functions:
  229. double sph_legendre(unsigned l, unsigned m, double theta);
  230. float sph_legendref(unsigned l, unsigned m, float theta);
  231. long double sph_legendrel(unsigned l, unsigned m, long double theta);
  232. // [5.2.1.23] spherical Neumann functions;
  233. // spherical Bessel functions (of the second kind):
  234. double sph_neumann(unsigned n, double x);
  235. float sph_neumannf(unsigned n, float x);
  236. long double sph_neumannl(unsigned n, long double x);
  237. }}}} // namespaces
  238. In addition sufficient additional overloads of the `double` versions of the
  239. above functions are provided, so that calling the function with any mixture
  240. of `float`, `double`, `long double`, or /integer/ arguments is supported, with the
  241. return type determined by the __arg_promotion_rules.
  242. [h4 Currently Unsupported C99 Functions]
  243. double exp2(double x);
  244. float exp2f(float x);
  245. long double exp2l(long double x);
  246. double fdim(double x, double y);
  247. float fdimf(float x, float y);
  248. long double fdiml(long double x, long double y);
  249. double fma(double x, double y, double z);
  250. float fmaf(float x, float y, float z);
  251. long double fmal(long double x, long double y, long double z);
  252. int ilogb(double x);
  253. int ilogbf(float x);
  254. int ilogbl(long double x);
  255. long long llrint(double x);
  256. long long llrintf(float x);
  257. long long llrintl(long double x);
  258. double log2(double x);
  259. float log2f(float x);
  260. long double log2l(long double x);
  261. double logb(double x);
  262. float logbf(float x);
  263. long double logbl(long double x);
  264. long lrint(double x);
  265. long lrintf(float x);
  266. long lrintl(long double x);
  267. double nan(const char *str);
  268. float nanf(const char *str);
  269. long double nanl(const char *str);
  270. double nearbyint(double x);
  271. float nearbyintf(float x);
  272. long double nearbyintl(long double x);
  273. double remainder(double x, double y);
  274. float remainderf(float x, float y);
  275. long double remainderl(long double x, long double y);
  276. double remquo(double x, double y, int *pquo);
  277. float remquof(float x, float y, int *pquo);
  278. long double remquol(long double x, long double y, int *pquo);
  279. double rint(double x);
  280. float rintf(float x);
  281. long double rintl(long double x);
  282. double scalbln(double x, long ex);
  283. float scalblnf(float x, long ex);
  284. long double scalblnl(long double x, long ex);
  285. double scalbn(double x, int ex);
  286. float scalbnf(float x, int ex);
  287. long double scalbnl(long double x, int ex);
  288. [h4 Currently Unsupported TR1 Functions]
  289. // [5.2.1.7] confluent hypergeometric functions:
  290. double conf_hyperg(double a, double c, double x);
  291. float conf_hypergf(float a, float c, float x);
  292. long double conf_hypergl(long double a, long double c, long double x);
  293. // [5.2.1.17] hypergeometric functions:
  294. double hyperg(double a, double b, double c, double x);
  295. float hypergf(float a, float b, float c, float x);
  296. long double hypergl(long double a, long double b, long double c,
  297. long double x);
  298. ]
  299. [/
  300. Copyright 2008 John Maddock and Paul A. Bristow.
  301. Distributed under the Boost Software License, Version 1.0.
  302. (See accompanying file LICENSE_1_0.txt or copy at
  303. http://www.boost.org/LICENSE_1_0.txt).
  304. ]