source: git/kernel/walkProc.cc @ 2f2bb21

spielwiese
Last change on this file since 2f2bb21 was b9642b1, checked in by Hans Schönemann <hannes@…>, 15 years ago
*hannes: remove OrdSgn, part 1 git-svn-id: file:///usr/local/Singular/svn/trunk@11277 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 10.4 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/* $Id: walkProc.cc,v 1.2 2009-01-06 13:59:36 Singular Exp $ */
5
6#include "mod2.h"
7#include "structs.h"
8#include "structs.h"
9#include "polys.h"
10#include "ideals.h"
11#include "ring.h"
12#include "febase.h"
13#include "maps.h"
14#include "omalloc.h"
15#include "kstd1.h"
16#include "fglm.h"
17#include "walkMain.h"
18#include "walkSupport.h"
19#include "walkProc.h"
20#include "prCopy.h"
21
22///////////////////////////////////////////////////////////////////
23//Frame procedures for Groebner Walk and Fractal Walk
24///////////////////////////////////////////////////////////////////
25//v1.3 2004-11-15
26///////////////////////////////////////////////////////////////////
27//implemented by Henrik Strohmayer
28///////////////////////////////////////////////////////////////////
29
30
31///////////////////////////////////////////////////////////////////
32//walkConsistency
33///////////////////////////////////////////////////////////////////
34//Description:
35// Checks if the two rings sringHdl and dringHdl are compatible
36// enough to be used for the Walk. This means:
37// 1) Same Characteristic
38// 2) globalOrderings in both rings,
39// 3) Same number of variables
40// 4) same number of parameters
41// 5) variables in one ring have the same names
42//    and order as variables of the other
43// 6) parameters in one ring have the same names
44//    and order as parameters of the other
45// 7) none of the rings are qrings
46// vperm must be a vector of length pVariables+1, initialized by 0.
47// If both rings are compatible, it stores the permutation of the
48// variables if mapped from sringHdl to dringHdl.
49// if the rings are compatible, it returns WalkOk.
50// Should be called with currRing= IDRING( sringHdl );
51///////////////////////////////////////////////////////////////////
52//Uses: IDRING,WerrorS,rPar,omAlloc0,maFindPerm,omFreeSize,sizeof
53///////////////////////////////////////////////////////////////////
54
55WalkState
56walkConsistency( idhdl sringHdl, idhdl dringHdl, int * vperm )
57{
58    int k;
59    WalkState state= WalkOk;
60    ring dring = IDRING( dringHdl );
61    ring sring = IDRING( sringHdl );
62
63    if ( rChar(sring) != rChar(dring) )
64    {
65        WerrorS( "rings must have same characteristic" );
66        state= WalkIncompatibleRings;
67    }
68    else if ( (rHasLocalOrMixedOrdering(sring))
69    || (rHasLocalOrMixedOrdering(dring)) )
70    {
71        WerrorS( "only works for global orderings" );
72        state= WalkIncompatibleRings;
73    }
74    else if ( sring->N != dring->N )
75    {
76        WerrorS( "rings must have same number of variables" );
77        state= WalkIncompatibleRings;
78    }
79    else if ( rPar(sring) != rPar(dring) )
80    {
81        WerrorS( "rings must have same number of parameters" );
82        state= WalkIncompatibleRings;
83    }
84
85    if ( state != WalkOk ) return state;
86    // now the rings have the same number of variables resp. parameters.
87    // check if the names of the variables resp. parameters do agree:
88
89    int nvar = rVar(sring);
90    int npar = rPar(sring);
91    int * pperm;
92    if ( npar > 0 )
93        pperm= (int *)omAlloc0( (npar+1)*sizeof( int ) );
94    else
95        pperm= NULL;
96
97    maFindPerm( sring->names, nvar, sring->parameter, npar,
98                dring->names, nvar, dring->parameter, npar, vperm, pperm,
99                dring->ch);
100
101    for ( k= nvar; (k > 0) && (state == WalkOk); k-- )
102        if ( vperm[k] <= 0 )
103        {
104            WerrorS( "variable names do not agree" );
105            state= WalkIncompatibleRings;
106        }
107
108    for ( k= npar-1; (k >= 0) && (state == WalkOk); k-- )
109        if ( pperm[k] >= 0 )
110        {
111            WerrorS( "paramater names do not agree" );
112            state= WalkIncompatibleRings;
113        }
114
115    //remove this to if you want to allow permutations of variables
116    for ( k= nvar; (k > 0) && (state == WalkOk); k-- )
117      if ( vperm[k] != (k) )
118      {
119        WerrorS( "orders of variables do not agree" );
120        state= WalkIncompatibleRings;
121      }
122
123    //remove this to if you want to allow permutations of parameters
124    for ( k= npar; (k > 0) && (state == WalkOk); k-- )
125      if ( pperm[k-1] != (-k) )
126      {
127        WerrorS( "orders of parameters do not agree" );
128        state= WalkIncompatibleRings;
129      }
130
131      if (pperm != NULL)
132        omFreeSize( (ADDRESS)pperm, (npar+1)*sizeof( int ) );
133
134    if ( state != WalkOk ) return state;
135
136    // check if any of the rings are qrings or not
137    if ( (sring->qideal != NULL) || (dring->qideal != NULL) )
138    {
139          WerrorS( "rings are not allowed to be qrings");
140          return WalkIncompatibleRings;
141    }
142
143    int i=0;
144    while(dring->order[i]!=0)
145    {
146      if(
147           !(dring->order[i]==ringorder_a) &&
148           !(dring->order[i]==ringorder_a64) &&
149           !(dring->order[i]==ringorder_lp) &&
150           !(dring->order[i]==ringorder_dp) &&
151           !(dring->order[i]==ringorder_Dp) &&
152           !(dring->order[i]==ringorder_wp) &&
153           !(dring->order[i]==ringorder_Wp) &&
154           !(dring->order[i]==ringorder_C)  &&
155           !(dring->order[i]==ringorder_M)
156         )
157      {
158        state=WalkIncompatibleDestRing;
159      }
160      i++;
161    }
162
163    i=0;
164    while(sring->order[i]!=0)
165    {
166      if(
167           !(sring->order[i]==ringorder_a) &&
168           !(sring->order[i]==ringorder_a64) &&
169           !(sring->order[i]==ringorder_lp) &&
170           !(sring->order[i]==ringorder_dp) &&
171           !(sring->order[i]==ringorder_Dp) &&
172           !(sring->order[i]==ringorder_wp) &&
173           !(sring->order[i]==ringorder_Wp) &&
174           !(sring->order[i]==ringorder_C)  &&
175           !(sring->order[i]==ringorder_M)
176         )
177      {
178       state=WalkIncompatibleSourceRing;
179      }
180      i++;
181    }
182
183    return state;
184}
185
186///////////////////////////////////////////////////////////////////
187
188
189///////////////////////////////////////////////////////////////////
190//fractalWalkConsistency
191///////////////////////////////////////////////////////////////////
192//Description:
193// Checks if the two rings sringHdl and dringHdl are compatible
194// enough to be used for the Walk. This means:
195// 1) Same Characteristic
196// 2) globalOrderings in both rings,
197// 3) Same number of variables
198// 4) same number of parameters
199// 5) variables in one ring have the same names
200//    and order as variables of the other
201// 6) parameters in one ring have the same names
202//    and order as parameters of the other
203// 7) none of the rings are qrings
204// vperm must be a vector of length pVariables+1, initialized by 0.
205// If both rings are compatible, it stores the permutation of the
206// variables if mapped from sringHdl to dringHdl.
207// if the rings are compatible, it returns WalkOk.
208// Should be called with currRing= IDRING( sringHdl );
209///////////////////////////////////////////////////////////////////
210//Uses: IDRING,WerrorS,rPar,omAlloc0,maFindPerm,omFreeSize,sizeof
211///////////////////////////////////////////////////////////////////
212
213WalkState
214fractalWalkConsistency( idhdl sringHdl, idhdl dringHdl, int * vperm )
215{
216    int k;
217    WalkState state= WalkOk;
218    ring dring = IDRING( dringHdl );
219    ring sring = IDRING( sringHdl );
220
221    if ( rChar(sring) != rChar(dring) )
222    {
223        WerrorS( "rings must have same characteristic" );
224        state= WalkIncompatibleRings;
225    }
226
227    if ( (rHasLocalOrMixedOrdering(sring))
228    || (rHasLocalOrMixedOrdering(dring)) )
229    {
230        WerrorS( "only works for global orderings" );
231        state= WalkIncompatibleRings;
232    }
233
234    if ( rVar(sring) != rVar(dring) )
235    {
236        WerrorS( "rings must have same number of variables" );
237        state= WalkIncompatibleRings;
238    }
239
240    if ( rPar(sring) != rPar(dring) )
241    {
242        WerrorS( "rings must have same number of parameters" );
243        state= WalkIncompatibleRings;
244    }
245
246    if ( state != WalkOk ) return state;
247
248    // now the rings have the same number of variables resp. parameters.
249    // check if the names of the variables resp. parameters do agree:
250    int nvar = sring->N;
251    int npar = rPar(sring);
252    int * pperm;
253
254    if ( npar > 0 )
255        pperm= (int *)omAlloc0( (npar+1)*sizeof( int ) );
256    else
257        pperm= NULL;
258
259    maFindPerm( sring->names, nvar, sring->parameter, npar,
260                dring->names, nvar, dring->parameter, npar, vperm, pperm,
261                dring->ch);
262
263    for ( k= nvar; (k > 0) && (state == WalkOk); k-- )
264      if ( vperm[k] <= 0 )
265      {
266        WerrorS( "variable names do not agree" );
267        state= WalkIncompatibleRings;
268      }
269
270    for ( k= npar; (k > 0) && (state == WalkOk); k-- )
271      if ( pperm[k-1] >= 0 )
272      {
273        WerrorS( "parameter names do not agree" );
274        state= WalkIncompatibleRings;
275      }
276
277    //check if order of variables resp. parameters does agree
278    //remove this to if you want to allow permutations of variables
279    for ( k= nvar; (k > 0) && (state == WalkOk); k-- )
280      if ( vperm[k] != (k) )
281      {
282        WerrorS( "orders of variables do not agree" );
283        state= WalkIncompatibleRings;
284      }
285
286    //remove this to if you want to allow permutations of parameters
287    for ( k= npar; (k > 0) && (state == WalkOk); k-- )
288      if ( pperm[k-1] != (-k) )
289      {
290        WerrorS( "orders of parameters do not agree" );
291        state= WalkIncompatibleRings;
292      }
293
294    if (pperm != NULL)
295      omFreeSize( (ADDRESS)pperm, (npar+1)*sizeof( int ) );
296
297    if ( state != WalkOk ) return state;
298
299    // check if any of the rings are qrings or not
300    if ( (sring->qideal != NULL) || (dring->qideal != NULL) )
301    {
302          WerrorS( "rings are not allowed to be qrings");
303          return WalkIncompatibleRings;
304    }
305
306    int i=0;
307    while(dring->order[i]!=0){
308      if(  !(dring->order[i]==ringorder_lp) &&
309           !(dring->order[i]==ringorder_dp) &&
310           !(dring->order[i]==ringorder_Dp) &&
311           !(dring->order[i]==ringorder_wp) &&
312           !(dring->order[i]==ringorder_Wp) &&
313           !(dring->order[i]==ringorder_C)  &&
314           !(dring->order[0]==ringorder_M)
315         )
316      {
317        state=WalkIncompatibleDestRing;
318      }
319      i++;
320    }
321
322    i=0;
323    while(sring->order[i]!=0)
324    {
325      if(  !(sring->order[i]==ringorder_lp) &&
326           !(sring->order[i]==ringorder_dp) &&
327           !(sring->order[i]==ringorder_Dp) &&
328           !(sring->order[i]==ringorder_wp) &&
329           !(sring->order[i]==ringorder_Wp) &&
330           !(sring->order[i]==ringorder_C)  &&
331           !(dring->order[0]==ringorder_M)
332         )
333      {
334        state=WalkIncompatibleSourceRing;
335      }
336      i++;
337    }
338
339    return state;
340}
341
342///////////////////////////////////////////////////////////////////
343
344
Note: See TracBrowser for help on using the repository browser.