DriveHQ Start Menu
Cloud Drive Mapping
Folder Sync
Cloud Backup
True Drop Box
FTP/SFTP Hosting
Group Account
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
|
Online Backup Tool
|
Cloud-to-Cloud Backup
FTP, Email & Web Service
FTP Home
|
FTP Hosting FAQ
|
Email Hosting
|
EmailManager
|
Web Hosting
Help & Resources
About
|
Enterprise Service
|
Partnership
|
Comparisons
|
Support
Quick Links
Security and Privacy
Download Software
Service Manual
Use Cases
Group Account
Online Help
Blog
Contact
Cloud Surveillance
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
IP Camera & DVR Solution
More...
Personal Features
Personal Cloud Drive
Backup All Devices
Mobile APPs
Personal Web Hosting
Sub-Account (for Kids)
Home/PC/Kids Monitoring
More...
Software
DriveHQ Drive Mapping Tool
DriveHQ FileManager
DriveHQ Online Backup
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_TOOLS_RATIONAL_HPP #define BOOST_MATH_TOOLS_RATIONAL_HPP #include
#include
#include
#if BOOST_MATH_POLY_METHOD == 1 # define BOOST_HEADER()
# include BOOST_HEADER() # undef BOOST_HEADER #elif BOOST_MATH_POLY_METHOD == 2 # define BOOST_HEADER()
# include BOOST_HEADER() # undef BOOST_HEADER #elif BOOST_MATH_POLY_METHOD == 3 # define BOOST_HEADER()
# include BOOST_HEADER() # undef BOOST_HEADER #endif #if BOOST_MATH_RATIONAL_METHOD == 1 # define BOOST_HEADER()
# include BOOST_HEADER() # undef BOOST_HEADER #elif BOOST_MATH_RATIONAL_METHOD == 2 # define BOOST_HEADER()
# include BOOST_HEADER() # undef BOOST_HEADER #elif BOOST_MATH_RATIONAL_METHOD == 3 # define BOOST_HEADER()
# include BOOST_HEADER() # undef BOOST_HEADER #endif namespace boost{ namespace math{ namespace tools{ // // Forward declaration to keep two phase lookup happy: // template
U evaluate_polynomial(const T* poly, U const& z, std::size_t count); namespace detail{ template
inline V evaluate_polynomial_c_imp(const T* a, const V& val, const Tag*) { return evaluate_polynomial(a, val, Tag::value); } } // namespace detail // // Polynomial evaluation with runtime size. // This requires a for-loop which may be more expensive than // the loop expanded versions above: // template
inline U evaluate_polynomial(const T* poly, U const& z, std::size_t count) { BOOST_ASSERT(count > 0); U sum = static_cast
(poly[count - 1]); for(int i = static_cast
(count) - 2; i >= 0; --i) { sum *= z; sum += static_cast
(poly[i]); } return sum; } // // Compile time sized polynomials, just inline forwarders to the // implementations above: // template
inline V evaluate_polynomial(const T(&a)[N], const V& val) { typedef mpl::int_
tag_type; return detail::evaluate_polynomial_c_imp(static_cast
(a), val, static_cast
(0)); } template
inline V evaluate_polynomial(const boost::array
& a, const V& val) { typedef mpl::int_
tag_type; return detail::evaluate_polynomial_c_imp(static_cast
(a.data()), val, static_cast
(0)); } // // Even polynomials are trivial: just square the argument! // template
inline U evaluate_even_polynomial(const T* poly, U z, std::size_t count) { return evaluate_polynomial(poly, z*z, count); } template
inline V evaluate_even_polynomial(const T(&a)[N], const V& z) { return evaluate_polynomial(a, z*z); } template
inline V evaluate_even_polynomial(const boost::array
& a, const V& z) { return evaluate_polynomial(a, z*z); } // // Odd polynomials come next: // template
inline U evaluate_odd_polynomial(const T* poly, U z, std::size_t count) { return poly[0] + z * evaluate_polynomial(poly+1, z*z, count-1); } template
inline V evaluate_odd_polynomial(const T(&a)[N], const V& z) { typedef mpl::int_
tag_type; return a[0] + z * detail::evaluate_polynomial_c_imp(static_cast
(a) + 1, z*z, static_cast
(0)); } template
inline V evaluate_odd_polynomial(const boost::array
& a, const V& z) { typedef mpl::int_
tag_type; return a[0] + z * detail::evaluate_polynomial_c_imp(static_cast
(a.data()) + 1, z*z, static_cast
(0)); } template
V evaluate_rational(const T* num, const U* denom, const V& z_, std::size_t count); namespace detail{ template
inline V evaluate_rational_c_imp(const T* num, const U* denom, const V& z, const Tag*) { return boost::math::tools::evaluate_rational(num, denom, z, Tag::value); } } // // Rational functions: numerator and denominator must be // equal in size. These always have a for-loop and so may be less // efficient than evaluating a pair of polynomials. However, there // are some tricks we can use to prevent overflow that might otherwise // occur in polynomial evaluation, if z is large. This is important // in our Lanczos code for example. // template
V evaluate_rational(const T* num, const U* denom, const V& z_, std::size_t count) { V z(z_); V s1, s2; if(z <= 1) { s1 = static_cast
(num[count-1]); s2 = static_cast
(denom[count-1]); for(int i = (int)count - 2; i >= 0; --i) { s1 *= z; s2 *= z; s1 += num[i]; s2 += denom[i]; } } else { z = 1 / z; s1 = static_cast
(num[0]); s2 = static_cast
(denom[0]); for(unsigned i = 1; i < count; ++i) { s1 *= z; s2 *= z; s1 += num[i]; s2 += denom[i]; } } return s1 / s2; } template
inline V evaluate_rational(const T(&a)[N], const U(&b)[N], const V& z) { return detail::evaluate_rational_c_imp(a, b, z, static_cast
*>(0)); } template
inline V evaluate_rational(const boost::array
& a, const boost::array
& b, const V& z) { return detail::evaluate_rational_c_imp(a.data(), b.data(), z, static_cast
*>(0)); } } // namespace tools } // namespace math } // namespace boost #endif // BOOST_MATH_TOOLS_RATIONAL_HPP
rational.hpp
Page URL
File URL
Prev
7/19
Next
Download
( 6 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.