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

spielwiese
Last change on this file since 6f1610 was 6f1610, checked in by Olaf Bachmann <obachman@…>, 24 years ago
* ideals: fix in idModulo * k* fix initSSpecial * mmbt: don't track on new git-svn-id: file:///usr/local/Singular/svn/trunk@3835 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 8.8 KB
Line 
1#ifndef KUTIL_H
2#define KUTIL_H
3/****************************************
4*  Computer Algebra System SINGULAR     *
5****************************************/
6/* $Id: kutil.h,v 1.23 1999-11-17 12:09:27 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)); heap = mm_specHeap;}
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{
57public:
58  kStrategy next;
59  int (*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  memHeap THeap;       // if != NULL, heap for monoms of T
88  BOOLEAN use_redheap; // if TRUE, use extra heap for reductions
89  BOOLEAN *pairtest;/*used for enterOnePair*/
90  int cp,c3;
91  int sl,mu;
92  int tl,tmax;
93  int Ll,Lmax;
94  int Bl,Bmax;
95  int ak,LazyDegree,LazyPass;
96  int syzComp;
97  int HCord;
98  int lastAxis;
99  int newIdeal;
100  int minim;
101  BOOLEAN interpt;
102  BOOLEAN homog;
103  BOOLEAN kHEdgeFound;
104  BOOLEAN honey,sugarCrit;
105  BOOLEAN Gebauer,noTailReduction;
106  BOOLEAN fromT;
107  BOOLEAN noetherSet;
108  BOOLEAN update;
109  BOOLEAN posInLOldFlag;
110  /*FALSE, if posInL == posInL10*/
111  char    redTailChange;
112  char    news;
113  char    newt;/*used for messageSets*/
114};
115
116void deleteHC(poly *p, int *e, int *l, kStrategy strat);
117void deleteInS (int i,kStrategy strat);
118void cleanT (kStrategy strat);
119LSet initL ();
120void deleteInL(LSet set, int *length, int j,kStrategy strat);
121void enterL (LSet *set,int *length, int *LSetmax, LObject p,int at);
122void initEcartPairBba (LObject* Lp,poly f,poly g,int ecartF,int ecartG);
123void initEcartPairMora (LObject* Lp,poly f,poly g,int ecartF,int ecartG);
124int posInS (polyset set,int length,poly p);
125int posInT0 (const TSet set,const int length,const LObject &p);
126int posInT1 (const TSet set,const int length,const LObject &p);
127int posInT2 (const TSet set,const int length,const LObject &p);
128int posInT11 (const TSet set,const int length,const LObject &p);
129int posInT13 (const TSet set,const int length,const LObject &p);
130int posInT15 (const TSet set,const int length,const LObject &p);
131int posInT17 (const TSet set,const int length,const LObject &p);
132int posInT19 (const TSet set,const int length,const LObject &p);
133void reorderS (int* suc,kStrategy strat);
134int posInL0 (const LSet set, const int length,
135             const LObject &L,const kStrategy strat);
136int posInL11 (const LSet set, const int length,
137             const LObject &L,const kStrategy strat);
138int posInL13 (const LSet set, const int length,
139             const LObject &L,const kStrategy strat);
140int posInL15 (const LSet set, const int length,
141             const LObject &L,const kStrategy strat);
142int posInL17 (const LSet set, const int length,
143             const LObject &L,const kStrategy strat);
144poly redtailBba (poly p,int pos,kStrategy strat);
145poly redtailSyz (poly p,int pos,kStrategy strat);
146poly redtail (poly p,int pos,kStrategy strat);
147void enterpairs (poly h, int k, int ec, int pos,kStrategy strat);
148void entersets (LObject h);
149void pairs ();
150void message (int i,int* reduc,int* olddeg,kStrategy strat);
151void messageStat (int srmax,int lrmax,int hilbcount,kStrategy strat);
152void messageSets (kStrategy strat);
153void initEcartNormal (LObject* h);
154void initEcartBBA (LObject* h);
155void initS (ideal F, ideal Q,kStrategy strat);
156void initSL (ideal F, ideal Q,kStrategy strat);
157void updateS(BOOLEAN toT,kStrategy strat);
158void enterSBba (LObject p, int pos,kStrategy strat);
159void enterT (LObject p,kStrategy strat);
160void enterTBba (LObject p, int pos,kStrategy strat);
161void cancelunit (LObject* p);
162void HEckeTest (poly pp,kStrategy strat);
163void redtailS (poly* h,int maxIndex);
164void redtailMora (poly* h,int maxIndex);
165void kinitBbaHeaps(kStrategy heap);
166void initBuchMoraCrit(kStrategy strat);
167void initHilbCrit(ideal F, ideal Q, intvec **hilb,kStrategy strat);
168void initBuchMoraPos(kStrategy strat);
169void initBuchMora (ideal F, ideal Q,kStrategy strat);
170void exitBuchMora (kStrategy strat);
171void updateResult(ideal r,ideal Q,kStrategy strat);
172void completeReduce (kStrategy strat);
173void kFreeStrat(kStrategy strat);
174BOOLEAN homogTest(polyset F, int Fmax);
175BOOLEAN newHEdge(polyset S, int ak,kStrategy strat);
176
177inline TSet initT () { return (TSet)Alloc0(setmax*sizeof(TObject)); }
178
179#ifdef KDEBUG
180#define kTest(A) K_Test(__FILE__,__LINE__,A)
181#define kTest_TS(A) K_Test_TS(__FILE__,__LINE__,A)
182#define kTest_T(T) K_Test_T(__FILE__,__LINE__,T)
183#define kTest_L(L) K_Test_L(__FILE__,__LINE__,L)
184#define kTest_S(strat) K_Test_S(__FILE__,__LINE__,strat)
185#define kTest_Pref(L) K_Test(__FILE__,__LINE__,L, 2)
186BOOLEAN K_Test(char *f, int l,kStrategy strat, int pref=0);
187BOOLEAN K_Test_TS(char *f, int l,kStrategy strat);
188BOOLEAN K_Test_T(char *f, int l, TObject* T, int tpos = -1);
189BOOLEAN K_Test_L(char* f, int l, LObject* L, 
190                 BOOLEAN testp = FALSE, int lpos = -1, 
191                 TSet T = NULL, int tlength = -1);
192BOOLEAN K_Test_S(char* f, int l, kStrategy strat);
193#else
194#define kTest(A)    (TRUE)
195#define kTest_Pref(A) (TRUE)
196#define kTest_TS(A) (TRUE)
197#define kTest_T(T)  (TRUE)
198#define kTest_S(T)  (TRUE)
199#define kTest_L(T)  (TRUE)
200#endif
201#endif
202
203/***************************************************************
204 *
205 * From kstd2.cc
206 *
207 ***************************************************************/
208ideal bba (ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat);
209poly kNF2 (ideal F, ideal Q, poly q, kStrategy strat, int lazyReduce);
210ideal kNF2 (ideal F,ideal Q,ideal q, kStrategy strat, int lazyReduce);
211void initBba(ideal F,kStrategy strat);
212
213/***************************************************************
214 *
215 * From kSpolys.cc
216 *
217 ***************************************************************/
218// Reduces PR with PW
219// Assumes PR != NULL, PW != NULL, Lm(PW) divides Lm(PR)
220// Changes: PR
221// Const:   PW
222// If coef != NULL, then *coef is a/gcd(a,b), where a = LC(PR), b = LC(PW)
223void ksReducePoly(LObject* PR,
224                  TObject* PW,
225                  poly spNoether = NULL,
226                  number *coef = NULL);
227
228// Reduces PR at Current->next with PW
229// Assumes PR != NULL, Current contained in PR
230//         Current->next != NULL, LM(PW) devides LM(Current->next)
231// Changes: PR
232// Const:   PW
233void ksReducePolyTail(LObject* PR,
234                      TObject* PW,
235                      poly Current,
236                      poly spNoether = NULL);
237
238// Creates S-Poly of Pair
239// Const:   Pair->p1, Pair->p2
240// Changes: Pair->p == S-Poly of p1, p2
241// Assume:  Pair->p1 != NULL && Pair->p2
242void ksCreateSpoly(LObject* Pair, 
243                   poly spNoether = NULL);
244
245
246/*2
247* creates the leading term of the S-polynomial of p1 and p2
248* do not destroy p1 and p2
249* remarks:
250*   1. the coefficient is 0 (nNew)
251*   2. pNext is undefined
252*/
253poly ksCreateShortSpoly(poly p1, poly p2);
254
255
256/*
257* input - output: a, b
258* returns:
259*   a := a/gcd(a,b), b := b/gcd(a,b)
260*   and return value
261*       0  ->  a != 1,  b != 1
262*       1  ->  a == 1,  b != 1
263*       2  ->  a != 1,  b == 1
264*       3  ->  a == 1,  b == 1
265*   this value is used to control the spolys
266*/
267int ksCheckCoeff(number *a, number *b);
268
269// old stuff
270poly ksOldSpolyRed(poly p1, poly p2, poly spNoether = NULL);
271poly ksOldSpolyRedNew(poly p1, poly p2, poly spNoether = NULL);
272poly ksOldCreateSpoly(poly p1, poly p2, poly spNoether = NULL);
273void ksOldSpolyTail(poly p1, poly q, poly q2, poly spNoether);
274
275
276#include "polys.h"
277// Methods for tobjects
278inline poly sTObject::SetP(poly new_p)
279{
280  poly old_p = p;
281  memset((void*) this, 0, sizeof(sTObject));
282  p = new_p;
283  sev = pGetShortExpVector(p);
284  return p;
285}
286
Note: See TracBrowser for help on using the repository browser.