source: git/Singular/polys.h @ c5f63ab

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