source: git/Singular/polys.h @ 400884

spielwiese
Last change on this file since 400884 was 6a6dccc, checked in by Hans Schönemann <hannes@…>, 27 years ago
* hannes: cleanup in some texts polys.h polys0.cc modification to dld code iparith.cc ipassign.cc ipid.cc ipshell.h sing_dld.cc tesths.cc sing_dld.h git-svn-id: file:///usr/local/Singular/svn/trunk@483 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 8.4 KB
Line 
1#ifndef POLYS_H
2#define POLYS_H
3/****************************************
4*  Computer Algebra System SINGULAR     *
5****************************************/
6/* $Id: polys.h,v 1.4 1997-07-02 16:44:12 Singular Exp $ */
7/*
8* ABSTRACT - all basic methods to manipulate polynomials
9*/
10#include "structs.h"
11
12#define VARS (100)   /*max. number of variables as constant*/
13
14typedef short bmonomial;
15typedef bmonomial monomial[VARS+1];
16typedef bmonomial * pmonomial;
17
18struct  spolyrec
19{
20  poly     next;
21#define pNext(p) ((p)->next)
22#define pIter(p) ((p) = (p)->next)
23  number   coef;
24//number  pGetCoeff(poly p);
25#define   pGetCoeff(p)     ((p)->coef)
26//void    pSetCoeff(poly p, number n);
27#define   pSetCoeff(p,n)   {nDelete(&((p)->coef));(p)->coef=n;}
28//void    pSetCoeff0(poly p, number n);
29#define   pSetCoeff0(p,n)  (p)->coef=n
30  int      Order;
31#define   pGetOrder(p)     ((p)->Order)
32#define POLYSIZE (sizeof(poly) + sizeof(number) + sizeof(int))
33  monomial exp;
34};
35typedef poly*   polyset;
36
37extern int      pVariables;
38extern int      pOrdSgn;
39extern BOOLEAN  pLexOrder;
40extern BOOLEAN  pMixedOrder;
41extern poly     ppNoether;
42extern BOOLEAN  pVectorOut;
43
44#ifdef DRING
45// D=k[x,d,y] is the Weyl-Algebra [y], y commuting with all others
46// M=k[x,x^(-1),y] is a D-module
47// all x(1..n),d,x(1..n)^(-1),y(1..k) are considered as "ring variables" v(1..N)
48// the map from x(i) to v:
49#define pdX(i)  (i)
50// d(i)
51#define pdDX(i) (pdN+i)
52// x(i)^(-1)
53#define pdIX(i) (pdN+i)
54// y(i)
55#define pdY(i)  (pdN*2+i+1)
56// a monomial m belongs to a D-module M iff pdDFlag(m)==0
57// a monomial m belongs to an ideal in the Weyl-Algebra D iff pdDFlag(m)==1
58#define pdDFlag(m) ((m)->exp[pdN*2+1])
59
60extern int      pdN;
61extern int      pdK;
62extern BOOLEAN  pDRING;
63poly   pdSpolyCreate(poly a, poly b);
64void   pdLcm(poly a, poly b, poly m);
65BOOLEAN pdIsConstantComp(poly p);
66void   spModuleToPoly(poly a1);
67void   pdSetDFlag(poly p,int i);
68#endif
69#ifdef SRING
70extern int      pAltVars;
71extern BOOLEAN  pSRING;
72#endif
73#ifdef SDRING
74void   psAug(poly q, poly done, polyset *s, int *l, int *m);
75void   pdAug(poly q, polyset *s, int *l, int *m);
76#endif
77#ifdef SDRING
78extern BOOLEAN pSDRING;
79#endif
80
81/* function prototypes */
82/*-------- several acces procedures to monomials ---- */
83//void    pGetExpV(poly p, short * exp);
84#define   pGetExpV(p,e)    memcpy((e),(p)->exp,(pVariables+1)*sizeof(short));
85//void    pSetExpV(poly p, short * exp);
86#define pSetExpV(p,e) {memcpy((p)->exp,(e),(pVariables+1)*sizeof(short));pSetm(p);}
87//void    pSetExp(poly p, int varnum, int exp);
88#define   pSetExp(p,v,e)   (p)->exp[(v)]=(e)
89//int     pGetExp(poly p, int varnum);
90#define   pGetExp(p,v)     ((p)->exp[(v)])
91//void    pSetComp(poly p, int k);
92#define   pSetComp(p,k)    pSetExp(p,0,k)
93//int     pGetComp(poly p);
94#define   pGetComp(p)      pGetExp(p,0)
95BOOLEAN   pIsConstant(poly p);
96BOOLEAN   pIsConstantComp(poly p);
97int       pIsPurePower(poly p);
98//BOOLEAN pIsVector(poly p);
99#define   pIsVector(p)     (pGetComp(p)!=0)
100BOOLEAN   pHasNotCF(poly p1, poly p2);   /*has no common factor ?*/
101void      pSplit(poly p, poly * r);   /*p => IN(p), r => REST(p) */
102//void    pCat(poly p, poly r);
103#define   pCat(p,r)        ((p)->next=(r))
104
105/*-------------ring management:----------------------*/
106extern void   pChangeRing(int N, int OrdSgn,
107                         int* ord, int* block0, int* block1,
108                         short** wv);
109
110/*-----------the ordering of monomials:-------------*/
111extern pSetmProc pSetm;
112extern pCompProc pComp0;
113int    pComp(poly p1,poly p2);
114extern pLDegProc pLDeg;
115extern pFDegProc pFDeg;
116int pDeg(poly p);
117int pTotaldegree(poly p);
118int pWTotaldegree(poly p);
119
120/*-------------pComp for syzygies:-------------------*/
121
122void pSetModDeg(intvec *w);
123void pSetSchreyerOrdB(polyset nextorder, int length);
124void pSetSchreyerOrdM(polyset nextorder, int length, int comps);
125int  pModuleOrder();
126
127/*-------------storage management:-------------------*/
128#ifdef MDEBUG
129poly pDBNew(char *f, int l);
130#define pNew() pDBNew(__FILE__,__LINE__)
131poly pDBInit(char * f,int l);
132#define pInit() pDBInit(__FILE__,__LINE__)
133#else
134//poly    pNew(void);
135#define   pNew() (poly)mmAllocSpecialized()
136poly      pInit(void);
137#endif
138
139poly      pmInit(char *s, BOOLEAN &ok);   /* monom -> poly */
140poly      pOne(void);
141#ifdef MDEBUG
142poly      pDBCopy(poly a, char *f, int l);
143#define   pCopy(A) pDBCopy(A,__FILE__,__LINE__)
144#else
145poly      pCopy(poly a);
146#endif
147
148void      ppDelete(poly * a, ring r);
149#ifdef MDEBUG
150#define   pDelete(a)             pDBDelete((a),__FILE__,__LINE__)
151void      pDBDelete(poly * a, char * f, int l);
152#define   pDelete1(a)            pDBDelete1((a),__FILE__,__LINE__)
153void      pDBDelete1(poly * a, char * f, int l);
154#define   pFree1(a)              {pDBFree1((a),__FILE__,__LINE__);(a)=NULL;}
155void      pDBFree1(poly a, char * f, int l);
156#else
157void      pDelete(poly * a);
158void      pDelete1(poly * a);
159#define   pFree1(a)               mmFreeSpecialized((ADDRESS)a)
160#endif
161
162/*-------------operations on polynomials:------------*/
163poly      pAdd(poly p1, poly p2);
164poly      pNeg(poly p);
165poly      pSub(poly a, poly b);
166poly      pMult(poly a, poly b);
167void      pMultN(poly a, number c);
168poly      pMultCopyN(poly a, number c);
169poly      pPower(poly p, int i);
170
171BOOLEAN   pEqual(poly a, poly b);
172
173#ifdef macintosh
174BOOLEAN   pDivisibleBy(poly a, poly b);
175#else
176inline BOOLEAN pDivisibleBy(poly a, poly b)
177{
178  if ((a!=NULL)&&((a->exp[0]==0) || (a->exp[0] == b->exp[0])))
179  {
180    int i=pVariables;
181    short *e1=&(a->exp[1]);
182    short *e2=&(b->exp[1]);
183    if ((*e1) > (*e2)) return FALSE;
184    do
185    {
186      i--;
187      if (i == 0) return TRUE;
188      e1++;
189      e2++;
190    } while ((*e1) <= (*e2));
191  }
192  return FALSE;
193}
194#endif
195
196poly      pDivide(poly a, poly b);
197poly      pDivideM(poly a, poly b);
198void      pLcm(poly a, poly b, poly m);
199poly      pDiff(poly a, int k);
200poly      pDiffOp(poly a, poly b,BOOLEAN multiply);
201
202int       pLength(poly a);
203#ifdef MDEBUG
204poly pDBHead(poly p,char *f, int l);
205#define pHead(A) pDBHead(A,__FILE__,__LINE__)
206poly pDBHead0(poly p,char *f, int l);
207#define pHead0(A) pDBHead0(A,__FILE__,__LINE__)
208#else
209poly pHead(poly p);
210poly pHead0(poly p);
211#endif
212int       pMaxComp(poly p);
213int       pMinComp(poly p);
214int       pWeight(int c);
215void      pSetCompP(poly a, int i);
216
217char*     pString(poly p);
218char*     pString0(poly p);
219void      pWrite(poly p);
220void      pWrite0(poly p);
221void      wrp(poly p);
222
223void      pEnlargeSet(polyset *p, int length, int increment);
224poly      pISet(int i);
225
226void      pContent(poly p);
227void      pCleardenom(poly p);
228
229poly      pHomogen (poly p, int varnum);
230  /*- homogenizes p by multiplying certain powers of the varnum-th variable -*/
231poly      pDehomogen (poly p1,poly p2,number n);
232  /*replaces the maximal powers of the leading monomial of p2 in p1 by
233  * the same powers of n, utility for dehomogenization*/
234BOOLEAN   pIsHomogeneous (poly p);
235poly      pDivByMonom (poly p1,poly p2);
236  /*returns the leading monomial of p1 divided by the maximal power of that
237  *of p2*/
238void      pCancelPolyByMonom (poly p1,poly p2,polyset * P,int * SizeOfSet);
239  /*Returns as i-th entry of P the coefficient of the (i-1) power of
240  * the leading monomial of p2 in p1*/
241poly      pOrdPoly (poly p);
242poly      pPermPoly (poly p, int * perm, int OldPvariables,
243  int *par_perm=NULL, int OldPar=0);
244poly      pOrdPolySchreyer(poly p);
245  /*- re-orders a polynomial -*/
246void      pSetSyzComp(int k);
247
248/*BOOLEAN   pVectorHasUnitM(poly p, int * k);*/
249BOOLEAN   pVectorHasUnitB(poly p, int * k);
250void      pVectorHasUnit(poly p, int * k, int * len);
251poly      pTakeOutComp(poly * p, int k);
252poly      pTakeOutComp1(poly * p, int k);
253void      pDeleteComp(poly * p,int k);
254void      pNorm(poly p);
255void      pNormalize(poly p);
256poly      pSubst(poly p, int n, poly e);
257poly      pJet(poly p, int m);
258poly      pJetW(poly p, int m, short * iv);
259int       pDegW(poly p, short *w);
260
261/*-----------type conversions ----------------------------*/
262poly  pPolys2Vec(polyset p, int len);
263void  pVec2Polys(poly v, polyset *p, int *len);
264int   pVar(poly m);
265/*-----------specials for spoly-computations--------------*/
266extern int pMonomSize;
267
268poly    pMultT(poly a, poly e);
269poly    pCopy1(poly p); // copy of the head monomial: coeff is 0
270
271int     pDivComp(poly p, poly q);
272BOOLEAN pCompareChain (poly p,poly p1,poly p2,poly lcm);
273BOOLEAN pEqualPolys(poly p1,poly p2);
274BOOLEAN pComparePolys(poly p1,poly p2);
275
276
277#ifdef PDEBUG
278#define pTest(A) pDBTest(A,__FILE__,__LINE__)
279BOOLEAN pDBTest(poly p, char *f, int l);
280#else
281#define pTest(A)
282#define pDBTest(A,B,C)
283#endif
284#endif
285
Note: See TracBrowser for help on using the repository browser.