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_POLYNOMIAL_HPP #define BOOST_MATH_TOOLS_POLYNOMIAL_HPP #include
#include
#include
#include
namespace boost{ namespace math{ namespace tools{ template
class polynomial { public: // typedefs: typedef typename std::vector
::value_type value_type; typedef typename std::vector
::size_type size_type; // construct: polynomial(){} template
polynomial(const U* data, unsigned order) : m_data(data, data + order + 1) { } template
polynomial(const U& point) { m_data.push_back(point); } // copy: polynomial(const polynomial& p) : m_data(p.m_data) { } template
polynomial(const polynomial
& p) { for(unsigned i = 0; i < p.size(); ++i) { m_data.push_back(boost::math::tools::real_cast
(p[i])); } } // access: size_type size()const { return m_data.size(); } size_type degree()const { return m_data.size() - 1; } value_type& operator[](size_type i) { return m_data[i]; } const value_type& operator[](size_type i)const { return m_data[i]; } T evaluate(T z)const { return boost::math::tools::evaluate_polynomial(&m_data[0], z, m_data.size());; } // operators: template
polynomial& operator +=(const U& value) { if(m_data.size() == 0) m_data.push_back(value); else { m_data[0] += value; } return *this; } template
polynomial& operator -=(const U& value) { if(m_data.size() == 0) m_data.push_back(-value); else { m_data[0] -= value; } return *this; } template
polynomial& operator *=(const U& value) { for(size_type i = 0; i < m_data.size(); ++i) m_data[i] *= value; return *this; } template
polynomial& operator +=(const polynomial
& value) { size_type s1 = (std::min)(m_data.size(), value.size()); for(size_type i = 0; i < s1; ++i) m_data[i] += value[i]; for(size_type i = s1; i < value.size(); ++i) m_data.push_back(value[i]); return *this; } template
polynomial& operator -=(const polynomial
& value) { size_type s1 = (std::min)(m_data.size(), value.size()); for(size_type i = 0; i < s1; ++i) m_data[i] -= value[i]; for(size_type i = s1; i < value.size(); ++i) m_data.push_back(-value[i]); return *this; } template
polynomial& operator *=(const polynomial
& value) { // TODO: FIXME: use O(N log(N)) algorithm!!! BOOST_ASSERT(value.size()); polynomial base(*this); *this *= value[0]; for(size_type i = 1; i < value.size(); ++i) { polynomial t(base); t *= value[i]; size_type s = size() - i; for(size_type j = 0; j < s; ++j) { m_data[i+j] += t[j]; } for(size_type j = s; j < t.size(); ++j) m_data.push_back(t[j]); } return *this; } private: std::vector
m_data; }; template
inline polynomial
operator + (const polynomial
& a, const polynomial
& b) { polynomial
result(a); result += b; return result; } template
inline polynomial
operator - (const polynomial
& a, const polynomial
& b) { polynomial
result(a); result -= b; return result; } template
inline polynomial
operator * (const polynomial
& a, const polynomial
& b) { polynomial
result(a); result *= b; return result; } template
inline polynomial
operator + (const polynomial
& a, const U& b) { polynomial
result(a); result += b; return result; } template
inline polynomial
operator - (const polynomial
& a, const U& b) { polynomial
result(a); result -= b; return result; } template
inline polynomial
operator * (const polynomial
& a, const U& b) { polynomial
result(a); result *= b; return result; } template
inline polynomial
operator + (const U& a, const polynomial
& b) { polynomial
result(b); result += a; return result; } template
inline polynomial
operator - (const U& a, const polynomial
& b) { polynomial
result(a); result -= b; return result; } template
inline polynomial
operator * (const U& a, const polynomial
& b) { polynomial
result(b); result *= a; return result; } template
inline std::basic_ostream
& operator << (std::basic_ostream
& os, const polynomial
& poly) { os << "{ "; for(unsigned i = 0; i < poly.size(); ++i) { if(i) os << ", "; os << poly[i]; } os << " }"; return os; } } // namespace tools } // namespace math } // namespace boost #endif // BOOST_MATH_TOOLS_POLYNOMIAL_HPP
polynomial.hpp
Page URL
File URL
Prev
4/19
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.