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 | #ifdef HAVE_FACTORY |
---|
12 | #include <factory/factory.h> |
---|
13 | #endif |
---|
14 | |
---|
15 | #include <string.h> |
---|
16 | #include <omalloc/omalloc.h> |
---|
17 | #include <coeffs/coeffs.h> |
---|
18 | #include <reporter/reporter.h> |
---|
19 | #include <coeffs/numbers.h> |
---|
20 | #include <coeffs/longrat.h> |
---|
21 | #include <coeffs/modulop.h> |
---|
22 | #include <coeffs/mpr_complex.h> |
---|
23 | #include <misc/mylimits.h> |
---|
24 | #include <coeffs/OPAE.h> |
---|
25 | #include <coeffs/AE.h> |
---|
26 | |
---|
27 | |
---|
28 | |
---|
29 | |
---|
30 | // DEFINITION DER FUNKTIONEN |
---|
31 | |
---|
32 | number nAEAdd(number a, number b,const coeffs r) |
---|
33 | { |
---|
34 | int_poly* f=reinterpret_cast<int_poly*> (a); |
---|
35 | int_poly* g=reinterpret_cast<int_poly*> (b); |
---|
36 | int_poly *res=new int_poly; |
---|
37 | res->poly_set(*f); |
---|
38 | res->poly_add_to(*g); |
---|
39 | return (number) res; |
---|
40 | } |
---|
41 | |
---|
42 | number nAEMult(number a, number b,const coeffs r) |
---|
43 | { |
---|
44 | int_poly* f=reinterpret_cast<int_poly*> (a); |
---|
45 | int_poly* g=reinterpret_cast<int_poly*> (b); |
---|
46 | int_poly *res=new int_poly; |
---|
47 | res->poly_set(*f); |
---|
48 | res->poly_mult_n_to(*g); |
---|
49 | return (number) res; |
---|
50 | } |
---|
51 | |
---|
52 | number nAESub(number a, number b,const coeffs r) |
---|
53 | { |
---|
54 | int_poly* f=reinterpret_cast<int_poly*> (a); |
---|
55 | int_poly* g=reinterpret_cast<int_poly*> (b); |
---|
56 | int_poly *res=new int_poly; |
---|
57 | res->poly_set(*f); |
---|
58 | res->poly_sub_to(*g); |
---|
59 | return (number) res; |
---|
60 | } |
---|
61 | |
---|
62 | |
---|
63 | number nAEDiv(number a, number b,const coeffs r) |
---|
64 | { |
---|
65 | int_poly* f=reinterpret_cast<int_poly*> (a); |
---|
66 | int_poly* g=reinterpret_cast<int_poly*> (b); |
---|
67 | int_poly *res=new int_poly; |
---|
68 | res->poly_set(*f); |
---|
69 | res->poly_div_to(*res,*f,*g); |
---|
70 | return (number) res; |
---|
71 | } |
---|
72 | |
---|
73 | |
---|
74 | number nAEIntDiv(number a, number b,const coeffs r) |
---|
75 | { |
---|
76 | |
---|
77 | int_poly* f=reinterpret_cast<int_poly*> (a); |
---|
78 | mpz_t* i= reinterpret_cast<mpz_t*> (b); |
---|
79 | int_poly *res=new int_poly; |
---|
80 | res->poly_set(*f); |
---|
81 | res->poly_scalar_div_to(*i); |
---|
82 | return (number) res; |
---|
83 | } |
---|
84 | |
---|
85 | number nAEIntMod(number a, number b,const coeffs r) |
---|
86 | { |
---|
87 | return a; |
---|
88 | } |
---|
89 | |
---|
90 | number nAEExactDiv(number a, number b,const coeffs r) |
---|
91 | { |
---|
92 | int_poly* f=reinterpret_cast<int_poly*> (a); |
---|
93 | int_poly* g=reinterpret_cast<int_poly*> (b); |
---|
94 | int_poly *res=new int_poly; |
---|
95 | res->poly_set(*f); |
---|
96 | res->poly_div_to(*res,*f,*g); |
---|
97 | return (number) res; |
---|
98 | } |
---|
99 | |
---|
100 | |
---|
101 | |
---|
102 | number nAEInit(long i, const coeffs r) |
---|
103 | { |
---|
104 | mpz_t m; |
---|
105 | mpz_init_set_ui(m,i); |
---|
106 | int_poly* res=new int_poly; |
---|
107 | res->poly_set(m); |
---|
108 | number res1=reinterpret_cast<number>(res); |
---|
109 | return res1; |
---|
110 | } |
---|
111 | |
---|
112 | number nAEInitMPZ(mpz_t m, const coeffs r) |
---|
113 | { |
---|
114 | int_poly* res=new int_poly; |
---|
115 | res->poly_set(m); |
---|
116 | number res1=reinterpret_cast<number>(res); |
---|
117 | return res1; |
---|
118 | } |
---|
119 | |
---|
120 | |
---|
121 | int nAESize (number a,const coeffs r) |
---|
122 | { |
---|
123 | int_poly* f=reinterpret_cast<int_poly*> (a); |
---|
124 | return f->deg; |
---|
125 | } |
---|
126 | |
---|
127 | int nAEInt(number &a,const coeffs r) |
---|
128 | { |
---|
129 | return 1; |
---|
130 | } |
---|
131 | |
---|
132 | |
---|
133 | number nAEMPZ(number a,const coeffs r) |
---|
134 | { |
---|
135 | return a; |
---|
136 | } |
---|
137 | |
---|
138 | |
---|
139 | number nAENeg(number c, const coeffs r) |
---|
140 | { |
---|
141 | int_poly* f=reinterpret_cast<int_poly*> (c); |
---|
142 | int_poly *res=new int_poly; |
---|
143 | res->poly_set(*f); |
---|
144 | res->poly_neg(); |
---|
145 | return (number) res; |
---|
146 | } |
---|
147 | |
---|
148 | number nAECopy(number c, const coeffs r) |
---|
149 | { |
---|
150 | return (number) c; |
---|
151 | } |
---|
152 | |
---|
153 | number nAERePart(number c, const coeffs r) |
---|
154 | { |
---|
155 | return (number) c; |
---|
156 | } |
---|
157 | |
---|
158 | number nAEImPart(number c, const coeffs r) |
---|
159 | { |
---|
160 | return (number) c; |
---|
161 | } |
---|
162 | |
---|
163 | void nAEWriteLong (number &a, const coeffs r) |
---|
164 | { |
---|
165 | int_poly* f=reinterpret_cast <int_poly*>(a); |
---|
166 | f->poly_print(); |
---|
167 | return ; |
---|
168 | } |
---|
169 | |
---|
170 | void nAEWriteShort (number &a, const coeffs r) |
---|
171 | { |
---|
172 | int_poly* f=reinterpret_cast <int_poly*>(a); |
---|
173 | f->poly_print(); |
---|
174 | return ; |
---|
175 | } |
---|
176 | |
---|
177 | |
---|
178 | const char * nAERead (const char *s, number *a,const coeffs r) |
---|
179 | { |
---|
180 | char* c=new char; |
---|
181 | *c='c'; |
---|
182 | return c; |
---|
183 | } |
---|
184 | |
---|
185 | number nAENormalize (number a,number b,const coeffs r) // ? |
---|
186 | { |
---|
187 | return a; |
---|
188 | } |
---|
189 | |
---|
190 | BOOLEAN nAEGreater (number a, number b,const coeffs r) |
---|
191 | { |
---|
192 | int_poly* f=reinterpret_cast<int_poly*> (a); |
---|
193 | int_poly* g=reinterpret_cast<int_poly*> (b); |
---|
194 | if (f->deg > g->deg) {return FALSE;} |
---|
195 | else {return TRUE;} |
---|
196 | } |
---|
197 | |
---|
198 | BOOLEAN nAEEqual (number a, number b,const coeffs r) |
---|
199 | { |
---|
200 | int_poly* f=reinterpret_cast<int_poly*> (a); |
---|
201 | int_poly* g=reinterpret_cast<int_poly*> (b); |
---|
202 | if (f->is_equal(*g) == 1) {return FALSE;} |
---|
203 | else {return TRUE;} |
---|
204 | } |
---|
205 | |
---|
206 | BOOLEAN nAEIsZero (number a,const coeffs r) |
---|
207 | { |
---|
208 | int_poly* f=reinterpret_cast<int_poly*> (a); |
---|
209 | if (f->is_zero() == 1) {return FALSE;} |
---|
210 | else {return TRUE;} |
---|
211 | } |
---|
212 | |
---|
213 | BOOLEAN nAEIsOne (number a,const coeffs r) |
---|
214 | { |
---|
215 | int_poly* f=reinterpret_cast<int_poly*> (a); |
---|
216 | if (f->is_one() == 1) {return FALSE;} |
---|
217 | else {return TRUE;} |
---|
218 | } |
---|
219 | |
---|
220 | BOOLEAN nAEIsMOne (number a,const coeffs r) |
---|
221 | { |
---|
222 | int_poly* f=reinterpret_cast<int_poly*> (a); |
---|
223 | if (f->is_one() == 1) {return FALSE;} |
---|
224 | else {return TRUE;} |
---|
225 | } |
---|
226 | |
---|
227 | BOOLEAN nAEGreaterZero (number a, const coeffs r) |
---|
228 | { |
---|
229 | if (nAEIsZero(a,r) == FALSE) { return TRUE; } |
---|
230 | else { return FALSE; } |
---|
231 | } |
---|
232 | |
---|
233 | void nAEPower (number a, int i, number * result,const coeffs r) |
---|
234 | { |
---|
235 | return; |
---|
236 | } |
---|
237 | |
---|
238 | number nAEGetDenom (number &a, const coeffs r) |
---|
239 | { |
---|
240 | return (number) 1; |
---|
241 | } |
---|
242 | |
---|
243 | number nAEGetNumerator (number &a, const coeffs r) |
---|
244 | { |
---|
245 | return a; |
---|
246 | } |
---|
247 | |
---|
248 | number nAEGcd (number a,number b,const coeffs r) |
---|
249 | { |
---|
250 | int_poly* f=reinterpret_cast<int_poly*> (a); |
---|
251 | int_poly* g=reinterpret_cast<int_poly*> (b); |
---|
252 | int_poly *res=new int_poly; |
---|
253 | res->poly_gcd(*f,*g); |
---|
254 | return (number) res; |
---|
255 | } |
---|
256 | |
---|
257 | number nAELcm (number a,number b,const coeffs r) |
---|
258 | { |
---|
259 | int_poly* f=reinterpret_cast<int_poly*> (a); |
---|
260 | int_poly* g=reinterpret_cast<int_poly*> (b); |
---|
261 | int_poly *gcd=new int_poly; |
---|
262 | int_poly *res=new int_poly; |
---|
263 | gcd->poly_gcd(*f,*g); |
---|
264 | res->poly_mult_n(*f,*g); |
---|
265 | res->poly_div_to(*res,*f,*gcd); |
---|
266 | return (number) res; |
---|
267 | } |
---|
268 | |
---|
269 | void nAEDelete (number *a, const coeffs r) |
---|
270 | { |
---|
271 | return; |
---|
272 | } |
---|
273 | |
---|
274 | /* |
---|
275 | number nAESetMap (number a, const coeffs r) |
---|
276 | { |
---|
277 | return a; |
---|
278 | } |
---|
279 | */ |
---|
280 | char* nAEName (number a, const coeffs r) |
---|
281 | { char *c=new char; |
---|
282 | *c='c'; |
---|
283 | return c; |
---|
284 | } |
---|
285 | |
---|
286 | void nAEInpMult (number &a, number b,const coeffs r) |
---|
287 | { |
---|
288 | return ; |
---|
289 | } |
---|
290 | |
---|
291 | void nAECoeffWrite (const coeffs r, BOOLEAN details) |
---|
292 | { |
---|
293 | return; |
---|
294 | } |
---|
295 | |
---|
296 | BOOLEAN nAEClearContent (number a,const coeffs r) |
---|
297 | { |
---|
298 | return FALSE; |
---|
299 | } |
---|
300 | |
---|
301 | BOOLEAN nAEClearDenominators (number a,const coeffs r) |
---|
302 | { |
---|
303 | return FALSE; |
---|
304 | } |
---|
305 | |
---|
306 | |
---|
307 | |
---|
308 | //INITIALISIERUNG FÃR SINGULAR |
---|
309 | |
---|
310 | |
---|
311 | BOOLEAN n_AEInitChar(coeffs r,void * p) // vlt noch void* p hin |
---|
312 | { |
---|
313 | |
---|
314 | r->ch = 0; |
---|
315 | r->cfKillChar=NULL; |
---|
316 | r->nCoeffIsEqual=ndCoeffIsEqual; |
---|
317 | r->cfMult = nAEMult; |
---|
318 | r->cfSub = nAESub; |
---|
319 | r->cfAdd = nAEAdd; |
---|
320 | r->cfDiv = nAEDiv; |
---|
321 | r->cfIntDiv= nAEIntDiv; |
---|
322 | r->cfIntMod= nAEIntMod; |
---|
323 | r->cfExactDiv= nAEExactDiv; |
---|
324 | r->cfInit = nAEInit; |
---|
325 | r->cfSize = nAESize; |
---|
326 | r->cfInt = nAEInt; |
---|
327 | #ifdef HAVE_RINGS |
---|
328 | //r->cfDivComp = NULL; // only for ring stuff |
---|
329 | //r->cfIsUnit = NULL; // only for ring stuff |
---|
330 | //r->cfGetUnit = NULL; // only for ring stuff |
---|
331 | //r->cfExtGcd = NULL; // only for ring stuff |
---|
332 | // r->cfDivBy = NULL; // only for ring stuff |
---|
333 | #endif |
---|
334 | r->cfNeg = nAENeg; |
---|
335 | r->cfInvers= NULL; |
---|
336 | //r->cfCopy = ndCopy; |
---|
337 | //r->cfRePart = ndCopy; |
---|
338 | //r->cfImPart = ndReturn0; |
---|
339 | r->cfWriteLong = nAEWriteLong; |
---|
340 | r->cfRead = nAERead; |
---|
341 | //r->cfNormalize=ndNormalize; |
---|
342 | r->cfGreater = nAEGreater; |
---|
343 | r->cfEqual = nAEEqual; |
---|
344 | r->cfIsZero = nAEIsZero; |
---|
345 | r->cfIsOne = nAEIsOne; |
---|
346 | r->cfIsMOne = nAEIsOne; |
---|
347 | r->cfGreaterZero = nAEGreaterZero; |
---|
348 | r->cfPower = nAEPower; // ZU BEARBEITEN |
---|
349 | r->cfGetDenom = nAEGetDenom; |
---|
350 | r->cfGetNumerator = nAEGetNumerator; |
---|
351 | r->cfGcd = nAEGcd; |
---|
352 | r->cfLcm = nAELcm; // ZU BEARBEITEN |
---|
353 | r->cfDelete= nAEDelete; |
---|
354 | r->cfSetMap = npSetMap; |
---|
355 | r->cfName = nAEName; |
---|
356 | r->cfInpMult=nAEInpMult; //???? |
---|
357 | r->cfInit_bigint= NULL; // nAEMap0; |
---|
358 | r->cfCoeffWrite=nAECoeffWrite; //???? |
---|
359 | |
---|
360 | |
---|
361 | // the variables: |
---|
362 | r->nNULL = (number) 0; |
---|
363 | //r->type = n_AE; |
---|
364 | r->ch = 0; |
---|
365 | r->has_simple_Alloc=TRUE; |
---|
366 | r->has_simple_Inverse=TRUE; |
---|
367 | return FALSE; |
---|
368 | } |
---|
369 | |
---|