WSJT-X/boost/libs/math/doc/internals/polynomial.qbk

180 lines
5.8 KiB
Plaintext
Raw Normal View History

[section:polynomials Polynomials]
[h4 Synopsis]
``
#include <boost/math/tools/polynomial.hpp>
``
namespace boost { namespace math {
namespace tools {
template <class T>
class polynomial
{
public:
// typedefs:
typedef typename std::vector<T>::value_type value_type;
typedef typename std::vector<T>::size_type size_type;
// construct:
polynomial(){}
template <class U>
polynomial(const U* data, unsigned order);
template <class I>
polynomial(I first, I last);
template <class U>
explicit polynomial(const U& point);
polynomial(std::initializer_list<T> l); // C++11
// access:
size_type size()const;
size_type degree()const;
value_type& operator[](size_type i);
const value_type& operator[](size_type i)const;
std::vector<T> const& data() const;
std::vector<T>& data();
explicit operator bool() const;
// modify:
void set_zero();
// operators:
template <class U>
polynomial& operator +=(const U& value);
template <class U>
polynomial& operator -=(const U& value);
template <class U>
polynomial& operator *=(const U& value);
template <class U>
polynomial& operator /=(const U& value);
template <class U>
polynomial& operator %=(const U& value);
template <class U>
polynomial& operator +=(const polynomial<U>& value);
template <class U>
polynomial& operator -=(const polynomial<U>& value);
template <class U>
polynomial& operator *=(const polynomial<U>& value);
template <class U>
polynomial& operator /=(const polynomial<U>& value);
template <class U>
polynomial& operator %=(const polynomial<U>& value);
};
template <class T>
polynomial<T> operator + (const polynomial<T>& a, const polynomial<T>& b);
template <class T>
polynomial<T> operator - (const polynomial<T>& a, const polynomial<T>& b);
template <class T>
polynomial<T> operator * (const polynomial<T>& a, const polynomial<T>& b);
template <class T>
polynomial<T> operator / (const polynomial<T>& a, const polynomial<T>& b);
template <class T>
polynomial<T> operator % (const polynomial<T>& a, const polynomial<T>& b);
template <class T, class U>
polynomial<T> operator + (const polynomial<T>& a, const U& b);
template <class T, class U>
polynomial<T> operator - (const polynomial<T>& a, const U& b);
template <class T, class U>
polynomial<T> operator * (const polynomial<T>& a, const U& b);
template <class T, class U>
polynomial<T> operator / (const polynomial<T>& a, const U& b);
template <class T, class U>
polynomial<T> operator % (const polynomial<T>& a, const U& b);
template <class U, class T>
polynomial<T> operator + (const U& a, const polynomial<T>& b);
template <class U, class T>
polynomial<T> operator - (const U& a, const polynomial<T>& b);
template <class U, class T>
polynomial<T> operator * (const U& a, const polynomial<T>& b);
template <class T>
polynomial<T> operator - (const polynomial<T>& a);
template <class T>
polynomial<T> operator >>= (const U& a);
template <class T>
polynomial<T> operator >> (polynomial<T> const &a, const U& b);
template <class T>
polynomial<T> operator <<= (const U& a);
template <class T>
polynomial<T> operator << (polynomial<T> const &a, const U& b);
template <class T>
bool operator == (const polynomial<T> &a, const polynomial<T> &b);
template <class T>
bool operator != (const polynomial<T> &a, const polynomial<T> &b);
template <class T>
polynomial<T> pow(polynomial<T> base, int exp);
template <class charT, class traits, class T>
std::basic_ostream<charT, traits>& operator <<
(std::basic_ostream<charT, traits>& os, const polynomial<T>& poly);
template <typename T>
std::pair< polynomial<T>, polynomial<T> >
quotient_remainder(const polynomial<T>& a, const polynomial<T>& b);
} // namespace tools
}} // namespace boost { namespace math
[h4 Description]
This is a somewhat trivial class for polynomial manipulation.
See
* [@https://en.wikipedia.org/wiki/Polynomial Polynomial] and
* Donald E. Knuth, The Art of Computer Programming: Volume 2, Third edition, (1998)
Chapter 4.6.1, Algorithm D: Division of polynomials over a field.
Implementation is currently of the "naive" variety, with [bigo](N[super 2])
multiplication, for example. This class should not be used in
high-performance computing environments: it is intended for the
simple manipulation of small polynomials, typically generated
for special function approximation.
It does has division for polynomials over a [@https://en.wikipedia.org/wiki/Field_%28mathematics%29 field]
(here floating point, complex, etc)
and over a unique factorization domain (integers).
Division of polynomials over a field is compatible with
[@https://en.wikipedia.org/wiki/Euclidean_algorithm Euclidean GCD].
Advanced manipulations: the FFT, factorisation etc are
not currently provided. Submissions for these are of course welcome :-)
[h4:polynomial_examples Polynomial Arithmetic Examples]
[import ../../example/polynomial_arithmetic.cpp]
[polynomial_arithmetic_0]
[polynomial_arithmetic_1]
[polynomial_arithmetic_2]
for output:
[polynomial_output_1]
[polynomial_arithmetic_3]
for output
[polynomial_output_2]
[h5 Division, Quotient and Remainder]
[polynomial_arithmetic_4]
The source code is at [@../../example/polynomial_arithmetic.cpp polynomial_arithmetic.cpp]
[endsect] [/section:polynomials Polynomials]
[/
Copyright 2006 John Maddock and Paul A. Bristow.
Copyright 2015 Jeremy William Murphy.
Distributed under 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).
]