2995{
2996
2997
2998
2999
3000
3001
3002
3003#if SBA_PRINT_ZERO_REDUCTIONS
3004 long zeroreductions = 0;
3005#endif
3006#if SBA_PRINT_PRODUCT_CRITERION
3007 long product_criterion = 0;
3008#endif
3009#if SBA_PRINT_SIZE_G
3010 int size_g = 0;
3011 int size_g_non_red = 0;
3012#endif
3013#if SBA_PRINT_SIZE_SYZ
3014 long size_syz = 0;
3015#endif
3016
3017#if SBA_PRINT_REDUCTION_STEPS
3018 sba_reduction_steps = 0;
3019 sba_interreduction_steps = 0;
3020#endif
3021#if SBA_PRINT_OPERATIONS
3022 sba_operations = 0;
3023 sba_interreduction_operations = 0;
3024#endif
3025
3026 ideal F1 = F0;
3027 ring sRing, currRingOld;
3030 {
3032 if (sRing!=currRingOld)
3033 {
3036 }
3037 }
3038 ideal F;
3039
3040
3041
3043 {
3044 #if 1
3049 {
3050 poly dummy;
3051 dummy =
pCopy(F->m[0]);
3053 F->m[
i] = F->m[
i+1];
3055 }
3056 #else
3058
3059 F->m[0] = F1->m[0];
3060 int pos;
3062 {
3064 {
3067 }
3069 {
3072 }
3073 poly dummy;
3074 dummy =
pCopy(F->m[0]);
3076 F->m[
i] = F->m[
i+1];
3078 }
3079 else
3080 {
3082 {
3085 }
3086 }
3087 #endif
3088
3089 }
3090 else
3091 {
3094 for (
int i=0;
i<
sort->length();++
i)
3095 F->m[
i] = F1->m[(*
sort)[
i]-1];
3097 {
3098
3099
3100 int nrmon = 0;
3102 {
3103
3105 {
3108 {
3109 F->m[
j] = F->m[
j-1];
3110 }
3112 nrmon++;
3113 }
3114
3115 }
3116 }
3117 }
3118
3123#if SBA_INTERRED_START
3125#endif
3126#if F5DEBUG
3127 printf("SBA COMPUTATIONS DONE IN THE FOLLOWING RING:\n");
3129 printf(
"ordSgn = %d\n",
currRing->OrdSgn);
3130 printf("\n");
3131#endif
3132 int srmax,lrmax, red_result = 1;
3133 int olddeg,reduc;
3134 int hilbeledeg=1,hilbcount=0,minimcnt=0;
3138
3143
3148 reduc = olddeg = lrmax = 0;
3149#ifndef NO_BUCKETS
3152#endif
3153
3154
3155
3156
3157
3158
3160
3161#ifdef HAVE_TAIL_RING
3164#endif
3166 {
3170 }
3171
3173 {
3175 {
3176
3177
3179 strat->
enterS(strat->
L[strat->
Ll-(
i)], strat->
sl+1, strat, strat->
tl);
3180 }
3183 }
3185#ifdef KDEBUG
3186
3187#endif
3188
3189 while (strat->
Ll >= 0)
3190 {
3191 if (strat->
Ll > lrmax) lrmax =strat->
Ll;
3192 #ifdef KDEBUG
3194 #endif
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3216 {
3218#if F5C
3219
3220
3221 f5c ( strat, olddeg, minimcnt, hilbeledeg, hilbcount, srmax,
3222 lrmax, reduc,
Q,
w, hilb );
3223#endif
3224
3226 }
3227
3228
3229
3230
3231
3232 strat->
P = strat->
L[strat->
Ll];
3234
3237
3238 if (!strat->
rewCrit2(strat->
P.sig, ~strat->
P.sevSig, strat->
P.GetLmCurrRing(), strat, strat->
P.checked+1))
3239 {
3240
3241#ifdef DEBUGF5
3242 PrintS(
"SIG OF NEXT PAIR TO HANDLE IN SIG-BASED ALGORITHM\n");
3243 PrintS(
"-------------------------------------------------\n");
3248 PrintS(
"-------------------------------------------------\n");
3249#endif
3251 {
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3264
3265
3268 {
3270
3271
3273 {
3275 break;
3276 }
3277 }
3278
3281
3282 }
3283 else if (strat->
P.p1 ==
NULL)
3284 {
3285 if (strat->
minim > 0)
3287
3290 }
3291 if (strat->
P.p ==
NULL && strat->
P.t_p ==
NULL)
3292 {
3293 red_result = 0;
3294 }
3295 else
3296 {
3297
3298#ifdef DEBUGF5
3299 PrintS(
"Poly before red: ");
3302#endif
3303#if SBA_PRODUCT_CRITERION
3304 if (strat->
P.prod_crit)
3305 {
3306#if SBA_PRINT_PRODUCT_CRITERION
3307 product_criterion++;
3308#endif
3309 int pos =
posInSyz(strat, strat->
P.sig);
3312 red_result = 2;
3313 }
3314 else
3315 {
3316 red_result = strat->
red(&strat->
P,strat);
3317 }
3318#else
3319 red_result = strat->
red(&strat->
P,strat);
3320#endif
3321 }
3322 }
3323 else
3324 {
3325
3326
3327
3328
3329 red_result = 2;
3330 }
3332 {
3334 {
3335 strat->
P.p =
pNeg(strat->
P.p);
3336 strat->
P.sig =
pNeg(strat->
P.sig);
3337 }
3339 if(strat->
P.sig !=
NULL)
3341 if(strat->
P.p !=
NULL)
3343 }
3344
3346 {
3347
3348 red_result =
redRing(&strat->
P,strat);
3349 if(red_result == 0)
3350 {
3353 strat->
P.sig =
NULL;
3354 }
3355 else
3356 {
3357 strat->
enterS(strat->
P, 0, strat, strat->
tl);
3360 break;
3361 }
3362 }
3364 {
3366 break;
3367 }
3368
3370
3371
3372#ifdef DEBUGF5
3373 if (red_result != 0)
3374 {
3375 PrintS(
"Poly after red: ");
3377 pWrite(strat->
P.GetLmCurrRing());
3379 printf("%d\n",red_result);
3380 }
3381#endif
3383 {
3384 if(strat->
P.p !=
NULL)
3386 &olddeg,&reduc,strat, red_result);
3387 else
3389 &olddeg,&reduc,strat, red_result);
3390 }
3391
3393 {
3395 }
3396
3397 if (red_result == 1)
3398 {
3399
3400 strat->
P.GetP(strat->
lmBin);
3401
3402
3403
3404 (strat->
P).FDeg = (strat->
P).pFDeg();
3405
3406
3407
3409
3410
3412
3413
3414
3415
3416 int pos = strat->
sl+1;
3417
3418
3419
3420 #ifdef HAVE_RINGS
3421 poly beforetailred;
3423 beforetailred =
pCopy(strat->
P.sig);
3424 #endif
3425#if SBA_TAIL_RED
3427 {
3429 strat->
P.p =
redtailSba(&(strat->
P),pos-1,strat, withT);
3430 }
3431 else
3432 {
3434 {
3436 {
3437 strat->
P.pCleardenom();
3439 {
3440 strat->
P.p =
redtailSba(&(strat->
P),pos-1,strat, withT);
3441 strat->
P.pCleardenom();
3442 }
3443 }
3444 else
3445 {
3448 strat->
P.p =
redtailSba(&(strat->
P),pos-1,strat, withT);
3449 }
3450 }
3451 }
3452
3453
3454
3456 {
3457 strat->
enterS(strat->
P, 0, strat, strat->
tl);
3458 break;
3459 }
3460#endif
3462 {
3463 if(strat->
P.sig ==
NULL ||
pLtCmp(beforetailred,strat->
P.sig) == 1)
3464 {
3466
3467 red_result =
redRing(&strat->
P,strat);
3468 if(red_result == 0)
3469 {
3470
3473 }
3474 else
3475 {
3476 strat->
enterS(strat->
P, 0, strat, strat->
tl);
3477 break;
3478 }
3479 }
3481
3482 if(strat->
P.p ==
NULL)
3483 goto case_when_red_result_changed;
3484 }
3485
3486
3488 {
3489 for (
int jj = 0; jj<strat->
tl+1; jj++)
3490 {
3492 {
3493 strat->
T[jj].is_sigsafe =
FALSE;
3494 }
3495 }
3496 }
3497 else
3498 {
3499 for (
int jj = 0; jj<strat->
tl+1; jj++)
3500 {
3501 strat->
T[jj].is_sigsafe =
FALSE;
3502 }
3503 }
3504#ifdef KDEBUG
3506#endif
3507
3508
3510 {
3511 if (strat->
minim==1)
3512 {
3515 }
3516 else
3517 {
3518 strat->
M->m[minimcnt]=strat->
P.p2;
3520 }
3522 pNext(strat->
M->m[minimcnt])
3526 minimcnt++;
3527 }
3528
3529
3530
3532 strat->
T[strat->
tl].is_sigsafe =
FALSE;
3533
3534
3535
3536
3537
3540 else
3543 break;
3546 strat->
enterS(strat->
P, pos, strat, strat->
tl);
3548 {
3550 for (
int tk=0; tk<strat->
sl+1; tk++)
3551 {
3553 {
3554
3556 break;
3557 }
3558 }
3559
3560 if (overwrite)
3561 {
3567
3571 for(
int ps=0;ps<strat->
sl+1;ps++)
3572 {
3573
3576 {
3579 (strat->
syzmax)*
sizeof(
unsigned long),
3581 *sizeof(unsigned long));
3583 }
3585
3586
3589
3590
3591
3592
3593
3594
3595
3596
3600
3601
3605 }
3606 }
3607 }
3608
3609
3611 {
3613 unsigned max_cmp =
IDELEMS(F);
3617 int pos;
3619
3620
3622 {
3623 for (
int i=0;
i<strat->
sl; ++
i)
3624 {
3630
3633 }
3635 }
3636 else
3637 {
3638
3639
3640 for (
unsigned i=cmp+1;
i<=max_cmp; ++
i)
3641 {
3642 pos = -1;
3643 for (
int j=0;
j<strat->
sl; ++
j)
3644 {
3646 {
3648 break;
3649 }
3650 }
3651 if (pos != -1)
3652 {
3655
3662 {
3664 {
3667 }
3668 }
3669 else
3670 {
3673 }
3674 }
3675 }
3676
3677 }
3678 }
3679
3680#if DEBUGF50
3681 printf("---------------------------\n");
3682 Print(
" %d. ELEMENT ADDED TO GCURR:\n",strat->
sl+1);
3685#endif
3686
3687
3688
3689
3690
3691
3692#if 0
3694 if (pl==1)
3695 {
3696
3697
3698 }
3699 else if (pl==2)
3700 {
3701
3702
3703 }
3704#endif
3705 if (hilb!=
NULL)
khCheck(
Q,
w,hilb,hilbeledeg,hilbcount,strat);
3706
3708 if (strat->
sl>srmax) srmax = strat->
sl;
3709 }
3710 else
3711 {
3712 case_when_red_result_changed:
3713
3714
3715
3716
3717
3718 if (red_result!=2)
3719 {
3720#if SBA_PRINT_ZERO_REDUCTIONS
3721 zeroreductions++;
3722#endif
3724 {
3725
3726 }
3727 else
3728 {
3729 int pos =
posInSyz(strat, strat->
P.sig);
3731
3732 #ifdef DEBUGF5
3733 Print(
"ADDING STUFF TO SYZ : ");
3734
3736 #endif
3737 }
3738 }
3740 {
3742 }
3743 }
3744
3745#ifdef KDEBUG
3746 memset(&(strat->
P), 0,
sizeof(strat->
P));
3747#endif
3749 }
3750 #if 0
3752 printf("\nSigDrop!\n");
3753 else
3754 printf("\nEnded with no SigDrop\n");
3755 #endif
3756
3758 {
3759
3760 if(strat->
P.sig !=
NULL)
3762
3763 #ifdef KDEBUG
3764 memset(&(strat->
P), 0,
sizeof(strat->
P));
3765 #endif
3766 }
3767#ifdef KDEBUG
3769#endif
3770
3772 {
3774 {
3777 while(k<=strat->sl)
3778 {
3781 {
3785 }
3787 }
3788 }
3789 }
3790
3792 {
3795 {
3796
3797
3798
3799#ifdef HAVE_TAIL_RING
3801 {
3807 }
3809#endif
3811 }
3812 }
3814
3815#if SBA_PRINT_SIZE_SYZ
3816
3817 size_syz = strat->
syzl;
3818#endif
3819
3820
3821
3822
3823
3824
3825
3826
3827
3830#if SBA_PRINT_SIZE_G
3832#endif
3835
3836 #ifdef HAVE_RINGS
3839 {
3840
3841
3843 #if 1
3844
3845 for(;
k>=0 && (strat->
L[
k].p1 !=
NULL || strat->
L[
k].p2 !=
NULL);
k--)
3846 {
3847
3849 }
3850 #endif
3851
3852
3853
3854
3855 for(;
k>=0 && strat->
L[
k].p1 ==
NULL && strat->
L[
k].p2 ==
NULL;
k--)
3856 {
3857
3858 strat->
enterS(strat->
L[
k], strat->
sl+1, strat, strat->
tl);
3859
3860 }
3861 }
3862
3863 #if 0
3865 {
3866 for(
k=strat->
sl;
k>=0;
k--)
3867 {
3871 }
3872 }
3873 #endif
3874 #endif
3875
3876
3877
3878
3880 {
3891 }
3898
3899#if SBA_PRINT_SIZE_G
3901#endif
3902#ifdef DEBUGF5
3903 printf(
"SIZE OF SHDL: %d\n",
IDELEMS(strat->
Shdl));
3904 int oo = 0;
3906 {
3907 printf(" %d. ",oo+1);
3909 oo++;
3910 }
3911#endif
3912#if SBA_PRINT_ZERO_REDUCTIONS
3913 printf("----------------------------------------------------------\n");
3914 printf("ZERO REDUCTIONS: %ld\n",zeroreductions);
3915 zeroreductions = 0;
3916#endif
3917#if SBA_PRINT_REDUCTION_STEPS
3918 printf("----------------------------------------------------------\n");
3919 printf("S-REDUCTIONS: %ld\n",sba_reduction_steps);
3920#endif
3921#if SBA_PRINT_OPERATIONS
3922 printf("OPERATIONS: %ld\n",sba_operations);
3923#endif
3924#if SBA_PRINT_REDUCTION_STEPS
3925 printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n");
3926 printf("INTERREDUCTIONS: %ld\n",sba_interreduction_steps);
3927#endif
3928#if SBA_PRINT_OPERATIONS
3929 printf("INTERREDUCTION OPERATIONS: %ld\n",sba_interreduction_operations);
3930#endif
3931#if SBA_PRINT_REDUCTION_STEPS
3932 printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n");
3933 printf("ALL REDUCTIONS: %ld\n",sba_reduction_steps+sba_interreduction_steps);
3934 sba_interreduction_steps = 0;
3935 sba_reduction_steps = 0;
3936#endif
3937#if SBA_PRINT_OPERATIONS
3938 printf("ALL OPERATIONS: %ld\n",sba_operations+sba_interreduction_operations);
3939 sba_interreduction_operations = 0;
3940 sba_operations = 0;
3941#endif
3942#if SBA_PRINT_SIZE_G
3943 printf("----------------------------------------------------------\n");
3944 printf("SIZE OF G: %d / %d\n",size_g,size_g_non_red);
3945 size_g = 0;
3946 size_g_non_red = 0;
3947#endif
3948#if SBA_PRINT_SIZE_SYZ
3949 printf("SIZE OF SYZ: %ld\n",size_syz);
3950 printf("----------------------------------------------------------\n");
3951 size_syz = 0;
3952#endif
3953#if SBA_PRINT_PRODUCT_CRITERION
3954 printf("PRODUCT CRITERIA: %ld\n",product_criterion);
3955 product_criterion = 0;
3956#endif
3957 return (strat->
Shdl);
3958}
BOOLEAN(* rewCrit2)(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
void sort(CFArray &A, int l=0)
quick sort A
BOOLEAN idInsertPolyOnPos(ideal I, poly p, int pos)
insert p into I on position pos
static intvec * idSort(ideal id, BOOLEAN nolex=TRUE)
ideal kInterRed(ideal F, const ideal Q)
void initSba(ideal F, kStrategy strat)
poly redtailSba(LObject *L, int pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize)
void f5c(kStrategy strat, int &olddeg, int &minimcnt, int &hilbeledeg, int &hilbcount, int &srmax, int &lrmax, int &reduc, ideal Q, intvec *w, intvec *hilb)
void initSbaPos(kStrategy strat)
void enterSyz(LObject &p, kStrategy strat, int atT)
void enterpairsSig(poly h, poly hSig, int hFrom, int k, int ecart, int pos, kStrategy strat, int atR)
void superenterpairsSig(poly h, poly hSig, int hFrom, int k, int ecart, int pos, kStrategy strat, int atR)
ring sbaRing(kStrategy strat, const ring r, BOOLEAN, int)
void messageStatSBA(int hilbcount, kStrategy strat)
void initSyzRules(kStrategy strat)
void initSbaBuchMora(ideal F, ideal Q, kStrategy strat)
int posInSyz(const kStrategy strat, poly sig)
void exitSba(kStrategy strat)
int posInIdealMonFirst(const ideal F, const poly p, int start, int end)
void initSbaCrit(kStrategy strat)
#define __p_GetComp(p, r)
#define omRealloc0Size(addr, o_size, size)
void pEnlargeSet(poly **p, int l, int increment)
static void p_ExpVectorAdd(poly p1, poly p2, const ring r)
static void p_SetExpV(poly p, int *ev, const ring r)
static int p_LmCmp(poly p, poly q, const ring r)
static void p_GetExpV(poly p, int *ev, const ring r)
void rChangeCurrRing(ring r)
ideal idrMoveR(ideal &id, ring src_r, ring dest_r)
ideal idrMoveR_NoSort(ideal &id, ring src_r, ring dest_r)
void rWrite(ring r, BOOLEAN details)
void rDelete(ring r)
unconditionally deletes fields in r
void id_DelDiv(ideal id, const ring r)
delete id[j], if LT(j) == coeff*mon*LT(i) and vice versa, i.e., delete id[i], if LT(i) == coeff*mon*L...