1 | #include "mod2.h" |
---|
2 | |
---|
3 | #ifdef HAVE_WRAPPERS |
---|
4 | |
---|
5 | #include <iostream> |
---|
6 | #include "febase.h" |
---|
7 | #include "Wrappers.h" |
---|
8 | #include "PolyWrapper.h" |
---|
9 | #include "RingWrapper.h" |
---|
10 | #include "CanonicalPoly.h" |
---|
11 | |
---|
12 | PolyWrapper PolyWrapper::operator+ (const PolyWrapper& p) const |
---|
13 | { |
---|
14 | +prpr > "PolyWrapper::operator+ called"; |
---|
15 | prpr+1; |
---|
16 | +prpr > "first argument = " < this->toString(); |
---|
17 | +prpr > "second argument = " < p.toString(); |
---|
18 | prpr-1; |
---|
19 | PolyWrapper q(this->getInternPoly()->deepCopy()); /* deep copy of given PolyWrapper */ |
---|
20 | q.getInternPoly()->add(p.getInternPoly()); |
---|
21 | return q; |
---|
22 | } |
---|
23 | |
---|
24 | PolyWrapper& PolyWrapper::operator+= (const PolyWrapper& p) |
---|
25 | { |
---|
26 | +prpr > "PolyWrapper::operator+= called"; |
---|
27 | prpr+1; |
---|
28 | +prpr > "first argument = " < this->toString(); |
---|
29 | +prpr > "second argument = " < p.toString(); |
---|
30 | prpr-1; |
---|
31 | if (this->getInternPoly()->isShared()) |
---|
32 | { |
---|
33 | m_pInternPoly->decrement(); |
---|
34 | m_pInternPoly = m_pInternPoly->deepCopy(); |
---|
35 | } |
---|
36 | this->getInternPoly()->add(p.getInternPoly()); |
---|
37 | return *this; |
---|
38 | } |
---|
39 | |
---|
40 | const RingWrapper& PolyWrapper::getRing () const |
---|
41 | { |
---|
42 | return m_pInternPoly->getRing(); |
---|
43 | } |
---|
44 | |
---|
45 | PolyWrapper::PolyWrapper (): m_pInternPoly(0) |
---|
46 | { |
---|
47 | assume(false); /* the default constructor, i.e. the one |
---|
48 | without arguments should never be called */ |
---|
49 | } |
---|
50 | |
---|
51 | PolyWrapper::PolyWrapper (InternPoly* ip): m_pInternPoly(ip) |
---|
52 | { |
---|
53 | +prpr > "PolyWrapper constructor with argument InternPoly*"; |
---|
54 | } |
---|
55 | |
---|
56 | PolyWrapper::~PolyWrapper () |
---|
57 | { |
---|
58 | +prpr > "PolyWrapper destructor, object = " < this->toString(); |
---|
59 | InternPoly* p_ip = this->getInternPoly(); |
---|
60 | p_ip->decrement(); |
---|
61 | if (p_ip->getCounter() == 0) delete p_ip; |
---|
62 | } |
---|
63 | |
---|
64 | PolyWrapper::PolyWrapper (const PolyWrapper& p) |
---|
65 | { |
---|
66 | +prpr > "creating a shallow copy of PolyWrapper, argument = " < p.toString(); |
---|
67 | m_pInternPoly = p.getInternPoly(); |
---|
68 | m_pInternPoly->increment(); |
---|
69 | } |
---|
70 | |
---|
71 | PolyWrapper& PolyWrapper::operator= (const PolyWrapper& p) |
---|
72 | { |
---|
73 | +prpr > "assignment operator of PolyWrapper, argument = " < p.toString(); |
---|
74 | prpr+1; |
---|
75 | +prpr > "working with PolyWrapper " < this->toString(); |
---|
76 | prpr+1; |
---|
77 | m_pInternPoly->decrement(); |
---|
78 | if (m_pInternPoly->getCounter() == 0) delete m_pInternPoly; |
---|
79 | m_pInternPoly = p.getInternPoly(); |
---|
80 | prpr-1; |
---|
81 | +prpr > "working with PolyWrapper " < this->toString(); |
---|
82 | prpr+1; |
---|
83 | m_pInternPoly->increment(); |
---|
84 | prpr-2; |
---|
85 | +prpr > "assignment of PolyWrapper completed"; |
---|
86 | return *this; |
---|
87 | } |
---|
88 | |
---|
89 | void PolyWrapper::print () const |
---|
90 | { |
---|
91 | PrintS(this->toString()); |
---|
92 | } |
---|
93 | |
---|
94 | void PolyWrapper::printLn () const |
---|
95 | { |
---|
96 | PrintS(this->toString()); |
---|
97 | PrintLn(); |
---|
98 | } |
---|
99 | |
---|
100 | char* PolyWrapper::toString () const |
---|
101 | { |
---|
102 | InternPoly* pip = this->getInternPoly(); |
---|
103 | return pip->toString(); |
---|
104 | } |
---|
105 | |
---|
106 | InternPoly* PolyWrapper::getInternPoly () const |
---|
107 | { |
---|
108 | return m_pInternPoly; |
---|
109 | } |
---|
110 | |
---|
111 | PolyWrapper::PolyWrapper (const int i, const RingWrapper& r) { |
---|
112 | +prpr > "creating a new PolyWrapper (internal type: CanonicalPoly)"; |
---|
113 | m_pInternPoly = new CanonicalPoly(i, r); |
---|
114 | } |
---|
115 | |
---|
116 | PolyWrapper::PolyWrapper (const SingularPoly& sp, const RingWrapper& r) { |
---|
117 | +prpr > "creating a new PolyWrapper (internal type: CanonicalPoly)"; |
---|
118 | m_pInternPoly = new CanonicalPoly(sp, r); |
---|
119 | } |
---|
120 | |
---|
121 | #endif |
---|
122 | /* HAVE_WRAPPERS */ |
---|