3002{
3003
3004
3005
3006
3007
3008
3009
3010#if SBA_PRINT_ZERO_REDUCTIONS
3011 long zeroreductions = 0;
3012#endif
3013#if SBA_PRINT_PRODUCT_CRITERION
3014 long product_criterion = 0;
3015#endif
3016#if SBA_PRINT_SIZE_G
3017 int size_g = 0;
3018 int size_g_non_red = 0;
3019#endif
3020#if SBA_PRINT_SIZE_SYZ
3021 long size_syz = 0;
3022#endif
3023
3024#if SBA_PRINT_REDUCTION_STEPS
3025 sba_reduction_steps = 0;
3026 sba_interreduction_steps = 0;
3027#endif
3028#if SBA_PRINT_OPERATIONS
3029 sba_operations = 0;
3030 sba_interreduction_operations = 0;
3031#endif
3032
3034 ring sRing, currRingOld;
3037 {
3039 if (sRing!=currRingOld)
3040 {
3043 }
3044 }
3045 ideal F;
3046
3047
3048
3050 {
3051 #if 1
3056 {
3057 poly dummy;
3058 dummy =
pCopy(F->m[0]);
3060 F->m[
i] = F->m[
i+1];
3062 }
3063 #else
3065
3067 int pos;
3069 {
3071 {
3074 }
3076 {
3079 }
3080 poly dummy;
3081 dummy =
pCopy(F->m[0]);
3083 F->m[
i] = F->m[
i+1];
3085 }
3086 else
3087 {
3089 {
3092 }
3093 }
3094 #endif
3095
3096 }
3097 else
3098 {
3101 for (
int i=0;
i<
sort->length();++
i)
3104 {
3105
3106
3107 int nrmon = 0;
3109 {
3110
3112 {
3115 {
3116 F->m[
j] = F->m[
j-1];
3117 }
3119 nrmon++;
3120 }
3121
3122 }
3123 }
3124 }
3125
3130#if SBA_INTERRED_START
3132#endif
3133#if F5DEBUG
3134 printf("SBA COMPUTATIONS DONE IN THE FOLLOWING RING:\n");
3136 printf(
"ordSgn = %d\n",
currRing->OrdSgn);
3137 printf("\n");
3138#endif
3139 int srmax,lrmax, red_result = 1;
3140 int olddeg,reduc;
3141 int hilbeledeg=1,hilbcount=0,minimcnt=0;
3145
3150
3155 reduc = olddeg = lrmax = 0;
3156#ifndef NO_BUCKETS
3159#endif
3160
3161
3162
3163
3164
3165
3167
3168#ifdef HAVE_TAIL_RING
3171#endif
3173 {
3177 }
3178
3180 {
3182 {
3183
3184
3186 strat->
enterS(strat->
L[strat->
Ll-(
i)], strat->
sl+1, strat, strat->
tl);
3187 }
3190 }
3192#ifdef KDEBUG
3193
3194#endif
3195
3196 while (strat->
Ll >= 0)
3197 {
3198 if (strat->
Ll > lrmax) lrmax =strat->
Ll;
3199 #ifdef KDEBUG
3201 #endif
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3223 {
3225#if F5C
3226
3227
3228 f5c ( strat, olddeg, minimcnt, hilbeledeg, hilbcount, srmax,
3229 lrmax, reduc,
Q,
w, hilb );
3230#endif
3231
3233 }
3234
3235
3236
3237
3238
3239 strat->
P = strat->
L[strat->
Ll];
3241
3244
3245 if (!strat->
rewCrit2(strat->
P.sig, ~strat->
P.sevSig, strat->
P.GetLmCurrRing(), strat, strat->
P.checked+1))
3246 {
3247
3248#ifdef DEBUGF5
3249 PrintS(
"SIG OF NEXT PAIR TO HANDLE IN SIG-BASED ALGORITHM\n");
3250 PrintS(
"-------------------------------------------------\n");
3255 PrintS(
"-------------------------------------------------\n");
3256#endif
3258 {
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3271
3272
3275 {
3277
3278
3280 {
3282 break;
3283 }
3284 }
3285
3288
3289 }
3290 else if (strat->
P.p1 ==
NULL)
3291 {
3292 if (strat->
minim > 0)
3294
3297 }
3298 if (strat->
P.p ==
NULL && strat->
P.t_p ==
NULL)
3299 {
3300 red_result = 0;
3301 }
3302 else
3303 {
3304
3305#ifdef DEBUGF5
3306 PrintS(
"Poly before red: ");
3309#endif
3310#if SBA_PRODUCT_CRITERION
3311 if (strat->
P.prod_crit)
3312 {
3313#if SBA_PRINT_PRODUCT_CRITERION
3314 product_criterion++;
3315#endif
3316 int pos =
posInSyz(strat, strat->
P.sig);
3319 red_result = 2;
3320 }
3321 else
3322 {
3323 red_result = strat->
red(&strat->
P,strat);
3324 }
3325#else
3326 red_result = strat->
red(&strat->
P,strat);
3327#endif
3328 }
3329 }
3330 else
3331 {
3332
3333
3334
3335
3336 red_result = 2;
3337 }
3339 {
3341 {
3342 strat->
P.p =
pNeg(strat->
P.p);
3343 strat->
P.sig =
pNeg(strat->
P.sig);
3344 }
3346 if(strat->
P.sig !=
NULL)
3348 if(strat->
P.p !=
NULL)
3350 }
3351
3353 {
3354
3355 red_result =
redRing(&strat->
P,strat);
3356 if(red_result == 0)
3357 {
3360 strat->
P.sig =
NULL;
3361 }
3362 else
3363 {
3364 strat->
enterS(strat->
P, 0, strat, strat->
tl);
3367 break;
3368 }
3369 }
3371 {
3373 break;
3374 }
3375
3377
3378
3379#ifdef DEBUGF5
3380 if (red_result != 0)
3381 {
3382 PrintS(
"Poly after red: ");
3384 pWrite(strat->
P.GetLmCurrRing());
3386 printf("%d\n",red_result);
3387 }
3388#endif
3390 {
3391 if(strat->
P.p !=
NULL)
3393 &olddeg,&reduc,strat, red_result);
3394 else
3396 &olddeg,&reduc,strat, red_result);
3397 }
3398
3400 {
3402 }
3403
3404 if (red_result == 1)
3405 {
3406
3407 strat->
P.GetP(strat->
lmBin);
3408
3409
3410
3411 (strat->
P).FDeg = (strat->
P).pFDeg();
3412
3413
3414
3416
3417
3419
3420
3421
3422
3423 int pos = strat->
sl+1;
3424
3425
3426
3427 #ifdef HAVE_RINGS
3428 poly beforetailred;
3430 beforetailred =
pCopy(strat->
P.sig);
3431 #endif
3432#if SBA_TAIL_RED
3434 {
3436 strat->
P.p =
redtailSba(&(strat->
P),pos-1,strat, withT);
3437 }
3438 else
3439 {
3441 {
3443 {
3444 strat->
P.pCleardenom();
3446 {
3447 strat->
P.p =
redtailSba(&(strat->
P),pos-1,strat, withT);
3448 strat->
P.pCleardenom();
3449 }
3450 }
3451 else
3452 {
3455 strat->
P.p =
redtailSba(&(strat->
P),pos-1,strat, withT);
3456 }
3457 }
3458 }
3459
3460
3461
3463 {
3464 strat->
enterS(strat->
P, 0, strat, strat->
tl);
3465 break;
3466 }
3467#endif
3469 {
3470 if(strat->
P.sig ==
NULL ||
pLtCmp(beforetailred,strat->
P.sig) == 1)
3471 {
3473
3474 red_result =
redRing(&strat->
P,strat);
3475 if(red_result == 0)
3476 {
3477
3480 }
3481 else
3482 {
3483 strat->
enterS(strat->
P, 0, strat, strat->
tl);
3484 break;
3485 }
3486 }
3488
3489 if(strat->
P.p ==
NULL)
3490 goto case_when_red_result_changed;
3491 }
3492
3493
3495 {
3496 for (
int jj = 0; jj<strat->
tl+1; jj++)
3497 {
3499 {
3500 strat->
T[jj].is_sigsafe =
FALSE;
3501 }
3502 }
3503 }
3504 else
3505 {
3506 for (
int jj = 0; jj<strat->
tl+1; jj++)
3507 {
3508 strat->
T[jj].is_sigsafe =
FALSE;
3509 }
3510 }
3511#ifdef KDEBUG
3513#endif
3514
3515
3517 {
3518 if (strat->
minim==1)
3519 {
3522 }
3523 else
3524 {
3525 strat->
M->m[minimcnt]=strat->
P.p2;
3527 }
3529 pNext(strat->
M->m[minimcnt])
3533 minimcnt++;
3534 }
3535
3536
3537
3539 strat->
T[strat->
tl].is_sigsafe =
FALSE;
3540
3541
3542
3543
3544
3547 else
3550 break;
3553 strat->
enterS(strat->
P, pos, strat, strat->
tl);
3555 {
3557 for (
int tk=0; tk<strat->
sl+1; tk++)
3558 {
3560 {
3561
3563 break;
3564 }
3565 }
3566
3567 if (overwrite)
3568 {
3574
3578 for(
int ps=0;ps<strat->
sl+1;ps++)
3579 {
3580
3583 {
3586 (strat->
syzmax)*
sizeof(
unsigned long),
3588 *sizeof(unsigned long));
3590 }
3592
3593
3596
3597
3598
3599
3600
3601
3602
3603
3607
3608
3612 }
3613 }
3614 }
3615
3616
3618 {
3620 unsigned max_cmp =
IDELEMS(F);
3624 int pos;
3626
3627
3629 {
3630 for (
int i=0;
i<strat->
sl; ++
i)
3631 {
3637
3640 }
3642 }
3643 else
3644 {
3645
3646
3647 for (
unsigned i=cmp+1;
i<=max_cmp; ++
i)
3648 {
3649 pos = -1;
3650 for (
int j=0;
j<strat->
sl; ++
j)
3651 {
3653 {
3655 break;
3656 }
3657 }
3658 if (pos != -1)
3659 {
3662
3669 {
3671 {
3674 }
3675 }
3676 else
3677 {
3680 }
3681 }
3682 }
3683
3684 }
3685 }
3686
3687#if DEBUGF50
3688 printf("---------------------------\n");
3689 Print(
" %d. ELEMENT ADDED TO GCURR:\n",strat->
sl+1);
3692#endif
3693
3694
3695
3696
3697
3698
3699#if 0
3701 if (pl==1)
3702 {
3703
3704
3705 }
3706 else if (pl==2)
3707 {
3708
3709
3710 }
3711#endif
3712 if (hilb!=
NULL)
khCheck(
Q,
w,hilb,hilbeledeg,hilbcount,strat);
3713
3715 if (strat->
sl>srmax) srmax = strat->
sl;
3716 }
3717 else
3718 {
3719 case_when_red_result_changed:
3720
3721
3722
3723
3724
3725 if (red_result!=2)
3726 {
3727#if SBA_PRINT_ZERO_REDUCTIONS
3728 zeroreductions++;
3729#endif
3731 {
3732
3733 }
3734 else
3735 {
3736 int pos =
posInSyz(strat, strat->
P.sig);
3738
3739 #ifdef DEBUGF5
3740 Print(
"ADDING STUFF TO SYZ : ");
3741
3743 #endif
3744 }
3745 }
3747 {
3749 }
3750 }
3751
3752#ifdef KDEBUG
3753 memset(&(strat->
P), 0,
sizeof(strat->
P));
3754#endif
3756 }
3757 #if 0
3759 printf("\nSigDrop!\n");
3760 else
3761 printf("\nEnded with no SigDrop\n");
3762 #endif
3763
3765 {
3766
3767 if(strat->
P.sig !=
NULL)
3769
3770 #ifdef KDEBUG
3771 memset(&(strat->
P), 0,
sizeof(strat->
P));
3772 #endif
3773 }
3774#ifdef KDEBUG
3776#endif
3777
3779 {
3781 {
3784 while(k<=strat->sl)
3785 {
3788 {
3792 }
3794 }
3795 }
3796 }
3797
3799 {
3802 {
3803
3804
3805
3806#ifdef HAVE_TAIL_RING
3808 {
3814 }
3816#endif
3818 }
3819 }
3821
3822#if SBA_PRINT_SIZE_SYZ
3823
3824 size_syz = strat->
syzl;
3825#endif
3826
3827
3828
3829
3830
3831
3832
3833
3834
3837#if SBA_PRINT_SIZE_G
3839#endif
3842
3843 #ifdef HAVE_RINGS
3846 {
3847
3848
3850 #if 1
3851
3852 for(;
k>=0 && (strat->
L[
k].p1 !=
NULL || strat->
L[
k].p2 !=
NULL);
k--)
3853 {
3854
3856 }
3857 #endif
3858
3859
3860
3861
3862 for(;
k>=0 && strat->
L[
k].p1 ==
NULL && strat->
L[
k].p2 ==
NULL;
k--)
3863 {
3864
3865 strat->
enterS(strat->
L[
k], strat->
sl+1, strat, strat->
tl);
3866
3867 }
3868 }
3869
3870 #if 0
3872 {
3873 for(
k=strat->
sl;
k>=0;
k--)
3874 {
3878 }
3879 }
3880 #endif
3881 #endif
3882
3883
3884
3885
3887 {
3898 }
3905
3906#if SBA_PRINT_SIZE_G
3908#endif
3909#ifdef DEBUGF5
3910 printf(
"SIZE OF SHDL: %d\n",
IDELEMS(strat->
Shdl));
3911 int oo = 0;
3913 {
3914 printf(" %d. ",oo+1);
3916 oo++;
3917 }
3918#endif
3919#if SBA_PRINT_ZERO_REDUCTIONS
3920 printf("----------------------------------------------------------\n");
3921 printf("ZERO REDUCTIONS: %ld\n",zeroreductions);
3922 zeroreductions = 0;
3923#endif
3924#if SBA_PRINT_REDUCTION_STEPS
3925 printf("----------------------------------------------------------\n");
3926 printf("S-REDUCTIONS: %ld\n",sba_reduction_steps);
3927#endif
3928#if SBA_PRINT_OPERATIONS
3929 printf("OPERATIONS: %ld\n",sba_operations);
3930#endif
3931#if SBA_PRINT_REDUCTION_STEPS
3932 printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n");
3933 printf("INTERREDUCTIONS: %ld\n",sba_interreduction_steps);
3934#endif
3935#if SBA_PRINT_OPERATIONS
3936 printf("INTERREDUCTION OPERATIONS: %ld\n",sba_interreduction_operations);
3937#endif
3938#if SBA_PRINT_REDUCTION_STEPS
3939 printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n");
3940 printf("ALL REDUCTIONS: %ld\n",sba_reduction_steps+sba_interreduction_steps);
3941 sba_interreduction_steps = 0;
3942 sba_reduction_steps = 0;
3943#endif
3944#if SBA_PRINT_OPERATIONS
3945 printf("ALL OPERATIONS: %ld\n",sba_operations+sba_interreduction_operations);
3946 sba_interreduction_operations = 0;
3947 sba_operations = 0;
3948#endif
3949#if SBA_PRINT_SIZE_G
3950 printf("----------------------------------------------------------\n");
3951 printf("SIZE OF G: %d / %d\n",size_g,size_g_non_red);
3952 size_g = 0;
3953 size_g_non_red = 0;
3954#endif
3955#if SBA_PRINT_SIZE_SYZ
3956 printf("SIZE OF SYZ: %ld\n",size_syz);
3957 printf("----------------------------------------------------------\n");
3958 size_syz = 0;
3959#endif
3960#if SBA_PRINT_PRODUCT_CRITERION
3961 printf("PRODUCT CRITERIA: %ld\n",product_criterion);
3962 product_criterion = 0;
3963#endif
3964 return (strat->
Shdl);
3965}
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, 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.