2743{
2744
2745
2746
2747
2748
2749
2750
2751#if SBA_PRINT_ZERO_REDUCTIONS
2752 long zeroreductions = 0;
2753#endif
2754#if SBA_PRINT_PRODUCT_CRITERION
2755 long product_criterion = 0;
2756#endif
2757#if SBA_PRINT_SIZE_G
2758 int size_g = 0;
2759 int size_g_non_red = 0;
2760#endif
2761#if SBA_PRINT_SIZE_SYZ
2762 long size_syz = 0;
2763#endif
2764
2765#if SBA_PRINT_REDUCTION_STEPS
2766 sba_reduction_steps = 0;
2767 sba_interreduction_steps = 0;
2768#endif
2769#if SBA_PRINT_OPERATIONS
2770 sba_operations = 0;
2771 sba_interreduction_operations = 0;
2772#endif
2773
2774 ideal F1 = F0;
2775 ring sRing, currRingOld;
2778 {
2780 if (sRing!=currRingOld)
2781 {
2784 }
2785 }
2786 ideal F;
2787
2788
2789
2791 {
2792 #if 1
2797 {
2798 poly dummy;
2799 dummy =
pCopy(F->m[0]);
2801 F->m[
i] = F->m[
i+1];
2803 }
2804 #else
2806
2807 F->m[0] = F1->m[0];
2808 int pos;
2810 {
2812 {
2815 }
2817 {
2820 }
2821 poly dummy;
2822 dummy =
pCopy(F->m[0]);
2824 F->m[
i] = F->m[
i+1];
2826 }
2827 else
2828 {
2830 {
2833 }
2834 }
2835 #endif
2836
2837 }
2838 else
2839 {
2842 for (
int i=0;
i<
sort->length();++
i)
2843 F->m[
i] = F1->m[(*
sort)[
i]-1];
2845 {
2846
2847
2848 int nrmon = 0;
2850 {
2851
2853 {
2856 {
2857 F->m[
j] = F->m[
j-1];
2858 }
2860 nrmon++;
2861 }
2862
2863 }
2864 }
2865 }
2866
2871#if SBA_INTERRED_START
2873#endif
2874#if F5DEBUG
2875 printf("SBA COMPUTATIONS DONE IN THE FOLLOWING RING:\n");
2877 printf(
"ordSgn = %d\n",
currRing->OrdSgn);
2878 printf("\n");
2879#endif
2880 int srmax,lrmax, red_result = 1;
2881 int olddeg,reduc;
2882 int hilbeledeg=1,hilbcount=0,minimcnt=0;
2886
2891
2896 reduc = olddeg = lrmax = 0;
2897#ifndef NO_BUCKETS
2900#endif
2901
2902
2903
2904
2905
2906
2908
2909#ifdef HAVE_TAIL_RING
2912#endif
2914 {
2918 }
2919
2921 {
2923 {
2924
2925
2927 strat->
enterS(strat->
L[strat->
Ll-(
i)], strat->
sl+1, strat, strat->
tl);
2928 }
2931 }
2933#ifdef KDEBUG
2934
2935#endif
2936
2937 while (strat->
Ll >= 0)
2938 {
2939 if (strat->
Ll > lrmax) lrmax =strat->
Ll;
2940 #ifdef KDEBUG
2942 #endif
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2964 {
2966#if F5C
2967
2968
2969 f5c ( strat, olddeg, minimcnt, hilbeledeg, hilbcount, srmax,
2970 lrmax, reduc,
Q,
w, hilb );
2971#endif
2972
2974 }
2975
2976
2977
2978
2979
2980 strat->
P = strat->
L[strat->
Ll];
2982
2985
2986 if (!strat->
rewCrit2(strat->
P.sig, ~strat->
P.sevSig, strat->
P.GetLmCurrRing(), strat, strat->
P.checked+1))
2987 {
2988
2989#ifdef DEBUGF5
2990 PrintS(
"SIG OF NEXT PAIR TO HANDLE IN SIG-BASED ALGORITHM\n");
2991 PrintS(
"-------------------------------------------------\n");
2996 PrintS(
"-------------------------------------------------\n");
2997#endif
2999 {
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3012
3013
3016 {
3018
3019
3021 {
3023 break;
3024 }
3025 }
3026
3029
3030 }
3031 else if (strat->
P.p1 ==
NULL)
3032 {
3033 if (strat->
minim > 0)
3035
3038 }
3039 if (strat->
P.p ==
NULL && strat->
P.t_p ==
NULL)
3040 {
3041 red_result = 0;
3042 }
3043 else
3044 {
3045
3046#ifdef DEBUGF5
3047 PrintS(
"Poly before red: ");
3050#endif
3051#if SBA_PRODUCT_CRITERION
3052 if (strat->
P.prod_crit)
3053 {
3054#if SBA_PRINT_PRODUCT_CRITERION
3055 product_criterion++;
3056#endif
3057 int pos =
posInSyz(strat, strat->
P.sig);
3060 red_result = 2;
3061 }
3062 else
3063 {
3064 red_result = strat->
red(&strat->
P,strat);
3065 }
3066#else
3067 red_result = strat->
red(&strat->
P,strat);
3068#endif
3069 }
3070 }
3071 else
3072 {
3073
3074
3075
3076
3077 red_result = 2;
3078 }
3080 {
3082 {
3083 strat->
P.p =
pNeg(strat->
P.p);
3084 strat->
P.sig =
pNeg(strat->
P.sig);
3085 }
3087 if(strat->
P.sig !=
NULL)
3089 if(strat->
P.p !=
NULL)
3091 }
3092
3094 {
3095
3096 red_result =
redRing(&strat->
P,strat);
3097 if(red_result == 0)
3098 {
3101 strat->
P.sig =
NULL;
3102 }
3103 else
3104 {
3105 strat->
enterS(strat->
P, 0, strat, strat->
tl);
3108 break;
3109 }
3110 }
3112 {
3114 break;
3115 }
3116
3118
3119
3120#ifdef DEBUGF5
3121 if (red_result != 0)
3122 {
3123 PrintS(
"Poly after red: ");
3125 pWrite(strat->
P.GetLmCurrRing());
3127 printf("%d\n",red_result);
3128 }
3129#endif
3131 {
3132 if(strat->
P.p !=
NULL)
3134 &olddeg,&reduc,strat, red_result);
3135 else
3137 &olddeg,&reduc,strat, red_result);
3138 }
3139
3141 {
3143 }
3144
3145 if (red_result == 1)
3146 {
3147
3148 strat->
P.GetP(strat->
lmBin);
3149
3150
3151
3152 (strat->
P).FDeg = (strat->
P).pFDeg();
3153
3154
3155
3157
3158
3160
3161
3162
3163
3164 int pos = strat->
sl+1;
3165
3166
3167
3168 #ifdef HAVE_RINGS
3169 poly beforetailred;
3171 beforetailred =
pCopy(strat->
P.sig);
3172 #endif
3173#if SBA_TAIL_RED
3175 {
3177 strat->
P.p =
redtailSba(&(strat->
P),pos-1,strat, withT);
3178 }
3179 else
3180 {
3182 {
3184 {
3185 strat->
P.pCleardenom();
3187 {
3188 strat->
P.p =
redtailSba(&(strat->
P),pos-1,strat, withT);
3189 strat->
P.pCleardenom();
3190 }
3191 }
3192 else
3193 {
3196 strat->
P.p =
redtailSba(&(strat->
P),pos-1,strat, withT);
3197 }
3198 }
3199 }
3200
3201
3202
3204 {
3205 strat->
enterS(strat->
P, 0, strat, strat->
tl);
3206 break;
3207 }
3208#endif
3210 {
3211 if(strat->
P.sig ==
NULL ||
pLtCmp(beforetailred,strat->
P.sig) == 1)
3212 {
3214
3215 red_result =
redRing(&strat->
P,strat);
3216 if(red_result == 0)
3217 {
3218
3221 }
3222 else
3223 {
3224 strat->
enterS(strat->
P, 0, strat, strat->
tl);
3225 break;
3226 }
3227 }
3229
3230 if(strat->
P.p ==
NULL)
3231 goto case_when_red_result_changed;
3232 }
3233
3234
3236 {
3237 for (
int jj = 0; jj<strat->
tl+1; jj++)
3238 {
3240 {
3241 strat->
T[jj].is_sigsafe =
FALSE;
3242 }
3243 }
3244 }
3245 else
3246 {
3247 for (
int jj = 0; jj<strat->
tl+1; jj++)
3248 {
3249 strat->
T[jj].is_sigsafe =
FALSE;
3250 }
3251 }
3252#ifdef KDEBUG
3254#endif
3255
3256
3258 {
3259 if (strat->
minim==1)
3260 {
3263 }
3264 else
3265 {
3266 strat->
M->m[minimcnt]=strat->
P.p2;
3268 }
3270 pNext(strat->
M->m[minimcnt])
3274 minimcnt++;
3275 }
3276
3277
3278
3280 strat->
T[strat->
tl].is_sigsafe =
FALSE;
3281
3282
3283
3284
3285
3288 else
3291 break;
3294 strat->
enterS(strat->
P, pos, strat, strat->
tl);
3296 {
3298 for (
int tk=0; tk<strat->
sl+1; tk++)
3299 {
3301 {
3302
3304 break;
3305 }
3306 }
3307
3308 if (overwrite)
3309 {
3315
3319 for(
int ps=0;ps<strat->
sl+1;ps++)
3320 {
3321
3324 {
3327 (strat->
syzmax)*
sizeof(
unsigned long),
3329 *sizeof(unsigned long));
3331 }
3333
3334
3337
3338
3339
3340
3341
3342
3343
3344
3348
3349
3353 }
3354 }
3355 }
3356
3357
3359 {
3361 unsigned max_cmp =
IDELEMS(F);
3365 int pos;
3367
3368
3370 {
3371 for (
int i=0;
i<strat->
sl; ++
i)
3372 {
3378
3381 }
3383 }
3384 else
3385 {
3386
3387
3388 for (
unsigned i=cmp+1;
i<=max_cmp; ++
i)
3389 {
3390 pos = -1;
3391 for (
int j=0;
j<strat->
sl; ++
j)
3392 {
3394 {
3396 break;
3397 }
3398 }
3399 if (pos != -1)
3400 {
3403
3410 {
3412 {
3415 }
3416 }
3417 else
3418 {
3421 }
3422 }
3423 }
3424
3425 }
3426 }
3427
3428#if DEBUGF50
3429 printf("---------------------------\n");
3430 Print(
" %d. ELEMENT ADDED TO GCURR:\n",strat->
sl+1);
3433#endif
3434
3435
3436
3437
3438
3439
3440#if 0
3442 if (pl==1)
3443 {
3444
3445
3446 }
3447 else if (pl==2)
3448 {
3449
3450
3451 }
3452#endif
3453 if (hilb!=
NULL)
khCheck(
Q,
w,hilb,hilbeledeg,hilbcount,strat);
3454
3456 if (strat->
sl>srmax) srmax = strat->
sl;
3457 }
3458 else
3459 {
3460 case_when_red_result_changed:
3461
3462
3463
3464
3465
3466 if (red_result!=2)
3467 {
3468#if SBA_PRINT_ZERO_REDUCTIONS
3469 zeroreductions++;
3470#endif
3472 {
3473
3474 }
3475 else
3476 {
3477 int pos =
posInSyz(strat, strat->
P.sig);
3479
3480 #ifdef DEBUGF5
3481 Print(
"ADDING STUFF TO SYZ : ");
3482
3484 #endif
3485 }
3486 }
3488 {
3490 }
3491 }
3492
3493#ifdef KDEBUG
3494 memset(&(strat->
P), 0,
sizeof(strat->
P));
3495#endif
3497 }
3498 #if 0
3500 printf("\nSigDrop!\n");
3501 else
3502 printf("\nEnded with no SigDrop\n");
3503 #endif
3504
3506 {
3507
3508 if(strat->
P.sig !=
NULL)
3510
3511 #ifdef KDEBUG
3512 memset(&(strat->
P), 0,
sizeof(strat->
P));
3513 #endif
3514 }
3515#ifdef KDEBUG
3517#endif
3518
3520 {
3522 {
3525 while(k<=strat->sl)
3526 {
3529 {
3533 }
3535 }
3536 }
3537 }
3538
3540 {
3543 {
3544
3545
3546
3547#ifdef HAVE_TAIL_RING
3549 {
3555 }
3557#endif
3559 }
3560 }
3562
3563#if SBA_PRINT_SIZE_SYZ
3564
3565 size_syz = strat->
syzl;
3566#endif
3567
3568
3569
3570
3571
3572
3573
3574
3575
3578#if SBA_PRINT_SIZE_G
3580#endif
3583
3584 #ifdef HAVE_RINGS
3587 {
3588
3589
3591 #if 1
3592
3593 for(;
k>=0 && (strat->
L[
k].p1 !=
NULL || strat->
L[
k].p2 !=
NULL);
k--)
3594 {
3595
3597 }
3598 #endif
3599
3600
3601
3602
3603 for(;
k>=0 && strat->
L[
k].p1 ==
NULL && strat->
L[
k].p2 ==
NULL;
k--)
3604 {
3605
3606 strat->
enterS(strat->
L[
k], strat->
sl+1, strat, strat->
tl);
3607
3608 }
3609 }
3610
3611 #if 0
3613 {
3614 for(
k=strat->
sl;
k>=0;
k--)
3615 {
3619 }
3620 }
3621 #endif
3622 #endif
3623
3624
3625
3626
3628 {
3639 }
3646
3647#if SBA_PRINT_SIZE_G
3649#endif
3650#ifdef DEBUGF5
3651 printf(
"SIZE OF SHDL: %d\n",
IDELEMS(strat->
Shdl));
3652 int oo = 0;
3654 {
3655 printf(" %d. ",oo+1);
3657 oo++;
3658 }
3659#endif
3660#if SBA_PRINT_ZERO_REDUCTIONS
3661 printf("----------------------------------------------------------\n");
3662 printf("ZERO REDUCTIONS: %ld\n",zeroreductions);
3663 zeroreductions = 0;
3664#endif
3665#if SBA_PRINT_REDUCTION_STEPS
3666 printf("----------------------------------------------------------\n");
3667 printf("S-REDUCTIONS: %ld\n",sba_reduction_steps);
3668#endif
3669#if SBA_PRINT_OPERATIONS
3670 printf("OPERATIONS: %ld\n",sba_operations);
3671#endif
3672#if SBA_PRINT_REDUCTION_STEPS
3673 printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n");
3674 printf("INTERREDUCTIONS: %ld\n",sba_interreduction_steps);
3675#endif
3676#if SBA_PRINT_OPERATIONS
3677 printf("INTERREDUCTION OPERATIONS: %ld\n",sba_interreduction_operations);
3678#endif
3679#if SBA_PRINT_REDUCTION_STEPS
3680 printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n");
3681 printf("ALL REDUCTIONS: %ld\n",sba_reduction_steps+sba_interreduction_steps);
3682 sba_interreduction_steps = 0;
3683 sba_reduction_steps = 0;
3684#endif
3685#if SBA_PRINT_OPERATIONS
3686 printf("ALL OPERATIONS: %ld\n",sba_operations+sba_interreduction_operations);
3687 sba_interreduction_operations = 0;
3688 sba_operations = 0;
3689#endif
3690#if SBA_PRINT_SIZE_G
3691 printf("----------------------------------------------------------\n");
3692 printf("SIZE OF G: %d / %d\n",size_g,size_g_non_red);
3693 size_g = 0;
3694 size_g_non_red = 0;
3695#endif
3696#if SBA_PRINT_SIZE_SYZ
3697 printf("SIZE OF SYZ: %ld\n",size_syz);
3698 printf("----------------------------------------------------------\n");
3699 size_syz = 0;
3700#endif
3701#if SBA_PRINT_PRODUCT_CRITERION
3702 printf("PRODUCT CRITERIA: %ld\n",product_criterion);
3703 product_criterion = 0;
3704#endif
3705 return (strat->
Shdl);
3706}
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, 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...