source: git/Singular/kutil.h @ b7b08c

fieker-DuValspielwiese
Last change on this file since b7b08c was b7b08c, checked in by Olaf Bachmann <obachman@…>, 25 years ago
* us short exponent vectors in divisbility tests * AllocSizeOf * garbage collection * scanner/gmp: allow .0 and 1. input of reals git-svn-id: file:///usr/local/Singular/svn/trunk@3711 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 8.7 KB
Line 
1#ifndef KUTIL_H
2#define KUTIL_H
3/****************************************
4*  Computer Algebra System SINGULAR     *
5****************************************/
6/* $Id: kutil.h,v 1.18 1999-10-14 14:27:14 obachman Exp $ */
7/*
8* ABSTRACT: kernel: utils for kStd
9*/
10#include <string.h>
11#include "mod2.h"
12#include "structs.h"
13#include "mmemory.h"
14#include "ring.h"
15#if HAVE_ASO == 1
16#include "kutil.aso"
17#endif
18
19#define setmax 16
20
21typedef int* intset;
22
23class sTObject
24{
25public:
26  poly  p;
27  int ecart,length, pLength;
28  memHeap heap;
29  unsigned long sev;
30  sTObject() { memset((void*) this, 0, sizeof(sTObject));}
31  inline poly SetP(poly p_new);
32};
33
34class sLObject
35{
36public:
37  poly  p;
38  poly  p1,p2; /*- the pair p comes from -*/
39  poly  lcm;   /*- the lcm of p1,p2 -*/
40  memHeap heap;
41  int ecart,length, pLength;
42  unsigned long sev;
43  sLObject() { memset((void*) this, 0, sizeof(sLObject));}
44};
45
46typedef class sTObject TObject;
47typedef class sLObject LObject;
48typedef TObject * TSet;
49typedef LObject * LSet;
50
51extern int HCord;
52
53class skStrategy;
54typedef skStrategy * kStrategy;
55class skStrategy
56{
57  public:
58    kStrategy next;
59    void (*red)(LObject * L,kStrategy strat);
60    void (*initEcart)(LObject * L);
61    int (*posInT)(const TSet T,const int tl,const LObject &h);
62    int (*posInL)(const LSet set, const int length,
63                  const LObject &L,const kStrategy strat);
64    void (*enterS)(LObject h, int pos,kStrategy strat);
65    void (*initEcartPair)(LObject * h, poly f, poly g, int ecartF, int ecartG);
66    int (*posInLOld)(const LSet Ls,const int Ll,
67                     const LObject &Lo,const kStrategy strat);
68    pFDegProc pOldFDeg;
69    ideal Shdl;
70    ideal D; /*V(S) is in D(D)*/
71    ideal M; /*set of minimal generators*/
72    polyset S;
73    intset ecartS;
74    intset fromQ;
75    unsigned long* sevS;
76    TSet T;
77    LSet L;
78    LSet    B;
79    poly    kHEdge;
80    poly    kNoether;
81    BOOLEAN * NotUsedAxis;
82    LObject P;
83    poly tail;
84    leftv kIdeal;
85    intvec * kModW;
86    intvec * kHomW;
87    BOOLEAN *pairtest;/*used for enterOnePair*/
88    int cp,c3;
89    int sl,mu;
90    int tl,tmax;
91    int Ll,Lmax;
92    int Bl,Bmax;
93    int ak,LazyDegree,LazyPass;
94    int syzComp;
95    int HCord;
96    int lastAxis;
97    int newIdeal;
98    int minim;
99    BOOLEAN interpt;
100    BOOLEAN homog;
101    BOOLEAN kHEdgeFound;
102    BOOLEAN honey,sugarCrit;
103    BOOLEAN Gebauer,noTailReduction;
104    BOOLEAN fromT;
105    BOOLEAN noetherSet;
106    BOOLEAN update;
107    BOOLEAN posInLOldFlag;
108           /*FALSE, if posInL == posInL10*/
109    char    redTailChange;
110    char    news;
111    char    newt;/*used for messageSets*/
112};
113
114void deleteHC(poly *p, int *e, int *l, kStrategy strat);
115void deleteInS (int i,kStrategy strat);
116void cleanT (kStrategy strat);
117LSet initL ();
118void deleteInL(LSet set, int *length, int j,kStrategy strat);
119void enterL (LSet *set,int *length, int *LSetmax, LObject p,int at);
120void initEcartPairBba (LObject* Lp,poly f,poly g,int ecartF,int ecartG);
121void initEcartPairMora (LObject* Lp,poly f,poly g,int ecartF,int ecartG);
122int posInS (polyset set,int length,poly p);
123int posInT0 (const TSet set,const int length,const LObject &p);
124int posInT1 (const TSet set,const int length,const LObject &p);
125int posInT2 (const TSet set,const int length,const LObject &p);
126int posInT11 (const TSet set,const int length,const LObject &p);
127int posInT13 (const TSet set,const int length,const LObject &p);
128int posInT15 (const TSet set,const int length,const LObject &p);
129int posInT17 (const TSet set,const int length,const LObject &p);
130int posInT19 (const TSet set,const int length,const LObject &p);
131void reorderS (int* suc,kStrategy strat);
132int posInL0 (const LSet set, const int length,
133             const LObject &L,const kStrategy strat);
134int posInL11 (const LSet set, const int length,
135             const LObject &L,const kStrategy strat);
136int posInL13 (const LSet set, const int length,
137             const LObject &L,const kStrategy strat);
138int posInL15 (const LSet set, const int length,
139             const LObject &L,const kStrategy strat);
140int posInL17 (const LSet set, const int length,
141             const LObject &L,const kStrategy strat);
142poly redtailBba (poly p,int pos,kStrategy strat);
143poly redtailSyz (poly p,int pos,kStrategy strat);
144poly redtail (poly p,int pos,kStrategy strat);
145void enterpairs (poly h, int k, int ec, int pos,kStrategy strat);
146void entersets (LObject h);
147void pairs ();
148void message (int i,int* reduc,int* olddeg,kStrategy strat);
149void messageStat (int srmax,int lrmax,int hilbcount,kStrategy strat);
150void messageSets (kStrategy strat);
151void initEcartNormal (LObject* h);
152void initEcartBBA (LObject* h);
153void initS (ideal F, ideal Q,kStrategy strat);
154void initSL (ideal F, ideal Q,kStrategy strat);
155void updateS(BOOLEAN toT,kStrategy strat);
156void enterSBba (LObject p, int pos,kStrategy strat);
157void enterT (LObject p,kStrategy strat);
158void enterTBba (LObject p, int pos,kStrategy strat);
159void cancelunit (LObject* p);
160void HEckeTest (poly pp,kStrategy strat);
161void redtailS (poly* h,int maxIndex);
162void redtailMora (poly* h,int maxIndex);
163void initBuchMoraCrit(kStrategy strat);
164void initHilbCrit(ideal F, ideal Q, intvec **hilb,kStrategy strat);
165void initBuchMoraPos(kStrategy strat);
166void initBuchMora (ideal F, ideal Q,kStrategy strat);
167void exitBuchMora (kStrategy strat);
168void updateResult(ideal r,ideal Q,kStrategy strat);
169void completeReduce (kStrategy strat);
170BOOLEAN homogTest(polyset F, int Fmax);
171BOOLEAN newHEdge(polyset S, int ak,kStrategy strat);
172
173inline TSet initT () { return (TSet)Alloc0(setmax*sizeof(TObject)); }
174
175#ifdef KDEBUG
176#define kTest(A) K_Test(__FILE__,__LINE__,A)
177#define kTest_TS(A) K_Test(__FILE__,__LINE__,A)
178#define kTest_T(T) K_Test_T(__FILE__,__LINE__,T)
179#define kTest_L(L) K_Test_L(__FILE__,__LINE__,L)
180#define kTest_S(strat) K_Test_S(__FILE__,__LINE__,strat)
181#define kTest_Pref(L) K_Test(__FILE__,__LINE__,L, 1)
182BOOLEAN K_Test(char *f, int l,kStrategy strat, int pref=0);
183BOOLEAN K_Test_TS(char *f, int l,kStrategy strat);
184BOOLEAN K_Test_T(char *f, int l, TObject* T, int tpos = -1);
185BOOLEAN K_Test_L(char* f, int l, LObject* L, 
186                 BOOLEAN testp = FALSE, int lpos = -1, 
187                 TSet T = NULL, int tlength = -1);
188BOOLEAN K_Test_S(char* f, int l, kStrategy strat);
189#else
190#define kTest(A)    (TRUE)
191#define kTest_Pref(A) (TRUE)
192#define kTest_TS(A) (TRUE)
193#define kTest_T(T)  (TRUE)
194#define kTest_S(T)  (TRUE)
195#define kTest_L(T)  (TRUE)
196#endif
197#endif
198
199/***************************************************************
200 *
201 * From kstd2.cc
202 *
203 ***************************************************************/
204ideal bba (ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat);
205poly kNF2 (ideal F, ideal Q, poly q, kStrategy strat, int lazyReduce);
206ideal kNF2 (ideal F,ideal Q,ideal q, kStrategy strat, int lazyReduce);
207void initBba(ideal F,kStrategy strat);
208
209/***************************************************************
210 *
211 * From kSpolys.cc
212 *
213 ***************************************************************/
214// Reduces PR with PW
215// Assumes PR != NULL, PW != NULL, Lm(PW) divides Lm(PR)
216// Changes: PR
217// Const:   PW
218// If coef != NULL, then *coef is a/gcd(a,b), where a = LC(PR), b = LC(PW)
219void ksReducePoly(LObject* PR,
220                  TObject* PW,
221                  poly spNoether = NULL,
222                  number *coef = NULL);
223
224// Reduces PR at Current->next with PW
225// Assumes PR != NULL, Current contained in PR
226//         Current->next != NULL, LM(PW) devides LM(Current->next)
227// Changes: PR
228// Const:   PW
229void ksReducePolyTail(LObject* PR,
230                      TObject* PW,
231                      poly Current,
232                      poly spNoether = NULL);
233
234// Creates S-Poly of Pair
235// Const:   Pair->p1, Pair->p2
236// Changes: Pair->p == S-Poly of p1, p2
237// Assume:  Pair->p1 != NULL && Pair->p2
238void ksCreateSpoly(LObject* Pair, 
239                   poly spNoether = NULL);
240
241
242/*2
243* creates the leading term of the S-polynomial of p1 and p2
244* do not destroy p1 and p2
245* remarks:
246*   1. the coefficient is 0 (nNew)
247*   2. pNext is undefined
248*/
249poly ksCreateShortSpoly(poly p1, poly p2);
250
251
252/*
253* input - output: a, b
254* returns:
255*   a := a/gcd(a,b), b := b/gcd(a,b)
256*   and return value
257*       0  ->  a != 1,  b != 1
258*       1  ->  a == 1,  b != 1
259*       2  ->  a != 1,  b == 1
260*       3  ->  a == 1,  b == 1
261*   this value is used to control the spolys
262*/
263int ksCheckCoeff(number *a, number *b);
264
265// old stuff
266poly ksOldSpolyRed(poly p1, poly p2, poly spNoether = NULL);
267poly ksOldSpolyRedNew(poly p1, poly p2, poly spNoether = NULL);
268poly ksOldCreateSpoly(poly p1, poly p2, poly spNoether = NULL);
269void ksOldSpolyTail(poly p1, poly q, poly q2, poly spNoether);
270
271
272#include "polys.h"
273// Methods for tobjects
274inline poly sTObject::SetP(poly new_p)
275{
276  poly old_p = p;
277  memset((void*) this, 0, sizeof(sTObject));
278  p = new_p;
279  sev = pGetShortExpVector(p);
280  return p;
281}
282
Note: See TracBrowser for help on using the repository browser.