source: git/Singular/kutil.h @ ec7aac

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