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 223 of file walkProc.cc.

224 {
225  int k;
226  WalkState state= WalkOk;
227 
228  if ( rChar(sring) != rChar(dring) )
229  {
230  WerrorS( "rings must have same characteristic" );
231  state= WalkIncompatibleRings;
232  }
233 
234  if ( (rHasLocalOrMixedOrdering(sring))
235  || (rHasLocalOrMixedOrdering(dring)) )
236  {
237  WerrorS( "only works for global orderings" );
238  state= WalkIncompatibleRings;
239  }
240 
241  if ( rVar(sring) != rVar(dring) )
242  {
243  WerrorS( "rings must have same number of variables" );
244  state= WalkIncompatibleRings;
245  }
246 
247  if ( rPar(sring) != rPar(dring) )
248  {
249  WerrorS( "rings must have same number of parameters" );
250  state= WalkIncompatibleRings;
251  }
252 
253  if ( state != WalkOk ) return state;
254 
255  // now the rings have the same number of variables resp. parameters.
256  // check if the names of the variables resp. parameters do agree:
257  int nvar = sring->N;
258  int npar = rPar(sring);
259  int * pperm;
260  char **snames;
261  char **dnames;
262 
263  if ( npar > 0 )
264  {
265  snames=sring->cf->extRing->names;
266  dnames=dring->cf->extRing->names;
267  pperm= (int *)omAlloc0( (npar+1)*sizeof( int ) );
268  }
269  else
270  {
271  pperm= NULL;
272  snames=NULL;
273  dnames=NULL;
274  }
275 
276  maFindPerm( sring->names, nvar, snames, npar,
277  dring->names, nvar, dnames, npar, vperm, pperm,
278  dring->cf->type);
279 
280  for ( k= nvar; (k > 0) && (state == WalkOk); k-- )
281  if ( vperm[k] <= 0 )
282  {
283  WerrorS( "variable names do not agree" );
284  state= WalkIncompatibleRings;
285  }
286 
287  for ( k= npar; (k > 0) && (state == WalkOk); k-- )
288  if ( pperm[k-1] >= 0 )
289  {
290  WerrorS( "parameter names do not agree" );
291  state= WalkIncompatibleRings;
292  }
293 
294  //check if order of variables resp. parameters does agree
295  //remove this to if you want to allow permutations of variables
296  for ( k= nvar; (k > 0) && (state == WalkOk); k-- )
297  if ( vperm[k] != (k) )
298  {
299  WerrorS( "orders of variables do not agree" );
300  state= WalkIncompatibleRings;
301  }
302 
303  //remove this to if you want to allow permutations of parameters
304  for ( k= npar; (k > 0) && (state == WalkOk); k-- )
305  if ( pperm[k-1] != (-k) )
306  {
307  WerrorS( "orders of parameters do not agree" );
308  state= WalkIncompatibleRings;
309  }
310 
311  if (pperm != NULL)
312  omFreeSize( (ADDRESS)pperm, (npar+1)*sizeof( int ) );
313 
314  if ( state != WalkOk ) return state;
315 
316  // check if any of the rings are qrings or not
317  if ( (sring->qideal != NULL) || (dring->qideal != NULL) )
318  {
319  WerrorS( "rings are not allowed to be qrings");
320  return WalkIncompatibleRings;
321  }
322 
323  int i=0;
324  while(dring->order[i]!=0){
325  if( !(dring->order[i]==ringorder_lp) &&
326  !(dring->order[i]==ringorder_dp) &&
327  !(dring->order[i]==ringorder_Dp) &&
328  !(dring->order[i]==ringorder_wp) &&
329  !(dring->order[i]==ringorder_Wp) &&
330  !(dring->order[i]==ringorder_C) &&
331  !(dring->order[0]==ringorder_M)
332  )
333  {
335  }
336  i++;
337  }
338 
339  i=0;
340  while(sring->order[i]!=0)
341  {
342  if( !(sring->order[i]==ringorder_lp) &&
343  !(sring->order[i]==ringorder_dp) &&
344  !(sring->order[i]==ringorder_Dp) &&
345  !(sring->order[i]==ringorder_wp) &&
346  !(sring->order[i]==ringorder_Wp) &&
347  !(sring->order[i]==ringorder_C) &&
348  !(dring->order[0]==ringorder_M)
349  )
350  {
352  }
353  i++;
354  }
355 
356  return state;
357 }
BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition: ring.h:747
WalkState
Definition: walkMain.h:7
static int rPar(const ring r)
(r->cf->P)
Definition: ring.h:587
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
int rChar(ring r)
Definition: ring.cc:684
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:580
void * ADDRESS
Definition: auxiliary.h:116
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:83
WalkState
Definition: walkMain.h:7
#define FALSE
Definition: auxiliary.h:95
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define TRUE
Definition: auxiliary.h:99
#define IDIDEAL(a)
Definition: ipid.h:130
void * ADDRESS
Definition: auxiliary.h:116
#define BITSET
Definition: structs.h:18
#define Sy_bit(x)
Definition: options.h:30
const char * Name()
Definition: subexpr.h:121
Definition: idrec.h:34
void * data
Definition: subexpr.h:89
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:223
void rSetHdl(idhdl h)
Definition: ipshell.cc:5021
int BOOLEAN
Definition: auxiliary.h:86
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  if ( pperm[k-1] != (-k) )
135  {
136  WerrorS( "orders of parameters do not agree" );
137  state= WalkIncompatibleRings;
138  }
139 
140  if (pperm != NULL)
141  omFreeSize( (ADDRESS)pperm, (npar+1)*sizeof( int ) );
142 
143  if ( state != WalkOk ) return state;
144 
145  // check if any of the rings are qrings or not
146  if ( (sring->qideal != NULL) || (dring->qideal != NULL) )
147  {
148  WerrorS( "rings are not allowed to be qrings");
149  return WalkIncompatibleRings;
150  }
151 
152  int i=0;
153  while(dring->order[i]!=0)
154  {
155  if(
156  !(dring->order[i]==ringorder_a) &&
157  !(dring->order[i]==ringorder_a64) &&
158  !(dring->order[i]==ringorder_lp) &&
159  !(dring->order[i]==ringorder_dp) &&
160  !(dring->order[i]==ringorder_Dp) &&
161  !(dring->order[i]==ringorder_wp) &&
162  !(dring->order[i]==ringorder_Wp) &&
163  !(dring->order[i]==ringorder_C) &&
164  !(dring->order[i]==ringorder_M)
165  )
166  {
168  }
169  i++;
170  }
171 
172  i=0;
173  while(sring->order[i]!=0)
174  {
175  if(
176  !(sring->order[i]==ringorder_a) &&
177  !(sring->order[i]==ringorder_a64) &&
178  !(sring->order[i]==ringorder_lp) &&
179  !(sring->order[i]==ringorder_dp) &&
180  !(sring->order[i]==ringorder_Dp) &&
181  !(sring->order[i]==ringorder_wp) &&
182  !(sring->order[i]==ringorder_Wp) &&
183  !(sring->order[i]==ringorder_C) &&
184  !(sring->order[i]==ringorder_M)
185  )
186  {
188  }
189  i++;
190  }
191 
192  return state;
193 }
BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition: ring.h:747
for int64 weights
Definition: ring.h:79
WalkState
Definition: walkMain.h:7
static int rPar(const ring r)
(r->cf->P)
Definition: ring.h:587
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
int rChar(ring r)
Definition: ring.cc:684
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:580
void * ADDRESS
Definition: auxiliary.h:116
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:83
WalkState
Definition: walkMain.h:7
#define FALSE
Definition: auxiliary.h:95
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:99
#define IDIDEAL(a)
Definition: ipid.h:130
void * ADDRESS
Definition: auxiliary.h:116
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:121
Definition: idrec.h:34
void * data
Definition: subexpr.h:89
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:86
void Werror(const char *fmt,...)
Definition: reporter.cc:189
#define omAlloc0(size)
Definition: omAllocDecl.h:211