1 [section:polynomials Polynomials]
6 #include <boost/math/tools/polynomial.hpp>
9 namespace boost { namespace math {
17 typedef typename std::vector<T>::value_type value_type;
18 typedef typename std::vector<T>::size_type size_type;
23 polynomial(const U* data, unsigned order);
25 polynomial(I first, I last);
27 explicit polynomial(const U& point);
28 polynomial(std::initializer_list<T> l); // C++11
31 size_type size()const;
32 size_type degree()const;
33 value_type& operator[](size_type i);
34 const value_type& operator[](size_type i)const;
35 std::vector<T> const& data() const;
36 std::vector<T>& data();
37 explicit operator bool() const;
44 polynomial& operator +=(const U& value);
46 polynomial& operator -=(const U& value);
48 polynomial& operator *=(const U& value);
50 polynomial& operator /=(const U& value);
52 polynomial& operator %=(const U& value);
54 polynomial& operator +=(const polynomial<U>& value);
56 polynomial& operator -=(const polynomial<U>& value);
58 polynomial& operator *=(const polynomial<U>& value);
60 polynomial& operator /=(const polynomial<U>& value);
62 polynomial& operator %=(const polynomial<U>& value);
66 polynomial<T> operator + (const polynomial<T>& a, const polynomial<T>& b);
68 polynomial<T> operator - (const polynomial<T>& a, const polynomial<T>& b);
70 polynomial<T> operator * (const polynomial<T>& a, const polynomial<T>& b);
72 polynomial<T> operator / (const polynomial<T>& a, const polynomial<T>& b);
74 polynomial<T> operator % (const polynomial<T>& a, const polynomial<T>& b);
76 template <class T, class U>
77 polynomial<T> operator + (const polynomial<T>& a, const U& b);
78 template <class T, class U>
79 polynomial<T> operator - (const polynomial<T>& a, const U& b);
80 template <class T, class U>
81 polynomial<T> operator * (const polynomial<T>& a, const U& b);
82 template <class T, class U>
83 polynomial<T> operator / (const polynomial<T>& a, const U& b);
84 template <class T, class U>
85 polynomial<T> operator % (const polynomial<T>& a, const U& b);
87 template <class U, class T>
88 polynomial<T> operator + (const U& a, const polynomial<T>& b);
89 template <class U, class T>
90 polynomial<T> operator - (const U& a, const polynomial<T>& b);
91 template <class U, class T>
92 polynomial<T> operator * (const U& a, const polynomial<T>& b);
95 polynomial<T> operator - (const polynomial<T>& a);
98 polynomial<T> operator >>= (const U& a);
100 polynomial<T> operator >> (polynomial<T> const &a, const U& b);
102 polynomial<T> operator <<= (const U& a);
104 polynomial<T> operator << (polynomial<T> const &a, const U& b);
107 bool operator == (const polynomial<T> &a, const polynomial<T> &b);
109 bool operator != (const polynomial<T> &a, const polynomial<T> &b);
112 polynomial<T> pow(polynomial<T> base, int exp);
114 template <class charT, class traits, class T>
115 std::basic_ostream<charT, traits>& operator <<
116 (std::basic_ostream<charT, traits>& os, const polynomial<T>& poly);
118 template <typename T>
119 std::pair< polynomial<T>, polynomial<T> >
120 quotient_remainder(const polynomial<T>& a, const polynomial<T>& b);
123 }} // namespace boost { namespace math
127 This is a somewhat trivial class for polynomial manipulation.
131 * [@https://en.wikipedia.org/wiki/Polynomial Polynomial] and
132 * Donald E. Knuth, The Art of Computer Programming: Volume 2, Third edition, (1998)
133 Chapter 4.6.1, Algorithm D: Division of polynomials over a field.
135 Implementation is currently of the "naive" variety, with [bigo](N[super 2])
136 multiplication, for example. This class should not be used in
137 high-performance computing environments: it is intended for the
138 simple manipulation of small polynomials, typically generated
139 for special function approximation.
141 It does has division for polynomials over a [@https://en.wikipedia.org/wiki/Field_%28mathematics%29 field]
142 (here floating point, complex, etc)
143 and over a unique factorization domain (integers).
144 Division of polynomials over a field is compatible with
145 [@https://en.wikipedia.org/wiki/Euclidean_algorithm Euclidean GCD].
147 Advanced manipulations: the FFT, factorisation etc are
148 not currently provided. Submissions for these are of course welcome :-)
150 [h4:polynomial_examples Polynomial Arithmetic Examples]
152 [import ../../example/polynomial_arithmetic.cpp]
154 [polynomial_arithmetic_0]
155 [polynomial_arithmetic_1]
157 [polynomial_arithmetic_2]
159 [polynomial_output_1]
161 [polynomial_arithmetic_3]
163 [polynomial_output_2]
165 [h5 Division, Quotient and Remainder]
166 [polynomial_arithmetic_4]
168 The source code is at [@../../example/polynomial_arithmetic.cpp polynomial_arithmetic.cpp]
170 [endsect] [/section:polynomials Polynomials]
173 Copyright 2006 John Maddock and Paul A. Bristow.
174 Copyright 2015 Jeremy William Murphy.
176 Distributed under the Boost Software License, Version 1.0.
177 (See accompanying file LICENSE_1_0.txt or copy at
178 http://www.boost.org/LICENSE_1_0.txt).