![]() |
Home | Libraries | People | FAQ | More |
#include <boost/math/special_functions/spheric_harmonic.hpp>
namespace boost{ namespace math{ template <class T1, class T2> std::complex<calculated-result-type> spherical_harmonic(unsigned n, int m, T1 theta, T2 phi); template <class T1, class T2, class Policy> std::complex<calculated-result-type> spherical_harmonic(unsigned n, int m, T1 theta, T2 phi, const Policy&); template <class T1, class T2> calculated-result-type spherical_harmonic_r(unsigned n, int m, T1 theta, T2 phi); template <class T1, class T2, class Policy> calculated-result-type spherical_harmonic_r(unsigned n, int m, T1 theta, T2 phi, const Policy&); template <class T1, class T2> calculated-result-type spherical_harmonic_i(unsigned n, int m, T1 theta, T2 phi); template <class T1, class T2, class Policy> calculated-result-type spherical_harmonic_i(unsigned n, int m, T1 theta, T2 phi, const Policy&); }} // namespaces
當T1和T2是不同類型的時候,函數返回值的類型使用返回值推導法則:來確定。
最後一個策略 參數是可選的並且可以用來控制函數的行為: 如何處理錯誤, 使用哪種層次的精度等等. 參見策略文檔瞭解更多信息。
template <class T1, class T2> std::complex<calculated-result-type> spherical_harmonic(unsigned n, int m, T1 theta, T2 phi); template <class T1, class T2, class Policy> std::complex<calculated-result-type> spherical_harmonic(unsigned n, int m, T1 theta, T2 phi, const Policy&);
返回球面低函數 Ynm(theta, phi):
球面低函數在球面上的拉普拉斯方程解的角度部分( angular portion),其中不滿足方位角對稱(azimuthal symmetry)。
![]() |
|
|
必須指明傳遞給這個函數的參數:θ 使用極坐標 (余緯度)且θ 範圍為 [0, π], 而 φ 作為方位角坐標 (經度)其中 φ 的範圍為 [0,2π). 這是在物理學中的約定形式,而且與Mathematica in the function SpericalHarmonicY中使用的定義相符,但是與通常的數學約定相反。 一些其它的文獻在函數的定義中包含了一個附加的 Condon-Shortley 位相 (-1)m項: 注意,我們所實現的附帶勒讓德多項式已經包含了這個項 。 對於 m > n,庫中的函數實現返回0 對於在[0, π]範圍之外的θ 和在[0, 2π]的φ ,這個庫的實現遵從Mathematica所使用的約定形式:這個函數對於θ是以π為週期,對於φ是以2π為週期。請注意: 這並不意味著用戶將可以從這個函數的定義中使用隨便的定義域來使用,.謹慎的用戶會保持θ和φ的範圍分別為: [0, π] 和 [0, 2π] . 參見: Weisstein, Eric W. "Spherical Harmonic." From MathWorld--A Wolfram Web Resource. |
template <class T1, class T2> calculated-result-type spherical_harmonic_r(unsigned n, int m, T1 theta, T2 phi); template <class T1, class T2, class Policy> calculated-result-type spherical_harmonic_r(unsigned n, int m, T1 theta, T2 phi, const Policy&);
返回 Ynm(θ, φ)的實部:
template <class T1, class T2> calculated-result-type spherical_harmonic_i(unsigned n, int m, T1 theta, T2 phi); template <class T1, class T2, class Policy> calculated-result-type spherical_harmonic_i(unsigned n, int m, T1 theta, T2 phi, const Policy&);
返回 Ynm(θ, φ)的虛部
下面的表顯示了參數的不同定義域的峰值誤差(單位為10的-5次方)。注意,在那些由寬浮點類型來給定窄浮點類型的系統上會有有效的零誤差. 對於實部和虛部,峰值誤差是相同的,而誤差由計算連帶勒讓德多項式來左右:尤其是在連帶勒讓德函數的根附近。
所有的值都是以 epsilon(10的-5次方)為單位.
表5.球面低函數的峰值誤差
|
有效數字位數 |
平台和編譯器 |
在 0 < l < 20 範圍內的誤差 |
|---|---|---|
|
53 |
Win32, Visual C++ 8 |
峰值=2x104 均值=700 |
|
64 |
SUSE Linux IA32, g++ 4.1 |
峰值=2900 均值=100 |
|
64 |
Red Hat Linux IA64, g++ 3.4.4 |
峰值=2900 均值=100 |
|
113 |
HPUX IA64, aCC A.06.06 |
峰值=6700 均值=230 |
注意:當次數增長時出現最壞誤差,大於 ~120 的值似乎不能產生有意義的結果,尤其是當相關的多項式的次數很大時。當函數非常接近於一個根時,相對誤差可能增長到任意大。
混合的抽樣測試使用 functions.wolfram.com產生的數據, 而隨機測試數據使用精度為1000-bit的NTL::RR 庫產生的數據。
這些函數使用上面的方程來實現。一些額外的措施用來避免從極坐標轉化時產生的捨入誤差(例如,連帶勒讓德多項式使用的1-x2項使用x = cos(θ)且1-x2 = sin2(θ)面沒有任何的捨入誤差),這些函數中的誤差率的限制因子是需要計算在根附近的勒讓德函數的值。