MathTL
algebra/laurent_polynomial.h
00001 // -*- c++ -*-
00002 
00003 // +--------------------------------------------------------------------+
00004 // | This file is part of MathTL - the Mathematical Template Library    |
00005 // |                                                                    |
00006 // | Copyright (c) 2002-2009                                            |
00007 // | Thorsten Raasch, Manuel Werner                                     |
00008 // +--------------------------------------------------------------------+
00009 
00010 #ifndef _MATHTL_LAURENT_POLYNOMIAL_H
00011 #define _MATHTL_LAURENT_POLYNOMIAL_H
00012 
00013 #include <cassert>
00014 #include <utils/function.h>
00015 #include <algebra/infinite_vector.h>
00016 #include <algebra/polynomial.h>
00017 #include <geometry/point.h>
00018 
00019 namespace MathTL
00020 {
00029   template <class R>
00030   class LaurentPolynomial
00031     : protected InfiniteVector<R,int>, public Function<1, R>
00032   {
00033   public:
00037     typedef typename InfiniteVector<R,int>::const_iterator
00038     const_iterator;
00039 
00043     typedef typename InfiniteVector<R,int>::const_reverse_iterator
00044     const_reverse_iterator;
00045 
00049     LaurentPolynomial();
00050 
00054     LaurentPolynomial(const LaurentPolynomial<R>& p);
00055 
00059     explicit LaurentPolynomial(const R c);
00060 
00064     explicit LaurentPolynomial(const Polynomial<R>& p);
00065 
00069     virtual ~LaurentPolynomial();
00070 
00074     LaurentPolynomial<R>& operator = (const LaurentPolynomial<R>& p);
00075 
00079     LaurentPolynomial<R>& operator = (const R c);
00080 
00084     unsigned int degree() const;
00085 
00089     R get_coefficient(const int k) const;
00090 
00094     void set_coefficient(const int k, const R coeff);
00095 
00099     const_iterator begin() const;
00100 
00104     const_iterator end() const;
00105 
00109     const_reverse_iterator rbegin() const;
00110 
00114     const_reverse_iterator rend() const;
00115 
00119     R value(const R x) const;
00120 
00125     R value(const Point<1>& p,
00126             const unsigned int component = 0) const;
00127 
00132     void vector_value(const Point<1> &p,
00133                       Vector<R>& values) const;
00134 
00138     void add(const LaurentPolynomial<R>& p);
00139 
00143     void add(const R s, const LaurentPolynomial<R>& p);
00144 
00148     void sadd(const R s, const LaurentPolynomial<R>& p);
00149 
00153     LaurentPolynomial<R>& operator += (const LaurentPolynomial<R>& p);
00154 
00159     LaurentPolynomial<R> operator + (const LaurentPolynomial<R>& p) const;
00160 
00164     void subtract(const LaurentPolynomial<R>& p);
00165 
00169     LaurentPolynomial<R>& operator -= (const LaurentPolynomial<R> &p);
00170 
00175     LaurentPolynomial<R> operator - () const;
00176     
00181     LaurentPolynomial<R> operator - (const LaurentPolynomial<R> &p) const;
00182 
00186     LaurentPolynomial<R>& operator *= (const R c);
00187 
00192     LaurentPolynomial<R> operator * (const R c) const;
00193     
00197     void multiply(const LaurentPolynomial<R>& p);
00198 
00202     LaurentPolynomial<R>& operator *= (const LaurentPolynomial<R>& p);
00203 
00207     LaurentPolynomial<R> power(const unsigned int k) const;
00208 
00212     void divide(const LaurentPolynomial<R>& q, LaurentPolynomial<R>& p) const;
00213 
00217     void divide(const LaurentPolynomial<R>& q,
00218                 LaurentPolynomial<R>& p, LaurentPolynomial<R>& r) const;
00219   };
00220 
00224   template <class R>
00225   LaurentPolynomial<R> operator * (const R c, const LaurentPolynomial<R>& p);
00226 
00230   template <class R>
00231   LaurentPolynomial<R> operator * (const LaurentPolynomial<R>& p,
00232                                    const LaurentPolynomial<R>& q);
00233     
00238   template <class R>
00239   std::ostream& operator << (std::ostream &s, const LaurentPolynomial<R> &p);
00240 
00241 }
00242 
00243 // include implementation of inline functions
00244 #include <algebra/laurent_polynomial.cpp>
00245 
00246 #endif
 All Classes Functions Variables Typedefs Enumerations