11#include <boost/shared_ptr.hpp>
17#define BOOST_DISABLE_THREADS
46 template <poly_variant,
class,
class>
friend class PolyBase;
82 if (
this==&p2)
return *
this;
106 number two=
n_Init(2,
r.get()->cf);
210 intrusive_ptr<ip_sring>
r;
260using namespace boost;
284public std::iterator<std::input_iterator_tag,T,int, shared_ptr<const T>,ConstTermReference<T> >
325 return shared_ptr<const T>(
new T(
p_Head(
t,
r),
r,0));
329template<poly_variant variant,
class create_type_input,
class error_handle_traits>
class PolyBase
340 if (error_handle_traits::handleErrors)
342 if (
p.getRing()!=this->getRing())
344 error_handle_traits::handleDifferentRing(this->
getRing(),
356 for(
int i=0;
i<nvars;
i++)
383 char* cp=(
char*)
omAlloc((strlen(c)+1)*
sizeof(char));
428 return ptr->getRing();
434 return ptr->leadCoef();
447 return ptr->getInternalReference();
455class Poly:
public PolyBase<POLY_VARIANT_RING, Poly, MyErrorHandler>{
485 for(
i=0;
i<
v.size();
i++){
535 for(
i=0;
i<
v.size();
i++){
587template <poly_variant variant,
class create_type,
class error_traits>
611 if (r1!=r2)
return false;
617 if (r1!=r2)
return false;
620template <poly_variant variant,
class create_type,
class error_traits>
640template <poly_variant variant,
class create_type,
class error_traits>
TrivialErrorHandler MyErrorHandler
PolyImpl operator-(const PolyImpl &p1, const PolyImpl &p2)
bool operator==(const Poly &p1, const Poly &p2)
Vector unitVector(int i, ring r=currRing)
PolyImpl operator+(const PolyImpl &p1, const PolyImpl &p2)
PolyImpl operator*(const PolyImpl &p1, const PolyImpl &p2)
ConstTermReference(poly p, ring r)
static void handleDifferentRing(ring r, ring s)
static const bool handleErrors
intrusive_ptr< ip_sring > r
void checkIsSameRing(T &p)
PolyBase & operator*=(Number n)
int lmTotalDegree() const
PolyInputIterator< create_type > end()
poly getInternalReference()
PolyBase(poly p, ring r, int)
PolyBase & operator+=(const PolyBase &p2)
PolyBase(ring r=currRing)
create_type_input create_type
PolyBase< variant, create_type_input, error_handle_traits > ThisType
PolyBase & operator*=(const Poly &p2)
PolyBase(const PolyBase &p)
PolyInputIterator< create_type > begin()
PolyInputIterator< create_type > iterator
shared_ptr< PolyImpl > ptr
PolyBase(const char *c, ring r=currRing)
PolyImpl(int n, intrusive_ptr< ip_sring > r)
PolyImpl & operator=(int n)
friend PolyImpl operator-(const PolyImpl &p1, const PolyImpl &n2)
intrusive_ptr< ip_sring > r
PolyImpl(const Number &n)
friend bool operator==(const PolyImpl &p1, int n2)
PolyImpl & operator*=(const Number &n)
PolyImpl(poly p, intrusive_ptr< ip_sring > r)
friend PolyImpl operator+(const PolyImpl &p1, const PolyImpl &n2)
friend bool operator==(const Poly &p1, const Poly &p2)
PolyImpl(const PolyImpl &p)
PolyImpl & operator=(const PolyImpl &p2)
friend PolyImpl operator*(const PolyImpl &p1, const PolyImpl &n2)
PolyImpl & operator+=(const PolyImpl &p2)
friend PolyImpl operator/(const PolyImpl &p1, const PolyImpl &n2)
PolyImpl & operator-=(const PolyImpl &p2)
PolyImpl & operator*=(const PolyImpl &p2)
friend bool operator==(const PolyImpl &p1, const PolyImpl &n2)
PolyImpl(poly p, intrusive_ptr< ip_sring > r, int)
poly getInternalReference() const
friend PolyImpl operator/(const PolyImpl &p1, int n2)
static void handleDifferentRing(ring r, ring s)
static const bool handleErrors
Vector(int n, ring r=currRing)
Vector(const char *c, ring r=currRing)
friend bool operator==(const Vector &p1, const Vector &p2)
Vector & operator+=(const Base &p)
PolyBase< POLY_VARIANT_MODUL, Vector, MyErrorHandler > Base
Vector(poly p, ring r, int)
Vector(std::vector< int > v, ring r=currRing)
Vector & operator+=(const Vector &p)
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
const CanonicalForm int s
const Variable & v
< [in] a sqrfree bivariate poly
void WerrorS(const char *s)
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
const char * p_Read(const char *st, poly &rc, const ring r)
BOOLEAN p_EqualPolys(poly p1, poly p2, const ring r)
static poly p_Neg(poly p, const ring r)
static poly p_Add_q(poly p, poly q, const ring r)
static poly p_Mult_q(poly p, poly q, const ring r)
char * p_String(poly p, ring lmRing, ring tailRing)
void p_Write(poly p, ring lmRing, ring tailRing)
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
static poly p_Head(const poly p, const ring r)
copy the (leading) term of p
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
static BOOLEAN p_LmIsConstant(const poly p, const ring r)
static poly p_Mult_nn(poly p, number n, const ring r)
static void p_Delete(poly *p, const ring r)
static poly p_Copy(poly p, const ring r)
returns a copy of p
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Compatibility layer for legacy polynomial operations (over currRing)
static long pTotaldegree(poly p)
void PrintS(const char *s)
static short rVar(const ring r)
#define rVar(r) (r->N)
Poly(const char *c, ring r=currRing)
Poly(int n, ring r=currRing)
friend bool operator==(const Poly &p1, const Poly &p2)
Poly(poly p, ring r, int)
Poly(const std::vector< int > &v, ring r=currRing)
PolyBase< POLY_VARIANT_RING, Poly, MyErrorHandler > Base
Poly & operator+=(const Base &p)
Poly & operator+=(const Poly &p)