source: git/libpolys/coeffs/OPAEp.cc @ ba5e9e

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