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
// Copyright John Maddock 2007. // Copyright Paul A. Bristow 2007. // 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_POLICY_ERROR_HANDLING_HPP #define BOOST_MATH_POLICY_ERROR_HANDLING_HPP #include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#ifdef BOOST_MSVC # pragma warning(push) // Quiet warnings in boost/format.hpp # pragma warning(disable: 4996) // _SCL_SECURE_NO_DEPRECATE # pragma warning(disable: 4512) // assignment operator could not be generated. // And warnings in error handling: # pragma warning(disable: 4702) // unreachable code // Note that this only occurs when the compiler can deduce code is unreachable, // for example when policy macros are used to ignore errors rather than throw. #endif #include
namespace boost{ namespace math{ class evaluation_error : public std::runtime_error { public: evaluation_error(const std::string& s) : std::runtime_error(s){} }; namespace policies{ // // Forward declarations of user error handlers, // it's up to the user to provide the definition of these: // template
T user_domain_error(const char* function, const char* message, const T& val); template
T user_pole_error(const char* function, const char* message, const T& val); template
T user_overflow_error(const char* function, const char* message, const T& val); template
T user_underflow_error(const char* function, const char* message, const T& val); template
T user_denorm_error(const char* function, const char* message, const T& val); template
T user_evaluation_error(const char* function, const char* message, const T& val); namespace detail { // // Helper function to avoid binding rvalue to non-const-reference, // in other words a warning suppression mechansim: // template
inline std::string do_format(Formatter f, const Group& g) { return (f % g).str(); } template
void raise_error(const char* function, const char* message) { if(function == 0) function = "Unknown function operating on type %1%"; if(message == 0) message = "Cause unknown"; std::string msg("Error in function "); msg += (boost::format(function) % typeid(T).name()).str(); msg += ": "; msg += message; E e(msg); boost::throw_exception(e); } template
void raise_error(const char* function, const char* message, const T& val) { if(function == 0) function = "Unknown function operating on type %1%"; if(message == 0) message = "Cause unknown: error caused by bad argument with value %1%"; std::string msg("Error in function "); msg += (boost::format(function) % typeid(T).name()).str(); msg += ": "; msg += message; int prec = 2 + (boost::math::policies::digits
>() * 30103UL) / 100000UL; msg = do_format(boost::format(msg), boost::io::group(std::setprecision(prec), val)); E e(msg); boost::throw_exception(e); } template
inline T raise_domain_error( const char* function, const char* message, const T& val, const ::boost::math::policies::domain_error< ::boost::math::policies::throw_on_error>&) { raise_error
(function, message, val); // we never get here: return std::numeric_limits
::quiet_NaN(); } template
inline T raise_domain_error( const char* , const char* , const T& , const ::boost::math::policies::domain_error< ::boost::math::policies::ignore_error>&) { // This may or may not do the right thing, but the user asked for the error // to be ignored so here we go anyway: return std::numeric_limits
::quiet_NaN(); } template
inline T raise_domain_error( const char* , const char* , const T& , const ::boost::math::policies::domain_error< ::boost::math::policies::errno_on_error>&) { errno = EDOM; // This may or may not do the right thing, but the user asked for the error // to be silent so here we go anyway: return std::numeric_limits
::quiet_NaN(); } template
inline T raise_domain_error( const char* function, const char* message, const T& val, const ::boost::math::policies::domain_error< ::boost::math::policies::user_error>&) { return user_domain_error(function, message, val); } template
inline T raise_pole_error( const char* function, const char* message, const T& val, const ::boost::math::policies::pole_error< ::boost::math::policies::throw_on_error>&) { return boost::math::policies::detail::raise_domain_error(function, message, val, ::boost::math::policies::domain_error< ::boost::math::policies::throw_on_error>()); } template
inline T raise_pole_error( const char* function, const char* message, const T& val, const ::boost::math::policies::pole_error< ::boost::math::policies::ignore_error>&) { return ::boost::math::policies::detail::raise_domain_error(function, message, val, ::boost::math::policies::domain_error< ::boost::math::policies::ignore_error>()); } template
inline T raise_pole_error( const char* function, const char* message, const T& val, const ::boost::math::policies::pole_error< ::boost::math::policies::errno_on_error>&) { return ::boost::math::policies::detail::raise_domain_error(function, message, val, ::boost::math::policies::domain_error< ::boost::math::policies::errno_on_error>()); } template
inline T raise_pole_error( const char* function, const char* message, const T& val, const ::boost::math::policies::pole_error< ::boost::math::policies::user_error>&) { return user_pole_error(function, message, val); } template
inline T raise_overflow_error( const char* function, const char* message, const ::boost::math::policies::overflow_error< ::boost::math::policies::throw_on_error>&) { raise_error
(function, message ? message : "numeric overflow"); // we never get here: return std::numeric_limits
::has_infinity ? std::numeric_limits
::infinity() : boost::math::tools::max_value
(); } template
inline T raise_overflow_error( const char* , const char* , const ::boost::math::policies::overflow_error< ::boost::math::policies::ignore_error>&) { // This may or may not do the right thing, but the user asked for the error // to be ignored so here we go anyway: return std::numeric_limits
::has_infinity ? std::numeric_limits
::infinity() : boost::math::tools::max_value
(); } template
inline T raise_overflow_error( const char* , const char* , const ::boost::math::policies::overflow_error< ::boost::math::policies::errno_on_error>&) { errno = ERANGE; // This may or may not do the right thing, but the user asked for the error // to be silent so here we go anyway: return std::numeric_limits
::has_infinity ? std::numeric_limits
::infinity() : boost::math::tools::max_value
(); } template
inline T raise_overflow_error( const char* function, const char* message, const ::boost::math::policies::overflow_error< ::boost::math::policies::user_error>&) { return user_overflow_error(function, message, std::numeric_limits
::infinity()); } template
inline T raise_underflow_error( const char* function, const char* message, const ::boost::math::policies::underflow_error< ::boost::math::policies::throw_on_error>&) { raise_error
(function, message ? message : "numeric underflow"); // we never get here: return 0; } template
inline T raise_underflow_error( const char* , const char* , const ::boost::math::policies::underflow_error< ::boost::math::policies::ignore_error>&) { // This may or may not do the right thing, but the user asked for the error // to be ignored so here we go anyway: return T(0); } template
inline T raise_underflow_error( const char* /* function */, const char* /* message */, const ::boost::math::policies::underflow_error< ::boost::math::policies::errno_on_error>&) { errno = ERANGE; // This may or may not do the right thing, but the user asked for the error // to be silent so here we go anyway: return T(0); } template
inline T raise_underflow_error( const char* function, const char* message, const ::boost::math::policies::underflow_error< ::boost::math::policies::user_error>&) { return user_underflow_error(function, message, T(0)); } template
inline T raise_denorm_error( const char* function, const char* message, const T& /* val */, const ::boost::math::policies::denorm_error< ::boost::math::policies::throw_on_error>&) { raise_error
(function, message ? message : "denormalised result"); // we never get here: return T(0); } template
inline T raise_denorm_error( const char* , const char* , const T& val, const ::boost::math::policies::denorm_error< ::boost::math::policies::ignore_error>&) { // This may or may not do the right thing, but the user asked for the error // to be ignored so here we go anyway: return val; } template
inline T raise_denorm_error( const char* , const char* , const T& val, const ::boost::math::policies::denorm_error< ::boost::math::policies::errno_on_error>&) { errno = ERANGE; // This may or may not do the right thing, but the user asked for the error // to be silent so here we go anyway: return val; } template
inline T raise_denorm_error( const char* function, const char* message, const T& val, const ::boost::math::policies::denorm_error< ::boost::math::policies::user_error>&) { return user_denorm_error(function, message, val); } template
inline T raise_evaluation_error( const char* function, const char* message, const T& val, const ::boost::math::policies::evaluation_error< ::boost::math::policies::throw_on_error>&) { raise_error
(function, message, val); // we never get here: return T(0); } template
inline T raise_evaluation_error( const char* , const char* , const T& val, const ::boost::math::policies::evaluation_error< ::boost::math::policies::ignore_error>&) { // This may or may not do the right thing, but the user asked for the error // to be ignored so here we go anyway: return val; } template
inline T raise_evaluation_error( const char* , const char* , const T& val, const ::boost::math::policies::evaluation_error< ::boost::math::policies::errno_on_error>&) { errno = EDOM; // This may or may not do the right thing, but the user asked for the error // to be silent so here we go anyway: return val; } template
inline T raise_evaluation_error( const char* function, const char* message, const T& val, const ::boost::math::policies::evaluation_error< ::boost::math::policies::user_error>&) { return user_evaluation_error(function, message, val); } } // namespace detail template
inline T raise_domain_error(const char* function, const char* message, const T& val, const Policy&) { typedef typename Policy::domain_error_type policy_type; return detail::raise_domain_error( function, message ? message : "Domain Error evaluating function at %1%", val, policy_type()); } template
inline T raise_pole_error(const char* function, const char* message, const T& val, const Policy&) { typedef typename Policy::pole_error_type policy_type; return detail::raise_pole_error( function, message ? message : "Evaluation of function at pole %1%", val, policy_type()); } template
inline T raise_overflow_error(const char* function, const char* message, const Policy&) { typedef typename Policy::overflow_error_type policy_type; return detail::raise_overflow_error
( function, message ? message : "Overflow Error", policy_type()); } template
inline T raise_underflow_error(const char* function, const char* message, const Policy&) { typedef typename Policy::underflow_error_type policy_type; return detail::raise_underflow_error
( function, message ? message : "Underflow Error", policy_type()); } template
inline T raise_denorm_error(const char* function, const char* message, const T& val, const Policy&) { typedef typename Policy::denorm_error_type policy_type; return detail::raise_denorm_error
( function, message ? message : "Denorm Error", val, policy_type()); } template
inline T raise_evaluation_error(const char* function, const char* message, const T& val, const Policy&) { typedef typename Policy::evaluation_error_type policy_type; return detail::raise_evaluation_error( function, message ? message : "Internal Evaluation Error, best value so far was %1%", val, policy_type()); } // // checked_narrowing_cast: // namespace detail { template
inline bool check_overflow(T val, R* result, const char* function, const Policy& pol) { BOOST_MATH_STD_USING if(fabs(val) > tools::max_value
()) { *result = static_cast
(boost::math::policies::detail::raise_overflow_error
(function, 0, pol)); return true; } return false; } template
inline bool check_underflow(T val, R* result, const char* function, const Policy& pol) { if((val != 0) && (static_cast
(val) == 0)) { *result = static_cast
(boost::math::policies::detail::raise_underflow_error
(function, 0, pol)); return true; } return false; } template
inline bool check_denorm(T val, R* result, const char* function, const Policy& pol) { BOOST_MATH_STD_USING if((fabs(val) < static_cast
(tools::min_value
())) && (static_cast
(val) != 0)) { *result = static_cast
(boost::math::policies::detail::raise_denorm_error
(function, 0, static_cast
(val), pol)); return true; } return false; } // Default instantiations with ignore_error policy. template
inline bool check_overflow(T /* val */, R* /* result */, const char* /* function */, const overflow_error
&){ return false; } template
inline bool check_underflow(T /* val */, R* /* result */, const char* /* function */, const underflow_error
&){ return false; } template
inline bool check_denorm(T /* val */, R* /* result*/, const char* /* function */, const denorm_error
&){ return false; } } // namespace detail template
inline R checked_narrowing_cast(T val, const char* function) { typedef typename Policy::overflow_error_type overflow_type; typedef typename Policy::underflow_error_type underflow_type; typedef typename Policy::denorm_error_type denorm_type; // // Most of what follows will evaluate to a no-op: // R result; if(detail::check_overflow
(val, &result, function, overflow_type())) return result; if(detail::check_underflow
(val, &result, function, underflow_type())) return result; if(detail::check_denorm
(val, &result, function, denorm_type())) return result; return static_cast
(val); } template
inline void check_series_iterations(const char* function, boost::uintmax_t max_iter, const Policy& pol) { if(max_iter >= policies::get_max_series_iterations
()) raise_evaluation_error
( function, "Series evaluation exceeded %1% iterations, giving up now.", max_iter, pol); } } //namespace policies #ifdef BOOST_MSVC # pragma warning(pop) #endif }} // namespaces boost/math #endif // BOOST_MATH_POLICY_ERROR_HANDLING_HPP
error_handling.hpp
Page URL
File URL
Prev 1/2
Next
Download
( 17 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.