My Project
Loading...
Searching...
No Matches
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 220 of file walkProc.cc.

221{
222 int k;
223 WalkState state= WalkOk;
224
225 if ( rChar(sring) != rChar(dring) )
226 {
227 WerrorS( "rings must have same characteristic" );
229 }
230
231 if ( (rHasLocalOrMixedOrdering(sring))
232 || (rHasLocalOrMixedOrdering(dring)) )
233 {
234 WerrorS( "only works for global orderings" );
236 }
237
238 if ( rVar(sring) != rVar(dring) )
239 {
240 WerrorS( "rings must have same number of variables" );
242 }
243
244 if ( rPar(sring) != rPar(dring) )
245 {
246 WerrorS( "rings must have same number of parameters" );
248 }
249
250 if ( state != WalkOk ) return state;
251
252 // now the rings have the same number of variables resp. parameters.
253 // check if the names of the variables resp. parameters do agree:
254 int nvar = sring->N;
255 int npar = rPar(sring);
256 int * pperm;
257 char **snames;
258 char **dnames;
259
260 if ( npar > 0 )
261 {
262 snames=sring->cf->extRing->names;
263 dnames=dring->cf->extRing->names;
264 pperm= (int *)omAlloc0( (npar+1)*sizeof( int ) );
265 }
266 else
267 {
268 pperm= NULL;
269 snames=NULL;
270 dnames=NULL;
271 }
272
273 maFindPerm( sring->names, nvar, snames, npar,
274 dring->names, nvar, dnames, npar, vperm, pperm,
275 dring->cf->type);
276
277 for ( k= nvar; (k > 0) && (state == WalkOk); k-- )
278 if ( vperm[k] <= 0 )
279 {
280 WerrorS( "variable names do not agree" );
282 }
283
284 for ( k= npar; (k > 0) && (state == WalkOk); k-- )
285 if ( pperm[k-1] >= 0 )
286 {
287 WerrorS( "parameter names do not agree" );
289 }
290
291 //check if order of variables resp. parameters does agree
292 //remove this to if you want to allow permutations of variables
293 for ( k= nvar; (k > 0) && (state == WalkOk); k-- )
294 if ( vperm[k] != (k) )
295 {
296 WerrorS( "orders of variables do not agree" );
298 }
299
300 //remove this to if you want to allow permutations of parameters
301 for ( k= npar; (k > 0) && (state == WalkOk); k-- )
302 if ( pperm[k-1] != (-k) )
303 {
304 WerrorS( "orders of parameters do not agree" );
306 }
307
308 if (pperm != NULL)
309 omFreeSize( (ADDRESS)pperm, (npar+1)*sizeof( int ) );
310
311 if ( state != WalkOk ) return state;
312
313 // check if any of the rings are qrings or not
314 if ( (sring->qideal != NULL) || (dring->qideal != NULL) )
315 {
316 WerrorS( "rings are not allowed to be qrings");
318 }
319
320 int i=0;
321 while(dring->order[i]!=0){
322 if( !(dring->order[i]==ringorder_lp) &&
323 !(dring->order[i]==ringorder_dp) &&
324 !(dring->order[i]==ringorder_Dp) &&
325 !(dring->order[i]==ringorder_wp) &&
326 !(dring->order[i]==ringorder_Wp) &&
327 !(dring->order[i]==ringorder_C) &&
328 !(dring->order[0]==ringorder_M)
329 )
330 {
332 }
333 i++;
334 }
335
336 i=0;
337 while(sring->order[i]!=0)
338 {
339 if( !(sring->order[i]==ringorder_lp) &&
340 !(sring->order[i]==ringorder_dp) &&
341 !(sring->order[i]==ringorder_Dp) &&
342 !(sring->order[i]==ringorder_wp) &&
343 !(sring->order[i]==ringorder_Wp) &&
344 !(sring->order[i]==ringorder_C) &&
345 !(dring->order[0]==ringorder_M)
346 )
347 {
349 }
350 i++;
351 }
352
353 return state;
354}
void * ADDRESS
Definition: auxiliary.h:119
int i
Definition: cfEzgcd.cc:132
int k
Definition: cfEzgcd.cc:99
void WerrorS(const char *s)
Definition: feFopen.cc:24
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:163
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omAlloc0(size)
Definition: omAllocDecl.h:211
#define NULL
Definition: omList.c:12
int rChar(ring r)
Definition: ring.cc:713
static int rPar(const ring r)
(r->cf->P)
Definition: ring.h:599
@ ringorder_lp
Definition: ring.h:77
@ ringorder_C
Definition: ring.h:73
@ ringorder_Dp
Definition: ring.h:80
@ ringorder_dp
Definition: ring.h:78
@ ringorder_Wp
Definition: ring.h:82
@ ringorder_wp
Definition: ring.h:81
@ ringorder_M
Definition: ring.h:74
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:592
BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition: ring.h:760
WalkState
Definition: walkMain.h:7
@ WalkIncompatibleDestRing
Definition: walkMain.h:28
@ WalkIncompatibleRings
Definition: walkMain.h:9
@ WalkOk
Definition: walkMain.h:30
@ WalkIncompatibleSourceRing
Definition: walkMain.h:29

◆ fractalWalkProc()

ideal fractalWalkProc ( leftv  first,
leftv  second 
)

Definition at line 161 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
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;
271}
int BOOLEAN
Definition: auxiliary.h:87
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
Definition: idrec.h:35
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
const char * Name()
Definition: subexpr.h:120
void * data
Definition: subexpr.h:88
VAR int myynest
Definition: febase.cc:41
@ IDEAL_CMD
Definition: grammar.cc:284
#define hasFlag(A, F)
Definition: ipid.h:112
#define IDIDEAL(a)
Definition: ipid.h:133
#define IDTYP(a)
Definition: ipid.h:119
#define FLAG_STD
Definition: ipid.h:106
void rSetHdl(idhdl h)
Definition: ipshell.cc:5126
VAR unsigned si_opt_1
Definition: options.c:5
#define SI_SAVE_OPT(A, B)
Definition: options.h:20
#define OPT_REDSB
Definition: options.h:77
#define SI_RESTORE_OPT(A, B)
Definition: options.h:23
void rChangeCurrRing(ring r)
Definition: polys.cc:15
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
ideal idrMoveR(ideal &id, ring src_r, ring dest_r)
Definition: prCopy.cc:248
void Werror(const char *fmt,...)
Definition: reporter.cc:189
idrec * idhdl
Definition: ring.h:21
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
#define BITSET
Definition: structs.h:16
WalkState fractalWalk64(ideal sourceIdeal, ring destRing, ideal &destIdeal, BOOLEAN sourceIsSB, BOOLEAN unperturbedStartVectorStrategy)
Definition: walkMain.cc:614
@ WalkOverFlowError
Definition: walkMain.h:11
@ WalkNoIdeal
Definition: walkMain.h:8
WalkState fractalWalkConsistency(ring sring, ring dring, int *vperm)
Definition: walkProc.cc:220
ideal sortRedSB(ideal G)

◆ walkConsistency()

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

Definition at line 53 of file walkProc.cc.

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

◆ walkProc()

ideal walkProc ( leftv  first,
leftv  second 
)

Definition at line 55 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
137 WerrorS( "Overflow occurred.\n");
138 destIdeal= NULL;
139 break;
140
141 default:
142 destIdeal= NULL;
143 }
144
145 return destIdeal;
146}
ideal idCopy(ideal A)
Definition: ideals.h:60
#define IDRING(a)
Definition: ipid.h:127
WalkState walk64(ideal I, int64vec *currw64, ring destRing, int64vec *destVec64, ideal &destIdeal, BOOLEAN sourceIsSB)
Definition: walkMain.cc:222
WalkState walkConsistency(ring sring, ring dring, int *vperm)
Definition: walkProc.cc:53
int64vec * rGetGlobalOrderWeightVec(ring r)