1 | /**************************************** |
---|
2 | * Computer Algebra System SINGULAR * |
---|
3 | ****************************************/ |
---|
4 | /* |
---|
5 | *Dense Integer Polynomials |
---|
6 | */ |
---|
7 | //Schauen was hier ÃŒberhaupt sinn macht |
---|
8 | #include "libpolysconfig.h" |
---|
9 | #include <misc/auxiliary.h> |
---|
10 | |
---|
11 | #include <factory/factory.h> |
---|
12 | |
---|
13 | #include <string.h> |
---|
14 | #include <omalloc/omalloc.h> |
---|
15 | #include <coeffs/coeffs.h> |
---|
16 | #include <reporter/reporter.h> |
---|
17 | #include <coeffs/numbers.h> |
---|
18 | #include <coeffs/longrat.h> |
---|
19 | #include <coeffs/modulop.h> |
---|
20 | #include <coeffs/mpr_complex.h> |
---|
21 | #include <misc/mylimits.h> |
---|
22 | #include <coeffs/OPAEQ.h> |
---|
23 | #include <coeffs/AEQ.h> |
---|
24 | |
---|
25 | |
---|
26 | |
---|
27 | |
---|
28 | |
---|
29 | // DEFINITION DER FUNKTIONEN |
---|
30 | |
---|
31 | number nAEQAdd(number a, number b,const coeffs r) |
---|
32 | { |
---|
33 | Q_poly* f=reinterpret_cast<Q_poly*> (a); |
---|
34 | Q_poly* g=reinterpret_cast<Q_poly*> (b); |
---|
35 | Q_poly *res=new Q_poly; |
---|
36 | res->Q_poly_set(*f); |
---|
37 | res->Q_poly_add_to(*g); |
---|
38 | return (number) res; |
---|
39 | } |
---|
40 | |
---|
41 | number nAEQMult(number a, number b,const coeffs r) |
---|
42 | { |
---|
43 | Q_poly* f=reinterpret_cast<Q_poly*> (a); |
---|
44 | Q_poly* g=reinterpret_cast<Q_poly*> (b); |
---|
45 | Q_poly *res=new Q_poly; |
---|
46 | res->Q_poly_set(*f); |
---|
47 | res->Q_poly_mult_n_to(*g); |
---|
48 | return (number) res; |
---|
49 | } |
---|
50 | |
---|
51 | number nAEQSub(number a, number b,const coeffs r) |
---|
52 | { |
---|
53 | Q_poly* f=reinterpret_cast<Q_poly*> (a); |
---|
54 | Q_poly* g=reinterpret_cast<Q_poly*> (b); |
---|
55 | Q_poly *res=new Q_poly; |
---|
56 | res->Q_poly_set(*f); |
---|
57 | res->Q_poly_sub_to(*g); |
---|
58 | return (number) res; |
---|
59 | } |
---|
60 | |
---|
61 | |
---|
62 | number nAEQDiv(number a, number b,const coeffs r) |
---|
63 | { |
---|
64 | Q_poly* f=reinterpret_cast<Q_poly*> (a); |
---|
65 | Q_poly* g=reinterpret_cast<Q_poly*> (b); |
---|
66 | Q_poly *res=new Q_poly; |
---|
67 | Q_poly *s=new Q_poly; |
---|
68 | res->Q_poly_set(*f); |
---|
69 | res->Q_poly_div_to(*res,*s,*g); |
---|
70 | return (number) res; |
---|
71 | } |
---|
72 | |
---|
73 | |
---|
74 | number nAEQIntDiv(number a, number b,const coeffs r) |
---|
75 | { |
---|
76 | |
---|
77 | Q_poly* f=reinterpret_cast<Q_poly*> (a); |
---|
78 | mpz_t* i= reinterpret_cast<mpz_t*> (b); |
---|
79 | Q_poly *res=new Q_poly; |
---|
80 | res->Q_poly_set(*f); |
---|
81 | res->Q_poly_scalar_div_to(*i); |
---|
82 | return (number) res; |
---|
83 | } |
---|
84 | |
---|
85 | number nAEQIntMod(number a, number b,const coeffs r) |
---|
86 | { |
---|
87 | return a; |
---|
88 | } |
---|
89 | |
---|
90 | number nAEQExactDiv(number a, number b,const coeffs r) |
---|
91 | { |
---|
92 | Q_poly* f=reinterpret_cast<Q_poly*> (a); |
---|
93 | Q_poly* g=reinterpret_cast<Q_poly*> (b); |
---|
94 | Q_poly *res=new Q_poly; |
---|
95 | Q_poly *s=new Q_poly; |
---|
96 | res->Q_poly_set(*f); |
---|
97 | res->Q_poly_div_to(*res,*s,*g); |
---|
98 | return (number) res; |
---|
99 | } |
---|
100 | |
---|
101 | |
---|
102 | |
---|
103 | number nAEQInit(long i, const coeffs r) |
---|
104 | { |
---|
105 | number res = (number) i; |
---|
106 | return res; |
---|
107 | } |
---|
108 | |
---|
109 | number nAEQInitMPZ(mpz_t m, const coeffs r) |
---|
110 | { |
---|
111 | number res= (number) m; |
---|
112 | return res; |
---|
113 | } |
---|
114 | |
---|
115 | int nAEQSize (number a,const coeffs r) |
---|
116 | { |
---|
117 | Q_poly* f=reinterpret_cast<Q_poly*> (a); |
---|
118 | return f->deg; |
---|
119 | } |
---|
120 | |
---|
121 | int nAEQInt(number &a,const coeffs r) |
---|
122 | { |
---|
123 | return 1; |
---|
124 | } |
---|
125 | |
---|
126 | |
---|
127 | number nAEQMPZ(number a,const coeffs r) |
---|
128 | { |
---|
129 | return a; |
---|
130 | } |
---|
131 | |
---|
132 | |
---|
133 | number nAEQNeg(number c, const coeffs r) |
---|
134 | { |
---|
135 | Q_poly* f=reinterpret_cast<Q_poly*> (c); |
---|
136 | Q_poly *res=new Q_poly; |
---|
137 | res->Q_poly_set(*f); |
---|
138 | res->Q_poly_neg(); |
---|
139 | return (number) res; |
---|
140 | } |
---|
141 | |
---|
142 | number nAEQCopy(number c, const coeffs r) |
---|
143 | { |
---|
144 | return (number) c; |
---|
145 | } |
---|
146 | |
---|
147 | number nAEQRePart(number c, const coeffs r) |
---|
148 | { |
---|
149 | return (number) c; |
---|
150 | } |
---|
151 | |
---|
152 | number nAEQImPart(number c, const coeffs r) |
---|
153 | { |
---|
154 | return (number) c; |
---|
155 | } |
---|
156 | |
---|
157 | void nAEQWriteLong (number &a, const coeffs r) |
---|
158 | { |
---|
159 | return; |
---|
160 | } |
---|
161 | |
---|
162 | void nAEQWriteShort (number &a, const coeffs r) |
---|
163 | { |
---|
164 | return ; |
---|
165 | } |
---|
166 | |
---|
167 | |
---|
168 | const char * nAEQRead (const char *s, number *a,const coeffs r) |
---|
169 | { |
---|
170 | return ""; |
---|
171 | } |
---|
172 | |
---|
173 | number nAEQNormalize (number a,number b,const coeffs r) // ? |
---|
174 | { |
---|
175 | return a; |
---|
176 | } |
---|
177 | |
---|
178 | BOOLEAN nAEQGreater (number a, number b,const coeffs r) |
---|
179 | { |
---|
180 | Q_poly* f=reinterpret_cast<Q_poly*> (a); |
---|
181 | Q_poly* g=reinterpret_cast<Q_poly*> (b); |
---|
182 | if (f->deg > g->deg) {return FALSE;} |
---|
183 | else {return TRUE;} |
---|
184 | } |
---|
185 | |
---|
186 | BOOLEAN nAEQEqual (number a, number b,const coeffs r) |
---|
187 | { |
---|
188 | Q_poly* f=reinterpret_cast<Q_poly*> (a); |
---|
189 | Q_poly* g=reinterpret_cast<Q_poly*> (b); |
---|
190 | if (f->is_equal(*g) == 1) {return FALSE;} |
---|
191 | else {return TRUE;} |
---|
192 | } |
---|
193 | |
---|
194 | BOOLEAN nAEQIsZero (number a,const coeffs r) |
---|
195 | { |
---|
196 | Q_poly* f=reinterpret_cast<Q_poly*> (a); |
---|
197 | if (f->is_zero() == 1) {return FALSE;} |
---|
198 | else {return TRUE;} |
---|
199 | } |
---|
200 | |
---|
201 | BOOLEAN nAEQIsOne (number a,const coeffs r) |
---|
202 | { |
---|
203 | Q_poly* f=reinterpret_cast<Q_poly*> (a); |
---|
204 | if (f->is_one() == 1) {return FALSE;} |
---|
205 | else {return TRUE;} |
---|
206 | } |
---|
207 | |
---|
208 | BOOLEAN nAEQIsMOne (number a,const coeffs r) |
---|
209 | { |
---|
210 | Q_poly* f=reinterpret_cast<Q_poly*> (a); |
---|
211 | if (f->is_one() == 1) {return FALSE;} |
---|
212 | else {return TRUE;} |
---|
213 | } |
---|
214 | |
---|
215 | BOOLEAN nAEQGreaterZero (number a, const coeffs r) |
---|
216 | { |
---|
217 | if (nAEQIsZero(a,r) == FALSE) { return TRUE; } |
---|
218 | else { return FALSE; } |
---|
219 | } |
---|
220 | |
---|
221 | void nAEQPower (number a, int i, number * result,const coeffs r) |
---|
222 | { |
---|
223 | return; |
---|
224 | } |
---|
225 | |
---|
226 | number nAEQGetDenom (number &a, const coeffs r) |
---|
227 | { |
---|
228 | return (number) 1; |
---|
229 | } |
---|
230 | |
---|
231 | number nAEQGetNumerator (number &a, const coeffs r) |
---|
232 | { |
---|
233 | return a; |
---|
234 | } |
---|
235 | |
---|
236 | number nAEQGcd (number a,number b,const coeffs r) |
---|
237 | { |
---|
238 | Q_poly* f=reinterpret_cast<Q_poly*> (a); |
---|
239 | Q_poly* g=reinterpret_cast<Q_poly*> (b); |
---|
240 | Q_poly *res=new Q_poly; |
---|
241 | res->Q_poly_gcd(*f,*g); |
---|
242 | return (number) res; |
---|
243 | } |
---|
244 | |
---|
245 | number nAEQLcm (number a,number b,const coeffs r) |
---|
246 | { |
---|
247 | Q_poly* f=reinterpret_cast<Q_poly*> (a); |
---|
248 | Q_poly* g=reinterpret_cast<Q_poly*> (b); |
---|
249 | Q_poly *gcd=new Q_poly; |
---|
250 | Q_poly *res=new Q_poly; |
---|
251 | Q_poly *s=new Q_poly; |
---|
252 | gcd->Q_poly_gcd(*f,*g); |
---|
253 | res->Q_poly_mult_n(*f,*g); |
---|
254 | res->Q_poly_div_to(*res,*s,*gcd); |
---|
255 | return (number) res; |
---|
256 | } |
---|
257 | |
---|
258 | void nAEQDelete (number *a, const coeffs r) |
---|
259 | { |
---|
260 | return; |
---|
261 | } |
---|
262 | |
---|
263 | /* |
---|
264 | number nAEQSetMap (number a, const coeffs r) |
---|
265 | { |
---|
266 | return a; |
---|
267 | } |
---|
268 | */ |
---|
269 | char* nAEQName (number a, const coeffs r) |
---|
270 | { |
---|
271 | char* c=new char; |
---|
272 | *c='c'; |
---|
273 | |
---|
274 | return c; |
---|
275 | } |
---|
276 | |
---|
277 | void nAEQInpMult (number &a, number b,const coeffs r) |
---|
278 | { |
---|
279 | return ; |
---|
280 | } |
---|
281 | |
---|
282 | void nAEQCoeffWrite (const coeffs r, BOOLEAN details) |
---|
283 | { |
---|
284 | return; |
---|
285 | } |
---|
286 | |
---|
287 | BOOLEAN nAEQClearContent (number a,const coeffs r) |
---|
288 | { |
---|
289 | return FALSE; |
---|
290 | } |
---|
291 | |
---|
292 | BOOLEAN nAEQClearDenominators (number a,const coeffs r) |
---|
293 | { |
---|
294 | return FALSE; |
---|
295 | } |
---|
296 | |
---|
297 | |
---|
298 | |
---|
299 | //INITIALISIERUNG FÃR SINGULAR |
---|
300 | |
---|
301 | |
---|
302 | BOOLEAN n_QAEInitChar(coeffs r,void *p) // vlt noch void* p hin |
---|
303 | { |
---|
304 | |
---|
305 | |
---|
306 | |
---|
307 | r->ch=0; |
---|
308 | r->cfKillChar=NULL; |
---|
309 | r->nCoeffIsEqual=ndCoeffIsEqual; |
---|
310 | r->cfMult = nAEQMult; |
---|
311 | r->cfSub = nAEQSub; |
---|
312 | r->cfAdd = nAEQAdd; |
---|
313 | r->cfDiv = nAEQDiv; |
---|
314 | r->cfIntDiv= nAEQIntDiv; |
---|
315 | r->cfIntMod= nAEQIntMod; |
---|
316 | r->cfExactDiv= nAEQExactDiv; |
---|
317 | r->cfInit = nAEQInit; |
---|
318 | r->cfSize = nAEQSize; |
---|
319 | r->cfInt = nAEQInt; |
---|
320 | #ifdef HAVE_RINGS |
---|
321 | //r->cfDivComp = NULL; // only for ring stuff |
---|
322 | //r->cfIsUnit = NULL; // only for ring stuff |
---|
323 | //r->cfGetUnit = NULL; // only for ring stuff |
---|
324 | //r->cfExtGcd = NULL; // only for ring stuff |
---|
325 | // r->cfDivBy = NULL; // only for ring stuff |
---|
326 | #endif |
---|
327 | r->cfNeg = nAEQNeg; |
---|
328 | r->cfInvers= NULL; |
---|
329 | //r->cfCopy = ndCopy; |
---|
330 | //r->cfRePart = ndCopy; |
---|
331 | //r->cfImPart = ndReturn0; |
---|
332 | r->cfWriteLong = nAEQWriteLong; |
---|
333 | r->cfRead = nAEQRead; |
---|
334 | //r->cfNormalize=ndNormalize; |
---|
335 | r->cfGreater = nAEQGreater; |
---|
336 | r->cfEqual = nAEQEqual; |
---|
337 | r->cfIsZero = nAEQIsZero; |
---|
338 | r->cfIsOne = nAEQIsOne; |
---|
339 | r->cfIsMOne = nAEQIsOne; |
---|
340 | r->cfGreaterZero = nAEQGreaterZero; |
---|
341 | r->cfPower = nAEQPower; // ZU BEARBEITEN |
---|
342 | r->cfGetDenom = nAEQGetDenom; |
---|
343 | r->cfGetNumerator = nAEQGetNumerator; |
---|
344 | r->cfGcd = nAEQGcd; |
---|
345 | r->cfLcm = nAEQLcm; // ZU BEARBEITEN |
---|
346 | r->cfDelete= nAEQDelete; |
---|
347 | r->cfSetMap = npSetMap; |
---|
348 | r->cfName = nAEQName; |
---|
349 | r->cfInpMult=nAEQInpMult; //???? |
---|
350 | r->cfInit_bigint= NULL; // nAEQMap0; |
---|
351 | r->cfCoeffWrite=nAEQCoeffWrite; //???? |
---|
352 | |
---|
353 | |
---|
354 | // the variables: |
---|
355 | r->nNULL = (number) 0; |
---|
356 | //r->type = n_AE; |
---|
357 | r->has_simple_Alloc=TRUE; |
---|
358 | r->has_simple_Inverse=TRUE; |
---|
359 | return FALSE; |
---|
360 | } |
---|
361 | |
---|