DriveHQ Start Menu
Cloud Drive Mapping
Folder Sync
True Drop Box
FTP/SFTP Hosting
Group Account
Team Anywhere
DriveHQ Start Menu
Online File Server
My Storage
|
Manage Shares
|
Publishes
|
Drop Boxes
|
Group Account
WebDAV Drive Mapping
Cloud Drive Home
|
WebDAV Guide
|
Drive Mapping Tool
|
Drive Mapping URL
Complete Data Backup
Backup Guide
|
Cloud-to-Cloud Backup
|
DVR/Camera Backup
FTP, Email & Web Service
FTP/SFTP Hosting
|
Email Hosting
|
Web Hosting
|
Webcam Hosting
Other Products & Services
Team Anywhere
|
Connect to Remote PC
|
Cloud Surveillance
|
Virtual CCTV NVR
Quick Links
Security and Privacy
Customer Support
Service Manual
Use Cases
Group Account
Online Help
Support Forum
Contact Us
About DriveHQ
Sign Up
Login
Features
Business Features
Online File Server
FTP Hosting
Cloud Drive Mapping
Cloud File Backup
Email Backup & Hosting
Cloud File Sharing
Folder Synchronization
Group Management
True Drop Box
Full-text Search
AD Integration/SSO
Mobile Access
Personal Features
Personal Cloud Drive
Backup All Devices
Mobile APPs
Personal Web Hosting
Sub-Account (for Kids)
Home/PC/Kids Monitoring
Other Features
Team Anywhere (Remote Desktop Service)
CameraFTP Cloud Surveillance
Software
DriveHQ Drive Mapping Tool
DriveHQ FileManager
DriveHQ Online Backup
DriveHQ Team Anywhere for Windows (Beta)
DriveHQ Mobile Apps
Pricing
Business Plans & Pricing
Personal Plans & Pricing
Price Comparison with Others
Feature Comparison with Others
Install Mobile App
Sign up
Creating account...
Invalid character in username! Only 0-9, a-z, A-Z, _, -, . allowed.
Username is required!
Invalid email address!
E-mail is required!
Password is required!
Password is invalid!
Password and confirmation do not match.
Confirm password is required!
I accept
Membership Agreement
Please read the Membership Agreement and check "I accept"!
Free Quick Sign-up
Sign-up Page
Log in
Signing in...
Username or e-mail address is required!
Password is required!
Keep me logged in
Quick Login
Forgot Password
Up
Upload
Download
Share
Publish
New Folder
New File
Copy
Cut
Delete
Paste
Rate
Upgrade
Rotate
Effect
Edit
Slide
History
// (C) Copyright John Maddock 2006. // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_MATH_SPECIAL_LEGENDRE_HPP #define BOOST_MATH_SPECIAL_LEGENDRE_HPP #include
#include
#include
namespace boost{ namespace math{ // Recurrance relation for legendre P and Q polynomials: template
inline typename tools::promote_args
::type legendre_next(unsigned l, T1 x, T2 Pl, T3 Plm1) { typedef typename tools::promote_args
::type result_type; return ((2 * l + 1) * result_type(x) * result_type(Pl) - l * result_type(Plm1)) / (l + 1); } namespace detail{ // Implement Legendre P and Q polynomials via recurrance: template
T legendre_imp(unsigned l, T x, const Policy& pol, bool second = false) { static const char* function = "boost::math::legrendre_p<%1%>(unsigned, %1%)"; // Error handling: if((x < -1) || (x > 1)) return policies::raise_domain_error
( function, "The Legendre Polynomial is defined for" " -1 <= x <= 1, but got x = %1%.", x, pol); T p0, p1; if(second) { // A solution of the second kind (Q): p0 = (boost::math::log1p(x, pol) - boost::math::log1p(-x, pol)) / 2; p1 = x * p0 - 1; } else { // A solution of the first kind (P): p0 = 1; p1 = x; } if(l == 0) return p0; unsigned n = 1; while(n < l) { std::swap(p0, p1); p1 = boost::math::legendre_next(n, x, p0, p1); ++n; } return p1; } } // namespace detail template
inline typename tools::promote_args
::type legendre_p(int l, T x, const Policy& pol) { typedef typename tools::promote_args
::type result_type; typedef typename policies::evaluation
::type value_type; static const char* function = "boost::math::legendre_p<%1%>(unsigned, %1%)"; if(l < 0) return policies::checked_narrowing_cast
(detail::legendre_imp(-l-1, static_cast
(x), pol, false), function); return policies::checked_narrowing_cast
(detail::legendre_imp(l, static_cast
(x), pol, false), function); } template
inline typename tools::promote_args
::type legendre_p(int l, T x) { return boost::math::legendre_p(l, x, policies::policy<>()); } template
inline typename tools::promote_args
::type legendre_q(unsigned l, T x, const Policy& pol) { typedef typename tools::promote_args
::type result_type; typedef typename policies::evaluation
::type value_type; return policies::checked_narrowing_cast
(detail::legendre_imp(l, static_cast
(x), pol, true), "boost::math::legendre_q<%1%>(unsigned, %1%)"); } template
inline typename tools::promote_args
::type legendre_q(unsigned l, T x) { return boost::math::legendre_q(l, x, policies::policy<>()); } // Recurrence for associated polynomials: template
inline typename tools::promote_args
::type legendre_next(unsigned l, unsigned m, T1 x, T2 Pl, T3 Plm1) { typedef typename tools::promote_args
::type result_type; return ((2 * l + 1) * result_type(x) * result_type(Pl) - (l + m) * result_type(Plm1)) / (l + 1 - m); } namespace detail{ // Legendre P associated polynomial: template
T legendre_p_imp(int l, int m, T x, T sin_theta_power, const Policy& pol) { // Error handling: if((x < -1) || (x > 1)) return policies::raise_domain_error
( "boost::math::legendre_p<%1%>(int, int, %1%)", "The associated Legendre Polynomial is defined for" " -1 <= x <= 1, but got x = %1%.", x, pol); // Handle negative arguments first: if(l < 0) return legendre_p_imp(-l-1, m, x, sin_theta_power, pol); if(m < 0) { int sign = (m&1) ? -1 : 1; return sign * boost::math::tgamma_ratio(static_cast
(l+m+1), static_cast
(l+1-m), pol) * legendre_p_imp(l, -m, x, sin_theta_power, pol); } // Special cases: if(m > l) return 0; if(m == 0) return boost::math::legendre_p(l, x, pol); T p0 = boost::math::double_factorial
(2 * m - 1, pol) * sin_theta_power; if(m&1) p0 *= -1; if(m == l) return p0; T p1 = x * (2 * m + 1) * p0; int n = m + 1; while(n < l) { std::swap(p0, p1); p1 = boost::math::legendre_next(n, m, x, p0, p1); ++n; } return p1; } template
inline T legendre_p_imp(int l, int m, T x, const Policy& pol) { BOOST_MATH_STD_USING // TODO: we really could use that mythical "pow1p" function here: return legendre_p_imp(l, m, x, pow(1 - x*x, T(abs(m))/2), pol); } } template
inline typename tools::promote_args
::type legendre_p(int l, int m, T x, const Policy& pol) { typedef typename tools::promote_args
::type result_type; typedef typename policies::evaluation
::type value_type; return policies::checked_narrowing_cast
(detail::legendre_p_imp(l, m, static_cast
(x), pol), "bost::math::legendre_p<%1%>(int, int, %1%)"); } template
inline typename tools::promote_args
::type legendre_p(int l, int m, T x) { return boost::math::legendre_p(l, m, x, policies::policy<>()); } } // namespace math } // namespace boost #endif // BOOST_MATH_SPECIAL_LEGENDRE_HPP
legendre.hpp
Page URL
File URL
Prev
26/35
Next
Download
( 5 KB )
Note: The DriveHQ service banners will NOT be displayed if the file owner is a paid member.
Comments
Total ratings:
0
Average rating:
Not Rated
Would you like to comment?
Join DriveHQ
for a free account, or
Logon
if you are already a member.