1 | #ifndef POLY_WRAPPER_H |
---|
2 | #define POLY_WRAPPER_H |
---|
3 | |
---|
4 | #ifdef HAVE_WRAPPERS |
---|
5 | |
---|
6 | #include "Wrappers.h" |
---|
7 | #include "InternPoly.h" |
---|
8 | #include "RingWrapper.h" |
---|
9 | |
---|
10 | /*! \class PolyWrapper |
---|
11 | * \brief Class PolyWrapper provides a uniform interface to different |
---|
12 | * representations of polynomials. |
---|
13 | * |
---|
14 | * Instances of PolyWrapper uniformly represent different kinds of |
---|
15 | * polynomials that play a role in the computer algebra system SINGULAR |
---|
16 | * and related suites such as PolyBoRi. Especially SINGULAR-internal |
---|
17 | * polynomials can be wrapped by instances of PolyWrapper.<br> |
---|
18 | * This implementation comes with an automatic reference counting so that copying |
---|
19 | * PolyWrappers is cheap as it will simply be done by incrementing the |
---|
20 | * respective reference counter. Constructors and destructors automatically |
---|
21 | * manage the reference counting. Methods that create new instances of |
---|
22 | * PolyWrapper, e.g. PolyWrapper::operator+ (const PolyWrapper& p) const, |
---|
23 | * will internally enforce the instantiation of a new ReferenceCounter.<br> |
---|
24 | * Summarizing this means that all methods of PolyWrapper <em>know</em> when |
---|
25 | * to make a shallow copy (by incrementing the ReferenceCounter) and when to |
---|
26 | * make a deep copy.<br> |
---|
27 | * Polynomials wrapped by PolyWrapper <em>know</em> in which ring they live. |
---|
28 | * A wrapper object of that ring can be obtained by calling |
---|
29 | * PolyWrapper::getRing () const. |
---|
30 | * \author Frank Seelisch, http://www.mathematik.uni-kl.de/~seelisch |
---|
31 | */ |
---|
32 | class PolyWrapper |
---|
33 | { |
---|
34 | private: |
---|
35 | /*! a pointer to an internal polynomial representation, |
---|
36 | e.g. to a SINGULAR-internal polynomial */ |
---|
37 | InternPoly* m_pInternPoly; |
---|
38 | |
---|
39 | /*! |
---|
40 | * A constructor for PolyWrapper.<br> |
---|
41 | * This constructor just wraps the provided instance of InternPoly, |
---|
42 | * which may e.g. be a SINGULAR-internal polynomial. |
---|
43 | * @param ip the internal polynomial to be wrapped |
---|
44 | * @see PolyWrapper::PolyWrapper () |
---|
45 | * @see PolyWrapper::PolyWrapper (const PolyWrapper& p) |
---|
46 | * @see PolyWrapper::PolyWrapper (const int i, const RingWrapper& r) |
---|
47 | * @see PolyWrapper::PolyWrapper (const SingularPoly& sp, const RingWrapper& r) |
---|
48 | */ |
---|
49 | PolyWrapper (InternPoly* ip); |
---|
50 | |
---|
51 | /*! |
---|
52 | * A method for retrieving the wrapped InternPoly. |
---|
53 | * @return the wrapped InternPoly |
---|
54 | * @see PolyWrapper::PolyWrapper (InternPoly* ip) |
---|
55 | */ |
---|
56 | InternPoly* getInternPoly () const; |
---|
57 | public: |
---|
58 | /*! |
---|
59 | * A default constructor for PolyWrapper.<br> |
---|
60 | * This constructor will make the program stop as it should |
---|
61 | * never be called by the user or as a side-effect of any action. |
---|
62 | * @see PolyWrapper::PolyWrapper (InternPoly* ip) |
---|
63 | * @see PolyWrapper::PolyWrapper (const PolyWrapper& p) |
---|
64 | * @see PolyWrapper::PolyWrapper (const int i, const RingWrapper& r) |
---|
65 | * @see PolyWrapper::PolyWrapper (const SingularPoly& sp, const RingWrapper& r) |
---|
66 | */ |
---|
67 | PolyWrapper (); |
---|
68 | |
---|
69 | /*! |
---|
70 | * A copy constructor for PolyWrapper.<br> |
---|
71 | * This constructor creates a shallow copy of the argument. This is |
---|
72 | * simply done by incrementing the ReferenceCounter. |
---|
73 | * @param p the PolyWrapper to be shallow-copied |
---|
74 | * @see PolyWrapper::PolyWrapper () |
---|
75 | * @see PolyWrapper::PolyWrapper (InternPoly* ip) |
---|
76 | * @see PolyWrapper::PolyWrapper (const int i, const RingWrapper& r) |
---|
77 | * @see PolyWrapper::PolyWrapper (const SingularPoly& sp, const RingWrapper& r) |
---|
78 | */ |
---|
79 | PolyWrapper (const PolyWrapper& p); |
---|
80 | |
---|
81 | /*! |
---|
82 | * A constructor for PolyWrapper.<br> |
---|
83 | * This constructor creates a SINGULAR-internal polynomial representing |
---|
84 | * the given argument integer, and then a wrapped version of it.<br> |
---|
85 | * The user may use RingWrapper::RingWrapper () to create a RingWrapper wrapping |
---|
86 | * the current SINGULAR-internal ring (<c>currRing</c>). |
---|
87 | * @param i the integer to be represented as a polynomial |
---|
88 | * @param r a RingWrapper wrapping the internal ring in which the polynomial lives |
---|
89 | * @see PolyWrapper::PolyWrapper () |
---|
90 | * @see PolyWrapper::PolyWrapper (InternPoly* ip) |
---|
91 | * @see PolyWrapper::PolyWrapper (const PolyWrapper& p) |
---|
92 | * @see PolyWrapper::PolyWrapper (const SingularPoly& sp, const RingWrapper& r) |
---|
93 | */ |
---|
94 | PolyWrapper (const int i, const RingWrapper& r); |
---|
95 | |
---|
96 | /*! |
---|
97 | * A constructor for PolyWrapper.<br> |
---|
98 | * This constructor creates a wrapped version of the given SINGULAR-internal |
---|
99 | * polynomial.<br> |
---|
100 | * The user may use RingWrapper::RingWrapper () to create a RingWrapper wrapping |
---|
101 | * the current SINGULAR-internal ring (<c>currRing</c>). |
---|
102 | * @param sp a SINGULAR-internal polynomial |
---|
103 | * @param r a RingWrapper wrapping the internal ring in which the polynomial lives |
---|
104 | * @see PolyWrapper::PolyWrapper () |
---|
105 | * @see PolyWrapper::PolyWrapper (InternPoly* ip) |
---|
106 | * @see PolyWrapper::PolyWrapper (const PolyWrapper& p) |
---|
107 | * @see PolyWrapper::PolyWrapper (const int i, const RingWrapper& r) |
---|
108 | */ |
---|
109 | PolyWrapper (const SingularPoly& sp, const RingWrapper& r); |
---|
110 | |
---|
111 | /*! |
---|
112 | * A destructor for PolyWrapper.<br> |
---|
113 | * This constructor creates a wrapped version of the given SINGULAR-internal |
---|
114 | * polynomial.<br> |
---|
115 | * This routine will automatically decrement the ReferenceCounter and, in case |
---|
116 | * the counter reaches zero, enforce the destruction of related objects. |
---|
117 | * @see PolyWrapper::PolyWrapper () |
---|
118 | * @see PolyWrapper::PolyWrapper (InternPoly* ip) |
---|
119 | * @see PolyWrapper::PolyWrapper (const PolyWrapper& p) |
---|
120 | * @see PolyWrapper::PolyWrapper (const int i, const RingWrapper& r) |
---|
121 | * @see PolyWrapper::PolyWrapper (const SingularPoly& sp, const RingWrapper& r) |
---|
122 | */ |
---|
123 | ~PolyWrapper (); |
---|
124 | |
---|
125 | /*! |
---|
126 | * A method for printing a string representation of the given instance.<br> |
---|
127 | * This method does not use std::cout but only SINGULAR-internal print routines. |
---|
128 | * @see PolyWrapper::printLn () const |
---|
129 | * @see PolyWrapper::toString () const |
---|
130 | */ |
---|
131 | void print () const; |
---|
132 | |
---|
133 | /*! |
---|
134 | * A method for printing a string representation of the given instance |
---|
135 | * followed by a linefeed.<br> |
---|
136 | * This method does not use std::cout but only SINGULAR-internal print routines. |
---|
137 | * @see PolyWrapper::print () const |
---|
138 | * @see PolyWrapper::toString () const |
---|
139 | */ |
---|
140 | void printLn () const; |
---|
141 | |
---|
142 | /*! |
---|
143 | * A method for obtaining a string representation of the given instance. |
---|
144 | * @see PolyWrapper::print () const |
---|
145 | * @see PolyWrapper::printLn () const |
---|
146 | */ |
---|
147 | char* toString () const; |
---|
148 | |
---|
149 | /*! |
---|
150 | * Assignment operator for PolyWrapper.<br> |
---|
151 | * This method will just exchange the wrapped instance of InternPoly. |
---|
152 | * Consequently, the ReferenceCounter of the InternPoly wrapped by the |
---|
153 | * given argument will be decremented (and in case of reaching zero, |
---|
154 | * the destruction of related objects will be enforced). |
---|
155 | * @param p an instance of PolyWrapper |
---|
156 | * @return a reference to the new PolyWrapper |
---|
157 | */ |
---|
158 | PolyWrapper& operator= (const PolyWrapper& p); |
---|
159 | |
---|
160 | /*! |
---|
161 | * Addition operator for PolyWrapper.<br> |
---|
162 | * This method will compute a PolyWrapper which wraps the result of |
---|
163 | * adding the polynomials wrapped by <c>this</c> PolyWrapper and by |
---|
164 | * the argument PolyWrapper. |
---|
165 | * @param p an instance of PolyWrapper |
---|
166 | * @return a PolyWrapper representing the sum |
---|
167 | */ |
---|
168 | PolyWrapper operator+ (const PolyWrapper& p) const; |
---|
169 | |
---|
170 | /*! |
---|
171 | * Modifying addition operator for PolyWrapper.<br> |
---|
172 | * This method will compute (in the PolyWrapper given by <c>this</c>), |
---|
173 | * the result of adding the polynomials wrapped by <c>this</c> PolyWrapper and by |
---|
174 | * the argument PolyWrapper. Note that this method will in general change the |
---|
175 | * given object. |
---|
176 | * @param p an instance of PolyWrapper |
---|
177 | * @return a reference to <c>this</c> PolyWrapper now representing the sum |
---|
178 | */ |
---|
179 | PolyWrapper& operator+= (const PolyWrapper& p); |
---|
180 | |
---|
181 | /*! |
---|
182 | * A method for retrieving a RingWrapper wrapping the internal ring in which |
---|
183 | * the given polynomial lives. |
---|
184 | * @return a reference to a RingWrapper |
---|
185 | */ |
---|
186 | const RingWrapper& getRing () const; |
---|
187 | }; |
---|
188 | |
---|
189 | #endif |
---|
190 | /* HAVE_WRAPPERS */ |
---|
191 | |
---|
192 | #endif |
---|
193 | /* POLY_WRAPPER_H */ |
---|