2972{
2973
2974
2975
2976
2977
2978
2979
2980#if SBA_PRINT_ZERO_REDUCTIONS
2981 long zeroreductions = 0;
2982#endif
2983#if SBA_PRINT_PRODUCT_CRITERION
2984 long product_criterion = 0;
2985#endif
2986#if SBA_PRINT_SIZE_G
2987 int size_g = 0;
2988 int size_g_non_red = 0;
2989#endif
2990#if SBA_PRINT_SIZE_SYZ
2991 long size_syz = 0;
2992#endif
2993
2994#if SBA_PRINT_REDUCTION_STEPS
2995 sba_reduction_steps = 0;
2996 sba_interreduction_steps = 0;
2997#endif
2998#if SBA_PRINT_OPERATIONS
2999 sba_operations = 0;
3000 sba_interreduction_operations = 0;
3001#endif
3002
3007 {
3009 if (sRing!=currRingOld)
3010 {
3013 }
3014 }
3015 ideal F;
3016
3017
3018
3020 {
3021 #if 1
3026 {
3027 poly dummy;
3028 dummy =
pCopy(F->m[0]);
3030 F->m[
i] = F->m[
i+1];
3032 }
3033 #else
3035
3037 int pos;
3039 {
3041 {
3044 }
3046 {
3049 }
3050 poly dummy;
3051 dummy =
pCopy(F->m[0]);
3053 F->m[
i] = F->m[
i+1];
3055 }
3056 else
3057 {
3059 {
3062 }
3063 }
3064 #endif
3065
3066 }
3067 else
3068 {
3071 for (
int i=0;
i<
sort->length();++
i)
3074 {
3075
3076
3077 int nrmon = 0;
3079 {
3080
3082 {
3085 {
3086 F->m[
j] = F->m[
j-1];
3087 }
3089 nrmon++;
3090 }
3091
3092 }
3093 }
3094 }
3095
3100#if SBA_INTERRED_START
3102#endif
3103#if F5DEBUG
3104 printf("SBA COMPUTATIONS DONE IN THE FOLLOWING RING:\n");
3106 printf(
"ordSgn = %d\n",
currRing->OrdSgn);
3107 printf("\n");
3108#endif
3109 int srmax,lrmax, red_result = 1;
3110 int olddeg,reduc;
3111 int hilbeledeg=1,hilbcount=0,minimcnt=0;
3115
3120
3125 reduc = olddeg = lrmax = 0;
3126#ifndef NO_BUCKETS
3129#endif
3130
3131
3132
3133
3134
3135
3137
3138#ifdef HAVE_TAIL_RING
3141#endif
3142
3144 {
3146 {
3147
3148
3150 strat->
enterS(&strat->
L[strat->
Ll-(
i)], strat->
sl+1, strat, strat->
tl);
3151 }
3154 }
3156#ifdef KDEBUG
3157
3158#endif
3159
3160 while (strat->
Ll >= 0)
3161 {
3162 if (strat->
Ll > lrmax) lrmax =strat->
Ll;
3163 #ifdef KDEBUG
3165 #endif
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3187 {
3189#if F5C
3190
3191
3192 f5c ( strat, olddeg, minimcnt, hilbeledeg, hilbcount, srmax,
3193 lrmax, reduc,
Q,
w, hilb );
3194#endif
3195
3197 }
3198
3199
3200
3201
3202
3203 strat->
P = strat->
L[strat->
Ll];
3205
3208
3209 if (!strat->
rewCrit2(strat->
P.sig, ~strat->
P.sevSig, strat->
P.GetLmCurrRing(), strat, strat->
P.checked+1))
3210 {
3211
3212#ifdef DEBUGF5
3213 PrintS(
"SIG OF NEXT PAIR TO HANDLE IN SIG-BASED ALGORITHM\n");
3214 PrintS(
"-------------------------------------------------\n");
3219 PrintS(
"-------------------------------------------------\n");
3220#endif
3222 {
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3235
3236
3239 {
3241
3242
3244 {
3246 break;
3247 }
3248 }
3249
3252
3253 }
3254 else if (strat->
P.p1 ==
NULL)
3255 {
3256 if (strat->
minim > 0)
3258
3261 }
3262 if (strat->
P.p ==
NULL && strat->
P.t_p ==
NULL)
3263 {
3264 red_result = 0;
3265 }
3266 else
3267 {
3268
3269#ifdef DEBUGF5
3270 PrintS(
"Poly before red: ");
3273#endif
3274#if SBA_PRODUCT_CRITERION
3275 if (strat->
P.prod_crit)
3276 {
3277#if SBA_PRINT_PRODUCT_CRITERION
3278 product_criterion++;
3279#endif
3280 int pos =
posInSyz(strat, strat->
P.sig);
3283 red_result = 2;
3284 }
3285 else
3286 {
3287 red_result = strat->
red(&strat->
P,strat);
3288 }
3289#else
3290 red_result = strat->
red(&strat->
P,strat);
3291#endif
3292 }
3293 }
3294 else
3295 {
3296
3297
3298
3299
3300 red_result = 2;
3301 }
3303 {
3305 {
3306 strat->
P.p =
pNeg(strat->
P.p);
3307 strat->
P.sig =
pNeg(strat->
P.sig);
3308 }
3310 if(strat->
P.sig !=
NULL)
3312 if(strat->
P.p !=
NULL)
3314 }
3315
3317 {
3318
3319 red_result =
redRing(&strat->
P,strat);
3320 if(red_result == 0)
3321 {
3324 strat->
P.sig =
NULL;
3325 }
3326 else
3327 {
3328 strat->
enterS(&strat->
P, 0, strat, strat->
tl);
3331 break;
3332 }
3333 }
3335 {
3337 break;
3338 }
3339
3341
3342
3343#ifdef DEBUGF5
3344 if (red_result != 0)
3345 {
3346 PrintS(
"Poly after red: ");
3348 pWrite(strat->
P.GetLmCurrRing());
3350 printf("%d\n",red_result);
3351 }
3352#endif
3354 {
3355 if(strat->
P.p !=
NULL)
3357 &olddeg,&reduc,strat, red_result);
3358 else
3360 &olddeg,&reduc,strat, red_result);
3361 }
3362
3364 {
3366 }
3367
3368 if (red_result == 1)
3369 {
3370
3371 strat->
P.GetP(strat->
lmBin);
3372
3373
3374
3375 (strat->
P).FDeg = (strat->
P).pFDeg();
3376
3377
3378
3380
3381
3383
3384
3385
3386
3387 int pos = strat->
sl+1;
3388
3389
3390
3391 poly beforetailred;
3393 beforetailred =
pCopy(strat->
P.sig);
3394#if SBA_TAIL_RED
3396 {
3398 strat->
P.p =
redtailSba(&(strat->
P),pos-1,strat, withT);
3399 }
3400 else
3401 {
3403 {
3405 {
3406 strat->
P.pCleardenom();
3408 {
3409 strat->
P.p =
redtailSba(&(strat->
P),pos-1,strat, withT);
3410 strat->
P.pCleardenom();
3411 }
3412 }
3413 else
3414 {
3417 strat->
P.p =
redtailSba(&(strat->
P),pos-1,strat, withT);
3418 }
3419 }
3420 }
3421
3422
3423
3425 {
3426 strat->
enterS(&strat->
P, 0, strat, strat->
tl);
3427 break;
3428 }
3429#endif
3431 {
3432 if(strat->
P.sig ==
NULL ||
pLtCmp(beforetailred,strat->
P.sig) == 1)
3433 {
3435
3436 red_result =
redRing(&strat->
P,strat);
3437 if(red_result == 0)
3438 {
3439
3442 }
3443 else
3444 {
3445 strat->
enterS(&strat->
P, 0, strat, strat->
tl);
3446 break;
3447 }
3448 }
3450
3451 if(strat->
P.p ==
NULL)
3452 goto case_when_red_result_changed;
3453 }
3454
3455
3457 {
3458 for (
int jj = 0; jj<strat->
tl+1; jj++)
3459 {
3461 {
3462 strat->
T[jj].is_sigsafe =
FALSE;
3463 }
3464 }
3465 }
3466 else
3467 {
3468 for (
int jj = 0; jj<strat->
tl+1; jj++)
3469 {
3470 strat->
T[jj].is_sigsafe =
FALSE;
3471 }
3472 }
3473#ifdef KDEBUG
3475#endif
3476
3477
3479 {
3480 if (strat->
minim==1)
3481 {
3484 }
3485 else
3486 {
3487 strat->
M->m[minimcnt]=strat->
P.p2;
3489 }
3491 pNext(strat->
M->m[minimcnt])
3495 minimcnt++;
3496 }
3497
3498
3499
3501 strat->
T[strat->
tl].is_sigsafe =
FALSE;
3502
3503
3504
3505
3506
3509 else
3512 break;
3515 strat->
enterS(&strat->
P, pos, strat, strat->
tl);
3517 {
3519 for (
int tk=0; tk<strat->
sl+1; tk++)
3520 {
3522 {
3523
3525 break;
3526 }
3527 }
3528
3529 if (overwrite)
3530 {
3536
3540 for(
int ps=0;ps<strat->
sl+1;ps++)
3541 {
3542
3545 {
3548 (strat->
syzmax)*
sizeof(
unsigned long),
3550 *sizeof(unsigned long));
3552 }
3554
3555
3558
3559
3560
3561
3562
3563
3564
3565
3569
3570
3574 }
3575 }
3576 }
3577
3578
3580 {
3582 unsigned max_cmp =
IDELEMS(F);
3586 int pos;
3588
3589
3591 {
3592 for (
int i=0;
i<strat->
sl; ++
i)
3593 {
3599
3602 }
3604 }
3605 else
3606 {
3607
3608
3609 for (
unsigned i=cmp+1;
i<=max_cmp; ++
i)
3610 {
3611 pos = -1;
3612 for (
int j=0;
j<strat->
sl; ++
j)
3613 {
3615 {
3617 break;
3618 }
3619 }
3620 if (pos != -1)
3621 {
3624
3631 {
3633 {
3636 }
3637 }
3638 else
3639 {
3642 }
3643 }
3644 }
3645
3646 }
3647 }
3648
3649#if DEBUGF50
3650 printf("---------------------------\n");
3651 Print(
" %d. ELEMENT ADDED TO GCURR:\n",strat->
sl+1);
3654#endif
3655
3656
3657
3658
3659
3660
3661#if 0
3663 if (pl==1)
3664 {
3665
3666
3667 }
3668 else if (pl==2)
3669 {
3670
3671
3672 }
3673#endif
3674 if (hilb!=
NULL)
khCheck(
Q,
w,hilb,hilbeledeg,hilbcount,strat);
3675
3677 if (strat->
sl>srmax) srmax = strat->
sl;
3678 }
3679 else
3680 {
3681 case_when_red_result_changed:
3682
3683
3684
3685
3686
3687 if (red_result!=2)
3688 {
3689#if SBA_PRINT_ZERO_REDUCTIONS
3690 zeroreductions++;
3691#endif
3693 {
3694
3695 }
3696 else
3697 {
3698 int pos =
posInSyz(strat, strat->
P.sig);
3700
3701 #ifdef DEBUGF5
3702 Print(
"ADDING STUFF TO SYZ : ");
3703
3705 #endif
3706 }
3707 }
3709 {
3711 }
3712 }
3713
3714#ifdef KDEBUG
3716#endif
3718 }
3719 #if 0
3721 printf("\nSigDrop!\n");
3722 else
3723 printf("\nEnded with no SigDrop\n");
3724 #endif
3725
3727 {
3728
3729 if(strat->
P.sig !=
NULL)
3731
3732 #ifdef KDEBUG
3734 #endif
3735 }
3736#ifdef KDEBUG
3738#endif
3739
3741 {
3743 {
3747 {
3750 {
3754 }
3756 }
3757 }
3758 }
3759
3761 {
3764 {
3765
3766
3767
3768#ifdef HAVE_TAIL_RING
3770 {
3776 }
3778#endif
3780 }
3781 }
3783
3784#if SBA_PRINT_SIZE_SYZ
3785
3786 size_syz = strat->
syzl;
3787#endif
3788
3789
3790
3791
3792
3793
3794
3795
3796
3799#if SBA_PRINT_SIZE_G
3801#endif
3804
3807 {
3808
3809
3811 #if 1
3812
3813 for(;
k>=0 && (strat->
L[
k].p1 !=
NULL || strat->
L[
k].p2 !=
NULL);
k--)
3814 {
3815
3817 }
3818 #endif
3819
3820
3821
3822
3823 for(;
k>=0 && strat->
L[
k].p1 ==
NULL && strat->
L[
k].p2 ==
NULL;
k--)
3824 {
3825
3826 strat->
enterS(&strat->
L[
k], strat->
sl+1, strat, strat->
tl);
3827
3828 }
3829 }
3830
3831 #if 0
3833 {
3834 for(
k=strat->
sl;
k>=0;
k--)
3835 {
3839 }
3840 }
3841 #endif
3842
3843
3844
3845
3847 {
3858 }
3865
3866#if SBA_PRINT_SIZE_G
3868#endif
3869#ifdef DEBUGF5
3870 printf(
"SIZE OF SHDL: %d\n",
IDELEMS(strat->
Shdl));
3871 int oo = 0;
3873 {
3874 printf(" %d. ",oo+1);
3876 oo++;
3877 }
3878#endif
3879#if SBA_PRINT_ZERO_REDUCTIONS
3880 printf("----------------------------------------------------------\n");
3881 printf("ZERO REDUCTIONS: %ld\n",zeroreductions);
3882 zeroreductions = 0;
3883#endif
3884#if SBA_PRINT_REDUCTION_STEPS
3885 printf("----------------------------------------------------------\n");
3886 printf("S-REDUCTIONS: %ld\n",sba_reduction_steps);
3887#endif
3888#if SBA_PRINT_OPERATIONS
3889 printf("OPERATIONS: %ld\n",sba_operations);
3890#endif
3891#if SBA_PRINT_REDUCTION_STEPS
3892 printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n");
3893 printf("INTERREDUCTIONS: %ld\n",sba_interreduction_steps);
3894#endif
3895#if SBA_PRINT_OPERATIONS
3896 printf("INTERREDUCTION OPERATIONS: %ld\n",sba_interreduction_operations);
3897#endif
3898#if SBA_PRINT_REDUCTION_STEPS
3899 printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n");
3900 printf("ALL REDUCTIONS: %ld\n",sba_reduction_steps+sba_interreduction_steps);
3901 sba_interreduction_steps = 0;
3902 sba_reduction_steps = 0;
3903#endif
3904#if SBA_PRINT_OPERATIONS
3905 printf("ALL OPERATIONS: %ld\n",sba_operations+sba_interreduction_operations);
3906 sba_interreduction_operations = 0;
3907 sba_operations = 0;
3908#endif
3909#if SBA_PRINT_SIZE_G
3910 printf("----------------------------------------------------------\n");
3911 printf("SIZE OF G: %d / %d\n",size_g,size_g_non_red);
3912 size_g = 0;
3913 size_g_non_red = 0;
3914#endif
3915#if SBA_PRINT_SIZE_SYZ
3916 printf("SIZE OF SYZ: %ld\n",size_syz);
3917 printf("----------------------------------------------------------\n");
3918 size_syz = 0;
3919#endif
3920#if SBA_PRINT_PRODUCT_CRITERION
3921 printf("PRODUCT CRITERIA: %ld\n",product_criterion);
3922 product_criterion = 0;
3923#endif
3924 return (strat->
Shdl);
3925}
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, bigintmat *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.