source: git/Singular/kutil.h @ 6e56de

spielwiese
Last change on this file since 6e56de was c232af, checked in by Olaf Bachmann <obachman@…>, 24 years ago
* omalloc stuff git-svn-id: file:///usr/local/Singular/svn/trunk@4524 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.26 2000-08-14 12:56:34 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  omBin heap;
25  unsigned long sev;
26  sTObject() { memset((void*) this, 0, sizeof(sTObject)); heap = currPolyBin;}
27  inline poly SetP(poly p_new);
28};
29
30class sLObject
31{
32public:
33  poly  p;
34  poly  p1,p2; /*- the pair p comes from -*/
35  poly  lcm;   /*- the lcm of p1,p2 -*/
36  omBin heap;
37  int ecart,length, pLength;
38  unsigned long sev;
39  sLObject() { memset((void*) this, 0, sizeof(sLObject));}
40};
41
42typedef class sTObject TObject;
43typedef class sLObject LObject;
44typedef TObject * TSet;
45typedef LObject * LSet;
46
47extern int HCord;
48
49class skStrategy;
50typedef skStrategy * kStrategy;
51class skStrategy
52{
53public:
54  kStrategy next;
55  int (*red)(LObject * L,kStrategy strat);
56  void (*initEcart)(LObject * L);
57  int (*posInT)(const TSet T,const int tl,const LObject &h);
58  int (*posInL)(const LSet set, const int length,
59                const LObject &L,const kStrategy strat);
60  void (*enterS)(LObject h, int pos,kStrategy strat);
61  void (*initEcartPair)(LObject * h, poly f, poly g, int ecartF, int ecartG);
62  int (*posInLOld)(const LSet Ls,const int Ll,
63                   const LObject &Lo,const kStrategy strat);
64  pFDegProc pOldFDeg;
65  ideal Shdl;
66  ideal D; /*V(S) is in D(D)*/
67  ideal M; /*set of minimal generators*/
68  polyset S;
69  intset ecartS;
70  intset fromQ;
71  unsigned long* sevS;
72  TSet T;
73  LSet L;
74  LSet    B;
75  poly    kHEdge;
76  poly    kNoether;
77  BOOLEAN * NotUsedAxis;
78  LObject P;
79  poly tail;
80  leftv kIdeal;
81  intvec * kModW;
82  intvec * kHomW;
83  omBin THeap;       // if != NULL, heap for monoms of T
84  BOOLEAN use_redheap; // if TRUE, use extra heap for reductions
85  BOOLEAN *pairtest;/*used for enterOnePair*/
86  int cp,c3;
87  int sl,mu;
88  int tl,tmax;
89  int Ll,Lmax;
90  int Bl,Bmax;
91  int ak,LazyDegree,LazyPass;
92  int syzComp;
93  int HCord;
94  int lastAxis;
95  int newIdeal;
96  int minim;
97  BOOLEAN interpt;
98  BOOLEAN homog;
99  BOOLEAN kHEdgeFound;
100  BOOLEAN honey,sugarCrit;
101  BOOLEAN Gebauer,noTailReduction;
102  BOOLEAN fromT;
103  BOOLEAN noetherSet;
104  BOOLEAN update;
105  BOOLEAN posInLOldFlag;
106  /*FALSE, if posInL == posInL10*/
107  char    redTailChange;
108  char    news;
109  char    newt;/*used for messageSets*/
110};
111
112void deleteHC(poly *p, int *e, int *l, kStrategy strat);
113void deleteInS (int i,kStrategy strat);
114void cleanT (kStrategy strat);
115LSet initL ();
116void deleteInL(LSet set, int *length, int j,kStrategy strat);
117void enterL (LSet *set,int *length, int *LSetmax, LObject p,int at);
118void initEcartPairBba (LObject* Lp,poly f,poly g,int ecartF,int ecartG);
119void initEcartPairMora (LObject* Lp,poly f,poly g,int ecartF,int ecartG);
120int posInS (polyset set,int length,poly p);
121int posInT0 (const TSet set,const int length,const LObject &p);
122int posInT1 (const TSet set,const int length,const LObject &p);
123int posInT2 (const TSet set,const int length,const LObject &p);
124int posInT11 (const TSet set,const int length,const LObject &p);
125int posInT13 (const TSet set,const int length,const LObject &p);
126int posInT15 (const TSet set,const int length,const LObject &p);
127int posInT17 (const TSet set,const int length,const LObject &p);
128int posInT19 (const TSet set,const int length,const LObject &p);
129void reorderS (int* suc,kStrategy strat);
130int posInL0 (const LSet set, const int length,
131             const LObject &L,const kStrategy strat);
132int posInL11 (const LSet set, const int length,
133             const LObject &L,const kStrategy strat);
134int posInL13 (const LSet set, const int length,
135             const LObject &L,const kStrategy strat);
136int posInL15 (const LSet set, const int length,
137             const LObject &L,const kStrategy strat);
138int posInL17 (const LSet set, const int length,
139             const LObject &L,const kStrategy strat);
140poly redtailBba (poly p,int pos,kStrategy strat);
141poly redtailSyz (poly p,int pos,kStrategy strat);
142poly redtail (poly p,int pos,kStrategy strat);
143void enterpairs (poly h, int k, int ec, int pos,kStrategy strat);
144void entersets (LObject h);
145void pairs ();
146void message (int i,int* reduc,int* olddeg,kStrategy strat);
147void messageStat (int srmax,int lrmax,int hilbcount,kStrategy strat);
148void messageSets (kStrategy strat);
149void initEcartNormal (LObject* h);
150void initEcartBBA (LObject* h);
151void initS (ideal F, ideal Q,kStrategy strat);
152void initSL (ideal F, ideal Q,kStrategy strat);
153void updateS(BOOLEAN toT,kStrategy strat);
154void enterSBba (LObject p, int pos,kStrategy strat);
155void enterT (LObject p,kStrategy strat);
156void enterTBba (LObject p, int pos,kStrategy strat);
157void cancelunit (LObject* p);
158void HEckeTest (poly pp,kStrategy strat);
159void redtailS (poly* h,int maxIndex);
160void redtailMora (poly* h,int maxIndex);
161void kinitBbaHeaps(kStrategy heap);
162void initBuchMoraCrit(kStrategy strat);
163void initHilbCrit(ideal F, ideal Q, intvec **hilb,kStrategy strat);
164void initBuchMoraPos(kStrategy strat);
165void initBuchMora (ideal F, ideal Q,kStrategy strat);
166void exitBuchMora (kStrategy strat);
167void updateResult(ideal r,ideal Q,kStrategy strat);
168void completeReduce (kStrategy strat);
169void kFreeStrat(kStrategy strat);
170BOOLEAN homogTest(polyset F, int Fmax);
171BOOLEAN newHEdge(polyset S, int ak,kStrategy strat);
172
173inline TSet initT () { return (TSet)omAlloc0(setmax*sizeof(TObject)); }
174
175#ifdef KDEBUG
176#define kTest(A) K_Test(__FILE__,__LINE__,A)
177#define kTest_TS(A) K_Test_TS(__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, 2)
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.