1 | /**************************************** |
---|
2 | * Computer Algebra System SINGULAR * |
---|
3 | ****************************************/ |
---|
4 | /* |
---|
5 | * Dense Polynomials modulo p |
---|
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/OPAEp.h> |
---|
23 | #include <coeffs/AEp.h> |
---|
24 | |
---|
25 | |
---|
26 | |
---|
27 | |
---|
28 | |
---|
29 | // DEFINITION DER FUNKTIONEN |
---|
30 | |
---|
31 | number nAEpAdd(number a, number b,const coeffs r) |
---|
32 | { |
---|
33 | p_poly* f=reinterpret_cast<p_poly*> (a); |
---|
34 | p_poly* g=reinterpret_cast<p_poly*> (b); |
---|
35 | p_poly *res=new p_poly; |
---|
36 | res->p_poly_set(*f); |
---|
37 | res->p_poly_add_to(*g); |
---|
38 | return (number) res; |
---|
39 | } |
---|
40 | |
---|
41 | number nAEpMult(number a, number b,const coeffs r) |
---|
42 | { |
---|
43 | p_poly* f=reinterpret_cast<p_poly*> (a); |
---|
44 | p_poly* g=reinterpret_cast<p_poly*> (b); |
---|
45 | p_poly *res=new p_poly; |
---|
46 | res->p_poly_set(*f); |
---|
47 | res->p_poly_mult_n_to(*g); |
---|
48 | return (number) res; |
---|
49 | } |
---|
50 | |
---|
51 | number nAEpSub(number a, number b,const coeffs r) |
---|
52 | { |
---|
53 | p_poly* f=reinterpret_cast<p_poly*> (a); |
---|
54 | p_poly* g=reinterpret_cast<p_poly*> (b); |
---|
55 | p_poly *res=new p_poly; |
---|
56 | res->p_poly_set(*f); |
---|
57 | res->p_poly_sub_to(*g); |
---|
58 | return (number) res; |
---|
59 | } |
---|
60 | |
---|
61 | |
---|
62 | number nAEpDiv(number a, number b,const coeffs r) |
---|
63 | { |
---|
64 | p_poly* f=reinterpret_cast<p_poly*> (a); |
---|
65 | p_poly* g=reinterpret_cast<p_poly*> (b); |
---|
66 | p_poly *res=new p_poly; |
---|
67 | p_poly *s=new p_poly; |
---|
68 | res->p_poly_set(*f); |
---|
69 | res->p_poly_div_to(*res,*s,*g); |
---|
70 | return (number) res; |
---|
71 | } |
---|
72 | |
---|
73 | |
---|
74 | number nAEpIntDiv(number a, number b,const coeffs r) |
---|
75 | { |
---|
76 | |
---|
77 | p_poly* f=reinterpret_cast<p_poly*> (a); |
---|
78 | mpz_t* i= reinterpret_cast<mpz_t*> (b); |
---|
79 | p_poly *res=new p_poly; |
---|
80 | res->p_poly_set(*f); |
---|
81 | res->p_poly_scalar_div_to(*i); |
---|
82 | return (number) res; |
---|
83 | } |
---|
84 | |
---|
85 | number nAEpIntMod(number a, number b,const coeffs r) |
---|
86 | { |
---|
87 | return a; |
---|
88 | } |
---|
89 | |
---|
90 | number nAEpExactDiv(number a, number b,const coeffs r) |
---|
91 | { |
---|
92 | p_poly* f=reinterpret_cast<p_poly*> (a); |
---|
93 | p_poly* g=reinterpret_cast<p_poly*> (b); |
---|
94 | p_poly *res=new p_poly; |
---|
95 | p_poly *s=new p_poly; |
---|
96 | res->p_poly_set(*f); |
---|
97 | res->p_poly_div_to(*res,*s,*g); |
---|
98 | return (number) res; |
---|
99 | } |
---|
100 | |
---|
101 | |
---|
102 | |
---|
103 | number nAEpInit(long i, const coeffs r) |
---|
104 | { |
---|
105 | int j=7; |
---|
106 | mpz_t m; |
---|
107 | mpz_init_set_ui(m,i); |
---|
108 | p_poly* res=new p_poly; |
---|
109 | res->p_poly_set(m,j); |
---|
110 | number res1=reinterpret_cast<number>(res); |
---|
111 | return res1; |
---|
112 | } |
---|
113 | |
---|
114 | number nAEpInitMPZ(mpz_t m, const coeffs r) |
---|
115 | { |
---|
116 | int j=7; |
---|
117 | p_poly* res=new p_poly; |
---|
118 | res->p_poly_set(m,j); |
---|
119 | number res1=reinterpret_cast<number>(res); |
---|
120 | return res1; |
---|
121 | |
---|
122 | } |
---|
123 | |
---|
124 | int nAEpSize (number a,const coeffs r) |
---|
125 | { |
---|
126 | p_poly* f=reinterpret_cast<p_poly*> (a); |
---|
127 | return f->deg; |
---|
128 | } |
---|
129 | |
---|
130 | int nAEpInt(number &a,const coeffs r) |
---|
131 | { |
---|
132 | return 1; |
---|
133 | } |
---|
134 | |
---|
135 | |
---|
136 | number nAEpMPZ(number a,const coeffs r) |
---|
137 | { |
---|
138 | return a; |
---|
139 | } |
---|
140 | |
---|
141 | |
---|
142 | number nAEpNeg(number c, const coeffs r) |
---|
143 | { |
---|
144 | p_poly* f=reinterpret_cast<p_poly*> (c); |
---|
145 | p_poly *res=new p_poly; |
---|
146 | res->p_poly_set(*f); |
---|
147 | res->p_poly_neg(); |
---|
148 | return (number) res; |
---|
149 | } |
---|
150 | |
---|
151 | number nAEpCopy(number c, const coeffs r) |
---|
152 | { |
---|
153 | return c; |
---|
154 | } |
---|
155 | |
---|
156 | number nAEpRePart(number c, const coeffs r) |
---|
157 | { |
---|
158 | return c; |
---|
159 | } |
---|
160 | |
---|
161 | number nAEpImPart(number c, const coeffs r) |
---|
162 | { |
---|
163 | return c; |
---|
164 | } |
---|
165 | |
---|
166 | void nAEpWriteLong (number &a, const coeffs r) |
---|
167 | { |
---|
168 | p_poly* f=reinterpret_cast <p_poly*>(a); |
---|
169 | f->p_poly_print(); |
---|
170 | |
---|
171 | return; |
---|
172 | } |
---|
173 | |
---|
174 | void nAEpWriteShort (number &a, const coeffs r) |
---|
175 | { |
---|
176 | p_poly* f=reinterpret_cast <p_poly*>(a); |
---|
177 | f->p_poly_print(); |
---|
178 | return ; |
---|
179 | } |
---|
180 | |
---|
181 | |
---|
182 | const char * nAEpRead (const char *s, number *a,const coeffs r) |
---|
183 | { |
---|
184 | p_poly& f=reinterpret_cast <p_poly&>(a); |
---|
185 | f.p_poly_insert(); |
---|
186 | f.p_poly_print(); |
---|
187 | *a=reinterpret_cast <number>(&f); |
---|
188 | char* c=new char; |
---|
189 | *c='c'; |
---|
190 | return c; |
---|
191 | } |
---|
192 | |
---|
193 | number nAEpNormalize (number a,number b,const coeffs r) // ? |
---|
194 | { |
---|
195 | return a; |
---|
196 | } |
---|
197 | |
---|
198 | BOOLEAN nAEpGreater (number a, number b,const coeffs r) |
---|
199 | { |
---|
200 | p_poly* f=reinterpret_cast<p_poly*> (a); |
---|
201 | p_poly* g=reinterpret_cast<p_poly*> (b); |
---|
202 | if (f->deg > g->deg) {return FALSE;} |
---|
203 | else {return TRUE;} |
---|
204 | } |
---|
205 | |
---|
206 | BOOLEAN nAEpEqual (number a, number b,const coeffs r) |
---|
207 | { |
---|
208 | p_poly* f=reinterpret_cast<p_poly*> (a); |
---|
209 | p_poly* g=reinterpret_cast<p_poly*> (b); |
---|
210 | if (f->is_equal(*g) == 1) {return FALSE;} |
---|
211 | else {return TRUE;} |
---|
212 | } |
---|
213 | |
---|
214 | BOOLEAN nAEpIsZero (number a,const coeffs r) |
---|
215 | { |
---|
216 | p_poly* f=reinterpret_cast<p_poly*> (a); |
---|
217 | if (f->is_zero() == 1) {return FALSE;} |
---|
218 | else {return TRUE;} |
---|
219 | } |
---|
220 | |
---|
221 | BOOLEAN nAEpIsOne (number a,const coeffs r) |
---|
222 | { |
---|
223 | p_poly* f=reinterpret_cast<p_poly*> (a); |
---|
224 | if (f->is_one() == 1) {return FALSE;} |
---|
225 | else {return TRUE;} |
---|
226 | } |
---|
227 | |
---|
228 | BOOLEAN nAEpIsMOne (number a,const coeffs r) |
---|
229 | { |
---|
230 | number b=nAEpNeg(a,r); |
---|
231 | p_poly* f=reinterpret_cast<p_poly*> (b); |
---|
232 | if (f->is_one() == 1) {return FALSE;} |
---|
233 | else {return TRUE;} |
---|
234 | } |
---|
235 | |
---|
236 | BOOLEAN nAEpGreaterZero (number a, const coeffs r) |
---|
237 | { |
---|
238 | if (nAEpIsZero(a,r) == FALSE) { return TRUE; } |
---|
239 | else { return FALSE; } |
---|
240 | } |
---|
241 | |
---|
242 | void nAEpPower (number a, int i, number * result,const coeffs r) |
---|
243 | { |
---|
244 | return; |
---|
245 | } |
---|
246 | |
---|
247 | number nAEpGetDenom (number &a, const coeffs r) |
---|
248 | { |
---|
249 | return (number) 1; |
---|
250 | } |
---|
251 | |
---|
252 | number nAEpGetNumerator (number &a, const coeffs r) |
---|
253 | { |
---|
254 | return a; |
---|
255 | } |
---|
256 | |
---|
257 | number nAEpGcd (number a,number b,const coeffs r) |
---|
258 | { |
---|
259 | p_poly* f=reinterpret_cast<p_poly*> (a); |
---|
260 | p_poly* g=reinterpret_cast<p_poly*> (b); |
---|
261 | p_poly *res=new p_poly; |
---|
262 | res->p_poly_gcd(*f,*g); |
---|
263 | return (number) res; |
---|
264 | } |
---|
265 | |
---|
266 | number nAEpLcm (number a,number b,const coeffs r) |
---|
267 | { |
---|
268 | p_poly* f=reinterpret_cast<p_poly*> (a); |
---|
269 | p_poly* g=reinterpret_cast<p_poly*> (b); |
---|
270 | p_poly *gcd=new p_poly; |
---|
271 | p_poly *res=new p_poly; |
---|
272 | p_poly *s=new p_poly; |
---|
273 | gcd->p_poly_gcd(*f,*g); |
---|
274 | res->p_poly_mult_n(*f,*g); |
---|
275 | res->p_poly_div_to(*res,*s,*gcd); |
---|
276 | return (number) res; |
---|
277 | } |
---|
278 | |
---|
279 | void nAEpDelete (number *a, const coeffs r) |
---|
280 | { |
---|
281 | return; |
---|
282 | } |
---|
283 | |
---|
284 | /* |
---|
285 | number nAEpSetMap (number a, const coeffs r) |
---|
286 | { |
---|
287 | return a; |
---|
288 | } |
---|
289 | */ |
---|
290 | char* nAEpName (number a, const coeffs r) |
---|
291 | { |
---|
292 | char* c=new char; |
---|
293 | *c='c'; |
---|
294 | |
---|
295 | return c;; |
---|
296 | } |
---|
297 | |
---|
298 | void nAEpInpMult (number &a, number b,const coeffs r) |
---|
299 | { |
---|
300 | p_poly* f=reinterpret_cast<p_poly*> (a); |
---|
301 | p_poly* g=reinterpret_cast<p_poly*> (g); |
---|
302 | f->p_poly_mult_n_to(*g); |
---|
303 | a=(number) f; |
---|
304 | return ; |
---|
305 | } |
---|
306 | |
---|
307 | void nAEpCoeffWrite (const coeffs r, BOOLEAN details) |
---|
308 | { |
---|
309 | return; |
---|
310 | } |
---|
311 | |
---|
312 | BOOLEAN nAEpClearContent (number a,const coeffs r) |
---|
313 | { |
---|
314 | return FALSE; |
---|
315 | } |
---|
316 | |
---|
317 | BOOLEAN nAEpClearDenominators (number a,const coeffs r) |
---|
318 | { |
---|
319 | return FALSE; |
---|
320 | } |
---|
321 | |
---|
322 | |
---|
323 | |
---|
324 | //INITIALISIERUNG FÃR SINGULAR |
---|
325 | |
---|
326 | |
---|
327 | BOOLEAN n_pAEInitChar(coeffs r,void *p) // vlt noch void* p hin |
---|
328 | { |
---|
329 | //Charakteristik abgreifen! |
---|
330 | const int c = (int) (long) p; |
---|
331 | |
---|
332 | |
---|
333 | r->ch=c; |
---|
334 | r->cfKillChar=NULL; |
---|
335 | r->nCoeffIsEqual=ndCoeffIsEqual; |
---|
336 | r->cfMult = nAEpMult; |
---|
337 | r->cfSub = nAEpSub; |
---|
338 | r->cfAdd = nAEpAdd; |
---|
339 | r->cfDiv = nAEpDiv; |
---|
340 | r->cfIntDiv= nAEpIntDiv; |
---|
341 | r->cfIntMod= nAEpIntMod; |
---|
342 | r->cfExactDiv= nAEpExactDiv; |
---|
343 | r->cfInit = nAEpInit; |
---|
344 | r->cfSize = nAEpSize; |
---|
345 | r->cfInt = nAEpInt; |
---|
346 | #ifdef HAVE_RINGS |
---|
347 | //r->cfDivComp = NULL; // only for ring stuff |
---|
348 | //r->cfIsUnit = NULL; // only for ring stuff |
---|
349 | //r->cfGetUnit = NULL; // only for ring stuff |
---|
350 | //r->cfExtGcd = NULL; // only for ring stuff |
---|
351 | // r->cfDivBy = NULL; // only for ring stuff |
---|
352 | #endif |
---|
353 | r->cfNeg = nAEpNeg; |
---|
354 | r->cfInvers= NULL; |
---|
355 | //r->cfCopy = ndCopy; |
---|
356 | //r->cfRePart = ndCopy; |
---|
357 | //r->cfImPart = ndReturn0; |
---|
358 | r->cfWriteLong = nAEpWriteLong; |
---|
359 | r->cfRead = nAEpRead; |
---|
360 | //r->cfNormalize=ndNormalize; |
---|
361 | r->cfGreater = nAEpGreater; |
---|
362 | r->cfEqual = nAEpEqual; |
---|
363 | r->cfIsZero = nAEpIsZero; |
---|
364 | r->cfIsOne = nAEpIsOne; |
---|
365 | r->cfIsMOne = nAEpIsOne; |
---|
366 | r->cfGreaterZero = nAEpGreaterZero; |
---|
367 | r->cfPower = nAEpPower; // ZU BEARBEITEN |
---|
368 | r->cfGetDenom = nAEpGetDenom; |
---|
369 | r->cfGetNumerator = nAEpGetNumerator; |
---|
370 | r->cfGcd = nAEpGcd; |
---|
371 | r->cfLcm = nAEpLcm; // ZU BEARBEITEN |
---|
372 | r->cfDelete= nAEpDelete; |
---|
373 | r->cfSetMap = npSetMap; |
---|
374 | r->cfName = nAEpName; |
---|
375 | r->cfInpMult=nAEpInpMult; //???? |
---|
376 | r->cfInit_bigint= NULL; // nAEpMap0; |
---|
377 | r->cfCoeffWrite=nAEpCoeffWrite; //???? |
---|
378 | |
---|
379 | |
---|
380 | // the variables: |
---|
381 | r->nNULL = (number) 0; |
---|
382 | //r->type = n_AE; |
---|
383 | r->ch = c; |
---|
384 | r->has_simple_Alloc=TRUE; |
---|
385 | r->has_simple_Inverse=TRUE; |
---|
386 | return FALSE; |
---|
387 | } |
---|
388 | |
---|