Changeset c10f46 in git


Ignore:
Timestamp:
Aug 3, 2012, 1:06:22 PM (10 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '96ce329119711a2b80858c8365abd29f8460bbfa')
Children:
b0732eb4254fbe76540d72c337f3d7f985adf948
Parents:
b8610796eaca5ba7db8dc75f8bc88d698e077b365abb0e7fdca82a2bad9778e410148c74d7b49a0b
Message:
Merge pull request #162 from steenpass/libs

changes in LIBs from master
Files:
2 added
48 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/modstd.lib

    rb86107 rc10f46  
    11////////////////////////////////////////////////////////////////////////////////
    2 version="$Id$";
     2version="$Id: modstd.lib 14375 2011-08-23 09:29:47Z steidel $";
    33category = "Commutative Algebra";
    44info="
     
    88@*        G. Pfister      pfister@mathematik.uni-kl.de
    99@*        H. Schoenemann  hannes@mathematik.uni-kl.de
     10@*        A. Steenpass    steenpass@mathematik.uni-kl.de
    1011@*        S. Steidel      steidel@mathematik.uni-kl.de
    1112
     
    2627LIB "poly.lib";
    2728LIB "ring.lib";
     29LIB "parallel.lib";
    2830
    2931////////////////////////////////////////////////////////////////////////////////
     
    243245      if(printlevel >= 11)
    244246      {
    245          "isIncluded(K,J) takes "+string(timer - t)+" seconds";
     247         "isIncluded(J,K) takes "+string(timer - t)+" seconds";
    246248         "j = "+string(j);
    247249      }
     
    373375////////////////////////////////////////////////////////////////////////////////
    374376
    375 proc primeTest(ideal I, bigint p)
     377proc primeTest(def II, bigint p)
    376378{
     379   if(typeof(II) == "string")
     380   {
     381      execute("ideal I = "+II+";");
     382   }
     383   else
     384   {
     385      ideal I = II;
     386   }
     387
     388   I = simplify(I, 2);   // erase zero generators
     389
    377390   int i,j;
     391   poly f;
     392   number cnt;
    378393   for(i = 1; i <= size(I); i++)
    379394   {
    380       for(j = 1; j <= size(I[i]); j++)
    381       {
    382          if((numerator(leadcoef(I[i][j])) mod p) == 0) { return(0); }
    383          if((denominator(leadcoef(I[i][j])) mod p) == 0) { return(0); }
     395      f = cleardenom(I[i]);
     396      if(f == 0) { return(0); }
     397      cnt = leadcoef(I[i])/leadcoef(f);
     398      if((numerator(cnt) mod p) == 0) { return(0); }
     399      if((denominator(cnt) mod p) == 0) { return(0); }
     400      for(j = size(f); j > 0; j--)
     401      {
     402         if((leadcoef(f[j]) mod p) == 0) { return(0); }
    384403      }
    385404   }
     
    390409
    391410proc primeList(ideal I, int n, list #)
    392 "USAGE:  primeList(I,n); ( resp. primeList(I,n,L); ) I ideal, n integer
    393 RETURN:  the intvec of n greatest primes  <= 2147483647 (resp. n greatest primes
     411"USAGE:  primeList(I,n[,ncores]); ( resp. primeList(I,n[,L,ncores]); ) I ideal,
     412         n integer
     413RETURN:  the intvec of n greatest primes <= 2147483647 (resp. n greatest primes
    394414         < L[size(L)] union with L) such that none of these primes divides any
    395415         coefficient occuring in I
     416NOTE:    The number of cores to use can be defined by ncores, default is 1.
    396417EXAMPLE: example primList; shows an example
    397418"
     
    399420   intvec L;
    400421   int i,p;
     422   int ncores = 1;
     423   
     424//-----------------  Initialize optional parameter ncores  ---------------------
     425   if(size(#) > 0)
     426   {
     427      if(size(#) == 1)
     428      {
     429         if(typeof(#[1]) == "int")
     430         {
     431            ncores = #[1];
     432            # = list();
     433         }
     434      }
     435      else
     436      {
     437         ncores = #[2];
     438      }
     439   }
     440   
    401441   if(size(#) == 0)
    402442   {
     
    421461   }
    422462   if(p == 2) { ERROR("no more primes"); }
    423    for(i = 2; i <= n; i++)
    424    {
    425       p = prime(p-1);
    426       while(!primeTest(I,p))
     463   if(ncores == 1)
     464   {
     465      for(i = 2; i <= n; i++)
    427466      {
    428467         p = prime(p-1);
    429          if(p == 2) { ERROR("no more primes"); }
    430       }
    431       L[size(L)+1] = p;
     468         while(!primeTest(I,p))
     469         {
     470            p = prime(p-1);
     471            if(p == 2) { ERROR("no more primes"); }
     472         }
     473         L[size(L)+1] = p;
     474      }
     475   }
     476   else
     477   {
     478      int neededSize = size(L)+n-1;;
     479      list parallelResults;
     480      list arguments;
     481      int neededPrimes = neededSize-size(L);
     482      while(neededPrimes > 0)
     483      {
     484         arguments = list();
     485         for(i = ((neededPrimes div ncores)+1-(neededPrimes%ncores == 0))
     486            *ncores; i > 0; i--)
     487         {
     488            p = prime(p-1);
     489            if(p == 2) { ERROR("no more primes"); }
     490            arguments[i] = list("I", p);
     491         }
     492         parallelResults = parallelWaitAll("primeTest", arguments,
     493            list(list(list(ncores))));
     494         for(i = size(arguments); i > 0; i--)
     495         {
     496            if(parallelResults[i])
     497            {
     498               L[size(L)+1] = arguments[i][2];
     499            }
     500         }
     501         neededPrimes = neededSize-size(L);
     502      }
     503      if(size(L) > neededSize)
     504      {
     505         L = L[1..neededSize];
     506      }
    432507   }
    433508   return(L);
     
    470545   ideal I = imap(R,I);
    471546
     547   intvec opt = option(get);
    472548   option(none);
    473549   option(prompt);
     
    504580
    505581   setring R;
     582   option(set, opt);
    506583   return(imap(newR,sI),imap(newR,T));
    507584}
     
    537614         The standard basis computation modulo p does also vary depending on the
    538615         integer variant, namely
    539 @*       - variant = 1/4: std(.,#[1]) resp. groebner,
    540 @*       - variant = 2/5: groebner,
    541 @*       - variant = 3/6: homog. - std(.,#[1]) resp. groebner - dehomog..
     616@*       - variant = 1: std(.,#[1]) resp. groebner,
     617@*       - variant = 2: groebner,
     618@*       - variant = 3: homog. - std(.,#[1]) resp. groebner - dehomog.,
     619@*       - variant = 4: fglm.
    542620EXAMPLE: example modpStd; shows an example
    543621"
     
    552630   option(redSB);
    553631
    554    int t = timer;
    555    if((variant == 1) || (variant == 4))
     632   if(variant == 1)
    556633   {
    557634      if(size(#) > 0)
     
    565642   }
    566643
    567    if((variant == 2) || (variant == 5))
     644   if(variant == 2)
    568645   {
    569646      i = groebner(i);
    570647   }
    571648
    572    if((variant == 3) || (variant == 6))
     649   if(variant == 3)
    573650   {
    574651      list rl = ringlist(@r);
     
    607684      }
    608685
    609       t = timer;
    610686      i = subst(i, homvar, 1);
    611687      i = simplify(i, 34);
     
    615691      i = interred(i);
    616692      kill HomR;
     693   }
     694   
     695   if(variant == 4)
     696   {
     697      def R1 = changeord("dp");
     698      setring R1;
     699      ideal i = fetch(@r,i);
     700      i = std(i);
     701      setring @r;
     702      i = fglm(R1,i);
    617703   }
    618704
     
    646732RETURN:  a standard basis of I if no warning appears;
    647733NOTE:    The procedure computes a standard basis of I (over the rational
    648          numbers) by using  modular methods. If a warning appears then the
    649          result is a standard basis containing I and with high probability
    650          a standard basis of I.
     734         numbers) by using  modular methods.
    651735         By default the procedure computes a standard basis of I for sure, but
    652736         if the optional parameter #[2] = 0, it computes a standard basis of I
    653          with high probability and a warning appears at the end.
     737         with high probability.
    654738         The procedure distinguishes between different variants for the standard
    655739         basis computation in positive characteristic depending on the ordering
    656740         of the basering, the parameter #[2] and if the ideal I is homogeneous.
    657 @*       - variant = 1, if I is homogeneous and exactness = 0,
    658 @*       - variant = 2, if I is not homogeneous, 1-block-ordering and
    659                         exactness = 0,
     741@*       - variant = 1, if I is homogeneous,
     742@*       - variant = 2, if I is not homogeneous, 1-block-ordering,
    660743@*       - variant = 3, if I is not homogeneous, complicated ordering (lp or
    661                         > 1 block) and exactness = 0,
    662 @*       - variant = 4, if I is homogeneous and exactness = 1,
    663 @*       - variant = 5, if I is not homogeneous, 1-block-ordering and
    664                         exactness = 1,
    665 @*       - variant = 6, if I is not homogeneous, complicated ordering (lp or
    666                         > 1 block) and exactness = 1.
     744                        > 1 block),
     745@*       - variant = 4, if I is not homogeneous, ordering lp, dim(I) = 0.
    667746EXAMPLE: example modStd; shows an example
    668747"
     
    752831   if(printlevel >= 10)
    753832   {
    754       "n1 = "+string(n1)+", n2 = "+string(n2)+", n3 = "+string(n3);
     833      "n1 = "+string(n1)+", n2 = "+string(n2)+", n3 = "+string(n3)
     834       +", exactness = "+string(exactness);
    755835   }
    756836
     
    761841
    762842//--------------------  Initialize the list of primes  -------------------------
    763    intvec L = primeList(I,n2);
     843   int tt = timer;
     844   int rt = rtimer;
     845   intvec L = primeList(I,n2,n1);
     846   if(printlevel >= 10)
     847   {
     848      "CPU-time for primeList: "+string(timer-tt)+" seconds.";
     849      "Real-time for primeList: "+string(rtimer-rt)+" seconds.";
     850   }
    764851   L[5] = prime(random(an,en));
    765852
     
    768855   int h = homog(I);
    769856
    770    int tt = timer;
    771    int rt = rtimer;
     857   tt = timer;
     858   rt = rtimer;
    772859
    773860   if(!mixedTest())
     
    775862      if(h)
    776863      {
    777          if(exactness == 0)
    778          {
    779             variant = 1;
    780             if(printlevel >= 10) { "variant = 1"; }
    781          }
    782          if(exactness == 1)
    783          {
    784             variant = 4;
    785             if(printlevel >= 10) { "variant = 4"; }
    786          }
     864         variant = 1;
     865         if(printlevel >= 10) { "variant = 1"; }
     866         
    787867         rl[1] = L[5];
    788868         def @r = ring(rl);
     
    802882         if((find(ordstr_R0, "M") > 0) || (find(ordstr_R0, "a") > 0) || neg)
    803883         {
    804             if(exactness == 0)
    805             {
    806                variant = 2;
    807                if(printlevel >= 10) { "variant = 2"; }
    808             }
    809             if(exactness == 1)
    810             {
    811                variant = 5;
    812                if(printlevel >= 10) { "variant = 5"; }
    813             }
     884            variant = 2;
     885            if(printlevel >= 10) { "variant = 2"; }
    814886         }
    815887         else
     
    827899            if((order == "simple") || (size(rl) > 4))
    828900            {
    829                if(exactness == 0)
     901               variant = 2;
     902               if(printlevel >= 10) { "variant = 2"; }
     903            }
     904            else
     905            {
     906               rl[1] = L[5];
     907               def @r = ring(rl);
     908               setring @r;
     909               
     910               def @s = changeord("dp");
     911               setring @s;
     912               ideal I = std(fetch(R0,I));
     913               if(dim(I) == 0)
    830914               {
    831                   variant = 2;
    832                   if(printlevel >= 10) { "variant = 2"; }
     915                  variant = 4;
     916                  if(printlevel >= 10) { "variant = 4"; }
    833917               }
    834                if(exactness == 1)
    835                {
    836                   variant = 5;
    837                   if(printlevel >= 10) { "variant = 5"; }
    838                }
    839             }
    840             else
    841             {
    842                if(exactness == 0)
     918               else
    843919               {
    844920                  variant = 3;
    845921                  if(printlevel >= 10) { "variant = 3"; }
     922                 
     923                  int nvar@r = nvars(@r);
     924                  intvec w;
     925                  for(i = 1; i <= nvar@r; i++)
     926                  {
     927                     w[i] = deg(var(i));
     928                  }
     929                  w[nvar@r + 1] = 1;
     930
     931                  list hiRi = hilbRing(fetch(R0,I),w);
     932                  intvec W = hiRi[2];
     933                  @s = hiRi[1];
     934                  setring @s;
     935
     936                  Id(1) = std(Id(1));
     937                  intvec hi = hilb(Id(1), 1, W);
    846938               }
    847                if(exactness == 1)
    848                {
    849                   variant = 6;
    850                   if(printlevel >= 10) { "variant = 6"; }
    851                }
    852 
    853                rl[1] = L[5];
    854                def @r = ring(rl);
    855                setring @r;
    856                int nvar@r = nvars(@r);
    857                intvec w;
    858                for(i = 1; i <= nvar@r; i++)
    859                {
    860                   w[i] = deg(var(i));
    861                }
    862                w[nvar@r + 1] = 1;
    863 
    864                list hiRi = hilbRing(fetch(R0,I),w);
    865                intvec W = hiRi[2];
    866                def @s = hiRi[1];
    867                setring @s;
    868 
    869                Id(1) = std(Id(1));
    870                intvec hi = hilb(Id(1), 1, W);
    871 
     939               
    872940               setring R0;
    873941               kill @r,@s;
     
    9711039         link l(i) = "ssi:fork";
    9721040         open(l(i));
    973          if((variant == 1) || (variant == 3) ||
    974             (variant == 4) || (variant == 6))
     1041         if((variant == 1) || (variant == 3))
    9751042         {
    9761043            write(l(i), quote(modpStd(I_for_fork, eval(L[i + 1]),
    9771044                                                  eval(variant), eval(hi))));
    9781045         }
    979          if((variant == 2) || (variant == 5))
     1046         if((variant == 2) || (variant == 4))
    9801047         {
    9811048            write(l(i), quote(modpStd(I_for_fork, eval(L[i + 1]),
     
    9851052
    9861053      int t = timer;
    987       if((variant == 1) || (variant == 3) || (variant == 4) || (variant == 6))
     1054      if((variant == 1) || (variant == 3))
    9881055      {
    9891056         P = modpStd(I_for_fork, L[1], variant, hi);
    9901057      }
    991       if((variant == 2) || (variant == 5))
     1058      if((variant == 2) || (variant == 4))
    9921059      {
    9931060         P = modpStd(I_for_fork, L[1], variant);
     
    10051072//--------------  Main standard basis computations in positive  ----------------
    10061073//----------------------  characteristic start here  ---------------------------
     1074
     1075   list arguments_farey, results_farey;
    10071076
    10081077   while(1)
     
    10291098                  if(j <= size(L))
    10301099                  {
    1031                      if((variant == 1) || (variant == 3) ||
    1032                         (variant == 4) || (variant == 6))
     1100                     if((variant == 1) || (variant == 3))
    10331101                     {
    10341102                        write(l(i), quote(modpStd(I_for_fork, eval(L[j]),
     
    10361104                        j++;
    10371105                     }
    1038                      if((variant == 2) || (variant == 5))
     1106                     if((variant == 2) || (variant == 4))
    10391107                     {
    10401108                        write(l(i), quote(modpStd(I_for_fork,
     
    10621130         while(j <= size(L))
    10631131         {
    1064             if((variant == 1) || (variant == 3) ||
    1065                (variant == 4) || (variant == 6))
     1132            if((variant == 1) || (variant == 3))
    10661133            {
    10671134               P = modpStd(I, L[j], variant, hi);
    10681135            }
    1069             if((variant == 2) || (variant == 5))
     1136            if((variant == 2) || (variant == 4))
    10701137            {
    10711138               P = modpStd(I, L[j], variant);
     
    10951162//-------------------  Lift results to basering via farey  ---------------------
    10961163
    1097       tt = timer;
     1164      tt = timer; rt = rtimer;
    10981165      N = T2[1];
    10991166      for(i = 2; i <= size(T2); i++) { N = N*T2[i]; }
    11001167      H = chinrem(T1,T2);
    1101       J = farey(H,N);
    1102       if(printlevel >= 10) { "Lifting-process takes "+string(timer - tt)
    1103                              +" seconds"; }
     1168      if(n1 == 1)
     1169      {
     1170         J = farey(H,N);
     1171      }
     1172      else
     1173      {
     1174         for(i = ncols(H); i > 0; i--)
     1175         {
     1176            arguments_farey[i] = list(ideal(H[i]), N);
     1177         }
     1178         results_farey = parallelWaitAll("farey", arguments_farey,
     1179                                         list(list(list(n1))));
     1180         for(i = ncols(H); i > 0; i--)
     1181         {
     1182            J[i] = results_farey[i][1];
     1183         }
     1184      }
     1185      if(printlevel >= 10)
     1186      {
     1187         "CPU-time for lifting-process is "+string(timer - tt)+" seconds.";
     1188         "Real-time for lifting-process is "+string(rtimer - rt)+" seconds.";
     1189      }
    11041190
    11051191//----------------  Test if we already have a standard basis of I --------------
    11061192
    11071193      tt = timer; rt = rtimer;
    1108       if((variant == 1) || (variant == 3) || (variant == 4) || (variant == 6))
     1194      if((variant == 1) || (variant == 3))
    11091195      {
    11101196         pTest = pTestSB(I,J,L,variant,hi);
    11111197      }
    1112       if((variant == 2) || (variant == 5))
     1198      if((variant == 2) || (variant == 4))
    11131199      {
    11141200         pTest = pTestSB(I,J,L,variant);
     
    11321218
    11331219         attrib(J,"isSB",1);
    1134          tt = timer; rt = rtimer;
    1135          sizeTest = 1 - isIncluded(I,J,n1);
    1136 
    1137          if(printlevel >= 10)
    1138          {
    1139             "CPU-time for checking if I subset <G> is "
    1140             +string(timer - tt)+" seconds.";
    1141             "Real-time for checking if I subset <G> is "
    1142             +string(rtimer - rt)+" seconds.";
    1143          }
    1144 
    1145          if(sizeTest == 0)
    1146          {
    1147             if((variant == 1) || (variant == 2) || (variant == 3))
    1148             {
    1149                "===========================================================";
    1150                "WARNING: Output might not be a standard basis of the input.";
    1151                "===========================================================";
    1152                option(set, opt);
    1153                if(n1 > 1) { kill I_for_fork; }
    1154                return(J);
    1155             }
    1156             if((variant == 4) || (variant == 5) || (variant == 6))
     1220         
     1221         if(exactness == 0)
     1222         {
     1223            option(set, opt);
     1224            if(n1 > 1) { kill I_for_fork; }
     1225            return(J);
     1226         }
     1227         
     1228         if(exactness == 1)
     1229         {
     1230            tt = timer; rt = rtimer;
     1231            sizeTest = 1 - isIncluded(I,J,n1);
     1232
     1233            if(printlevel >= 10)
     1234            {
     1235               "CPU-time for checking if I subset <G> is "
     1236               +string(timer - tt)+" seconds.";
     1237               "Real-time for checking if I subset <G> is "
     1238               +string(rtimer - rt)+" seconds.";
     1239            }
     1240
     1241            if(sizeTest == 0)
    11571242            {
    11581243               tt = timer; rt = rtimer;
     
    11851270
    11861271      j = size(L) + 1;
    1187       L = primeList(I,n3,L);
     1272      tt = timer; rt = rtimer;
     1273      L = primeList(I,n3,L,n1);
     1274      if(printlevel >= 10)
     1275      {
     1276         "CPU-time for primeList: "+string(timer-tt)+" seconds.";
     1277         "Real-time for primeList: "+string(rtimer-rt)+" seconds.";
     1278      }
    11881279
    11891280      if(n1 > 1)
     
    11921283         {
    11931284            open(l(i));
    1194             if((variant == 1) || (variant == 3) ||
    1195                (variant == 4) || (variant == 6))
     1285            if((variant == 1) || (variant == 3))
    11961286            {
    11971287               write(l(i), quote(modpStd(I_for_fork, eval(L[j+i-1]),
    11981288                                                     eval(variant), eval(hi))));
    11991289            }
    1200             if((variant == 2) || (variant == 5))
     1290            if((variant == 2) || (variant == 4))
    12011291            {
    12021292               write(l(i), quote(modpStd(I_for_fork, eval(L[j+i-1]),
     
    13181408   def S = ring(rl);
    13191409   setring S;
     1410   intvec opt = option(get);
    13201411   option(redSB);
    13211412   module Z,M,Z2;
     
    13621453               if(size(reduce(G3,testG1)) == 0)
    13631454               {
     1455                  option(set, opt);
    13641456                  return(G3);
    13651457               }
  • Singular/LIB/parallel.lib

    rb86107 rc10f46  
    33category="General purpose";
    44info="
    5 LIBRARY:   parallel.lib  An Interface for Parallelization
     5LIBRARY:   parallel.lib  Tools for Parallelization
    66AUTHOR:    Andreas Steenpass, e-mail: steenpass@mathematik.uni-kl.de
     7
     8OVERVIEW:
     9This library provides tools to do several computations in parallel. They
     10are aimed at ordinary Singular users as well as authors of Singular
     11libraries.
     12@* Even without this library, it is possible to do execute self-defined
     13Singular commands in parallel using @ref{links}, but the handling of
     14such links can be quite tedious. With the pocedures described below,
     15this can be done by one-line commands.
     16@* There are many parallel 'skeletons' (i.e. ways in which parallel
     17tasks rely upon and interact with each other). A few of them are already
     18implemented. Future plans include an abstraction layer for modular
     19techniques, 'worker farms', and parallel tests.
    720
    821SEE ALSO:  link, modstd_lib, assprimeszerodim_lib
     
    2639RETURN:  a list, containing the results of commands[i] applied to arg[i],
    2740         i = 1, ..., size(commands).
    28          @* The entries of the list commands must be strings.
    29          @* The entries of the list args must be lists.
    3041         @* The procedure waits for N jobs to finish.
    31          @* An optional timeout in ms can be provided. Default is 0 which
     42
     43         @* OPTIONAL PARAMETERS:
     44
     45            An optional timeout in ms can be provided. Default is 0 which
    3246            disables the timeout.
    33          @* Supported linktypes are up to now \"ssi\" and \"mp\", see
     47
     48            Supported linktypes are up to now \"ssi\" and \"mp\", see
    3449            @ref{Ssi links} and @ref{MP links}.
     50
     51            Servers:
    3552         @* Each server is given by a list containing the address of the server,
    3653            the number of cores to use on this server and the command to start
    37             Singular. If the address is \"localhost\", the processes will
    38             be generated on the same machine using forks. If the command to
    39             start Singular is \"\" (the empty string), \"Singular\" will be
    40             used. Default is @code{list(\"localhost\", system(\"cpu\"), \"\")}.
    41             There are some obvious shortcuts for servers, e.g. \"myserver\" is
     54            Singular.
     55         @* If the address is \"localhost\", the processes will be generated on
     56            the same machine using forks. If the command to start Singular is
     57            \"\" (the empty string), \"Singular\" will be used.
     58         @* Default is @code{list(\"localhost\", system(\"cpu\"), \"\")}.
     59         @* There are some obvious shortcuts for servers, e.g. \"myserver\" is
    4260            a shortcut for
    4361            @code{list(\"myserver\", [nb. of cores on myserver], \"\")}, or 3
    4462            for @code{list(\"localhost\", 3, \"\")}.
     63
     64            Memory limits:
    4565         @* If an intvec maxmemory of size @code{size(commands)} is given, the
    4666            i-th job will be killed if it uses more than maxmemory[i] MB of
    4767            memory. If maxmemory[i] is 0, there will be no restraint for the
    4868            i-th job. Default is @code{0:size(commands)}.
    49 NOTE:       The returned list may contain more than N results if several jobs
     69NOTE:       The entries of the list commands must be strings.
     70         @* The entries of the list args must be lists.
     71         @* The returned list may contain more than N results if several jobs
    5072            finished \"at the same time\". It may contain less than N results in
    5173            the case of timeout or errors occurring.
     
    368390    }
    369391    write(l(i), quote(execute("result = "+eval(commands[k])
    370                                     +"(currentargs[1..size(currentargs)]);")));
     392      +"("+argsToString("currentargs", size(currentargs))+");")));
    371393    assignment[i] = k;
    372394    k++;
     
    455477      }
    456478      write(l(wait), quote(execute("def result = "+eval(commands[k])
    457                                      +"(currentargs[1..size(currentargs)]);")));
     479        +"("+argsToString("currentargs", size(currentargs))+");")));
    458480      assignment[wait] = k;
    459481      k++;
     
    542564  ideal i = z8+z6+4z5+4z3+4z2+4, y-z2;
    543565  ideal j = 3x3y+x3+xy3+y2z2, 2x3z-xy-xz3-y4-z2, 2x2yz-2xy2+xz2-y4;
    544   list commands = list("std", "primdecGTZ", "primdecSY", "std", "primdecGTZ",
    545                        "primdecSY");
     566  list commands = list("std", "primdecGTZ", "primdecSY",
     567                       "std", "primdecGTZ", "primdecSY");
    546568  list args = list(list(i), list(i), list(i), list(j), list(j), list(j));
    547569  parallelWaitN(commands, args, 3);
     
    717739  return(i);
    718740}
     741
     742static proc argsToString(string name, int length)
     743{
     744  string arglist;
     745  if(length > 0) {
     746    arglist = name+"[1]";
     747  }
     748  int i;
     749  for(i = 2; i <= length; i++) {
     750    arglist = arglist+", "+name+"["+string(i)+"]";
     751  }
     752  return(arglist);
     753}
  • Singular/LIB/realclassify.lib

    rb86107 rc10f46  
    99OVERVIEW:
    1010   A library for classifying isolated hypersurface singularities over the reals
    11    w.r.t. right
    12    equivalence, based on the determinator of singularities by V.I. Arnold.
    13    This library is based on classify.lib by Kai Krueger, but handles the real
    14    case, while classify.lib does the complex classification.
     11   w.r.t. right equivalence, based on the determinator of singularities by
     12   V.I. Arnold. This library is based on classify.lib by Kai Krueger, but
     13   handles the real case, while classify.lib does the complex classification.
     14
     15REFERENCES:
     16Arnold, Varchenko, Gusein-Zade: Singularities of Differentiable Maps.
     17Vol. 1: The classification of critical points caustics and wave fronts.
     18Birkh\"auser, Boston 1985
     19
     20Greuel, Lossen, Shustin: Introduction to singularities and deformations.
     21Springer, Berlin 2007
    1522
    1623PROCEDURES:
     
    3138RETURN:   A list containing (in this order)
    3239          @* - the type of the singularity as a string,
    33           @* - the normal form as well as
     40          @* - the normal form,
    3441          @* - the corank, the Milnor number, the inertia index and
    3542               a bound for the determinacy as integers.
     
    778785  "EXAMPLE:";
    779786  echo = 2;
    780   LIB "realclassify.lib";
    781787  ring r = 0, (x,y,z), ds;
    782788  poly f = (x2+3y-2z)^2+xyz-(x-y3+x2z3)^3;
     
    10061012  "EXAMPLE:";
    10071013  echo = 2;
    1008   LIB "realclassify.lib";
    10091014  ring r = 0, (x,y,z), ds;
    10101015  poly f = (x2+3y-2z)^2+xyz-(x-y3+x2z3)^3;
     
    10531058  "EXAMPLE:";
    10541059  echo = 2;
    1055   LIB "realclassify.lib";
    10561060  ring r = 0, (x,y), ds;
    10571061  poly f = x3+y4;
     
    11451149  "EXAMPLE:";
    11461150  echo = 2;
    1147   LIB "realclassify.lib";
    11481151  ring r = 0, (x,y), ds;
    11491152  poly f = x3+xy3;
  • factory/libfac/Makefile.am

    r5abb0e7 rc10f46  
    4848EXTRA_DIST = factor/class.cc \
    4949      factor/test.cc test.cc testcs.cc header.tpl \
    50       tests charset/tests bin \
     50      charset/tests bin \
    5151      ChangeLog 00README
    5252
  • factory/libfac/charset/alg_factor.cc

    r5abb0e7 rc10f46  
    22// emacs edit mode for this file is -*- C++ -*-
    33////////////////////////////////////////////////////////////
    4 ////////////////////////////////////////////////////////////
     4
    55// FACTORY - Includes
    66#include <factory.h>
     
    1818#include "alg_factor.h"
    1919
    20 void out_cf(char *s1,const CanonicalForm &f,char *s2);
     20void out_cf(const char *s1,const CanonicalForm &f,const char *s2);
    2121
    2222#ifdef ALGFACTORDEBUG
     
    8080// replacement for factory's broken psr
    8181static CanonicalForm
    82 mypsr ( const CanonicalForm &rr, const CanonicalForm &vv, const Variable & x ){
     82mypsr ( const CanonicalForm &rr, const CanonicalForm &vv, const Variable & x )
     83{
    8384  CanonicalForm r=rr, v=vv, l, test, lu, lv, t, retvalue;
    8485  int dr, dv, d,n=0;
     
    104105// replacement for factory's broken resultant
    105106static CanonicalForm
    106 resultante( const CanonicalForm & f, const CanonicalForm& g, const Variable & v ){
     107resultante( const CanonicalForm & f, const CanonicalForm& g, const Variable & v )
     108{
    107109  bool on_rational = isOn(SW_RATIONAL);
    108110  On(SW_RATIONAL);
     
    113115  if (!on_rational)  Off(SW_RATIONAL);
    114116
    115 return resultant(fz,gz,v);
     117  return resultant(fz,gz,v);
    116118}
    117119
     
    133135sqrf_norm_sub( const CanonicalForm & f, const CanonicalForm & PPalpha,
    134136           CFGenerator & myrandom, CanonicalForm & s,  CanonicalForm & g,
    135            CanonicalForm & R){
     137           CanonicalForm & R)
     138{
    136139  Variable y=PPalpha.mvar(),vf=f.mvar();
    137140  CanonicalForm temp, Palpha=PPalpha, t;
     
    147150
    148151  // Norm, resultante taken with respect to y
    149   while ( !sqfreetest ){
     152  while ( !sqfreetest )
     153  {
    150154    DEBOUTLN(CERR, "sqrf_norm_sub: Palpha= ", Palpha);
    151155    R = resultante(Palpha, g, y); R= R* bCommonDen(R);
     
    160164      DEBOUTLN(CERR, "sqrf_norm_sub: sqfreetest= ", sqfreetest);
    161165    }
    162     else{
     166    else
     167    {
    163168      DEBOUTMSG(CERR, "Starting SqrFreeTest(R)!");
    164169      // Look at SqrFreeTest!
     
    169174      if (getAlgVar(R,X))
    170175      {
    171         if (R.isUnivariate())
    172176          testlist=factorize( R, X );
    173         else
    174           testlist= Factorize(R, X, 0);
    175177      }
    176178      else
     
    183185      DEBOUTLN(CERR, "SqrFreeTest(R)= ", sqfreetest);
    184186    }
    185     if ( ! sqfreetest ){
     187    if ( ! sqfreetest )
     188    {
    186189      myrandom.next();
    187190      DEBOUTLN(CERR, "sqrf_norm_sub generated new myrandom item: ", myrandom.item());
     
    198201sqrf_agnorm_sub( const CanonicalForm & f, const CanonicalForm & PPalpha,
    199202           AlgExtGenerator & myrandom, CanonicalForm & s,  CanonicalForm & g,
    200            CanonicalForm & R){
     203           CanonicalForm & R)
     204{
    201205  Variable y=PPalpha.mvar(),vf=f.mvar();
    202206  CanonicalForm temp, Palpha=PPalpha, t;
     
    212216
    213217  // Norm, resultante taken with respect to y
    214   while ( !sqfreetest ){
     218  while ( !sqfreetest )
     219  {
    215220    DEBOUTLN(CERR, "sqrf_norm_sub: Palpha= ", Palpha);
    216221    R = resultante(Palpha, g, y); R= R* bCommonDen(R);
     
    225230      DEBOUTLN(CERR, "sqrf_norm_sub: sqfreetest= ", sqfreetest);
    226231    }
    227     else{
     232    else
     233    {
    228234      DEBOUTMSG(CERR, "Starting SqrFreeTest(R)!");
    229235      // Look at SqrFreeTest!
     
    234240      if (getAlgVar(R,X))
    235241      {
    236         if (R.isUnivariate())
    237242          testlist=factorize( R, X );
    238         else
    239           testlist= Factorize(R, X, 0);
    240243      }
    241244      else
     
    248251      DEBOUTLN(CERR, "SqrFreeTest(R)= ", sqfreetest);
    249252    }
    250     if ( ! sqfreetest ){
     253    if ( ! sqfreetest )
     254    {
    251255      myrandom.next();
    252256      DEBOUTLN(CERR, "sqrf_norm_sub generated new myrandom item: ", myrandom.item());
     
    264268sqrf_norm( const CanonicalForm & f, const CanonicalForm & PPalpha,
    265269           const Variable & Extension, CanonicalForm & s,  CanonicalForm & g,
    266            CanonicalForm & R){
    267 
     270           CanonicalForm & R)
     271{
    268272  DEBOUTLN(CERR, "sqrf_norm:      f= ", f);
    269273  DEBOUTLN(CERR, "sqrf_norm: Palpha= ", PPalpha);
    270   if ( getCharacteristic() == 0 ) {
     274  if ( getCharacteristic() == 0 )
     275  {
    271276    IntGenerator myrandom;
    272277    DEBOUTMSG(CERR, "sqrf_norm: no extension, char=0");
     
    278283    DEBOUTLN(CERR, "sqrf_norm:      R= ", R);
    279284  }
    280   else if ( degree(Extension) > 0 ){ // working over Extensions
     285  else if ( degree(Extension) > 0 ) // working over Extensions
     286  {
    281287    DEBOUTLN(CERR, "sqrf_norm: degree of extension is ", degree(Extension));
    282288    AlgExtGenerator myrandom(Extension);
    283289    sqrf_agnorm_sub(f,PPalpha, myrandom, s,g,R);
    284290  }
    285   else{
     291  else
     292  {
    286293    FFGenerator myrandom;
    287294    DEBOUTMSG(CERR, "sqrf_norm: degree of extension is 0");
     
    296303  Variable x;
    297304
    298   for ( VarlistIterator i=uord; i.hasItem(); i++){
     305  for ( VarlistIterator i=uord; i.hasItem(); i++)
     306  {
    299307    x=i.getItem();
    300     for ( CFListIterator j=Astar; j.hasItem(); j++ ){
     308    for ( CFListIterator j=Astar; j.hasItem(); j++ )
     309    {
    301310      elem= j.getItem();
    302       if ( degree(elem,x) > 0 ){ // x actually occures in Astar
     311      if ( degree(elem,x) > 0 ) // x actually occures in Astar
     312      {
    303313        output.append(x);
    304314        break;
     
    312322// Must be a power of p: i.e. y^{p^e}-x
    313323static int
    314 inseperable(const CFList & Astar){
     324inseperable(const CFList & Astar)
     325{
    315326  CanonicalForm elem;
    316327  int Counter= 1;
    317328
    318329  if ( Astar.length() == 0 ) return 0;
    319   for ( CFListIterator i=Astar; i.hasItem(); i++){
     330  for ( CFListIterator i=Astar; i.hasItem(); i++)
     331  {
    320332    elem= i.getItem();
    321333    if ( elem.deriv() == elem.genZero() ) return Counter;
     
    327339// calculate gcd of f and g in char=0
    328340static CanonicalForm
    329 gcd0( CanonicalForm f, CanonicalForm g ){
     341gcd0( CanonicalForm f, CanonicalForm g )
     342{
    330343  int charac= getCharacteristic();
    331344  int save=isOn(SW_RATIONAL);
     
    333346  CanonicalForm ff= mapinto(f), gg= mapinto(g);
    334347  CanonicalForm result= gcd(ff,gg);
    335   setCharacteristic(charac); 
     348  setCharacteristic(charac);
    336349  if (save) On(SW_RATIONAL);
    337350  return mapinto(result);
     
    344357// have enough elements to plug in.
    345358static int
    346 getextension( IntList & degreelist, int n){
     359getextension( IntList & degreelist, int n)
     360{
    347361  int charac= getCharacteristic();
    348362  setCharacteristic(0); // need it for k !
     
    543557
    544558static CFFList
    545 endler( const CanonicalForm & f, const CFList & AS, const Varlist & uord ){
     559endler( const CanonicalForm & f, const CFList & AS, const Varlist & uord )
     560{
    546561  CanonicalForm F=f, g, q,r;
    547562  CFFList Output;
     
    551566  Variable vg;
    552567
    553   for (i=as; i.hasItem(); i++){
     568  for (i=as; i.hasItem(); i++)
     569  {
    554570    g= i.getItem();
    555     if (g.deriv() == 0 ){
     571    if (g.deriv() == 0 )
     572    {
    556573      DEBOUTLN(CERR, "Inseperable extension detected: ", g);
    557       for (j=uord; j.hasItem(); j++){
     574      for (j=uord; j.hasItem(); j++)
     575      {
    558576        if ( degree(g,j.getItem()) > 0 ) vg= j.getItem();
    559577      }
     
    568586      // Now transform all remaining polys in as:
    569587      int x=0;
    570       for (ii=i; ii.hasItem(); ii++){
    571         if ( x != 0 ){
     588      for (ii=i; ii.hasItem(); ii++)
     589      {
     590        if ( x != 0 )
     591        {
    572592          divrem(ii.getItem(), gg, q,r);
    573593//          CERR << ii.getItem() << " divided by " << gg << "\n";
     
    595615
    596616  // Transform back:
    597   for ( CFFListIterator k=factorlist; k.hasItem(); k++){
     617  for ( CFFListIterator k=factorlist; k.hasItem(); k++)
     618  {
    598619    CanonicalForm factor= k.getItem().factor();
    599620    ii=One;
    600     for (i=Two; i.hasItem(); i++){
     621    for (i=Two; i.hasItem(); i++)
     622    {
    601623      DEBOUTLN(CERR, "Mapping ", i.getItem());
    602624      DEBOUTLN(CERR, "     to ", ii.getItem());
     
    618640//           no transcendentals, seperable and inseperable extensions
    619641CFFList
    620 newfactoras( const CanonicalForm & f, const CFList & as, int &success){
     642newfactoras( const CanonicalForm & f, const CFList & as, int &success)
     643{
    621644  Variable vf=f.mvar();
    622645  CFListIterator i;
     
    751774
    752775CFFList
    753 newcfactor(const CanonicalForm & f, const CFList & as, int & success ){
     776newcfactor(const CanonicalForm & f, const CFList & as, int & success )
     777{
    754778  Off(SW_RATIONAL);
    755   CFFList Output, output, Factors=Factorize(f); On(SW_RATIONAL);
     779  CFFList Output, output, Factors=Factorize(f);
     780  On(SW_RATIONAL);
    756781  Factors.removeFirst();
    757782
     
    760785
    761786  success=1;
    762   for ( CFFListIterator i=Factors; i.hasItem(); i++ ){
     787  for ( CFFListIterator i=Factors; i.hasItem(); i++ )
     788  {
    763789    output=newfactoras(i.getItem().factor(),as, success);
    764790    for ( CFFListIterator j=output; j.hasItem(); j++)
  • factory/libfac/charset/charset.cc

    r5abb0e7 rc10f46  
    493493    if ( degree(elem) > 1 ) // linear poly's are irreduzible
    494494    {
    495       qs = Factorize(elem);
     495      qs = factorize(elem);
    496496      // remove a constant
    497497      if (qs.getFirst().factor().degree()==0) qs.removeFirst();
  • factory/libfac/configure

    r5abb0e7 rc10f46  
    530530libfac_name="\"Factorization and characteristic sets library\""
    531531
    532 libfac_version="3.1.3"
     532libfac_version="3.1.5"
    533533cat >> confdefs.h <<EOF
    534534#define LIBFAC_VERSION "$libfac_version"
     
    536536
    537537
    538 libfac_date="\"March 2011\""
     538libfac_date="\"July 2012\""
    539539cat >> confdefs.h <<EOF
    540540#define LIBFAC_DATE $libfac_date
  • factory/libfac/configure.in

    r5abb0e7 rc10f46  
    1515libfac_name="\"Factorization and characteristic sets library\""
    1616AC_SUBST(libfac_name)
    17 libfac_version="3.1.3"
     17libfac_version="3.1.5"
    1818AC_DEFINE_UNQUOTED(LIBFAC_VERSION,"$libfac_version")
    1919AC_SUBST(libfac_version)
    20 libfac_date="\"March 2011\""
     20libfac_date="\"July 2012\""
    2121AC_DEFINE_UNQUOTED(LIBFAC_DATE,$libfac_date)
    2222AC_SUBST(libfac_date)
  • factory/libfac/factor/Factor.cc

    r5abb0e7 rc10f46  
    2727
    2828#include "alg_factor.h"
    29 void out_cf(char *s1,const CanonicalForm &f,char *s2);
     29void out_cf(const char *s1,const CanonicalForm &f,const char *s2);
    3030void out_cff(CFFList &L);
    3131
     
    5252* ( in factorize, alpha.level() must be < 0 )
    5353*/
     54static
    5455CFFList factorize2 ( const CanonicalForm & f,
    5556                     const Variable & alpha, const CanonicalForm & mipo )
     
    6162  else
    6263  {
    63     bool repl=(f.mvar() != alpha);
    6464    //out_cf("f2 - factor:",f,"\n");
    6565    //out_cf("f2 - ext:",alpha,"\n");
     
    6767    Variable X=rootOf(mipo);
    6868    CanonicalForm F=f;
    69     if (repl) F=replacevar(f,alpha,X);
     69    F=replacevar(f,alpha,X);
    7070    //out_cf("call - factor:",F,"\n");
    7171    //out_cf("call - ext:",X,"\n");
     
    7373    CFFList L=factorize(F,X);
    7474    CFFListIterator i=L;
    75     if (repl)
    7675    {
    7776      CFFList Outputlist;
     
    8281        i.getItem().exp()));
    8382      }
     83      //out_cff(Outputlist);
    8484      return Outputlist;
    8585    }
    86     else return L;
    8786  }
    8887}
     
    393392generate_mipo( int degree_of_Extension , const Variable & Extension ){
    394393  FFRandom gen;
    395   if ( degree(Extension) > 0 ) GFRandom gen;
    396   else {
    397     if ( degree(Extension) == 0 ) FFRandom gen;
    398     else
    399     {
    400       factoryError("libfac: evaluate: Extension not inFF() or inGF() !");
    401     }
    402   }
     394  if (degree (Extension) < 0)
     395    factoryError("libfac: evaluate: Extension not inFF() or inGF() !");
    403396  return find_irreducible( degree_of_Extension, gen, Variable(1) );
    404397}
     
    465458
    466459static int
    467 specializePoly(const CanonicalForm & f, Variable & Extension, int deg, SFormList & Substitutionlist, int i,int j){
     460specializePoly(const CanonicalForm & f, Variable & Extension, int deg, SFormList & Substitutionlist, int i,int j)
     461{
    468462  Variable minpoly= Extension;
    469463  int ok,extended= degree(Extension), working_over_extension;
     
    474468  // First try:
    475469  ok = try_specializePoly(f,minpoly,deg,Substitutionlist,i,j);
    476   while ( ! ok ){ // we have to extend!
     470  while ( ! ok ) // we have to extend!
     471  {
     472    SFormList origS=Substitutionlist;
    477473    extended+= 1;
    478     if ( ! working_over_extension ){
    479       minpoly= rootOf(generate_mipo( extended,Extension ));
     474    if ( ! working_over_extension )
     475    {
     476      if (!hasMipo(Extension))
     477        minpoly= rootOf (generate_mipo (extended, Extension));
     478      else
     479      {
     480        setReduce (Extension, false);
     481        setMipo (minpoly, generate_mipo ( extended, Extension));
     482        setReduce (Extension, true);
     483      }
    480484      Extension= minpoly;
    481485      ok= try_specializePoly(f,minpoly,deg,Substitutionlist,i,j);
     486      if (!ok)
     487        Substitutionlist=origS;
    482488    }
    483489    else
     
    804810{
    805811  //out_cf("Factorize ",F,"\n");
    806   CFFList Outputlist,SqrFreeList,Intermediatelist,Outputlist2;
    807   ListIterator<CFFactor> i,j;
    808   CanonicalForm g=1,unit=1,r=1;
    809   Variable minpoly; // dummy
    810   int exp;
    811   CFMap m;
     812  CFFList Outputlist;
    812813
    813814  // INTERRUPTHANDLER
     
    831832    return Outputlist;
    832833  }
     834  CFFList SqrFreeList,Intermediatelist,Outputlist2;
     835  ListIterator<CFFactor> i,j;
     836  CanonicalForm g=1,unit=1,r=1;
     837  Variable minpoly; // dummy
     838  int exp;
     839  CFMap m;
    833840  TIMING_START(factorize_time);
    834841  // search an "optimal" main variavble
  • factory/variable.cc

    r5abb0e7 rc10f46  
    215215}
    216216
    217 /*void setMipo ( const Variable & alpha, const CanonicalForm & mipo)
     217void setMipo ( const Variable & alpha, const CanonicalForm & mipo)
    218218{
    219219    ASSERT( alpha.level() < 0 && alpha.level() != LEVELBASE, "illegal extension" );
    220220    algextensions[-alpha.level()]= ext_entry((InternalPoly*)(conv2mipo( mipo, alpha ).getval()), true );
    221 }*/
     221}
    222222
    223223bool hasMipo( const Variable & alpha )
    224224{
    225     ASSERT( alpha.level() < 0 && alpha.level() != LEVELBASE, "illegal extension" );
    226     return ((algextensions!=NULL) && getReduce(alpha) );
     225    ASSERT( alpha.level() < 0, "illegal extension" );
     226    return (alpha.level() != LEVELBASE && (algextensions!=NULL) && getReduce(alpha) );
    227227}
    228228
  • factory/variable.h

    r5abb0e7 rc10f46  
    7878inline char name( const Variable & v ) { return v.name(); }
    7979
     80void setReduce( const Variable & alpha, bool reduce );
     81void setMipo ( const Variable & alpha, const CanonicalForm & mipo);
    8082CanonicalForm getMipo( const Variable & alpha, const Variable & x );
    8183bool hasMipo( const Variable & alpha );
     
    9395InternalPoly * getInternalMipo ( const Variable & alpha );
    9496bool getReduce( const Variable & alpha );
    95 void setReduce( const Variable & alpha, bool reduce );
    9697
    9798#endif /* ! INCL_VARIABLE_H */
Note: See TracChangeset for help on using the changeset viewer.