Functions
walkProc.h File Reference
#include <kernel/groebner_walk/walkMain.h>

Go to the source code of this file.

Functions

ideal walkProc (leftv first, leftv second)
 
ideal fractalWalkProc (leftv first, leftv second)
 
WalkState walkConsistency (ring sring, ring dring, int *vperm)
 
WalkState fractalWalkConsistency (ring sring, ring dring, int *vperm)
 

Function Documentation

◆ fractalWalkConsistency()

WalkState fractalWalkConsistency ( ring  sring,
ring  dring,
int *  vperm 
)

Definition at line 224 of file walkProc.cc.

225 {
226  int k;
227  WalkState state= WalkOk;
228 
229  if ( rChar(sring) != rChar(dring) )
230  {
231  WerrorS( "rings must have same characteristic" );
232  state= WalkIncompatibleRings;
233  }
234 
235  if ( (rHasLocalOrMixedOrdering(sring))
236  || (rHasLocalOrMixedOrdering(dring)) )
237  {
238  WerrorS( "only works for global orderings" );
239  state= WalkIncompatibleRings;
240  }
241 
242  if ( rVar(sring) != rVar(dring) )
243  {
244  WerrorS( "rings must have same number of variables" );
245  state= WalkIncompatibleRings;
246  }
247 
248  if ( rPar(sring) != rPar(dring) )
249  {
250  WerrorS( "rings must have same number of parameters" );
251  state= WalkIncompatibleRings;
252  }
253 
254  if ( state != WalkOk ) return state;
255 
256  // now the rings have the same number of variables resp. parameters.
257  // check if the names of the variables resp. parameters do agree:
258  int nvar = sring->N;
259  int npar = rPar(sring);
260  int * pperm;
261  char **snames;
262  char **dnames;
263 
264  if ( npar > 0 )
265  {
266  snames=sring->cf->extRing->names;
267  dnames=dring->cf->extRing->names;
268  pperm= (int *)omAlloc0( (npar+1)*sizeof( int ) );
269  }
270  else
271  {
272  pperm= NULL;
273  snames=NULL;
274  dnames=NULL;
275  }
276 
277  maFindPerm( sring->names, nvar, snames, npar,
278  dring->names, nvar, dnames, npar, vperm, pperm,
279  dring->cf->type);
280 
281  for ( k= nvar; (k > 0) && (state == WalkOk); k-- )
282  if ( vperm[k] <= 0 )
283  {
284  WerrorS( "variable names do not agree" );
285  state= WalkIncompatibleRings;
286  }
287 
288  for ( k= npar; (k > 0) && (state == WalkOk); k-- )
289  if ( pperm[k-1] >= 0 )
290  {
291  WerrorS( "parameter names do not agree" );
292  state= WalkIncompatibleRings;
293  }
294 
295  //check if order of variables resp. parameters does agree
296  //remove this to if you want to allow permutations of variables
297  for ( k= nvar; (k > 0) && (state == WalkOk); k-- )
298  if ( vperm[k] != (k) )
299  {
300  WerrorS( "orders of variables do not agree" );
301  state= WalkIncompatibleRings;
302  }
303 
304  //remove this to if you want to allow permutations of parameters
305  for ( k= npar; (k > 0) && (state == WalkOk); k-- )
306  if ( pperm[k-1] != (-k) )
307  {
308  WerrorS( "orders of parameters do not agree" );
309  state= WalkIncompatibleRings;
310  }
311 
312  if (pperm != NULL)
313  omFreeSize( (ADDRESS)pperm, (npar+1)*sizeof( int ) );
314 
315  if ( state != WalkOk ) return state;
316 
317  // check if any of the rings are qrings or not
318  if ( (sring->qideal != NULL) || (dring->qideal != NULL) )
319  {
320  WerrorS( "rings are not allowed to be qrings");
321  return WalkIncompatibleRings;
322  }
323 
324  int i=0;
325  while(dring->order[i]!=0){
326  if( !(dring->order[i]==ringorder_lp) &&
327  !(dring->order[i]==ringorder_dp) &&
328  !(dring->order[i]==ringorder_Dp) &&
329  !(dring->order[i]==ringorder_wp) &&
330  !(dring->order[i]==ringorder_Wp) &&
331  !(dring->order[i]==ringorder_C) &&
332  !(dring->order[0]==ringorder_M)
333  )
334  {
336  }
337  i++;
338  }
339 
340  i=0;
341  while(sring->order[i]!=0)
342  {
343  if( !(sring->order[i]==ringorder_lp) &&
344  !(sring->order[i]==ringorder_dp) &&
345  !(sring->order[i]==ringorder_Dp) &&
346  !(sring->order[i]==ringorder_wp) &&
347  !(sring->order[i]==ringorder_Wp) &&
348  !(sring->order[i]==ringorder_C) &&
349  !(dring->order[0]==ringorder_M)
350  )
351  {
353  }
354  i++;
355  }
356 
357  return state;
358 }
BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition: ring.h:752
WalkState
Definition: walkMain.h:7
static int rPar(const ring r)
(r->cf->P)
Definition: ring.h:590
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
int rChar(ring r)
Definition: ring.cc:688
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
void * ADDRESS
Definition: auxiliary.h:115
void WerrorS(const char *s)
Definition: feFopen.cc:24
int k
Definition: cfEzgcd.cc:93
int i
Definition: cfEzgcd.cc:123
void maFindPerm(char const *const *const preim_names, int preim_n, char const *const *const preim_par, int preim_p, char const *const *const names, int n, char const *const *const par, int nop, int *perm, int *par_perm, n_coeffType ch)
Definition: maps.cc:169
#define NULL
Definition: omList.c:10
#define omAlloc0(size)
Definition: omAllocDecl.h:211

◆ fractalWalkProc()

ideal fractalWalkProc ( leftv  first,
leftv  second 
)

Definition at line 167 of file walk_ip.cc.

168 {
169 
170  //unperturbedStartVectorStrategy SHOULD BE SET BY THE USER THROUGH
171  //A THIRD ARGUMENT. TRUE MEANS THAT THE UNPERTURBED START
172  //VECTOR STRATEGY IS USED AND FALSE THAT THE START VECTOR IS
173  //MAXIMALLY PERTURBED
174 
175  BOOLEAN unperturbedStartVectorStrategy=TRUE;
176 
177  WalkState state = WalkOk;
178  BITSET save1,save2;
179  SI_SAVE_OPT(save1,save2);
180  si_opt_1 &= (~Sy_bit(OPT_REDSB)); //make sure option noredSB is set
181 
182  ring destRing = currRing;
183  ideal destIdeal = NULL;
184  idhdl sourceRingHdl = (idhdl)first->data;
185  rSetHdl( sourceRingHdl );
186  ring sourceRing = currRing;
187 
188  int * vperm = (int *)omAlloc0( (currRing->N+1)*sizeof( int ) );
189  state= fractalWalkConsistency( sourceRing, destRing, vperm );
190  omFreeSize( (ADDRESS)vperm, (currRing->N+1)*sizeof(int) );
191 
192  ideal sourceIdeal;
193  BOOLEAN sourcIdealIsSB=FALSE;
194  if ( state == WalkOk ) {
195  idhdl ih = currRing->idroot->get( second->Name(), myynest );
196  if ( (ih != NULL) && (IDTYP(ih)==IDEAL_CMD) ) {
197  sourceIdeal = IDIDEAL( ih );
198  if(hasFlag((leftv)ih,FLAG_STD)){
199  sourcIdealIsSB=TRUE;
200  }
201  }
202  else {
203  state=WalkNoIdeal;
204  }
205  }
206 
207  if ( state == WalkOk ) {
208  // Now the settings are compatible with Walk
209  state=fractalWalk64(sourceIdeal,destRing,destIdeal,
210  sourcIdealIsSB,
211  unperturbedStartVectorStrategy);
212  }
213 
214  SI_RESTORE_OPT(save1,save2);//making sure options are as before functiocall
215 
216  if ( state == WalkOk )
217  {
218  ring almostDestRing=currRing;
219  rChangeCurrRing(destRing);
220  destIdeal=idrMoveR(destIdeal, almostDestRing, destRing);
221  }
222 
223 
224  switch (state) {
225 
226  case WalkOk:
227  destIdeal=sortRedSB(destIdeal);
228  return(destIdeal);
229  break;
230 
232  Werror( "ring %s and current ring are incompatible\n",
233  first->Name() );
234  rChangeCurrRing(destRing);
235  destIdeal= NULL;
236  return destIdeal;
237  break;
238 
240  Werror( "Order of basering not allowed,\n must be a combination of lp,dp,Dp,wp,Wp and C or just M.\n");
241  rChangeCurrRing(destRing);
242  destIdeal= NULL;
243  return destIdeal;
244  break;
245 
247  Werror( "Order of %s not allowed,\n must be a combination of lp,dp,Dp,wp,Wp and C or just M.\n",
248  first->Name());
249  rChangeCurrRing(destRing);
250  destIdeal= NULL;
251  return destIdeal;
252  break;
253 
254  case WalkNoIdeal:
255  Werror( "Can't find ideal %s in ring %s.\n",
256  second->Name(), first->Name() );
257  rChangeCurrRing(destRing);
258  destIdeal= NULL;
259  return destIdeal;
260  break;
261 
262  case WalkOverFlowError:
263  Werror( "Overflow occurred in ring %s.\n", first->Name() );
264  rChangeCurrRing(destRing);
265  destIdeal= NULL;
266  return destIdeal;
267  break;
268 
269  default:
270  rChangeCurrRing(destRing);
271  destIdeal= idInit(1,1);
272  return destIdeal;
273  }
274 
275 
276  return NULL;
277 }
#define OPT_REDSB
Definition: options.h:71
ideal sortRedSB(ideal G)
unsigned si_opt_1
Definition: options.c:5
Class used for (list of) interpreter objects.
Definition: subexpr.h:82
WalkState
Definition: walkMain.h:7
#define FALSE
Definition: auxiliary.h:94
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define TRUE
Definition: auxiliary.h:98
#define IDIDEAL(a)
Definition: ipid.h:130
void * ADDRESS
Definition: auxiliary.h:115
#define BITSET
Definition: structs.h:18
#define Sy_bit(x)
Definition: options.h:30
const char * Name()
Definition: subexpr.h:120
Definition: idrec.h:34
void * data
Definition: subexpr.h:88
int myynest
Definition: febase.cc:46
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
#define IDTYP(a)
Definition: ipid.h:116
#define SI_RESTORE_OPT(A, B)
Definition: options.h:22
WalkState fractalWalk64(ideal sourceIdeal, ring destRing, ideal &destIdeal, BOOLEAN sourceIsSB, BOOLEAN unperturbedStartVectorStrategy)
Definition: walkMain.cc:614
ideal idrMoveR(ideal &id, ring src_r, ring dest_r)
Definition: prCopy.cc:249
idrec * idhdl
Definition: ring.h:18
#define FLAG_STD
Definition: ipid.h:106
void rChangeCurrRing(ring r)
Definition: polys.cc:12
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:38
#define NULL
Definition: omList.c:10
#define hasFlag(A, F)
Definition: ipid.h:109
#define SI_SAVE_OPT(A, B)
Definition: options.h:19
WalkState fractalWalkConsistency(ring sring, ring dring, int *vperm)
Definition: walkProc.cc:224
void rSetHdl(idhdl h)
Definition: ipshell.cc:5038
int BOOLEAN
Definition: auxiliary.h:85
void Werror(const char *fmt,...)
Definition: reporter.cc:189
#define omAlloc0(size)
Definition: omAllocDecl.h:211

◆ walkConsistency()

WalkState walkConsistency ( ring  sring,
ring  dring,
int *  vperm 
)

Definition at line 57 of file walkProc.cc.

58 {
59  int k;
60  WalkState state= WalkOk;
61 
62  if ( rChar(sring) != rChar(dring) )
63  {
64  WerrorS( "rings must have same characteristic" );
65  state= WalkIncompatibleRings;
66  }
67  else if ( (rHasLocalOrMixedOrdering(sring))
68  || (rHasLocalOrMixedOrdering(dring)) )
69  {
70  WerrorS( "only works for global orderings" );
71  state= WalkIncompatibleRings;
72  }
73  else if ( sring->N != dring->N )
74  {
75  WerrorS( "rings must have same number of variables" );
76  state= WalkIncompatibleRings;
77  }
78  else if ( rPar(sring) != rPar(dring) )
79  {
80  WerrorS( "rings must have same number of parameters" );
81  state= WalkIncompatibleRings;
82  }
83 
84  if ( state != WalkOk ) return state;
85  // now the rings have the same number of variables resp. parameters.
86  // check if the names of the variables resp. parameters do agree:
87 
88  int nvar = rVar(sring);
89  int npar = rPar(sring);
90  int * pperm;
91  char **snames;
92  char **dnames;
93  if ( npar > 0 )
94  {
95  snames=sring->cf->extRing->names;
96  dnames=dring->cf->extRing->names;
97  pperm= (int *)omAlloc0( (npar+1)*sizeof( int ) );
98  }
99  else
100  {
101  snames=NULL;
102  dnames=NULL;
103  pperm= NULL;
104  }
105 
106  maFindPerm( sring->names, nvar, snames, npar,
107  dring->names, nvar, dnames, npar, vperm, pperm,
108  dring->cf->type);
109 
110  for ( k= nvar; (k > 0) && (state == WalkOk); k-- )
111  if ( vperm[k] <= 0 )
112  {
113  WerrorS( "variable names do not agree" );
114  state= WalkIncompatibleRings;
115  }
116 
117  for ( k= npar-1; (k >= 0) && (state == WalkOk); k-- )
118  if ( pperm[k] >= 0 )
119  {
120  WerrorS( "parameter names do not agree" );
121  state= WalkIncompatibleRings;
122  }
123 
124  //remove this to if you want to allow permutations of variables
125  for ( k= nvar; (k > 0) && (state == WalkOk); k-- )
126  if ( vperm[k] != (k) )
127  {
128  WerrorS( "orders of variables do not agree" );
129  state= WalkIncompatibleRings;
130  }
131 
132  //remove this to if you want to allow permutations of parameters
133  for ( k= npar; (k > 0) && (state == WalkOk); k-- )
134  {
135  if ( pperm[k-1] != (-k) )
136  {
137  WerrorS( "orders of parameters do not agree" );
138  state= WalkIncompatibleRings;
139  }
140  }
141  if (pperm != NULL)
142  omFreeSize( (ADDRESS)pperm, (npar+1)*sizeof( int ) );
143 
144  if ( state != WalkOk ) return state;
145 
146  // check if any of the rings are qrings or not
147  if ( (sring->qideal != NULL) || (dring->qideal != NULL) )
148  {
149  WerrorS( "rings are not allowed to be qrings");
150  return WalkIncompatibleRings;
151  }
152 
153  int i=0;
154  while(dring->order[i]!=0)
155  {
156  if(
157  !(dring->order[i]==ringorder_a) &&
158  !(dring->order[i]==ringorder_a64) &&
159  !(dring->order[i]==ringorder_lp) &&
160  !(dring->order[i]==ringorder_dp) &&
161  !(dring->order[i]==ringorder_Dp) &&
162  !(dring->order[i]==ringorder_wp) &&
163  !(dring->order[i]==ringorder_Wp) &&
164  !(dring->order[i]==ringorder_C) &&
165  !(dring->order[i]==ringorder_M)
166  )
167  {
169  }
170  i++;
171  }
172 
173  i=0;
174  while(sring->order[i]!=0)
175  {
176  if(
177  !(sring->order[i]==ringorder_a) &&
178  !(sring->order[i]==ringorder_a64) &&
179  !(sring->order[i]==ringorder_lp) &&
180  !(sring->order[i]==ringorder_dp) &&
181  !(sring->order[i]==ringorder_Dp) &&
182  !(sring->order[i]==ringorder_wp) &&
183  !(sring->order[i]==ringorder_Wp) &&
184  !(sring->order[i]==ringorder_C) &&
185  !(sring->order[i]==ringorder_M)
186  )
187  {
189  }
190  i++;
191  }
192 
193  return state;
194 }
BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition: ring.h:752
for int64 weights
Definition: ring.h:79
WalkState
Definition: walkMain.h:7
static int rPar(const ring r)
(r->cf->P)
Definition: ring.h:590
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
int rChar(ring r)
Definition: ring.cc:688
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
void * ADDRESS
Definition: auxiliary.h:115
void WerrorS(const char *s)
Definition: feFopen.cc:24
int k
Definition: cfEzgcd.cc:93
int i
Definition: cfEzgcd.cc:123
void maFindPerm(char const *const *const preim_names, int preim_n, char const *const *const preim_par, int preim_p, char const *const *const names, int n, char const *const *const par, int nop, int *perm, int *par_perm, n_coeffType ch)
Definition: maps.cc:169
#define NULL
Definition: omList.c:10
#define omAlloc0(size)
Definition: omAllocDecl.h:211

◆ walkProc()

ideal walkProc ( leftv  first,
leftv  second 
)

Definition at line 61 of file walk_ip.cc.

62 {
63  WalkState state = WalkOk;
64  BITSET save1,save2;
65  SI_SAVE_OPT(save1,save2);
66  si_opt_1 &= (~Sy_bit(OPT_REDSB)); //make sure option noredSB is set
67 
68  ring destRing = currRing;
69  ideal destIdeal = NULL;
70  idhdl sourceRingHdl = (idhdl)first->data;
71  ring sourceRing = IDRING(sourceRingHdl);
72  rChangeCurrRing( sourceRing );
73 
74  if(state==WalkOk)
75  {
76  int * vperm = (int *)omAlloc0( (currRing->N+1)*sizeof( int ) );
77  state= walkConsistency( sourceRing, destRing, vperm );
78  omFreeSize( (ADDRESS)vperm, (currRing->N+1)*sizeof(int) );
79  }
80 
81  int64vec* currw64=rGetGlobalOrderWeightVec(sourceRing);
82  int64vec* destVec64=rGetGlobalOrderWeightVec(destRing);
83 
84  ideal sourceIdeal;
85  BOOLEAN sourcIdealIsSB=FALSE;
86  if ( state == WalkOk )
87  {
88  idhdl ih = currRing->idroot->get( second->Name(), myynest );
89  if ( (ih != NULL) && (IDTYP(ih)==IDEAL_CMD) )
90  {
91  sourceIdeal = idCopy(IDIDEAL( ih ));
92  if(hasFlag((leftv)ih,FLAG_STD)){
93  sourcIdealIsSB=TRUE;
94  }
95  }
96  else
97  {
98  state=WalkNoIdeal;
99  }
100  }
101 
102  if ( state == WalkOk )
103  {
104  // Now the settings are compatible with Walk
105  state=walk64(sourceIdeal,currw64,destRing,destVec64,
106  destIdeal,sourcIdealIsSB);
107  }
108 
109  SI_RESTORE_OPT(save1,save2);//making sure options are as before function call
110 
111  ring almostDestRing=currRing;
112  rChangeCurrRing(destRing);
113 
114  switch (state) {
115  case WalkOk:
116  destIdeal=idrMoveR(destIdeal,currRing,almostDestRing);
117  break;
118 
120  Werror("ring %s and current ring are incompatible\n",
121  first->Name() );
122  destIdeal= NULL;
123  break;
124 
126  WerrorS( "Order of basering not allowed,\n must be a combination of a,A,lp,dp,Dp,wp,Wp,M and C.\n");
127  destIdeal= NULL;
128  break;
129 
131  Werror( "Order of %s not allowed,\n must be a combination of a,A,lp,dp,Dp,wp,Wp,M and C.\n",first->Name());
132  rChangeCurrRing(destRing);
133  destIdeal= NULL;
134  break;
135 
136  case WalkNoIdeal:
137  Werror( "Can't find ideal %s in ring %s.\n",
138  second->Name(), first->Name() );
139  destIdeal= NULL;
140  break;
141 
142  case WalkOverFlowError:
143  WerrorS( "Overflow occurred.\n");
144  destIdeal= NULL;
145  break;
146 
147  default:
148  destIdeal= NULL;
149  }
150 
151  return destIdeal;
152 }
#define OPT_REDSB
Definition: options.h:71
int64vec * rGetGlobalOrderWeightVec(ring r)
unsigned si_opt_1
Definition: options.c:5
Class used for (list of) interpreter objects.
Definition: subexpr.h:82
WalkState
Definition: walkMain.h:7
#define FALSE
Definition: auxiliary.h:94
WalkState walk64(ideal I, int64vec *currw64, ring destRing, int64vec *destVec64, ideal &destIdeal, BOOLEAN sourceIsSB)
Definition: walkMain.cc:222
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define TRUE
Definition: auxiliary.h:98
#define IDIDEAL(a)
Definition: ipid.h:130
void * ADDRESS
Definition: auxiliary.h:115
void WerrorS(const char *s)
Definition: feFopen.cc:24
#define BITSET
Definition: structs.h:18
#define Sy_bit(x)
Definition: options.h:30
const char * Name()
Definition: subexpr.h:120
Definition: idrec.h:34
void * data
Definition: subexpr.h:88
int myynest
Definition: febase.cc:46
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
#define IDTYP(a)
Definition: ipid.h:116
WalkState walkConsistency(ring sring, ring dring, int *vperm)
Definition: walkProc.cc:57
#define SI_RESTORE_OPT(A, B)
Definition: options.h:22
ideal idrMoveR(ideal &id, ring src_r, ring dest_r)
Definition: prCopy.cc:249
idrec * idhdl
Definition: ring.h:18
#define FLAG_STD
Definition: ipid.h:106
ideal idCopy(ideal A)
Definition: ideals.h:60
void rChangeCurrRing(ring r)
Definition: polys.cc:12
#define NULL
Definition: omList.c:10
#define hasFlag(A, F)
Definition: ipid.h:109
#define IDRING(a)
Definition: ipid.h:124
#define SI_SAVE_OPT(A, B)
Definition: options.h:19
int BOOLEAN
Definition: auxiliary.h:85
void Werror(const char *fmt,...)
Definition: reporter.cc:189
#define omAlloc0(size)
Definition: omAllocDecl.h:211