My Project
Loading...
Searching...
No Matches
walk.cc File Reference
#include "kernel/mod2.h"
#include "misc/intvec.h"
#include "Singular/cntrlc.h"
#include "misc/options.h"
#include "omalloc/omalloc.h"
#include "Singular/ipshell.h"
#include "Singular/ipconv.h"
#include "coeffs/ffields.h"
#include "coeffs/coeffs.h"
#include "Singular/subexpr.h"
#include "polys/templates/p_Procs.h"
#include "polys/monomials/maps.h"
#include "kernel/combinatorics/stairc.h"
#include "kernel/GBEngine/kutil.h"
#include "kernel/GBEngine/khstd.h"
#include "Singular/walk.h"
#include "kernel/polys.h"
#include "kernel/ideals.h"
#include "Singular/ipid.h"
#include "Singular/tok.h"
#include "coeffs/numbers.h"
#include "polys/monomials/ring.h"
#include "kernel/GBEngine/kstd1.h"
#include "polys/matpol.h"
#include "polys/weight.h"
#include "kernel/GBEngine/syz.h"
#include "Singular/lists.h"
#include "polys/prCopy.h"
#include "polys/clapsing.h"
#include "coeffs/mpr_complex.h"
#include <cmath>
#include "misc/mylimits.h"

Go to the source code of this file.

Macros

#define BUCHBERGER_ALG
 
#define CHECK_IDEAL_MWALK
 
#define INVEPS_SMALL_IN_FRACTAL
 
#define INVEPS_SMALL_IN_MPERTVECTOR
 
#define INVEPS_SMALL_IN_TRAN
 
#define FIRST_STEP_FRACTAL
 
#define MSTDCC_FRACTAL
 

Functions

BOOLEAN ErrorCheck ()
 
void Set_Error (BOOLEAN f)
 
static intset initec (int maxnr)
 
static unsigned long * initsevS (int maxnr)
 
static int * initS_2_R (int maxnr)
 
static ideal kInterRedCC (ideal F, ideal Q)
 
static void idString (ideal L, const char *st)
 
static void ivString (intvec *iv, const char *ch)
 
static long gcd (const long a, const long b)
 
static void cancel (mpz_t zaehler, mpz_t nenner)
 
static int MLmWeightedDegree (const poly p, intvec *weight)
 
static int MwalkWeightDegree (poly p, intvec *weight_vector)
 
static void MLmWeightedDegree_gmp (mpz_t result, const poly p, intvec *weight)
 
static poly MpolyInitialForm (poly g, intvec *curr_weight)
 
ideal MwalkInitialForm (ideal G, intvec *ivw)
 
static int test_w_in_ConeCC (ideal G, intvec *iv)
 
static long Mlcm (long &i1, long &i2)
 
static long MivDotProduct (intvec *a, intvec *b)
 
static intvecMivSub (intvec *a, intvec *b)
 
static intvecMExpPol (poly f)
 
int MivSame (intvec *u, intvec *v)
 
int M3ivSame (intvec *temp, intvec *u, intvec *v)
 
static ideal MstdCC (ideal G)
 
static ideal MstdhomCC (ideal G)
 
intvecMivMatrixOrder (intvec *iv)
 
intvecMivMatrixOrderRefine (intvec *iv, intvec *iw)
 
intvecMivdp (int nR)
 
intvecMivlp (int nR)
 
intvecMPertVectors (ideal G, intvec *ivtarget, int pdeg)
 
intvecMPertVectorslp (ideal G, intvec *ivtarget, int pdeg)
 
intvecMivMatrixOrderlp (int nV)
 
intvecMivMatrixOrderdp (int nV)
 
intvecMivWeightOrderlp (intvec *ivstart)
 
intvecMivWeightOrderdp (intvec *ivstart)
 
intvecMivUnit (int nV)
 
intvecMfpertvector (ideal G, intvec *ivtarget)
 
static ideal MidMult (ideal A, ideal B)
 
static ideal MLifttwoIdeal (ideal Gw, ideal M, ideal G)
 
static int MivComp (intvec *iva, intvec *ivb)
 
static int MivAbsMax (intvec *vec)
 
static int MivAbsMaxArg (intvec *vec)
 
static intvecMwalkNextWeightCC (intvec *curr_weight, intvec *target_weight, ideal G)
 
intvecMkInterRedNextWeight (intvec *iva, intvec *ivb, ideal G)
 
static ring VMrDefault (intvec *va)
 
static ring VMrRefine (intvec *va, intvec *vb)
 
static ring VMatrDefault (intvec *va)
 
static ring VMatrRefine (intvec *va, intvec *vb)
 
static void VMrDefaultlp (void)
 
static void DefRingPar (intvec *va)
 
static void DefRingParlp (void)
 
static int isNegNolVector (intvec *hilb)
 
static ideal middleOfCone (ideal G, ideal Gomega)
 
static ideal LastGB (ideal G, intvec *curr_weight, int tp_deg)
 
static int lengthpoly (ideal G)
 
static int maxlengthpoly (ideal G)
 
static int islengthpoly2 (ideal G)
 
static ideal idHeadCC (ideal h)
 
static int test_G_GB_walk (ideal H0, ideal H1)
 
static ideal Rec_LastGB (ideal G, intvec *curr_weight, intvec *orig_target_weight, int tp_deg, int npwinc)
 
ideal MAltwalk2 (ideal Go, intvec *curr_weight, intvec *target_weight)
 
static intvecNewVectorlp (ideal I)
 
static intvecMWalkRandomNextWeight (ideal G, intvec *orig_M, intvec *target_weight, int weight_rad, int pert_deg)
 
static ideal REC_GB_Mwalk (ideal G, intvec *curr_weight, intvec *orig_target_weight, int tp_deg, int npwinc)
 
ideal MwalkAlt (ideal Go, intvec *curr_weight, intvec *target_weight)
 
ideal Mwalk (ideal Go, intvec *orig_M, intvec *target_M, ring baseRing, int reduction, int printout)
 
ideal Mrwalk (ideal Go, intvec *orig_M, intvec *target_M, int weight_rad, int pert_deg, int reduction, int printout)
 
ideal Mpwalk (ideal Go, int op_deg, int tp_deg, intvec *curr_weight, intvec *target_weight, int nP, int reduction, int printout)
 
ideal Mprwalk (ideal Go, intvec *orig_M, intvec *target_M, int weight_rad, int op_deg, int tp_deg, int nP, int reduction, int printout)
 
intvecMMatrixone (int nV)
 
static ideal rec_fractal_call (ideal G, int nlev, intvec *ivtarget, int reduction, int printout)
 
static ideal rec_r_fractal_call (ideal G, int nlev, intvec *ivtarget, int weight_rad, int reduction, int printout)
 
ideal Mfwalk (ideal G, intvec *ivstart, intvec *ivtarget, int reduction, int printout)
 
ideal Mfrwalk (ideal G, intvec *ivstart, intvec *ivtarget, int weight_rad, int reduction, int printout)
 
ideal TranMImprovwalk (ideal G, intvec *curr_weight, intvec *target_tmp, int nP)
 
static ideal Mpwalk_MAltwalk1 (ideal Go, intvec *curr_weight, int tp_deg)
 
ideal MAltwalk1 (ideal Go, int op_deg, int tp_deg, intvec *curr_weight, intvec *target_weight)
 

Variables

VAR int nstep
 kstd2.cc
 
EXTERN_VAR BOOLEAN pSetm_error
 
VAR BOOLEAN Overflow_Error = FALSE
 
VAR int Xnlev
 
VAR int ngleich
 
VAR intvecXsigma
 
VAR intvecXtau
 
VAR int xn
 
VAR intvecXivinput
 
VAR intvecXivlp
 
VAR intvecXivNull
 
VAR int nnflow
 
VAR int Xcall
 
VAR int Xngleich
 

Macro Definition Documentation

◆ BUCHBERGER_ALG

#define BUCHBERGER_ALG

Definition at line 11 of file walk.cc.

◆ CHECK_IDEAL_MWALK

#define CHECK_IDEAL_MWALK

Definition at line 18 of file walk.cc.

◆ FIRST_STEP_FRACTAL

#define FIRST_STEP_FRACTAL

Definition at line 27 of file walk.cc.

◆ INVEPS_SMALL_IN_FRACTAL

#define INVEPS_SMALL_IN_FRACTAL

Definition at line 23 of file walk.cc.

◆ INVEPS_SMALL_IN_MPERTVECTOR

#define INVEPS_SMALL_IN_MPERTVECTOR

Definition at line 24 of file walk.cc.

◆ INVEPS_SMALL_IN_TRAN

#define INVEPS_SMALL_IN_TRAN

Definition at line 25 of file walk.cc.

◆ MSTDCC_FRACTAL

#define MSTDCC_FRACTAL

Definition at line 28 of file walk.cc.

Function Documentation

◆ cancel()

static void cancel ( mpz_t zaehler,
mpz_t nenner )
static

Definition at line 589 of file walk.cc.

590{
591// assume(zaehler >= 0 && nenner > 0);
592 mpz_t g;
593 mpz_init(g);
594 mpz_gcd(g, zaehler, nenner);
595
596 mpz_div(zaehler , zaehler, g);
597 mpz_div(nenner , nenner, g);
598
599 mpz_clear(g);
600}
g
Definition cfModGcd.cc:4098

◆ DefRingPar()

static void DefRingPar ( intvec * va)
static

Definition at line 2940 of file walk.cc.

2941{
2942 int nv = currRing->N;
2943 int nb = rBlocks(currRing) + 1;
2944
2946
2947 /*weights: entries for 3 blocks: NULL Made:???*/
2948 res->wvhdl = (int **)omAlloc0(nb * sizeof(int_ptr));
2949 res->wvhdl[0] = (int*) omAlloc(nv*sizeof(int));
2950 for(int i=0; i<nv; i++)
2951 res->wvhdl[0][i] = (*va)[i];
2952
2953 /* order: a,lp,C,0 */
2954
2955 res->order = (rRingOrder_t *) omAlloc(nb * sizeof(rRingOrder_t *));
2956 res->block0 = (int *)omAlloc0(nb * sizeof(int *));
2957 res->block1 = (int *)omAlloc0(nb * sizeof(int *));
2958
2959 // ringorder a for the first block: var 1..nv
2960 res->order[0] = ringorder_a;
2961 res->block0[0] = 1;
2962 res->block1[0] = nv;
2963
2964 // ringorder lp for the second block: var 1..nv
2965 res->order[1] = ringorder_lp;
2966 res->block0[1] = 1;
2967 res->block1[1] = nv;
2968
2969 // ringorder C for the third block
2970 // it is very important within "idLift",
2971 // especially, by ring syz_ring=rCurrRingAssure_SyzComp();
2972 // therefore, nb must be (nBlocks(currRing) + 1)
2973 res->order[2] = ringorder_C;
2974
2975 // the last block: everything is 0
2976 res->order[3] = (rRingOrder_t)0;
2977
2978 // polynomial ring
2979 res->OrdSgn = 1;
2980
2981
2982 // complete ring intializations
2983 rComplete(res);
2984
2985 // execute the created ring
2987}
#define FALSE
Definition auxiliary.h:97
int i
Definition cfEzgcd.cc:132
CanonicalForm res
Definition facAbsFact.cc:60
#define omAlloc(size)
#define omAlloc0(size)
void rChangeCurrRing(ring r)
Definition polys.cc:16
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
BOOLEAN rComplete(ring r, int force)
this needs to be called whenever a new ring is created: new fields in ring are created (like VarOffse...
Definition ring.cc:3526
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition ring.cc:1426
static int rBlocks(const ring r)
Definition ring.h:574
rRingOrder_t
order stuff
Definition ring.h:69
@ ringorder_lp
Definition ring.h:78
@ ringorder_a
Definition ring.h:71
@ ringorder_C
Definition ring.h:74
int * int_ptr
Definition structs.h:50

◆ DefRingParlp()

static void DefRingParlp ( void )
static

Definition at line 2989 of file walk.cc.

2990{
2991 int nv = currRing->N;
2992
2993 ring r=rCopy0(currRing,FALSE,FALSE);
2994
2995 int nb = rBlocks(currRing) + 1;
2996
2997 /*weights: entries for 3 blocks: NULL Made:???*/
2998
2999 r->wvhdl = (int **)omAlloc0(nb * sizeof(int_ptr));
3000
3001 /* order: lp,C,0 */
3002 r->order = (rRingOrder_t *) omAlloc(nb * sizeof(rRingOrder_t *));
3003 r->block0 = (int *)omAlloc0(nb * sizeof(int *));
3004 r->block1 = (int *)omAlloc0(nb * sizeof(int *));
3005
3006 /* ringorder lp for the first block: var 1..nv */
3007 r->order[0] = ringorder_lp;
3008 r->block0[0] = 1;
3009 r->block1[0] = nv;
3010
3011 /* ringorder C for the second block */
3012 r->order[1] = ringorder_C;
3013
3014 /* the last block: everything is 0 */
3015 r->order[2] = (rRingOrder_t)0;
3016
3017 /*polynomial ring*/
3018 r->OrdSgn = 1;
3019
3020
3021// if (rParameter(currRing)!=NULL)
3022// {
3023// r->cf->extRing->qideal->m[0]=p_Copy(currRing->cf->extRing->qideal->m[0], currRing->cf->extRing);
3024// int l=rPar(currRing);
3025// r->cf->extRing->names=(char **)omAlloc(l*sizeof(char_ptr));
3026//
3027// for(int i=l-1;i>=0;i--)
3028// {
3029// rParameter(r)[i]=omStrDup(rParameter(currRing)[i]);
3030// }
3031// }
3032
3033 // complete ring intializations
3034
3035 rComplete(r);
3036
3037 // execute the created ring
3038 rChangeCurrRing(r);
3039}

◆ ErrorCheck()

BOOLEAN ErrorCheck ( )
extern

◆ gcd()

static long gcd ( const long a,
const long b )
inlinestatic

Definition at line 533 of file walk.cc.

534{
535 long r, p0 = a, p1 = b;
536 //assume(p0 >= 0 && p1 >= 0);
537 if(p0 < 0)
538 {
539 p0 = -p0;
540 }
541 if(p1 < 0)
542 {
543 p1 = -p1;
544 }
545 while(p1 != 0)
546 {
547 r = p0 % p1;
548 p0 = p1;
549 p1 = r;
550 }
551 return p0;
552}
CanonicalForm b
Definition cfModGcd.cc:4111

◆ idHeadCC()

static ideal idHeadCC ( ideal h)
static

Definition at line 3514 of file walk.cc.

3515{
3516 int i, nH =IDELEMS(h);
3517
3518 ideal m = idInit(nH,h->rank);
3519
3520 for (i=nH-1;i>=0; i--)
3521 {
3522 if (h->m[i]!=NULL)
3523 {
3524 m->m[i]=pHead(h->m[i]);
3525 }
3526 }
3527 return m;
3528}
int m
Definition cfEzgcd.cc:128
STATIC_VAR Poly * h
Definition janet.cc:971
#define NULL
Definition omList.c:12
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL
Definition polys.h:68
ideal idInit(int idsize, int rank)
initialise an ideal / module
#define IDELEMS(i)

◆ idString()

static void idString ( ideal L,
const char * st )
static

Definition at line 425 of file walk.cc.

426{
427 int i, nL = IDELEMS(L);
428
429 Print("\n// ideal %s = ", st);
430 for(i=0; i<nL-1; i++)
431 {
432 Print(" %s, ", pString(L->m[i]));
433 }
434 Print(" %s;", pString(L->m[nL-1]));
435}
#define Print
Definition emacs.cc:80
char * pString(poly p)
Definition polys.h:307

◆ initec()

static intset initec ( int maxnr)
inlinestatic

Definition at line 98 of file walk.cc.

99{
100 return (intset)omAlloc(maxnr*sizeof(int));
101}
int * intset
Definition kutil.h:54

◆ initS_2_R()

static int * initS_2_R ( int maxnr)
inlinestatic

Definition at line 107 of file walk.cc.

108{
109 return (int*)omAlloc0(maxnr*sizeof(int));
110}

◆ initsevS()

static unsigned long * initsevS ( int maxnr)
inlinestatic

Definition at line 103 of file walk.cc.

104{
105 return (unsigned long*)omAlloc0(maxnr*sizeof(unsigned long));
106}

◆ islengthpoly2()

static int islengthpoly2 ( ideal G)
static

Definition at line 3478 of file walk.cc.

3479{
3480 int i;
3481 for(i=IDELEMS(G)-1; i>=0; i--)
3482 {
3483 if((G->m[i]!=NULL) /* len >=0 */
3484 && (G->m[i]->next!=NULL) /* len >=1 */
3485 && (G->m[i]->next->next!=NULL)) /* len >=2 */
3486 {
3487 return 1;
3488 }
3489 }
3490 return 0;
3491}
STATIC_VAR TreeM * G
Definition janet.cc:31

◆ isNegNolVector()

static int isNegNolVector ( intvec * hilb)
static

Definition at line 3062 of file walk.cc.

3063{
3064 int i;
3065 for(i=hilb->length()-1; i>=0; i--)
3066 {
3067 if((* hilb)[i]<=0)
3068 {
3069 return 1;
3070 }
3071 }
3072 return 0;
3073}
int length() const
Definition intvec.h:95

◆ ivString()

static void ivString ( intvec * iv,
const char * ch )
static

Definition at line 493 of file walk.cc.

494{
495 int nV = iv->length()-1;
496 Print("\n// intvec %s = ", ch);
497
498 for(int i=0; i<nV; i++)
499 {
500 Print("%d, ", (*iv)[i]);
501 }
502 Print("%d;", (*iv)[nV]);
503}

◆ kInterRedCC()

static ideal kInterRedCC ( ideal F,
ideal Q )
static

Definition at line 269 of file walk.cc.

270{
271 int j;
272 kStrategy strat = new skStrategy;
273/*
274 if (TEST_OPT_PROT)
275 {
276 writeTime("start InterRed:");
277 mflush();
278 }
279 strat->syzComp = 0;
280*/
281 strat->kAllAxis = (currRing->ppNoether) != NULL;
282 strat->kNoether=pCopy((currRing->ppNoether));
283 strat->ak = id_RankFreeModule(F, currRing);
284 initBuchMoraCrit(strat);
285 strat->NotUsedAxis = (BOOLEAN *)omAlloc((currRing->N+1)*sizeof(BOOLEAN));
286 for(j=currRing->N; j>0; j--)
287 {
288 strat->NotUsedAxis[j] = TRUE;
289 }
290 strat->enterS = enterSBba;
291 strat->posInT = posInT0;
292 strat->initEcart = initEcartNormal;
293 strat->sl = -1;
294 strat->tl = -1;
295 strat->tmax = setmaxT;
296 strat->T = initT();
297 strat->R = initR();
298 strat->sevT = initsevT();
300 {
301 strat->honey = TRUE;
302 }
303
304 //initSCC(F,Q,strat);
305 initS(F,Q,strat);
306
307 /*
308 timetmp=clock();//22.01.02
309 initSSpecialCC(F,Q,NULL,strat);
310 tininitS=tininitS+clock()-timetmp;//22.01.02
311 */
313 {
314 strat->noTailReduction=FALSE;
315 }
316 updateS(TRUE,strat);
317
319 {
320 completeReduce(strat);
321 }
322 if(strat->kNoether!=NULL) pLmFree(&strat->kNoether);
323 omFreeSize((ADDRESS)strat->T,strat->tmax*sizeof(TObject));
324 omFreeSize((ADDRESS)strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
325 omFreeSize((ADDRESS)strat->sevS,IDELEMS(strat->Shdl)*sizeof(unsigned long));
326 omFreeSize((ADDRESS)strat->NotUsedAxis,(currRing->N+1)*sizeof(BOOLEAN));
327 omfree(strat->sevT);
328 omfree(strat->S_2_R);
329 omfree(strat->R);
330
331 if(strat->fromQ)
332 {
333 for(j=0; j<IDELEMS(strat->Shdl); j++)
334 {
335 if(strat->fromQ[j])
336 {
337 pDelete(&strat->Shdl->m[j]);
338 }
339 }
340 omFreeSize((ADDRESS)strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int));
341 strat->fromQ = NULL;
342 }
343/*
344 if (TEST_OPT_PROT)
345 {
346 writeTime("end Interred:");
347 mflush();
348 }
349*/
350 ideal shdl=strat->Shdl;
351 idSkipZeroes(shdl);
352 delete(strat);
353
354 return shdl;
355}
int BOOLEAN
Definition auxiliary.h:88
#define TRUE
Definition auxiliary.h:101
void * ADDRESS
Definition auxiliary.h:120
int * S_2_R
Definition kutil.h:343
char noTailReduction
Definition kutil.h:377
TSet T
Definition kutil.h:327
intset ecartS
Definition kutil.h:310
char honey
Definition kutil.h:376
poly kNoether
Definition kutil.h:330
BOOLEAN * NotUsedAxis
Definition kutil.h:333
int ak
Definition kutil.h:354
TObject ** R
Definition kutil.h:341
int tl
Definition kutil.h:351
unsigned long * sevT
Definition kutil.h:326
ideal Shdl
Definition kutil.h:304
int tmax
Definition kutil.h:351
char kAllAxis
Definition kutil.h:375
intset fromQ
Definition kutil.h:322
void(* enterS)(LObject &h, int pos, kStrategy strat, int atR)
Definition kutil.h:287
void(* initEcart)(TObject *L)
Definition kutil.h:281
int(* posInT)(const TSet T, const int tl, LObject &h)
Definition kutil.h:282
int sl
Definition kutil.h:349
unsigned long * sevS
Definition kutil.h:323
int j
Definition facHensel.cc:110
KINLINE TSet initT()
Definition kInline.h:84
KINLINE TObject ** initR()
Definition kInline.h:95
KINLINE unsigned long * initsevT()
Definition kInline.h:100
int posInT0(const TSet, const int length, LObject &)
Definition kutil.cc:4892
void initS(ideal F, ideal Q, kStrategy strat)
Definition kutil.cc:7590
void initEcartNormal(TObject *h)
Definition kutil.cc:1300
void updateS(BOOLEAN toT, kStrategy strat)
Definition kutil.cc:8559
void initBuchMoraCrit(kStrategy strat)
Definition kutil.cc:9435
void completeReduce(kStrategy strat, BOOLEAN withT)
Definition kutil.cc:10287
void enterSBba(LObject &p, int atS, kStrategy strat, int atR)
Definition kutil.cc:8794
#define setmaxT
Definition kutil.h:34
class sTObject TObject
Definition kutil.h:58
#define omfree(addr)
#define omFreeSize(addr, size)
#define TEST_OPT_INTSTRATEGY
Definition options.h:112
#define TEST_OPT_REDSB
Definition options.h:106
#define pDelete(p_ptr)
Definition polys.h:187
static void pLmFree(poly p)
frees the space of the monomial m, assumes m != NULL coef is not freed, m is not advanced
Definition polys.h:71
#define pCopy(p)
return a copy of the poly
Definition polys.h:186
static BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition ring.h:769
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
#define Q
Definition sirandom.c:26
skStrategy * kStrategy
Definition structs.h:54

◆ LastGB()

static ideal LastGB ( ideal G,
intvec * curr_weight,
int tp_deg )
static

Definition at line 3146 of file walk.cc.

3147{
3148 BOOLEAN nError = Overflow_Error;
3150
3151 int i, nV = currRing->N;
3152 int nwalk=0, endwalks=0, nnwinC=1;
3153 int nlast = 0;
3154 ideal Gomega, M, F, Gomega1, Gomega2, M1,F1,result,ssG;
3155 ring newRing, oldRing, TargetRing;
3156 intvec* iv_M_lp;
3157 intvec* target_weight;
3158 intvec* iv_lp = Mivlp(nV); //define (1,0,...,0)
3159 intvec* pert_target_vector;
3160 intvec* ivNull = new intvec(nV);
3161 intvec* extra_curr_weight = new intvec(nV);
3162 intvec* next_weight;
3163
3164#ifndef BUCHBERGER_ALG
3165 intvec* hilb_func;
3166#endif
3167
3168 // to avoid (1,0,...,0) as the target vector
3169 intvec* last_omega = new intvec(nV);
3170 for(i=nV-1; i>0; i--)
3171 {
3172 (*last_omega)[i] = 1;
3173 }
3174 (*last_omega)[0] = 10000;
3175
3176 ring EXXRing = currRing;
3177
3178 // compute a pertubed weight vector of the target weight vector
3179 if(tp_deg > 1 && tp_deg <= nV)
3180 {
3181 //..25.03.03 VMrDefaultlp();// VMrDefault(target_weight);
3182 if (rParameter (currRing) != NULL)
3183 {
3184 DefRingParlp();
3185 }
3186 else
3187 {
3188 VMrDefaultlp();
3189 }
3190 TargetRing = currRing;
3191 ssG = idrMoveR(G,EXXRing,currRing);
3192 iv_M_lp = MivMatrixOrderlp(nV);
3193 //target_weight = MPertVectorslp(ssG, iv_M_lp, tp_deg);
3194 target_weight = MPertVectors(ssG, iv_M_lp, tp_deg);
3195 delete iv_M_lp;
3196 pert_target_vector = target_weight;
3197
3198 rChangeCurrRing(EXXRing);
3199 G = idrMoveR(ssG, TargetRing,currRing);
3200 }
3201 else
3202 {
3203 target_weight = Mivlp(nV);
3204 }
3205 //Print("\n// ring r%d_%d = %s;\n", tp_deg, nwalk, rString(currRing));
3206
3207 while(1)
3208 {
3209 nwalk++;
3210 nstep++;
3211#ifdef TIME_TEST
3212 to=clock();
3213#endif
3214 // compute a next weight vector
3215 next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
3216#ifdef TIME_TEST
3217 xtnw=xtnw+clock()-to;
3218#endif
3219
3220#ifdef PRINT_VECTORS
3221 MivString(curr_weight, target_weight, next_weight);
3222#endif
3223
3224 if(Overflow_Error == TRUE)
3225 {
3226 newRing = currRing;
3227 nnwinC = 0;
3228 if(tp_deg == 1)
3229 {
3230 nlast = 1;
3231 }
3232 delete next_weight;
3233
3234 //idElements(G, "G");
3235 //Print("\n// ring r%d_%d = %s;\n", tp_deg, nwalk, rString(currRing));
3236
3237 break;
3238 }
3239
3240 if(MivComp(next_weight, ivNull) == 1)
3241 {
3242 //Print("\n// ring r%d_%d = %s;\n", tp_deg, nwalk, rString(currRing));
3243 newRing = currRing;
3244 delete next_weight;
3245 break;
3246 }
3247
3248 if(MivComp(next_weight, target_weight) == 1)
3249 endwalks = 1;
3250
3251 for(i=nV-1; i>=0; i--)
3252 {
3253 (*extra_curr_weight)[i] = (*curr_weight)[i];
3254 }
3255 /* 06.11.01 NOT Changed */
3256 for(i=nV-1; i>=0; i--)
3257 {
3258 (*curr_weight)[i] = (*next_weight)[i];
3259 }
3260 oldRing = currRing;
3261#ifdef TIME_TEST
3262 to=clock();
3263#endif
3264 // compute an initial form ideal of <G> w.r.t. "curr_vector"
3265 Gomega = MwalkInitialForm(G, curr_weight);
3266#ifdef TIME_TEST
3267 xtif=xtif+clock()-to;
3268#endif
3269
3270#ifdef ENDWALKS
3271 if(endwalks == 1)
3272 {
3273 Print("\n// ring r%d_%d = %s;\n", tp_deg, nwalk, rString(currRing));
3274/*
3275 idElements(Gomega, "Gw");
3276 headidString(Gomega, "Gw");
3277*/
3278 }
3279#endif
3280
3281#ifndef BUCHBERGER_ALG
3282 if(isNolVector(curr_weight) == 0)
3283 {
3284 hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing);
3285 }
3286 else
3287 {
3288 hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);
3289 }
3290#endif // BUCHBERGER_ALG
3291
3292 /* define a new ring that its ordering is "(a(curr_weight),lp) */
3293 //..25.03.03 VMrDefault(curr_weight);
3294 if (rParameter (currRing) != NULL)
3295 {
3296 DefRingPar(curr_weight);
3297 }
3298 else
3299 {
3300 rChangeCurrRing(VMrDefault(curr_weight));
3301 }
3302 newRing = currRing;
3303 Gomega1 = idrMoveR(Gomega, oldRing,currRing);
3304
3305#ifdef TIME_TEST
3306 to=clock();
3307#endif
3308 /* compute a reduced Groebner basis of <Gomega> w.r.t. "newRing" */
3309#ifdef BUCHBERGER_ALG
3310 M = MstdhomCC(Gomega1);
3311#else
3312 M=kStd2(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
3313 delete hilb_func;
3314#endif // BUCHBERGER_ALG
3315#ifdef TIME_TEST
3316 xtstd=xtstd+clock()-to;
3317#endif
3318 /* change the ring to oldRing */
3319 rChangeCurrRing(oldRing);
3320 M1 = idrMoveR(M, newRing,currRing);
3321 Gomega2 = idrMoveR(Gomega1, newRing,currRing);
3322
3323#ifdef TIME_TEST
3324 to=clock();
3325#endif
3326 /* compute a reduced Groebner basis of <G> w.r.t. "newRing" */
3327 F = MLifttwoIdeal(Gomega2, M1, G);
3328#ifdef TIME_TEST
3329 xtlift=xtlift+clock()-to;
3330#endif
3331
3332 idDelete(&M1);
3333 idDelete(&G);
3334
3335 /* change the ring to newRing */
3336 rChangeCurrRing(newRing);
3337 F1 = idrMoveR(F, oldRing,currRing);
3338
3339#ifdef TIME_TEST
3340 to=clock();
3341#endif
3342 /* reduce the Groebner basis <G> w.r.t. new ring */
3343 G = kInterRedCC(F1, NULL);
3344#ifdef TIME_TEST
3345 xtred=xtred+clock()-to;
3346#endif
3347 idDelete(&F1);
3348
3349 if(endwalks == 1)
3350 {
3351 //Print("\n// ring r%d_%d = %s;\n", tp_deg, nwalk, rString(currRing));
3352 break;
3353 }
3354
3355 delete next_weight;
3356 }//while
3357
3358 delete ivNull;
3359
3360 if(tp_deg != 1)
3361 {
3362 //..25.03.03 VMrDefaultlp();//define and execute the ring "lp"
3363 if (rParameter (currRing) != NULL)
3364 {
3365 DefRingParlp();
3366 }
3367 else
3368 {
3369 VMrDefaultlp();
3370 }
3371 F1 = idrMoveR(G, newRing,currRing);
3372
3373 if(nnwinC == 0 || test_w_in_ConeCC(F1, pert_target_vector) != 1)
3374 {
3375 oldRing = currRing;
3376 rChangeCurrRing(newRing);
3377 G = idrMoveR(F1, oldRing,currRing);
3378 Print("\n// takes %d steps and calls the recursion of level %d:",
3379 nwalk, tp_deg-1);
3380
3381 F1 = LastGB(G,curr_weight, tp_deg-1);
3382 }
3383
3384 TargetRing = currRing;
3385 rChangeCurrRing(EXXRing);
3386 result = idrMoveR(F1, TargetRing,currRing);
3387 }
3388 else
3389 {
3390 if(nlast == 1)
3391 {
3392 //OMEGA_OVERFLOW_LASTGB:
3393 /*
3394 if(MivSame(curr_weight, iv_lp) == 1)
3395 if (rParameter(currRing) != NULL)
3396 DefRingParlp();
3397 else
3398 VMrDefaultlp();
3399 else
3400 if (rParameter(currRing) != NULL)
3401 DefRingPar(curr_weight);
3402 else
3403 VMrDefault(curr_weight);
3404 */
3405
3406 //..25.03.03 VMrDefaultlp();//define and execute the ring "lp"
3407 if (rParameter (currRing) != NULL)
3408 {
3409 DefRingParlp();
3410 }
3411 else
3412 {
3413 VMrDefaultlp();
3414 }
3415
3416 F1 = idrMoveR(G, newRing,currRing);
3417 //Print("\n// Apply \"std\" in ring r%d_%d = %s;\n", tp_deg, nwalk, rString(currRing));
3418
3419 G = MstdCC(F1);
3420 idDelete(&F1);
3421 newRing = currRing;
3422 }
3423
3424 rChangeCurrRing(EXXRing);
3425 result = idrMoveR(G, newRing,currRing);
3426 }
3427 delete target_weight;
3428 delete last_omega;
3429 delete iv_lp;
3430
3431 if(Overflow_Error == FALSE)
3432 {
3433 Overflow_Error = nError;
3434 }
3435 return(result);
3436}
return result
intvec * hFirstSeries(ideal A, intvec *module_w, ideal Q, intvec *wdegree)
Definition hilb.cc:2150
#define idDelete(H)
delete an ideal
Definition ideals.h:29
ideal kStd2(ideal F, ideal Q, tHomog h, intvec **w, bigintmat *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
generic interface to GB/SB computations, large hilbert vectors
Definition kstd1.cc:2602
ideal idrMoveR(ideal &id, ring src_r, ring dest_r)
Definition prCopy.cc:248
char * rString(ring r)
Definition ring.cc:678
static char const ** rParameter(const ring r)
(r->cf->parameter)
Definition ring.h:631
#define M
Definition sirandom.c:25
@ isHomog
Definition structs.h:33
int F1(int a1, int &r1)
F1.
static ideal kInterRedCC(ideal F, ideal Q)
Definition walk.cc:269
VAR int nstep
kstd2.cc
Definition walk.cc:80
static ideal MstdhomCC(ideal G)
Definition walk.cc:948
static int MivComp(intvec *iva, intvec *ivb)
Definition walk.cc:1799
intvec * MPertVectors(ideal G, intvec *ivtarget, int pdeg)
Definition walk.cc:1089
static ideal MLifttwoIdeal(ideal Gw, ideal M, ideal G)
Definition walk.cc:1722
static ring VMrDefault(intvec *va)
Definition walk.cc:2681
static void DefRingParlp(void)
Definition walk.cc:2989
VAR BOOLEAN Overflow_Error
Definition walk.cc:88
intvec * Mivlp(int nR)
Definition walk.cc:1023
ideal MwalkInitialForm(ideal G, intvec *ivw)
Definition walk.cc:762
static ideal LastGB(ideal G, intvec *curr_weight, int tp_deg)
Definition walk.cc:3146
intvec * MivMatrixOrderlp(int nV)
Definition walk.cc:1402
intvec * MkInterRedNextWeight(intvec *iva, intvec *ivb, ideal G)
Definition walk.cc:2571
static void VMrDefaultlp(void)
Definition walk.cc:2899
static void DefRingPar(intvec *va)
Definition walk.cc:2940
static ideal MstdCC(ideal G)
Definition walk.cc:933
static int test_w_in_ConeCC(ideal G, intvec *iv)
Definition walk.cc:786

◆ lengthpoly()

static int lengthpoly ( ideal G)
static

Definition at line 3441 of file walk.cc.

3442{
3443 int i;
3444 for(i=IDELEMS(G)-1; i>=0; i--)
3445 {
3446 if((G->m[i]!=NULL) /* len >=0 */
3447 && (G->m[i]->next!=NULL) /* len >=1 */
3448 && (G->m[i]->next->next!=NULL) /* len >=2 */
3449 && (G->m[i]->next->next->next!=NULL) /* len >=3 */
3450 && (G->m[i]->next->next->next->next!=NULL) /* len >=4*/ )
3451 {
3452 return 1;
3453 }
3454 }
3455 return 0;
3456}

◆ M3ivSame()

int M3ivSame ( intvec * temp,
intvec * u,
intvec * v )

Definition at line 915 of file walk.cc.

916{
917 assume(temp->length() == u->length() && u->length() == v->length());
918
919 if((MivSame(temp, u)) == 1)
920 {
921 return 0;
922 }
923 if((MivSame(temp, v)) == 1)
924 {
925 return 1;
926 }
927 return 2;
928}
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
#define assume(x)
Definition mod2.h:389
int MivSame(intvec *u, intvec *v)
Definition walk.cc:894

◆ MAltwalk1()

ideal MAltwalk1 ( ideal Go,
int op_deg,
int tp_deg,
intvec * curr_weight,
intvec * target_weight )

Definition at line 9672 of file walk.cc.

9674{
9675 Set_Error(FALSE );
9677#ifdef TIME_TEST
9678 BOOLEAN nOverflow_Error = FALSE;
9679#endif
9680 // Print("// pSetm_Error = (%d)", ErrorCheck());
9681
9682#ifdef TIME_TEST
9683 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0; xtextra=0;
9684 xftinput = clock();
9685 clock_t tostd, tproc;
9686#endif
9687
9688 nstep = 0;
9689 int i, nV = currRing->N;
9690 int nwalk=0, endwalks=0;
9691 int op_tmp = op_deg;
9692 ideal Gomega, M, F, G, Gomega1, Gomega2, M1, F1;
9693 ring newRing, oldRing;
9694 intvec* next_weight;
9695 intvec* iv_M_dp;
9696 intvec* ivNull = new intvec(nV);
9697 intvec* iv_dp = MivUnit(nV);// define (1,1,...,1)
9698 intvec* exivlp = Mivlp(nV);
9699 //intvec* extra_curr_weight = new intvec(nV);
9700#ifndef BUCHBERGER_ALG
9701 intvec* hilb_func;
9702#endif
9703 intvec* cw_tmp = curr_weight;
9704
9705 // to avoid (1,0,...,0) as the target vector
9706 intvec* last_omega = new intvec(nV);
9707 for(i=nV-1; i>0; i--)
9708 {
9709 (*last_omega)[i] = 1;
9710 }
9711 (*last_omega)[0] = 10000;
9712
9713 ring XXRing = currRing;
9714
9715#ifdef TIME_TEST
9716 to=clock();
9717#endif
9718 /* compute a pertubed weight vector of the original weight vector.
9719 The perturbation degree is recursive decrease until that vector
9720 stays inn the correct cone. */
9721 while(1)
9722 {
9723 if(Overflow_Error == FALSE)
9724 {
9725 if(MivComp(curr_weight, iv_dp) == 1)
9726 {
9727 //rOrdStr(currRing) = "dp"
9728 if(op_tmp == op_deg)
9729 {
9730 G = MstdCC(Go);
9731 if(op_deg != 1)
9732 {
9733 iv_M_dp = MivMatrixOrderdp(nV);
9734 }
9735 }
9736 }
9737 }
9738 else
9739 {
9740 if(op_tmp == op_deg)
9741 {
9742 //rOrdStr(currRing) = (a(...),lp,C)
9743 if (rParameter(currRing) != NULL)
9744 {
9745 DefRingPar(cw_tmp);
9746 }
9747 else
9748 {
9749 rChangeCurrRing(VMrDefault(cw_tmp));
9750 }
9751 G = idrMoveR(Go, XXRing,currRing);
9752 G = MstdCC(G);
9753 if(op_deg != 1)
9754 iv_M_dp = MivMatrixOrder(cw_tmp);
9755 }
9756 }
9758 if(op_deg != 1)
9759 {
9760 curr_weight = MPertVectors(G, iv_M_dp, op_deg);
9761 }
9762 else
9763 {
9764 curr_weight = cw_tmp;
9765 break;
9766 }
9767 if(Overflow_Error == FALSE)
9768 {
9769 break;
9770 }
9772 op_deg --;
9773 }
9774#ifdef TIME_TEST
9775 tostd=clock()-to;
9776#endif
9777
9778 if(op_tmp != 1 )
9779 delete iv_M_dp;
9780 delete iv_dp;
9781
9782 if(currRing->order[0] == ringorder_a)
9783 goto NEXT_VECTOR;
9784
9785 while(1)
9786 {
9787 nwalk ++;
9788 nstep ++;
9789
9790#ifdef TIME_TEST
9791 to = clock();
9792#endif
9793 // compute an initial form ideal of <G> w.r.t. "curr_vector"
9794 Gomega = MwalkInitialForm(G, curr_weight);
9795#ifdef TIME_TEST
9796 xtif=xtif+clock()-to;
9797#endif
9798#if 0
9799 if(Overflow_Error == TRUE)
9800 {
9801 for(i=nV-1; i>=0; i--)
9802 (*curr_weight)[i] = (*extra_curr_weight)[i];
9803 delete extra_curr_weight;
9804
9805 newRing = currRing;
9806 goto MSTD_ALT1;
9807 }
9808#endif
9809#ifndef BUCHBERGER_ALG
9810 if(isNolVector(curr_weight) == 0)
9811 {
9812 hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing);
9813 }
9814 else
9815 {
9816 hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);
9817 }
9818#endif // BUCHBERGER_ALG
9819
9820 oldRing = currRing;
9821
9822 // define a new ring which ordering is "(a(curr_weight),lp)
9823 if (rParameter(currRing) != NULL)
9824 {
9825 DefRingPar(curr_weight);
9826 }
9827 else
9828 {
9829 rChangeCurrRing(VMrDefault(curr_weight));
9830 }
9831 newRing = currRing;
9832 Gomega1 = idrMoveR(Gomega, oldRing,currRing);
9833
9834#ifdef TIME_TEST
9835 to=clock();
9836#endif
9837 // compute a reduced Groebner basis of <Gomega> w.r.t. "newRing"
9838#ifdef BUCHBERGER_ALG
9839 M = MstdhomCC(Gomega1);
9840#else
9841 M=kStd2(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
9842 delete hilb_func;
9843#endif // BUCHBERGER_ALG
9844#ifdef TIME_TEST
9845 xtstd=xtstd+clock()-to;
9846#endif
9847
9848 // change the ring to oldRing
9849 rChangeCurrRing(oldRing);
9850 M1 = idrMoveR(M, newRing,currRing);
9851 Gomega2 = idrMoveR(Gomega1, newRing,currRing);
9852
9853#ifdef TIME_TEST
9854 to=clock();
9855#endif
9856 // compute a reduced Groebner basis of <G> w.r.t. "newRing" by the lifting process
9857 F = MLifttwoIdeal(Gomega2, M1, G);
9858#ifdef TIME_TEST
9859 xtlift=xtlift+clock()-to;
9860#endif
9861
9862 idDelete(&M1);
9863 idDelete(&Gomega2);
9864 idDelete(&G);
9865
9866 // change the ring to newRing
9867 rChangeCurrRing(newRing);
9868 F1 = idrMoveR(F, oldRing,currRing);
9869 if (oldRing!=IDRING(currRingHdl)) rDelete(oldRing); // do not delete the global currRing
9870 oldRing=NULL;
9871
9872#ifdef TIME_TEST
9873 to=clock();
9874#endif
9875 // reduce the Groebner basis <G> w.r.t. new ring
9876 G = kInterRedCC(F1, NULL);
9877#ifdef TIME_TEST
9878 xtred=xtred+clock()-to;
9879#endif
9880 idDelete(&F1);
9881
9882 if(endwalks == 1)
9883 {
9884 break;
9885 }
9886 NEXT_VECTOR:
9887#ifdef TIME_TEST
9888 to=clock();
9889#endif
9890 // compute a next weight vector
9891 next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
9892#ifdef TIME_TEST
9893 xtnw=xtnw+clock()-to;
9894#endif
9895#ifdef PRINT_VECTORS
9896 MivString(curr_weight, target_weight, next_weight);
9897#endif
9898 if(Overflow_Error == TRUE)
9899 {
9900 newRing = currRing;
9901
9902 if (rParameter(currRing) != NULL)
9903 {
9904 DefRingPar(target_weight);
9905 }
9906 else
9907 {
9908 rChangeCurrRing(VMrDefault(target_weight));
9909 }
9910 F1 = idrMoveR(G, newRing,currRing);
9911 G = MstdCC(F1);
9912 idDelete(&F1);
9913 newRing = currRing;
9914 break; //for while
9915 }
9916
9917
9918 /* G is the wanted Groebner basis if next_weight == curr_weight */
9919 if(MivComp(next_weight, ivNull) == 1)
9920 {
9921 newRing = currRing;
9922 delete next_weight;
9923 break; //for while
9924 }
9925
9926 if(MivComp(next_weight, target_weight) == 1)
9927 {
9928 if(tp_deg == 1 || MivSame(target_weight, exivlp) == 0)
9929 endwalks = 1;
9930 else
9931 {
9932 // MSTD_ALT1:
9933#ifdef TIME_TEST
9934 nOverflow_Error = Overflow_Error;
9935 tproc = clock()-xftinput;
9936#endif
9937
9938 //Print("\n// main routine takes %d steps and calls \"Mpwalk\" (1,%d):", nwalk, tp_deg);
9939
9940 // compute the red. GB of <G> w.r.t. the lex order by the "recursive-modified" perturbation walk alg (1,tp_deg)
9941 G = Mpwalk_MAltwalk1(G, curr_weight, tp_deg);
9942 delete next_weight;
9943 break; // for while
9944 }
9945 }
9946
9947 //NOT Changed, to free memory
9948 for(i=nV-1; i>=0; i--)
9949 {
9950 //(*extra_curr_weight)[i] = (*curr_weight)[i];
9951 (*curr_weight)[i] = (*next_weight)[i];
9952 }
9953 delete next_weight;
9954 }//while
9955
9956 rChangeCurrRing(XXRing);
9957 ideal result = idrMoveR(G, newRing,currRing);
9958 id_Delete(&G, newRing);
9959
9960 delete ivNull;
9961 if(op_deg != 1 )
9962 {
9963 delete curr_weight;
9964 }
9965 delete exivlp;
9966#ifdef TIME_TEST
9967/*
9968 Print("\n// \"Main procedure\" took %d steps, %.2f sec. and Overflow_Error(%d)",
9969 nwalk, ((double) tproc)/1000000, nOverflow_Error);
9970
9971 TimeStringFractal(xftinput, tostd, xtif, xtstd,xtextra, xtlift, xtred, xtnw);
9972*/
9973 // Print("\n// pSetm_Error = (%d)", ErrorCheck());
9974 // Print("\n// Overflow_Error? (%d)", Overflow_Error);
9975 // Print("\n// Awalk1 took %d steps.\n", nstep);
9976#endif
9977 return(result);
9978}
VAR idhdl currRingHdl
Definition ipid.cc:57
#define IDRING(a)
Definition ipid.h:127
void rDelete(ring r)
unconditionally deletes fields in r
Definition ring.cc:454
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
intvec * MivUnit(int nV)
Definition walk.cc:1497
intvec * MivMatrixOrderdp(int nV)
Definition walk.cc:1418
intvec * MivMatrixOrder(intvec *iv)
Definition walk.cc:964
void Set_Error(BOOLEAN f)
Definition walk.cc:86
static ideal Mpwalk_MAltwalk1(ideal Go, intvec *curr_weight, int tp_deg)
Definition walk.cc:9378

◆ MAltwalk2()

ideal MAltwalk2 ( ideal Go,
intvec * curr_weight,
intvec * target_weight )

Definition at line 4281 of file walk.cc.

4282{
4285 //BOOLEAN nOverflow_Error = FALSE;
4286 //Print("// pSetm_Error = (%d)", ErrorCheck());
4287#ifdef TIME_TEST
4288 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0; xtextra=0;
4289 xftinput = clock();
4290 clock_t tostd, tproc;
4291#endif
4292 nstep = 0;
4293 int i, nV = currRing->N;
4294 int nwalk=0, endwalks=0;
4295 // int nhilb = 1;
4296 ideal Gomega, M, F, Gomega1, Gomega2, M1, F1, G;
4297 //ideal G1;
4298 //ring endRing;
4299 ring newRing, oldRing;
4300 intvec* ivNull = new intvec(nV);
4301 intvec* next_weight;
4302 //intvec* extra_curr_weight = new intvec(nV);
4303 //intvec* hilb_func;
4304 intvec* exivlp = Mivlp(nV);
4305 ring XXRing = currRing;
4306
4307 //Print("\n// ring r_input = %s;", rString(currRing));
4308#ifdef TIME_TEST
4309 to = clock();
4310#endif
4311 /* compute the reduced Groebner basis of the given ideal w.r.t.
4312 a "fast" monomial order, e.g. degree reverse lex. order (dp) */
4313 G = MstdCC(Go);
4314#ifdef TIME_TEST
4315 tostd=clock()-to;
4316
4317 Print("\n// Computation of the first std took = %.2f sec",
4318 ((double) tostd)/1000000);
4319#endif
4320 if(currRing->order[0] == ringorder_a)
4321 {
4322 goto NEXT_VECTOR;
4323 }
4324 while(1)
4325 {
4326 nwalk ++;
4327 nstep ++;
4328#ifdef TIME_TEST
4329 to = clock();
4330#endif
4331 /* compute an initial form ideal of <G> w.r.t. "curr_vector" */
4332 Gomega = MwalkInitialForm(G, curr_weight);
4333#ifdef TIME_TEST
4334 xtif=xtif+clock()-to;
4335#endif
4336/*
4337 if(Overflow_Error == TRUE)
4338 {
4339 for(i=nV-1; i>=0; i--)
4340 (*curr_weight)[i] = (*extra_curr_weight)[i];
4341 delete extra_curr_weight;
4342 goto LAST_GB_ALT2;
4343 }
4344*/
4345 oldRing = currRing;
4346
4347 /* define a new ring that its ordering is "(a(curr_weight),lp) */
4348 if (rParameter(currRing) != NULL)
4349 {
4350 DefRingPar(curr_weight);
4351 }
4352 else
4353 {
4354 rChangeCurrRing(VMrDefault(curr_weight));
4355 }
4356 newRing = currRing;
4357 Gomega1 = idrMoveR(Gomega, oldRing,currRing);
4358#ifdef TIME_TEST
4359 to = clock();
4360#endif
4361 /* compute a reduced Groebner basis of <Gomega> w.r.t. "newRing" */
4362 M = MstdhomCC(Gomega1);
4363#ifdef TIME_TEST
4364 xtstd=xtstd+clock()-to;
4365#endif
4366 /* change the ring to oldRing */
4367 rChangeCurrRing(oldRing);
4368 M1 = idrMoveR(M, newRing,currRing);
4369 Gomega2 = idrMoveR(Gomega1, newRing,currRing);
4370#ifdef TIME_TEST
4371 to = clock();
4372#endif
4373 /* compute the reduced Groebner basis of <G> w.r.t. "newRing"
4374 by the liftig process */
4375 F = MLifttwoIdeal(Gomega2, M1, G);
4376#ifdef TIME_TEST
4377 xtlift=xtlift+clock()-to;
4378#endif
4379 idDelete(&M1);
4380 idDelete(&Gomega2);
4381 idDelete(&G);
4382
4383 /* change the ring to newRing */
4384 rChangeCurrRing(newRing);
4385 F1 = idrMoveR(F, oldRing,currRing);
4386#ifdef TIME_TEST
4387 to = clock();
4388#endif
4389 /* reduce the Groebner basis <G> w.r.t. newRing */
4390 G = kInterRedCC(F1, NULL);
4391#ifdef TIME_TEST
4392 xtred=xtred+clock()-to;
4393#endif
4394 idDelete(&F1);
4395
4396 if(endwalks == 1)
4397 break;
4398
4399 NEXT_VECTOR:
4400#ifdef TIME_TEST
4401 to = clock();
4402#endif
4403 /* compute a next weight vector */
4404 next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
4405#ifdef TIME_TEST
4406 xtnw=xtnw+clock()-to;
4407#endif
4408#ifdef PRINT_VECTORS
4409 MivString(curr_weight, target_weight, next_weight);
4410#endif
4411
4412 if(Overflow_Error == TRUE)
4413 {
4414 /*
4415 ivString(next_weight, "omega");
4416 PrintS("\n// ** The weight vector does NOT stay in Cone!!\n");
4417 */
4418#ifdef TEST_OVERFLOW
4419 goto TEST_OVERFLOW_OI;
4420#endif
4421
4422 newRing = currRing;
4423 if (rParameter(currRing) != NULL)
4424 {
4425 DefRingPar(target_weight);
4426 }
4427 else
4428 {
4429 rChangeCurrRing(VMrDefault(target_weight)); // Aenderung
4430 }
4431 F1 = idrMoveR(G, newRing,currRing);
4432 G = MstdCC(F1);
4433 idDelete(&F1);
4434 newRing = currRing;
4435 break;
4436 }
4437
4438 if(MivComp(next_weight, ivNull) == 1)
4439 {
4440 newRing = currRing;
4441 delete next_weight;
4442 break;
4443 }
4444
4445 if(MivComp(next_weight, target_weight) == 1)
4446 {
4447 if(MivSame(target_weight, exivlp)==1)
4448 {
4449 // LAST_GB_ALT2:
4450 //nOverflow_Error = Overflow_Error;
4451#ifdef TIME_TEST
4452 tproc = clock()-xftinput;
4453#endif
4454 //Print("\n// takes %d steps and calls the recursion of level 2:", nwalk);
4455 /* call the changed perturbation walk algorithm with degree 2 */
4456 G = Rec_LastGB(G, curr_weight, target_weight, 2,1);
4457 newRing = currRing;
4458 delete next_weight;
4459 break;
4460 }
4461 endwalks = 1;
4462 }
4463
4464 for(i=nV-1; i>=0; i--)
4465 {
4466 //(*extra_curr_weight)[i] = (*curr_weight)[i];
4467 (*curr_weight)[i] = (*next_weight)[i];
4468 }
4469 delete next_weight;
4470 }
4471#ifdef TEST_OVERFLOW
4472 TEST_OVERFLOW_OI:
4473#endif
4474 rChangeCurrRing(XXRing);
4475 G = idrMoveR(G, newRing,currRing);
4476 delete ivNull;
4477 delete exivlp;
4478
4479#ifdef TIME_TEST
4480 /*Print("\n// \"Main procedure\" took %d steps dnd %.2f sec. Overflow_Error (%d)",
4481 nwalk, ((double) tproc)/1000000, nOverflow_Error);
4482*/
4483 TimeStringFractal(xftinput, tostd, xtif, xtstd, xtextra,xtlift, xtred,xtnw);
4484
4485 //Print("\n// pSetm_Error = (%d)", ErrorCheck());
4486 //Print("\n// Overflow_Error? (%d)", nOverflow_Error);
4487 //Print("\n// Awalk2 took %d steps!!", nstep);
4488#endif
4489
4490 return(G);
4491}
static ideal Rec_LastGB(ideal G, intvec *curr_weight, intvec *orig_target_weight, int tp_deg, int npwinc)
Definition walk.cc:3934

◆ maxlengthpoly()

static int maxlengthpoly ( ideal G)
static

Definition at line 3461 of file walk.cc.

3462{
3463 int i,k,length=0;
3464 for(i=IDELEMS(G)-1; i>=0; i--)
3465 {
3466 k = pLength(G->m[i]);
3467 if(k>length)
3468 {
3469 length = k;
3470 }
3471 }
3472 return length;
3473}
int k
Definition cfEzgcd.cc:99
static BOOLEAN length(leftv result, leftv arg)
Definition interval.cc:257
static int pLength(poly a)
Definition p_polys.h:190

◆ MExpPol()

static intvec * MExpPol ( poly f)
static

Definition at line 878 of file walk.cc.

879{
880 int i, nR = currRing->N;
881 intvec* result = new intvec(nR);
882
883 for(i=nR-1; i>=0; i--)
884 {
885 (*result)[i] = pGetExp(f,i+1);
886 }
887 return result;
888}
FILE * f
Definition checklibs.c:9
#define pGetExp(p, i)
Exponent.
Definition polys.h:42

◆ Mfpertvector()

intvec * Mfpertvector ( ideal G,
intvec * ivtarget )

Definition at line 1513 of file walk.cc.

1514{
1515 int i, j, nG = IDELEMS(G);
1516 int nV = currRing->N;
1517 int niv = nV*nV;
1518
1519
1520 // Calculate maxA = Max(A2) + Max(A3) + ... + Max(AnV),
1521 // where the Ai are the i-te rows of the matrix 'targer_ord'.
1522 int ntemp, maxAi, maxA=0;
1523 for(i=1; i<nV; i++)
1524 {
1525 maxAi = (*ivtarget)[i*nV];
1526 if(maxAi<0)
1527 {
1528 maxAi = -maxAi;
1529 }
1530 for(j=i*nV+1; j<(i+1)*nV; j++)
1531 {
1532 ntemp = (*ivtarget)[j];
1533 if(ntemp < 0)
1534 {
1535 ntemp = -ntemp;
1536 }
1537 if(ntemp > maxAi)
1538 {
1539 maxAi = ntemp;
1540 }
1541 }
1542 maxA = maxA + maxAi;
1543 }
1544 intvec* ivUnit = Mivdp(nV);
1545
1546 // Calculate inveps = 1/eps, where 1/eps > deg(p)*maxA for all p in G.
1547 mpz_t tot_deg; mpz_init(tot_deg);
1548 mpz_t maxdeg; mpz_init(maxdeg);
1549 mpz_t inveps; mpz_init(inveps);
1550
1551
1552 for(i=nG-1; i>=0; i--)
1553 {
1554 mpz_set_ui(maxdeg, MwalkWeightDegree(G->m[i], ivUnit));
1555 if (mpz_cmp(maxdeg, tot_deg) > 0 )
1556 {
1557 mpz_set(tot_deg, maxdeg);
1558 }
1559 }
1560
1561 delete ivUnit;
1562 //inveps = (tot_deg * maxA) + 1;
1563 mpz_mul_ui(inveps, tot_deg, maxA);
1564 mpz_add_ui(inveps, inveps, 1);
1565
1566 // takes "small" inveps
1567#ifdef INVEPS_SMALL_IN_FRACTAL
1568 if(mpz_cmp_ui(inveps, nV)>0 && nV > 3)
1569 {
1570 mpz_cdiv_q_ui(inveps, inveps, nV);
1571 }
1572 // choose the small inverse epsilon
1573#endif
1574
1575 // PrintLn(); mpz_out_str(stdout, 10, inveps);
1576
1577 // Calculate the perturbed target orders:
1578 mpz_t *ivtemp=(mpz_t *)omAlloc(nV*sizeof(mpz_t));
1579 mpz_t *pert_vector=(mpz_t *)omAlloc(niv*sizeof(mpz_t));
1580
1581 for(i=0; i < nV; i++)
1582 {
1583 mpz_init_set_si(ivtemp[i], (*ivtarget)[i]);
1584 mpz_init_set_si(pert_vector[i], (*ivtarget)[i]);
1585 }
1586
1587 mpz_t ztmp; mpz_init(ztmp);
1588 // BOOLEAN isneg = FALSE;
1589
1590 for(i=1; i<nV; i++)
1591 {
1592 for(j=0; j<nV; j++)
1593 {
1594 mpz_mul(ztmp, inveps, ivtemp[j]);
1595 if((*ivtarget)[i*nV+j]<0)
1596 {
1597 mpz_sub_ui(ivtemp[j], ztmp, -(*ivtarget)[i*nV+j]);
1598 }
1599 else
1600 {
1601 mpz_add_ui(ivtemp[j], ztmp,(*ivtarget)[i*nV+j]);
1602 }
1603 }
1604
1605 for(j=0; j<nV; j++)
1606 {
1607 mpz_init_set(pert_vector[i*nV+j],ivtemp[j]);
1608 }
1609 }
1610
1611 // 2147483647 is max. integer representation in SINGULAR
1612 mpz_t sing_int;
1613 mpz_init_set_ui(sing_int, 2147483647);
1614
1615 intvec* result = new intvec(niv);
1616 BOOLEAN nflow = FALSE;
1617
1618 // computes gcd
1619 mpz_set(ztmp, pert_vector[0]);
1620 for(i=0; i<niv; i++)
1621 {
1622 mpz_gcd(ztmp, ztmp, pert_vector[i]);
1623 if(mpz_cmp_si(ztmp, 1)==0)
1624 {
1625 break;
1626 }
1627 }
1628
1629 for(i=0; i<niv; i++)
1630 {
1631 mpz_divexact(pert_vector[i], pert_vector[i], ztmp);
1632 (* result)[i] = mpz_get_si(pert_vector[i]);
1633 }
1634
1635 //CHECK_OVERFLOW:
1636
1637 for(i=0; i<niv; i++)
1638 {
1639 if(mpz_cmp(pert_vector[i], sing_int)>0)
1640 {
1641 if(nflow == FALSE)
1642 {
1643 Xnlev = i / nV;
1644 nflow = TRUE;
1646 Print("\n// Xlev = %d and the %d-th element is", Xnlev, i+1);
1647 PrintS("\n// ** OVERFLOW in \"Mfpertvector\": ");
1648 mpz_out_str( stdout, 10, pert_vector[i]);
1649 PrintS(" is greater than 2147483647 (max. integer representation)");
1650 Print("\n// So vector[%d] := %d is wrong!!", i+1, (*result)[i]);
1651 }
1652 }
1653 }
1654 if(Overflow_Error == TRUE)
1655 {
1656 ivString(result, "new_vector");
1657 }
1658 omFree(pert_vector);
1659 omFree(ivtemp);
1660 mpz_clear(ztmp);
1661 mpz_clear(tot_deg);
1662 mpz_clear(maxdeg);
1663 mpz_clear(inveps);
1664 mpz_clear(sing_int);
1665
1667 for(j=0; j<IDELEMS(G); j++)
1668 {
1669 poly p=G->m[j];
1670 while(p!=NULL)
1671 {
1672 p_Setm(p,currRing);
1673 pIter(p);
1674 }
1675 }
1676 return result;
1677}
int p
Definition cfModGcd.cc:4086
#define pIter(p)
Definition monomials.h:37
#define omFree(addr)
static void p_Setm(poly p, const ring r)
Definition p_polys.h:235
void PrintS(const char *s)
Definition reporter.cc:284
static void ivString(intvec *iv, const char *ch)
Definition walk.cc:493
VAR int Xnlev
Definition walk.cc:1512
static int MwalkWeightDegree(poly p, intvec *weight_vector)
Definition walk.cc:669
intvec * Mivdp(int nR)
Definition walk.cc:1008

◆ Mfrwalk()

ideal Mfrwalk ( ideal G,
intvec * ivstart,
intvec * ivtarget,
int weight_rad,
int reduction,
int printout )

Definition at line 8213 of file walk.cc.

8215{
8216 BITSET save1 = si_opt_1; // save current options
8217 //check that weight radius is valid
8218 if(weight_rad < 0)
8219 {
8220 WerrorS("Invalid radius.\n");
8221 return NULL;
8222 }
8223 if(reduction == 0)
8224 {
8225 si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis
8226 si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions
8227 }
8230 //Print("// pSetm_Error = (%d)", ErrorCheck());
8231 //Print("\n// ring ro = %s;", rString(currRing));
8232
8233 nnflow = 0;
8234 Xngleich = 0;
8235 Xcall = 0;
8236#ifdef TIME_TEST
8237 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0; xtextra=0;
8238 xftinput = clock();
8239#endif
8240 ring oldRing = currRing;
8241 int i, nV = currRing->N;
8242 XivNull = new intvec(nV);
8243 Xivinput = ivtarget;
8244 ngleich = 0;
8245#ifdef TIME_TEST
8246 to=clock();
8247#endif
8248 ideal I = MstdCC(G);
8249 G = NULL;
8250#ifdef TIME_TEST
8251 xftostd=clock()-to;
8252#endif
8253 Xsigma = ivstart;
8254
8255 Xnlev=nV;
8256
8257#ifdef FIRST_STEP_FRACTAL
8258 ideal Gw = MwalkInitialForm(I, ivstart);
8259 for(i=IDELEMS(Gw)-1; i>=0; i--)
8260 {
8261 if((Gw->m[i]!=NULL) // len >=0
8262 && (Gw->m[i]->next!=NULL) // len >=1
8263 && (Gw->m[i]->next->next!=NULL)) // len >=2
8264 {
8265 intvec* iv_dp = MivUnit(nV); // define (1,1,...,1)
8266 intvec* Mdp;
8267 if(ivstart->length() == nV)
8268 {
8269 if(MivSame(ivstart, iv_dp) != 1)
8270 Mdp = MivWeightOrderdp(ivstart);
8271 else
8272 Mdp = MivMatrixOrderdp(nV);
8273 }
8274 else
8275 {
8276 Mdp = ivstart;
8277 }
8278
8279 Xsigma = Mfpertvector(I, Mdp);
8281
8282 delete Mdp;
8283 delete iv_dp;
8284 break;
8285 }
8286 }
8287 idDelete(&Gw);
8288#endif
8289
8290 ideal I1;
8291 intvec* Mlp;
8292 Xivlp = Mivlp(nV);
8293
8294 if(ivtarget->length() == nV)
8295 {
8296 if(MivComp(ivtarget, Xivlp) != 1)
8297 {
8298 if (rParameter(currRing) != NULL)
8299 DefRingPar(ivtarget);
8300 else
8301 rChangeCurrRing(VMrDefault(ivtarget));
8302
8303 I1 = idrMoveR(I, oldRing,currRing);
8304 Mlp = MivWeightOrderlp(ivtarget);
8305 Xtau = Mfpertvector(I1, Mlp);
8306 }
8307 else
8308 {
8309 if (rParameter(currRing) != NULL)
8310 DefRingParlp();
8311 else
8312 VMrDefaultlp();
8313
8314 I1 = idrMoveR(I, oldRing,currRing);
8315 Mlp = MivMatrixOrderlp(nV);
8316 Xtau = Mfpertvector(I1, Mlp);
8317 }
8318 }
8319 else
8320 {
8321 rChangeCurrRing(VMatrDefault(ivtarget));
8322 I1 = idrMoveR(I,oldRing,currRing);
8323 Mlp = ivtarget;
8324 Xtau = Mfpertvector(I1, Mlp);
8325 }
8326 delete Mlp;
8328
8329 //ivString(Xsigma, "Xsigma");
8330 //ivString(Xtau, "Xtau");
8331
8332 id_Delete(&I, oldRing);
8333 ring tRing = currRing;
8334 if(ivtarget->length() == nV)
8335 {
8336/*
8337 if (rParameter(currRing) != NULL)
8338 DefRingPar(ivstart);
8339 else
8340 rChangeCurrRing(VMrDefault(ivstart));
8341*/
8342 rChangeCurrRing(VMrRefine(ivtarget,ivstart));
8343 }
8344 else
8345 {
8346 //rChangeCurrRing(VMatrDefault(ivstart));
8347 rChangeCurrRing(VMatrRefine(ivtarget,ivstart));
8348 }
8349
8350 I = idrMoveR(I1,tRing,currRing);
8351#ifdef TIME_TEST
8352 to=clock();
8353#endif
8354 ideal J = MstdCC(I);
8355 idDelete(&I);
8356#ifdef TIME_TEST
8357 xftostd=xftostd+clock()-to;
8358#endif
8359 ideal resF;
8360 ring helpRing = currRing;
8361
8362 J = rec_r_fractal_call(J,1,ivtarget,weight_rad,reduction,printout);
8363 //idString(J,"//*** Mfrwalk: J");
8364 //Print("\n//** Mfrwalk hier (1)\n");
8365 rChangeCurrRing(oldRing);
8366 //Print("\n//** Mfrwalk hier (2)\n");
8367 resF = idrMoveR(J, helpRing,currRing);
8368 //Print("\n//** Mfrwalk hier (3)\n");
8369 //idSkipZeroes(resF);
8370 //Print("\n//** Mfrwalk hier (4)\n");
8371 si_opt_1 = save1; //set original options, e. g. option(RedSB)
8372 delete Xivlp;
8373 //delete Xsigma;
8374 delete Xtau;
8375 delete XivNull;
8376 //Print("\n//** Mfrwalk hier (5)\n");
8377#ifdef TIME_TEST
8378 TimeStringFractal(xftinput, xftostd, xtif, xtstd, xtextra,
8379 xtlift, xtred, xtnw);
8380
8381
8382 // Print("\n// pSetm_Error = (%d)", ErrorCheck());
8383 Print("\n// Overflow_Error? (%d)\n", Overflow_Error);
8384 Print("\n// the numbers of Overflow_Error (%d)", nnflow);
8385#endif
8386 //Print("\n//** Mfrwalk hier (6)\n");
8387 //idString(resF,"resF");
8388 //Print("\n//** Mfrwalk hier (7)\n");
8389 return(resF);
8390}
#define BITSET
Definition auxiliary.h:85
void reduction(LList *sPolyList, CListOld *critPairs, LList *gPrev, RList *rules, LTagList *lTag, RTagList *rTag, ideal gbPrev, PList *rejectedGBList, int plus)
Definition f5gb.cc:1089
void WerrorS(const char *s)
Definition feFopen.cc:24
VAR unsigned si_opt_1
Definition options.c:5
#define OPT_REDTAIL
Definition options.h:92
#define OPT_REDSB
Definition options.h:77
#define Sy_bit(x)
Definition options.h:31
intvec * MivWeightOrderdp(intvec *ivstart)
Definition walk.cc:1457
VAR intvec * Xtau
Definition walk.cc:4508
static ring VMrRefine(intvec *va, intvec *vb)
Definition walk.cc:2732
static ideal rec_r_fractal_call(ideal G, int nlev, intvec *ivtarget, int weight_rad, int reduction, int printout)
Definition walk.cc:7454
VAR intvec * Xivlp
Definition walk.cc:4511
intvec * MivWeightOrderlp(intvec *ivstart)
Definition walk.cc:1437
VAR intvec * XivNull
Definition walk.cc:6928
VAR int Xcall
Definition walk.cc:6946
static ring VMatrRefine(intvec *va, intvec *vb)
Definition walk.cc:2842
VAR intvec * Xivinput
Definition walk.cc:4510
VAR intvec * Xsigma
Definition walk.cc:4507
VAR int ngleich
Definition walk.cc:4506
intvec * Mfpertvector(ideal G, intvec *ivtarget)
Definition walk.cc:1513
static ring VMatrDefault(intvec *va)
Definition walk.cc:2791
VAR int nnflow
Definition walk.cc:6945
VAR int Xngleich
Definition walk.cc:6947

◆ Mfwalk()

ideal Mfwalk ( ideal G,
intvec * ivstart,
intvec * ivtarget,
int reduction,
int printout )

Definition at line 8032 of file walk.cc.

8034{
8035 BITSET save1 = si_opt_1; // save current options
8036 if(reduction == 0)
8037 {
8038 si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis
8039 //si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions
8040 }
8043 //Print("// pSetm_Error = (%d)", ErrorCheck());
8044 //Print("\n// ring ro = %s;", rString(currRing));
8045
8046 nnflow = 0;
8047 Xngleich = 0;
8048 Xcall = 0;
8049#ifdef TIME_TEST
8050 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0; xtextra=0;
8051 xftinput = clock();
8052#endif
8053 ring oldRing = currRing;
8054 int i, nV = currRing->N;
8055 XivNull = new intvec(nV);
8056 Xivinput = ivtarget;
8057 ngleich = 0;
8058#ifdef TIME_TEST
8059 to=clock();
8060#endif
8061 ideal I = MstdCC(G);
8062 G = NULL;
8063#ifdef TIME_TEST
8064 xftostd=clock()-to;
8065#endif
8066 Xsigma = ivstart;
8067
8068 Xnlev=nV;
8069
8070#ifdef FIRST_STEP_FRACTAL
8071 ideal Gw = MwalkInitialForm(I, ivstart);
8072 for(i=IDELEMS(Gw)-1; i>=0; i--)
8073 {
8074 if((Gw->m[i]!=NULL) // len >=0
8075 && (Gw->m[i]->next!=NULL) // len >=1
8076 && (Gw->m[i]->next->next!=NULL)) // len >=2
8077 {
8078 intvec* iv_dp = MivUnit(nV); // define (1,1,...,1)
8079 intvec* Mdp;
8080 if(ivstart->length() == nV)
8081 {
8082 if(MivSame(ivstart, iv_dp) != 1)
8083 Mdp = MivWeightOrderdp(ivstart);
8084 else
8085 Mdp = MivMatrixOrderdp(nV);
8086 }
8087 else
8088 {
8089 Mdp = ivstart;
8090 }
8091
8092 Xsigma = Mfpertvector(I, Mdp);
8094
8095 delete Mdp;
8096 delete iv_dp;
8097 break;
8098 }
8099 }
8100 idDelete(&Gw);
8101#endif
8102
8103 ideal I1;
8104 intvec* Mlp;
8105 Xivlp = Mivlp(nV);
8106
8107 if(ivtarget->length() == nV)
8108 {
8109 if(MivComp(ivtarget, Xivlp) != 1)
8110 {
8111 if (rParameter(currRing) != NULL)
8112 DefRingPar(ivtarget);
8113 else
8114 rChangeCurrRing(VMrDefault(ivtarget));
8115
8116 I1 = idrMoveR(I, oldRing,currRing);
8117 Mlp = MivWeightOrderlp(ivtarget);
8118 Xtau = Mfpertvector(I1, Mlp);
8119 }
8120 else
8121 {
8122 if (rParameter(currRing) != NULL)
8123 DefRingParlp();
8124 else
8125 VMrDefaultlp();
8126
8127 I1 = idrMoveR(I, oldRing,currRing);
8128 Mlp = MivMatrixOrderlp(nV);
8129 Xtau = Mfpertvector(I1, Mlp);
8130 }
8131 }
8132 else
8133 {
8134 rChangeCurrRing(VMatrDefault(ivtarget));
8135 I1 = idrMoveR(I,oldRing,currRing);
8136 Mlp = ivtarget;
8137 Xtau = Mfpertvector(I1, Mlp);
8138 }
8139 delete Mlp;
8141
8142 //ivString(Xsigma, "Xsigma");
8143 //ivString(Xtau, "Xtau");
8144
8145 id_Delete(&I, oldRing);
8146 ring tRing = currRing;
8147 if(ivtarget->length() == nV)
8148 {
8149/*
8150 if (rParameter(currRing) != NULL)
8151 DefRingPar(ivstart);
8152 else
8153 rChangeCurrRing(VMrDefault(ivstart));
8154*/
8155 rChangeCurrRing(VMrRefine(ivtarget,ivstart));
8156 }
8157 else
8158 {
8159 //rChangeCurrRing(VMatrDefault(ivstart));
8160 rChangeCurrRing(VMatrRefine(ivtarget,ivstart));
8161 }
8162
8163 I = idrMoveR(I1,tRing,currRing);
8164#ifdef TIME_TEST
8165 to=clock();
8166#endif
8167 ideal J = MstdCC(I);
8168 idDelete(&I);
8169#ifdef TIME_TEST
8170 xftostd=xftostd+clock()-to;
8171#endif
8172 ideal resF;
8173 ring helpRing = currRing;
8174
8175 J = rec_fractal_call(J,1,ivtarget,reduction,printout);
8176 //idString(J,"//** Mfwalk: J");
8177 rChangeCurrRing(oldRing);
8178 //Print("\n//Mfwalk: (2)\n");
8179 resF = idrMoveR(J, helpRing,currRing);
8180 //Print("\n//Mfwalk: (3)\n");
8181 idSkipZeroes(resF);
8182 //Print("\n//Mfwalk: (4)\n");
8183
8184 si_opt_1 = save1; //set original options, e. g. option(RedSB)
8185 delete Xivlp;
8186 //delete Xsigma;
8187 delete Xtau;
8188 delete XivNull;
8189 //Print("\n//Mfwalk: (5)\n");
8190#ifdef TIME_TEST
8191 TimeStringFractal(xftinput, xftostd, xtif, xtstd, xtextra,
8192 xtlift, xtred, xtnw);
8193
8194
8195 //Print("\n// pSetm_Error = (%d)", ErrorCheck());
8196 Print("\n// Overflow_Error? (%d)\n", Overflow_Error);
8197 Print("\n// the numbers of Overflow_Error (%d)", nnflow);
8198#endif
8199 //Print("\n//Mfwalk: (6)\n");
8200 //idString(resF,"//** Mfwalk: resF");
8201 return(idCopy(resF));
8202}
ideal idCopy(ideal A)
Definition ideals.h:60
static ideal rec_fractal_call(ideal G, int nlev, intvec *ivtarget, int reduction, int printout)
Definition walk.cc:6952

◆ middleOfCone()

static ideal middleOfCone ( ideal G,
ideal Gomega )
static

Definition at line 3080 of file walk.cc.

3081{
3082 BOOLEAN middle = FALSE;
3083 int i,j,N = IDELEMS(Gomega);
3084 poly p,lm,factor1,factor2;
3085
3086 ideal Go = idCopy(G);
3087
3088 // check whether leading monomials of G and Gomega coincide
3089 // and return NULL if not
3090 for(i=0; i<N; i++)
3091 {
3092 if(!pIsConstant(pSub(pCopy(Gomega->m[i]),pCopy(pHead(G->m[i])))))
3093 {
3094 idDelete(&Go);
3095 return NULL;
3096 }
3097 }
3098 for(i=0; i<N; i++)
3099 {
3100 for(j=0; j<N; j++)
3101 {
3102 if(i!=j)
3103 {
3104 p = pCopy(Gomega->m[i]);
3105 lm = pCopy(Gomega->m[j]);
3106 pIter(p);
3107 while(p!=NULL)
3108 {
3109 if(pDivisibleBy(lm,p))
3110 {
3111 if(middle == FALSE)
3112 {
3113 middle = TRUE;
3114 }
3115 factor1 = singclap_pdivide(pHead(p),lm,currRing);
3116 factor2 = pMult(pCopy(factor1),pCopy(Go->m[j]));
3117 pDelete(&factor1);
3118 Go->m[i] = pAdd((Go->m[i]),pNeg(pCopy(factor2)));
3119 pDelete(&factor2);
3120 }
3121 pIter(p);
3122 }
3123 pDelete(&lm);
3124 pDelete(&p);
3125 }
3126 }
3127 }
3128
3129 if(middle == TRUE)
3130 {
3131 return Go;
3132 }
3133 idDelete(&Go);
3134 return NULL;
3135}
const CanonicalForm CFMap CFMap & N
Definition cfEzgcd.cc:56
poly singclap_pdivide(poly f, poly g, const ring r)
Definition clapsing.cc:624
#define pAdd(p, q)
Definition polys.h:204
#define pIsConstant(p)
like above, except that Comp must be 0
Definition polys.h:239
#define pNeg(p)
Definition polys.h:199
#define pSub(a, b)
Definition polys.h:288
#define pMult(p, q)
Definition polys.h:208
#define pDivisibleBy(a, b)
returns TRUE, if leading monom of a divides leading monom of b i.e., if there exists a expvector c > ...
Definition polys.h:139

◆ MidMult()

static ideal MidMult ( ideal A,
ideal B )
static

Definition at line 1684 of file walk.cc.

1685{
1686 int mA = IDELEMS(A), mB = IDELEMS(B);
1687
1688 if(A==NULL || B==NULL)
1689 {
1690 return NULL;
1691 }
1692 if(mB < mA)
1693 {
1694 mA = mB;
1695 }
1696 ideal result = idInit(mA, 1);
1697
1698 int i, k=0;
1699 for(i=0; i<mA; i++)
1700 {
1701 result->m[k] = pMult(A->m[i], pCopy(B->m[i]));
1702 A->m[i]=NULL;
1703 if (result->m[k]!=NULL)
1704 {
1705 k++;
1706 }
1707 }
1708
1709 idDelete(&A);
1711 return result;
1712}
b *CanonicalForm B
Definition facBivar.cc:52
#define A
Definition sirandom.c:24

◆ MivAbsMax()

static int MivAbsMax ( intvec * vec)
static

Definition at line 1816 of file walk.cc.

1817{
1818 int i,k;
1819 if((*vec)[0] < 0)
1820 {
1821 k = -(*vec)[0];
1822 }
1823 else
1824 {
1825 k = (*vec)[0];
1826 }
1827 for(i=1; i < (vec->length()); i++)
1828 {
1829 if((*vec)[i] < 0)
1830 {
1831 if(-(*vec)[i] > k)
1832 {
1833 k = -(*vec)[i];
1834 }
1835 }
1836 else
1837 {
1838 if((*vec)[i] > k)
1839 {
1840 k = (*vec)[i];
1841 }
1842 }
1843 }
1844 return k;
1845}
fq_nmod_poly_t * vec
Definition facHensel.cc:108

◆ MivAbsMaxArg()

static int MivAbsMaxArg ( intvec * vec)
static

Definition at line 1851 of file walk.cc.

1852{
1853 int k = MivAbsMax(vec);
1854 int i=0;
1855 while(1)
1856 {
1857 if((*vec)[i] == k || (*vec)[i] == -k)
1858 {
1859 break;
1860 }
1861 i++;
1862 }
1863 return i;
1864}
static int MivAbsMax(intvec *vec)
Definition walk.cc:1816

◆ MivComp()

static int MivComp ( intvec * iva,
intvec * ivb )
inlinestatic

Definition at line 1799 of file walk.cc.

1800{
1801 assume(iva->length() == ivb->length());
1802 int i;
1803 for(i=iva->length()-1; i>=0; i--)
1804 {
1805 if((*iva)[i] - (*ivb)[i] != 0)
1806 {
1807 return 0;
1808 }
1809 }
1810 return 1;
1811}

◆ MivDotProduct()

static long MivDotProduct ( intvec * a,
intvec * b )
inlinestatic

Definition at line 846 of file walk.cc.

847{
848 assume( a->length() == b->length());
849 int i, n = a->length();
850 long result = 0;
851
852 for(i=n-1; i>=0; i--)
853 {
854 result += (*a)[i] * (*b)[i];
855 }
856 return result;
857}

◆ Mivdp()

intvec * Mivdp ( int nR)

Definition at line 1008 of file walk.cc.

1009{
1010 int i;
1011 intvec* ivm = new intvec(nR);
1012
1013 for(i=nR-1; i>=0; i--)
1014 {
1015 (*ivm)[i] = 1;
1016 }
1017 return ivm;
1018}

◆ Mivlp()

intvec * Mivlp ( int nR)

Definition at line 1023 of file walk.cc.

1024{
1025 intvec* ivm = new intvec(nR);
1026 (*ivm)[0] = 1;
1027
1028 return ivm;
1029}

◆ MivMatrixOrder()

intvec * MivMatrixOrder ( intvec * iv)

Definition at line 964 of file walk.cc.

965{
966 int i, nR = iv->length();
967
968 intvec* ivm = new intvec(nR*nR);
969
970 for(i=0; i<nR; i++)
971 {
972 (*ivm)[i] = (*iv)[i];
973 }
974 for(i=1; i<nR; i++)
975 {
976 (*ivm)[i*nR+i-1] = 1;
977 }
978 return ivm;
979}

◆ MivMatrixOrderdp()

intvec * MivMatrixOrderdp ( int nV)

Definition at line 1418 of file walk.cc.

1419{
1420 int i;
1421 intvec* ivM = new intvec(nV*nV);
1422
1423 for(i=0; i<nV; i++)
1424 {
1425 (*ivM)[i] = 1;
1426 }
1427 for(i=1; i<nV; i++)
1428 {
1429 (*ivM)[(i+1)*nV - i] = -1;
1430 }
1431 return(ivM);
1432}

◆ MivMatrixOrderlp()

intvec * MivMatrixOrderlp ( int nV)

Definition at line 1402 of file walk.cc.

1403{
1404 int i;
1405 intvec* ivM = new intvec(nV*nV);
1406
1407 for(i=0; i<nV; i++)
1408 {
1409 (*ivM)[i*nV + i] = 1;
1410 }
1411 return(ivM);
1412}

◆ MivMatrixOrderRefine()

intvec * MivMatrixOrderRefine ( intvec * iv,
intvec * iw )

Definition at line 984 of file walk.cc.

985{
986 assume((iv->length())*(iv->length()) == iw->length());
987 int i,j, nR = iv->length();
988
989 intvec* ivm = new intvec(nR*nR);
990
991 for(i=0; i<nR; i++)
992 {
993 (*ivm)[i] = (*iv)[i];
994 }
995 for(i=1; i<nR; i++)
996 {
997 for(j=0; j<nR; j++)
998 {
999 (*ivm)[j+i*nR] = (*iw)[j+i*nR];
1000 }
1001 }
1002 return ivm;
1003}

◆ MivSame()

int MivSame ( intvec * u,
intvec * v )

Definition at line 894 of file walk.cc.

895{
896 assume(u->length() == v->length());
897
898 int i, niv = u->length();
899
900 for (i=0; i<niv; i++)
901 {
902 if ((*u)[i] != (*v)[i])
903 {
904 return 0;
905 }
906 }
907 return 1;
908}

◆ MivSub()

static intvec * MivSub ( intvec * a,
intvec * b )
static

Definition at line 862 of file walk.cc.

863{
864 assume( a->length() == b->length());
865 int i, n = a->length();
866 intvec* result = new intvec(n);
867
868 for(i=n-1; i>=0; i--)
869 {
870 (*result)[i] = (*a)[i] - (*b)[i];
871 }
872 return result;
873}

◆ MivUnit()

intvec * MivUnit ( int nV)

Definition at line 1497 of file walk.cc.

1498{
1499 int i;
1500 intvec* ivM = new intvec(nV);
1501 for(i=nV-1; i>=0; i--)
1502 {
1503 (*ivM)[i] = 1;
1504 }
1505 return(ivM);
1506}

◆ MivWeightOrderdp()

intvec * MivWeightOrderdp ( intvec * ivstart)

Definition at line 1457 of file walk.cc.

1458{
1459 int i;
1460 int nV = ivstart->length();
1461 intvec* ivM = new intvec(nV*nV);
1462
1463 for(i=0; i<nV; i++)
1464 {
1465 (*ivM)[i] = (*ivstart)[i];
1466 }
1467 for(i=0; i<nV; i++)
1468 {
1469 (*ivM)[nV+i] = 1;
1470 }
1471 for(i=2; i<nV; i++)
1472 {
1473 (*ivM)[(i+1)*nV - i] = -1;
1474 }
1475 return(ivM);
1476}

◆ MivWeightOrderlp()

intvec * MivWeightOrderlp ( intvec * ivstart)

Definition at line 1437 of file walk.cc.

1438{
1439 int i;
1440 int nV = ivstart->length();
1441 intvec* ivM = new intvec(nV*nV);
1442
1443 for(i=0; i<nV; i++)
1444 {
1445 (*ivM)[i] = (*ivstart)[i];
1446 }
1447 for(i=1; i<nV; i++)
1448 {
1449 (*ivM)[i*nV + i-1] = 1;
1450 }
1451 return(ivM);
1452}

◆ MkInterRedNextWeight()

intvec * MkInterRedNextWeight ( intvec * iva,
intvec * ivb,
ideal G )

Definition at line 2571 of file walk.cc.

2572{
2573 intvec* tmp = new intvec(iva->length());
2574 intvec* result;
2575
2576 if(G == NULL)
2577 {
2578 return tmp;
2579 }
2580 if(MivComp(iva, ivb) == 1)
2581 {
2582 return tmp;
2583 }
2584 result = MwalkNextWeightCC(iva, ivb, G);
2585
2586 if(MivComp(result, iva) == 1)
2587 {
2588 delete result;
2589 return tmp;
2590 }
2591
2592 delete tmp;
2593 return result;
2594}
static intvec * MwalkNextWeightCC(intvec *curr_weight, intvec *target_weight, ideal G)
Definition walk.cc:2229

◆ Mlcm()

static long Mlcm ( long & i1,
long & i2 )
inlinestatic

Definition at line 836 of file walk.cc.

837{
838 long temp = gcd(i1, i2);
839 return ((i1 / temp)* i2);
840}
static long gcd(const long a, const long b)
Definition walk.cc:533

◆ MLifttwoIdeal()

static ideal MLifttwoIdeal ( ideal Gw,
ideal M,
ideal G )
static

Definition at line 1722 of file walk.cc.

1723{
1724 ideal Mtmp = idLift(Gw, M, NULL, FALSE, TRUE, TRUE, NULL);
1725
1726 // If Gw is a GB, then isSB = TRUE, otherwise FALSE
1727 // So, it is better, if one tests whether Gw is a GB
1728 // in ideals.cc:
1729 // idLift (ideal mod, ideal submod,ideal * rest, BOOLEAN goodShape,
1730 // BOOLEAN isSB,BOOLEAN divide,matrix * unit)
1731
1732 // Let be Mtmp = {m1,...,ms}, where mi=sum hij.in_gj, for all i=1,...,s
1733 // We compute F = {f1,...,fs}, where fi=sum hij.gj
1734 int i, j, nM = IDELEMS(Mtmp);
1735 ideal idpol, idLG;
1736 ideal F = idInit(nM, 1);
1737
1738 for(i=0; i<nM; i++)
1739 {
1740 idpol = idVec2Ideal(Mtmp->m[i]);
1741 idLG = MidMult(idpol, G);
1742 idpol = NULL;
1743 F->m[i] = NULL;
1744 for(j=IDELEMS(idLG)-1; j>=0; j--)
1745 {
1746 F->m[i] = pAdd(F->m[i], idLG->m[j]);
1747 idLG->m[j]=NULL;
1748 }
1749 idDelete(&idLG);
1750 }
1751 idDelete(&Mtmp);
1752 return F;
1753}
ideal idLift(ideal mod, ideal submod, ideal *rest, BOOLEAN goodShape, BOOLEAN isSB, BOOLEAN divide, matrix *unit, GbVariant alg)
represents the generators of submod in terms of the generators of mod (Matrix(SM)*U-Matrix(rest)) = M...
Definition ideals.cc:1111
static ideal idVec2Ideal(poly vec)
Definition ideals.h:173
static ideal MidMult(ideal A, ideal B)
Definition walk.cc:1684

◆ MLmWeightedDegree()

static int MLmWeightedDegree ( const poly p,
intvec * weight )
inlinestatic

Definition at line 622 of file walk.cc.

623{
624 /* 2147483647 is max. integer representation in SINGULAR */
625 mpz_t sing_int;
626 mpz_init_set_ui(sing_int, 2147483647);
627
628 int i, wgrad;
629
630 mpz_t zmul;
631 mpz_init(zmul);
632 mpz_t zvec;
633 mpz_init(zvec);
634 mpz_t zsum;
635 mpz_init(zsum);
636
637 for (i=currRing->N; i>0; i--)
638 {
639 mpz_set_si(zvec, (*weight)[i-1]);
640 mpz_mul_ui(zmul, zvec, pGetExp(p, i));
641 mpz_add(zsum, zsum, zmul);
642 }
643
644 wgrad = mpz_get_ui(zsum);
645
646 if(mpz_cmp(zsum, sing_int)>0)
647 {
648 if(Overflow_Error == FALSE)
649 {
650 PrintLn();
651 PrintS("\n// ** OVERFLOW in \"MwalkInitialForm\": ");
652 mpz_out_str( stdout, 10, zsum);
653 PrintS(" is greater than 2147483647 (max. integer representation)");
655 }
656 }
657
658 mpz_clear(zmul);
659 mpz_clear(zvec);
660 mpz_clear(zsum);
661 mpz_clear(sing_int);
662
663 return wgrad;
664}
void PrintLn()
Definition reporter.cc:310

◆ MLmWeightedDegree_gmp()

static void MLmWeightedDegree_gmp ( mpz_t result,
const poly p,
intvec * weight )
static

Definition at line 691 of file walk.cc.

692{
693 /* 2147483647 is max. integer representation in SINGULAR */
694 mpz_t sing_int;
695 mpz_init_set_ui(sing_int, 2147483647);
696
697 int i;
698
699 mpz_t zmul;
700 mpz_init(zmul);
701 mpz_t zvec;
702 mpz_init(zvec);
703 mpz_t ztmp;
704 mpz_init(ztmp);
705
706 for (i=currRing->N; i>0; i--)
707 {
708 mpz_set_si(zvec, (*weight)[i-1]);
709 mpz_mul_ui(zmul, zvec, pGetExp(p, i));
710 mpz_add(ztmp, ztmp, zmul);
711 }
712 mpz_set(result, ztmp);
713 mpz_clear(ztmp);
714 mpz_clear(sing_int);
715 mpz_clear(zvec);
716 mpz_clear(zmul);
717}

◆ MMatrixone()

intvec * MMatrixone ( int nV)

Definition at line 6933 of file walk.cc.

6934{
6935 int i,j;
6936 intvec* ivM = new intvec(nV*nV);
6937
6938 for(i=0; i<nV; i++)
6939 for(j=0; j<nV; j++)
6940 (*ivM)[i*nV + j] = 1;
6941
6942 return(ivM);
6943}

◆ MPertVectors()

intvec * MPertVectors ( ideal G,
intvec * ivtarget,
int pdeg )

Definition at line 1089 of file walk.cc.

1090{
1091 // ivtarget is a matrix order of a degree reverse lex. order
1092 int nV = currRing->N;
1093 //assume(pdeg <= nV && pdeg >= 0);
1094
1095 int i, j, nG = IDELEMS(G);
1096 intvec* v_null = new intvec(nV);
1097
1098 // Check that the perturbed degree is valid
1099 if(pdeg > nV || pdeg <= 0)
1100 {
1101 WerrorS("//** The perturbed degree is wrong!!");
1102 return v_null;
1103 }
1104 delete v_null;
1105
1106 if(pdeg == 1)
1107 {
1108 return ivtarget;
1109 }
1110 mpz_t *pert_vector = (mpz_t*)omAlloc(nV*sizeof(mpz_t));
1111 mpz_t *pert_vector1 = (mpz_t*)omAlloc(nV*sizeof(mpz_t));
1112
1113 for(i=0; i<nV; i++)
1114 {
1115 mpz_init_set_si(pert_vector[i], (*ivtarget)[i]);
1116 mpz_init_set_si(pert_vector1[i], (*ivtarget)[i]);
1117 }
1118 // Calculate max1 = Max(A2)+Max(A3)+...+Max(Apdeg),
1119 // where the Ai are the i-te rows of the matrix target_ord.
1120 int ntemp, maxAi, maxA=0;
1121 for(i=1; i<pdeg; i++)
1122 {
1123 maxAi = (*ivtarget)[i*nV];
1124 if(maxAi<0)
1125 {
1126 maxAi = -maxAi;
1127 }
1128 for(j=i*nV+1; j<(i+1)*nV; j++)
1129 {
1130 ntemp = (*ivtarget)[j];
1131 if(ntemp < 0)
1132 {
1133 ntemp = -ntemp;
1134 }
1135 if(ntemp > maxAi)
1136 {
1137 maxAi = ntemp;
1138 }
1139 }
1140 maxA += maxAi;
1141 }
1142
1143 // Calculate inveps = 1/eps, where 1/eps > totaldeg(p)*max1 for all p in G.
1144
1145 intvec* ivUnit = Mivdp(nV);
1146
1147 mpz_t tot_deg; mpz_init(tot_deg);
1148 mpz_t maxdeg; mpz_init(maxdeg);
1149 mpz_t inveps; mpz_init(inveps);
1150
1151
1152 for(i=nG-1; i>=0; i--)
1153 {
1154 mpz_set_ui(maxdeg, MwalkWeightDegree(G->m[i], ivUnit));
1155 if (mpz_cmp(maxdeg, tot_deg) > 0 )
1156 {
1157 mpz_set(tot_deg, maxdeg);
1158 }
1159 }
1160
1161 delete ivUnit;
1162 mpz_mul_ui(inveps, tot_deg, maxA);
1163 mpz_add_ui(inveps, inveps, 1);
1164
1165
1166 // takes "small" inveps
1167#ifdef INVEPS_SMALL_IN_MPERTVECTOR
1168 if(mpz_cmp_ui(inveps, pdeg)>0 && pdeg > 3)
1169 {
1170 // Print("\n// choose the\"small\" inverse epsilon := %d / %d = ", mpz_get_si(inveps), pdeg);
1171 mpz_fdiv_q_ui(inveps, inveps, pdeg);
1172 // mpz_out_str(stdout, 10, inveps);
1173 }
1174#else
1175 // PrintS("\n// the \"big\" inverse epsilon: ");
1176 mpz_out_str(stdout, 10, inveps);
1177#endif
1178
1179 // pert(A1) = inveps^(pdeg-1)*A1 + inveps^(pdeg-2)*A2+...+A_pdeg,
1180 // pert_vector := A1
1181 for( i=1; i < pdeg; i++ )
1182 {
1183 for(j=0; j<nV; j++)
1184 {
1185 mpz_mul(pert_vector[j], pert_vector[j], inveps);
1186 if((*ivtarget)[i*nV+j]<0)
1187 {
1188 mpz_sub_ui(pert_vector[j], pert_vector[j],-(*ivtarget)[i*nV+j]);
1189 }
1190 else
1191 {
1192 mpz_add_ui(pert_vector[j], pert_vector[j],(*ivtarget)[i*nV+j]);
1193 }
1194 }
1195 }
1196
1197 // 2147483647 is max. integer representation in SINGULAR
1198 mpz_t sing_int;
1199 mpz_init_set_ui(sing_int, 2147483647);
1200
1201 mpz_t check_int;
1202 mpz_init_set_ui(check_int, 100000);
1203
1204 mpz_t ztemp;
1205 mpz_init(ztemp);
1206 mpz_set(ztemp, pert_vector[0]);
1207 for(i=1; i<nV; i++)
1208 {
1209 mpz_gcd(ztemp, ztemp, pert_vector[i]);
1210 if(mpz_cmp_si(ztemp, 1) == 0)
1211 {
1212 break;
1213 }
1214 }
1215 if(mpz_cmp_si(ztemp, 1) != 0)
1216 {
1217 for(i=0; i<nV; i++)
1218 {
1219 mpz_divexact(pert_vector[i], pert_vector[i], ztemp);
1220 }
1221 }
1222
1223 for(i=0; i<nV; i++)
1224 {
1225 if(mpz_cmp(pert_vector[i], check_int)>=0)
1226 {
1227 for(j=0; j<nV; j++)
1228 {
1229 mpz_fdiv_q_ui(pert_vector1[j], pert_vector[j], 100);
1230 }
1231 }
1232 }
1233
1234 intvec* result = new intvec(nV);
1235
1236 int ntrue=0;
1237
1238 for(i=0; i<nV; i++)
1239 {
1240 (*result)[i] = mpz_get_si(pert_vector1[i]);
1241 if(mpz_cmp(pert_vector1[i], sing_int)>=0)
1242 {
1243 ntrue++;
1244 }
1245 }
1246 if(ntrue > 0 || test_w_in_ConeCC(G,result)==0)
1247 {
1248 ntrue=0;
1249 for(i=0; i<nV; i++)
1250 {
1251 (*result)[i] = mpz_get_si(pert_vector[i]);
1252 if(mpz_cmp(pert_vector[i], sing_int)>=0)
1253 {
1254 ntrue++;
1255 if(Overflow_Error == FALSE)
1256 {
1258 PrintS("\n// ** OVERFLOW in \"MPertvectors\": ");
1259 mpz_out_str( stdout, 10, pert_vector[i]);
1260 PrintS(" is greater than 2147483647 (max. integer representation)");
1261 Print("\n// So vector[%d] := %d is wrong!!", i+1, (*result)[i]);
1262 }
1263 }
1264 }
1265
1266 if(Overflow_Error == TRUE)
1267 {
1268 ivString(result, "pert_vector");
1269 Print("\n// %d element(s) of it is overflow!!", ntrue);
1270 }
1271 }
1272
1273 mpz_clear(ztemp);
1274 mpz_clear(sing_int);
1275 mpz_clear(check_int);
1276 omFree(pert_vector);
1277 omFree(pert_vector1);
1278 mpz_clear(tot_deg);
1279 mpz_clear(maxdeg);
1280 mpz_clear(inveps);
1281
1283 for(j=0; j<IDELEMS(G); j++)
1284 {
1285 poly p=G->m[j];
1286 while(p!=NULL)
1287 {
1288 p_Setm(p,currRing); pIter(p);
1289 }
1290 }
1291 return result;
1292}

◆ MPertVectorslp()

intvec * MPertVectorslp ( ideal G,
intvec * ivtarget,
int pdeg )

Definition at line 1300 of file walk.cc.

1301{
1302 // ivtarget is a matrix order of the lex. order
1303 int nV = currRing->N;
1304 //assume(pdeg <= nV && pdeg >= 0);
1305
1306 int i, j, nG = IDELEMS(G);
1307 intvec* pert_vector = new intvec(nV);
1308
1309 //Checking that the perturbated degree is valid
1310 if(pdeg > nV || pdeg <= 0)
1311 {
1312 WerrorS("//** The perturbed degree is wrong!!");
1313 return pert_vector;
1314 }
1315 for(i=0; i<nV; i++)
1316 {
1317 (*pert_vector)[i]=(*ivtarget)[i];
1318 }
1319 if(pdeg == 1)
1320 {
1321 return pert_vector;
1322 }
1323 // Calculate max1 = Max(A2)+Max(A3)+...+Max(Apdeg),
1324 // where the Ai are the i-te rows of the matrix target_ord.
1325 int ntemp, maxAi, maxA=0;
1326 for(i=1; i<pdeg; i++)
1327 {
1328 maxAi = (*ivtarget)[i*nV];
1329 for(j=i*nV+1; j<(i+1)*nV; j++)
1330 {
1331 ntemp = (*ivtarget)[j];
1332 if(ntemp > maxAi)
1333 {
1334 maxAi = ntemp;
1335 }
1336 }
1337 maxA += maxAi;
1338 }
1339
1340 // Calculate inveps := 1/eps, where 1/eps > deg(p)*max1 for all p in G.
1341 int inveps, tot_deg = 0, maxdeg;
1342
1343 intvec* ivUnit = Mivdp(nV);//19.02
1344 for(i=nG-1; i>=0; i--)
1345 {
1346 // maxdeg = pTotaldegree(G->m[i], currRing); //it's wrong for ex1,2,rose
1347 maxdeg = MwalkWeightDegree(G->m[i], ivUnit);
1348 if (maxdeg > tot_deg )
1349 {
1350 tot_deg = maxdeg;
1351 }
1352 }
1353 delete ivUnit;
1354
1355 inveps = (tot_deg * maxA) + 1;
1356
1357#ifdef INVEPS_SMALL_IN_FRACTAL
1358 // Print("\n// choose the\"small\" inverse epsilon := %d / %d = ", inveps, pdeg);
1359 if(inveps > pdeg && pdeg > 3)
1360 {
1361 inveps = inveps / pdeg;
1362 }
1363 // Print(" %d", inveps);
1364#else
1365 PrintS("\n// the \"big\" inverse epsilon %d", inveps);
1366#endif
1367
1368 // Pert(A1) = inveps^(pdeg-1)*A1 + inveps^(pdeg-2)*A2+...+A_pdeg
1369 for ( i=1; i < pdeg; i++ )
1370 {
1371 for(j=0; j<nV; j++)
1372 {
1373 (*pert_vector)[j] = inveps*((*pert_vector)[j]) + (*ivtarget)[i*nV+j];
1374 }
1375 }
1376
1377 int temp = (*pert_vector)[0];
1378 for(i=1; i<nV; i++)
1379 {
1380 temp = gcd(temp, (*pert_vector)[i]);
1381 if(temp == 1)
1382 {
1383 break;
1384 }
1385 }
1386 if(temp != 1)
1387 {
1388 for(i=0; i<nV; i++)
1389 {
1390 (*pert_vector)[i] = (*pert_vector)[i] / temp;
1391 }
1392 }
1393
1394 intvec* result = pert_vector;
1395 delete pert_vector;
1396 return result;
1397}

◆ MpolyInitialForm()

static poly MpolyInitialForm ( poly g,
intvec * curr_weight )
static

Definition at line 723 of file walk.cc.

724{
725 if(g == NULL)
726 {
727 return NULL;
728 }
729 mpz_t max; mpz_init(max);
730 mpz_t maxtmp; mpz_init(maxtmp);
731
732 poly hg, in_w_g = NULL;
733
734 while(g != NULL)
735 {
736 hg = g;
737 pIter(g);
738 MLmWeightedDegree_gmp(maxtmp, hg, curr_weight);
739
740 if(mpz_cmp(maxtmp, max)>0)
741 {
742 mpz_set(max, maxtmp);
743 if (in_w_g!=NULL) pDelete(&in_w_g);
744 in_w_g = pHead(hg);
745 }
746 else
747 {
748 if(mpz_cmp(maxtmp, max)==0)
749 {
750 in_w_g = pAdd(in_w_g, pHead(hg));
751 }
752 }
753 }
754 mpz_clear(maxtmp);
755 mpz_clear(max);
756 return in_w_g;
757}
static int max(int a, int b)
Definition fast_mult.cc:264
static void MLmWeightedDegree_gmp(mpz_t result, const poly p, intvec *weight)
Definition walk.cc:691

◆ Mprwalk()

ideal Mprwalk ( ideal Go,
intvec * orig_M,
intvec * target_M,
int weight_rad,
int op_deg,
int tp_deg,
int nP,
int reduction,
int printout )

Definition at line 6389 of file walk.cc.

6391{
6392 BITSET save1 = si_opt_1; // save current options
6393 if(reduction == 0)
6394 {
6395 si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis
6396 si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions
6397 }
6400 //Print("// pSetm_Error = (%d)", ErrorCheck());
6401#ifdef TIME_TEST
6402 clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
6403 xtextra=0;
6404 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;
6405 tinput = clock();
6406
6407 clock_t tim;
6408#endif
6409 nstep = 0;
6410 int i, ntwC=1, ntestw=1, nV = currRing->N; //polylength
6411
6412 //check that weight radius is valid
6413 if(weight_rad < 0)
6414 {
6415 WerrorS("Invalid radius.\n");
6416 return NULL;
6417 }
6418
6419 //check that perturbation degree is valid
6420 if(op_deg < 1 || tp_deg < 1 || op_deg > nV || tp_deg > nV)
6421 {
6422 WerrorS("Invalid perturbation degree.\n");
6423 return NULL;
6424 }
6425
6426 BOOLEAN endwalks = FALSE;
6427
6428 ideal Gomega, M, F, FF, G, Gomega1, Gomega2, M1,F1,Eresult,ssG;
6429 ring newRing, oldRing, TargetRing;
6430 intvec* iv_M;
6431 intvec* iv_M_dp;
6432 intvec* iv_M_lp;
6433 intvec* exivlp = Mivlp(nV);
6434 intvec* curr_weight = new intvec(nV);
6435 intvec* target_weight = new intvec(nV);
6436 for(i=0; i<nV; i++)
6437 {
6438 (*curr_weight)[i] = (*orig_M)[i];
6439 (*target_weight)[i] = (*target_M)[i];
6440 }
6441 intvec* orig_target = target_weight;
6442 intvec* pert_target_vector = target_weight;
6443 intvec* ivNull = new intvec(nV);
6444 intvec* iv_dp = MivUnit(nV);// define (1,1,...,1)
6445#ifndef BUCHBERGER_ALG
6446 intvec* hilb_func;
6447#endif
6448 intvec* next_weight;
6449
6450 // to avoid (1,0,...,0) as the target vector
6451 intvec* last_omega = new intvec(nV);
6452 for(i=nV-1; i>0; i--)
6453 (*last_omega)[i] = 1;
6454 (*last_omega)[0] = 10000;
6455
6456 ring XXRing = currRing;
6457
6458 // perturbs the original vector
6459 if(orig_M->length() == nV)
6460 {
6461 if(MivComp(curr_weight, iv_dp) == 1) //rOrdStr(currRing) := "dp"
6462 {
6463#ifdef TIME_TEST
6464 to = clock();
6465#endif
6466 G = MstdCC(Go);
6467#ifdef TIME_TEST
6468 tostd = clock()-to;
6469#endif
6470 if(op_deg != 1)
6471 {
6472 iv_M_dp = MivMatrixOrderdp(nV);
6473 curr_weight = MPertVectors(G, iv_M_dp, op_deg);
6474 }
6475 }
6476 else
6477 {
6478 //define ring order := (a(curr_weight),lp);
6479 if (rParameter(currRing) != NULL)
6480 DefRingPar(curr_weight);
6481 else
6482 rChangeCurrRing(VMrDefault(curr_weight));
6483
6484 G = idrMoveR(Go, XXRing,currRing);
6485#ifdef TIME_TEST
6486 to = clock();
6487#endif
6488 G = MstdCC(G);
6489#ifdef TIME_TEST
6490 tostd = clock()-to;
6491#endif
6492 if(op_deg != 1)
6493 {
6494 iv_M_dp = MivMatrixOrder(curr_weight);
6495 curr_weight = MPertVectors(G, iv_M_dp, op_deg);
6496 }
6497 }
6498 }
6499 else
6500 {
6502 G = idrMoveR(Go, XXRing,currRing);
6503#ifdef TIME_TEST
6504 to = clock();
6505#endif
6506 G = MstdCC(G);
6507#ifdef TIME_TEST
6508 tostd = clock()-to;
6509#endif
6510 if(op_deg != 1)
6511 {
6512 curr_weight = MPertVectors(G, orig_M, op_deg);
6513 }
6514 }
6515
6516 delete iv_dp;
6517 if(op_deg != 1) delete iv_M_dp;
6518
6519 ring HelpRing = currRing;
6520
6521 // perturbs the target weight vector
6522 if(target_M->length() == nV)
6523 {
6524 if(tp_deg > 1 && tp_deg <= nV)
6525 {
6526 if (rParameter(currRing) != NULL)
6527 DefRingPar(target_weight);
6528 else
6529 rChangeCurrRing(VMrDefault(target_weight));
6530
6531 TargetRing = currRing;
6532 ssG = idrMoveR(G,HelpRing,currRing);
6533 if(MivSame(target_weight, exivlp) == 1)
6534 {
6535 iv_M_lp = MivMatrixOrderlp(nV);
6536 target_weight = MPertVectors(ssG, iv_M_lp, tp_deg);
6537 }
6538 else
6539 {
6540 iv_M_lp = MivMatrixOrder(target_weight);
6541 target_weight = MPertVectors(ssG, iv_M_lp, tp_deg);
6542 }
6543 delete iv_M_lp;
6544 pert_target_vector = target_weight;
6545 rChangeCurrRing(HelpRing);
6546 G = idrMoveR(ssG, TargetRing,currRing);
6547 }
6548 }
6549 else
6550 {
6551 if(tp_deg > 1 && tp_deg <= nV)
6552 {
6553 rChangeCurrRing(VMatrDefault(target_M));
6554 TargetRing = currRing;
6555 ssG = idrMoveR(G,HelpRing,currRing);
6556 target_weight = MPertVectors(ssG, target_M, tp_deg);
6557 }
6558 }
6559 if(printout > 0)
6560 {
6561 Print("\n//** Mprwalk: Random Perturbation Walk of degree (%d,%d):",op_deg,tp_deg);
6562 ivString(curr_weight, "//** Mprwalk: new current weight");
6563 ivString(target_weight, "//** Mprwalk: new target weight");
6564 }
6565
6566#ifdef TIME_TEST
6567 to = clock();
6568#endif
6569 Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"
6570#ifdef TIME_TEST
6571 tif = tif + clock()-to; //time for computing initial form ideal
6572#endif
6573
6574 while(1)
6575 {
6576 nstep ++;
6577#ifdef CHECK_IDEAL_MWALK
6578 if(printout > 1)
6579 {
6580 idString(Gomega,"//** Mprwalk: Gomega");
6581 }
6582#endif
6583
6584 if(reduction == 0 && nstep > 1)
6585 {
6586 FF = middleOfCone(G,Gomega);
6587 if(FF != NULL)
6588 {
6589 idDelete(&G);
6590 G = idCopy(FF);
6591 idDelete(&FF);
6592 goto NEXT_VECTOR;
6593 }
6594 }
6595
6596#ifdef ENDWALKS
6597 if(endwalks == TRUE)
6598 {
6599 if(printout > 0)
6600 {
6601 Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
6602 //idElements(G, "G");
6603 //headidString(G, "G");
6604 }
6605 }
6606#endif
6607
6608#ifndef BUCHBERGER_ALG
6609 if(isNolVector(curr_weight) == 0)
6610 hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing);
6611 else
6612 hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);
6613#endif // BUCHBERGER_ALG
6614
6615 oldRing = currRing;
6616
6617 if(target_M->length() == nV)
6618 {/*
6619 // define a new ring with ordering "(a(curr_weight),lp)
6620 if (rParameter(currRing) != NULL)
6621 DefRingPar(curr_weight);
6622 else
6623 rChangeCurrRing(VMrDefault(curr_weight));
6624*/
6625 rChangeCurrRing(VMrRefine(target_M,curr_weight));
6626 }
6627 else
6628 {
6629 rChangeCurrRing(VMatrRefine(target_M,curr_weight));
6630 }
6631 newRing = currRing;
6632 Gomega1 = idrMoveR(Gomega, oldRing,currRing);
6633#ifdef ENDWALKS
6634 if(endwalks == TRUE)
6635 {
6636 if(printout > 0)
6637 {
6638 Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
6639
6640 //idElements(Gomega1, "Gw");
6641 //headidString(Gomega1, "headGw");
6642
6643 PrintS("\n// compute a rGB of Gw:\n");
6644 }
6645#ifndef BUCHBERGER_ALG
6646 ivString(hilb_func, "w");
6647#endif
6648 }
6649#endif
6650#ifdef TIME_TEST
6651 tim = clock();
6652 to = clock();
6653#endif
6654 // compute a reduced Groebner basis of <Gomega> w.r.t. "newRing"
6655#ifdef BUCHBERGER_ALG
6656 M = MstdhomCC(Gomega1);
6657#else
6658 M=kStd2(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
6659 delete hilb_func;
6660#endif
6661#ifdef CHECK_IDEAL_MWALK
6662 if(printout > 2)
6663 {
6664 idString(M,"//** Mprwalk: M");
6665 }
6666#endif
6667#ifdef TIME_TEST
6668 if(endwalks == TRUE)
6669 {
6670 xtstd = xtstd+clock()-to;
6671#ifdef ENDWALKS
6672 Print("\n// time for the last std(Gw) = %.2f sec\n",
6673 ((double) clock())/1000000 -((double)tim) /1000000);
6674#endif
6675 }
6676 else
6677 tstd=tstd+clock()-to;
6678#endif
6679 /* change the ring to oldRing */
6680 rChangeCurrRing(oldRing);
6681 M1 = idrMoveR(M, newRing,currRing);
6682 Gomega2 = idrMoveR(Gomega1, newRing,currRing);
6683#ifdef TIME_TEST
6684 to=clock();
6685#endif
6686 /* compute a representation of the generators of submod (M)
6687 with respect to those of mod (Gomega).
6688 Gomega is a reduced Groebner basis w.r.t. the current ring */
6689 F = MLifttwoIdeal(Gomega2, M1, G);
6690#ifdef TIME_TEST
6691 if(endwalks == FALSE)
6692 tlift = tlift+clock()-to;
6693 else
6694 xtlift=clock()-to;
6695#endif
6696#ifdef CHECK_IDEAL_MWALK
6697 if(printout > 2)
6698 {
6699 idString(F,"//** Mprwalk: F");
6700 }
6701#endif
6702
6703 idDelete(&M1);
6704 idDelete(&Gomega2);
6705 idDelete(&G);
6706
6707 // change the ring to newRing
6708 rChangeCurrRing(newRing);
6709 if(reduction == 0)
6710 {
6711 G = idrMoveR(F,oldRing,currRing);
6712 }
6713 else
6714 {
6715 F1 = idrMoveR(F, oldRing,currRing);
6716 if(printout > 2)
6717 {
6718 PrintS("\n //** Mprwalk: reduce the Groebner basis.\n");
6719 }
6720#ifdef TIME_TEST
6721 to=clock();
6722#endif
6723 G = kInterRedCC(F1, NULL);
6724#ifdef TIME_TEST
6725 if(endwalks == FALSE)
6726 tred = tred+clock()-to;
6727 else
6728 xtred=clock()-to;
6729#endif
6730 idDelete(&F1);
6731 }
6732
6733 if(endwalks == TRUE)
6734 break;
6735
6736 NEXT_VECTOR:
6737#ifdef TIME_TEST
6738 to = clock();
6739#endif
6740 next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
6741#ifdef TIME_TEST
6742 tnw = tnw + clock() - to;
6743#endif
6744
6745#ifdef TIME_TEST
6746 to = clock();
6747#endif
6748 // compute an initial form ideal of <G> w.r.t. "next_vector"
6749 Gomega = MwalkInitialForm(G, next_weight);
6750#ifdef TIME_TEST
6751 tif = tif + clock()-to; //time for computing initial form ideal
6752#endif
6753
6754 //lengthpoly(Gomega) = 1 if there is a polynomial in Gomega with at least 3 monomials and 0 otherwise
6755 if(lengthpoly(Gomega) > 0)
6756 {
6757 if(printout > 1)
6758 {
6759 PrintS("\n Mpwalk: there is a polynomial in Gomega with at least 3 monomials.\n");
6760 }
6761 // low-dimensional facet of the cone
6762 delete next_weight;
6763 if(target_M->length() == nV)
6764 {
6765 iv_M = MivMatrixOrder(curr_weight);
6766 }
6767 else
6768 {
6769 iv_M = MivMatrixOrderRefine(curr_weight,target_M);
6770 }
6771#ifdef TIME_TEST
6772 to = clock();
6773#endif
6774 next_weight = MWalkRandomNextWeight(G, iv_M, target_weight, weight_rad, op_deg);
6775#ifdef TIME_TEST
6776 tnw = tnw + clock() - to;
6777#endif
6778 idDelete(&Gomega);
6779#ifdef TIME_TEST
6780 to = clock();
6781#endif
6782 Gomega = MwalkInitialForm(G, next_weight);
6783#ifdef TIME_TEST
6784 tif = tif + clock()-to; //time for computing initial form ideal
6785#endif
6786 delete iv_M;
6787 }
6788
6789#ifdef PRINT_VECTORS
6790 if(printout > 0)
6791 {
6792 MivString(curr_weight, target_weight, next_weight);
6793 }
6794#endif
6795
6796 if(Overflow_Error == TRUE)
6797 {
6798 ntwC = 0;
6799 //Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
6800 //idElements(G, "G");
6801 delete next_weight;
6802 goto FINISH_160302;
6803 }
6804 if(MivComp(next_weight, ivNull) == 1){
6805 newRing = currRing;
6806 delete next_weight;
6807 //Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
6808 break;
6809 }
6810 if(MivComp(next_weight, target_weight) == 1)
6811 endwalks = TRUE;
6812
6813 for(i=nV-1; i>=0; i--)
6814 (*curr_weight)[i] = (*next_weight)[i];
6815
6816 delete next_weight;
6817 }// end of while-loop
6818
6819 if(tp_deg != 1)
6820 {
6821 FINISH_160302:
6822 if(target_M->length() == nV)
6823 {
6824 if(MivSame(orig_target, exivlp) == 1)
6825 if (rParameter(currRing) != NULL)
6826 DefRingParlp();
6827 else
6828 VMrDefaultlp();
6829 else
6830 if (rParameter(currRing) != NULL)
6831 DefRingPar(orig_target);
6832 else
6833 rChangeCurrRing(VMrDefault(orig_target));
6834 }
6835 else
6836 {
6837 rChangeCurrRing(VMatrDefault(target_M));
6838 }
6839 TargetRing=currRing;
6840 F1 = idrMoveR(G, newRing,currRing);
6841
6842 // check whether the pertubed target vector stays in the correct cone
6843 if(ntwC != 0)
6844 {
6845 ntestw = test_w_in_ConeCC(F1, pert_target_vector);
6846 }
6847 if(ntestw != 1 || ntwC == 0)
6848 {
6849 if(ntestw != 1 && printout > 2)
6850 {
6851#ifdef PRINT_VECTORS
6852 ivString(pert_target_vector, "tau");
6853#endif
6854 PrintS("\n// **Mprwalk: perturbed target vector doesn't stay in cone.");
6855 Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
6856 //idElements(F1, "G");
6857 }
6858 // LastGB is "better" than the kStd2 subroutine
6859#ifdef TIME_TEST
6860 to=clock();
6861#endif
6862 ideal eF1;
6863 if(nP == 0 || tp_deg == 1 || MivSame(orig_target, exivlp) != 1 || target_M->length() != nV)
6864 {
6865 if(printout > 2)
6866 {
6867 PrintS("\n// ** Mprwalk: Call \"std\" to compute a Groebner basis.\n");
6868 }
6869 eF1 = MstdCC(F1);
6870 idDelete(&F1);
6871 }
6872 else
6873 {
6874 if(printout > 2)
6875 {
6876 PrintS("\n// **Mprwalk: Call \"LastGB\" to compute a Groebner basis.\n");
6877 }
6878 rChangeCurrRing(newRing);
6879 ideal F2 = idrMoveR(F1, TargetRing,currRing);
6880 eF1 = LastGB(F2, curr_weight, tp_deg-1);
6881 F2=NULL;
6882 }
6883#ifdef TIME_TEST
6884 xtextra=clock()-to;
6885#endif
6886 ring exTargetRing = currRing;
6887
6888 rChangeCurrRing(XXRing);
6889 Eresult = idrMoveR(eF1, exTargetRing,currRing);
6890 }
6891 else
6892 {
6893 rChangeCurrRing(XXRing);
6894 Eresult = idrMoveR(F1, TargetRing,currRing);
6895 }
6896 }
6897 else
6898 {
6899 rChangeCurrRing(XXRing);
6900 Eresult = idrMoveR(G, newRing,currRing);
6901 }
6902 si_opt_1 = save1; //set original options, e. g. option(RedSB)
6903 delete ivNull;
6904 if(tp_deg != 1)
6905 delete target_weight;
6906
6907 if(op_deg != 1 )
6908 delete curr_weight;
6909
6910 delete exivlp;
6911 delete last_omega;
6912
6913#ifdef TIME_TEST
6914 TimeStringFractal(tinput, tostd, tif+xtif, tstd+xtstd,0, tlift+xtlift, tred+xtred,
6915 tnw+xtnw);
6916
6917 //Print("\n// pSetm_Error = (%d)", ErrorCheck());
6918 //Print("\n// It took %d steps and Overflow_Error? (%d)\n", nstep, Overflow_Error);
6919#endif
6920
6921 if(printout > 0)
6922 {
6923 Print("\n//** Mprwalk: Perturbation Walk took %d steps.\n", nstep);
6924 }
6925 return(Eresult);
6926}
void F2(int a2, int &r2)
F2.
static int lengthpoly(ideal G)
Definition walk.cc:3441
static ideal middleOfCone(ideal G, ideal Gomega)
Definition walk.cc:3080
static intvec * MWalkRandomNextWeight(ideal G, intvec *orig_M, intvec *target_weight, int weight_rad, int pert_deg)
Definition walk.cc:4517
intvec * MivMatrixOrderRefine(intvec *iv, intvec *iw)
Definition walk.cc:984
static void idString(ideal L, const char *st)
Definition walk.cc:425

◆ Mpwalk()

ideal Mpwalk ( ideal Go,
int op_deg,
int tp_deg,
intvec * curr_weight,
intvec * target_weight,
int nP,
int reduction,
int printout )

Definition at line 5948 of file walk.cc.

5950{
5951 BITSET save1 = si_opt_1; // save current options
5952 if(reduction == 0)
5953 {
5954 si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis
5955 si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions
5956 }
5957 Set_Error(FALSE );
5959 //Print("// pSetm_Error = (%d)", ErrorCheck());
5960#ifdef TIME_TEST
5961 clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
5962 xtextra=0;
5963 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;
5964 tinput = clock();
5965
5966 clock_t tim;
5967#endif
5968 nstep = 0;
5969 int i, ntwC=1, ntestw=1, nV = currRing->N;
5970
5971 //check that perturbation degree is valid
5972 if(op_deg < 1 || tp_deg < 1 || op_deg > nV || tp_deg > nV)
5973 {
5974 WerrorS("Invalid perturbation degree.\n");
5975 return NULL;
5976 }
5977
5978 BOOLEAN endwalks = FALSE;
5979 ideal Gomega, M, F, FF, G, Gomega1, Gomega2, M1,F1,Eresult,ssG;
5980 ring newRing, oldRing, TargetRing;
5981 intvec* iv_M_dp;
5982 intvec* iv_M_lp;
5983 intvec* exivlp = Mivlp(nV);
5984 intvec* orig_target = target_weight;
5985 intvec* pert_target_vector = target_weight;
5986 intvec* ivNull = new intvec(nV);
5987 intvec* iv_dp = MivUnit(nV);// define (1,1,...,1)
5988#ifndef BUCHBERGER_ALG
5989 intvec* hilb_func;
5990#endif
5991 intvec* next_weight;
5992
5993 // to avoid (1,0,...,0) as the target vector
5994 intvec* last_omega = new intvec(nV);
5995 for(i=nV-1; i>0; i--)
5996 (*last_omega)[i] = 1;
5997 (*last_omega)[0] = 10000;
5998
5999 ring XXRing = currRing;
6000#ifdef TIME_TEST
6001 to = clock();
6002#endif
6003 // perturbs the original vector
6004 if(MivComp(curr_weight, iv_dp) == 1) //rOrdStr(currRing) := "dp"
6005 {
6006 G = MstdCC(Go);
6007#ifdef TIME_TEST
6008 tostd = clock()-to;
6009#endif
6010 if(op_deg != 1){
6011 iv_M_dp = MivMatrixOrderdp(nV);
6012 //ivString(iv_M_dp, "iv_M_dp");
6013 curr_weight = MPertVectors(G, iv_M_dp, op_deg);
6014 }
6015 }
6016 else
6017 {
6018 //define ring order := (a(curr_weight),lp);
6019/*
6020 if (rParameter(currRing) != NULL)
6021 DefRingPar(curr_weight);
6022 else
6023 rChangeCurrRing(VMrDefault(curr_weight));
6024*/
6025 rChangeCurrRing(VMrRefine(target_weight,curr_weight));
6026
6027 G = idrMoveR(Go, XXRing,currRing);
6028 G = MstdCC(G);
6029#ifdef TIME_TEST
6030 tostd = clock()-to;
6031#endif
6032 if(op_deg != 1){
6033 iv_M_dp = MivMatrixOrder(curr_weight);
6034 curr_weight = MPertVectors(G, iv_M_dp, op_deg);
6035 }
6036 }
6037 delete iv_dp;
6038 if(op_deg != 1) delete iv_M_dp;
6039
6040 ring HelpRing = currRing;
6041
6042 // perturbs the target weight vector
6043 if(tp_deg > 1 && tp_deg <= nV)
6044 {
6045/*
6046 if (rParameter(currRing) != NULL)
6047 DefRingPar(target_weight);
6048 else
6049 rChangeCurrRing(VMrDefault(target_weight));
6050*/
6051 rChangeCurrRing(VMrRefine(target_weight,curr_weight));
6052
6053 TargetRing = currRing;
6054 ssG = idrMoveR(G,HelpRing,currRing);
6055 if(MivSame(target_weight, exivlp) == 1)
6056 {
6057 iv_M_lp = MivMatrixOrderlp(nV);
6058 target_weight = MPertVectors(ssG, iv_M_lp, tp_deg);
6059 }
6060 else
6061 {
6062 iv_M_lp = MivMatrixOrder(target_weight);
6063 target_weight = MPertVectors(ssG, iv_M_lp, tp_deg);
6064 }
6065 delete iv_M_lp;
6066 pert_target_vector = target_weight;
6067 rChangeCurrRing(HelpRing);
6068 G = idrMoveR(ssG, TargetRing,currRing);
6069 }
6070 if(printout > 0)
6071 {
6072 Print("\n//** Mpwalk: Perturbation Walk of degree (%d,%d):",op_deg,tp_deg);
6073#ifdef PRINT_VECTORS
6074 ivString(curr_weight, "//** Mpwalk: new current weight");
6075 ivString(target_weight, "//** Mpwalk: new target weight");
6076#endif
6077 }
6078 while(1)
6079 {
6080 nstep ++;
6081#ifdef TIME_TEST
6082 to = clock();
6083#endif
6084 // compute an initial form ideal of <G> w.r.t. the weight vector
6085 // "curr_weight"
6086 Gomega = MwalkInitialForm(G, curr_weight);
6087#ifdef TIME_TEST
6088 tif = tif + clock()-to;
6089#endif
6090#ifdef CHECK_IDEAL_MWALK
6091 if(printout > 1)
6092 {
6093 idString(Gomega,"//** Mpwalk: Gomega");
6094 }
6095#endif
6096 if(reduction == 0 && nstep > 1)
6097 {
6098 FF = middleOfCone(G,Gomega);
6099 if(FF != NULL)
6100 {
6101 idDelete(&G);
6102 G = idCopy(FF);
6103 idDelete(&FF);
6104 goto NEXT_VECTOR;
6105 }
6106 }
6107
6108#ifdef ENDWALKS
6109 if(endwalks == TRUE)
6110 {
6111 if(printout > 0)
6112 {
6113 Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
6114 }
6115 //idElements(G, "G");
6116 //headidString(G, "G");
6117 }
6118#endif
6119
6120#ifndef BUCHBERGER_ALG
6121 if(isNolVector(curr_weight) == 0)
6122 hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing);
6123 else
6124 hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);
6125#endif // BUCHBERGER_ALG
6126
6127 oldRing = currRing;
6128
6129 // define a new ring with ordering "(a(curr_weight),lp)
6130/*
6131 if (rParameter(currRing) != NULL)
6132 DefRingPar(curr_weight);
6133 else
6134 rChangeCurrRing(VMrDefault(curr_weight));
6135*/
6136 rChangeCurrRing(VMrRefine(target_weight,curr_weight));
6137
6138 newRing = currRing;
6139 Gomega1 = idrMoveR(Gomega, oldRing,currRing);
6140
6141#ifdef ENDWALKS
6142 if(endwalks==TRUE)
6143 {
6144 if(printout > 0)
6145 {
6146 Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
6147 //idElements(Gomega1, "Gw");
6148 //headidString(Gomega1, "headGw");
6149 PrintS("\n// compute a rGB of Gw:\n");
6150 }
6151#ifndef BUCHBERGER_ALG
6152 ivString(hilb_func, "w");
6153#endif
6154 }
6155#endif
6156#ifdef TIME_TEST
6157 tim = clock();
6158 to = clock();
6159#endif
6160 // compute a reduced Groebner basis of <Gomega> w.r.t. "newRing"
6161#ifdef BUCHBERGER_ALG
6162 M = MstdhomCC(Gomega1);
6163#else
6164 M=kStd2(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
6165 delete hilb_func;
6166#endif
6167
6168 if(endwalks == TRUE)
6169 {
6170#ifdef TIME_TEST
6171 xtstd = xtstd+clock()-to;
6172#endif
6173#ifdef ENDWALKS
6174#ifdef TIME_TEST
6175 if(printout > 1)
6176 {
6177 Print("\n// time for the last std(Gw) = %.2f sec\n",
6178 ((double) clock())/1000000 -((double)tim) /1000000);
6179 }
6180#endif
6181#endif
6182 }
6183 else
6184 {
6185#ifdef TIME_TEST
6186 tstd=tstd+clock()-to;
6187#endif
6188 }
6189#ifdef CHECK_IDEAL_MWALK
6190 if(printout > 2)
6191 {
6192 idString(M,"//** Mpwalk: M");
6193 }
6194#endif
6195 // change the ring to oldRing
6196 rChangeCurrRing(oldRing);
6197 M1 = idrMoveR(M, newRing,currRing);
6198 Gomega2 = idrMoveR(Gomega1, newRing,currRing);
6199#ifdef TIME_TEST
6200 to=clock();
6201#endif
6202 /* compute a representation of the generators of submod (M)
6203 with respect to those of mod (Gomega).
6204 Gomega is a reduced Groebner basis w.r.t. the current ring */
6205 F = MLifttwoIdeal(Gomega2, M1, G);
6206#ifdef TIME_TEST
6207 if(endwalks == FALSE)
6208 tlift = tlift+clock()-to;
6209 else
6210 xtlift=clock()-to;
6211#endif
6212#ifdef CHECK_IDEAL_MWALK
6213 if(printout > 2)
6214 {
6215 idString(F,"//** Mpwalk: F");
6216 }
6217#endif
6218
6219 idDelete(&M1);
6220 idDelete(&Gomega2);
6221 idDelete(&G);
6222
6223 // change the ring to newRing
6224 rChangeCurrRing(newRing);
6225 if(reduction == 0)
6226 {
6227 G = idrMoveR(F,oldRing,currRing);
6228 }
6229 else
6230 {
6231 F1 = idrMoveR(F, oldRing,currRing);
6232 if(printout > 2)
6233 {
6234 PrintS("\n //** Mpwalk: reduce the Groebner basis.\n");
6235 }
6236#ifdef TIME_TEST
6237 to=clock();
6238#endif
6239 G = kInterRedCC(F1, NULL);
6240#ifdef TIME_TEST
6241 if(endwalks == FALSE)
6242 tred = tred+clock()-to;
6243 else
6244 xtred=clock()-to;
6245#endif
6246 idDelete(&F1);
6247 }
6248 if(endwalks == TRUE)
6249 break;
6250
6251 NEXT_VECTOR:
6252#ifdef TIME_TEST
6253 to=clock();
6254#endif
6255 // compute a next weight vector
6256 next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
6257#ifdef TIME_TEST
6258 tnw=tnw+clock()-to;
6259#endif
6260#ifdef PRINT_VECTORS
6261 if(printout > 0)
6262 {
6263 MivString(curr_weight, target_weight, next_weight);
6264 }
6265#endif
6266
6267 if(Overflow_Error == TRUE)
6268 {
6269 ntwC = 0;
6270 //ntestomega = 1;
6271 //Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
6272 //idElements(G, "G");
6273 delete next_weight;
6274 goto FINISH_160302;
6275 }
6276 if(MivComp(next_weight, ivNull) == 1){
6277 newRing = currRing;
6278 delete next_weight;
6279 //Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
6280 break;
6281 }
6282 if(MivComp(next_weight, target_weight) == 1)
6283 endwalks = TRUE;
6284
6285 for(i=nV-1; i>=0; i--)
6286 (*curr_weight)[i] = (*next_weight)[i];
6287
6288 delete next_weight;
6289 }//end of while-loop
6290
6291 if(tp_deg != 1)
6292 {
6293 FINISH_160302:
6294 if(MivSame(orig_target, exivlp) == 1) {
6295 /* if (rParameter(currRing) != NULL)
6296 DefRingParlp();
6297 else
6298 VMrDefaultlp();
6299 else
6300 if (rParameter(currRing) != NULL)
6301 DefRingPar(orig_target);
6302 else*/
6303 rChangeCurrRing(VMrDefault(orig_target));
6304 }
6305 TargetRing=currRing;
6306 F1 = idrMoveR(G, newRing,currRing);
6307/*
6308#ifdef CHECK_IDEAL_MWALK
6309 headidString(G, "G");
6310#endif
6311*/
6312
6313 // check whether the pertubed target vector stays in the correct cone
6314 if(ntwC != 0){
6315 ntestw = test_w_in_ConeCC(F1, pert_target_vector);
6316 }
6317
6318 if( ntestw != 1 || ntwC == 0)
6319 {
6320 if(ntestw != 1 && printout >2)
6321 {
6322 ivString(pert_target_vector, "tau");
6323 PrintS("\n// ** perturbed target vector doesn't stay in cone!!");
6324 Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
6325 //idElements(F1, "G");
6326 }
6327 // LastGB is "better" than the kStd2 subroutine
6328#ifdef TIME_TEST
6329 to=clock();
6330#endif
6331 ideal eF1;
6332 if(nP == 0 || tp_deg == 1 || MivSame(orig_target, exivlp) != 1){
6333 // PrintS("\n// ** calls \"std\" to compute a GB");
6334 eF1 = MstdCC(F1);
6335 idDelete(&F1);
6336 }
6337 else {
6338 // PrintS("\n// ** calls \"LastGB\" to compute a GB");
6339 rChangeCurrRing(newRing);
6340 ideal F2 = idrMoveR(F1, TargetRing,currRing);
6341 eF1 = LastGB(F2, curr_weight, tp_deg-1);
6342 F2=NULL;
6343 }
6344#ifdef TIME_TEST
6345 xtextra=clock()-to;
6346#endif
6347 ring exTargetRing = currRing;
6348
6349 rChangeCurrRing(XXRing);
6350 Eresult = idrMoveR(eF1, exTargetRing,currRing);
6351 }
6352 else{
6353 rChangeCurrRing(XXRing);
6354 Eresult = idrMoveR(F1, TargetRing,currRing);
6355 }
6356 }
6357 else {
6358 rChangeCurrRing(XXRing);
6359 Eresult = idrMoveR(G, newRing,currRing);
6360 }
6361 si_opt_1 = save1; //set original options, e. g. option(RedSB)
6362 delete ivNull;
6363 if(tp_deg != 1)
6364 delete target_weight;
6365
6366 if(op_deg != 1 )
6367 delete curr_weight;
6368
6369 delete exivlp;
6370 delete last_omega;
6371
6372#ifdef TIME_TEST
6373 TimeStringFractal(tinput, tostd, tif+xtif, tstd+xtstd,0, tlift+xtlift, tred+xtred,
6374 tnw+xtnw);
6375
6376 //Print("\n// pSetm_Error = (%d)", ErrorCheck());
6377 //Print("\n// It took %d steps and Overflow_Error? (%d)\n", nstep, Overflow_Error);
6378#endif
6379 if(printout > 0)
6380 {
6381 Print("\n//** Mpwalk: Perturbation Walk took %d steps.\n", nstep);
6382 }
6383 return(Eresult);
6384}

◆ Mpwalk_MAltwalk1()

static ideal Mpwalk_MAltwalk1 ( ideal Go,
intvec * curr_weight,
int tp_deg )
static

Definition at line 9378 of file walk.cc.

9379{
9381 // BOOLEAN nOverflow_Error = FALSE;
9382#ifdef TIME_TEST
9383 clock_t tproc=0;
9384 clock_t tinput=clock();
9385#endif
9386 int i, nV = currRing->N;
9387
9388 //check that perturbation degree is valid
9389 if(tp_deg < 1 || tp_deg > nV)
9390 {
9391 WerrorS("Invalid perturbation degree.\n");
9392 return NULL;
9393 }
9394
9395 int nwalk=0, endwalks=0, ntestwinC=1;
9396 int tp_deg_tmp = tp_deg;
9397 ideal Gomega, M, F, G, M1, F1, Gomega1, Gomega2, G1;
9398 ring newRing, oldRing, TargetRing;
9399 intvec* next_weight;
9400 intvec* ivNull = new intvec(nV);
9401
9402 ring YXXRing = currRing;
9403
9404 intvec* iv_M_dpp = MivMatrixOrderlp(nV);
9405 intvec* target_weight;// = Mivlp(nV);
9406 ideal ssG;
9407
9408 // perturb the target vector
9409 while(1)
9410 {
9411 if(Overflow_Error == FALSE)
9412 {
9413 if (rParameter(currRing) != NULL)
9414 {
9415 DefRingParlp();
9416 }
9417 else
9418 {
9419 VMrDefaultlp();
9420 }
9421 TargetRing = currRing;
9422 ssG = idrMoveR(Go,YXXRing,currRing);
9423 }
9425 if(tp_deg != 1)
9426 {
9427 target_weight = MPertVectors(ssG, iv_M_dpp, tp_deg);
9428 }
9429 else
9430 {
9431 target_weight = Mivlp(nV);
9432 break;
9433 }
9434 if(Overflow_Error == FALSE)
9435 {
9436 break;
9437 }
9439 tp_deg --;
9440 }
9441 if(tp_deg != tp_deg_tmp)
9442 {
9444 //nOverflow_Error = TRUE;
9445 }
9446
9447 // Print("\n// tp_deg = %d", tp_deg);
9448 // ivString(target_weight, "pert target");
9449
9450 delete iv_M_dpp;
9451#ifndef BUCHBERGER_ALG
9452 intvec* hilb_func;
9453#endif
9454 // to avoid (1,0,...,0) as the target vector
9455 intvec* last_omega = new intvec(nV);
9456 for(i=nV-1; i>0; i--)
9457 {
9458 (*last_omega)[i] = 1;
9459 }
9460 (*last_omega)[0] = 10000;
9461
9462 rChangeCurrRing(YXXRing);
9463 G = idrMoveR(ssG, TargetRing,currRing);
9464
9465 while(1)
9466 {
9467 nwalk ++;
9468 nstep ++;
9469
9470 if(nwalk==1)
9471 {
9472 goto FIRST_STEP;
9473 }
9474#ifdef TIME_TEST
9475 to=clock();
9476#endif
9477 // compute an initial form ideal of <G> w.r.t. "curr_vector"
9478 Gomega = MwalkInitialForm(G, curr_weight);
9479#ifdef TIME_TEST
9480 xtif=xtif+clock()-to;
9481#endif
9482
9483#ifndef BUCHBERGER_ALG
9484 if(isNolVector(curr_weight) == 0)
9485 hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing);
9486 else
9487 hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);
9488#endif
9489
9490 oldRing = currRing;
9491
9492 // define a new ring that its ordering is "(a(curr_weight),lp)
9493 if (rParameter(currRing) != NULL)
9494 {
9495 DefRingPar(curr_weight);
9496 }
9497 else
9498 {
9499 rChangeCurrRing(VMrDefault(curr_weight));
9500 }
9501 newRing = currRing;
9502 Gomega1 = idrMoveR(Gomega, oldRing,currRing);
9503/*
9504#ifdef ENDWALKS
9505 if(endwalks == 1)
9506 {
9507 Print("\n// it is %d-th step!!", nwalk);
9508 idString(Gomega1, "Gw");
9509 PrintS("\n// compute a rGB of Gw:");
9510 }
9511#endif
9512*/
9513#ifdef TIME_TEST
9514 to=clock();
9515#endif
9516 // compute a reduced Groebner basis of <Gomega> w.r.t. "newRing"
9517#ifdef BUCHBERGER_ALG
9518 M = MstdhomCC(Gomega1);
9519#else
9520 M=kStd2(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
9521 delete hilb_func;
9522#endif // BUCHBERGER_ALG
9523#ifdef TIME_TEST
9524 xtstd=xtstd+clock()-to;
9525#endif
9526
9527 // change the ring to oldRing
9528 rChangeCurrRing(oldRing);
9529 M1 = idrMoveR(M, newRing,currRing);
9530 Gomega2 = idrMoveR(Gomega1, newRing,currRing);
9531#ifdef TIME_TEST
9532 to=clock();
9533#endif
9534
9535 // if(endwalks == 1){PrintS("\n// Lifting is still working:");}
9536
9537 // compute a reduced Groebner basis of <G> w.r.t. "newRing" by the lifting process
9538 F = MLifttwoIdeal(Gomega2, M1, G);
9539#ifdef TIME_TEST
9540 xtlift=xtlift+clock()-to;
9541#endif
9542
9543 idDelete(&M1);
9544 idDelete(&Gomega2);
9545 idDelete(&G);
9546
9547 // change the ring to newRing
9548 rChangeCurrRing(newRing);
9549 F1 = idrMoveR(F, oldRing,currRing);
9550#ifdef TIME_TEST
9551 to=clock();
9552#endif
9553 //if(endwalks == 1){ PrintS("\n// InterRed is still working:");}
9554 // reduce the Groebner basis <G> w.r.t. the new ring
9555 G = kInterRedCC(F1, NULL);
9556#ifdef TIME_TEST
9557 xtred=xtred+clock()-to;
9558#endif
9559 idDelete(&F1);
9560
9561 if(endwalks == 1)
9562 break;
9563
9564 FIRST_STEP:
9566#ifdef TIME_TEST
9567 to=clock();
9568#endif
9569 // compute a next weight vector
9570 next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
9571#ifdef TIME_TEST
9572 xtnw=xtnw+clock()-to;
9573#endif
9574#ifdef PRINT_VECTORS
9575 MivString(curr_weight, target_weight, next_weight);
9576#endif
9577
9578 if(Overflow_Error == TRUE)
9579 {
9580 delete next_weight;
9581 if(tp_deg > 1){
9582 //nOverflow_Error = Overflow_Error;
9583#ifdef TIME_TEST
9584 tproc = tproc+clock()-tinput;
9585#endif
9586 //Print("\n// A subroutine takes %d steps and calls \"Mpwalk\" (1,%d):", nwalk, tp_deg-1);
9587 G1 = Mpwalk_MAltwalk1(G, curr_weight, tp_deg-1);
9588 goto MPW_Finish;
9589 }
9590 else {
9591 newRing = currRing;
9592 ntestwinC = 0;
9593 break;
9594 }
9595 }
9596
9597 if(MivComp(next_weight, ivNull) == 1)
9598 {
9599 newRing = currRing;
9600 delete next_weight;
9601 break;
9602 }
9603 if(MivComp(next_weight, target_weight) == 1)
9604 {
9605 endwalks = 1;
9606 }
9607 for(i=nV-1; i>=0; i--)
9608 {
9609 //(*extra_curr_weight)[i] = (*curr_weight)[i];
9610 (*curr_weight)[i] = (*next_weight)[i];
9611 }
9612 delete next_weight;
9613 }//while
9614
9615 // check whether the pertubed target vector is correct
9616
9617 //define and execute ring with lex. order
9618 if (rParameter(currRing) != NULL)
9619 {
9620 DefRingParlp();
9621 }
9622 else
9623 {
9624 VMrDefaultlp();
9625 }
9626 G1 = idrMoveR(G, newRing,currRing);
9627
9628 if( test_w_in_ConeCC(G1, target_weight) != 1 || ntestwinC == 0)
9629 {
9630 //PrintS("\n// The perturbed target vector doesn't STAY in the correct cone!!");
9631 if(tp_deg == 1)
9632 {
9633 //Print("\n// subroutine takes %d steps and applys \"std\"", nwalk);
9634#ifdef TIME_TEST
9635 to=clock();
9636#endif
9637 ideal G2 = MstdCC(G1);
9638#ifdef TIME_TEST
9639 xtextra=xtextra+clock()-to;
9640#endif
9641 idDelete(&G1);
9642 G1 = G2;
9643 G2 = NULL;
9644 }
9645 else
9646 {
9647 //nOverflow_Error = Overflow_Error;
9648#ifdef TIME_TEST
9649 tproc = tproc+clock()-tinput;
9650#endif
9651 // Print("\n// B subroutine takes %d steps and calls \"Mpwalk\" (1,%d) :", nwalk, tp_deg-1);
9652 G1 = Mpwalk_MAltwalk1(G1, curr_weight, tp_deg-1);
9653 }
9654 }
9655
9656 MPW_Finish:
9657 newRing = currRing;
9658 rChangeCurrRing(YXXRing);
9659 ideal result = idrMoveR(G1, newRing,currRing);
9660
9661 delete ivNull;
9662 delete target_weight;
9663
9664 //Print("\n// \"Mpwalk\" (1,%d) took %d steps and %.2f sec. Overflow_Error (%d)", tp_deg, nwalk, ((double) clock()-tinput)/1000000, nOverflow_Error);
9665 //Print("\n// Mprwalk took %d steps. Ring= %s;\n", nwalk, rString(currRing));
9666 return(result);
9667}

◆ Mrwalk()

ideal Mrwalk ( ideal Go,
intvec * orig_M,
intvec * target_M,
int weight_rad,
int pert_deg,
int reduction,
int printout )

Definition at line 5604 of file walk.cc.

5606{
5607 BITSET save1 = si_opt_1; // save current options
5608 if(reduction == 0)
5609 {
5610 si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis
5611 si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions
5612 }
5613
5616#ifdef TIME_TEST
5617 clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
5618 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;
5619 tinput = clock();
5620 clock_t tim;
5621#endif
5622 nstep=0;
5623 int i,nwalk;//polylength;
5624 int nV = currRing->N;
5625
5626 //check that weight radius is valid
5627 if(weight_rad < 0)
5628 {
5629 WerrorS("Invalid radius.\n");
5630 return NULL;
5631 }
5632
5633 //check that perturbation degree is valid
5634 if(pert_deg > nV || pert_deg < 1)
5635 {
5636 WerrorS("Invalid perturbation degree.\n");
5637 return NULL;
5638 }
5639
5640 ideal Gomega, M, F,FF, Gomega1, Gomega2, M1;
5641 ring newRing;
5642 ring targetRing;
5643 ring baseRing = currRing;
5644 ring XXRing = currRing;
5645 intvec* iv_M;
5646 intvec* ivNull = new intvec(nV);
5647 intvec* curr_weight = new intvec(nV);
5648 intvec* target_weight = new intvec(nV);
5649 intvec* next_weight= new intvec(nV);
5650
5651 for(i=0; i<nV; i++)
5652 {
5653 (*curr_weight)[i] = (*orig_M)[i];
5654 (*target_weight)[i] = (*target_M)[i];
5655 }
5656
5657#ifndef BUCHBERGER_ALG
5658 intvec* hilb_func;
5659 // to avoid (1,0,...,0) as the target vector
5660 intvec* last_omega = new intvec(nV);
5661 for(i=nV-1; i>0; i--)
5662 {
5663 (*last_omega)[i] = 1;
5664 }
5665 (*last_omega)[0] = 10000;
5666#endif
5668
5669 if(target_M->length() == nV)
5670 {
5671 targetRing = VMrDefault(target_weight); // define the target ring
5672 }
5673 else
5674 {
5675 targetRing = VMatrDefault(target_M);
5676 }
5677 if(orig_M->length() == nV)
5678 {
5679 //newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp)
5680 newRing=VMrRefine(target_weight, curr_weight);
5681 }
5682 else
5683 {
5684 newRing = VMatrRefine(target_M,curr_weight);//newRing = VMatrDefault(orig_M);
5685 }
5686 rChangeCurrRing(newRing);
5687#ifdef TIME_TEST
5688 to = clock();
5689#endif
5690 ideal G = MstdCC(idrMoveR(Go,baseRing,currRing));
5691#ifdef TIME_TEST
5692 tostd = clock()-to;
5693#endif
5694 baseRing = currRing;
5695 nwalk = 0;
5696
5697#ifdef TIME_TEST
5698 to = clock();
5699#endif
5700 Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"
5701#ifdef TIME_TEST
5702 tif = tif + clock()-to; //time for computing initial form ideal
5703#endif
5704
5705 while(1)
5706 {
5707 nwalk ++;
5708 nstep ++;
5709#ifdef CHECK_IDEAL_MWALK
5710 if(printout > 1)
5711 {
5712 idString(Gomega,"//** Mrwalk: Gomega");
5713 }
5714#endif
5715 if(reduction == 0)
5716 {
5717 FF = middleOfCone(G,Gomega);
5718 if(FF != NULL)
5719 {
5720 idDelete(&G);
5721 G = idCopy(FF);
5722 idDelete(&FF);
5723 goto NEXT_VECTOR;
5724 }
5725 }
5726#ifndef BUCHBERGER_ALG
5727 if(isNolVector(curr_weight) == 0)
5728 {
5729 hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing);
5730 }
5731 else
5732 {
5733 hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);
5734 }
5735#endif
5736 if(nwalk == 1)
5737 {
5738 if(orig_M->length() == nV)
5739 {
5740 /*newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp)*/
5741 newRing=VMrRefine(target_weight, curr_weight);
5742 }
5743 else
5744 {
5745 newRing = VMatrRefine(target_M,curr_weight);//newRing = VMatrDefault(orig_M);
5746 }
5747 }
5748 else
5749 {
5750 if(target_M->length() == nV)
5751 {
5752 /*newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp)*/
5753 newRing=VMrRefine(target_weight, curr_weight);
5754 }
5755 else
5756 {
5757 newRing = VMatrRefine(target_M,curr_weight);
5758 }
5759 }
5760 rChangeCurrRing(newRing);
5761 Gomega1 = idrMoveR(Gomega, baseRing,currRing);
5762 idDelete(&Gomega);
5763 // compute a reduced Groebner basis of <Gomega> w.r.t. "newRing"
5764#ifdef TIME_TEST
5765 to = clock();
5766#endif
5767#ifndef BUCHBERGER_ALG
5768 M=kStd2(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
5769 delete hilb_func;
5770#else
5771 M = kStd2(Gomega1,NULL,testHomog,NULL,(bigintmat*)NULL,0,0,NULL);
5772#endif
5773#ifdef TIME_TEST
5774 tstd = tstd + clock() - to;
5775#endif
5776 idSkipZeroes(M);
5777#ifdef CHECK_IDEAL_MWALK
5778 if(printout > 2)
5779 {
5780 idString(M, "//** Mrwalk: M");
5781 }
5782#endif
5783 //change the ring to baseRing
5784 rChangeCurrRing(baseRing);
5785 M1 = idrMoveR(M, newRing,currRing);
5786 idDelete(&M);
5787 Gomega2 = idrMoveR(Gomega1, newRing,currRing);
5788 idDelete(&Gomega1);
5789#ifdef TIME_TEST
5790 to = clock();
5791#endif
5792 // compute a representation of the generators of submod (M) with respect to those of mod (Gomega),
5793 // where Gomega is a reduced Groebner basis w.r.t. the current ring
5794 F = MLifttwoIdeal(Gomega2, M1, G);
5795#ifdef TIME_TEST
5796 tlift = tlift + clock() - to;
5797#endif
5798#ifdef CHECK_IDEAL_MWALK
5799 if(printout > 2)
5800 {
5801 idString(F,"//** Mrwalk: F");
5802 }
5803#endif
5804 idDelete(&Gomega2);
5805 idDelete(&M1);
5806 rChangeCurrRing(newRing); // change the ring to newRing
5807 G = idrMoveR(F,baseRing,currRing);
5808 idDelete(&F);
5809 baseRing = currRing;
5810#ifdef TIME_TEST
5811 to = clock();
5812 tstd = tstd + clock() - to;
5813#endif
5814 idSkipZeroes(G);
5815#ifdef CHECK_IDEAL_MWALK
5816 if(printout > 2)
5817 {
5818 idString(G,"//** Mrwalk: G");
5819 }
5820#endif
5821
5822 rChangeCurrRing(targetRing);
5823 G = idrMoveR(G,newRing,currRing);
5824
5825 // test whether target cone is reached
5826 if(reduction !=0 && test_w_in_ConeCC(G,curr_weight) == 1)
5827 {
5828 baseRing = currRing;
5829 break;
5830 }
5831
5832 rChangeCurrRing(newRing);
5833 G = idrMoveR(G,targetRing,currRing);
5834 baseRing = currRing;
5835
5836 NEXT_VECTOR:
5837#ifdef TIME_TEST
5838 to = clock();
5839#endif
5840 next_weight = MwalkNextWeightCC(curr_weight,target_weight,G);
5841#ifdef TIME_TEST
5842 tnw = tnw + clock() - to;
5843#endif
5844
5845#ifdef TIME_TEST
5846 to = clock();
5847#endif
5848 Gomega = MwalkInitialForm(G, next_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"
5849#ifdef TIME_TEST
5850 tif = tif + clock()-to; //time for computing initial form ideal
5851#endif
5852
5853 //lengthpoly(Gomega) = 1 if there is a polynomial in Gomega with at least 3 monomials and 0 otherwise
5854 //polylength = lengthpoly(Gomega);
5855 if(lengthpoly(Gomega) > 0)
5856 {
5857 //there is a polynomial in Gomega with at least 3 monomials,
5858 //low-dimensional facet of the cone
5859 delete next_weight;
5860 if(target_M->length() == nV)
5861 {
5862 //iv_M = MivMatrixOrder(curr_weight);
5863 iv_M = MivMatrixOrderRefine(curr_weight,target_M);
5864 }
5865 else
5866 {
5867 iv_M = MivMatrixOrderRefine(curr_weight,target_M);
5868 }
5869#ifdef TIME_TEST
5870 to = clock();
5871#endif
5872 next_weight = MWalkRandomNextWeight(G, iv_M, target_weight, weight_rad, pert_deg);
5873#ifdef TIME_TEST
5874 tnw = tnw + clock() - to;
5875#endif
5876 idDelete(&Gomega);
5877#ifdef TIME_TEST
5878 to = clock();
5879#endif
5880 Gomega = MwalkInitialForm(G, next_weight);
5881#ifdef TIME_TEST
5882 tif = tif + clock()-to; //time for computing initial form ideal
5883#endif
5884 delete iv_M;
5885 }
5886
5887 // test whether target weight vector is reached
5888 if(MivComp(next_weight, ivNull) == 1 || MivComp(target_weight,curr_weight) == 1)
5889 {
5890 baseRing = currRing;
5891 delete next_weight;
5892 break;
5893 }
5894 if(reduction ==0)
5895 {
5896 if(MivComp(curr_weight,next_weight)==1)
5897 {
5898 break;
5899 }
5900 }
5901#ifdef PRINT_VECTORS
5902 if(printout > 0)
5903 {
5904 MivString(curr_weight, target_weight, next_weight);
5905 }
5906#endif
5907
5908 for(i=nV-1; i>=0; i--)
5909 {
5910 (*curr_weight)[i] = (*next_weight)[i];
5911 }
5912 delete next_weight;
5913 }
5914 baseRing = currRing;
5915 rChangeCurrRing(XXRing);
5916 ideal result = idrMoveR(G,baseRing,currRing);
5917 idDelete(&G);
5918 delete ivNull;
5919#ifndef BUCHBERGER_ALG
5920 delete last_omega;
5921#endif
5922 if(printout > 0)
5923 {
5924 Print("\n//** Mrwalk: Groebner Walk took %d steps.\n", nstep);
5925 }
5926#ifdef TIME_TEST
5927 TimeString(tinput, tostd, tif, tstd, tlift, tred, tnw, nstep);
5928 //Print("\n// pSetm_Error = (%d)", ErrorCheck());
5929 //Print("\n// Overflow_Error? (%d)\n", Overflow_Error);
5930#endif
5931 si_opt_1 = save1; //set original options
5932 return(result);
5933}
Matrices of numbers.
Definition bigintmat.h:51
@ testHomog
Definition structs.h:34

◆ MstdCC()

static ideal MstdCC ( ideal G)
static

Definition at line 933 of file walk.cc.

934{
935 BITSET save1,save2;
936 SI_SAVE_OPT(save1,save2);
938 ideal G1 = kStd2(G, NULL, testHomog, NULL,(bigintmat*)NULL);
939 SI_RESTORE_OPT(save1,save2);
940
941 idSkipZeroes(G1);
942 return G1;
943}
#define SI_SAVE_OPT(A, B)
Definition options.h:20
#define SI_RESTORE_OPT(A, B)
Definition options.h:23

◆ MstdhomCC()

static ideal MstdhomCC ( ideal G)
static

Definition at line 948 of file walk.cc.

949{
950 BITSET save1,save2;
951 SI_SAVE_OPT(save1,save2);
953 ideal G1 = kStd2(G, NULL, isHomog, NULL,(bigintmat*)NULL);
954 SI_RESTORE_OPT(save1,save2);
955
956 idSkipZeroes(G1);
957 return G1;
958}

◆ Mwalk()

ideal Mwalk ( ideal Go,
intvec * orig_M,
intvec * target_M,
ring baseRing,
int reduction,
int printout )

Definition at line 5303 of file walk.cc.

5305{
5306 // save current options
5307 BITSET save1 = si_opt_1;
5308 if(reduction == 0)
5309 {
5310 si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis
5311 si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions
5312 }
5315 //BOOLEAN endwalks = FALSE;
5316#ifdef TIME_TEST
5317 clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
5318 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;
5319 tinput = clock();
5320 clock_t tim;
5321#endif
5322 nstep=0;
5323 int i,nwalk;
5324 int nV = baseRing->N;
5325
5326 ideal Gomega, M, F, FF, Gomega1, Gomega2, M1;
5327 ring newRing;
5328 ring XXRing = baseRing;
5329 ring targetRing;
5330 intvec* ivNull = new intvec(nV);
5331 intvec* curr_weight = new intvec(nV);
5332 intvec* target_weight = new intvec(nV);
5333 intvec* exivlp = Mivlp(nV);
5334/*
5335 intvec* tmp_weight = new intvec(nV);
5336 for(i=0; i<nV; i++)
5337 {
5338 (*tmp_weight)[i] = (*orig_M)[i];
5339 }
5340*/
5341 for(i=0; i<nV; i++)
5342 {
5343 (*curr_weight)[i] = (*orig_M)[i];
5344 (*target_weight)[i] = (*target_M)[i];
5345 }
5346#ifndef BUCHBERGER_ALG
5347 intvec* hilb_func;
5348 // to avoid (1,0,...,0) as the target vector
5349 intvec* last_omega = new intvec(nV);
5350 for(i=nV-1; i>0; i--)
5351 {
5352 (*last_omega)[i] = 1;
5353 }
5354 (*last_omega)[0] = 10000;
5355#endif
5357#ifdef CHECK_IDEAL_MWALK
5358 if(printout > 2)
5359 {
5360 idString(Go,"//** Mwalk: Go");
5361 }
5362#endif
5363
5364 if(target_M->length() == nV)
5365 {
5366 // define the target ring
5367 targetRing = VMrDefault(target_weight);
5368 }
5369 else
5370 {
5371 targetRing = VMatrDefault(target_M);
5372 }
5373 if(orig_M->length() == nV)
5374 {
5375 // define a new ring with ordering "(a(curr_weight),lp)
5376 //newRing = VMrDefault(curr_weight);
5377 newRing=VMrRefine(target_weight, curr_weight);
5378 }
5379 else
5380 {
5381 newRing = VMatrRefine(target_M,curr_weight); //newRing = VMatrDefault(orig_M);
5382 }
5383 rChangeCurrRing(newRing);
5384 if(printout > 2)
5385 {
5386 Print("\n//** Mrwalk: Current ring r = %s;\n", rString(currRing));
5387 }
5388#ifdef TIME_TEST
5389 to = clock();
5390#endif
5391 ideal G = MstdCC(idrMoveR(Go,baseRing,currRing));
5392#ifdef TIME_TEST
5393 tostd = clock()-to;
5394#endif
5395
5396 baseRing = currRing;
5397 nwalk = 0;
5398
5399 while(1)
5400 {
5401 nwalk ++;
5402 nstep ++;
5403 //compute an initial form ideal of <G> w.r.t. "curr_vector"
5404#ifdef TIME_TEST
5405 to = clock();
5406#endif
5407 Gomega = MwalkInitialForm(G, curr_weight);
5408#ifdef TIME_TEST
5409 tif = tif + clock()-to;
5410#endif
5411
5412#ifdef CHECK_IDEAL_MWALK
5413 if(printout > 1)
5414 {
5415 idString(Gomega,"//** Mwalk: Gomega");
5416 }
5417#endif
5418
5419 if(reduction == 0)
5420 {
5421 FF = middleOfCone(G,Gomega);
5422 if(FF != NULL)
5423 {
5424 PrintS("middle of Cone");
5425 idDelete(&G);
5426 G = idCopy(FF);
5427 idDelete(&FF);
5428 goto NEXT_VECTOR;
5429 }
5430 }
5431
5432#ifndef BUCHBERGER_ALG
5433 if(isNolVector(curr_weight) == 0)
5434 {
5435 hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing);
5436 }
5437 else
5438 {
5439 hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);
5440 }
5441#endif
5442
5443 if(nwalk == 1)
5444 {
5445 if(orig_M->length() == nV)
5446 {
5447 // define a new ring with ordering "(a(curr_weight),lp)
5448 //newRing = VMrDefault(curr_weight);
5449 newRing=VMrRefine(target_weight, curr_weight);
5450 }
5451 else
5452 {
5453 newRing = VMatrRefine(target_M,curr_weight);//newRing = VMatrDefault(orig_M);
5454 }
5455 }
5456 else
5457 {
5458 if(target_M->length() == nV)
5459 {
5460 //define a new ring with ordering "(a(curr_weight),lp)"
5461 //newRing = VMrDefault(curr_weight);
5462 newRing=VMrRefine(target_weight, curr_weight);
5463 }
5464 else
5465 {
5466 //define a new ring with matrix ordering
5467 newRing = VMatrRefine(target_M,curr_weight);
5468 }
5469 }
5470 rChangeCurrRing(newRing);
5471 if(printout > 2)
5472 {
5473 Print("\n// Current ring r = %s;\n", rString(currRing));
5474 }
5475 Gomega1 = idrMoveR(Gomega, baseRing,currRing);
5476 idDelete(&Gomega);
5477 // compute a reduced Groebner basis of <Gomega> w.r.t. "newRing"
5478#ifdef TIME_TEST
5479 to = clock();
5480#endif
5481#ifndef BUCHBERGER_ALG
5482 M=kStd2(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
5483 delete hilb_func;
5484#else
5485 M = kStd2(Gomega1,NULL,testHomog,NULL,(bigintmat*)NULL,0,0,NULL);
5486#endif
5487#ifdef TIME_TEST
5488 tstd = tstd + clock() - to;
5489#endif
5490 idSkipZeroes(M);
5491#ifdef CHECK_IDEAL_MWALK
5492 if(printout > 2)
5493 {
5494 idString(M, "//** Mwalk: M");
5495 }
5496#endif
5497 //change the ring to baseRing
5498 rChangeCurrRing(baseRing);
5499 M1 = idrMoveR(M, newRing,currRing);
5500 idDelete(&M);
5501 Gomega2 = idrMoveR(Gomega1, newRing,currRing);
5502 idDelete(&Gomega1);
5503#ifdef TIME_TEST
5504 to = clock();
5505#endif
5506 // compute a representation of the generators of submod (M) with respect to those of mod (Gomega),
5507 // where Gomega is a reduced Groebner basis w.r.t. the current ring
5508 F = MLifttwoIdeal(Gomega2, M1, G);
5509#ifdef TIME_TEST
5510 tlift = tlift + clock() - to;
5511#endif
5512#ifdef CHECK_IDEAL_MWALK
5513 if(printout > 2)
5514 {
5515 idString(F, "//** Mwalk: F");
5516 }
5517#endif
5518 idDelete(&Gomega2);
5519 idDelete(&M1);
5520
5521 rChangeCurrRing(newRing); // change the ring to newRing
5522 G = idrMoveR(F,baseRing,currRing);
5523 idDelete(&F);
5524 idSkipZeroes(G);
5525
5526#ifdef CHECK_IDEAL_MWALK
5527 if(printout > 2)
5528 {
5529 idString(G, "//** Mwalk: G");
5530 }
5531#endif
5532
5533 rChangeCurrRing(targetRing);
5534 G = idrMoveR(G,newRing,currRing);
5535 // test whether target cone is reached
5536 if(reduction !=0 && test_w_in_ConeCC(G,curr_weight) == 1)
5537 {
5538 baseRing = currRing;
5539 break;
5540 //endwalks = TRUE;
5541 }
5542
5543 rChangeCurrRing(newRing);
5544 G = idrMoveR(G,targetRing,currRing);
5545 baseRing = currRing;
5546
5547 NEXT_VECTOR:
5548#ifdef TIME_TEST
5549 to = clock();
5550#endif
5551 intvec* next_weight = MwalkNextWeightCC(curr_weight,target_weight,G);
5552#ifdef TIME_TEST
5553 tnw = tnw + clock() - to;
5554#endif
5555#ifdef PRINT_VECTORS
5556 if(printout > 0)
5557 {
5558 MivString(curr_weight, target_weight, next_weight);
5559 }
5560#endif
5561 if(reduction ==0)
5562 {
5563 if(MivComp(curr_weight,next_weight)==1)
5564 {
5565 break;
5566 }
5567 }
5568 if(MivComp(target_weight,curr_weight) == 1)
5569 {
5570 break;
5571 }
5572
5573 for(i=nV-1; i>=0; i--)
5574 {
5575 //(*tmp_weight)[i] = (*curr_weight)[i];
5576 (*curr_weight)[i] = (*next_weight)[i];
5577 }
5578 delete next_weight;
5579 }
5580 rChangeCurrRing(XXRing);
5581 ideal result = idrMoveR(G,baseRing,currRing);
5582 idDelete(&Go);
5583 idDelete(&G);
5584 //delete tmp_weight;
5585 delete ivNull;
5586 delete exivlp;
5587#ifndef BUCHBERGER_ALG
5588 delete last_omega;
5589#endif
5590#ifdef TIME_TEST
5591 TimeString(tinput, tostd, tif, tstd, tlift, tred, tnw, nstep);
5592 //Print("\n// pSetm_Error = (%d)", ErrorCheck());
5593 //Print("\n// Overflow_Error? (%d)\n", Overflow_Error);
5594#endif
5595 if(printout > 0)
5596 {
5597 Print("\n//** Mwalk: Groebner Walk took %d steps.\n", nstep);
5598 }
5599 si_opt_1 = save1; //set original options
5600 return(result);
5601}

◆ MwalkAlt()

ideal MwalkAlt ( ideal Go,
intvec * curr_weight,
intvec * target_weight )

Definition at line 5028 of file walk.cc.

5029{
5032 //Print("// pSetm_Error = (%d)", ErrorCheck());
5033
5034#ifdef TIME_TEST
5035 clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
5036 tinput = clock();
5037 clock_t tim;
5038 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;
5039#endif
5040 nstep=0;
5041 int i;
5042 int nV = currRing->N;
5043 int nwalk=0;
5044 int endwalks=0;
5045
5046 ideal Gomega, M, F, Gomega1, Gomega2, M1, F1, G;
5047
5048 ring newRing, oldRing;
5049 intvec* ivNull = new intvec(nV);
5050 intvec* exivlp = Mivlp(nV);
5051#ifndef BUCHBERGER_ALG
5052 intvec* hilb_func;
5053#endif
5054 intvec* tmp_weight = new intvec(nV);
5055 for(i=nV-1; i>=0; i--)
5056 (*tmp_weight)[i] = (*curr_weight)[i];
5057
5058 // to avoid (1,0,...,0) as the target vector
5059 intvec* last_omega = new intvec(nV);
5060 for(i=nV-1; i>0; i--)
5061 (*last_omega)[i] = 1;
5062 (*last_omega)[0] = 10000;
5063
5064 ring XXRing = currRing;
5065
5066#ifdef TIME_TEST
5067 to = clock();
5068#endif
5069 // the monomial ordering of this current ring would be "dp"
5070 G = MstdCC(Go);
5071#ifdef TIME_TEST
5072 tostd = clock()-to;
5073#endif
5074
5075 if(currRing->order[0] == ringorder_a)
5076 goto NEXT_VECTOR;
5077
5078 while(1)
5079 {
5080 nwalk ++;
5081 nstep ++;
5082#ifdef TIME_TEST
5083 to = clock();
5084#endif
5085 // compute an initial form ideal of <G> w.r.t. "curr_vector"
5086 Gomega = MwalkInitialForm(G, curr_weight);
5087#ifdef TIME_TEST
5088 tif = tif + clock()-to;
5089#endif
5090 oldRing = currRing;
5091
5092 if(endwalks == 1)
5093 {
5094 /* compute a reduced Groebner basis of Gomega w.r.t. >>_cw by
5095 the recursive changed perturbation walk alg. */
5096#ifdef TIME_TEST
5097 tim = clock();
5098#endif
5099#ifdef CHECK_IDEAL_MWALK
5100 Print("\n// **** Groebnerwalk took %d steps and ", nwalk);
5101 PrintS("\n// **** call the rec. Pert. Walk to compute a red GB of:");
5102 idString(Gomega, "Gomega");
5103#endif
5104
5105 if(MivSame(exivlp, target_weight)==1)
5106 M = REC_GB_Mwalk(idCopy(Gomega), tmp_weight, curr_weight, 2,1);
5107 else
5108 goto NORMAL_GW;
5109#ifdef TIME_TEST
5110 Print("\n// time for the last std(Gw) = %.2f sec",
5111 ((double) (clock()-tim)/1000000));
5112#endif
5113/*
5114#ifdef CHECK_IDEAL_MWALK
5115 idElements(Gomega, "G_omega");
5116 headidString(Gomega, "Gw");
5117 idElements(M, "M");
5118 //headidString(M, "M");
5119#endif
5120*/
5121#ifdef TIME_TEST
5122 to = clock();
5123#endif
5124 F = MLifttwoIdeal(Gomega, M, G);
5125#ifdef TIME_TEST
5126 xtlift = xtlift + clock() - to;
5127#endif
5128
5129 idDelete(&Gomega);
5130 idDelete(&M);
5131 idDelete(&G);
5132
5133 oldRing = currRing;
5134
5135 // create a new ring newRing
5136 if (rParameter(currRing) != NULL)
5137 {
5138 DefRingPar(curr_weight);
5139 }
5140 else
5141 {
5142 rChangeCurrRing(VMrDefault(curr_weight));
5143 }
5144 newRing = currRing;
5145 F1 = idrMoveR(F, oldRing,currRing);
5146 }
5147 else
5148 {
5149 NORMAL_GW:
5150#ifndef BUCHBERGER_ALG
5151 if(isNolVector(curr_weight) == 0)
5152 {
5153 hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing);
5154 }
5155 else
5156 {
5157 hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);
5158 }
5159#endif // BUCHBERGER_ALG
5160
5161 // define a new ring that its ordering is "(a(curr_weight),lp)
5162 if (rParameter(currRing) != NULL)
5163 {
5164 DefRingPar(curr_weight);
5165 }
5166 else
5167 {
5168 rChangeCurrRing(VMrDefault(curr_weight));
5169 }
5170 newRing = currRing;
5171 Gomega1 = idrMoveR(Gomega, oldRing,currRing);
5172
5173#ifdef TIME_TEST
5174 to = clock();
5175#endif
5176 // compute a reduced Groebner basis of <Gomega> w.r.t. "newRing"
5177#ifdef BUCHBERGER_ALG
5178 M = MstdhomCC(Gomega1);
5179#else
5180 M=kStd2(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
5181 delete hilb_func;
5182#endif
5183#ifdef TIME_TEST
5184 tstd = tstd + clock() - to;
5185#endif
5186
5187 // change the ring to oldRing
5188 rChangeCurrRing(oldRing);
5189 M1 = idrMoveR(M, newRing,currRing);
5190 Gomega2 = idrMoveR(Gomega1, newRing,currRing);
5191
5192#ifdef TIME_TEST
5193 to = clock();
5194#endif
5195 // compute a representation of the generators of submod (M) with respect
5196 // to those of mod (Gomega).
5197 // Gomega is a reduced Groebner basis w.r.t. the current ring.
5198 F = MLifttwoIdeal(Gomega2, M1, G);
5199#ifdef TIME_TEST
5200 tlift = tlift + clock() - to;
5201#endif
5202
5203 idDelete(&M1);
5204 idDelete(&Gomega2);
5205 idDelete(&G);
5206
5207 // change the ring to newRing
5208 rChangeCurrRing(newRing);
5209 F1 = idrMoveR(F, oldRing,currRing);
5210 }
5211
5212#ifdef TIME_TEST
5213 to = clock();
5214#endif
5215 // reduce the Groebner basis <G> w.r.t. new ring
5216 G = kInterRedCC(F1, NULL);
5217#ifdef TIME_TEST
5218 if(endwalks != 1)
5219 {
5220 tred = tred + clock() - to;
5221 }
5222 else
5223 {
5224 xtred = xtred + clock() - to;
5225 }
5226#endif
5227 idDelete(&F1);
5228 if(endwalks == 1)
5229 {
5230 break;
5231 }
5232 NEXT_VECTOR:
5233#ifdef TIME_TEST
5234 to = clock();
5235#endif
5236 // compute a next weight vector
5237 intvec* next_weight = MkInterRedNextWeight(curr_weight,target_weight,G);
5238#ifdef TIME_TEST
5239 tnw = tnw + clock() - to;
5240#endif
5241#ifdef PRINT_VECTORS
5242 MivString(curr_weight, target_weight, next_weight);
5243#endif
5244
5245 //if(test_w_in_ConeCC(G, next_weight) != 1)
5246 if(Overflow_Error == TRUE)
5247 {
5248 newRing = currRing;
5249 PrintS("\n// ** The computed vector does NOT stay in Cone!!\n");
5250
5251 if (rParameter(currRing) != NULL)
5252 {
5253 DefRingPar(target_weight);
5254 }
5255 else
5256 {
5257 rChangeCurrRing(VMrDefault(target_weight));
5258 }
5259 F1 = idrMoveR(G, newRing,currRing);
5260 G = MstdCC(F1);
5261 idDelete(&F1);
5262
5263 newRing = currRing;
5264 break;
5265 }
5266
5267 if(MivComp(next_weight, ivNull) == 1)
5268 {
5269 newRing = currRing;
5270 delete next_weight;
5271 break;
5272 }
5273 if(MivComp(next_weight, target_weight) == 1)
5274 {
5275 endwalks = 1;
5276 }
5277 for(i=nV-1; i>=0; i--)
5278 {
5279 (*tmp_weight)[i] = (*curr_weight)[i];
5280 (*curr_weight)[i] = (*next_weight)[i];
5281 }
5282 delete next_weight;
5283 }
5284 rChangeCurrRing(XXRing);
5285 G = idrMoveR(G, newRing,currRing);
5286
5287 delete tmp_weight;
5288 delete ivNull;
5289 delete exivlp;
5290
5291#ifdef TIME_TEST
5292 TimeString(tinput, tostd, tif, tstd, tlift, tred, tnw, nstep);
5293
5294 //Print("\n// pSetm_Error = (%d)", ErrorCheck());
5295 Print("\n// Overflow_Error? (%d)\n", Overflow_Error);
5296#endif
5297 return(G);
5298}
static ideal REC_GB_Mwalk(ideal G, intvec *curr_weight, intvec *orig_target_weight, int tp_deg, int npwinc)
Definition walk.cc:4720

◆ MwalkInitialForm()

ideal MwalkInitialForm ( ideal G,
intvec * ivw )

Definition at line 762 of file walk.cc.

763{
764 BOOLEAN nError = Overflow_Error;
766
767 int i, nG = IDELEMS(G);
768 ideal Gomega = idInit(nG, 1);
769
770 for(i=nG-1; i>=0; i--)
771 {
772 Gomega->m[i] = MpolyInitialForm(G->m[i], ivw);
773 }
774 if(Overflow_Error == FALSE)
775 {
776 Overflow_Error = nError;
777 }
778 return Gomega;
779}
static poly MpolyInitialForm(poly g, intvec *curr_weight)
Definition walk.cc:723

◆ MwalkNextWeightCC()

static intvec * MwalkNextWeightCC ( intvec * curr_weight,
intvec * target_weight,
ideal G )
static

Definition at line 2229 of file walk.cc.

2231{
2232 BOOLEAN nError = Overflow_Error;
2234
2235 assume(currRing != NULL && curr_weight != NULL &&
2236 target_weight != NULL && G != NULL);
2237
2238 int nRing = currRing->N;
2239 int j, nG = IDELEMS(G);
2240 intvec* ivtemp;
2241
2242 mpz_t t_zaehler, t_nenner;
2243 mpz_init(t_zaehler);
2244 mpz_init(t_nenner);
2245
2246 mpz_t s_zaehler, s_nenner, temp, MwWd;
2247 mpz_init(s_zaehler);
2248 mpz_init(s_nenner);
2249 mpz_init(temp);
2250 mpz_init(MwWd);
2251
2252 mpz_t sing_int;
2253 mpz_init(sing_int);
2254 mpz_set_ui(sing_int, 2147483647);
2255
2256 mpz_t sing_int_half;
2257 mpz_init(sing_int_half);
2258 mpz_set_ui(sing_int_half, 3*(1073741824/2));
2259
2260 mpz_t deg_w0_p1, deg_d0_p1;
2261 mpz_init(deg_w0_p1);
2262 mpz_init(deg_d0_p1);
2263
2264 mpz_t sztn, sntz;
2265 mpz_init(sztn);
2266 mpz_init(sntz);
2267
2268 mpz_t t_null;
2269 mpz_init(t_null);
2270
2271 mpz_t ggt;
2272 mpz_init(ggt);
2273
2274 mpz_t dcw;
2275 mpz_init(dcw);
2276
2277 int gcd_tmp;
2278 //intvec* diff_weight = MivSub(target_weight, curr_weight);
2279
2280 intvec* diff_weight1 = new intvec(nRing); //MivSub(target_weight, curr_weight);
2281 poly g;
2282
2283 // reduce the size of the entries of the current weight vector
2284 if(TEST_OPT_REDSB)
2285 {
2286 for (j=0; j<nRing; j++)
2287 {
2288 (*diff_weight1)[j] = (*curr_weight)[j];
2289 }
2290 while(MivAbsMax(diff_weight1)>10000 && test_w_in_ConeCC(G,diff_weight1)==1)
2291 {
2292 for(j=0; j<nRing; j++)
2293 {
2294 (*curr_weight)[j] = (*diff_weight1)[j];
2295 }
2296 for(j=0; j<nRing; j++)
2297 {
2298 (*diff_weight1)[j] = ((*diff_weight1)[j] + 5) / 10;
2299 }
2300 }
2301
2302 if(MivAbsMax(curr_weight)>100000)
2303 {
2304 for(j=0; j<nRing; j++)
2305 {
2306 (*diff_weight1)[j] = (*curr_weight)[j];
2307 }
2308 j = 0;
2309 while(test_w_in_ConeCC(G,diff_weight1)==1 && MivAbsMax(diff_weight1)>1000)
2310 {
2311 (*curr_weight)[j] = (*diff_weight1)[j];
2312 j = MivAbsMaxArg(diff_weight1);
2313 (*diff_weight1)[j] = ((*diff_weight1)[j] + 5) / 10;
2314 }
2315 }
2316
2317 }
2318 intvec* diff_weight = MivSub(target_weight, curr_weight);
2319
2320 // compute a suitable next weight vector
2321 for (j=0; j<nG; j++)
2322 {
2323 g = G->m[j];
2324 if (g != NULL)
2325 {
2326 ivtemp = MExpPol(g);
2327 mpz_set_si(deg_w0_p1, MivDotProduct(ivtemp, curr_weight));
2328 mpz_set_si(deg_d0_p1, MivDotProduct(ivtemp, diff_weight));
2329 delete ivtemp;
2330
2331 pIter(g);
2332 while (g != NULL)
2333 {
2334 ivtemp = MExpPol(g);
2335 mpz_set_si(MwWd, MivDotProduct(ivtemp, curr_weight));
2336 mpz_sub(s_zaehler, deg_w0_p1, MwWd);
2337 if(mpz_cmp(s_zaehler, t_null) != 0)
2338 {
2339 mpz_set_si(MwWd, MivDotProduct(ivtemp, diff_weight));
2340 mpz_sub(s_nenner, MwWd, deg_d0_p1);
2341 // check for 0 < s <= 1
2342 if( (mpz_cmp(s_zaehler,t_null) > 0 &&
2343 mpz_cmp(s_nenner, s_zaehler)>=0) ||
2344 (mpz_cmp(s_zaehler, t_null) < 0 &&
2345 mpz_cmp(s_nenner, s_zaehler)<=0))
2346 {
2347 // make both positive
2348 if (mpz_cmp(s_zaehler, t_null) < 0)
2349 {
2350 mpz_neg(s_zaehler, s_zaehler);
2351 mpz_neg(s_nenner, s_nenner);
2352 }
2353
2354 //compute a simple fraction of s
2355 cancel(s_zaehler, s_nenner);
2356
2357 if(mpz_cmp(t_nenner, t_null) != 0)
2358 {
2359 mpz_mul(sztn, s_zaehler, t_nenner);
2360 mpz_mul(sntz, s_nenner, t_zaehler);
2361
2362 if(mpz_cmp(sztn,sntz) < 0)
2363 {
2364 mpz_add(t_nenner, t_null, s_nenner);
2365 mpz_add(t_zaehler,t_null, s_zaehler);
2366 }
2367 }
2368 else
2369 {
2370 mpz_add(t_nenner, t_null, s_nenner);
2371 mpz_add(t_zaehler,t_null, s_zaehler);
2372 }
2373 }
2374 }
2375 pIter(g);
2376 delete ivtemp;
2377 }
2378 }
2379 }
2380 //Print("\n// Alloc Size = %d \n", nRing*sizeof(mpz_t));
2381 mpz_t *vec=(mpz_t*)omAlloc(nRing*sizeof(mpz_t));
2382
2383
2384 // there is no 0<t<1 and define the next weight vector that is equal
2385 // to the current weight vector
2386 if(mpz_cmp(t_nenner, t_null) == 0)
2387 {
2388#ifndef SING_NDEBUG
2389 //PrintS("\n//MwalkNextWeightCC: t_nenner=0\n");
2390#endif
2391 delete diff_weight;
2392 diff_weight = ivCopy(curr_weight);//take memory
2393 goto FINISH;
2394 }
2395
2396 // define the target vector as the next weight vector, if t = 1
2397 if(mpz_cmp_si(t_nenner, 1)==0 && mpz_cmp_si(t_zaehler,1)==0)
2398 {
2399 delete diff_weight;
2400 diff_weight = ivCopy(target_weight); //this takes memory
2401 goto FINISH;
2402 }
2403
2404 //SIMPLIFY_GCD:
2405
2406 // simplify the vectors curr_weight and diff_weight (C-int)
2407 gcd_tmp = (*curr_weight)[0];
2408
2409 for (j=1; j<nRing; j++)
2410 {
2411 gcd_tmp = gcd(gcd_tmp, (*curr_weight)[j]);
2412 if(gcd_tmp == 1)
2413 {
2414 break;
2415 }
2416 }
2417 if(gcd_tmp != 1)
2418 {
2419 for (j=0; j<nRing; j++)
2420 {
2421 gcd_tmp = gcd(gcd_tmp, (*diff_weight)[j]);
2422 if(gcd_tmp == 1)
2423 {
2424 break;
2425 }
2426 }
2427 }
2428 if(gcd_tmp != 1)
2429 {
2430 for (j=0; j<nRing; j++)
2431 {
2432 (*curr_weight)[j] = (*curr_weight)[j]/gcd_tmp;
2433 (*diff_weight)[j] = (*diff_weight)[j]/gcd_tmp;
2434 }
2435 }
2436
2437#ifdef NEXT_VECTORS_CC
2438 Print("\n// gcd of the weight vectors (current and target) = %d", gcd_tmp);
2439 ivString(curr_weight, "new cw");
2440 ivString(diff_weight, "new dw");
2441
2442 PrintS("\n// t_zaehler: "); mpz_out_str( stdout, 10, t_zaehler);
2443 PrintS(", t_nenner: "); mpz_out_str( stdout, 10, t_nenner);
2444#endif
2445
2446// construct a new weight vector and check whether vec[j] is overflow, i.e. vec[j] > 2^31.
2447// If vec[j] doesn't overflow, define a weight vector. Otherwise, report that overflow
2448// appears. In the second case, test whether the the correctness of the new vector plays
2449// an important role
2450
2451 for (j=0; j<nRing; j++)
2452 {
2453 mpz_set_si(dcw, (*curr_weight)[j]);
2454 mpz_mul(s_nenner, t_nenner, dcw);
2455
2456 if( (*diff_weight)[j]>0)
2457 {
2458 mpz_mul_ui(s_zaehler, t_zaehler, (*diff_weight)[j]);
2459 }
2460 else
2461 {
2462 mpz_mul_ui(s_zaehler, t_zaehler, -(*diff_weight)[j]);
2463 mpz_neg(s_zaehler, s_zaehler);
2464 }
2465 mpz_add(sntz, s_nenner, s_zaehler);
2466 mpz_init_set(vec[j], sntz);
2467
2468#ifdef NEXT_VECTORS_CC
2469 Print("\n// j = %d ==> ", j);
2470 PrintS("(");
2471 mpz_out_str( stdout, 10, t_nenner);
2472 Print(" * %d)", (*curr_weight)[j]);
2473 PrintS(" + ("); mpz_out_str( stdout, 10, t_zaehler);
2474 Print(" * %d) = ", (*diff_weight)[j]);
2475 mpz_out_str( stdout, 10, s_nenner);
2476 PrintS(" + ");
2477 mpz_out_str( stdout, 10, s_zaehler);
2478 PrintS(" = "); mpz_out_str( stdout, 10, sntz);
2479 Print(" ==> vector[%d]: ", j); mpz_out_str(stdout, 10, vec[j]);
2480#endif
2481
2482 if(j==0)
2483 {
2484 mpz_set(ggt, sntz);
2485 }
2486 else
2487 {
2488 if(mpz_cmp_si(ggt,1) != 0)
2489 {
2490 mpz_gcd(ggt, ggt, sntz);
2491 }
2492 }
2493 }
2494 // reduce the vector with the gcd
2495 if(mpz_cmp_si(ggt,1) != 0)
2496 {
2497 for (j=0; j<nRing; j++)
2498 {
2499 mpz_divexact(vec[j], vec[j], ggt);
2500 }
2501 }
2502#ifdef NEXT_VECTORS_CC
2503 PrintS("\n// gcd of elements of the vector: ");
2504 mpz_out_str( stdout, 10, ggt);
2505#endif
2506
2507 for (j=0; j<nRing; j++)
2508 {
2509 (*diff_weight)[j] = mpz_get_si(vec[j]);
2510 }
2511
2512 //TEST_OVERFLOW:
2513
2514 for (j=0; j<nRing; j++)
2515 {
2516 if(mpz_cmp(vec[j], sing_int)>=0)
2517 {
2518 if(Overflow_Error == FALSE)
2519 {
2521 PrintS("\n// ** OVERFLOW in \"MwalkNextWeightCC\": ");
2522 mpz_out_str( stdout, 10, vec[j]);
2523 PrintS(" is greater than 2147483647 (max. integer representation)\n");
2524 //Print("// So vector[%d] := %d is wrong!!\n",j+1, vec[j]);// vec[j] is mpz_t
2525 }
2526 }
2527 }
2528
2529 FINISH:
2530 delete diff_weight1;
2531 mpz_clear(t_zaehler);
2532 mpz_clear(t_nenner);
2533 mpz_clear(s_zaehler);
2534 mpz_clear(s_nenner);
2535 mpz_clear(sntz);
2536 mpz_clear(sztn);
2537 mpz_clear(temp);
2538 mpz_clear(MwWd);
2539 mpz_clear(deg_w0_p1);
2540 mpz_clear(deg_d0_p1);
2541 mpz_clear(ggt);
2542 omFree(vec);
2543 mpz_clear(sing_int_half);
2544 mpz_clear(sing_int);
2545 mpz_clear(dcw);
2546 mpz_clear(t_null);
2547
2548 if(Overflow_Error == FALSE)
2549 {
2550 Overflow_Error = nError;
2551 }
2553 for(j=0; j<IDELEMS(G); j++)
2554 {
2555 poly p=G->m[j];
2556 while(p!=NULL)
2557 {
2558 p_Setm(p,currRing);
2559 pIter(p);
2560 }
2561 }
2562return diff_weight;
2563}
intvec * ivCopy(const intvec *o)
Definition intvec.h:146
static int MivAbsMaxArg(intvec *vec)
Definition walk.cc:1851
static void cancel(mpz_t zaehler, mpz_t nenner)
Definition walk.cc:589
static intvec * MExpPol(poly f)
Definition walk.cc:878
static intvec * MivSub(intvec *a, intvec *b)
Definition walk.cc:862
static long MivDotProduct(intvec *a, intvec *b)
Definition walk.cc:846

◆ MWalkRandomNextWeight()

static intvec * MWalkRandomNextWeight ( ideal G,
intvec * orig_M,
intvec * target_weight,
int weight_rad,
int pert_deg )
static

Definition at line 4517 of file walk.cc.

4519{
4520 assume(currRing != NULL && orig_M != NULL &&
4521 target_weight != NULL && G->m[0] != NULL);
4522
4523 //BOOLEAN nError = Overflow_Error;
4525
4526 BOOLEAN found_random_weight = FALSE;
4527 int i,nV = currRing->N;
4528 intvec* curr_weight = new intvec(nV);
4529
4530 for(i=0; i<nV; i++)
4531 {
4532 (*curr_weight)[i] = (*orig_M)[i];
4533 }
4534
4535 int k=0,weight_norm;
4536 intvec* next_weight;
4537 intvec* next_weight1 = MkInterRedNextWeight(curr_weight,target_weight,G);
4538 intvec* next_weight2 = new intvec(nV);
4539 intvec* result = new intvec(nV);
4540 intvec* curr_weight1;
4541 ideal G_test, G_test1, G_test2;
4542
4543 //try to find a random next weight vector "next_weight2"
4544 if(weight_rad > 0)
4545 {
4546 while(k<10)
4547 {
4548 weight_norm = 0;
4549 while(weight_norm == 0)
4550 {
4551 for(i=0; i<nV; i++)
4552 {
4553 (*next_weight2)[i] = rand() % 60000 - 30000;
4554 weight_norm = weight_norm + (*next_weight2)[i]*(*next_weight2)[i];
4555 }
4556 weight_norm = 1 + static_cast<int>(sqrt(double(weight_norm)));
4557 }
4558 for(i=0; i<nV; i++)
4559 {
4560 if((*next_weight2)[i] < 0)
4561 {
4562 (*next_weight2)[i] = 1 + (*curr_weight)[i] + weight_rad*(*next_weight2)[i]/weight_norm;
4563 }
4564 else
4565 {
4566 (*next_weight2)[i] = (*curr_weight)[i] + weight_rad*(*next_weight2)[i]/weight_norm;
4567 }
4568 }
4569 if(test_w_in_ConeCC(G,next_weight2) == 1)
4570 {
4571 if(maxlengthpoly(MwalkInitialForm(G,next_weight2))<2)
4572 {
4573 next_weight2 = MkInterRedNextWeight(next_weight2,target_weight,G);
4574 }
4575 G_test2 = MwalkInitialForm(G, next_weight2);
4576 found_random_weight = TRUE;
4577 break;
4578 }
4579 k++;
4580 }
4581 }
4582
4583 // compute "perturbed" next weight vector
4584 if(pert_deg > 1)
4585 {
4586 curr_weight1 = MPertVectors(G,orig_M,pert_deg);
4587 next_weight = MkInterRedNextWeight(curr_weight1,target_weight,G);
4588 delete curr_weight1;
4589 }
4590 else
4591 {
4592 next_weight = MkInterRedNextWeight(curr_weight,target_weight,G);
4593 }
4594 if(MivSame(curr_weight,next_weight)==1 || Overflow_Error == TRUE)
4595 {
4597 delete next_weight;
4598 next_weight = MkInterRedNextWeight(curr_weight,target_weight,G);
4599 }
4600 G_test=MwalkInitialForm(G,next_weight);
4601 G_test1=MwalkInitialForm(G,next_weight1);
4602
4603 // compare next weights
4604 if(Overflow_Error == FALSE)
4605 {
4606 if(found_random_weight == TRUE)
4607 {
4608 // random next weight vector found
4609 if(G_test1->m[0] != NULL && maxlengthpoly(G_test1) < maxlengthpoly(G_test))
4610 {
4611 if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test1))
4612 {
4613 for(i=0; i<nV; i++)
4614 {
4615 (*result)[i] = (*next_weight2)[i];
4616 }
4617 }
4618 else
4619 {
4620 for(i=0; i<nV; i++)
4621 {
4622 (*result)[i] = (*next_weight1)[i];
4623 }
4624 }
4625 }
4626 else
4627 {
4628 if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test))
4629 {
4630 for(i=0; i<nV; i++)
4631 {
4632 (*result)[i] = (*next_weight2)[i];
4633 }
4634 }
4635 else
4636 {
4637 for(i=0; i<nV; i++)
4638 {
4639 (*result)[i] = (*next_weight)[i];
4640 }
4641 }
4642 }
4643 }
4644 else
4645 {
4646 // no random next weight vector found
4647 if(G_test1->m[0] != NULL && maxlengthpoly(G_test1) < maxlengthpoly(G_test))
4648 {
4649 for(i=0; i<nV; i++)
4650 {
4651 (*result)[i] = (*next_weight1)[i];
4652 }
4653 }
4654 else
4655 {
4656 for(i=0; i<nV; i++)
4657 {
4658 (*result)[i] = (*next_weight)[i];
4659 }
4660 }
4661 }
4662 }
4663 else
4664 {
4666 if(found_random_weight == TRUE)
4667 {
4668 if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test))
4669 {
4670 for(i=1; i<nV; i++)
4671 {
4672 (*result)[i] = (*next_weight2)[i];
4673 }
4674 }
4675 else
4676 {
4677 for(i=0; i<nV; i++)
4678 {
4679 (*result)[i] = (*next_weight)[i];
4680 }
4681 }
4682 }
4683 else
4684 {
4685 for(i=0; i<nV; i++)
4686 {
4687 (*result)[i] = (*next_weight)[i];
4688 }
4689 }
4690 }
4691
4692 delete next_weight;
4693 delete next_weight2;
4694 idDelete(&G_test);
4695 idDelete(&G_test1);
4696 if(found_random_weight == TRUE)
4697 {
4698 idDelete(&G_test2);
4699 }
4700 if(test_w_in_ConeCC(G, result) == 1 && MivSame(curr_weight,result)==0)
4701 {
4702 delete curr_weight;
4703 delete next_weight1;
4704 return result;
4705 }
4706 else
4707 {
4708 delete curr_weight;
4709 delete result;
4710 return next_weight1;
4711 }
4712}
gmp_float sqrt(const gmp_float &a)
static int maxlengthpoly(ideal G)
Definition walk.cc:3461

◆ MwalkWeightDegree()

static int MwalkWeightDegree ( poly p,
intvec * weight_vector )
inlinestatic

Definition at line 669 of file walk.cc.

670{
671 assume(weight_vector->length() >= currRing->N);
672 int max = 0, maxtemp;
673
674 while(p != NULL)
675 {
676 maxtemp = MLmWeightedDegree(p, weight_vector);
677 pIter(p);
678
679 if (maxtemp > max)
680 {
681 max = maxtemp;
682 }
683 }
684 return max;
685}
static int MLmWeightedDegree(const poly p, intvec *weight)
Definition walk.cc:622

◆ NewVectorlp()

static intvec * NewVectorlp ( ideal I)
static

Definition at line 4497 of file walk.cc.

4498{
4499 int nV = currRing->N;
4500 intvec* iv_wlp = MivMatrixOrderlp(nV);
4501 intvec* result = Mfpertvector(I, iv_wlp);
4502 delete iv_wlp;
4503 return result;
4504}

◆ rec_fractal_call()

static ideal rec_fractal_call ( ideal G,
int nlev,
intvec * ivtarget,
int reduction,
int printout )
static

Definition at line 6952 of file walk.cc.

6954{
6956 if(printout >0)
6957 {
6958 Print("\n\n// Entering the %d-th recursion:", nlev);
6959 }
6960 int i, nV = currRing->N;
6961 ring new_ring, testring;
6962 //ring extoRing;
6963 ideal Gomega, Gomega1, Gomega2, FF, F, Gresult, Gresult1, G1, Gt;
6964 int nwalks = 0;
6965 intvec* Mwlp;
6966#ifndef BUCHBERGER_ALG
6967 intvec* hilb_func;
6968#endif
6969 //intvec* extXtau;
6970 intvec* next_vect;
6971 intvec* omega2 = new intvec(nV);
6972 intvec* omtmp = new intvec(nV);
6973 //intvec* altomega = new intvec(nV);
6974
6975 for(i = nV -1; i>=0; i--)//Aenderung!!
6976 {
6977 (*omtmp)[i] = (*ivtarget)[i];
6978 }
6979 //BOOLEAN isnewtarget = FALSE;
6980
6981 // to avoid (1,0,...,0) as the target vector (Hans)
6982 intvec* last_omega = new intvec(nV);
6983 for(i=nV-1; i>0; i--)
6984 (*last_omega)[i] = 1;
6985 (*last_omega)[0] = 10000;
6986
6987 intvec* omega = new intvec(nV);
6988 for(i=0; i<nV; i++) {
6989 if(Xsigma->length() == nV)
6990 (*omega)[i] = (*Xsigma)[i];
6991 else
6992 (*omega)[i] = (*Xsigma)[(nV*(nlev-1))+i];
6993
6994 (*omega2)[i] = (*Xtau)[(nlev-1)*nV+i];
6995 }
6996
6997 if(nlev == 1) Xcall = 1;
6998 else Xcall = 0;
6999
7000 ring oRing = currRing;
7001
7002 while(1)
7003 {
7004#ifdef FIRST_STEP_FRACTAL
7005 // perturb the current weight vector only on the top level or
7006 // after perturbation of the both vectors, nlev = 2 as the top level
7007 if((nlev == 1 && Xcall == 0) || (nlev == 2 && Xngleich == 1))
7008 if(islengthpoly2(G) == 1)
7009 {
7010 Mwlp = MivWeightOrderlp(omega);
7011 Xsigma = Mfpertvector(G, Mwlp);
7012 delete Mwlp;
7014 }
7015#endif
7016 nwalks ++;
7017 NEXT_VECTOR_FRACTAL:
7018#ifdef TIME_TEST
7019 to=clock();
7020#endif
7021 // determine the next border
7022 next_vect = MkInterRedNextWeight(omega,omega2,G);
7023#ifdef TIME_TEST
7024 xtnw=xtnw+clock()-to;
7025#endif
7026 oRing = currRing;
7027
7028 // We only perturb the current target vector at the recursion level 1
7029 if(Xngleich == 0 && nlev == 1) //(ngleich == 0) important, e.g. ex2, ex3
7030 if (MivComp(next_vect, omega2) == 1)
7031 {
7032 // to dispense with taking initial (and lifting/interreducing
7033 // after the call of recursion
7034 if(printout > 0)
7035 {
7036 Print("\n//** rec_fractal_call: Perturb the both vectors with degree %d.",nlev);
7037 //idElements(G, "G");
7038 }
7039
7040 Xngleich = 1;
7041 nlev +=1;
7042
7043 if(ivtarget->length() == nV)
7044 {
7045/*
7046 if (rParameter(currRing) != NULL)
7047 DefRingPar(omtmp);
7048 else
7049 rChangeCurrRing(VMrDefault(omtmp));
7050*/
7051 rChangeCurrRing(VMrRefine(ivtarget,omtmp));
7052 }
7053 else
7054 {
7055 //rChangeCurrRing(VMatrDefault(ivtarget));
7056 rChangeCurrRing(VMatrRefine(ivtarget,omtmp));
7057 }
7058 testring = currRing;
7059 Gt = idrMoveR(G, oRing,currRing);
7060
7061 // perturb the original target vector w.r.t. the current GB
7062 if(ivtarget->length() == nV)
7063 {
7064 delete Xtau;
7065 Xtau = NewVectorlp(Gt);
7066 }
7067 else
7068 {
7069 delete Xtau;
7070 Xtau = Mfpertvector(Gt,ivtarget);
7071 }
7072
7073 rChangeCurrRing(oRing);
7074 G = idrMoveR(Gt, testring,currRing);
7075
7076 // perturb the current vector w.r.t. the current GB
7077 Mwlp = MivWeightOrderlp(omega);
7078 Xsigma = Mfpertvector(G, Mwlp);
7079 delete Mwlp;
7080
7081 for(i=nV-1; i>=0; i--) {
7082 (*omega2)[i] = (*Xtau)[nV+i];
7083 (*omega)[i] = (*Xsigma)[nV+i];
7084 }
7085
7086 delete next_vect;
7087#ifdef TIME_TEST
7088 to=clock();
7089#endif
7090 // to avoid the value of Overflow_Error that occur in Mfpertvector
7092 next_vect = MkInterRedNextWeight(omega,omega2,G);
7093#ifdef TIME_TEST
7094 xtnw=xtnw+clock()-to;
7095#endif
7096 }// end of (if MivComp(next_vect, omega2) == 1)
7097
7098#ifdef PRINT_VECTORS
7099 if(printout > 0)
7100 {
7101 MivString(omega, omega2, next_vect);
7102 }
7103#endif
7104
7105 // check whether the the computed vector is in the correct cone.
7106 // If no, compute the reduced Groebner basis of an omega-homogeneous
7107 // ideal with Buchberger's algorithm and stop this recursion step
7108 if(Overflow_Error == TRUE || test_w_in_ConeCC(G, next_vect) != 1) //e.g. Example s7, cyc6
7109 {
7110 delete next_vect;
7111 if(ivtarget->length() == nV)
7112 {
7113/*
7114 if (rParameter(currRing) != NULL)
7115 DefRingPar(omtmp);
7116 else
7117 rChangeCurrRing(VMrDefault(omtmp));
7118*/
7119 rChangeCurrRing(VMrRefine(ivtarget,omtmp));
7120 }
7121 else
7122 {
7123 //rChangeCurrRing(VMatrDefault(ivtarget));
7124 rChangeCurrRing(VMatrRefine(ivtarget,omtmp));
7125 }
7126#ifdef TEST_OVERFLOW
7127 Gt = idrMoveR(G, oRing,currRing);
7128 Gt = NULL; return(Gt);
7129#endif
7130 if(printout > 0)
7131 {
7132 Print("\n//** rec_fractal_call: Applying Buchberger's algorithm in ring r = %s;",
7133 rString(currRing));
7134 }
7135#ifdef TIME_TEST
7136 to=clock();
7137#endif
7138 Gt = idrMoveR(G, oRing,currRing);
7139 G1 = MstdCC(Gt);
7140#ifdef TIME_TEST
7141 xtextra=xtextra+clock()-to;
7142#endif
7143 Gt = NULL;
7144
7145 delete omega2;
7146 //delete altomega;
7147 if(printout > 0)
7148 {
7149 Print("\n//** rec_fractal_call: Overflow. (4) Leaving the %d-th recursion with %d steps.\n",
7150 nlev, nwalks);
7151 //Print(" ** Overflow_Error? (%d)", Overflow_Error);
7152 }
7153
7154 nnflow ++;
7156 return (G1);
7157 }
7158
7159 /* If the perturbed target vector stays in the correct cone,
7160 return the current GB,
7161 otherwise, return the computed GB by the Buchberger-algorithm.
7162 Then we update the perturbed target vectors w.r.t. this GB. */
7163
7164 /* the computed vector is equal to the origin vector, since
7165 t is not defined */
7166
7167 if (MivComp(next_vect, XivNull) == 1)
7168 {
7169 if(ivtarget->length() == nV)
7170 {
7171/*
7172 if (rParameter(currRing) != NULL)
7173 DefRingPar(omtmp);
7174 else
7175 rChangeCurrRing(VMrDefault(omtmp));
7176*/
7177 rChangeCurrRing(VMrRefine(ivtarget,omtmp));
7178 }
7179 else
7180 {
7181 //rChangeCurrRing(VMatrDefault(ivtarget));
7182 rChangeCurrRing(VMatrRefine(ivtarget,omtmp));
7183 }
7184
7185 testring = currRing;
7186 Gt = idrMoveR(G, oRing,currRing);
7187 if(test_w_in_ConeCC(Gt, omega2) == 1)
7188 {
7189 delete omega2;
7190 delete next_vect;
7191 //delete altomega;
7192 if(printout > 0)
7193 {
7194 Print("\n//** rec_fractal_call: Correct cone. (5) Leaving the %d-th recursion with %d steps.\n",
7195 nlev, nwalks);
7196 }
7197 if(printout>2)
7198 {
7199 idString(Gt,"//** rec_fractal_call: Gt");
7200 }
7201 return (Gt);
7202 }
7203 else
7204 {
7205 if(printout > 0)
7206 {
7207 PrintS("\n//** rec_fractal_call: Wrong cone. Tau doesn't stay in the correct cone.\n");
7208 }
7209
7210#ifndef MSTDCC_FRACTAL
7211 intvec* Xtautmp;
7212 if(ivtarget->length() == nV)
7213 {
7214 Xtautmp = Mfpertvector(Gt, MivMatrixOrder(omtmp));
7215 }
7216 else
7217 {
7218 Xtautmp = Mfpertvector(Gt, ivtarget);
7219 }
7220#ifdef TEST_OVERFLOW
7221 if(Overflow_Error == TRUE)
7222 Gt = NULL; return(Gt);
7223#endif
7224
7225 if(MivSame(Xtau, Xtautmp) == 1)
7226 {
7227 if(printout > 0)
7228 {
7229 PrintS("\n//** rec_fractal_call: Updated vectors are equal to the old vectors.\n");
7230 }
7231 delete Xtautmp;
7232 goto FRACTAL_MSTDCC;
7233 }
7234
7235 Xtau = Xtautmp;
7236 Xtautmp = NULL;
7237
7238 for(i=nV-1; i>=0; i--)
7239 (*omega2)[i] = (*Xtau)[(nlev-1)*nV+i];
7240
7241 rChangeCurrRing(oRing);
7242 G = idrMoveR(Gt, testring,currRing);
7243
7244 goto NEXT_VECTOR_FRACTAL;
7245#endif
7246
7247 //FRACTAL_MSTDCC:
7248 if(printout > 0)
7249 {
7250 Print("\n//** rec_fractal_call: Wrong cone. Applying Buchberger's algorithm in ring = %s.\n",
7251 rString(currRing));
7252 }
7253#ifdef TIME_TEST
7254 to=clock();
7255#endif
7256 G = MstdCC(Gt);
7257#ifdef TIME_TEST
7258 xtextra=xtextra+clock()-to;
7259#endif
7260 oRing = currRing;
7261
7262 // update the original target vector w.r.t. the current GB
7263 if(ivtarget->length() == nV)
7264 {
7265/*
7266 if(MivSame(Xivinput, Xivlp) == 1)
7267 if (rParameter(currRing) != NULL)
7268 DefRingParlp();
7269 else
7270 VMrDefaultlp();
7271 else
7272 if (rParameter(currRing) != NULL)
7273 DefRingPar(Xivinput);
7274 else
7275 rChangeCurrRing(VMrDefault(Xivinput));
7276*/
7278 }
7279 else
7280 {
7282 }
7283 testring = currRing;
7284 Gt = idrMoveR(G, oRing,currRing);
7285
7286 // perturb the original target vector w.r.t. the current GB
7287 if(ivtarget->length() == nV)
7288 {
7289 delete Xtau;
7290 Xtau = NewVectorlp(Gt);
7291 }
7292 else
7293 {
7294 delete Xtau;
7295 Xtau = Mfpertvector(Gt,ivtarget);
7296 }
7297
7298 rChangeCurrRing(oRing);
7299 G = idrMoveR(Gt, testring,currRing);
7300
7301 delete omega2;
7302 delete next_vect;
7303 //delete altomega;
7304 if(printout > 0)
7305 {
7306 Print("\n//** rec_fractal_call: Vectors updated. (6) Leaving the %d-th recursion with %d steps.\n",
7307 nlev, nwalks);
7308 //Print(" ** Overflow_Error? (%d)", Overflow_Error);
7309 }
7310 if(Overflow_Error == TRUE)
7311 nnflow ++;
7312
7314 return(G);
7315 }
7316 }// end of (if next_vect==nullvector)
7317
7318 for(i=nV-1; i>=0; i--) {
7319 //(*altomega)[i] = (*omega)[i];
7320 (*omega)[i] = (*next_vect)[i];
7321 }
7322 delete next_vect;
7323#ifdef TIME_TEST
7324 to=clock();
7325#endif
7326 // Take the initial form of <G> w.r.t. omega
7327 Gomega = MwalkInitialForm(G, omega);
7328#ifdef TIME_TEST
7329 xtif=xtif+clock()-to;
7330#endif
7331#ifdef CHECK_IDEAL_MWALK
7332 if(printout > 1)
7333 {
7334 idString(Gomega,"//** rec_fractal_call: Gomega");
7335 }
7336#endif
7337 if(reduction == 0)
7338 {
7339 // Check whether the intermediate weight vector lies in the interior of the cone.
7340 // If so, only perform reductions. Otherwise apply Buchberger's algorithm.
7341 FF = middleOfCone(G,Gomega);
7342 if( FF != NULL)
7343 {
7344 idDelete(&G);
7345 G = idCopy(FF);
7346 idDelete(&FF);
7347 // Compue next vector.
7348 goto NEXT_VECTOR_FRACTAL;
7349 }
7350 }
7351
7352#ifndef BUCHBERGER_ALG
7353 if(isNolVector(omega) == 0)
7354 hilb_func = hFirstSeries(Gomega,NULL,NULL,omega,currRing);
7355 else
7356 hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);
7357#endif
7358
7359 if(ivtarget->length() == nV)
7360 {
7361/*
7362 if (rParameter(currRing) != NULL)
7363 DefRingPar(omega);
7364 else
7365 rChangeCurrRing(VMrDefault(omega));
7366*/
7367 rChangeCurrRing(VMrRefine(ivtarget,omega));
7368 }
7369 else
7370 {
7371 rChangeCurrRing(VMatrRefine(ivtarget,omega));
7372 }
7373 Gomega1 = idrMoveR(Gomega, oRing,currRing);
7374
7375 // Maximal recursion depth, to compute a red. GB
7376 // Fractal walk with the alternative recursion
7377 // alternative recursion
7378 if(nlev == Xnlev || lengthpoly(Gomega1) == 0)
7379 {
7380 if(printout > 1)
7381 {
7382 PrintS("\n//** rec_fractal_call: Maximal recursion depth.\n");
7383 }
7384#ifdef TIME_TEST
7385 to=clock();
7386#endif
7387#ifdef BUCHBERGER_ALG
7388 Gresult = MstdhomCC(Gomega1);
7389#else
7390 Gresult =kStd2(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,omega);
7391 delete hilb_func;
7392#endif
7393#ifdef TIME_TEST
7394 xtstd=xtstd+clock()-to;
7395#endif
7396 }
7397 else
7398 {
7399 rChangeCurrRing(oRing);
7400 Gomega1 = idrMoveR(Gomega1, oRing,currRing);
7401 Gresult = rec_fractal_call(idCopy(Gomega1),nlev+1,omega,reduction,printout);
7402 }
7403#ifdef CHECK_IDEAL_MWALK
7404 if(printout > 2)
7405 {
7406 idString(Gresult,"//** rec_fractal_call: M");
7407 }
7408#endif
7409 //convert a Groebner basis from a ring to another ring
7410 new_ring = currRing;
7411
7412 rChangeCurrRing(oRing);
7413 Gresult1 = idrMoveR(Gresult, new_ring,currRing);
7414 Gomega2 = idrMoveR(Gomega1, new_ring,currRing);
7415#ifdef TIME_TEST
7416 to=clock();
7417#endif
7418 // Lifting process
7419 F = MLifttwoIdeal(Gomega2, Gresult1, G);
7420#ifdef TIME_TEST
7421 xtlift=xtlift+clock()-to;
7422#endif
7423#ifdef CHECK_IDEAL_MWALK
7424 if(printout > 2)
7425 {
7426 idString(F,"//** rec_fractal_call: F");
7427 }
7428#endif
7430 idDelete(&Gresult1);
7431 idDelete(&Gomega2);
7432 idDelete(&G);
7433
7434 rChangeCurrRing(new_ring);
7435 G = idrMoveR(F,oRing,currRing);
7436/*
7437 ideal F1 = idrMoveR(F, oRing,currRing);
7438#ifdef TIME_TEST
7439 to=clock();
7440#endif
7441 // Interreduce G
7442 G = kInterRedCC(F1, NULL);
7443#ifdef TIME_TEST
7444 xtred=xtred+clock()-to;
7445#endif
7446 idDelete(&F1);
7447*/
7448 }
7449}
void id_Normalize(ideal I, const ring r)
normialize all polys in id
static int islengthpoly2(ideal G)
Definition walk.cc:3478
static intvec * NewVectorlp(ideal I)
Definition walk.cc:4497

◆ REC_GB_Mwalk()

static ideal REC_GB_Mwalk ( ideal G,
intvec * curr_weight,
intvec * orig_target_weight,
int tp_deg,
int npwinc )
static

Definition at line 4720 of file walk.cc.

4722{
4723 BOOLEAN nError = Overflow_Error;
4725
4726 int i, nV = currRing->N;
4727 int nwalk=0, endwalks=0, nnwinC=1, nlast = 0;
4728 ideal Gomega, M, F, Gomega1, Gomega2, M1,F1,result,ssG;
4729 ring newRing, oldRing, TargetRing;
4730 intvec* target_weight;
4731 intvec* ivNull = new intvec(nV);
4732#ifndef BUCHBERGER_ALG
4733 intvec* hilb_func;
4734 // to avoid (1,0,...,0) as the target vector
4735 intvec* last_omega = new intvec(nV);
4736 for(i=nV-1; i>0; i--)
4737 {
4738 (*last_omega)[i] = 1;
4739 }
4740 (*last_omega)[0] = 10000;
4741#endif
4742 BOOLEAN isGB = FALSE;
4743
4744 ring EXXRing = currRing;
4745
4746 // compute a pertubed weight vector of the target weight vector
4747 if(tp_deg > 1 && tp_deg <= nV)
4748 {
4749 ideal H0 = idHeadCC(G);
4750 if (rParameter(currRing) != NULL)
4751 {
4752 DefRingPar(orig_target_weight);
4753 }
4754 else
4755 {
4756 rChangeCurrRing(VMrDefault(orig_target_weight));
4757 }
4758 TargetRing = currRing;
4759 ssG = idrMoveR(G,EXXRing,currRing);
4760
4761 ideal H0_tmp = idrMoveR(H0,EXXRing,currRing);
4762 ideal H1 = idHeadCC(ssG);
4763 id_Delete(&H0,EXXRing);
4764
4765 if(test_G_GB_walk(H0_tmp,H1)==1)
4766 {
4767 //Print("\n//REC_GB_Mwalk: input in %d-th recursive is a GB!\n",tp_deg);
4768 idDelete(&H0_tmp);
4769 idDelete(&H1);
4770 G = ssG;
4771 ssG = NULL;
4772 newRing = currRing;
4773 delete ivNull;
4774 if(npwinc == 0)
4775 {
4776 isGB = TRUE;
4777 goto KSTD_Finish;
4778 }
4779 else
4780 {
4781 goto LastGB_Finish;
4782 }
4783 }
4784 idDelete(&H0_tmp);
4785 idDelete(&H1);
4786
4787 target_weight = MPertVectors(ssG, MivMatrixOrder(orig_target_weight), tp_deg);
4788
4789 rChangeCurrRing(EXXRing);
4790 G = idrMoveR(ssG, TargetRing,currRing);
4791 }
4792
4793 while(1)
4794 {
4795 nwalk ++;
4796 nstep++;
4797 if(nwalk == 1)
4798 {
4799 goto NEXT_STEP;
4800 }
4801 //Print("\n//REC_GB_Mwalk: Entering the %d-th step in the %d-th recursive:\n",nwalk,tp_deg);
4802#ifdef TIME_TEST
4803 to = clock();
4804#endif
4805 // compute an initial form ideal of <G> w.r.t. "curr_vector"
4806 Gomega = MwalkInitialForm(G, curr_weight);
4807#ifdef TIME_TEST
4808 xtif = xtif + clock()-to;
4809#endif
4810
4811#ifndef BUCHBERGER_ALG
4812 if(isNolVector(curr_weight) == 0)
4813 {
4814 hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing);
4815 }
4816 else
4817 {
4818 hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);
4819 }
4820#endif
4821
4822 oldRing = currRing;
4823
4824 // define a new ring with ordering "(a(curr_weight),lp)
4825 if (rParameter(currRing) != NULL)
4826 {
4827 DefRingPar(curr_weight);
4828 }
4829 else
4830 {
4831 rChangeCurrRing(VMrDefault(curr_weight));
4832 }
4833 newRing = currRing;
4834 Gomega1 = idrMoveR(Gomega, oldRing,currRing);
4835
4836#ifdef TIME_TEST
4837 to = clock();
4838#endif
4839 // compute a reduced Groebner basis of <Gomega> w.r.t. "newRing"
4840#ifdef BUCHBERGER_ALG
4841 M = MstdhomCC(Gomega1);
4842#else
4843 M=kStd2(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
4844 delete hilb_func;
4845#endif
4846#ifdef TIME_TEST
4847 xtstd = xtstd + clock() - to;
4848#endif
4849
4850 // change the ring to oldRing
4851 rChangeCurrRing(oldRing);
4852
4853 M1 = idrMoveR(M, newRing,currRing);
4854 Gomega2 = idrMoveR(Gomega1, newRing,currRing);
4855
4856#ifdef TIME_TEST
4857 to = clock();
4858#endif
4859 F = MLifttwoIdeal(Gomega2, M1, G);
4860#ifdef TIME_TEST
4861 xtlift = xtlift + clock() -to;
4862#endif
4863
4864 idDelete(&M1);
4865 idDelete(&Gomega2);
4866 idDelete(&G);
4867
4868
4869 // change the ring to newRing
4870 rChangeCurrRing(newRing);
4871 F1 = idrMoveR(F, oldRing,currRing);
4872
4873#ifdef TIME_TEST
4874 to = clock();
4875#endif
4876 // reduce the Groebner basis <G> w.r.t. new ring
4877 G = kInterRedCC(F1, NULL);
4878#ifdef TIME_TEST
4879 xtred = xtred + clock() -to;
4880#endif
4881
4882 idDelete(&F1);
4883
4884 if(endwalks == 1)
4885 {
4886 break;
4887 }
4888 NEXT_STEP:
4889#ifdef TIME_TEST
4890 to = clock();
4891#endif
4892 // compute a next weight vector
4893 intvec* next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
4894
4895
4896#ifdef TIME_TEST
4897 xtnw = xtnw + clock() - to;
4898#endif
4899
4900#ifdef PRINT_VECTORS
4901 MivString(curr_weight, target_weight, next_weight);
4902#endif
4903
4904 if(Overflow_Error == TRUE)
4905 {
4906 //PrintS("\n//REC_GB_Mwalk: The computed vector does NOT stay in the correct cone!!\n");
4907 nnwinC = 0;
4908 if(tp_deg == nV)
4909 {
4910 nlast = 1;
4911 }
4912 delete next_weight;
4913 break;
4914 }
4915 if(MivComp(next_weight, ivNull) == 1)
4916 {
4917 newRing = currRing;
4918 delete next_weight;
4919 break;
4920 }
4921
4922 if(MivComp(next_weight, target_weight) == 1)
4923 {
4924 if(tp_deg == nV)
4925 {
4926 endwalks = 1;
4927 }
4928 else
4929 {
4930 G = REC_GB_Mwalk(G,curr_weight, orig_target_weight, tp_deg+1,nnwinC);
4931 newRing = currRing;
4932 delete next_weight;
4933 break;
4934 }
4935 }
4936
4937 for(i=nV-1; i>=0; i--)
4938 {
4939 (*curr_weight)[i] = (*next_weight)[i];
4940 }
4941 delete next_weight;
4942 }
4943
4944 delete ivNull;
4945
4946 if(tp_deg != nV)
4947 {
4948 newRing = currRing;
4949
4950 if (rParameter(currRing) != NULL)
4951 {
4952 DefRingPar(orig_target_weight);
4953 }
4954 else
4955 {
4956 rChangeCurrRing(VMrDefault(orig_target_weight));
4957 }
4958 F1 = idrMoveR(G, newRing,currRing);
4959
4960 if(nnwinC == 0)
4961 {
4962 F1 = REC_GB_Mwalk(F1,curr_weight, orig_target_weight, tp_deg+1,nnwinC);
4963 }
4964 else
4965 {
4966 if(test_w_in_ConeCC(F1, target_weight) != 1)
4967 {
4968 F1 = REC_GB_Mwalk(F1,curr_weight, orig_target_weight,tp_deg+1,nnwinC);
4969 }
4970 }
4971 delete target_weight;
4972
4973 TargetRing = currRing;
4974 rChangeCurrRing(EXXRing);
4975 result = idrMoveR(F1, TargetRing,currRing);
4976 }
4977 else
4978 {
4979 if(nlast == 1)
4980 {
4981 if (rParameter(currRing) != NULL)
4982 {
4983 DefRingPar(orig_target_weight);
4984 }
4985 else
4986 {
4987 rChangeCurrRing(VMrDefault(orig_target_weight));
4988 }
4989 KSTD_Finish:
4990 if(isGB == FALSE)
4991 {
4992 F1 = idrMoveR(G, newRing,currRing);
4993 }
4994 else
4995 {
4996 F1 = G;
4997 }
4998#ifdef TIME_TEST
4999 to=clock();
5000#endif
5001 // apply Buchberger alg to compute a red. GB of F1
5002 G = MstdCC(F1);
5003#ifdef TIME_TEST
5004 xtextra=clock()-to;
5005#endif
5006 idDelete(&F1);
5007 newRing = currRing;
5008 }
5009
5010 LastGB_Finish:
5011 rChangeCurrRing(EXXRing);
5012 result = idrMoveR(G, newRing,currRing);
5013 }
5014
5015 if(Overflow_Error == FALSE)
5016 {
5017 Overflow_Error = nError;
5018 }
5019#ifndef BUCHBERGER_ALG
5020 delete last_omega;
5021#endif
5022 return(result);
5023}
static ideal idHeadCC(ideal h)
Definition walk.cc:3514
static int test_G_GB_walk(ideal H0, ideal H1)
Definition walk.cc:3533

◆ Rec_LastGB()

static ideal Rec_LastGB ( ideal G,
intvec * curr_weight,
intvec * orig_target_weight,
int tp_deg,
int npwinc )
static

Definition at line 3934 of file walk.cc.

3936{
3937 BOOLEAN nError = Overflow_Error;
3939 // BOOLEAN nOverflow_Error = FALSE;
3940
3941#ifdef TIME_TEST
3942 clock_t tproc=0;
3943 clock_t tinput = clock();
3944#endif
3945
3946 int i, nV = currRing->N;
3947 int nwalk=0, endwalks=0, nnwinC=1;
3948 int nlast = 0;
3949 ideal Gomega, M, F, Gomega1, Gomega2, M1,F1,result,ssG;
3950 ring newRing, oldRing, TargetRing;
3951 intvec* iv_M_lp;
3952 intvec* target_weight;
3953 intvec* ivNull = new intvec(nV); //define (0,...,0)
3954 ring EXXRing = currRing;
3955 //int NEG=0; //19 juni 03
3956 intvec* next_weight;
3957#ifndef BUCHBERGER_ALG
3958 //08 Juli 03
3959 intvec* hilb_func;
3960#endif
3961 // to avoid (1,0,...,0) as the target vector
3962 intvec* last_omega = new intvec(nV);
3963 for(i=nV-1; i>0; i--)
3964 (*last_omega)[i] = 1;
3965 (*last_omega)[0] = 10000;
3966
3967 BOOLEAN isGB = FALSE;
3968
3969 // compute a pertubed weight vector of the target weight vector
3970 if(tp_deg > 1 && tp_deg <= nV)
3971 {
3972 ideal H0 = idHeadCC(G);
3973
3974 if (rParameter (currRing) != NULL)
3975 {
3976 DefRingParlp();
3977 }
3978 else
3979 {
3980 VMrDefaultlp();
3981 }
3982 TargetRing = currRing;
3983 ssG = idrMoveR(G,EXXRing,currRing);
3984
3985 ideal H0_tmp = idrMoveR(H0,EXXRing,currRing);
3986 ideal H1 = idHeadCC(ssG);
3987
3988 // Apply Lemma 2.2 in Collart et. al (1997) to check whether cone(k-1) is equal to cone(k)
3989 if(test_G_GB_walk(H0_tmp,H1)==1)
3990 {
3991 idDelete(&H0_tmp);
3992 idDelete(&H1);
3993 G = ssG;
3994 ssG = NULL;
3995 newRing = currRing;
3996 delete ivNull;
3997
3998 if(npwinc != 0)
3999 {
4000 goto LastGB_Finish;
4001 }
4002 else
4003 {
4004 isGB = TRUE;
4005 goto KSTD_Finish;
4006 }
4007 }
4008 idDelete(&H0_tmp);
4009 idDelete(&H1);
4010
4011 iv_M_lp = MivMatrixOrderlp(nV);
4012 target_weight = MPertVectors(ssG, iv_M_lp, tp_deg);
4013 delete iv_M_lp;
4014 //PrintS("\n// Input is not GB!!");
4015 rChangeCurrRing(EXXRing);
4016 G = idrMoveR(ssG, TargetRing,currRing);
4017
4018 if(Overflow_Error == TRUE)
4019 {
4020 //nOverflow_Error = Overflow_Error;
4021 //NEG = 1;
4022 newRing = currRing;
4023 goto JUNI_STD;
4024 }
4025 }
4026
4027 while(1)
4028 {
4029 nwalk ++;
4030 nstep++;
4031
4032 if(nwalk==1)
4033 {
4034 goto FIRST_STEP;
4035 }
4036#ifdef TIME_TEST
4037 to=clock();
4038#endif
4039 // compute an initial form ideal of <G> w.r.t. "curr_vector"
4040 Gomega = MwalkInitialForm(G, curr_weight);
4041#ifdef TIME_TEST
4042 xtif=xtif+clock()-to;
4043#endif
4044
4045#ifndef BUCHBERGER_ALG
4046 if(isNolVector(curr_weight) == 0)
4047 {
4048 hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing);
4049 }
4050 else
4051 {
4052 hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);
4053 }
4054#endif // BUCHBERGER_ALG
4055
4056 oldRing = currRing;
4057
4058 // defiNe a new ring that its ordering is "(a(curr_weight),lp)
4059 if (rParameter(currRing) != NULL)
4060 {
4061 DefRingPar(curr_weight);
4062 }
4063 else
4064 {
4065 rChangeCurrRing(VMrDefault(curr_weight));
4066 }
4067 newRing = currRing;
4068 Gomega1 = idrMoveR(Gomega, oldRing,currRing);
4069#ifdef TIME_TEST
4070 to=clock();
4071#endif
4072 // compute a reduced Groebner basis of <Gomega> w.r.t. "newRing"
4073#ifdef BUCHBERGER_ALG
4074 M = MstdhomCC(Gomega1);
4075#else
4076 M=kStd2(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
4077 delete hilb_func;
4078#endif // BUCHBERGER_ALG
4079#ifdef TIME_TEST
4080 xtstd=xtstd+clock()-to;
4081#endif
4082 // change the ring to oldRing
4083 rChangeCurrRing(oldRing);
4084 M1 = idrMoveR(M, newRing,currRing);
4085 Gomega2 = idrMoveR(Gomega1, newRing,currRing);
4086
4087#ifdef TIME_TEST
4088 to=clock();
4089#endif
4090 // compute a reduced Groebner basis of <G> w.r.t. "newRing" by the lifting process
4091 F = MLifttwoIdeal(Gomega2, M1, G);
4092#ifdef TIME_TEST
4093 xtlift=xtlift+clock()-to;
4094#endif
4095 idDelete(&M1);
4096 idDelete(&Gomega2);
4097 idDelete(&G);
4098
4099 // change the ring to newRing
4100 rChangeCurrRing(newRing);
4101 F1 = idrMoveR(F, oldRing,currRing);
4102
4103#ifdef TIME_TEST
4104 to=clock();
4105#endif
4106 // reduce the Groebner basis <G> w.r.t. new ring
4107 G = kInterRedCC(F1, NULL);
4108#ifdef TIME_TEST
4109 xtred=xtred+clock()-to;
4110#endif
4111 idDelete(&F1);
4112
4113 if(endwalks == 1)
4114 {
4115 break;
4116 }
4117 FIRST_STEP:
4118#ifdef TIME_TEST
4119 to=clock();
4120#endif
4122 // compute a next weight vector
4123 next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
4124#ifdef TIME_TEST
4125 xtnw=xtnw+clock()-to;
4126#endif
4127#ifdef PRINT_VECTORS
4128 MivString(curr_weight, target_weight, next_weight);
4129#endif
4130 if(Overflow_Error == TRUE)
4131 {
4132 //PrintS("\n// ** The next vector does NOT stay in Cone!!\n");
4133#ifdef TEST_OVERFLOW
4134 goto LastGB_Finish;
4135#endif
4136
4137 nnwinC = 0;
4138 if(tp_deg == nV)
4139 {
4140 nlast = 1;
4141 }
4142 delete next_weight;
4143 break;
4144 }
4145
4146 if(MivComp(next_weight, ivNull) == 1)
4147 {
4148 //newRing = currRing;
4149 delete next_weight;
4150 break;
4151 }
4152
4153 if(MivComp(next_weight, target_weight) == 1)
4154 {
4155 if(tp_deg == nV)
4156 {
4157 endwalks = 1;
4158 }
4159 else
4160 {
4161 // REC_LAST_GB_ALT2:
4162 //nOverflow_Error = Overflow_Error;
4163#ifdef TIME_TEST
4164 tproc=tproc+clock()-tinput;
4165#endif
4166
4167 /*Print("\n// takes %d steps and calls \"Rec_LastGB\" (%d):",
4168 nwalk, tp_deg+1);
4169 */
4170 G = Rec_LastGB(G,curr_weight, orig_target_weight, tp_deg+1,nnwinC);
4171 newRing = currRing;
4172 delete next_weight;
4173 break;
4174 }
4175 }
4176
4177 for(i=nV-1; i>=0; i--)
4178 {
4179 (*curr_weight)[i] = (*next_weight)[i];
4180 }
4181 delete next_weight;
4182 }//while
4183
4184 delete ivNull;
4185
4186 if(tp_deg != nV)
4187 {
4188 newRing = currRing;
4189
4190 if (rParameter(currRing) != NULL)
4191 {
4192 DefRingParlp();
4193 }
4194 else
4195 {
4196 VMrDefaultlp();
4197 }
4198 F1 = idrMoveR(G, newRing,currRing);
4199
4200 if(nnwinC == 0 || test_w_in_ConeCC(F1, target_weight) != 1 )
4201 {
4202 // nOverflow_Error = Overflow_Error;
4203 //Print("\n// takes %d steps and calls \"Rec_LastGB (%d):", tp_deg+1);
4204#ifdef TIME_TEST
4205 tproc=tproc+clock()-tinput;
4206#endif
4207 F1 = Rec_LastGB(F1,curr_weight, orig_target_weight, tp_deg+1,nnwinC);
4208 }
4209 delete target_weight;
4210
4211 TargetRing = currRing;
4212 rChangeCurrRing(EXXRing);
4213 result = idrMoveR(F1, TargetRing,currRing);
4214 }
4215 else
4216 {
4217 if(nlast == 1)
4218 {
4219 JUNI_STD:
4220
4221 newRing = currRing;
4222 if (rParameter(currRing) != NULL)
4223 {
4224 DefRingParlp();
4225 }
4226 else
4227 {
4228 VMrDefaultlp();
4229 }
4230 KSTD_Finish:
4231 if(isGB == FALSE)
4232 {
4233 F1 = idrMoveR(G, newRing,currRing);
4234 }
4235 else
4236 {
4237 F1 = G;
4238 }
4239#ifdef TIME_TEST
4240 to=clock();
4241#endif
4242 // Print("\n// apply the Buchberger's alg in ring = %s",rString(currRing));
4243 // idElements(F1, "F1");
4244 G = MstdCC(F1);
4245#ifdef TIME_TEST
4246 xtextra=xtextra+clock()-to;
4247#endif
4248
4249
4250 idDelete(&F1);
4251 newRing = currRing;
4252 }
4253
4254 LastGB_Finish:
4255 rChangeCurrRing(EXXRing);
4256 result = idrMoveR(G, newRing,currRing);
4257 }
4258
4259 if(Overflow_Error == FALSE)
4260 {
4261 Overflow_Error=nError;
4262 }
4263#ifdef TIME_TEST
4264 //Print("\n// \"Rec_LastGB\" (%d) took %d steps and %.2f sec.Overflow_Error (%d)", tp_deg, nwalk, ((double) tproc)/1000000, nOverflow_Error);
4265#endif
4266 return(result);
4267}

◆ rec_r_fractal_call()

static ideal rec_r_fractal_call ( ideal G,
int nlev,
intvec * ivtarget,
int weight_rad,
int reduction,
int printout )
static

Definition at line 7454 of file walk.cc.

7456{
7458 //Print("\n\n// Entering the %d-th recursion:", nlev);
7459
7460 int nwalks = 0,i,nV=currRing->N;//polylength
7461 ring new_ring, testring;
7462 //ring extoRing;
7463 ideal Gomega, Gomega1, Gomega2, F, FF, Gresult, Gresult1, G1, Gt;
7464#ifdef TIME_TEST
7465 ideal F1;
7466#endif
7467 intvec* Mwlp;
7468#ifndef BUCHBERGER_ALG
7469 intvec* hilb_func;
7470#endif
7471// intvec* extXtau;
7472 intvec* next_vect;
7473 intvec* iv_M;
7474 intvec* omega2 = new intvec(nV);
7475 intvec* omtmp = new intvec(nV);
7476 intvec* altomega = new intvec(nV);
7477
7478 //BOOLEAN isnewtarget = FALSE;
7479
7480 for(i = nV -1; i>=0; i--)
7481 {
7482 (*omtmp)[i] = (*ivtarget)[i];
7483 }
7484 // to avoid (1,0,...,0) as the target vector (Hans)
7485 intvec* last_omega = new intvec(nV);
7486 for(i=nV-1; i>0; i--)
7487 (*last_omega)[i] = 1;
7488 (*last_omega)[0] = 10000;
7489
7490 intvec* omega = new intvec(nV);
7491 for(i=0; i<nV; i++) {
7492 if(Xsigma->length() == nV)
7493 (*omega)[i] = (*Xsigma)[i];
7494 else
7495 (*omega)[i] = (*Xsigma)[(nV*(nlev-1))+i];
7496
7497 (*omega2)[i] = (*Xtau)[(nlev-1)*nV+i];
7498 }
7499
7500 if(nlev == 1) Xcall = 1;
7501 else Xcall = 0;
7502
7503 ring oRing = currRing;
7504
7505 while(1)
7506 {
7507#ifdef FIRST_STEP_FRACTAL
7508 /*
7509 perturb the current weight vector only on the top level or
7510 after perturbation of the both vectors, nlev = 2 as the top level
7511 */
7512 if((nlev == 1 && Xcall == 0) || (nlev == 2 && Xngleich == 1))
7513 if(islengthpoly2(G) == 1)
7514 {
7515 Mwlp = MivWeightOrderlp(omega);
7516 Xsigma = Mfpertvector(G, Mwlp);
7517 delete Mwlp;
7519 }
7520#endif
7521 nwalks ++;
7522 NEXT_VECTOR_FRACTAL:
7523#ifdef TIME_TEST
7524 to=clock();
7525#endif
7526 /* determine the next border */
7527 next_vect = MkInterRedNextWeight(omega,omega2,G);
7528#ifdef TIME_TEST
7529 xtnw=xtnw+clock()-to;
7530#endif
7531 if(lengthpoly(MwalkInitialForm(G, next_vect)) > 0 && G->m[0] != NULL)
7532 {
7533 if(printout > 0)
7534 {
7535 PrintS("\n**// rec_r_fractal_call: there is a polynomial in Gomega with at least 3 monomials.\n");
7536 }
7537 delete next_vect;
7538 iv_M = MivMatrixOrder(omega);
7539#ifdef TIME_TEST
7540 to=clock();
7541#endif
7542 next_vect = MWalkRandomNextWeight(G,iv_M,omega2,weight_rad,nlev);
7543#ifdef TIME_TEST
7544 xtnw=xtnw+clock()-to;
7545#endif
7546 if(isNegNolVector(next_vect) == 1)
7547 {
7548 delete next_vect;
7549#ifdef TIME_TEST
7550 to=clock();
7551#endif
7552 next_vect = MkInterRedNextWeight(omega,omega2,G);
7553#ifdef TIME_TEST
7554 xtnw=xtnw+clock()-to;
7555#endif
7556 }
7557 }
7558 oRing = currRing;
7559
7560 // We only perturb the current target vector at the recursion level 1
7561 if(Xngleich == 0 && nlev == 1) //(ngleich == 0) important, e.g. ex2, ex3
7562 if (MivComp(next_vect, omega2) == 1)
7563 {
7564 // to dispense with taking initials and lifting/interreducing
7565 // after the call of recursion.
7566 if(printout > 0)
7567 {
7568 Print("\n//** rec_r_fractal_call: Perturb both vectors with degree %d.",nlev);
7569 //idElements(G, "G");
7570 }
7571 Xngleich = 1;
7572 nlev +=1;
7573 if(ivtarget->length() == nV)
7574 {
7575/*
7576 if (rParameter(currRing) != NULL)
7577 DefRingPar(omtmp);
7578 else
7579 rChangeCurrRing(VMrDefault(omtmp));
7580*/
7581 rChangeCurrRing(VMrRefine(ivtarget,omtmp));
7582 }
7583 else
7584 {
7585 //rChangeCurrRing(VMatrDefault(ivtarget));
7586 rChangeCurrRing(VMatrRefine(ivtarget,omtmp));
7587 }
7588 testring = currRing;
7589 Gt = idrMoveR(G, oRing,currRing);
7590
7591 // perturb the original target vector w.r.t. the current GB
7592 if(ivtarget->length() == nV)
7593 {
7594 delete Xtau;
7595 Xtau = NewVectorlp(Gt);
7596 }
7597 else
7598 {
7599 delete Xtau;
7600 Xtau = Mfpertvector(Gt,ivtarget);
7601 }
7602
7603 rChangeCurrRing(oRing);
7604 G = idrMoveR(Gt,testring,currRing);
7605
7606 // perturb the current vector w.r.t. the current GB
7607 Mwlp = MivWeightOrderlp(omega);
7608 if(ivtarget->length() > nV)
7609 {
7610 delete Mwlp;
7611 Mwlp = MivMatrixOrderRefine(omega,ivtarget);
7612 }
7613 Xsigma = Mfpertvector(G, Mwlp);
7614 delete Mwlp;
7615
7616 for(i=nV-1; i>=0; i--)
7617 {
7618 (*omega2)[i] = (*Xtau)[nV+i];
7619 (*omega)[i] = (*Xsigma)[nV+i];
7620 }
7621
7622 delete next_vect;
7623
7624 //to avoid the value of Overflow_Error that occur in Mfpertvector
7626#ifdef TIME_TEST
7627 to=clock();
7628#endif
7629 next_vect = MkInterRedNextWeight(omega,omega2,G);
7630#ifdef TIME_TEST
7631 xtnw=xtnw+clock()-to;
7632#endif
7633 if(lengthpoly(MwalkInitialForm(G, next_vect)) > 0 && G->m[0] != NULL)
7634 {
7635 // there is a polynomial in Gomega with at least 3 monomials
7636 iv_M = MivMatrixOrder(omega);
7637 delete next_vect;
7638#ifdef TIME_TEST
7639 to=clock();
7640#endif
7641 next_vect = MWalkRandomNextWeight(G,iv_M,omega2,weight_rad,nlev);
7642#ifdef TIME_TEST
7643 xtnw=xtnw+clock()-to;
7644#endif
7645 delete iv_M;
7646 if(isNegNolVector(next_vect) == 1)
7647 {
7648 delete next_vect;
7649#ifdef TIME_TEST
7650 to=clock();
7651#endif
7652 next_vect = MkInterRedNextWeight(omega,omega2,G);
7653#ifdef TIME_TEST
7654 xtnw=xtnw+clock()-to;
7655#endif
7656 }
7657 }
7658 }
7659#ifdef PRINT_VECTORS
7660 if(printout > 0)
7661 {
7662 MivString(omega, omega2, next_vect);
7663 }
7664#endif
7665
7666/* check whether the the computed vector is in the correct cone
7667 If no, the reduced GB of an omega-homogeneous ideal will be
7668 computed by Buchberger algorithm and stop this recursion step
7669*/
7670 if(Overflow_Error == TRUE || test_w_in_ConeCC(G,next_vect) != 1)//e.g. Example s7, cyc6
7671 {
7672 delete next_vect;
7673 if(ivtarget->length() == nV)
7674 {
7675/*
7676 if (rParameter(currRing) != NULL)
7677 {
7678 DefRingPar(omtmp);
7679 }
7680 else
7681 {
7682 rChangeCurrRing(VMrDefault(omtmp));
7683 }
7684*/
7685 rChangeCurrRing(VMrRefine(ivtarget,omtmp));
7686 }
7687 else
7688 {
7689 //rChangeCurrRing(VMatrDefault(ivtarget));
7690 rChangeCurrRing(VMatrRefine(ivtarget,omtmp));
7691 }
7692#ifdef TEST_OVERFLOW
7693 Gt = idrMoveR(G, oRing,currRing);
7694 Gt = NULL;
7695 return(Gt);
7696#endif
7697 if(printout > 0)
7698 {
7699 Print("\n//** rec_r_fractal_call: applying Buchberger's algorithm in ring r = %s;",
7700 rString(currRing));
7701 }
7702 Gt = idrMoveR(G, oRing,currRing);
7703#ifdef TIME_TEST
7704 to=clock();
7705#endif
7706 G1 = MstdCC(Gt);
7707#ifdef TIME_TEST
7708 xtextra=xtextra+clock()-to;
7709#endif
7710 Gt = NULL;
7711
7712 delete omega2;
7713 delete altomega;
7714 if(printout > 0)
7715 {
7716 Print("\n//** rec_r_fractal_call: (1) Leaving the %d-th recursion with %d steps.\n",
7717 nlev, nwalks);
7718 //Print(" ** Overflow_Error? (%d)", Overflow_Error);
7719 }
7720 nnflow ++;
7722 return (G1);
7723 }
7724 /*
7725 If the perturbed target vector stays in the correct cone,
7726 return the current Groebner basis.
7727 Otherwise, return the Groebner basis computed with Buchberger's
7728 algorithm.
7729 Then we update the perturbed target vectors w.r.t. this GB.
7730 */
7731 if (MivComp(next_vect, XivNull) == 1)
7732 {
7733 // The computed vector is equal to the origin vector,
7734 // because t is not defined
7735 if(ivtarget->length() == nV)
7736 {
7737/*
7738 if (rParameter(currRing) != NULL)
7739 DefRingPar(omtmp);
7740 else
7741 rChangeCurrRing(VMrDefault(omtmp));
7742*/
7743 rChangeCurrRing(VMrRefine(ivtarget,omtmp));
7744 }
7745 else
7746 {
7747 //rChangeCurrRing(VMatrDefault(ivtarget));
7748 rChangeCurrRing(VMatrRefine(ivtarget,omtmp));
7749 }
7750 testring = currRing;
7751 Gt = idrMoveR(G, oRing,currRing);
7752
7753 if(test_w_in_ConeCC(Gt, omega2) == 1)
7754 {
7755 delete omega2;
7756 delete next_vect;
7757 delete altomega;
7758 if(printout > 0)
7759 {
7760 Print("\n//** rec_r_fractal_call: (2) Leaving the %d-th recursion with %d steps.\n",
7761 nlev, nwalks);
7762 //Print(" ** Overflow_Error? (%d)", Overflow_Error);
7763 }
7764 return (Gt);
7765 }
7766 else
7767 {
7768 if(printout > 0)
7769 {
7770 Print("\n//** rec_r_fractal_call: target weight doesn't stay in the correct cone.\n");
7771 }
7772
7773#ifndef MSTDCC_FRACTAL
7774#ifdef PRINT_VECTORS
7775 if(printout > 0)
7776 {
7777 ivString(Xtau, "old Xtau");
7778 }
7779#endif
7780 intvec* Xtautmp;
7781 if(ivtarget->length() == nV)
7782 {
7783 Xtautmp = Mfpertvector(Gt, MivMatrixOrder(omtmp));
7784 }
7785 else
7786 {
7787 Xtautmp = Mfpertvector(Gt, ivtarget);
7788 }
7789#ifdef TEST_OVERFLOW
7790 if(Overflow_Error == TRUE)
7791 Gt = NULL; return(Gt);
7792#endif
7793
7794 if(MivSame(Xtau, Xtautmp) == 1)
7795 {
7796 //PrintS("\n// Update vectors are equal to the old vectors!!");
7797 delete Xtautmp;
7798 goto FRACTAL_MSTDCC;
7799 }
7800
7801 Xtau = Xtautmp;
7802 Xtautmp = NULL;
7803#ifdef PRINT_VECTORS
7804 if(printout > 0)
7805 {
7806 ivString(Xtau, "new Xtau");
7807 }
7808#endif
7809
7810 for(i=nV-1; i>=0; i--)
7811 (*omega2)[i] = (*Xtau)[(nlev-1)*nV+i];
7812
7813 //Print("\n// ring tau = %s;", rString(currRing));
7814 rChangeCurrRing(oRing);
7815 G = idrMoveR(Gt, testring,currRing);
7816
7817 goto NEXT_VECTOR_FRACTAL;
7818#endif
7819
7820 //FRACTAL_MSTDCC:
7821 if(printout > 0)
7822 {
7823 Print("\n//** rec_r_fractal_call: apply Buchberger's algorithm in ring = %s.\n",
7824 rString(currRing));
7825 }
7826#ifdef TIME_TEST
7827 to=clock();
7828#endif
7829 G = MstdCC(Gt);
7830#ifdef TIME_TEST
7831 xtextra=xtextra+clock()-to;
7832#endif
7833 oRing = currRing;
7834
7835 // update the original target vector w.r.t. the current GB
7836 if(ivtarget->length() == nV)
7837 {
7838/*
7839 if(MivSame(Xivinput, Xivlp) == 1)
7840 if (rParameter(currRing) != NULL)
7841 DefRingParlp();
7842 else
7843 VMrDefaultlp();
7844 else
7845 if (rParameter(currRing) != NULL)
7846 DefRingPar(Xivinput);
7847 else
7848 rChangeCurrRing(VMrDefault(Xivinput));
7849*/
7851 }
7852 else
7853 {
7855 }
7856 testring = currRing;
7857 Gt = idrMoveR(G, oRing,currRing);
7858
7859 // perturb the original target vector w.r.t. the current GB
7860 if(ivtarget->length() == nV)
7861 {
7862 delete Xtau;
7863 Xtau = NewVectorlp(Gt);
7864 }
7865 else
7866 {
7867 delete Xtau;
7868 Xtau = Mfpertvector(Gt,ivtarget);
7869 }
7870
7871 rChangeCurrRing(oRing);
7872 G = idrMoveR(Gt, testring,currRing);
7873
7874 delete omega2;
7875 delete next_vect;
7876 delete altomega;
7877 if(printout > 0)
7878 {
7879 Print("\n//** rec_r_fractal_call: (3) Leaving the %d-th recursion with %d steps.\n",
7880 nlev,nwalks);
7881 //Print(" ** Overflow_Error? (%d)", Overflow_Error);
7882 }
7883 if(Overflow_Error == TRUE)
7884 nnflow ++;
7885
7887 return(G);
7888 }
7889 } //end of if(MivComp(next_vect, XivNull) == 1)
7890
7891 for(i=nV-1; i>=0; i--)
7892 {
7893 (*altomega)[i] = (*omega)[i];
7894 (*omega)[i] = (*next_vect)[i];
7895 }
7896 delete next_vect;
7897#ifdef TIME_TEST
7898 to=clock();
7899#endif
7900 // Take the initial form of <G> w.r.t. omega
7901 Gomega = MwalkInitialForm(G, omega);
7902#ifdef TIME_TEST
7903 xtif=xtif+clock()-to;
7904#endif
7905 //polylength = 1 if there is a polynomial in Gomega with at least 3 monomials and 0 otherwise
7906 //polylength = lengthpoly(Gomega);
7907#ifdef CHECK_IDEAL_MWALK
7908 if(printout > 1)
7909 {
7910 idString(Gomega,"//** rec_r_fractal_call: Gomega");
7911 }
7912#endif
7913 if(reduction == 0)
7914 {
7915 /* Check whether the intermediate weight vector lies in the interior of the cone.
7916 * If so, only perform reductions. Otherwise apply Buchberger's algorithm. */
7917 FF = middleOfCone(G,Gomega);
7918 if( FF != NULL)
7919 {
7920 idDelete(&G);
7921 G = idCopy(FF);
7922 idDelete(&FF);
7923 /* Compue next vector. */
7924 goto NEXT_VECTOR_FRACTAL;
7925 }
7926 }
7927
7928#ifndef BUCHBERGER_ALG
7929 if(isNolVector(omega) == 0)
7930 hilb_func = hFirstSeries(Gomega,NULL,NULL,omega,currRing);
7931 else
7932 hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);
7933#endif
7934 if(ivtarget->length() == nV)
7935 {
7936/*
7937 if (rParameter(currRing) != NULL)
7938 DefRingPar(omega);
7939 else
7940 rChangeCurrRing(VMrDefault(omega));
7941*/
7942 rChangeCurrRing(VMrRefine(ivtarget,omega));
7943 }
7944 else
7945 {
7946 rChangeCurrRing(VMatrRefine(ivtarget,omega));
7947 }
7948 Gomega1 = idrMoveR(Gomega, oRing,currRing);
7949
7950 // Maximal recursion depth, to compute a red. GB
7951 // Fractal walk with the alternative recursion
7952 // alternative recursion
7953 if(nlev == Xnlev || lengthpoly(Gomega1) == 0)
7954 {
7955#ifdef TIME_TEST
7956 to=clock();
7957#endif
7958#ifdef BUCHBERGER_ALG
7959 Gresult = MstdhomCC(Gomega1);
7960#else
7961 Gresult =kStd2(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,omega);
7962 delete hilb_func;
7963#endif
7964#ifdef TIME_TEST
7965 xtstd=xtstd+clock()-to;
7966#endif
7967 }
7968 else
7969 {
7970 rChangeCurrRing(oRing);
7971 Gomega1 = idrMoveR(Gomega1, oRing,currRing);
7972 Gresult = rec_r_fractal_call(idCopy(Gomega1),nlev+1,omega,weight_rad,reduction,printout);
7973 }
7974#ifdef CHECK_IDEAL_MWALK
7975 if(printout > 2)
7976 {
7977 idString(Gresult,"//** rec_r_fractal_call: M");
7978 }
7979#endif
7980 //convert a Groebner basis from a ring to another ring
7981 new_ring = currRing;
7982
7983 rChangeCurrRing(oRing);
7984 Gresult1 = idrMoveR(Gresult, new_ring,currRing);
7985 Gomega2 = idrMoveR(Gomega1, new_ring,currRing);
7986#ifdef TIME_TEST
7987 to=clock();
7988#endif
7989 // Lifting process
7990 F = MLifttwoIdeal(Gomega2, Gresult1, G);
7991#ifdef TIME_TEST
7992 xtlift=xtlift+clock()-to;
7993#endif
7994#ifdef CHECK_IDEAL_MWALK
7995 if(printout > 2)
7996 {
7997 idString(F,"//** rec_r_fractal_call: F");
7998 }
7999#endif
8001 idDelete(&Gresult1);
8002 idDelete(&Gomega2);
8003 idDelete(&G);
8004
8005 rChangeCurrRing(new_ring);
8006 //F1 = idrMoveR(F, oRing,currRing);
8007 G = idrMoveR(F,oRing,currRing);
8008/*
8009#ifdef TIME_TEST
8010 to=clock();
8011#endif
8012 // Interreduce G
8013 G = kInterRedCC(F1, NULL);
8014#ifdef TIME_TEST
8015 xtred=xtred+clock()-to;
8016#endif
8017 idDelete(&F1);
8018*/
8019 }
8020}
static int isNegNolVector(intvec *hilb)
Definition walk.cc:3062

◆ Set_Error()

void Set_Error ( BOOLEAN f)

Definition at line 86 of file walk.cc.

86{ pSetm_error=f; }
VAR BOOLEAN pSetm_error
Definition p_polys.cc:150

◆ test_G_GB_walk()

static int test_G_GB_walk ( ideal H0,
ideal H1 )
inlinestatic

Definition at line 3533 of file walk.cc.

3534{
3535 int i, nG = IDELEMS(H0);
3536
3537 if(nG != IDELEMS(H1))
3538 {
3539 return 0;
3540 }
3541 for(i=nG-1; i>=0; i--)
3542 {
3543/*
3544 poly t;
3545 if((t=pSub(pCopy(H0->m[i]), pCopy(H1->m[i]))) != NULL)
3546 {
3547 pDelete(&t);
3548 return 0;
3549 }
3550 pDelete(&t);
3551*/
3552 if(!pEqualPolys(H0->m[i],H1->m[i]))
3553 {
3554 return 0;
3555 }
3556 }
3557 return 1;
3558}
#define pEqualPolys(p1, p2)
Definition polys.h:400

◆ test_w_in_ConeCC()

static int test_w_in_ConeCC ( ideal G,
intvec * iv )
static

Definition at line 786 of file walk.cc.

787{
788 if(G->m[0] == NULL)
789 {
790 PrintS("//** the result may be WRONG, i.e. 0!!\n");
791 return 0;
792 }
793
794 BOOLEAN nError = Overflow_Error;
796
797 int i, nG = IDELEMS(G);
798 poly mi, gi;
799
800 for(i=nG-1; i>=0; i--)
801 {
802 mi = MpolyInitialForm(G->m[i], iv);
803 //Print("\n **// test_w_in_ConeCC: lm(initial)= %s \n",pString(mi));
804 gi = G->m[i];
805 //Print("\n **// test_w_in_ConeCC: lm(ideal)= %s \n",pString(gi));
806 if(mi == NULL)
807 {
808 if(Overflow_Error == FALSE)
809 {
810 Overflow_Error = nError;
811 }
812 return 0;
813 }
814 if(!pLmEqual(mi, gi))
815 {
816 pDelete(&mi);
817 if(Overflow_Error == FALSE)
818 {
819 Overflow_Error = nError;
820 }
821 return 0;
822 }
823 pDelete(&mi);
824 }
825
826 if(Overflow_Error == FALSE)
827 {
828 Overflow_Error = nError;
829 }
830 return 1;
831}
#define pLmEqual(p1, p2)
Definition polys.h:112

◆ TranMImprovwalk()

ideal TranMImprovwalk ( ideal G,
intvec * curr_weight,
intvec * target_tmp,
int nP )

Definition at line 8397 of file walk.cc.

8398{
8399#ifdef TIME_TEST
8400 clock_t mtim = clock();
8401#endif
8402 Set_Error(FALSE );
8404 //Print("// pSetm_Error = (%d)", ErrorCheck());
8405 //Print("\n// ring ro = %s;", rString(currRing));
8406
8407#ifdef TIME_TEST
8408 clock_t tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0, textra=0;
8409 clock_t tinput = clock();
8410#endif
8411 int nsteppert=0, i, nV = currRing->N, nwalk=0, npert_tmp=0;
8412 int *npert=(int*)omAlloc(2*nV*sizeof(int));
8413 ideal Gomega, M,F, G1, Gomega1, Gomega2, M1, F1;
8414 //ring endRing;
8415 ring newRing, oldRing, lpRing;
8416 intvec* next_weight;
8417 intvec* ivNull = new intvec(nV); //define (0,...,0)
8418 intvec* iv_dp = MivUnit(nV);// define (1,1,...,1)
8419 intvec* iv_lp = Mivlp(nV); //define (1,0,...,0)
8420 ideal H0;
8421 //ideal H1;
8422 ideal H2, Glp;
8423 int nGB, endwalks = 0, nwalkpert=0;
8424 intvec* Mlp = MivMatrixOrderlp(nV);
8425 intvec* vector_tmp = new intvec(nV);
8426#ifndef BUCHBERGER_ALG
8427 intvec* hilb_func;
8428#endif
8429 // to avoid (1,0,...,0) as the target vector
8430 intvec* last_omega = new intvec(nV);
8431 for(i=nV-1; i>0; i--)
8432 (*last_omega)[i] = 1;
8433 (*last_omega)[0] = 10000;
8434
8435 // intvec* extra_curr_weight = new intvec(nV);
8436 intvec* target_weight = new intvec(nV);
8437 for(i=nV-1; i>=0; i--)
8438 (*target_weight)[i] = (*target_tmp)[i];
8439
8440 ring XXRing = currRing;
8441 newRing = currRing;
8442
8443#ifdef TIME_TEST
8444 to=clock();
8445#endif
8446 // compute a red. GB w.r.t. the help ring
8447 if(MivComp(curr_weight, iv_dp) == 1) //rOrdStr(currRing) = "dp"
8448 G = MstdCC(G);
8449 else
8450 {
8451 //rOrdStr(currRing) = (a(.c_w..),lp,C)
8452 if (rParameter(currRing) != NULL)
8453 DefRingPar(curr_weight);
8454 else
8455 rChangeCurrRing(VMrDefault(curr_weight));
8456 G = idrMoveR(G, XXRing,currRing);
8457 G = MstdCC(G);
8458 }
8459#ifdef TIME_TEST
8460 tostd=clock()-to;
8461#endif
8462
8463#ifdef REPRESENTATION_OF_SIGMA
8464 ideal Gw = MwalkInitialForm(G, curr_weight);
8465
8466 if(islengthpoly2(Gw)==1)
8467 {
8468 intvec* MDp;
8469 if(MivComp(curr_weight, iv_dp) == 1)
8470 MDp = MatrixOrderdp(nV); //MivWeightOrderlp(iv_dp);
8471 else
8472 MDp = MivWeightOrderlp(curr_weight);
8473
8474 curr_weight = RepresentationMatrix_Dp(G, MDp);
8475
8476 delete MDp;
8477
8478 ring exring = currRing;
8479
8480 if (rParameter(currRing) != NULL)
8481 DefRingPar(curr_weight);
8482 else
8483 rChangeCurrRing(VMrDefault(curr_weight));
8484#ifdef TIME_TEST
8485 to=clock();
8486#endif
8487 Gw = idrMoveR(G, exring,currRing);
8488 G = MstdCC(Gw);
8489 Gw = NULL;
8490#ifdef TIME_TEST
8491 tostd=tostd+clock()-to;
8492#endif
8493 //ivString(curr_weight,"rep. sigma");
8494 goto COMPUTE_NEW_VECTOR;
8495 }
8496
8497 idDelete(&Gw);
8498 delete iv_dp;
8499#endif
8500
8501
8502 while(1)
8503 {
8504#ifdef TIME_TEST
8505 to=clock();
8506#endif
8507 /* compute an initial form ideal of <G> w.r.t. "curr_vector" */
8508 Gomega = MwalkInitialForm(G, curr_weight);
8509#ifdef TIME_TEST
8510 tif=tif+clock()-to;
8511#endif
8512
8513#ifndef BUCHBERGER_ALG
8514 if(isNolVector(curr_weight) == 0)
8515 hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing);
8516 else
8517 hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);
8518#endif // BUCHBERGER_ALG
8519
8520 oldRing = currRing;
8521
8522 /* define a new ring that its ordering is "(a(curr_weight),lp) */
8523 if (rParameter(currRing) != NULL)
8524 DefRingPar(curr_weight);
8525 else
8526 rChangeCurrRing(VMrDefault(curr_weight));
8527
8528 newRing = currRing;
8529 Gomega1 = idrMoveR(Gomega, oldRing,currRing);
8530
8531#ifdef TIME_TEST
8532 to=clock();
8533#endif
8534 /* compute a reduced Groebner basis of <Gomega> w.r.t. "newRing" */
8535#ifdef BUCHBERGER_ALG
8536 M = MstdhomCC(Gomega1);
8537#else
8538 M=kStd2(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
8539 delete hilb_func;
8540#endif // BUCHBERGER_ALG
8541#ifdef TIME_TEST
8542 tstd=tstd+clock()-to;
8543#endif
8544
8545 /* change the ring to oldRing */
8546 rChangeCurrRing(oldRing);
8547 M1 = idrMoveR(M, newRing,currRing);
8548 Gomega2 = idrMoveR(Gomega1, newRing,currRing);
8549
8550#ifdef TIME_TEST
8551 to=clock();
8552#endif
8553 /* compute a representation of the generators of submod (M)
8554 with respect to those of mod (Gomega).
8555 Gomega is a reduced Groebner basis w.r.t. the current ring */
8556 F = MLifttwoIdeal(Gomega2, M1, G);
8557#ifdef TIME_TEST
8558 tlift=tlift+clock()-to;
8559#endif
8560
8561 idDelete(&M1);
8562 idDelete(&Gomega2);
8563 idDelete(&G);
8564
8565 /* change the ring to newRing */
8566 rChangeCurrRing(newRing);
8567 F1 = idrMoveR(F, oldRing,currRing);
8568
8569#ifdef TIME_TEST
8570 to=clock();
8571#endif
8572 /* reduce the Groebner basis <G> w.r.t. new ring */
8573 G = kInterRedCC(F1, NULL);
8574#ifdef TIME_TEST
8575 tred=tred+clock()-to;
8576#endif
8577 idDelete(&F1);
8578
8579
8580 COMPUTE_NEW_VECTOR:
8581 newRing = currRing;
8582 nwalk++;
8583 nwalkpert++;
8584#ifdef TIME_TEST
8585 to=clock();
8586#endif
8587 // compute a next weight vector
8588 next_weight = MwalkNextWeightCC(curr_weight,target_weight, G);
8589#ifdef TIME_TEST
8590 tnw=tnw+clock()-to;
8591#endif
8592#ifdef PRINT_VECTORS
8593 MivString(curr_weight, target_weight, next_weight);
8594#endif
8595
8596 /* check whether the computed intermediate weight vector is in
8597 the correct cone; sometimes it is very big e.g. s7, cyc7.
8598 If it is NOT in the correct cone, then compute directly
8599 a reduced Groebner basis with respect to the lexicographic ordering
8600 for the known Groebner basis that it is computed in the last step.
8601 */
8602 //if(test_w_in_ConeCC(G, next_weight) != 1)
8603 if(Overflow_Error == TRUE)
8604 {
8605 OMEGA_OVERFLOW_TRAN_NEW:
8606 //Print("\n// takes %d steps!", nwalk-1);
8607 //Print("\n//ring lastRing = %s;", rString(currRing));
8608#ifdef TEST_OVERFLOW
8609 goto BE_FINISH;
8610#endif
8611/*
8612#ifdef CHECK_IDEAL_MWALK
8613 idElements(G, "G");
8614 //headidString(G, "G");
8615#endif
8616*/
8617 if(MivSame(target_tmp, iv_lp) == 1)
8618 if (rParameter(currRing) != NULL)
8619 DefRingParlp();
8620 else
8621 VMrDefaultlp();
8622 else
8623 if (rParameter(currRing) != NULL)
8624 DefRingPar(target_tmp);
8625 else
8626 rChangeCurrRing(VMrDefault(target_tmp));
8627
8628 lpRing = currRing;
8629 G1 = idrMoveR(G, newRing,currRing);
8630
8631#ifdef TIME_TEST
8632 to=clock();
8633#endif
8634 /*apply kStd2 or LastGB to compute a lex. red. Groebner basis of <G>*/
8635 if(nP == 0 || MivSame(target_tmp, iv_lp) == 0){
8636 //Print("\n\n// calls \"std in ring r_%d = %s;", nwalk, rString(currRing));
8637 G = MstdCC(G1);//no result for qnt1
8638 }
8639 else {
8640 rChangeCurrRing(newRing);
8641 G1 = idrMoveR(G1, lpRing,currRing);
8642
8643 //Print("\n\n// calls \"LastGB\" (%d) to compute a GB", nV-1);
8644 G = LastGB(G1, curr_weight, nV-1); //no result for kats7
8645
8646 rChangeCurrRing(lpRing);
8647 G = idrMoveR(G, newRing,currRing);
8648 }
8649#ifdef TIME_TEST
8650 textra=clock()-to;
8651#endif
8652 npert[endwalks]=nwalk-npert_tmp;
8653 npert_tmp = nwalk;
8654 endwalks ++;
8655 break;
8656 }
8657
8658 /* check whether the computed Groebner basis is really a Groebner basis.
8659 If not, we perturb the target vector with the maximal "perturbation"
8660 degree.*/
8661 if(MivComp(next_weight, target_weight) == 1 ||
8662 MivComp(next_weight, curr_weight) == 1 )
8663 {
8664 //Print("\n//ring r_%d = %s;", nwalk, rString(currRing));
8665
8666
8667 //compute the number of perturbations and its step
8668 npert[endwalks]=nwalk-npert_tmp;
8669 npert_tmp = nwalk;
8670
8671 endwalks ++;
8672
8673 /*it is very important if the walk only uses one step, e.g. Fate, liu*/
8674 if(endwalks == 1 && MivComp(next_weight, curr_weight) == 1){
8675 rChangeCurrRing(XXRing);
8676 G = idrMoveR(G, newRing,currRing);
8677 goto FINISH;
8678 }
8679 H0 = id_Head(G,currRing);
8680
8681 if(MivSame(target_tmp, iv_lp) == 1)
8682 if (rParameter(currRing) != NULL)
8683 DefRingParlp();
8684 else
8685 VMrDefaultlp();
8686 else
8687 if (rParameter(currRing) != NULL)
8688 DefRingPar(target_tmp);
8689 else
8690 rChangeCurrRing(VMrDefault(target_tmp));
8691
8692 lpRing = currRing;
8693 Glp = idrMoveR(G, newRing,currRing);
8694 H2 = idrMoveR(H0, newRing,currRing);
8695
8696 /* Apply Lemma 2.2 in Collart et. al (1997) to check whether
8697 cone(k-1) is equal to cone(k) */
8698 nGB = 1;
8699 for(i=IDELEMS(Glp)-1; i>=0; i--)
8700 {
8701 poly t;
8702 if((t=pSub(pHead(Glp->m[i]), pCopy(H2->m[i]))) != NULL)
8703 {
8704 pDelete(&t);
8705 idDelete(&H2);//5.5.02
8706 nGB = 0; //i.e. Glp is no reduced Groebner basis
8707 break;
8708 }
8709 pDelete(&t);
8710 }
8711
8712 idDelete(&H2);//5.5.02
8713
8714 if(nGB == 1)
8715 {
8716 G = Glp;
8717 Glp = NULL;
8718 break;
8719 }
8720
8721 /* perturb the target weight vector, if the vector target_tmp
8722 stays in many cones */
8723 poly p;
8724 BOOLEAN plength3 = FALSE;
8725 for(i=IDELEMS(Glp)-1; i>=0; i--)
8726 {
8727 p = MpolyInitialForm(Glp->m[i], target_tmp);
8728 if(p->next != NULL &&
8729 p->next->next != NULL &&
8730 p->next->next->next != NULL)
8731 {
8733
8734 for(i=0; i<nV; i++)
8735 (*vector_tmp)[i] = (*target_weight)[i];
8736
8737 delete target_weight;
8738 target_weight = MPertVectors(Glp, Mlp, nV);
8739
8740 if(MivComp(vector_tmp, target_weight)==1)
8741 {
8742 //PrintS("\n// The old and new representaion vector are the same!!");
8743 G = Glp;
8744 newRing = currRing;
8745 goto OMEGA_OVERFLOW_TRAN_NEW;
8746 }
8747
8748 if(Overflow_Error == TRUE)
8749 {
8750 rChangeCurrRing(newRing);
8751 G = idrMoveR(Glp, lpRing,currRing);
8752 goto OMEGA_OVERFLOW_TRAN_NEW;
8753 }
8754
8755 plength3 = TRUE;
8756 pDelete(&p);
8757 break;
8758 }
8759 pDelete(&p);
8760 }
8761
8762 if(plength3 == FALSE)
8763 {
8764 rChangeCurrRing(newRing);
8765 G = idrMoveR(Glp, lpRing,currRing);
8766 goto TRAN_LIFTING;
8767 }
8768
8769
8770 nwalkpert = 1;
8771 nsteppert ++;
8772
8773 /*
8774 Print("\n// Subroutine needs (%d) steps.", nwalk);
8775 idElements(Glp, "last G in walk:");
8776 PrintS("\n// ****************************************");
8777 Print("\n// Perturb the original target vector (%d): ", nsteppert);
8778 ivString(target_weight, "new target");
8779 PrintS("\n// ****************************************\n");
8780 */
8781 rChangeCurrRing(newRing);
8782 G = idrMoveR(Glp, lpRing,currRing);
8783
8784 delete next_weight;
8785
8786 //Print("\n// ring rNEW = %s;", rString(currRing));
8787 goto COMPUTE_NEW_VECTOR;
8788 }
8789
8790 TRAN_LIFTING:
8791 for(i=nV-1; i>=0; i--)
8792 (*curr_weight)[i] = (*next_weight)[i];
8793
8794 delete next_weight;
8795 }//while
8796#ifdef TEST_OVERFLOW
8797 BE_FINISH:
8798#endif
8799 rChangeCurrRing(XXRing);
8800 G = idrMoveR(G, lpRing,currRing);
8801
8802 FINISH:
8803 delete ivNull;
8804 delete next_weight;
8805 delete iv_lp;
8806 omFree(npert);
8807/*
8808#ifdef TIME_TEST
8809 Print("\n// Computation took %d steps and %.2f sec",
8810 nwalk, ((double) (clock()-mtim)/1000000));
8811
8812 TimeStringFractal(tinput, tostd, tif, tstd, textra, tlift, tred, tnw);
8813
8814 // Print("\n// pSetm_Error = (%d)", ErrorCheck());
8815 Print("\n// Overflow_Error? (%d)\n", Overflow_Error);
8816#endif
8817*/
8818 return(G);
8819}
ideal id_Head(ideal h, const ring r)
returns the ideals of initial terms

◆ VMatrDefault()

static ring VMatrDefault ( intvec * va)
static

Definition at line 2791 of file walk.cc.

2792{
2793
2794 ring r = rCopy0(currRing,FALSE,FALSE);
2795 int i, nv = currRing->N;
2796
2797 int nb = 4;
2798
2799 /*weights: entries for 3 blocks: NULL Made:???*/
2800 r->wvhdl = (int **)omAlloc0(nb * sizeof(int_ptr));
2801 r->wvhdl[0] = (int*) omAlloc(nv*nv*sizeof(int));
2802 r->wvhdl[1] =NULL; // (int*) omAlloc(nv*sizeof(int));
2803 r->wvhdl[2]=NULL;
2804 r->wvhdl[3]=NULL;
2805 for(i=0; i<nv*nv; i++)
2806 r->wvhdl[0][i] = (*va)[i];
2807
2808 /* order: a,lp,C,0 */
2809 r->order = (rRingOrder_t*) omAlloc(nb * sizeof(rRingOrder_t*));
2810 r->block0 = (int *)omAlloc0(nb * sizeof(int *));
2811 r->block1 = (int *)omAlloc0(nb * sizeof(int *));
2812
2813 // ringorder a for the first block: var 1..nv
2814 r->order[0] = ringorder_M;
2815 r->block0[0] = 1;
2816 r->block1[0] = nv;
2817
2818 // ringorder C for the second block
2819 r->order[1] = ringorder_C;
2820 r->block0[1] = 1;
2821 r->block1[1] = nv;
2822
2823// ringorder C for the third block: var 1..nv
2824 r->order[2] = ringorder_C;
2825 r->block0[2] = 1;
2826 r->block1[2] = nv;
2827
2828 // the last block: everything is 0
2829 r->order[3] = (rRingOrder_t)0;
2830
2831 // complete ring intializations
2832
2833 rComplete(r);
2834
2835 //rChangeCurrRing(r);
2836 return r;
2837}
@ ringorder_M
Definition ring.h:75

◆ VMatrRefine()

static ring VMatrRefine ( intvec * va,
intvec * vb )
static

Definition at line 2842 of file walk.cc.

2843{
2844
2845 ring r = rCopy0(currRing,FALSE,FALSE);
2846 int i, nv = currRing->N;
2847 int nvs = nv*nv;
2848
2849 int nb = 4;
2850
2851 /*weights: entries for 3 blocks: NULL Made:???*/
2852 r->wvhdl = (int **)omAlloc0(nb * sizeof(int_ptr));
2853 r->wvhdl[0] = (int*) omAlloc(nv*sizeof(int));
2854 r->wvhdl[1] = (int*) omAlloc(nvs*sizeof(int));
2855 r->wvhdl[2]=NULL;
2856 r->wvhdl[3]=NULL;
2857 for(i=0; i<nvs; i++)
2858 {
2859 r->wvhdl[1][i] = (*va)[i];
2860 }
2861 for(i=0; i<nv; i++)
2862 {
2863 r->wvhdl[0][i] = (*vb)[i];
2864 }
2865 /* order: a,lp,C,0 */
2866 r->order = (rRingOrder_t *) omAlloc(nb * sizeof(rRingOrder_t *));
2867 r->block0 = (int *)omAlloc0(nb * sizeof(int *));
2868 r->block1 = (int *)omAlloc0(nb * sizeof(int *));
2869
2870 // ringorder a for the first block: var 1..nv
2871 r->order[0] = ringorder_a;
2872 r->block0[0] = 1;
2873 r->block1[0] = nv;
2874
2875 // ringorder M for the second block: var 1..nv
2876 r->order[1] = ringorder_M;
2877 r->block0[1] = 1;
2878 r->block1[1] = nv;
2879
2880 // ringorder C for the third block: var 1..nv
2881 r->order[2] = ringorder_C;
2882 r->block0[2] = 1;
2883 r->block1[2] = nv;
2884
2885 // the last block: everything is 0
2886 r->order[3] = (rRingOrder_t)0;
2887
2888 // complete ring intializations
2889
2890 rComplete(r);
2891
2892 //rChangeCurrRing(r);
2893 return r;
2894}

◆ VMrDefault()

static ring VMrDefault ( intvec * va)
static

Definition at line 2681 of file walk.cc.

2682{
2683
2684 ring r = rCopy0(currRing,FALSE,FALSE);
2685 int i, nv = currRing->N;
2686
2687 int nb = 4;
2688
2689 /*weights: entries for 3 blocks: NULL Made:???*/
2690 r->wvhdl = (int **)omAlloc0(nb * sizeof(int_ptr));
2691 r->wvhdl[0] = (int*) omAlloc(nv*sizeof(int));
2692 for(i=0; i<nv; i++)
2693 r->wvhdl[0][i] = (*va)[i];
2694
2695 /* order: a,lp,C,0 */
2696 r->order = (rRingOrder_t *) omAlloc(nb * sizeof(rRingOrder_t *));
2697 r->block0 = (int *)omAlloc0(nb * sizeof(int *));
2698 r->block1 = (int *)omAlloc0(nb * sizeof(int *));
2699
2700 // ringorder a for the first block: var 1..nv
2701 r->order[0] = ringorder_a;
2702 r->block0[0] = 1;
2703 r->block1[0] = nv;
2704
2705 // ringorder lp for the second block: var 1..nv
2706 r->order[1] = ringorder_lp;
2707 r->block0[1] = 1;
2708 r->block1[1] = nv;
2709
2710 // ringorder C for the third block
2711 // it is very important within "idLift",
2712 // especially, by ring syz_ring=rCurrRingAssure_SyzComp();
2713 // therefore, nb must be (nBlocks(currRing) + 1)
2714 r->order[2] = ringorder_C;
2715
2716 // the last block: everything is 0
2717 r->order[3] = (rRingOrder_t)0;
2718
2719 // polynomial ring
2720 r->OrdSgn = 1;
2721
2722 // complete ring intializations
2723
2724 rComplete(r);
2725 return r;
2726 //rChangeCurrRing(r);
2727}

◆ VMrDefaultlp()

static void VMrDefaultlp ( void )
static

Definition at line 2899 of file walk.cc.

2900{
2901 ring r = rCopy0(currRing,FALSE,FALSE);
2902 int nv = currRing->N;
2903
2904 int nb = rBlocks(currRing) + 1;
2905
2906 /*weights: entries for 3 blocks: NULL Made:???*/
2907
2908 r->wvhdl = (int **)omAlloc0(nb * sizeof(int_ptr));
2909
2910 /* order: lp,C,0 */
2911 r->order = (rRingOrder_t *) omAlloc(nb * sizeof(rRingOrder_t *));
2912 r->block0 = (int *)omAlloc0(nb * sizeof(int *));
2913 r->block1 = (int *)omAlloc0(nb * sizeof(int *));
2914
2915 /* ringorder lp for the first block: var 1..nv */
2916 r->order[0] = ringorder_lp;
2917 r->block0[0] = 1;
2918 r->block1[0] = nv;
2919
2920 /* ringorder C for the second block */
2921 r->order[1] = ringorder_C;
2922
2923 /* the last block: everything is 0 */
2924 r->order[2] = (rRingOrder_t)0;
2925
2926 /*polynomial ring*/
2927 r->OrdSgn = 1;
2928
2929 /* complete ring intializations */
2930
2931 rComplete(r);
2932
2933 rChangeCurrRing(r);
2934}

◆ VMrRefine()

static ring VMrRefine ( intvec * va,
intvec * vb )
static

Definition at line 2732 of file walk.cc.

2733{
2734
2735 ring r = rCopy0(currRing,FALSE,FALSE);
2736 int i, nv = currRing->N;
2737
2738 int nb = 5;
2739
2740 //weights: entries for 3 blocks: NULL Made:???
2741 r->wvhdl = (int **)omAlloc0(nb * sizeof(int_ptr));
2742 r->wvhdl[0] = (int*) omAlloc(nv*sizeof(int));
2743 r->wvhdl[1] = (int*) omAlloc(nv*sizeof(int));
2744
2745 for(i=0; i<nv; i++)
2746 {
2747 r->wvhdl[0][i] = (*vb)[i];
2748 r->wvhdl[1][i] = (*va)[i];
2749 }
2750
2751 // order: (1..1),a,lp,C
2752 r->order = (rRingOrder_t *) omAlloc(nb * sizeof(rRingOrder_t *));
2753 r->block0 = (int *)omAlloc0(nb * sizeof(int *));
2754 r->block1 = (int *)omAlloc0(nb * sizeof(int *));
2755
2756 // ringorder a for the first block: var 1..nv
2757 r->order[0] = ringorder_a;
2758 r->block0[0] = 1;
2759 r->block1[0] = nv;
2760
2761 // ringorder Wp for the second block: var 1..nv
2762 r->order[1] = ringorder_a;
2763 r->block0[1] = 1;
2764 r->block1[1] = nv;
2765
2766 // ringorder lp for the third block: var 1..nv
2767 r->order[2] = ringorder_lp;
2768 r->block0[2] = 1;
2769 r->block1[2] = nv;
2770
2771 // ringorder C for the 4th block
2772 // it is very important within "idLift",
2773 // especially, by ring syz_ring=rCurrRingAssure_SyzComp();
2774 // therefore, nb must be (nBlocks(currRing) + 1)
2775 r->order[3] = ringorder_C;
2776
2777 // the last block: everything is 0
2778 r->order[4] = (rRingOrder_t)0;
2779
2780 // complete ring intializations
2781
2782 rComplete(r);
2783
2784 //rChangeCurrRing(r);
2785 return r;
2786}

Variable Documentation

◆ ngleich

VAR int ngleich

Definition at line 4506 of file walk.cc.

◆ nnflow

VAR int nnflow

Definition at line 6945 of file walk.cc.

◆ nstep

VAR int nstep

kstd2.cc

Definition at line 80 of file walk.cc.

◆ Overflow_Error

VAR BOOLEAN Overflow_Error = FALSE

Definition at line 88 of file walk.cc.

◆ pSetm_error

EXTERN_VAR BOOLEAN pSetm_error

Definition at line 84 of file walk.cc.

◆ Xcall

VAR int Xcall

Definition at line 6946 of file walk.cc.

◆ Xivinput

VAR intvec* Xivinput

Definition at line 4510 of file walk.cc.

◆ Xivlp

VAR intvec* Xivlp

Definition at line 4511 of file walk.cc.

◆ XivNull

VAR intvec* XivNull

Definition at line 6928 of file walk.cc.

◆ xn

VAR int xn

Definition at line 4509 of file walk.cc.

◆ Xngleich

VAR int Xngleich

Definition at line 6947 of file walk.cc.

◆ Xnlev

VAR int Xnlev

Definition at line 1512 of file walk.cc.

◆ Xsigma

VAR intvec* Xsigma

Definition at line 4507 of file walk.cc.

◆ Xtau

VAR intvec* Xtau

Definition at line 4508 of file walk.cc.