source: git/Singular/polys.h @ 5480da

spielwiese
Last change on this file since 5480da was f003a9, checked in by Olaf Bachmann <obachman@…>, 26 years ago
* polys-impl.cc, polys.cc: No COMP_FAST any more * Makefile.in: Introduced variable PERL, set by configure * kstdfac.cc (kStratCopy): kModW iv is not copied, but just the pointer is set 1998-03-18 Olaf Bachmann <obachman@mathematik.uni-kl.de> * Makefile.in: added Singularb target for bprof * polys-impl.h, polys-comp.h: Cleaned up COMP_FAST and related #defines 1998-03-16 Olaf Bachmann <obachman@mathematik.uni-kl.de> * polys-impl.h: no #define COMP_FAST * configure.in,Makefile.in: check for flex -P; increased version number to 1.1.7 git-svn-id: file:///usr/local/Singular/svn/trunk@1268 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 10.9 KB
Line 
1#ifndef POLYS_H
2#define POLYS_H
3/****************************************
4*  Computer Algebra System SINGULAR     *
5****************************************/
6/* $Id: polys.h,v 1.11 1998-03-23 22:51:05 obachman Exp $ */
7/*
8* ABSTRACT - all basic methods to manipulate polynomials
9*/
10#include "polys-impl.h"
11
12typedef poly*   polyset;
13extern int      pVariables;
14extern int      pOrdSgn;
15extern BOOLEAN  pLexOrder;
16extern BOOLEAN  pMixedOrder;
17extern poly     ppNoether;
18extern BOOLEAN  pVectorOut;
19// 1 for lex ordering (except ls), -1 otherwise
20extern int pLexSgn;
21extern int pComponentOrder;
22
23#ifdef DRING
24// D=k[x,d,y] is the Weyl-Algebra [y], y commuting with all others
25// M=k[x,x^(-1),y] is a D-module
26// all x(1..n),d,x(1..n)^(-1),y(1..k) are considered as "ring variables" v(1..N)
27// the map from x(i) to v:
28#define pdX(i)  (i)
29// d(i)
30#define pdDX(i) (pdN+i)
31// x(i)^(-1)
32#define pdIX(i) (pdN+i)
33// y(i)
34#define pdY(i)  (pdN*2+i+1)
35// a monomial m belongs to a D-module M iff pdDFlag(m)==0
36// a monomial m belongs to an ideal in the Weyl-Algebra D iff pdDFlag(m)==1
37#define pdDFlag(m) pGetExp(m,pdN*2+1)
38
39extern int      pdN;
40extern int      pdK;
41extern BOOLEAN  pDRING;
42poly   pdSpolyCreate(poly a, poly b);
43void   pdLcm(poly a, poly b, poly m);
44BOOLEAN pdIsConstantComp(poly p);
45void   spModuleToPoly(poly a1);
46void   pdSetDFlag(poly p,int i);
47#endif
48#ifdef SRING
49extern int      pAltVars;
50extern BOOLEAN  pSRING;
51#endif
52#ifdef SDRING
53void   psAug(poly q, poly done, polyset *s, int *l, int *m);
54void   pdAug(poly q, polyset *s, int *l, int *m);
55#endif
56#ifdef SDRING
57extern BOOLEAN pSDRING;
58#endif
59
60/* function prototypes */
61
62/* ---------------- General poly access and iteration macros -----------*/
63// IMPORTANT: Do _NOT_ make _ANY_ assumptions about their actual implementation
64
65#define pNext(p)            _pNext(p)
66#define pIter(p)            _pIter(p)
67
68#define pGetCoeff(p)        _pGetCoeff(p)
69// deletes old coeff before setting the new
70#define pSetCoeff(p,n)      _pSetCoeff(p,n)
71// sets new coeff without deleting the old one
72#define pSetCoeff0(p,n)     _pSetCoeff0(p,n)
73
74#define pGetOrder(p)        _pGetOrder(p)
75
76// Gets/Sets Component field w.r.t. of polys of global ring
77#define pSetComp(p,k)       _pSetComp(p,k)   
78#define pGetComp(p)         _pGetComp(p)
79#define pIncrComp(p)        _pIncrComp(p)
80#define pDecrComp(p)        _pDecrComp(p)
81#define pAddComp(p,v)       _pAddComp(p,v)
82#define pSubComp(p,v)       _pSubComp(p,v)
83
84// Gets/Sets Component field w.r.t. of polys of ring r
85#define pRingSetComp(r,p,k)       _pRingSetComp(r,p,k)   
86#define pRingGetComp(r,p)         _pRingGetComp(r,p)
87
88// Gets/Sets ith exponent poly of global ring
89#define pGetExp(p,i)        _pGetExp(p,i)
90#define pSetExp(p,i,v)      _pSetExp(p,i,v)
91
92// Gets/Sets ith exponent of poly of ring r
93#define pRingGetExp(r,p,i)        _pRingGetExp(r,p,i)
94#define pRingSetExp(r,p,i,v)      _pRingSetExp(r,p,i,v)
95
96// Increments/decrements ith exponent by one
97#define pIncrExp(p,i)       _pIncrExp(p,i)   
98#define pDecrExp(p,i)       _pDecrExp(p,i)   
99
100// Gets Difference and sum of ith Exponent of m1, m2
101#define pGetExpSum(m1, m2, i)  _pGetExpSum(p1, p2, i)
102#define pGetExpDiff(p1, p2, i) _pGetExpDiff(p1, p2, i)
103
104// Adds/Substracts v to/from the ith Exponent
105#define pAddExp(p,i,v)      _pAddExp(p,i,v) 
106#define pSubExp(p,i,v)      _pSubExp(p,i,v) 
107#define pMultExp(p,i,v)     _pMultExp(p,i,v)
108
109// Gets a copy of (resp. sets) the exponent vector, where e is assumed
110// to point to (pVariables+1)*sizeof(Exponent_t) memory. Exponents are
111// filled in as follows: comp, e_1, .., e_n
112#define pGetExpV(p, e)      _pGetExpV(p, e)
113#define pSetExpV(p, e)      _pSetExpV(p, e)
114
115
116/*-------------predicate on polys ----------------------*/
117BOOLEAN   pIsConstant(poly p);
118BOOLEAN   pIsConstantComp(poly p);
119int       pIsPurePower(poly p);
120#define   pIsVector(p)     (pGetComp(p)!=0)
121BOOLEAN   pHasNotCF(poly p1, poly p2);   /*has no common factor ?*/
122void      pSplit(poly p, poly * r);   /*p => IN(p), r => REST(p) */
123
124
125/*-------------ring management:----------------------*/
126extern void   pChangeRing(int N, int OrdSgn,
127                         int* ord, int* block0, int* block1,
128                         short** wv);
129extern void pSetGlobals(ring r, BOOLEAN complete = TRUE);
130
131/*-----------the ordering of monomials:-------------*/
132extern pSetmProc pSetm;
133extern pCompProc pComp0;
134// this is needed here as long as monomials with negative exponents might be
135// compared (see in spolys.cc)
136extern pCompProc t_pComp0;
137int    pComp(poly p1,poly p2);
138extern pLDegProc pLDeg;
139extern pFDegProc pFDeg;
140int pDeg(poly p);
141int pTotaldegree(poly p);
142int pWTotaldegree(poly p);
143
144/*-------------pComp for syzygies:-------------------*/
145
146void pSetModDeg(intvec *w);
147void pSetSchreyerOrdB(polyset nextorder, int length);
148void pSetSchreyerOrdM(polyset nextorder, int length, int comps);
149int  pModuleOrder();
150
151/*-------------storage management:-------------------*/
152// allocates the space for a new monomial
153#define pNew()      _pNew()
154// allocates a new monomial and initializes everything to 0
155#define pInit()     _pInit()
156
157// frees the space of the monomial m
158#define pFree1(m)       _pFree1(m)
159// frees the space of monoial and frees coefficient
160#define pDelete1(m)     _pDelete1(m)
161// deletes the whole polynomial p
162#define pDelete(p)      _pDelete(p)
163
164// makes a simple memcopy of m2 into m1 -- does _not_ allocate memory for m1
165#define pCopy2(m1, m2)  _pCopy2(m1, m2)
166// Returns a newly allocated copy of the monomial m, initializes coefficient
167// and sets the next-fieled to NULL
168#define pCopy1(m)       _pCopy1(m)
169// Returns a newly allocated copy of the monomial m, sets the coefficient to 0,
170// and sets the next-fieled to NULL
171#define pHead0(p)       _pHead0(p)
172// Returns a newly allocated copy of the monomial m, copy includes copy of ceoff
173// and sets the next-fieled to NULL
174#define pHead(p)        _pHead(p)
175extern  poly pHeadProc(poly p);
176// Returns copy of the whole polynomial
177#define pCopy(p)        _pCopy(p)
178// Returns a converted copy (in the sense that returned poly is in
179// poly of currRing) of poly p which is from ring r -- assumes that
180// currRing and r have the same number of variables, i.e. that polys
181// from r can be "fetched" into currRing
182#define pFetchCopy(r,p)     _pFetchCopy(r,p)
183
184
185// Adds exponents of p2 to exponents of p1; updates Order field
186// assumes that exponents > 0 and < MAX_EXPONENT / 2
187#define pMonAddFast(p1, p2) _pMonAddFast(p1, p2)
188// Is equivalent to pCopy2(p1, p2);pMonAddFast(p1, p3);
189#define pCopyAddFast(p1, p2, p3)    _pCopyAddFast(p1, p2, p3)
190// Similar to pCopyAddFast, except that we do not care about the next field
191#define pCopyAddFast0(p1, p2, p3)  _pCopyAddFast0(p1, p2, p3)
192// Similar to pCopyAddFast0, except that we do not recompute the Order,
193// but assume that it is the sum of the Order of p2 and p3
194#define pCopyAddFastHomog(p1, p2, p3, Order)  \
195  _pCopyAddFastHomog(p1, p2, p3, Order)
196
197poly      pmInit(char *s, BOOLEAN &ok);   /* monom -> poly */
198void      ppDelete(poly * a, ring r);
199
200/*-------------operations on polynomials:------------*/
201poly      pAdd(poly p1, poly p2);
202poly      pNeg(poly p);
203poly      pSub(poly a, poly b);
204poly      pMult(poly a, poly b);
205void      pMultN(poly a, number c);
206poly      pMultCopyN(poly a, number c);
207poly      pPower(poly p, int i);
208
209// return TRUE, if exponent and component of p1 and p2 are equal,
210// FALSE otherwise
211#define pEqual(p1, p2) _pEqual(p1, p2)
212
213// returns TRUE, if leading monom of a divides leading monom of b
214// i.e., if there exists a expvector c > 0, s.t. b = a + c
215#if defined(macintosh)
216BOOLEAN   pDivisibleBy(poly a, poly b);
217#else
218#define pDivisibleBy(a, b)  _pDivisibleBy(a,b)
219#endif
220// like pDivisibleBy, except that it is assumed that a!=NULL
221#define pDivisibleBy1(a,b)   _pDivisibleBy1(a,b)
222// like pDivisibleBy, assumes a != NULL, does not check components
223#define pDivisibleBy2(a, b) _pDivisibleBy2(a,b)
224
225
226poly      pDivide(poly a, poly b);
227poly      pDivideM(poly a, poly b);
228void      pLcm(poly a, poly b, poly m);
229poly      pDiff(poly a, int k);
230poly      pDiffOp(poly a, poly b,BOOLEAN multiply);
231
232int       pLength(poly a);
233int       pMaxComp(poly p);
234int       pMinComp(poly p);
235int       pWeight(int c);
236void      pSetCompP(poly a, int i);
237
238// Quer sum (total degree) of all exponents of leading monomial
239#define pExpQuerSum(p1)             _pExpQuerSum(p1)
240// sum from 1st to "to"th exponent (including the "to" one)
241#define pExpQuerSum1(p1, to)        _pExpQuerSum1(p1, to)
242// sum from "from"th to "to"th exponent (including borders)
243#define pExpQuerSum2(p1, from, to)  _pExpQuerSum2(p1, from, to)
244
245char*     pString(poly p);
246char*     pString0(poly p);
247void      pWrite(poly p);
248void      pWrite0(poly p);
249void      wrp(poly p);
250
251void      pEnlargeSet(polyset *p, int length, int increment);
252poly      pISet(int i);
253#define   pOne()   pISet(1)
254
255void      pContent(poly p);
256void      pCleardenom(poly p);
257
258// homogenizes p by multiplying certain powers of the varnum-th variable
259poly      pHomogen (poly p, int varnum);
260 
261// replaces the maximal powers of the leading monomial of p2 in p1 by
262// the same powers of n, utility for dehomogenization
263poly      pDehomogen (poly p1,poly p2,number n);
264BOOLEAN   pIsHomogeneous (poly p);
265
266// returns the leading monomial of p1 divided by the maximal power of
267// that of p2
268poly      pDivByMonom (poly p1,poly p2);
269
270// Returns as i-th entry of P the coefficient of the (i-1) power of
271// the leading monomial of p2 in p1
272void      pCancelPolyByMonom (poly p1,poly p2,polyset * P,int * SizeOfSet);
273
274// orders monoms of poly using insertion sort, performs pSetm on each
275// monom (i.e. sets Order field)
276poly      pOrdPolyInsertSetm(poly p);
277
278// orders monoms of poly using merge sort (ususally faster than
279// insertion sort). ASSUMES that pSetm was performed on monoms
280// (i.e. that Order field is set correctly)
281poly      pOrdPolyMerge(poly p);
282
283poly      pPermPoly (poly p, int * perm, ring OldRing,
284                     int *par_perm=NULL, int OldPar=0);
285void      pSetSyzComp(int k);
286
287/*BOOLEAN   pVectorHasUnitM(poly p, int * k);*/
288BOOLEAN   pVectorHasUnitB(poly p, int * k);
289void      pVectorHasUnit(poly p, int * k, int * len);
290poly      pTakeOutComp(poly * p, int k);
291poly      pTakeOutComp1(poly * p, int k);
292void      pDeleteComp(poly * p,int k);
293void      pNorm(poly p);
294void      pNormalize(poly p);
295poly      pSubst(poly p, int n, poly e);
296poly      pJet(poly p, int m);
297poly      pJetW(poly p, int m, short * iv);
298int       pDegW(poly p, short *w);
299
300/*-----------type conversions ----------------------------*/
301poly  pPolys2Vec(polyset p, int len);
302void  pVec2Polys(poly v, polyset *p, int *len);
303int   pVar(poly m);
304
305/*-----------specials for spoly-computations--------------*/
306poly    pMultT(poly a, poly e);
307int     pDivComp(poly p, poly q);
308BOOLEAN pCompareChain (poly p,poly p1,poly p2,poly lcm);
309BOOLEAN pEqualPolys(poly p1,poly p2);
310BOOLEAN pComparePolys(poly p1,poly p2);
311
312
313#ifdef PDEBUG
314#define pTest(A) pDBTest(A,__FILE__,__LINE__)
315BOOLEAN pDBTest(poly p, char *f, int l);
316#else
317#define pTest(A)
318#define pDBTest(A,B,C)
319#endif
320#endif
321
322
Note: See TracBrowser for help on using the repository browser.