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