2981{
2982
2983
2984
2985
2986
2987
2988
2989#if SBA_PRINT_ZERO_REDUCTIONS
2990 long zeroreductions = 0;
2991#endif
2992#if SBA_PRINT_PRODUCT_CRITERION
2993 long product_criterion = 0;
2994#endif
2995#if SBA_PRINT_SIZE_G
2996 int size_g = 0;
2997 int size_g_non_red = 0;
2998#endif
2999#if SBA_PRINT_SIZE_SYZ
3000 long size_syz = 0;
3001#endif
3002
3003#if SBA_PRINT_REDUCTION_STEPS
3004 sba_reduction_steps = 0;
3005 sba_interreduction_steps = 0;
3006#endif
3007#if SBA_PRINT_OPERATIONS
3008 sba_operations = 0;
3009 sba_interreduction_operations = 0;
3010#endif
3011
3013 ring sRing, currRingOld;
3016 {
3018 if (sRing!=currRingOld)
3019 {
3022 }
3023 }
3024 ideal F;
3025
3026
3027
3029 {
3030 #if 1
3035 {
3036 poly dummy;
3037 dummy =
pCopy(F->m[0]);
3039 F->m[
i] = F->m[
i+1];
3041 }
3042 #else
3044
3046 int pos;
3048 {
3050 {
3053 }
3055 {
3058 }
3059 poly dummy;
3060 dummy =
pCopy(F->m[0]);
3062 F->m[
i] = F->m[
i+1];
3064 }
3065 else
3066 {
3068 {
3071 }
3072 }
3073 #endif
3074
3075 }
3076 else
3077 {
3080 for (
int i=0;
i<
sort->length();++
i)
3083 {
3084
3085
3086 int nrmon = 0;
3088 {
3089
3091 {
3094 {
3095 F->m[
j] = F->m[
j-1];
3096 }
3098 nrmon++;
3099 }
3100
3101 }
3102 }
3103 }
3104
3109#if SBA_INTERRED_START
3111#endif
3112#if F5DEBUG
3113 printf("SBA COMPUTATIONS DONE IN THE FOLLOWING RING:\n");
3115 printf(
"ordSgn = %d\n",
currRing->OrdSgn);
3116 printf("\n");
3117#endif
3118 int srmax,lrmax, red_result = 1;
3119 int olddeg,reduc;
3120 int hilbeledeg=1,hilbcount=0,minimcnt=0;
3124
3129
3134 reduc = olddeg = lrmax = 0;
3135#ifndef NO_BUCKETS
3138#endif
3139
3140
3141
3142
3143
3144
3146
3147#ifdef HAVE_TAIL_RING
3150#endif
3152 {
3156 }
3157
3159 {
3161 {
3162
3163
3165 strat->
enterS(strat->
L[strat->
Ll-(
i)], strat->
sl+1, strat, strat->
tl);
3166 }
3169 }
3171#ifdef KDEBUG
3172
3173#endif
3174
3175 while (strat->
Ll >= 0)
3176 {
3177 if (strat->
Ll > lrmax) lrmax =strat->
Ll;
3178 #ifdef KDEBUG
3180 #endif
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3202 {
3204#if F5C
3205
3206
3207 f5c ( strat, olddeg, minimcnt, hilbeledeg, hilbcount, srmax,
3208 lrmax, reduc,
Q,
w, hilb );
3209#endif
3210
3212 }
3213
3214
3215
3216
3217
3218 strat->
P = strat->
L[strat->
Ll];
3220
3223
3224 if (!strat->
rewCrit2(strat->
P.sig, ~strat->
P.sevSig, strat->
P.GetLmCurrRing(), strat, strat->
P.checked+1))
3225 {
3226
3227#ifdef DEBUGF5
3228 PrintS(
"SIG OF NEXT PAIR TO HANDLE IN SIG-BASED ALGORITHM\n");
3229 PrintS(
"-------------------------------------------------\n");
3234 PrintS(
"-------------------------------------------------\n");
3235#endif
3237 {
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3250
3251
3254 {
3256
3257
3259 {
3261 break;
3262 }
3263 }
3264
3267
3268 }
3269 else if (strat->
P.p1 ==
NULL)
3270 {
3271 if (strat->
minim > 0)
3273
3276 }
3277 if (strat->
P.p ==
NULL && strat->
P.t_p ==
NULL)
3278 {
3279 red_result = 0;
3280 }
3281 else
3282 {
3283
3284#ifdef DEBUGF5
3285 PrintS(
"Poly before red: ");
3288#endif
3289#if SBA_PRODUCT_CRITERION
3290 if (strat->
P.prod_crit)
3291 {
3292#if SBA_PRINT_PRODUCT_CRITERION
3293 product_criterion++;
3294#endif
3295 int pos =
posInSyz(strat, strat->
P.sig);
3298 red_result = 2;
3299 }
3300 else
3301 {
3302 red_result = strat->
red(&strat->
P,strat);
3303 }
3304#else
3305 red_result = strat->
red(&strat->
P,strat);
3306#endif
3307 }
3308 }
3309 else
3310 {
3311
3312
3313
3314
3315 red_result = 2;
3316 }
3318 {
3320 {
3321 strat->
P.p =
pNeg(strat->
P.p);
3322 strat->
P.sig =
pNeg(strat->
P.sig);
3323 }
3325 if(strat->
P.sig !=
NULL)
3327 if(strat->
P.p !=
NULL)
3329 }
3330
3332 {
3333
3334 red_result =
redRing(&strat->
P,strat);
3335 if(red_result == 0)
3336 {
3339 strat->
P.sig =
NULL;
3340 }
3341 else
3342 {
3343 strat->
enterS(strat->
P, 0, strat, strat->
tl);
3346 break;
3347 }
3348 }
3350 {
3352 break;
3353 }
3354
3356
3357
3358#ifdef DEBUGF5
3359 if (red_result != 0)
3360 {
3361 PrintS(
"Poly after red: ");
3363 pWrite(strat->
P.GetLmCurrRing());
3365 printf("%d\n",red_result);
3366 }
3367#endif
3369 {
3370 if(strat->
P.p !=
NULL)
3372 &olddeg,&reduc,strat, red_result);
3373 else
3375 &olddeg,&reduc,strat, red_result);
3376 }
3377
3379 {
3381 }
3382
3383 if (red_result == 1)
3384 {
3385
3386 strat->
P.GetP(strat->
lmBin);
3387
3388
3389
3390 (strat->
P).FDeg = (strat->
P).pFDeg();
3391
3392
3393
3395
3396
3398
3399
3400
3401
3402 int pos = strat->
sl+1;
3403
3404
3405
3406 poly beforetailred;
3408 beforetailred =
pCopy(strat->
P.sig);
3409#if SBA_TAIL_RED
3411 {
3413 strat->
P.p =
redtailSba(&(strat->
P),pos-1,strat, withT);
3414 }
3415 else
3416 {
3418 {
3420 {
3421 strat->
P.pCleardenom();
3423 {
3424 strat->
P.p =
redtailSba(&(strat->
P),pos-1,strat, withT);
3425 strat->
P.pCleardenom();
3426 }
3427 }
3428 else
3429 {
3432 strat->
P.p =
redtailSba(&(strat->
P),pos-1,strat, withT);
3433 }
3434 }
3435 }
3436
3437
3438
3440 {
3441 strat->
enterS(strat->
P, 0, strat, strat->
tl);
3442 break;
3443 }
3444#endif
3446 {
3447 if(strat->
P.sig ==
NULL ||
pLtCmp(beforetailred,strat->
P.sig) == 1)
3448 {
3450
3451 red_result =
redRing(&strat->
P,strat);
3452 if(red_result == 0)
3453 {
3454
3457 }
3458 else
3459 {
3460 strat->
enterS(strat->
P, 0, strat, strat->
tl);
3461 break;
3462 }
3463 }
3465
3466 if(strat->
P.p ==
NULL)
3467 goto case_when_red_result_changed;
3468 }
3469
3470
3472 {
3473 for (
int jj = 0; jj<strat->
tl+1; jj++)
3474 {
3476 {
3477 strat->
T[jj].is_sigsafe =
FALSE;
3478 }
3479 }
3480 }
3481 else
3482 {
3483 for (
int jj = 0; jj<strat->
tl+1; jj++)
3484 {
3485 strat->
T[jj].is_sigsafe =
FALSE;
3486 }
3487 }
3488#ifdef KDEBUG
3490#endif
3491
3492
3494 {
3495 if (strat->
minim==1)
3496 {
3499 }
3500 else
3501 {
3502 strat->
M->m[minimcnt]=strat->
P.p2;
3504 }
3506 pNext(strat->
M->m[minimcnt])
3510 minimcnt++;
3511 }
3512
3513
3514
3516 strat->
T[strat->
tl].is_sigsafe =
FALSE;
3517
3518
3519
3520
3521
3524 else
3527 break;
3530 strat->
enterS(strat->
P, pos, strat, strat->
tl);
3532 {
3534 for (
int tk=0; tk<strat->
sl+1; tk++)
3535 {
3537 {
3538
3540 break;
3541 }
3542 }
3543
3544 if (overwrite)
3545 {
3551
3555 for(
int ps=0;ps<strat->
sl+1;ps++)
3556 {
3557
3560 {
3563 (strat->
syzmax)*
sizeof(
unsigned long),
3565 *sizeof(unsigned long));
3567 }
3569
3570
3573
3574
3575
3576
3577
3578
3579
3580
3584
3585
3589 }
3590 }
3591 }
3592
3593
3595 {
3597 unsigned max_cmp =
IDELEMS(F);
3601 int pos;
3603
3604
3606 {
3607 for (
int i=0;
i<strat->
sl; ++
i)
3608 {
3614
3617 }
3619 }
3620 else
3621 {
3622
3623
3624 for (
unsigned i=cmp+1;
i<=max_cmp; ++
i)
3625 {
3626 pos = -1;
3627 for (
int j=0;
j<strat->
sl; ++
j)
3628 {
3630 {
3632 break;
3633 }
3634 }
3635 if (pos != -1)
3636 {
3639
3646 {
3648 {
3651 }
3652 }
3653 else
3654 {
3657 }
3658 }
3659 }
3660
3661 }
3662 }
3663
3664#if DEBUGF50
3665 printf("---------------------------\n");
3666 Print(
" %d. ELEMENT ADDED TO GCURR:\n",strat->
sl+1);
3669#endif
3670
3671
3672
3673
3674
3675
3676#if 0
3678 if (pl==1)
3679 {
3680
3681
3682 }
3683 else if (pl==2)
3684 {
3685
3686
3687 }
3688#endif
3689 if (hilb!=
NULL)
khCheck(
Q,
w,hilb,hilbeledeg,hilbcount,strat);
3690
3692 if (strat->
sl>srmax) srmax = strat->
sl;
3693 }
3694 else
3695 {
3696 case_when_red_result_changed:
3697
3698
3699
3700
3701
3702 if (red_result!=2)
3703 {
3704#if SBA_PRINT_ZERO_REDUCTIONS
3705 zeroreductions++;
3706#endif
3708 {
3709
3710 }
3711 else
3712 {
3713 int pos =
posInSyz(strat, strat->
P.sig);
3715
3716 #ifdef DEBUGF5
3717 Print(
"ADDING STUFF TO SYZ : ");
3718
3720 #endif
3721 }
3722 }
3724 {
3726 }
3727 }
3728
3729#ifdef KDEBUG
3731#endif
3733 }
3734 #if 0
3736 printf("\nSigDrop!\n");
3737 else
3738 printf("\nEnded with no SigDrop\n");
3739 #endif
3740
3742 {
3743
3744 if(strat->
P.sig !=
NULL)
3746
3747 #ifdef KDEBUG
3749 #endif
3750 }
3751#ifdef KDEBUG
3753#endif
3754
3756 {
3758 {
3762 {
3765 {
3769 }
3771 }
3772 }
3773 }
3774
3776 {
3779 {
3780
3781
3782
3783#ifdef HAVE_TAIL_RING
3785 {
3791 }
3793#endif
3795 }
3796 }
3798
3799#if SBA_PRINT_SIZE_SYZ
3800
3801 size_syz = strat->
syzl;
3802#endif
3803
3804
3805
3806
3807
3808
3809
3810
3811
3814#if SBA_PRINT_SIZE_G
3816#endif
3819
3822 {
3823
3824
3826 #if 1
3827
3828 for(;
k>=0 && (strat->
L[
k].p1 !=
NULL || strat->
L[
k].p2 !=
NULL);
k--)
3829 {
3830
3832 }
3833 #endif
3834
3835
3836
3837
3838 for(;
k>=0 && strat->
L[
k].p1 ==
NULL && strat->
L[
k].p2 ==
NULL;
k--)
3839 {
3840
3841 strat->
enterS(strat->
L[
k], strat->
sl+1, strat, strat->
tl);
3842
3843 }
3844 }
3845
3846 #if 0
3848 {
3849 for(
k=strat->
sl;
k>=0;
k--)
3850 {
3854 }
3855 }
3856 #endif
3857
3858
3859
3860
3862 {
3873 }
3880
3881#if SBA_PRINT_SIZE_G
3883#endif
3884#ifdef DEBUGF5
3885 printf(
"SIZE OF SHDL: %d\n",
IDELEMS(strat->
Shdl));
3886 int oo = 0;
3888 {
3889 printf(" %d. ",oo+1);
3891 oo++;
3892 }
3893#endif
3894#if SBA_PRINT_ZERO_REDUCTIONS
3895 printf("----------------------------------------------------------\n");
3896 printf("ZERO REDUCTIONS: %ld\n",zeroreductions);
3897 zeroreductions = 0;
3898#endif
3899#if SBA_PRINT_REDUCTION_STEPS
3900 printf("----------------------------------------------------------\n");
3901 printf("S-REDUCTIONS: %ld\n",sba_reduction_steps);
3902#endif
3903#if SBA_PRINT_OPERATIONS
3904 printf("OPERATIONS: %ld\n",sba_operations);
3905#endif
3906#if SBA_PRINT_REDUCTION_STEPS
3907 printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n");
3908 printf("INTERREDUCTIONS: %ld\n",sba_interreduction_steps);
3909#endif
3910#if SBA_PRINT_OPERATIONS
3911 printf("INTERREDUCTION OPERATIONS: %ld\n",sba_interreduction_operations);
3912#endif
3913#if SBA_PRINT_REDUCTION_STEPS
3914 printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n");
3915 printf("ALL REDUCTIONS: %ld\n",sba_reduction_steps+sba_interreduction_steps);
3916 sba_interreduction_steps = 0;
3917 sba_reduction_steps = 0;
3918#endif
3919#if SBA_PRINT_OPERATIONS
3920 printf("ALL OPERATIONS: %ld\n",sba_operations+sba_interreduction_operations);
3921 sba_interreduction_operations = 0;
3922 sba_operations = 0;
3923#endif
3924#if SBA_PRINT_SIZE_G
3925 printf("----------------------------------------------------------\n");
3926 printf("SIZE OF G: %d / %d\n",size_g,size_g_non_red);
3927 size_g = 0;
3928 size_g_non_red = 0;
3929#endif
3930#if SBA_PRINT_SIZE_SYZ
3931 printf("SIZE OF SYZ: %ld\n",size_syz);
3932 printf("----------------------------------------------------------\n");
3933 size_syz = 0;
3934#endif
3935#if SBA_PRINT_PRODUCT_CRITERION
3936 printf("PRODUCT CRITERIA: %ld\n",product_criterion);
3937 product_criterion = 0;
3938#endif
3939 return (strat->
Shdl);
3940}
static void sort(int **points, int sizePoints)
BOOLEAN(* rewCrit2)(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start)
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...
int F1(int a1, int &r1)
F1.