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 2005-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_LOG1P_INCLUDED #define BOOST_MATH_LOG1P_INCLUDED #include
#include
// platform's ::log1p #include
#include
#include
#include
#include
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS # include
#else # include
#endif namespace boost{ namespace math{ namespace detail { // Functor log1p_series returns the next term in the Taylor series // pow(-1, k-1)*pow(x, k) / k // each time that operator() is invoked. // template
struct log1p_series { typedef T result_type; log1p_series(T x) : k(0), m_mult(-x), m_prod(-1){} T operator()() { m_prod *= m_mult; return m_prod / ++k; } int count()const { return k; } private: int k; const T m_mult; T m_prod; log1p_series(const log1p_series&); log1p_series& operator=(const log1p_series&); }; } // namespace detail // Algorithm log1p is part of C99, but is not yet provided by many compilers. // // This version uses a Taylor series expansion for 0.5 > x > epsilon, which may // require up to std::numeric_limits
::digits+1 terms to be calculated. // It would be much more efficient to use the equivalence: // log(1+x) == (log(1+x) * x) / ((1-x) - 1) // Unfortunately many optimizing compilers make such a mess of this, that // it performs no better than log(1+x): which is to say not very well at all. // template
typename tools::promote_args
::type log1p(T x, const Policy& pol) { // The function returns the natural logarithm of 1 + x. // A domain error occurs if x < -1. TODO should there be a check? typedef typename tools::promote_args
::type result_type; BOOST_MATH_STD_USING using std::abs; static const char* function = "boost::math::log1p<%1%>(%1%)"; if(x < -1) return policies::raise_domain_error
( function, "log1p(x) requires x > -1, but got x = %1%.", x, pol); if(x == -1) return -policies::raise_overflow_error
( function, 0, pol); result_type a = abs(result_type(x)); if(a > result_type(0.5L)) return log(1 + result_type(x)); // Note that without numeric_limits specialisation support, // epsilon just returns zero, and our "optimisation" will always fail: if(a < tools::epsilon
()) return x; detail::log1p_series
s(x); boost::uintmax_t max_iter = policies::get_max_series_iterations
(); #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582)) result_type result = tools::sum_series(s, policies::digits
(), max_iter); #else result_type zero = 0; result_type result = tools::sum_series(s, policies::digits
(), max_iter, zero); #endif policies::check_series_iterations(function, max_iter, pol); return result; } #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) // These overloads work around a type deduction bug: inline float log1p(float z) { return log1p
(z); } inline double log1p(double z) { return log1p
(z); } #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS inline long double log1p(long double z) { return log1p
(z); } #endif #endif #ifdef log1p # ifndef BOOST_HAS_LOG1P # define BOOST_HAS_LOG1P # endif # undef log1p #endif #ifdef BOOST_HAS_LOG1P # if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)) \ || ((defined(linux) || defined(__linux) || defined(__linux__)) && !defined(__SUNPRO_CC)) \ || (defined(__hpux) && !defined(__hppa)) template
inline float log1p(float x, const Policy& pol) { if(x < -1) return policies::raise_domain_error
( "log1p<%1%>(%1%)", "log1p(x) requires x > -1, but got x = %1%.", x, pol); if(x == -1) return -policies::raise_overflow_error
( "log1p<%1%>(%1%)", 0, pol); return ::log1pf(x); } template
inline long double log1p(long double x, const Policy& pol) { if(x < -1) return policies::raise_domain_error
( "log1p<%1%>(%1%)", "log1p(x) requires x > -1, but got x = %1%.", x, pol); if(x == -1) return -policies::raise_overflow_error
( "log1p<%1%>(%1%)", 0, pol); return ::log1pl(x); } #else template
inline float log1p(float x, const Policy& pol) { if(x < -1) return policies::raise_domain_error
( "log1p<%1%>(%1%)", "log1p(x) requires x > -1, but got x = %1%.", x, pol); if(x == -1) return -policies::raise_overflow_error
( "log1p<%1%>(%1%)", 0, pol); return ::log1p(x); } #endif template
inline double log1p(double x, const Policy& pol) { if(x < -1) return policies::raise_domain_error
( "log1p<%1%>(%1%)", "log1p(x) requires x > -1, but got x = %1%.", x, pol); if(x == -1) return -policies::raise_overflow_error
( "log1p<%1%>(%1%)", 0, pol); return ::log1p(x); } #elif defined(_MSC_VER) && (BOOST_MSVC >= 1400) // // You should only enable this branch if you are absolutely sure // that your compilers optimizer won't mess this code up!! // Currently tested with VC8 and Intel 9.1. // template
inline double log1p(double x, const Policy& pol) { if(x < -1) return policies::raise_domain_error
( "log1p<%1%>(%1%)", "log1p(x) requires x > -1, but got x = %1%.", x, pol); if(x == -1) return -policies::raise_overflow_error
( "log1p<%1%>(%1%)", 0, pol); double u = 1+x; if(u == 1.0) return x; else return log(u)*(x/(u-1.0)); } template
inline float log1p(float x, const Policy& pol) { return static_cast
(boost::math::log1p(static_cast
(x), pol)); } template
inline long double log1p(long double x, const Policy& pol) { if(x < -1) return policies::raise_domain_error
( "log1p<%1%>(%1%)", "log1p(x) requires x > -1, but got x = %1%.", x, pol); if(x == -1) return -policies::raise_overflow_error
( "log1p<%1%>(%1%)", 0, pol); long double u = 1+x; if(u == 1.0) return x; else return log(u)*(x/(u-1.0)); } #endif template
inline typename tools::promote_args
::type log1p(T x) { return boost::math::log1p(x, policies::policy<>()); } // // Compute log(1+x)-x: // template
inline typename tools::promote_args
::type log1pmx(T x, const Policy& pol) { typedef typename tools::promote_args
::type result_type; BOOST_MATH_STD_USING static const char* function = "boost::math::log1pmx<%1%>(%1%)"; if(x < -1) return policies::raise_domain_error
( function, "log1pmx(x) requires x > -1, but got x = %1%.", x, pol); if(x == -1) return -policies::raise_overflow_error
( function, 0, pol); result_type a = abs(result_type(x)); if(a > result_type(0.95L)) return log(1 + result_type(x)) - result_type(x); // Note that without numeric_limits specialisation support, // epsilon just returns zero, and our "optimisation" will always fail: if(a < tools::epsilon
()) return -x * x / 2; boost::math::detail::log1p_series
s(x); s(); boost::uintmax_t max_iter = policies::get_max_series_iterations
(); #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582)) T zero = 0; T result = boost::math::tools::sum_series(s, policies::digits
(), max_iter, zero); #else T result = boost::math::tools::sum_series(s, policies::digits
(), max_iter); #endif policies::check_series_iterations(function, max_iter, pol); return result; } template
inline T log1pmx(T x) { return log1pmx(x, policies::policy<>()); } } // namespace math } // namespace boost #endif // BOOST_MATH_LOG1P_INCLUDED
log1p.hpp
Page URL
File URL
Prev
27/35
Next
Download
( 8 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.