Library of Assembled Shared Sources
polynomial_quotient.h
Go to the documentation of this file.
1/** @file
2 * @author Bram de Greve (bram@cocamware.com)
3 * @author Tom De Muer (tom@cocamware.com)
4 *
5 * *** BEGIN LICENSE INFORMATION ***
6 *
7 * The contents of this file are subject to the Common Public Attribution License
8 * Version 1.0 (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
10 * http://lass.sourceforge.net/cpal-license. The License is based on the
11 * Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover
12 * use of software over a computer network and provide for limited attribution for
13 * the Original Developer. In addition, Exhibit A has been modified to be consistent
14 * with Exhibit B.
15 *
16 * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
17 * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
18 * language governing rights and limitations under the License.
19 *
20 * The Original Code is LASS - Library of Assembled Shared Sources.
21 *
22 * The Initial Developer of the Original Code is Bram de Greve and Tom De Muer.
23 * The Original Developer is the Initial Developer.
24 *
25 * All portions of the code written by the Initial Developer are:
26 * Copyright (C) 2004-2011 the Initial Developer.
27 * All Rights Reserved.
28 *
29 * Contributor(s):
30 *
31 * Alternatively, the contents of this file may be used under the terms of the
32 * GNU General Public License Version 2 or later (the GPL), in which case the
33 * provisions of GPL are applicable instead of those above. If you wish to allow use
34 * of your version of this file only under the terms of the GPL and not to allow
35 * others to use your version of this file under the CPAL, indicate your decision by
36 * deleting the provisions above and replace them with the notice and other
37 * provisions required by the GPL License. If you do not delete the provisions above,
38 * a recipient may use your version of this file under either the CPAL or the GPL.
39 *
40 * *** END LICENSE INFORMATION ***
41 */
42
43
44
45/** @class lass::num::Polynomial
46 * @brief an univariate polynomial.
47 * @author Bram de Greve [BdG]
48 *
49 * <i>A polynomial is a mathematical expression involving a sum of powers in one or more variables
50 * multiplied by coefficients.</i>,
51 * Eric W. Weisstein. "Polynomial." From MathWorld--A Wolfram Web Resource.
52 * http://mathworld.wolfram.com/Polynomial.html
53 */
54
55#ifndef LASS_GUARDIAN_OF_INCLUSION_NUM_POLYNOMIAL_QUOTIENT_H
56#define LASS_GUARDIAN_OF_INCLUSION_NUM_POLYNOMIAL_QUOTIENT_H
57
58#include "num_common.h"
59#include "polynomial.h"
60
61namespace lass
62{
63namespace num
64{
65
66template <typename T>
67class PolynomialQuotient
68{
69public:
70
71 typedef PolynomialQuotient<T> TSelf;
72 typedef Polynomial<T> TPolynomial;
73 typedef NumTraits<T> TNumTraits;
74 typedef typename util::CallTraits<T>::TValue TValue;
75 typedef typename util::CallTraits<T>::TParam TParam;
76 typedef typename util::CallTraits<T>::TReference TReference;
77 typedef typename util::CallTraits<T>::TConstReference TConstReference;
78 typedef std::vector<TValue> TCoefficients;
79 typedef std::pair<TCoefficients, TCoefficients> TCoefficientsPair;
80
81 PolynomialQuotient();
82 explicit PolynomialQuotient(TParam scalar);
83 explicit PolynomialQuotient(const TCoefficients& numerator);
84 explicit PolynomialQuotient(const TPolynomial& numerator);
85 explicit PolynomialQuotient(const TCoefficientsPair& numeratorDenominator);
86 PolynomialQuotient(TParam scalar, const TCoefficients& denominator);
87 PolynomialQuotient(TParam scalar, const TPolynomial& denominator);
88 PolynomialQuotient(const TCoefficients& numerator, const TCoefficients& denominator);
89 PolynomialQuotient(const TPolynomial& numerator, const TPolynomial& denominator);
90 template <typename InputIterator> PolynomialQuotient(InputIterator numFirst, InputIterator numLast);
91 template <typename InputIterator> PolynomialQuotient(InputIterator numFirst, InputIterator numLast,
92 InputIterator denFirst, InputIterator denLast);
93
94 const TPolynomial& numerator() const;
95 const TPolynomial& denominator() const;
96
97 const TValue operator()(TParam x) const;
98
99 const TSelf& operator+() const;
100 const TSelf operator-() const;
101
102 TSelf& operator+=(const TSelf& other);
103 TSelf& operator-=(const TSelf& other);
104 TSelf& operator*=(const TSelf& other);
105 TSelf& operator/=(const TSelf& other);
106
107 TSelf& operator+=(const TPolynomial& other);
108 TSelf& operator-=(const TPolynomial& other);
109 TSelf& operator*=(const TPolynomial& other);
110 TSelf& operator/=(const TPolynomial& other);
111
112 TSelf& operator+=(TParam scalar);
113 TSelf& operator-=(TParam scalar);
114 TSelf& operator*=(TParam scalar);
115 TSelf& operator/=(TParam scalar);
116
117 TSelf derivative() const;
118 TSelf pow(unsigned power) const;
119
120 static TSelf one();
121 static TSelf x();
122
123private:
124
125 TPolynomial numerator_;
126 TPolynomial denominator_;
127};
128
129template <typename T> bool operator==(const PolynomialQuotient<T>& a, const PolynomialQuotient<T>& b);
130template <typename T> bool operator!=(const PolynomialQuotient<T>& a, const PolynomialQuotient<T>& b);
131
132template <typename T> PolynomialQuotient<T> operator+(const PolynomialQuotient<T>& a, const PolynomialQuotient<T>& b);
133template <typename T> PolynomialQuotient<T> operator-(const PolynomialQuotient<T>& a, const PolynomialQuotient<T>& b);
134template <typename T> PolynomialQuotient<T> operator*(const PolynomialQuotient<T>& a, const PolynomialQuotient<T>& b);
135template <typename T> PolynomialQuotient<T> operator/(const PolynomialQuotient<T>& a, const PolynomialQuotient<T>& b);
136
137template <typename T> PolynomialQuotient<T> operator+(const Polynomial<T>& a, const PolynomialQuotient<T>& b);
138template <typename T> PolynomialQuotient<T> operator-(const Polynomial<T>& a, const PolynomialQuotient<T>& b);
139template <typename T> PolynomialQuotient<T> operator*(const Polynomial<T>& a, const PolynomialQuotient<T>& b);
140template <typename T> PolynomialQuotient<T> operator/(const Polynomial<T>& a, const PolynomialQuotient<T>& b);
141
142template <typename T> PolynomialQuotient<T> operator+(const PolynomialQuotient<T>& a, const Polynomial<T>& b);
143template <typename T> PolynomialQuotient<T> operator-(const PolynomialQuotient<T>& a, const Polynomial<T>& b);
144template <typename T> PolynomialQuotient<T> operator*(const PolynomialQuotient<T>& a, const Polynomial<T>& b);
145template <typename T> PolynomialQuotient<T> operator/(const PolynomialQuotient<T>& a, const Polynomial<T>& b);
146
147template <typename T> PolynomialQuotient<T> operator+(const T& a, const PolynomialQuotient<T>& b);
148template <typename T> PolynomialQuotient<T> operator-(const T& a, const PolynomialQuotient<T>& b);
149template <typename T> PolynomialQuotient<T> operator*(const T& a, const PolynomialQuotient<T>& b);
150template <typename T> PolynomialQuotient<T> operator/(const T& a, const PolynomialQuotient<T>& b);
151
152template <typename T> PolynomialQuotient<T> operator+(const PolynomialQuotient<T>& a, const T& b);
153template <typename T> PolynomialQuotient<T> operator-(const PolynomialQuotient<T>& a, const T& b);
154template <typename T> PolynomialQuotient<T> operator*(const PolynomialQuotient<T>& a, const T& b);
155template <typename T> PolynomialQuotient<T> operator/(const PolynomialQuotient<T>& a, const T& b);
156
157template <typename T> PolynomialQuotient<T> operator/(const Polynomial<T>& a, const Polynomial<T>& b);
158
159template <typename T, typename Char, typename Traits>
160std::basic_ostream<Char, Traits>&
161operator<<(std::basic_ostream<Char, Traits>& s, const PolynomialQuotient<T>& a);
162
163
164}
165}
166
168
169#endif
170
171// EOF
an univariate polynomial.
Definition polynomial.h:68
numeric types and traits.
Definition basic_ops.h:70
Library for Assembled Shared Sources.
Definition config.h:53