Changeset 45f7bf in git for Singular/LIB/standard.lib


Ignore:
Timestamp:
May 24, 1998, 5:50:29 PM (26 years ago)
Author:
Olaf Bachmann <obachman@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
6149f4fc52e4155e098c88eb317a7abd5b8d6541
Parents:
3bb3e6aa8f77d610b72ac96bb897600802300029
Message:
* status with sleep in microseconds
* groebner with 2 args


git-svn-id: file:///usr/local/Singular/svn/trunk@1962 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/standard.lib

    r3bb3e6a r45f7bf  
    1 // $Id: standard.lib,v 1.11 1998-05-18 13:24:50 Singular Exp $
     1// $Id: standard.lib,v 1.12 1998-05-24 15:50:27 obachman Exp $
    22///////////////////////////////////////////////////////////////////////////////
    33
    4 version="$Id: standard.lib,v 1.11 1998-05-18 13:24:50 Singular Exp $";
     4version="$Id: standard.lib,v 1.12 1998-05-24 15:50:27 obachman Exp $";
    55info="
    66LIBRARY: standard.lib   PROCEDURES WHICH ARE ALWAYS LOADED AT START-UP
     
    88 stdfglm(ideal[,ord])   standard basis of the ideal via fglm [and ordering ord]
    99 stdhilb(ideal)         standard basis of the ideal using the Hilbert function
     10 groebner(ideal/module) standard basis of ideal or module using a
     11                        heuristically choosen method
    1012";
    1113
     
    122124///////////////////////////////////////////////////////////////////////////////
    123125
     126proc groebner(def i, list #)
     127"USAGE: groebner(i) i ideal/module
     128RETURNS: standard basis of ideal or module which is computed using a
     129         heuristically choosen method:
     130         If the ordering of the current ring is a lokal ordering, or
     131         if it is a non-block ordering and the current ring has no
     132         parameters, then std(i) is returned. 
     133         Otherwise, i is mapped into a ring with no parameters and
     134         ordering dp, where its Hilbert series is computed. This is
     135         followed by a Hilbert-series based std computation in the
     136         original ring.
     137EXAMPLE: example groebner; shows an example"
     138{
     139  def P=basering;
     140  if (size(#) > 0)
     141  {
     142    if (system("with", "MP"))
     143    {
     144      if (typeof(#[1]) == "int")
     145      {
     146        int wait = #[1];
     147        int j, pid;
     148        string bs = nameof(basering);
     149        link l_fork = "MPtcp:fork";
     150        open(l_fork);
     151        write(l_fork, quote(system("pid")));
     152        pid = read(l_fork);
     153        write(l_fork, quote(groebner(eval(i))));
     154       
     155        for (j=0; j<wait; j++)
     156        {
     157          if (status(l_fork, "read", "ready", 1)) {break;}
     158        }
     159       
     160        if (status(l_fork, "read", "ready"))
     161        {
     162          def result = read(l_fork);
     163          if (bs != nameof(basering))
     164          {
     165            def PP = basering;
     166            setring P;
     167            def result = imap(PP, result);
     168            kill PP;
     169          }
     170          kill (l_fork);
     171        }
     172        else
     173        {
     174          ideal result;
     175          if (! defined(groebner_error))
     176          {
     177            int groebner_error;
     178            export groebner_error;
     179          }
     180          groebner_error = 1;
     181          "// ** groebner did not finish";
     182          j = system("sh", "kill " + string(pid));
     183        }
     184        return (result);
     185      }
     186      else
     187      {
     188        "// ** groebner needs int as 2nd arg";
     189      }
     190    }
     191    else
     192    {
     193      "// ** groebner with two args not supported in this configuration";
     194    }
     195  }
     196   string ordstr_P = ordstr(P);
     197
     198   if (find(ordstr_P,"s") > 0)
     199   {
     200     //spaeter den lokalen fall ueber lp oder aehnlich behandeln
     201      return(std(i));
     202   }
     203   
     204   int IsSimple_P;
     205   if (system("nblocks") <= 2)
     206   {
     207     if (find(ordstr_P, "M") <= 0)
     208     {
     209       IsSimple_P = 1;
     210     }
     211   }
     212   int npars_P = npars(P);
     213
     214   // return std if no parameters and (dp or wp)
     215   if ((npars_P == 0) && IsSimple_P)
     216   {
     217     if (find(ordstr_P, "d") > 0)
     218     {
     219       return (std(i));
     220     }
     221     if (find(ordstr_P,"w") > 0)
     222     {
     223       return (std(i));
     224     }
     225   }
     226
     227   // reset options
     228   intvec opt=option(get);
     229   int p_opt;
     230   string s_opt = option();
     231   option(none);
     232   // turn on option(prot) and/or option(mem), if previously set
     233   if (find(s_opt, "prot"))
     234   {
     235     option(prot);
     236     p_opt = 1;
     237   }
     238   if (find(s_opt, "mem"))
     239   {
     240     option(mem);
     241   }
     242   
     243   // construct ring in which first std computation is done
     244   string varstr_P = varstr(P);
     245   string parstr_P = parstr(P);
     246   int is_homog = (homog(i) && (npars_P == 0));
     247   
     248   string ri = "ring Phelp =" + string(char(P)) + ",(" + varstr_P;
     249   // parameters are converted to ring variables
     250   if (npars_P > 0)
     251   {
     252     ri = ri + "," + parstr_P;
     253   }
     254   // a homogenizing variable is added, if necessary
     255   if (! is_homog)
     256   {
     257     ri = ri + ",@t";
     258   }
     259   // ordering is set to (dp, C)
     260   ri = ri + "),(dp,C);";
     261
     262   // change the ring
     263   execute(ri);
     264   
     265   // get ideal from previous ring
     266   if (is_homog)
     267   {
     268     ideal qh = imap(P, i);
     269   }
     270   else
     271   {
     272     // and homogenize
     273     ideal qh=homog(imap(P,i),@t);
     274   }
     275   
     276   // compute std and hilbert series
     277   if (p_opt)
     278   {
     279     "std in " + ri[13, size(ri) - 13];
     280   }
     281   ideal qh1=std(qh);
     282   intvec hi=hilb(qh1,1);
     283
     284   if (is_homog && (npars_P == 0))
     285   {
     286     // no additional variables were introduced
     287     setring P; // can immediately change to original ring
     288     // simply compute std with hilbert series in original ring
     289     if (p_opt)
     290     {
     291       "std with hilb in basering";
     292       i = std(i, hi);
     293     }
     294   }
     295   else
     296   {
     297     // additional variables were introduced
     298     // need another intermediate ring
     299     ri = "ring Phelp1 =" + string(char(P))
     300       + ",(" + varstr(Phelp) + "),(" + ordstr_P;
     301     
     302     // for lp without parameters, we do not need a block ordering
     303     if ( ! (IsSimple_P && (npars_P + is_homog < 2) && find(ordstr_P, "l")))
     304     {
     305       // need block ordering
     306       ri = ri + ", dp(" + string(npars_P + is_homog) + ")";
     307     }
     308     ri = ri + ");";
     309     
     310     // change to intermediate ring
     311     execute(ri);
     312     ideal qh = imap(Phelp, qh);
     313     kill Phelp;
     314     if (p_opt)
     315     {
     316       "std with hilb in " + ri[14,size(ri)-14];
     317     }
     318     // compute std with Hilbert series
     319     qh = std(qh, hi);
     320     // subst 1 for homogenizing var
     321     if (!is_homog)
     322     {
     323       qh = subst(qh, @t, 1);
     324     }
     325     
     326     // go back to original ring
     327     setring P;
     328     // get ideal, delete zeros and clean SB
     329     i = imap(Phelp1,qh);
     330     i = simplify(i, 34);
     331     kill Phelp1;
     332   }
     333
     334   // clean-up time
     335   option(set, opt);
     336   if (find(s_opt, "redSB") > 0)
     337   {
     338     i=interred(i);
     339   }
     340   attrib(i, "isSB", 1);
     341   return (i);
     342}
     343example
     344{
     345  "EXAMPLE: "; echo = 2;
     346  ring r = 0, (a,b,c,d), lp;
     347  option(prot);
     348  ideal i = a+b+c+d, ab+ad+bc+cd, abc+abd+acd+bcd, abcd-1; // cyclic 4
     349  groebner(i);
     350  ring rp = (0, a, b), (c,d), lp;
     351  ideal i = imap(r, i);
     352  ideal j = groebner(i);
     353  option(noprot);
     354  j; simplify(j, 1); std(i);
     355}
     356
Note: See TracChangeset for help on using the changeset viewer.