source: sage/libs/singular/singular-cdefs.pxi @ 5645:2537226feb05

Revision 5645:2537226feb05, 9.6 KB checked in by 'Martin Albrecht <malb@…, 6 years ago (diff)

added libSINGULAR versions of std and slimgb Groebner basis computations
to get rid of conversion overhead for small GB calculations

Line 
1"""
2C level declarations of symbols in the SINGULAR libary.
3
4AUTHOR: Martin Albrecht <malb@informatik.uni-bremen.de>
5
6NOTE: our ring, poly etc. types are not the Singular ring, poly,
7etc. types. They are deferences. So a Singular ring is a ring* here.
8
9"""
10include "../../ext/cdefs.pxi"
11
12cdef extern from "stdsage.h":
13    ctypedef void PyObject
14   
15    # Global tuple -- useful optimization
16    void init_global_empty_tuple()
17    object PY_NEW(object t)
18    void* PY_TYPE(object o)
19    int PY_TYPE_CHECK(object o, object t)
20    object IS_INSTANCE(object o, object t)
21
22
23# Shared Library Loading,
24cdef extern from "dlfcn.h":
25    void *dlopen(char *, long)
26    char *dlerror()
27   
28cdef extern from "stdlib.h":
29    void *calloc(size_t nmemb, size_t size)
30    void free(void *ptr)
31    void delete "delete" (void *ptr)
32
33cdef extern from "libsingular.h":
34
35    # all possible ring orders per block
36    ctypedef struct number "snumber":
37        mpz_t z
38        mpz_t n
39        int s
40
41    ctypedef struct napoly "polyrec"
42
43    cdef enum tHomog:
44        isNotHomog
45        isHomog
46        testHomog
47
48    cdef enum rRingOrder_t:
49        ringorder_no
50        ringorder_a
51        ringorder_a64 # for int64 weights
52        ringorder_c
53        ringorder_C
54        ringorder_M
55        ringorder_S
56        ringorder_s
57        ringorder_lp
58        ringorder_dp
59        ringorder_rp
60        ringorder_Dp
61        ringorder_wp
62        ringorder_Wp
63        ringorder_ls
64        ringorder_ds
65        ringorder_Ds
66        ringorder_ws
67        ringorder_Ws
68        ringorder_L
69   
70    # This is the basis ring datatype of SINGULAR
71    # Please note: This is not the SINGULAR ring, it has one pointer
72    # layer less.
73
74    ctypedef struct ring "ip_sring":
75        int  *order  # array of orderings
76        int  *block0 # starting pos
77        int  *block1 # ending pos
78        int  **wvhdl
79        int  OrdSgn
80        int  ShortOut
81        int  CanShortOut
82        number *minpoly
83        char **names
84        char **parameter
85        ring *algring
86        short N
87        short P
88        int ch
89
90    # This is the basic polynomial datatype of SINGULAR
91
92    # Please note: This is not the SINGULAR poly, it has one pointer
93    # layer less.
94
95    ctypedef struct poly "polyrec":
96        poly *next
97
98    # This is the basic ideal/matrix datatype of SINGULAR
99
100    # Please note: This is not the SINGULAR ideal, it has one pointer
101    # layer less.
102
103    ctypedef struct ideal "ip_sideal":
104        poly **m
105        long rank
106        int nrows
107        int ncols
108
109    # comment from the SINGULAR code:
110   
111    #  'keiner (ausser obachman) darf das folgenden benutzen !!!'
112    #  in English: 'nobody (except obachman) may use the following!!!'
113    #
114    # I feel so obachman today.
115
116    ctypedef struct intvec:
117        int *(*ivGetVec)()
118        int (*rows)()
119        int (*cols)()
120
121    # oMalloc Bins
122    ctypedef struct omBin "omBin_s"
123
124
125    # SINGULAR Init
126    # ------------------------
127    void feInitResources(char *name)
128
129    void rChangeCurrRing(ring *r)
130    cdef ring *currRing
131    cdef omBin *rnumber_bin
132    cdef omBin *sip_sring_bin
133    cdef int (*pLDeg)(poly *p, int *l, ring *r)
134
135    int siInit(char *)
136
137    # OMalloc
138    void *omAlloc0(size_t size)
139    void *omAllocBin(omBin *bin)
140    void *omAlloc0Bin(omBin *bin)
141    char *omStrDup(char *)
142    void omFree(void *)
143
144
145    # rDefault accepts the characteristic, the number of variables,
146    # and an array of variable names.
147    ring *rDefault(int char, int nvars, char **names)
148   
149    void rDelete(ring *r) # Destructor
150    int rChar(ring *r) # Returns the characteristic of the ring
151    char* rRingVar(short i, ring *r) # Returns the name of the i-th variable of the ring r.
152
153    # if you change anything in the ring, like the term ordering
154    # this needs to be called
155    void rUnComplete(ring *r)
156
157    # this enables the changes done after rUnComplete
158    void rComplete(ring *r, int force)
159
160    ring *rCopy0(ring *)
161
162
163    ###
164   
165    ### Polynomials
166    ####
167
168    ### The rule of thumb is: p_XXX accepts a ring as parameter, while
169    ### pXXX doesn't. It relies on currRing.
170
171    ## Constructions / Destructors
172    ## -------------------------------
173
174    # new empty monomial
175    poly *p_Init(ring *r)
176
177    # const polynomial from int
178    poly *p_ISet(int i, ring *r)
179
180    # const polynomial from number (coefficient)
181    poly *p_NSet(number *n,ring *r)
182
183    # destructor
184    void p_Delete(poly **p, ring *r)
185
186    # set the coeff n for the current list element p in r
187    int p_SetCoeff(poly *p, number *n, ring *r)
188
189    # get the coeff of the current list element p in r
190    number *p_GetCoeff(poly *p, ring *r)
191
192    # sets the exponent e at index v for the list element (monomial) p in r
193    # v starts counting at 1
194    int p_SetExp(poly *p, int v, int e, ring *r)
195
196    # get the exponent at index v of the monomial p in r
197    int p_GetExp(poly *p, int v, ring *r)
198
199    # if SetExp is called on p, p_Setm needs to be called afterwards
200    # to finalize the change.
201    void p_Setm(poly *p, ring *r)
202   
203    # gets a component out of a polynomial vector
204    poly *pTakeOutComp1(poly **, int)
205
206    # copies p
207    poly *p_Copy(poly *p, ring *r)
208
209    # homogenizes p by multiplying certain powers of the varnum-th variable
210    poly *pHomogen (poly *p, int varnum)
211
212    # returns whether a polynomial is homogenous.
213    int pIsHomogeneous(poly *p)
214
215    char *p_String(poly *p, ring *r, ring *r)   
216
217    ## Arithmetic
218    ## -------------------------------
219
220    # returns -p, p is destroyed
221    poly *p_Neg(poly *p, ring *r)
222
223    # returns p*n, p is const (i.e. copied)
224    poly *pp_Mult_nn(poly *p, number *n, ring *r)
225
226    # returns p*m, does neither destroy p nor m
227    poly *pp_Mult_mm(poly *p, poly *m, ring *r)
228
229    # returns p+q, destroys p and q
230    poly *p_Add_q(poly *p, poly *q, ring *r)
231
232    # return p - m*q, destroys p; const: q,m
233    poly *p_Minus_mm_Mult_qq(poly *p, poly *m, poly *q, ring *r)
234
235    # returns p + m*q destroys p, const: q, m
236    poly *p_Plus_mm_Mult_qq(poly *p, poly *m, poly *q, ring *r)
237
238    # returns p*q, does neither destroy p nor q
239    poly *pp_Mult_qq(poly *p, poly *q, ring *r)
240   
241    # returns p*q, destroys p and q
242    poly *p_Mult_q(poly *p, poly *q, ring *r)
243
244    poly *pDivide(poly *,poly *)
245
246    # returns the i-th power of p; p will be destroyed, requires global ring
247    poly *pPower(poly *p, int exp)
248   
249    # returns newly allocated copy of Lm(p), coef is copied,
250    # next=NULL, p might be NULL
251    poly *p_Head(poly *p, ring *r)
252
253    # returns TRUE, if leading monom of a divides leading monom of b
254    # i.e., if there exists a expvector c > 0, s.t. b = a + c;
255    int p_DivisibleBy(poly *a, poly *b, ring *r)
256
257    # like pDivisibleBy, except that it is assumed that a!=NULL, b!=NULL
258    int p_LmDivisibleBy(poly *a, poly *b, ring *r)
259
260    # least common multiplies for MONOMIALS only, result is written to m
261    # p_Setm must be called on m afterwards.
262    void pLcm(poly *a, poly *b, poly *m)
263
264    # total degree of p
265    long pTotaldegree(poly *p, ring *r)
266
267    # iterates through the monomials of p
268    poly *pNext(poly *p)
269
270    int p_Cmp(poly *l, poly *r, ring *r)
271    int p_ExpVectorEqual(poly *p, poly *m, ring *r)
272
273    int p_IsConstant(poly *, ring *)
274    int p_LmIsConstant(poly *p, ring *)
275    int p_IsUnit(poly *, ring *)
276
277    poly *pSubst(poly *, int varidx, poly *value)
278
279    poly *pInvers(int n, poly *, intvec *)
280
281    # gcd of f and g
282    poly *singclap_gcd ( poly *f, poly *g )
283
284    # resultants of f and g in x
285    poly *singclap_resultant ( poly *f, poly *g , poly *x)
286
287    # extended GVD
288    int singclap_extgcd( poly *f, poly *g, poly *res, poly *pa, poly *pb )
289
290    # polynomial division (as opposed to monomial division)
291    poly *singclap_pdivide ( poly *f, poly *g )
292
293    # factorization
294    ideal *singclap_factorize ( poly *f, intvec ** v , int with_exps)
295
296    # is square free
297    int singclap_isSqrFree(poly *f)
298
299    # normal form calculation of p with respect to F, Q is quotient
300    # ring.
301    poly *kNF(ideal *F, ideal *Q, poly *p)
302
303    # General Numbers
304    poly *pDiff(poly *, int)
305
306    number *n_Init(int n, ring *r)
307    void n_Delete(number **n, ring *r)
308    int nInt(number *n)
309    number *n_Div(number *a, number *b, ring *r)
310    int n_GreaterZero(number *a, ring *r)
311    int n_IsZero(number *a, ring *r)
312
313    number *n_Sub(number *a, number *b, ring *r)
314    number *nInvers(number *n)
315
316    # Rational Numbers
317    number *nlInit(int)
318    number *nlInit2gmp(mpz_t i, mpz_t j)
319    number *nlInit2(int i, int j)
320    number *nlGetNom(number *n, ring *r)
321    number *nlGetDenom(number *n, ring *r)
322    number *nlRInit(int)
323
324
325    # Algebraic Numbers
326    number *naPar(int)
327    void naPower(number *, int, number **)
328    number *naMult(number *, number *)
329    number *naAdd(number *, number *)
330    number *naCopy(number *)
331    number *naInit(int)
332    void naDelete(number **, ring*)
333    int naIsZero(number *)
334    char * naRead(char *s, number *)
335    int naIsOne(number *)
336    int naIsZero(number *)
337
338    number *napGetCoeff(napoly *z)
339    int napGetExp(napoly *, int)
340    napoly *napIter(napoly *)
341
342    # Integer Numbers
343    cdef long SR_INT
344    long SR_TO_INT(number *)
345    long SR_HDL(mpz_t )
346
347
348    ctypedef struct napoly "polyrec"
349
350    ctypedef struct lnumber "slnumber":
351        napoly *z
352        napoly *n
353        int s
354
355
356    # Ideals
357    ideal *idInit(int size, int rank)
358    void id_Delete(ideal **, ring *)
359    ideal *fast_map(ideal *, ring *, ideal *, ring *)
360    ideal *idLift(ideal *mod, ideal *submod, ideal **rest, int goodShape, int isSB, int divide)
361    void idShow(ideal *i)
362    int IDELEMS(ideal *i)
363
364
365    void idSkipZeroes (ideal *ide)
366    long idRankFreeModule(ideal *m, ring *r)
367    ideal *kStd(ideal *i, ideal *q, tHomog h, intvec *w)
368    ideal *t_rep_gb(ring *r,ideal *arg_I, int syz_comp, int F4_mode)
Note: See TracBrowser for help on using the repository browser.