Changeset ae99c8 in git


Ignore:
Timestamp:
Jun 3, 2016, 3:35:33 PM (8 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
52a8a94bdb5c861b9dfc195e1caeac28976f4cb6
Parents:
c7afbd34f1aae46fbf47925ff2246e5f42f4ca08f5430b3a3eb5a73492e701be4b7eb64eb8d10513
Message:
Merge pull request #770 from tigistdereje/ffmodstd

chg: update ffmodstd.lib
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/ffmodstd.lib

    rc7afbd3 rae99c8  
    11///////////////////////////////////////////////////////////////////////////////
    2 version="version poly.lib 4.0.3.0 Mar_2016 "; // $Id$
     2version="version ffmodstd.lib 4.0.3.0 May_2016"; // $Id$
    33category="Commutative Algebra";
    44info="
     
    2020  b:=(b_1,...,b_m) (usually the b_i's are distinct primes), so that K is an ideal in
    2121  Q(z)[X]. For such a rational point b, we compute a Groebner basis G_b of K using
    22   modular algorithms [1] and univariate rational interpolation[2,7]. The
    23   procedure is repeated for many rational points b until their is sufficiently large
    24   to recover the correct coeffcients in Q(T). Once we have these points, we obtain a
    25   set of polynomials G by applying the sparse multivariate rational interpolation
     22  modular algorithms [1] and univariate rational interpolation [2,7]. The
     23  procedure is repeated for many rational points b until their number is sufficiently
     24  large to recover the correct coeffcients in Q(T). Once we have these points, we
     25  obtain a set of polynomials G by applying the sparse multivariate rational interpolation
    2626  algorithm from [4] coefficient-wise to the list of Groebner bases G_b in Q(z)[X],
    2727  where this algorithm makes use of the following algorithms: univariate polynomial
     
    209209static proc NewtonInterpolationNormal(list d, list e,int vr)
    210210{
    211     /*  compute a polynomial from given numerical data
    212      *  size of d and e must be equal
     211    /* compute a polynomial from given numerical data
     212     * size of d and e must be equal
    213213     * d is list of distinct elements
    214214     * number of points here are sufficiently large
     
    300300static proc choose_a_prime(int p)
    301301{
    302     int i;
     302    // p must be a prime number and the procedure returns the next prime
     303    if(p==2){return(3);}
     304    int i=p;
    303305    while(1)
    304306    {
    305         i++;
    306         if((p+i)%2 !=0)
    307         {
    308             if(prime(p+i)==p+i)
    309             {
    310                 return(p+i);
    311                 break;
    312             }
     307        i = i+2;
     308        if(prime(i)==i)
     309        {
     310            return(i);
    313311        }
    314312    }
     
    319317static proc list_of_primes(int pa, list #)
    320318{
    321     // find distinct pa prime(s)
     319    // find distinct pa prime(s) up to permutations
    322320    int p=3;
    323321    int j,k;
     
    529527        }
    530528    }
    531     return(list(0,B));
    532529}
    533530
     
    622619{   "EXAMPLE:"; echo = 2;
    623620    ring rr=0,(x,y),dp;
    624     list lpr = 2,3; // assign 2 for y and 3 for z
     621    list lpr = 2,3; // assign 2 for x and 3 for y
    625622    list La = 150,3204,79272,2245968,70411680, 2352815424, 81496927872;
    626623    // La[i] = number(subst(f,y,lpr[1]^i,z,lpr[2]^i)); for f = x2y2+2x2y+5xy2 and i=1,...,7
    627624    poly Br = BerlekampMassey(La,1)[1];
    628625    Br;
    629     sparseInterpolation(Br,La,lpr,0,1); // reconstruct f
    630     sparseInterpolation(Br,La,lpr,0); // default
     626    sparseInterpolation(Br,La,lpr,0); // reconstruct f default
    631627    La = 97,275,793,2315,6817;
    632628    // La[i] = number(subst(g,y,lpr[1]^i,z,lpr[2]^i)); for g = x+y and i=4,...,8
     
    664660    poly r1,r2,r3,t1,t2,q_m,r_m,t_m,q1;
    665661    q_m = 1;
    666 
    667662    if(g==0)
    668663    {
    669664        return(list(poly(0),poly(1)));
    670665    }
    671 
    672666    if(2*deg(g)<deg(f))
    673667    {
     668        // the degree of f is large enough
    674669        return(list(g,poly(1)));
    675670    }
     
    680675    t2=h;
    681676    list ls,l1,l,T;
    682 
    683677    int i=0;
    684 
     678    // a modified while loop in the Extended Euclidean algorithm
    685679    while(r2!=0)
    686680    {
     
    688682        ls=division(r1,r2);
    689683        r3=r2;
    690         q1=ls[1][1,1];
     684        q1=ls[1][1,1]; // quotient
    691685        h=number(1)/lu(ls[2][1]);
    692         r2=ls[2][1]*h;
     686        r2=ls[2][1]*h; // remainder times h
    693687        r1=r3;
    694688        r3=t2;
    695689        t2=(t1-q1*t2)*h;
    696690        t1=r3;
    697 
     691        /***** find a quotient q_m whose degree is maximal and polynomials r_m & t_m
     692        correspond to q_m *********************************************************/
    698693        if( deg(q1) > deg(q_m))
    699694        {
     
    717712            if(normalize_constant_term)
    718713            {
     714                // here we normalize only for internal use
    719715                number ut=number(1)/lu(t_m[size(t_m)]);
    720716                return(list(ut*r_m,ut*t_m));
     
    727723            if(normalize_constant_term)
    728724            {
     725                // here we normalize only for internal use
    729726                number ut=number(1)/lu(t_m[size(t_m)]);
    730727                return(list(ut*r_m,ut*t_m));
     
    811808///////////////////////////////////////////////////////////////////////////////
    812809
    813 static proc expandf_wrt_vaRnvaRkplusShift(poly f,list shft,int n)
     810static proc evaluate_f_at_given_points(poly f,list shft,int n)
    814811{
    815812    // evaluate f at var(n+k) = bigint(shft[k])**j for each j
     
    925922    list m2 = list(list(poly(-7/6),21/2y+1));
    926923    list L = list(l1,l2),list(m1,m2);
    927     L;
    928924    Add_the_list_farey(L);
    929925}
     
    933929static proc Add_list_of_list(list l1,list l2, int m)
    934930{
     931    // the procedure returns a list containing list of polynomials w.r.t. m
    935932    list lst,lyt,Yt,lm;
    936 
    937933    if(size(l1)!=size(l2))
    938934    {
     
    953949    return(l1);
    954950}
    955 
     951example
     952{
     953    "EXAMPLE:"; echo = 2;
     954    ring rr=0,y,dp;
     955    list l2,m2;
     956    l2[1] = list(list(-2y-5/6,y+1));
     957    m2[1] = list(list(-4y-5/6,y-5));
     958    l2[2] = list(list(-2y-5/6,2y+3));
     959    m2[2] = list(list(-4y-5/6,3y-7));
     960    Add_list_of_list(l2,m2,1);
     961}
    956962///////////////////////////////////////////////////////////////////////////////
    957963
    958964static proc Add_two_lists(list l1, list l2)
    959965{
     966    // the procedure returns a list containing list of polynomials
    960967    int im=size(l1);
    961968    int k,i;
     
    986993    l2[2] = list(list(-2y-5/6,poly(1)));
    987994    m2[2] = list(list(-4y-5/6,poly(1)));
    988     list L = l2,m2;
    989     L;
    990     Add_the_list_farey(L);
    991995    Add_two_lists(l2[2],m2[2]);
    992996}
     
    10141018{   "EXAMPLE:"; echo = 2;
    10151019    ring rr=0,y,dp;
    1016     list l1,l2,l3,l4;
    1017     l1 = 1,2,3;
    1018     l2 = 1,4,9;
    1019     l3 = 1,8,27;
    1020     l4 = 1,16,81;
     1020    list l1 = 1,2,3;
     1021    list l2 = 1,4,9;
     1022    list l3 = 1,8,27;
     1023    list l4 = 1,16,81;
    10211024    list L = l1,l2,l3,l4;
    1022     L;
    10231025    arrange_list_first(L);
    10241026}
     
    10541056static proc arrangeListofIdeals(list L, list #)
    10551057{
     1058    /* the procedure returns list of coeffcients in the given list of ideals. The
     1059     * coeffcients are correspond to polynomials whose leading monomials are the same.
     1060     * Moreover, if optional parameter # is given, then it also returns a list
     1061     * of monomials in one of these ideals
     1062    */
    10561063    ideal Tr = L[1];
    10571064    L = arrange_list_first(L);
     
    10891096    return(Ld);
    10901097}
    1091 
    1092 ///////////////////////////////////////////////////////////////////////////////
    1093 // return list(Jc, us) if us is a good point
     1098example
     1099{
     1100    "EXAMPLE:"; echo = 2;
     1101    ring rr=(0,a),y,dp;
     1102    ideal I1 = y2+(3a2+6a+5)/(a+2)*y+1, y-6a;
     1103    ideal I2 = y2+(3a2+5a+7)/(a+4)*y+1, 7y-17a;
     1104    list L = I1,I2;
     1105    arrangeListofIdeals(L);
     1106    arrangeListofIdeals(L,1);
     1107}
     1108
     1109///////////////////////////////////////////////////////////////////////////////
    10941110
    10951111static proc Add_the_shift_and_evaluate_new(ideal J,list pr, list shft, int i)
    10961112{
    1097     // n number of variables
     1113    // evaluate J at a given point
    10981114    int k;
    10991115    number Nm;
     
    11081124}
    11091125
    1110 // =============== a procedure for one parameter ends here ==========
    1111 
    11121126///////////////////////////////////////////////////////////////////////////////
    11131127
     
    11151129    int fn, string Command, list JL,list #)
    11161130{
     1131    // generate a set of ideals whose coefficients are univariate rational functions
    11171132    def Gt = basering;
    11181133    int i,i1;
     
    11311146    list optL = imap(Gt,JL);
    11321147    list T;
     1148    int tmp;
    11331149    int c_z = size(L);
    11341150    for(i1=1;i1<=c_z;i1++)
     
    11361152        if(Command == "slimgb")
    11371153        {
    1138             task t(i1) = "slimgb", list(L[i1]);
     1154            task tk(i1) = "slimgb", list(L[i1]);
    11391155        }
    11401156        else
    11411157        {
    1142             task t(i1) = "Ffmodstd::ffmodStdOne",list(L[i1],list(optL,1));
    1143         }
    1144     }
    1145     startTasks(t(1..c_z));
    1146     waitAllTasks(t(1..c_z));
     1158            task tk(i1) = "Ffmodstd::ffmodStdOne",list(L[i1],list(optL,1));
     1159        }
     1160    }
     1161    startTasks(tk(1..c_z));
     1162    waitAllTasks(tk(1..c_z));
    11471163    for(i1 = 1;i1 <= c_z; i1++)
    11481164    {
    1149         T[i1] = getResult(t(i1));
    1150         killTask(t(i1));
    1151         kill t(i1);
     1165        T[i1] = getResult(tk(i1));
     1166        killTask(tk(i1));
     1167        kill tk(i1);
    11521168    }
    11531169    if(tp)
     
    11661182static proc normalize_LiftofIdeal(list L)
    11671183{
     1184    // normalize each ideal L[j]
    11681185    for(int j=1;j<=size(L);j++)
    11691186    {
     
    11771194static proc normalize_constTerm(poly g, poly f)
    11781195{
     1196    /* Assumption: f has a non-zero constant. Then the procedure
     1197    returns a pair (g/N, f/N) where N is the constant term of f */
    11791198    number N = leadcoef(f[size(f)]);
    11801199    g = g/N;
     
    11871206static proc normalize_constTermAll(list M2, int kk)
    11881207{
     1208    /*
     1209      Assumption: each polynomial in the list has a non-zero constant term. Then
     1210      the procedure normalize_constTermAll normalizes the constatnt term of
     1211      each polynomial in this list starting from M2[kk] where kk is a
     1212      positive integer less than or equal to the size of M2
     1213    */
    11891214    int i,j,k;
    11901215    list l,l1,l2,l3,l4;
     
    12161241///////////////////////////////////////////////////////////////////////////////
    12171242
    1218 static proc stdoverFF(ideal I, list pr, list shft, string Command,list Zr, list JL)
    1219 {
    1220     // return std of I with high probability
     1243static proc stdoverFF(ideal I, list pr, list shft,string Command,list Zr, list JL)
     1244{
     1245    // return std of I with high probability using sparse rational interpolation
    12211246    int fn=13;
    12221247    def R_1=basering;
     
    12361261    setring R_1;
    12371262    int in = 2;
     1263    // with respect to given bounds, generate univariate rational functions
    12381264    list M2 = generate_uniRationalFunctions(I, pr, shft, in,fn, Command,JL[1],JL[2]);
    12391265    M2 = arrangeListofIdeals(M2);
     
    12441270    list M2 = imap(R_1,M2);
    12451271    M2 = normalize_constTermAll(M2,1); // starts from 1
    1246     list Zr = imap(R_1, Zr);
     1272    list Zr = imap(R_1, Zr); // list of monomials in the std of I
    12471273    int u_w,i1,i2,i3;
    12481274    poly Gn,pn,pl,plm;
     
    12581284            Gn = Zr[u_w][1];
    12591285            setring R_2;
     1286            /******** start lifting elements from Q to Q(var(1),.., var(pa)) *****/
    12601287            l1 = M2[u_w];
    12611288            for(i1=1;i1<=size(l1);i1++)
     
    12631290                for(i2=1;i2<=2;i2++)
    12641291                {
     1292                    // the procedure first lifts the numerator and then the denominator
    12651293                    for(i3=1;i3<=size(l1[i1][i2][1]);i3++)
    12661294                    {
    12671295                        l3 = return_coef_indx(l1[i1][i2],i3);
    12681296                        l3 = l3,lk1;
    1269                         l3 = SubList(l3);
     1297                        l3 = SubList(l3); // adjust the coefficients
     1298                        // early termination for BerlekampMassey algorithm(BMA)
    12701299                        bp = BerlekampMassey(l3,n);
    12711300                        if(size(bp)==2)
    12721301                        {
     1302                            // at this step BerlekampMassey algorithm terminated early
    12731303                            if(bp[1]==1)
    12741304                            {
     
    12801310                                pn = sparseInterpolation(bp[1],l3,pr,n);
    12811311                                pl = pn+pl;
    1282                                 lup = expandf_wrt_vaRnvaRkplusShift(pn, shft, n);
     1312                                lup = evaluate_f_at_given_points(pn, shft, n);
    12831313                                lup = lup,lk3;
    12841314                            }
     
    12861316                        else
    12871317                        {
     1318                            /* elements in the sequence l3[i] are not large enough.
     1319                             * We thus add more elements to l3 and continue with the
     1320                             * early termination strategy until size(bp)=2 where bp[2]
     1321                             * is the length of the sequence that the early temination
     1322                             * of BMA requires
     1323                             */
    12881324                            l3n = bp[6];
    12891325                            while(1)
     
    12921328                                fn = 2*in;
    12931329                                setring R_1;
     1330                                /* add more points to l3 by generating rational
     1331                                functions*/
    12941332                                uM1 = generate_uniRationalFunctions(I, pr, shft, in,
    12951333                                                                    fn, Command,JL[1]);
     
    13121350                                if(size(bp)==2)
    13131351                                {
     1352                                    // at this step BerlekampMassey algorithm terminated early
    13141353                                    l3n = l3n[1..bp[2]];
    13151354                                    pn = sparseInterpolation(bp[1],l3n,pr,n);
    13161355                                    pl = pn+pl;
    1317                                     lup = expandf_wrt_vaRnvaRkplusShift(pn,shft,n);
     1356                                    lup = evaluate_f_at_given_points(pn,shft,n);
    13181357                                    lup = lup,lk3;
    13191358                                    break;
     
    13241363                        if(i3 < size(l1[i1][i2][1]))
    13251364                        {
     1365                            // unshift the shifted parameters see also SubList
    13261366                            lk3 = Add_poly_list(lup);
    13271367                            plm = lk3[1];
     
    13381378                setring R_1;
    13391379                list H = imap(R_2,py);
     1380                // numerator H[1] & denominator H[2] are recovered for each i1=1,2,...
    13401381                Gn = Gn + (H[1]/H[2])*Zr[u_w][i1+1];
    13411382                kill H;
     
    13581399}
    13591400
     1401
    13601402///////////////////////////////////////////////////////////////////////////////
    13611403// +++++++++++++++++ std for one parameter begins here +++++++++++++++++++
     
    13751417///////////////////////////////////////////////////////////////////////////////
    13761418
    1377 static proc ChooseprimeIdealsIAnd_ImodgJ(ideal gJ, ideal I,int n1,int nt,
    1378                                      int i_s)
     1419static proc  choose_evaluation_points(ideal I, ideal cI,int n1,int nt, int i_s)
    13791420{
    13801421    /*
    1381      * gJ is given ideal
    1382      * f is linear polynomial with leadcoef 1
    1383      * I is an output from Testlist_all
    1384      * n is number of variables
     1422     * I is given ideal
     1423     * cI is an output from Testlist_all
     1424     * n1 is number of variables
    13851425     * nt number of prime ideals
    13861426     * i_s is an integer
     
    13981438        }
    13991439        f=var(n1)-i_s;
    1400         if(test_fmodI(f,I)==1)
     1440        if(test_fmodI(f,cI)==1)
    14011441        {
    14021442            j=j+1;
    1403             n=n+list(subst(gJ,var(n1),i_s));
     1443            // specialize var(n1) with i_s
     1444            n=n+list(subst(I,var(n1),i_s));
    14041445            m[j]=i_s;
    14051446        }
     
    14091450            n=n,m;
    14101451            return(n);
    1411             break;
    1412         }
    1413     }
    1414 }
    1415 
    1416 ///////////////////////////////////////////////////////////////////////////////
    1417 
    1418 static proc firststdmodp(ideal I,ideal cI, int in_value)
    1419 {
    1420     /* return a list of univariate rational functions, where each function is the
    1421      coefficient for each of monomials appear in the output ideal */
     1452        }
     1453    }
     1454}
     1455
     1456///////////////////////////////////////////////////////////////////////////////
     1457
     1458static proc firststdmodp(ideal I,ideal cI,int in_value)
     1459{
     1460    /* return std FJ of I together with the coefficients, as a list of univariate
     1461    rational functions, of FJ */
    14221462    def St=basering;
     1463    // define a new ring
    14231464    int nx=nvars(St);
    14241465    int nr=nx-1;
     
    14421483    int i,k1,k2;
    14431484    list T,T1,L1,L2,L3,m_l;
    1444     int r_d = char(basering)-10000000;
    1445     list l_1 = ChooseprimeIdealsIAnd_ImodgJ(I,cI, nx,in_value,r_d);
     1485    int r_d = char(basering)-10000000; // choose an integer r_d which is d/t from
     1486    // char(basering)
     1487    list l_1 =  choose_evaluation_points(I,cI, nx,in_value,r_d);
    14461488    list lus = l_1[2];
    14471489    l_1 = l_1[1];
    1448     m_l[1] = normalize(std(l_1[1]));
     1490    m_l[1] = std(l_1[1]);
    14491491    if(size(m_l[1])==1 and deg(m_l[1][1])==0)
    14501492    {
    14511493        return(list(ideal(1)));
    14521494    }
    1453 
     1495    // compute std in parallel w.r.t. distinct r_d
    14541496    for(k1 = 2; k1<= in_value; k1++)
    14551497    {
    1456         task t(k1-1) = "std", list(l_1[k1]);
    1457     }
    1458     startTasks(t(1..in_value-1));
    1459     waitAllTasks(t(1..in_value-1));
     1498        task tk(k1-1) = "std", list(l_1[k1]);
     1499    }
     1500    startTasks(tk(1..in_value-1));
     1501    waitAllTasks(tk(1..in_value-1));
    14601502    for(k1 = 1;k1<=in_value-1;k1++)
    14611503    {
    1462         m_l = m_l + list(getResult(t(k1)));
    1463         killTask(t(k1));
    1464         kill t(k1);
     1504        m_l = m_l + list(getResult(tk(k1)));
     1505        killTask(tk(k1));
     1506        kill tk(k1);
    14651507    }
    14661508    r_d = lus[in_value]-1;
    1467 
    14681509    // DeleteUnluckyEvaluationPoints
    1469 
    1470     list indices = delete_unlucky_primes(m_l);
     1510    list indices = Modstd::deleteUnluckyPrimes_std(m_l);
    14711511    for(i = size(indices); i > 0; i--)
    14721512    {
     
    14741514        lus = delete(lus, indices[i]);
    14751515    }
     1516    m_l = normalize_LiftofIdeal(m_l);
    14761517    in_value = size(lus);
    14771518    int ug;
    1478 
    14791519    for(int cZ =1;cZ<=ncols(m_l[1]);cZ++)
    14801520    {
     
    14891529        return(list(m_l[1]));
    14901530    }
     1531    // dense univariate rational interpolation
    14911532    list lev = list_coef_index(m_l,ug,2,in_value-1);
    14921533    list L = polyInterpolation(list(lus[1..in_value-1]),lev,nx);
     
    15281569                }
    15291570                T1 = fareypolyEarlyTermination(I,cI,M,nx,lus,lev, k1, k2, r_d,#);
     1571                // save maximum number of data m_x that are used in each lifting
    15301572                if(m_x < T1[3][2]){ m_x = T1[3][2];}
    15311573                L1[k2-1] = T1[3];
     
    15331575                setring Gt;
    15341576                list Fr = imap(St,Fr);
     1577                // add the coeffcients to g_t which are already lifted
    15351578                g_t = g_t + (Fr[1]/Fr[2])*Zr[k1][k2];
    15361579                kill Fr;
     
    15851628    /* the early termination version of the farey rational funtion map for
    15861629    polynomials */
    1587 
    15881630    ideal Id;
    15891631    list Tr,fr,L,l_1,m_l;
     
    15951637    if(size(#)==1)
    15961638    {
     1639        // dense univariate rational interpolation
    15971640        sz = size(lus);
    15981641        L = polyInterpolation(list(lus[1..sz-1]),list(lev[1..sz-1]),#);
     
    16061649    else
    16071650    {
    1608         // update
     1651        // update by adding more evaluation points
    16091652        NR = #[1];
    16101653        DR = #[2];
     
    16171660    while(fr[1]!=NR or fr[2]!=DR)
    16181661    {
    1619         l_1 = ChooseprimeIdealsIAnd_ImodgJ(I, cI, nx, in_value, us);
     1662        l_1 =  choose_evaluation_points(I, cI, nx, in_value, us);
    16201663        lus = l_1[2];
    16211664        l_1 = l_1[1];
     1665        // compute std in parallel w.r.t. lus
    16221666        for(k11 = 1; k11 <= in_value; k11++)
    16231667        {
    1624             task t(k11) = "std", list(l_1[k11]);
    1625         }
    1626         startTasks(t(1..in_value));
    1627         waitAllTasks(t(1..in_value));
     1668            task tk(k11) = "std", list(l_1[k11]);
     1669        }
     1670        startTasks(tk(1..in_value));
     1671        waitAllTasks(tk(1..in_value));
    16281672        for(k11 = 1;k11<=in_value;k11++)
    16291673        {
    1630             m_l[k11] = getResult(t(k11));
    1631             killTask(t(k11));
    1632             kill t(k11);
     1674            m_l[k11] = getResult(tk(k11));
     1675            killTask(tk(k11));
     1676            kill tk(k11);
    16331677        }
    16341678        us = lus[size(lus)]-1;
    16351679        // DeleteUnluckyEvaluationPoints
    1636         indices = delete_unlucky_primes(m_l);
     1680        indices = Modstd::deleteUnluckyPrimes_std(m_l);
    16371681        for(i = size(indices); i > 0; i--)
    16381682        {
     
    16411685        }
    16421686        sz = size(m_l);
     1687        m_l = normalize_LiftofIdeal(m_l);
    16431688        lev = list_coef_index(m_l,k1,k2,sz);
    16441689        # = L;
     1690        // dense univariate rational interpolation
    16451691        L = polyInterpolation(list(lus[1..sz-1]),list(lev[1..sz-1]),nx,#);
    16461692        fr = fareypoly(L[1],L[2]);
     
    16661712///////////////////////////////////////////////////////////////////////////////
    16671713
    1668 static proc RecoverCoeffsForAFixedData(list stdResults, list distElmnt,
    1669          list maxData, list Zr)
     1714static proc  RecoverCoeffsForAFixedData(list stdResults,list distElmnt,list maxData,
     1715                                       list Zr)
    16701716{
    16711717    /* here a bound on the number of interpolation points is known and, hence,
     
    16741720     * of std over F_p*/
    16751721    def St=basering;
     1722    // define a new ring
    16761723    int nx=nvars(St);
    16771724    int nr=nx-1;
     
    17261773        if(n_z>1)
    17271774        {
     1775            // dense univariate rational interpolation in parallel
    17281776            list TL = interpolation_farey_lift_parallel(maxData, M, distElmnt, n_z,
    17291777                                                       nx, k1);
     
    17491797///////////////////////////////////////////////////////////////////////////////
    17501798
    1751 static proc interpolation_farey_lift_parallel(list maxData, list M, list distElmnt, int m_sz,
    1752        int nx, int k1)
    1753 {
    1754     // return list of uni.rational functions
     1799static proc interpolation_farey_lift_parallel(list maxData, list M, list distElmnt,
     1800                                              int m_sz,int nx, int k1)
     1801{
     1802    // return list of univariate rational functions
    17551803    list L;
    17561804    int k2;
    17571805    for(k2=2;k2<=m_sz;k2++)
    17581806    {
    1759        task t(k2) = "Ffmodstd::lift_interp_farey", list(maxData, M, distElmnt,
     1807       task tk(k2) = "Ffmodstd::lift_interp_farey", list(maxData, M, distElmnt,
    17601808       nx, k1, k2);
    17611809    }
    1762     startTasks(t(2..m_sz));
    1763     waitAllTasks(t(2..m_sz));
     1810    startTasks(tk(2..m_sz));
     1811    waitAllTasks(tk(2..m_sz));
    17641812    for(k2 = 2;k2 <= m_sz; k2++)
    17651813    {
    1766          L[k2] = getResult(t(k2));
    1767          killTask(t(k2));
    1768          kill t(k2);
     1814         L[k2] = getResult(tk(k2));
     1815         killTask(tk(k2));
     1816         kill tk(k2);
    17691817    }
    17701818    return(L);
     
    18061854    if(2*deg(g)<deg(f))
    18071855    {
     1856        // here the degree of f is large enough
    18081857        return(list(g,poly(1)));
    18091858    }
     
    18151864    list ls,l1,l,T;
    18161865    int i=0;
     1866    // a modified while loop in the Extended Euclidean algorithm
    18171867    while(r2!=0)
    18181868    {
     
    18501900    list m_l,l_1,R_d, indices,G,Fd;
    18511901    int k11,v_r,i;
    1852     int r_d = char(basering)-10000000;
     1902    int r_d = char(basering)-10000000; // choose an integer r_d d/f from char(basering)
    18531903    while(size(G) < ma_x)
    18541904    {
    1855         l_1 = ChooseprimeIdealsIAnd_ImodgJ(I, cI,nva,ma_x,r_d);
     1905        l_1 =  choose_evaluation_points(I, cI,nva,ma_x,r_d);
    18561906        R_d = l_1[2];
    18571907        l_1 = l_1[1];
     1908        // compute std in parallel
    18581909        for(k11 = 1; k11 <= ma_x; k11++)
    18591910        {
    1860             task t(k11) = "std", list(l_1[k11]);
    1861         }
    1862         startTasks(t(1..ma_x));
    1863         waitAllTasks(t(1..ma_x));
     1911            task tk(k11) = "std", list(l_1[k11]);
     1912        }
     1913        startTasks(tk(1..ma_x));
     1914        waitAllTasks(tk(1..ma_x));
    18641915        for(k11 = 1;k11 <= ma_x; k11++)
    18651916        {
    1866             m_l[k11] = getResult(t(k11));
    1867             killTask(t(k11));
    1868             kill t(k11);
    1869         }
    1870         indices = delete_unlucky_primes(m_l);
     1917            m_l[k11] = getResult(tk(k11));
     1918            killTask(tk(k11));
     1919            kill tk(k11);
     1920        }
     1921        indices = Modstd::deleteUnluckyPrimes_std(m_l);
    18711922        r_d = R_d[size(R_d)]-1;
    18721923        for(i = size(indices); i > 0; i--)
     
    18751926            R_d = delete(R_d, indices[i]);
    18761927        }
     1928        m_l = normalize_LiftofIdeal(m_l);
    18771929        G = G + m_l;
    18781930        Fd = Fd + R_d;
    18791931    }
    18801932    return(list(G,Fd));
    1881 }
    1882 
    1883 /////////////// copied from modstd.lib /////////////////////////////////
    1884 
    1885 static proc delete_unlucky_primes(list modresults)
    1886 {
    1887     int size_modresults = size(modresults);
    1888     // the command delete_unlucky_primes is the same as delete_unlucky_evaluation points
    1889     /* sort results into categories.
    1890      * each category is represented by three entries:
    1891      * - the corresponding leading ideal
    1892      * - the number of elements
    1893      * - the indices of the elements
    1894      */
    1895 
    1896     list cat;
    1897     ideal L;
    1898     int i, j, size_cat;
    1899     for (i = 1; i <= size_modresults; i++) {
    1900         L = lead(modresults[i]);
    1901         attrib(L, "isSB", 1);
    1902         for (j = 1; j <= size_cat; j++) {
    1903             if (size(L) == size(cat[j][1])
    1904                 && size(reduce(L, cat[j][1])) == 0
    1905                 && size(reduce(cat[j][1], L)) == 0) {
    1906                 cat[j][2] = cat[j][2]+1;
    1907             cat[j][3][cat[j][2]] = i;
    1908             break;
    1909                 }
    1910         }
    1911         if (j > size_cat) {
    1912             size_cat++;
    1913             cat[size_cat] = list();
    1914             cat[size_cat][1] = L;
    1915             cat[size_cat][2] = 1;
    1916             cat[size_cat][3] = list(i);
    1917         }
    1918     }
    1919 
    1920     /* find the biggest categories */
    1921     int cat_max = 1;
    1922     int max = cat[1][2];
    1923     for (i = 2; i <= size_cat; i++) {
    1924         if (cat[i][2] > max) {
    1925             cat_max = i;
    1926             max = cat[i][2];
    1927         }
    1928     }
    1929 
    1930     /* return all other indices */
    1931     list unluckyIndices;
    1932     for (i = 1; i <= size_cat; i++) {
    1933         if (i != cat_max) {
    1934             unluckyIndices = unluckyIndices + cat[i][3];
    1935         }
    1936     }
    1937     return(unluckyIndices);
    19381933}
    19391934
     
    20092004static proc select_the_command(ideal I)
    20102005{
     2006    /* the procedure select_the_command selects a command which finishes the
     2007       computation first but if this command applied in a machine with a single
     2008       core it returns (by default) the command ffmodStdOne
     2009    */
    20112010    if(getcores() == 1)
    20122011    {
     
    20442043    list stdResults = tedY[1];
    20452044    list distElmnt = tedY[2];
    2046     ideal F = RecoverCoeffsForAFixedData(stdResults, distElmnt, L[1], L[2]);
     2045    ideal F =  RecoverCoeffsForAFixedData(stdResults, distElmnt, L[1], L[2]);
    20472046    return(F);
    20482047}
     
    20522051static proc ffmodStdOne(ideal I,list #)
    20532052{
    2054     /*
    2055      * note that the number of parameter(s) and variable(s)
    2056      * in I must be equal to those in the current
    2057      * base ring
    2058      */
     2053    // compute std of I using dense univariate rationa interpolation
    20592054    int tmp2 = 0;
    20602055    int tmp = 0;
     
    20642059    option(redSB);
    20652060    list pL;
     2061    // optional parameters
    20662062    if(size(#)>0)
    20672063    {
     
    20802076    n=nvars(G_t);
    20812077    pa=1;
    2082     I = normalize(I);
     2078    I = normalize(I); // make each element of I monic
    20832079    I=scalIdeal(I);
    20842080    list L=collect_coeffs(I);
     2081    // define a new ring
    20852082    list rl=ringlist(G_t);
    20862083    list la=rl[1][2];
     
    21012098        cI = 1;
    21022099    }
    2103 
    21042100    int pr = 536870909;
    2105     int paSS = prime_pass(pr, cI); // I
     2101    int paSS = prime_pass(pr, cI); // test whether pr is a suitable for cI
    21062102    pr = paSS;
    21072103    if(!tmp)
     
    21122108        def rp = ring(lbr);
    21132109        setring(rp);
     2110        // initial std computation using dense rational interpolation
    21142111        list rL = firststdmodp(imap(S_t,I),imap(S_t,cI), in_value);
    21152112        setring S_t;
     
    21212118            return(EI[1]);
    21222119        }
     2120        /*
     2121        * from the initial std we obtain bounds on the number of interpolation points
     2122        * and degree of each numerator and denominator which we use for later
     2123        * interpolation
     2124        */
    21232125        rL= rL[2..size(rL)];
    21242126    }
    2125 
    21262127    list newL,optionL;
    21272128    ideal J;
     
    21292130    {
    21302131        newL = I, cI, opL;
     2132        // apply modular command from the Singular library parallel.lib
    21312133        if(tmp2)
    21322134        {
     2135            // with final test
    21332136            J = modular("Ffmodstd::modp_tran", list(newL), primeTest_tran,
    21342137            Modstd::deleteUnluckyPrimes_std, pTest_tran, finalTest_tran, pr);
     
    21362139        else
    21372140        {
     2141            // without final test
    21382142            J = modular("Ffmodstd::modp_tran", list(newL), primeTest_tran,
    21392143            Modstd::deleteUnluckyPrimes_std, pTest_tran, pr);
     
    21422146    else
    21432147    {
     2148        // apply modular command from the Singular library parallel.lib with final test
    21442149        newL = I, cI, rL;
    21452150        J = modular("Ffmodstd::modp_tran", list(newL),  primeTest_tran,
    21462151        Modstd::deleteUnluckyPrimes_std, pTest_tran, finalTest_tran, pr);
    21472152    }
    2148 
    21492153    setring G_t;
    21502154    ideal J = imap(S_t, J);
     
    22042208///////////////////////////////////////////////////////////////////////////////
    22052209
    2206 static proc Is_belongs(ideal I, ideal fareyresult)
     2210static proc ideal_Inclusion(ideal I, ideal fareyresult)
    22072211{
    22082212    //return 1 if I is in fareyresult otherwise 0
     
    22452249    attrib(fry,"isSB",1);
    22462250    attrib(Jp,"isSB",1);
    2247     if(Is_belongs(Jp,fry))
     2251    if(ideal_Inclusion(Jp,fry))
    22482252    {
    22492253        // test if fry is in Jp
     
    22802284    return(1);
    22812285}
     2286
     2287// =============== a procedure for one parameter ends here ==========
    22822288
    22832289///////////////////////////////////////////////////////////////////////////////
     
    23292335"
    23302336{
    2331     /*
    2332      * note that the number of parameter(s) and variable(s)
    2333      * in the given ideal must be equal to those in the current
    2334      * basering
    2335      */
    23362337    intvec opt = option(get);
    2337     option(redSB);
     2338    option(redSB); // to obtain the reduced standard basis
    23382339    def G_t=basering;
    23392340    int n,pa,kr;
     
    23592360    if(pa==1)
    23602361    {
     2362        // if the current ring has one parameter
    23612363        def GF = ffmodStdOne(I);
    23622364        if(size(GF)==1)
     
    23692371    I=scalIdeal(I);
    23702372    list L=collect_coeffs(I);
     2373    // define a new ring
    23712374    list rl=ringlist(G_t);
    23722375    list la=rl[1][2];
     
    23872390    }
    23882391    list shft = test_the_shift(cI,n,pa);
    2389     //intvec vshft = shft[1..pa]; vshft;
    23902392    int j;
    23912393    // shift the parameters
     
    23942396        cI = subst(cI, var(n+j), var(n+j) + shft[j]);
    23952397    }
    2396 
    2397     list pr=list_of_primes(pa);
    2398     //intvec vpr = pr[1..pa];
    2399     //vpr;
     2398    list pr=list_of_primes(pa); // list distinct primes
     2399    // define a new ring
    24002400    setring G_t;
    24012401    rl = ringlist(G_t);
     
    24102410    setring StA;
    24112411    ideal Jc = imap(St,Jc);
     2412    // make selection to use relitively fast command
    24122413    list Lcom = select_the_command(Jc);
    24132414    string Command = Lcom[1];
     
    24262427        Lcom = poly(0);
    24272428    }
    2428 
    24292429    Lcom = Lcom,Jc;
    24302430    if(ncols(Jc)==1 and Jc[1]==1)
     
    24512451    list Zr = imap(StA,Zr);
    24522452    list FG = imap(StA, Lcom);
     2453    // compute std using sparse multivariate rational interpolation
    24532454    ideal J = stdoverFF(I,pr,shft, Command, Zr, FG);
    24542455    setring G_t;
     
    24732474    ideal J = x^2*y+y*z^2, x*z^2+x^2-y^2;
    24742475    ffmodStd(J);
    2475     ring R=(0,a,b),(x,y,z),dp;
     2476    ring R1=(0,a,b),(x,y,z),dp;
    24762477    ideal I = x^2*y^3*z+2*a*x*y*z^2+7*y^3,
    24772478              x^2*y^4*z+(a-7b)*x^2*y*z^2-x*y^2*z^2+2*x^2*y*z-12*x+by,
Note: See TracChangeset for help on using the changeset viewer.