1 | #include "mod2.h" |
---|
2 | |
---|
3 | #ifdef HAVE_WRAPPERS |
---|
4 | |
---|
5 | #include <iostream> |
---|
6 | #include "structs.h" |
---|
7 | #include "polys.h" |
---|
8 | #include "Wrappers.h" |
---|
9 | #include "CanonicalPoly.h" |
---|
10 | |
---|
11 | CanonicalPoly::CanonicalPoly (const SingularPoly& sp, const RingWrapper& r):InternPoly(r) |
---|
12 | { |
---|
13 | +prpr > "CanonicalPoly constructor with poly argument = " < |
---|
14 | p_String(sp, r.getSingularRing(), r.getSingularRing()); |
---|
15 | m_poly = sp; |
---|
16 | } |
---|
17 | |
---|
18 | CanonicalPoly::CanonicalPoly (const int i, const RingWrapper& r):InternPoly(r) |
---|
19 | { |
---|
20 | +prpr > "CanonicalPoly constructor with int argument = " < i; |
---|
21 | m_poly = p_ISet(i, r.getSingularRing()); |
---|
22 | } |
---|
23 | |
---|
24 | CanonicalPoly::~CanonicalPoly () |
---|
25 | { |
---|
26 | +prpr > "CanonicalPoly destructor, object = " < this->toString(); |
---|
27 | } |
---|
28 | |
---|
29 | char* CanonicalPoly::toString () const |
---|
30 | { |
---|
31 | SingularRing r = this->getRing().getSingularRing(); |
---|
32 | return p_String(this->getSingularPoly(), r, r); |
---|
33 | } |
---|
34 | |
---|
35 | void CanonicalPoly::addCompatible (const InternPoly* ip) |
---|
36 | { |
---|
37 | if (ip->getPolyType() == CANONICAL_POLY_TYPE) |
---|
38 | { |
---|
39 | const CanonicalPoly* pcp = static_cast<const CanonicalPoly*>(ip); |
---|
40 | +prpr > "value of CanonicalPoly is being changed"; |
---|
41 | prpr+1; |
---|
42 | +prpr > "old value = " < this->toString(); |
---|
43 | +prpr > "value to be added = " < pcp->toString(); |
---|
44 | m_poly = p_Add_q(m_poly, pcp->deepCopy()->getSingularPoly(), this->getRing().getSingularRing()); |
---|
45 | +prpr > "new value = " < this->toString(); |
---|
46 | prpr-1; |
---|
47 | +prpr > "value of CanonicalPoly has been changed"; |
---|
48 | } |
---|
49 | else |
---|
50 | assume(false); |
---|
51 | } |
---|
52 | |
---|
53 | int CanonicalPoly::getPolyType () const |
---|
54 | { |
---|
55 | return CANONICAL_POLY_TYPE; |
---|
56 | } |
---|
57 | |
---|
58 | const SingularPoly& CanonicalPoly::getSingularPoly () const |
---|
59 | { |
---|
60 | return m_poly; |
---|
61 | } |
---|
62 | |
---|
63 | CanonicalPoly* CanonicalPoly::deepCopy () const |
---|
64 | { |
---|
65 | +prpr > "creating a deep copy of CanonicalPoly, argument = " < this->toString(); |
---|
66 | SingularPoly sp = p_Copy(this->getSingularPoly(), this->getRing().getSingularRing()); /* SINGULAR poly is deeply copied. */ |
---|
67 | CanonicalPoly* pcp = new CanonicalPoly(sp, this->getRing()); /* ring is not deeply copied! */ |
---|
68 | return pcp; |
---|
69 | } |
---|
70 | |
---|
71 | #endif |
---|
72 | /* HAVE_WRAPPERS */ |
---|