My Project  debian-1:4.1.1-p2+ds-4build1
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 221 of file walkProc.cc.

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

◆ fractalWalkProc()

ideal fractalWalkProc ( leftv  first,
leftv  second 
)

Definition at line 160 of file walk_ip.cc.

162 {
163 
164  //unperturbedStartVectorStrategy SHOULD BE SET BY THE USER THROUGH
165  //A THIRD ARGUMENT. TRUE MEANS THAT THE UNPERTURBED START
166  //VECTOR STRATEGY IS USED AND FALSE THAT THE START VECTOR IS
167  //MAXIMALLY PERTURBED
168 
169  BOOLEAN unperturbedStartVectorStrategy=TRUE;
170 
171  WalkState state = WalkOk;
172  BITSET save1,save2;
173  SI_SAVE_OPT(save1,save2);
174  si_opt_1 &= (~Sy_bit(OPT_REDSB)); //make sure option noredSB is set
175 
176  ring destRing = currRing;
177  ideal destIdeal = NULL;
178  idhdl sourceRingHdl = (idhdl)first->data;
179  rSetHdl( sourceRingHdl );
180  ring sourceRing = currRing;
181 
182  int * vperm = (int *)omAlloc0( (currRing->N+1)*sizeof( int ) );
183  state= fractalWalkConsistency( sourceRing, destRing, vperm );
184  omFreeSize( (ADDRESS)vperm, (currRing->N+1)*sizeof(int) );
185 
186  ideal sourceIdeal;
187  BOOLEAN sourcIdealIsSB=FALSE;
188  if ( state == WalkOk ) {
189  idhdl ih = currRing->idroot->get( second->Name(), myynest );
190  if ( (ih != NULL) && (IDTYP(ih)==IDEAL_CMD) ) {
191  sourceIdeal = IDIDEAL( ih );
192  if(hasFlag((leftv)ih,FLAG_STD)){
193  sourcIdealIsSB=TRUE;
194  }
195  }
196  else {
197  state=WalkNoIdeal;
198  }
199  }
200 
201  if ( state == WalkOk ) {
202  // Now the settings are compatible with Walk
203  state=fractalWalk64(sourceIdeal,destRing,destIdeal,
204  sourcIdealIsSB,
205  unperturbedStartVectorStrategy);
206  }
207 
208  SI_RESTORE_OPT(save1,save2);//making sure options are as before functiocall
209 
210  if ( state == WalkOk )
211  {
212  ring almostDestRing=currRing;
213  rChangeCurrRing(destRing);
214  destIdeal=idrMoveR(destIdeal, almostDestRing, destRing);
215  }
216 
217 
218  switch (state) {
219 
220  case WalkOk:
221  destIdeal=sortRedSB(destIdeal);
222  return(destIdeal);
223  break;
224 
226  Werror( "ring %s and current ring are incompatible\n",
227  first->Name() );
228  rChangeCurrRing(destRing);
229  destIdeal= NULL;
230  return destIdeal;
231  break;
232 
234  Werror( "Order of basering not allowed,\n must be a combination of lp,dp,Dp,wp,Wp and C or just M.\n");
235  rChangeCurrRing(destRing);
236  destIdeal= NULL;
237  return destIdeal;
238  break;
239 
241  Werror( "Order of %s not allowed,\n must be a combination of lp,dp,Dp,wp,Wp and C or just M.\n",
242  first->Name());
243  rChangeCurrRing(destRing);
244  destIdeal= NULL;
245  return destIdeal;
246  break;
247 
248  case WalkNoIdeal:
249  Werror( "Can't find ideal %s in ring %s.\n",
250  second->Name(), first->Name() );
251  rChangeCurrRing(destRing);
252  destIdeal= NULL;
253  return destIdeal;
254  break;
255 
256  case WalkOverFlowError:
257  Werror( "Overflow occurred in ring %s.\n", first->Name() );
258  rChangeCurrRing(destRing);
259  destIdeal= NULL;
260  return destIdeal;
261  break;
262 
263  default:
264  rChangeCurrRing(destRing);
265  destIdeal= idInit(1,1);
266  return destIdeal;
267  }
268 
269 
270  return NULL;

◆ walkConsistency()

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

Definition at line 54 of file walkProc.cc.

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

◆ walkProc()

ideal walkProc ( leftv  first,
leftv  second 
)

Definition at line 54 of file walk_ip.cc.

56 {
57  WalkState state = WalkOk;
58  BITSET save1,save2;
59  SI_SAVE_OPT(save1,save2);
60  si_opt_1 &= (~Sy_bit(OPT_REDSB)); //make sure option noredSB is set
61 
62  ring destRing = currRing;
63  ideal destIdeal = NULL;
64  idhdl sourceRingHdl = (idhdl)first->data;
65  ring sourceRing = IDRING(sourceRingHdl);
66  rChangeCurrRing( sourceRing );
67 
68  if(state==WalkOk)
69  {
70  int * vperm = (int *)omAlloc0( (currRing->N+1)*sizeof( int ) );
71  state= walkConsistency( sourceRing, destRing, vperm );
72  omFreeSize( (ADDRESS)vperm, (currRing->N+1)*sizeof(int) );
73  }
74 
75  int64vec* currw64=rGetGlobalOrderWeightVec(sourceRing);
76  int64vec* destVec64=rGetGlobalOrderWeightVec(destRing);
77 
78  ideal sourceIdeal;
79  BOOLEAN sourcIdealIsSB=FALSE;
80  if ( state == WalkOk )
81  {
82  idhdl ih = currRing->idroot->get( second->Name(), myynest );
83  if ( (ih != NULL) && (IDTYP(ih)==IDEAL_CMD) )
84  {
85  sourceIdeal = idCopy(IDIDEAL( ih ));
86  if(hasFlag((leftv)ih,FLAG_STD)){
87  sourcIdealIsSB=TRUE;
88  }
89  }
90  else
91  {
92  state=WalkNoIdeal;
93  }
94  }
95 
96  if ( state == WalkOk )
97  {
98  // Now the settings are compatible with Walk
99  state=walk64(sourceIdeal,currw64,destRing,destVec64,
100  destIdeal,sourcIdealIsSB);
101  }
102 
103  SI_RESTORE_OPT(save1,save2);//making sure options are as before function call
104 
105  ring almostDestRing=currRing;
106  rChangeCurrRing(destRing);
107 
108  switch (state) {
109  case WalkOk:
110  destIdeal=idrMoveR(destIdeal,currRing,almostDestRing);
111  break;
112 
114  Werror("ring %s and current ring are incompatible\n",
115  first->Name() );
116  destIdeal= NULL;
117  break;
118 
120  WerrorS( "Order of basering not allowed,\n must be a combination of a,A,lp,dp,Dp,wp,Wp,M and C.\n");
121  destIdeal= NULL;
122  break;
123 
125  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());
126  rChangeCurrRing(destRing);
127  destIdeal= NULL;
128  break;
129 
130  case WalkNoIdeal:
131  Werror( "Can't find ideal %s in ring %s.\n",
132  second->Name(), first->Name() );
133  destIdeal= NULL;
134  break;
135 
136  case WalkOverFlowError:
137  WerrorS( "Overflow occurred.\n");
138  destIdeal= NULL;
139  break;
140 
141  default:
142  destIdeal= NULL;
143  }
144 
145  return destIdeal;
FALSE
#define FALSE
Definition: auxiliary.h:94
idCopy
ideal idCopy(ideal A)
Definition: ideals.h:59
OPT_REDSB
#define OPT_REDSB
Definition: options.h:74
k
int k
Definition: cfEzgcd.cc:92
rChangeCurrRing
void rChangeCurrRing(ring r)
Definition: polys.cc:15
fractalWalk64
WalkState fractalWalk64(ideal sourceIdeal, ring destRing, ideal &destIdeal, BOOLEAN sourceIsSB, BOOLEAN unperturbedStartVectorStrategy)
Definition: walkMain.cc:614
ADDRESS
void * ADDRESS
Definition: auxiliary.h:133
BITSET
#define BITSET
Definition: structs.h:17
WalkIncompatibleRings
Definition: walkMain.h:9
walkConsistency
WalkState walkConsistency(ring sring, ring dring, int *vperm)
Definition: walkProc.cc:54
sleftv
Class used for (list of) interpreter objects.
Definition: subexpr.h:81
idhdl
idrec * idhdl
Definition: ring.h:20
ringorder_C
Definition: ring.h:79
WalkOverFlowError
Definition: walkMain.h:11
ringorder_Wp
Definition: ring.h:88
WalkNoIdeal
Definition: walkMain.h:8
currRing
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
rVar
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:582
fractalWalkConsistency
WalkState fractalWalkConsistency(ring sring, ring dring, int *vperm)
Definition: walkProc.cc:221
TRUE
#define TRUE
Definition: auxiliary.h:98
i
int i
Definition: cfEzgcd.cc:125
hasFlag
#define hasFlag(A, F)
Definition: ipid.h:106
rChar
int rChar(ring r)
Definition: ring.cc:687
rHasLocalOrMixedOrdering
BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition: ring.h:751
idrMoveR
ideal idrMoveR(ideal &id, ring src_r, ring dest_r)
Definition: prCopy.cc:248
int64vec
Definition: int64vec.h:16
ringorder_Dp
Definition: ring.h:86
Sy_bit
#define Sy_bit(x)
Definition: options.h:31
omFreeSize
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:258
BOOLEAN
int BOOLEAN
Definition: auxiliary.h:85
WalkState
WalkState
Definition: walkMain.h:7
ringorder_M
Definition: ring.h:80
IDEAL_CMD
Definition: grammar.cc:283
SI_RESTORE_OPT
#define SI_RESTORE_OPT(A, B)
Definition: options.h:23
sleftv::data
void * data
Definition: subexpr.h:87
rPar
static int rPar(const ring r)
(r->cf->P)
Definition: ring.h:589
myynest
int myynest
Definition: febase.cc:40
IDTYP
#define IDTYP(a)
Definition: ipid.h:113
ringorder_lp
Definition: ring.h:83
IDRING
#define IDRING(a)
Definition: ipid.h:121
ringorder_dp
Definition: ring.h:84
walk64
WalkState walk64(ideal I, int64vec *currw64, ring destRing, int64vec *destVec64, ideal &destIdeal, BOOLEAN sourceIsSB)
Definition: walkMain.cc:222
idrec
Definition: idrec.h:33
ringorder_a
Definition: ring.h:76
Werror
void Werror(const char *fmt,...)
Definition: reporter.cc:188
idInit
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:36
WerrorS
void WerrorS(const char *s)
Definition: feFopen.cc:24
NULL
#define NULL
Definition: omList.c:9
maFindPerm
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:164
sortRedSB
ideal sortRedSB(ideal G)
Definition: walkSupport.cc:1146
ringorder_wp
Definition: ring.h:87
WalkIncompatibleDestRing
Definition: walkMain.h:28
rGetGlobalOrderWeightVec
int64vec * rGetGlobalOrderWeightVec(ring r)
Definition: walkSupport.cc:1094
SI_SAVE_OPT
#define SI_SAVE_OPT(A, B)
Definition: options.h:20
sleftv::Name
const char * Name()
Definition: subexpr.h:119
WalkIncompatibleSourceRing
Definition: walkMain.h:29
ringorder_a64
for int64 weights
Definition: ring.h:77
FLAG_STD
#define FLAG_STD
Definition: ipid.h:103
omAlloc0
#define omAlloc0(size)
Definition: omAllocDecl.h:209
WalkOk
Definition: walkMain.h:30
rSetHdl
void rSetHdl(idhdl h)
Definition: ipshell.cc:5049
IDIDEAL
#define IDIDEAL(a)
Definition: ipid.h:127
si_opt_1
unsigned si_opt_1
Definition: options.c:5