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