source: git/Singular/polys.h @ ca7a56

spielwiese
Last change on this file since ca7a56 was ca7a56, checked in by Hans Schönemann <hannes@…>, 26 years ago
* hannes: * changes for TEST_MAC_ORDER, part 3 (binom.cc, binom.h, spSpolyLoop.cc, algmap.cc polys-impl.cc polys-impl.h polys.h syz.cc syz0.cc syz1.cc) git-svn-id: file:///usr/local/Singular/svn/trunk@1038 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.9 1998-01-17 18:08:00 Singular 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// Is equivalent to pCopy2(p1, p2);pMonAddFast(p1, p3);
189#define pCopyAddFast(p1, p2, p3)    _pCopyAddFast(p1, p2, p3)
190#define pbCopyAddFast(p1, p2, p3)   _pbCopyAddFast(p1, p2, p3)
191#define pbCopyAddFast0(p1, p2, p3)  _pbCopyAddFast0(p1, p2, p3)
192// Similar to pCopyAddFast, except that components of p2, and p3 must be 0
193#define pCopyAddFast1(p1, p2, p3)    _pCopyAddFast1(p1, p2, p3)
194
195poly      pmInit(char *s, BOOLEAN &ok);   /* monom -> poly */
196void      ppDelete(poly * a, ring r);
197
198/*-------------operations on polynomials:------------*/
199poly      pAdd(poly p1, poly p2);
200poly      pNeg(poly p);
201poly      pSub(poly a, poly b);
202poly      pMult(poly a, poly b);
203void      pMultN(poly a, number c);
204poly      pMultCopyN(poly a, number c);
205poly      pPower(poly p, int i);
206
207// return TRUE, if exponent and component of p1 and p2 are equal,
208// FALSE otherwise
209#define pEqual(p1, p2) _pEqual(p1, p2)
210
211// returns TRUE, if leading monom of a is dividble be leading monom of b
212#if defined(macintosh) || defined(DIV_COUNT)
213BOOLEAN   pDivisibleBy(poly a, poly b);
214#else
215#define pDivisibleBy(a, b)  _pDivisibleBy(a,b)
216#endif
217// like pDivisibleBy, except that it is assumed that a!=NULL
218#define pDivisibleBy1(a,b)   _pDivisibleBy1(a,b)
219// returns TRUE, if leading monom of a is dividble be leading monom of b
220// assumes a != NULL, b != NULL, and does not check components
221#define pDivisibleBy2(a, b) _pDivisibleBy2(a,b)
222
223
224poly      pDivide(poly a, poly b);
225poly      pDivideM(poly a, poly b);
226void      pLcm(poly a, poly b, poly m);
227poly      pDiff(poly a, int k);
228poly      pDiffOp(poly a, poly b,BOOLEAN multiply);
229
230int       pLength(poly a);
231int       pMaxComp(poly p);
232int       pMinComp(poly p);
233int       pWeight(int c);
234void      pSetCompP(poly a, int i);
235
236// Quer sum (total degree) of all exponents of leading monomial
237#define pExpQuerSum(p1)             _pExpQuerSum(p1)
238// sum from 1st to "to"th exponent (including the "to" one)
239#define pExpQuerSum1(p1, to)        _pExpQuerSum1(p1, to)
240// sum from "from"th to "to"th exponent (including borders)
241#define pExpQuerSum2(p1, from, to)  _pExpQuerSum2(p1, from, to)
242
243char*     pString(poly p);
244char*     pString0(poly p);
245void      pWrite(poly p);
246void      pWrite0(poly p);
247void      wrp(poly p);
248
249void      pEnlargeSet(polyset *p, int length, int increment);
250poly      pISet(int i);
251#define   pOne()   pISet(1)
252
253void      pContent(poly p);
254void      pCleardenom(poly p);
255
256// homogenizes p by multiplying certain powers of the varnum-th variable
257poly      pHomogen (poly p, int varnum);
258 
259// replaces the maximal powers of the leading monomial of p2 in p1 by
260// the same powers of n, utility for dehomogenization
261poly      pDehomogen (poly p1,poly p2,number n);
262BOOLEAN   pIsHomogeneous (poly p);
263
264// returns the leading monomial of p1 divided by the maximal power of
265// that of p2
266poly      pDivByMonom (poly p1,poly p2);
267
268// Returns as i-th entry of P the coefficient of the (i-1) power of
269// the leading monomial of p2 in p1
270void      pCancelPolyByMonom (poly p1,poly p2,polyset * P,int * SizeOfSet);
271
272// orders monoms of poly using insertion sort, performs pSetm on each
273// monom (i.e. sets Order field)
274poly      pOrdPolyInsertSetm(poly p);
275
276// orders monoms of poly using merge sort (ususally faster than
277// insertion sort). ASSUMES that pSetm was performed on monoms
278// (i.e. that Order field is set correctly)
279poly      pOrdPolyMerge(poly p);
280
281poly      pPermPoly (poly p, int * perm, ring OldRing,
282                     int *par_perm=NULL, int OldPar=0);
283void      pSetSyzComp(int k);
284
285/*BOOLEAN   pVectorHasUnitM(poly p, int * k);*/
286BOOLEAN   pVectorHasUnitB(poly p, int * k);
287void      pVectorHasUnit(poly p, int * k, int * len);
288poly      pTakeOutComp(poly * p, int k);
289poly      pTakeOutComp1(poly * p, int k);
290void      pDeleteComp(poly * p,int k);
291void      pNorm(poly p);
292void      pNormalize(poly p);
293poly      pSubst(poly p, int n, poly e);
294poly      pJet(poly p, int m);
295poly      pJetW(poly p, int m, short * iv);
296int       pDegW(poly p, short *w);
297
298/*-----------type conversions ----------------------------*/
299poly  pPolys2Vec(polyset p, int len);
300void  pVec2Polys(poly v, polyset *p, int *len);
301int   pVar(poly m);
302
303/*-----------specials for spoly-computations--------------*/
304poly    pMultT(poly a, poly e);
305int     pDivComp(poly p, poly q);
306BOOLEAN pCompareChain (poly p,poly p1,poly p2,poly lcm);
307BOOLEAN pEqualPolys(poly p1,poly p2);
308BOOLEAN pComparePolys(poly p1,poly p2);
309
310
311#ifdef PDEBUG
312#define pTest(A) pDBTest(A,__FILE__,__LINE__)
313BOOLEAN pDBTest(poly p, char *f, int l);
314#else
315#define pTest(A)
316#define pDBTest(A,B,C)
317#endif
318#endif
319
320
Note: See TracBrowser for help on using the repository browser.