Quotient modulo a univariate polynomial

The quotient modulo a polynomial is implemented as a class upoly, which provides the operations in this quotient algebra:

namespace quotient {
   template<class C, class P=UPolDse<C>, class R=upol::horner<C> >
   struct upoly;
}

This class provides the following functions
 void assign(R& r, const R & a); 
 void assign(R& r, const P & a);

 void add(R& r, const R & a, const R& b); 
 void add(R& r, const R & a); 
 void sub(R& r, const R & a, const R& b); 
 void sub(R& r, const R & a); 
 void mul(R& r, const R & a, const R& b); 
 void mul(R& r, const R & a, const C& b); 
 void div(R& r, const R & a, const C& b);
 void square(R& r, const R & a);

 void print(std::ostream & os, const R & a)  
which implements the arithmetic operations of the polynomials of type R modulo a given polynomial of type P.

In order to define the polynomial modulo which we compute, we use the constructor

upoly(const P & p);

Example

#include <synaps/upol/ModUPol.h>
              
typedef UPolDse<double> pol_t;
int main() 
{ 
  using namespace std; 
  quotient::upoly<double, pol_t> modpol(pol_t("x0^3-2*x0^2")); 
  upol::horner<double> p,q,r;   
  modpol.assign(p,"x0^2-2*x0+1"); 
  modpol.assign(q,"x0-1");
  cout <<"p="; modpol.print(cout,p);cout << endl;
  cout <<"q="; modpol.print(cout,q);cout << endl;  

\[ p = x^2 - 2 x + 1 ; q = x - 1 ; \]

  modpol.add(r,p,q); modpol.print(cout,r);cout << endl;

\[ p + q \equiv x^2 - x - 1 \]

  modpol.mul(r,p,q); modpol.print(cout,r);cout << endl;

\[ p q \equiv - x^2 + 3 x - 1 \]

}

Implementation

See also:
synaps/upol/ModUPol.h

SYNAPS DOCUMENTATION
logo