![]() |
Home | Libraries | People | FAQ | More |
這個庫中所包含的大量的特殊函數是C99 標準 或 C++技術報告之庫擴展的一部分。因此這個庫包含了一個小的函數包裝頭文件boost/math/tr1.hpp 用於提供與這兩個標準的兼容性.
在這種方式下使用這個庫有各種 pros 和 cons:
Pros:
Cons:
float, double 和 long double.
![]() |
注意 |
|---|---|
僅 當你選擇使用 boost/math/tr1.hpp 而不是其它的Boost.Math 頭文件時才需要其它的庫,其它的 Boost.Math僅保留頭文件. |
為了使用 tr1.hpp 而需要的其它Boost分離庫可以使用 bjam 在 libs/math/build 目錄下進行編譯, 或者在 Boost 根目錄下使用 Boost-wide 安裝過程. 在 libs/math/src 中的頭文件且它們實現的的函數具有相同的名字. 各種庫的命名如下:
|
名稱 |
類型 |
函數 |
|---|---|---|
|
boost_math_c99f-<suffix> |
float |
C99 函數 |
|
boost_math_c99-<suffix> |
double |
C99 函數 |
|
boost_math_c99l-<suffix> |
long double |
C99 函數 |
|
boost_math_tr1f-<suffix> |
float |
TR1 函數 |
|
boost_math_tr1-<suffix> |
double |
TR1 函數 |
|
boost_math_tr1l-<suffix> |
long double |
TR1 函數 |
其中 <suffix> 編碼編譯器以及用於編譯這個庫的編譯選項: 例如"libboost_math_tr1-vc80-mt-gd.lib"是用於Visual C++ 8.0的靜態鏈接多線程調試模式的TR1 庫, 使用 DLL VC++ 運行時支持, 而 "boost_math_tr1-vc80-mt.lib" 是使用Visual C++ 8.0發行多線程編譯模式運行時的TR1DLL導入庫. 參看使用指導<suffix> 含義完整解釋.
![]() |
注意 |
|---|---|
|
基於你的編譯設置,Visual C++通常會有正確的編譯鏈接選項而不是由 boost/math/tr1.hpp來選擇的編譯選項. 當編譯代碼的時候, 如果用戶想要鏈接這些庫的 DLL 版本而不是靜態版本. 用戶需要定義 BOOST_MATH_TR1_DYN_LINK。 用戶可以通過定義 BOOST_MATH_TR1_NO_LIB 來禁止編譯時的自動鏈接: 這僅當鏈接一個用戶編譯的庫時使用. |
![]() |
注意 |
|---|---|
Linux 和 Unix 用戶通常只有這個已安裝庫的一個鏈接變量 且通常鏈接 -lboost_math_tr1 等等. |
這些庫現在給用戶一個選擇:
選擇哪一各方式很大程度上依賴於你選擇如何工作以及你的系統是如何安排的.
例如一個臨時的用戶僅僅需要使用acosh 函數, 或許最好包含頭文件<boost/math/special_functions/acosh.hpp> 然後在他的代碼中使用用boost::math::acosh(x).
然而, 對於編譯時間很長的大規模軟件開發, 且 Boost 庫已經編譯安裝在系統中, 那麼包含 <boost/math/tr1.hpp>並使用boost::math::tr1::acosh(x) 將會加快編譯速度, 減少對像(obj)文件大小 (因為不再有模板實例化), 同樣也會加快調試運行時間 - 因為外部編譯的庫可以被編譯器優化 , 而不是使用完整設置來編譯 - 發行版 和 調試版的編譯時間相差20倍, 因此對於大的項目這是一個巨大的收益.
參看函數快速參考.
namespace boost{ namespace math{ namespace tr1{ extern "C"{ typedef unspecified float_t; typedef unspecified double_t; double acosh(double x); float acoshf(float x); long double acoshl(long double x); double asinh(double x); float asinhf(float x); long double asinhl(long double x); double atanh(double x); float atanhf(float x); long double atanhl(long double x); double cbrt(double x); float cbrtf(float x); long double cbrtl(long double x); double copysign(double x, double y); float copysignf(float x, float y); long double copysignl(long double x, long double y); double erf(double x); float erff(float x); long double erfl(long double x); double erfc(double x); float erfcf(float x); long double erfcl(long double x); double expm1(double x); float expm1f(float x); long double expm1l(long double x); double fmax(double x, double y); float fmaxf(float x, float y); long double fmaxl(long double x, long double y); double fmin(double x, double y); float fminf(float x, float y); long double fminl(long double x, long double y); double hypot(double x, double y); float hypotf(float x, float y); long double hypotl(long double x, long double y); double lgamma(double x); float lgammaf(float x); long double lgammal(long double x); long long llround(double x); long long llroundf(float x); long long llroundl(long double x); double log1p(double x); float log1pf(float x); long double log1pl(long double x); long lround(double x); long lroundf(float x); long lroundl(long double x); double nextafter(double x, double y); float nextafterf(float x, float y); long double nextafterl(long double x, long double y); double nexttoward(double x, long double y); float nexttowardf(float x, long double y); long double nexttowardl(long double x, long double y); double round(double x); float roundf(float x); long double roundl(long double x); double tgamma(double x); float tgammaf(float x); long double tgammal(long double x); double trunc(double x); float truncf(float x); long double truncl(long double x); }}}} // namespaces
參看函數快速參考.
namespace boost{ namespace math{ namespace tr1{ extern "C"{ // [5.2.1.1] 相關的拉格朗日多項式: double assoc_laguerre(unsigned n, unsigned m, double x); float assoc_laguerref(unsigned n, unsigned m, float x); long double assoc_laguerrel(unsigned n, unsigned m, long double x); // [5.2.1.2] 連帶的勒讓德函數: double assoc_legendre(unsigned l, unsigned m, double x); float assoc_legendref(unsigned l, unsigned m, float x); long double assoc_legendrel(unsigned l, unsigned m, long double x); // [5.2.1.3] β函數: double beta(double x, double y); float betaf(float x, float y); long double betal(long double x, long double y); // [5.2.1.4] (完全)第一類橢圓積分: double comp_ellint_1(double k); float comp_ellint_1f(float k); long double comp_ellint_1l(long double k); // [5.2.1.5] (完全)第二類橢圓積分: double comp_ellint_2(double k); float comp_ellint_2f(float k); long double comp_ellint_2l(long double k); // [5.2.1.6] (完全 )第三類橢圓積分: double comp_ellint_3(double k, double nu); float comp_ellint_3f(float k, float nu); long double comp_ellint_3l(long double k, long double nu); // [5.2.1.8] 規範化調整的柱面貝賽爾函數: double cyl_bessel_i(double nu, double x); float cyl_bessel_if(float nu, float x); long double cyl_bessel_il(long double nu, long double x); // [5.2.1.9] 柱面貝賽爾函數(第一類): double cyl_bessel_j(double nu, double x); float cyl_bessel_jf(float nu, float x); long double cyl_bessel_jl(long double nu, long double x); // [5.2.1.10] 不規則修正柱面貝賽你函數: double cyl_bessel_k(double nu, double x); float cyl_bessel_kf(float nu, float x); long double cyl_bessel_kl(long double nu, long double x); // [5.2.1.11] 柱面諾依曼函數; // 柱面貝賽你函數(第二類): double cyl_neumann(double nu, double x); float cyl_neumannf(float nu, float x); long double cyl_neumannl(long double nu, long double x); // [5.2.1.12] (不完全)第一類橢圓積分: double ellint_1(double k, double phi); float ellint_1f(float k, float phi); long double ellint_1l(long double k, long double phi); // [5.2.1.13] (不完全)第二類橢圓積分: double ellint_2(double k, double phi); float ellint_2f(float k, float phi); long double ellint_2l(long double k, long double phi); // [5.2.1.14] (不完全)第三類橢圓積分: double ellint_3(double k, double nu, double phi); float ellint_3f(float k, float nu, float phi); long double ellint_3l(long double k, long double nu, long double phi); // [5.2.1.15] 指數積分: double expint(double x); float expintf(float x); long double expintl(long double x); // [5.2.1.16] 哈米特多項式: double hermite(unsigned n, double x); float hermitef(unsigned n, float x); long double hermitel(unsigned n, long double x); // [5.2.1.18] 拉格朗日多項式: double laguerre(unsigned n, double x); float laguerref(unsigned n, float x); long double laguerrel(unsigned n, long double x); // [5.2.1.19] 勒讓德多項式: double legendre(unsigned l, double x); float legendref(unsigned l, float x); long double legendrel(unsigned l, long double x); // [5.2.1.20] 黎曼ζ函數: double riemann_zeta(double); float riemann_zetaf(float); long double riemann_zetal(long double); // [5.2.1.21] 球面貝賽爾函數(第一類): double sph_bessel(unsigned n, double x); float sph_besself(unsigned n, float x); long double sph_bessell(unsigned n, long double x); // [5.2.1.22] 球面相關勒讓德函數: double sph_legendre(unsigned l, unsigned m, double theta); float sph_legendref(unsigned l, unsigned m, float theta); long double sph_legendrel(unsigned l, unsigned m, long double theta); // [5.2.1.23] 球面諾依曼函數; // 球面貝賽爾函數(第二類): double sph_neumann(unsigned n, double x); float sph_neumannf(unsigned n, float x); long double sph_neumannl(unsigned n, long double x); }}}} // namespaces
此外還提供了大量的上面函數的針對double版本的重載函數, 因此使用混合的 float, double, long double, 或 integer 參數都得到支持, 返回值的類型由返回值類型推導法則.來確定。
double exp2(double x); float exp2f(float x); long double exp2l(long double x); double fdim(double x, double y); float fdimf(float x, float y); long double fdiml(long double x, long double y); double fma(double x, double y, double z); float fmaf(float x, float y, float z); long double fmal(long double x, long double y, long double z); int ilogb(double x); int ilogbf(float x); int ilogbl(long double x); long long llrint(double x); long long llrintf(float x); long long llrintl(long double x); double log2(double x); float log2f(float x); long double log2l(long double x); double logb(double x); float logbf(float x); long double logbl(long double x); long lrint(double x); long lrintf(float x); long lrintl(long double x); double nan(const char *str); float nanf(const char *str); long double nanl(const char *str); double nearbyint(double x); float nearbyintf(float x); long double nearbyintl(long double x); double remainder(double x, double y); float remainderf(float x, float y); long double remainderl(long double x, long double y); double remquo(double x, double y, int *pquo); float remquof(float x, float y, int *pquo); long double remquol(long double x, long double y, int *pquo); double rint(double x); float rintf(float x); long double rintl(long double x); double scalbln(double x, long ex); float scalblnf(float x, long ex); long double scalblnl(long double x, long ex); double scalbn(double x, int ex); float scalbnf(float x, int ex); long double scalbnl(long double x, int ex);
// [5.2.1.7] 合連幾何函數: double conf_hyperg(double a, double c, double x); float conf_hypergf(float a, float c, float x); long double conf_hypergl(long double a, long double c, long double x); // [5.2.1.17] 幾何函數: double hyperg(double a, double b, double c, double x); float hypergf(float a, float b, float c, float x); long double hypergl(long double a, long double b, long double c, long double x);