Changeset 6af701c in git


Ignore:
Timestamp:
May 29, 2019, 5:00:57 PM (5 years ago)
Author:
Christian Eder
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
6e28b0f08c1d092c3f93c44addd2bebe61d206d0
Parents:
90a512bb3f9b999e6009a39bf4c5b00651e6e5c3
Message:
adds coefficient reduction to mora normalform over rings
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/GBEngine/kstd1.cc

    r90a512 r6af701c  
    531531    reddeg = strat->LazyDegree+d;
    532532    h->SetShortExpVector();
    533     /* printf("new reduction\n"); */
    534533    loop
    535534    {
     
    539538        if (strat->T[0].GetpFDeg() == 0 && strat->T[0].length <= 2) {
    540539            j = kFindDivisibleByInT_Z_only_first(strat, h);
    541             /* printf("j %d --> ", j);
    542              * pWrite(pHead(strat->T[j].p)); */
    543540            if (j == 0 && n_DivBy(pGetCoeff(h->p), pGetCoeff(strat->T[j].p), currRing->cf) == FALSE) {
    544                 /* printf("ecart h %d < %d ?\n",h->ecart, strat->T[j].ecart); */
    545541                if (strat->T[j].ecart <= h->ecart) {
    546                     /* printf("ja\n");
    547                      * printf("before: ");
    548                      * pWrite(pHead(h->p)); */
    549542                    /* not(lc(reducer) | lc(poly)) && not(lc(poly) | lc(reducer))
    550543                     * => we try to cut down the lead coefficient at least */
     
    553546                    TObject tj  = strat->T[j];
    554547                    tj.Copy();
    555                     /* tj.max_exp = strat->T[j].max_exp; */
    556548                    /* compute division with remainder of lc(h) and lc(T[j]) */
    557549                    mult = n_QuotRem(pGetCoeff(h->p), pGetCoeff(strat->T[j].p),
     
    564556                    tj.Delete();
    565557                    tj.Clear();
    566                     /* printf("after: ");
    567                      * pWrite(pHead(h->p)); */
    568558                }
    569559            }
    570560        }
    571         /* pWrite(pHead(h->p)); */
    572561        j = kFindDivisibleByInT(strat, h);
    573562        if (j < 0)
    574563        {
    575             /* printf("h goes out as: ");
    576              * pWrite(pHead(h->p)); */
    577 #if 0
    578             if (j >= 0)
    579             {
    580                 printf("ja\n");
    581                 /* not(lc(reducer) | lc(poly)) && not(lc(poly) | lc(reducer))
    582                  * => we try to cut down the lead coefficient at least */
    583                 /* first copy T[j] in order to multiply it with a coefficient later on */
    584                 number mult, rest;
    585                 TObject tj  = strat->T[j];
    586                 tj.Copy();
    587                 /* tj.max_exp = strat->T[j].max_exp; */
    588                 /* compute division with remainder of lc(h) and lc(T[j]) */
    589                 mult = n_QuotRem(pGetCoeff(h->p), pGetCoeff(strat->T[j].p),
    590                         &rest, currRing->cf);
    591                 /* set corresponding new lead coefficient already. we do not
    592                  * remove the lead term in ksReducePolyLC, but only apply
    593                  * a lead coefficient reduction */
    594                 tj.Mult_nn(mult);
    595                 ksReducePolyLC(h, &tj, NULL, &rest, strat);
    596                 tj.Delete();
    597                 tj.Clear();
    598             }
    599 #endif
    600564            // over ZZ: cleanup coefficients by complete reduction with monomials
    601565            postReduceByMon(h, strat);
     
    1007971static poly redMoraNFRing (poly h,kStrategy strat, int flag)
    1008972{
    1009   LObject H;
    1010   H.p = h;
    1011   int j = 0;
    1012   int z = 10;
    1013   int o = H.SetpFDeg();
    1014   H.ecart = currRing->pLDeg(H.p,&H.length,currRing)-o;
    1015   if ((flag & 2) == 0) cancelunit(&H,TRUE);
    1016   H.sev = pGetShortExpVector(H.p);
    1017   unsigned long not_sev = ~ H.sev;
    1018   loop
    1019   {
    1020 #if 0
     973    LObject H;
     974    H.p = h;
     975    int j0, j = 0;
     976    int z = 10;
     977    int o = H.SetpFDeg();
     978    H.ecart = currRing->pLDeg(H.p,&H.length,currRing)-o;
     979    if ((flag & 2) == 0) cancelunit(&H,TRUE);
     980    H.sev = pGetShortExpVector(H.p);
     981    unsigned long not_sev = ~ H.sev;
     982    loop
     983    {
     984#if 1
    1021985        /* cut down the lead coefficients, only possible if the degree of
    1022986         * T[0] is 0 (constant). This is only efficient if T[0] is short, thus
    1023987         * we ask for the length of T[0] to be <= 2 */
    1024988        if (strat->T[0].GetpFDeg() == 0 && strat->T[0].length <= 2) {
    1025             j = kFindDivisibleByInT_Z_only_first(strat, &H);
    1026             /* printf("j %d --> ", j);
    1027              * pWrite(pHead(strat->T[j].p)); */
    1028             if (j == 0 && n_DivBy(pGetCoeff(H.p), pGetCoeff(strat->T[j].p), currRing->cf) == FALSE) {
    1029                 /* printf("ecart h %d < %d ?\n",h->ecart, strat->T[j].ecart); */
    1030                 if (strat->T[j].ecart <= H.ecart) {
    1031                     /* printf("ja\n");
    1032                      * printf("before: ");
    1033                      * pWrite(pHead(h->p)); */
     989            j0 = kFindDivisibleByInT_Z_only_first(strat, &H);
     990            if (j0 == 0 && n_DivBy(pGetCoeff(H.p), pGetCoeff(strat->T[j0].p), currRing->cf) == FALSE) {
     991                if (strat->T[j0].ecart <= H.ecart) {
    1034992                    /* not(lc(reducer) | lc(poly)) && not(lc(poly) | lc(reducer))
    1035993                     * => we try to cut down the lead coefficient at least */
    1036                     /* first copy T[j] in order to multiply it with a coefficient later on */
     994                    /* first copy T[j0] in order to multiply it with a coefficient later on */
    1037995                    number mult, rest;
    1038                     TObject tj  = strat->T[j];
     996                    TObject tj  = strat->T[j0];
    1039997                    tj.Copy();
    1040                     /* tj.max_exp = strat->T[j].max_exp; */
    1041998                    /* compute division with remainder of lc(h) and lc(T[j]) */
    1042                     mult = n_QuotRem(pGetCoeff(H.p), pGetCoeff(strat->T[j].p),
     999                    mult = n_QuotRem(pGetCoeff(H.p), pGetCoeff(strat->T[j0].p),
    10431000                            &rest, currRing->cf);
    10441001                    /* set corresponding new lead coefficient already. we do not
     
    10491006                    tj.Delete();
    10501007                    tj.Clear();
    1051                     /* printf("after: ");
    1052                      * pWrite(pHead(h->p)); */
    10531008                }
    10541009            }
    10551010        }
    1056     j = 0;
    1057 #endif
    1058     if (j > strat->tl)
    1059     {
    1060       return H.p;
    1061     }
    1062     if (TEST_V_DEG_STOP)
    1063     {
    1064       if (kModDeg(H.p)>Kstd1_deg) pLmDelete(&H.p);
    1065       if (H.p==NULL) return NULL;
    1066     }
    1067     if (p_LmShortDivisibleBy(strat->T[j].GetLmTailRing(), strat->sevT[j], H.GetLmTailRing(), not_sev, strat->tailRing)
    1068         && (n_DivBy(H.p->coef, strat->T[j].p->coef,strat->tailRing->cf))
    1069         )
    1070     {
    1071       /*- remember the found T-poly -*/
    1072       // poly pi = strat->T[j].p;
    1073       int ei = strat->T[j].ecart;
    1074       int li = strat->T[j].length;
    1075       int ii = j;
    1076       /*
    1077       * the polynomial to reduce with (up to the moment) is;
    1078       * pi with ecart ei and length li
    1079       */
    1080       loop
    1081       {
    1082         /*- look for a better one with respect to ecart -*/
    1083         /*- stop, if the ecart is small enough (<=ecart(H)) -*/
    1084         j++;
    1085         if (j > strat->tl) break;
    1086         if (ei <= H.ecart) break;
    1087         if (((strat->T[j].ecart < ei)
    1088           || ((strat->T[j].ecart == ei)
    1089         && (strat->T[j].length < li)))
    1090         && pLmShortDivisibleBy(strat->T[j].p,strat->sevT[j], H.p, not_sev)
    1091         && (n_DivBy(H.p->coef, strat->T[j].p->coef,strat->tailRing->cf))
    1092         )
    1093         {
    1094           /*
    1095           * the polynomial to reduce with is now;
    1096           */
    1097           // pi = strat->T[j].p;
    1098           ei = strat->T[j].ecart;
    1099           li = strat->T[j].length;
    1100           ii = j;
    1101         }
    1102       }
    1103       /*
    1104       * end of search: have to reduce with pi
    1105       */
    1106       z++;
    1107       if (z>10)
    1108       {
    1109         pNormalize(H.p);
    1110         z=0;
    1111       }
    1112       if ((ei > H.ecart) && (!strat->kHEdgeFound))
    1113       {
    1114         /*
    1115         * It is not possible to reduce h with smaller ecart;
    1116         * we have to reduce with bad ecart: H has to enter in T
    1117         */
    1118         doRed(&H,&(strat->T[ii]),TRUE,strat,TRUE);
    1119         if (H.p == NULL)
    1120           return NULL;
    1121       }
    1122       else
    1123       {
    1124         /*
    1125         * we reduce with good ecart, h need not to be put to T
    1126         */
    1127         doRed(&H,&(strat->T[ii]),FALSE,strat,TRUE);
    1128         if (H.p == NULL)
    1129           return NULL;
    1130       }
    1131       /*- try to reduce the s-polynomial -*/
    1132       o = H.SetpFDeg();
    1133       if ((flag &2 ) == 0) cancelunit(&H,TRUE);
    1134       H.ecart = currRing->pLDeg(H.p,&(H.length),currRing)-o;
    1135       j = 0;
    1136       H.sev = pGetShortExpVector(H.p);
    1137       not_sev = ~ H.sev;
    1138     }
    1139     else
    1140     {
    1141       j++;
    1142     }
    1143   }
     1011#endif
     1012        if (j > strat->tl)
     1013        {
     1014            return H.p;
     1015        }
     1016        if (TEST_V_DEG_STOP)
     1017        {
     1018            if (kModDeg(H.p)>Kstd1_deg) pLmDelete(&H.p);
     1019            if (H.p==NULL) return NULL;
     1020        }
     1021        if (p_LmShortDivisibleBy(strat->T[j].GetLmTailRing(), strat->sevT[j], H.GetLmTailRing(), not_sev, strat->tailRing)
     1022                && (n_DivBy(H.p->coef, strat->T[j].p->coef,strat->tailRing->cf))
     1023           )
     1024        {
     1025            /*- remember the found T-poly -*/
     1026            // poly pi = strat->T[j].p;
     1027            int ei = strat->T[j].ecart;
     1028            int li = strat->T[j].length;
     1029            int ii = j;
     1030            /*
     1031             * the polynomial to reduce with (up to the moment) is;
     1032             * pi with ecart ei and length li
     1033             */
     1034            loop
     1035            {
     1036                /*- look for a better one with respect to ecart -*/
     1037                /*- stop, if the ecart is small enough (<=ecart(H)) -*/
     1038                j++;
     1039                if (j > strat->tl) break;
     1040                if (ei <= H.ecart) break;
     1041                if (((strat->T[j].ecart < ei)
     1042                            || ((strat->T[j].ecart == ei)
     1043                                && (strat->T[j].length < li)))
     1044                        && pLmShortDivisibleBy(strat->T[j].p,strat->sevT[j], H.p, not_sev)
     1045                        && (n_DivBy(H.p->coef, strat->T[j].p->coef,strat->tailRing->cf))
     1046                   )
     1047                {
     1048                    /*
     1049                     * the polynomial to reduce with is now;
     1050                     */
     1051                    // pi = strat->T[j].p;
     1052                    ei = strat->T[j].ecart;
     1053                    li = strat->T[j].length;
     1054                    ii = j;
     1055                }
     1056            }
     1057            /*
     1058             * end of search: have to reduce with pi
     1059             */
     1060            z++;
     1061            if (z>10)
     1062            {
     1063                pNormalize(H.p);
     1064                z=0;
     1065            }
     1066            if ((ei > H.ecart) && (!strat->kHEdgeFound))
     1067            {
     1068                /*
     1069                 * It is not possible to reduce h with smaller ecart;
     1070                 * we have to reduce with bad ecart: H has to enter in T
     1071                 */
     1072                doRed(&H,&(strat->T[ii]),TRUE,strat,TRUE);
     1073                if (H.p == NULL)
     1074                    return NULL;
     1075            }
     1076            else
     1077            {
     1078                /*
     1079                 * we reduce with good ecart, h need not to be put to T
     1080                 */
     1081                doRed(&H,&(strat->T[ii]),FALSE,strat,TRUE);
     1082                if (H.p == NULL)
     1083                    return NULL;
     1084            }
     1085            /*- try to reduce the s-polynomial -*/
     1086            o = H.SetpFDeg();
     1087            if ((flag &2 ) == 0) cancelunit(&H,TRUE);
     1088            H.ecart = currRing->pLDeg(H.p,&(H.length),currRing)-o;
     1089            j = 0;
     1090            H.sev = pGetShortExpVector(H.p);
     1091            not_sev = ~ H.sev;
     1092        }
     1093        else
     1094        {
     1095            j++;
     1096        }
     1097    }
    11441098}
    11451099#endif
Note: See TracChangeset for help on using the changeset viewer.