Changeset 8bdcfe in git


Ignore:
Timestamp:
Mar 16, 2007, 2:27:19 PM (17 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
Children:
d7ec93557f184076889ab9000aba4beb6874988b
Parents:
d1b99911a64bbf04d1c52b7382f40a4c2061e39c
Message:
*hannes: format, optim. in groebner, res


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

Legend:

Unmodified
Added
Removed
  • Singular/LIB/standard.lib

    rd1b999 r8bdcfe  
    33//groebner mit Optionen versehen
    44//////////////////////////////////////////////////////////////////////////////
    5 version="$Id: standard.lib,v 1.89 2007-03-14 18:17:34 Singular Exp $";
     5version="$Id: standard.lib,v 1.90 2007-03-16 13:27:19 Singular Exp $";
    66category="Miscellaneous";
    77info="
     
    4040EXAMPLE: example stdfglm; shows an example"
    4141{
    42    if (nrows(i) > 1)
    43    {
    44       ERROR("first argument of 'stdfglm' must be an ideal");
    45    }
    46    string os;
    47    int s = size(#);
    48    def P= basering;
    49    string algorithm;
    50    int ii;
    51    for( ii=1; ii<=s; ii++)
    52    {
    53       if ( typeof(#[ii])== "string" )
     42  if (nrows(i) > 1)
     43  {
     44    ERROR("first argument of 'stdfglm' must be an ideal");
     45  }
     46  string os;
     47  int s = size(#);
     48  def P= basering;
     49  string algorithm;
     50  int ii;
     51  for( ii=1; ii<=s; ii++)
     52  {
     53    if ( typeof(#[ii])== "string" )
     54    {
     55      if ( #[ii]=="std" || #[ii]=="slimgb" )
    5456      {
    55          if ( #[ii]=="std" || #[ii]=="slimgb" )
    56          {
    57             algorithm =  #[ii];
    58             # = delete(#,ii);
    59             s = s-1;
    60             ii--;
    61          }
     57        algorithm =  #[ii];
     58        # = delete(#,ii);
     59        s--;
     60        ii--;
    6261      }
    63    }
    64 
    65    if( s > 0 && (typeof(#[1]) == "string") )
    66    {
    67       os = #[1];
    68       ideal Qideal = ideal(P);
    69       int sQ = size(Qideal);
    70       int sM = size(minpoly);
    71       if ( sM!=0 )
     62    }
     63  }
     64
     65  if( s > 0 && (typeof(#[1]) == "string") )
     66  {
     67    os = #[1];
     68    ideal Qideal = ideal(P);
     69    int sQ = size(Qideal);
     70    int sM = size(minpoly);
     71    if ( sM!=0 )
     72    {
     73      string mpoly = string(minpoly);
     74    }
     75    if (sQ!=0 )
     76    {
     77      execute("ring Rfglm=("+charstr(P)+"),("+varstr(P)+"),"+os+";");
     78      ideal Qideal = fetch(P,Qideal);
     79      qring Pfglm = groebner(Qideal,"std","slimgb");
     80    }
     81    else
     82    {
     83      execute("ring Pfglm=("+charstr(P)+"),("+varstr(P)+"),"+os+";");
     84    }
     85    if ( sM!=0 )
     86    {
     87      execute("minpoly="+mpoly+";");
     88    }
     89  }
     90  else
     91  {
     92    list BRlist = ringlist(P);
     93    int nvarP = nvars(P);
     94    intvec w;                       //for ringweights of basering P
     95    int k;
     96    for(k=1;  k <= nvarP; k++)
     97    {
     98      w[k]=deg(var(k));
     99    }
     100
     101    BRlist[3] = list();
     102    if( s==0 or (typeof(#[1]) != "string") )
     103    {
     104      if( w==1 )
    72105      {
    73          string mpoly = string(minpoly);
    74       }
    75       if (sQ!=0 )
    76       {
    77         execute("ring Rfglm=("+charstr(P)+"),("+varstr(P)+"),"+os+";");
    78         ideal Qideal = fetch(P,Qideal);
    79         qring Pfglm = groebner(Qideal,"std","slimgb");
     106        BRlist[3][1]=list("dp",w);
    80107      }
    81108      else
    82109      {
    83         execute("ring Pfglm=("+charstr(P)+"),("+varstr(P)+"),"+os+";");
     110        BRlist[3][1]=list("wp",w);
    84111      }
    85       if ( sM!=0 )
    86       {
    87         execute("minpoly="+mpoly+";");
    88       }
    89     }
    90     else
    91     {
    92       list BRlist = ringlist(P);
    93       int nvarP = nvars(P);
    94       intvec w;                       //for ringweights of basering P
    95       int k;
    96       for(k=1;  k <= nvarP; k++)
    97       {
    98         w[k]=deg(var(k));
    99       }
    100 
    101       BRlist[3] = list();
    102       if( s==0 or (typeof(#[1]) != "string") )
    103       {
    104         if( w==1 )
    105         {
    106            BRlist[3][1]=list("dp",w);
    107         }
    108         else
    109         {
    110            BRlist[3][1]=list("wp",w);
    111         }
    112         BRlist[3][2]=list("C",intvec(0));
    113         def Pfglm = ring(quotientList(BRlist));
    114         setring Pfglm;
    115       }
    116     }
    117     ideal i = fetch(P,i);
    118 
    119     intvec opt = option(get);            //save options
    120     option(redSB);
    121     if (size(algorithm) > 0)
    122     {
    123        i = groebner(i,algorithm);
    124     }
    125     else
    126     {
    127        i = groebner(i);
    128     }
    129     option(set,opt);
    130     setring P;
    131     return (fglm(Pfglm,i));
     112      BRlist[3][2]=list("C",intvec(0));
     113      def Pfglm = ring(quotientList(BRlist));
     114      setring Pfglm;
     115    }
     116  }
     117  ideal i = fetch(P,i);
     118
     119  intvec opt = option(get);            //save options
     120  option(redSB);
     121  if (size(algorithm) > 0)
     122  {
     123    i = groebner(i,algorithm);
     124  }
     125  else
     126  {
     127    i = groebner(i);
     128  }
     129  option(set,opt);
     130  setring P;
     131  return (fglm(Pfglm,i));
    132132}
    133133example
     
    182182  ideal Qideal = ideal(P);      //defining the quotient ideal if P is a qring
    183183  int was_qring;                //remembers if basering was a qring
    184   int is_homog = homog(Qideal); //remembers if Qideal was homog (homog(0)=1)
    185   is_homog = is_homog*homog(i); //check for homogeneity of i and Qideal
     184  int is_homog =homog(i);       //check for homogeneity of i and Qideal
    186185  if (size(Qideal) > 0)
    187186  {
     
    197196  for(k=1;  k<=nvarP; k++)
    198197  {
    199      w[k]=deg(var(k));
     198    w[k]=deg(var(k));
    200199  }
    201200  int neg=1-attrib (P,"global");
     
    210209  for (k=1; k<=size(#); k++)
    211210  {
    212      if (typeof(#[k]) == "intvec")
    213      {
    214         intvec hi = #[k];
    215      }
    216      if (typeof(#[k]) == "string")
    217      {
    218        method = method + "," + #[k];
    219      }
     211    if (typeof(#[k]) == "intvec")
     212    {
     213      intvec hi = #[k];
     214    }
     215    if (typeof(#[k]) == "string")
     216    {
     217      method = method + "," + #[k];
     218    }
    220219  }
    221220
     
    224223    for( k=ncols(i); k>0; k-- )
    225224    {
    226        i[k]=cleardenom(i[k]);
     225      i[k]=cleardenom(i[k]);
    227226    }
    228227  }
     
    231230//Note that quotient ideal of qring must be homogeneous too
    232231
    233    if( find(ordstr_P,"s") || find(ordstr_P,"M")
    234        || find(ordstr_P,"a") || (neg > 0) )
    235    {
    236       if( defined(hi) && is_homog )
    237       {
    238          if (p_opt){"std with given Hilbert function in basering";}
    239          return( std(i,hi,w) );
    240       }
    241       if (p_opt){"//--stdhilb not implemented, use std in basering";}
    242       //if ( neg )
    243       //{
    244       //  "//*** WARNING: non-positive ring weights, computation may not finish";
    245       //}
    246       return( std(i) );
    247    }
     232  if( find(ordstr_P,"s") || find(ordstr_P,"M")
     233      || find(ordstr_P,"a") || (neg > 0) )
     234  {
     235    if( defined(hi) && is_homog )
     236    {
     237      if (p_opt){"std with given Hilbert function in basering";}
     238      return( std(i,hi,w) );
     239    }
     240    if (p_opt){"//--stdhilb not implemented, use std in basering";}
     241    //if ( neg )
     242    //{
     243    //  "//*** WARNING: non-positive ring weights, computation may not finish";
     244    //}
     245    return( std(i) );
     246  }
    248247
    249248//------------------------ change to hilbRing ----------------------------
    250249
    251      list hiRi = hilbRing(i);  //The ground field of P and Philb coincide
    252      intvec W = hiRi[2];       //Philb has an extra variable @ or @(k)
    253      def Philb = hiRi[1];      //Philb is no qring and the predefined
    254      setring Philb;            //ideal/module Id(1) in Philb is homogeneous
    255                                //Parameters of P are not converted in Philb
     250  list hiRi = hilbRing(i);  //The ground field of P and Philb coincide
     251  intvec W = hiRi[2];       //Philb has an extra variable @ or @(k)
     252  def Philb = hiRi[1];      //Philb is no qring and the predefined
     253  setring Philb;            //ideal/module Id(1) in Philb is homogeneous
     254                            //Parameters of P are not converted in Philb
    256255//-------- compute Hilbert function of homogenized ideal in Philb ---------
    257256//Philb has only 1 block. There are three cases
    258257
    259      string algorithm;       //possibilities: std, slimgb, stdorslimgb
    260      //define algorithm:
    261      if( find(method,"std") && !find(method,"slimgb") )
    262      {
    263         algorithm = "std";
    264      }
    265      if( find(method,"slimgb") && !find(method,"std") )
    266      {
    267          algorithm = "slimgb";
    268      }
    269      if( find(method,"std") && find(method,"slimgb") ||
    270          (!find(method,"std") && !find(method,"slimgb")) )
    271      {
    272         algorithm = "stdorslimgb";
    273      }
    274 
    275      if ( algorithm=="std" || ( algorithm=="stdorslimgb" && char(P)>0 ) )
    276      {
    277         if (p_opt) {"std in ring " + string(Philb);}
    278         intvec hi = hilb( std(Id(1)),1,W );
    279      }
    280      if ( algorithm=="slimgb" || ( algorithm=="stdorslimgb" && char(P)==0 ) )
    281      {
    282         intvec hi = hilb(qslimgb(Id(1)),1,W);
    283      }
    284 
    285    //-------------- we need another intermediate ring Phelp ----------------
    286    //In Phelp we change the ordering from Philb, otherwise it coincides with
    287    //Philb, that is, it has in addition to P an extra homogenizing variable
    288    //with name @, resp. @(i) if @ and @(1), ..., @(i-1) are defined.
    289    //Phelp has the same ordering as P on common variables. In Phelp
    290    //a quotient ideal from P is added to the input
    291 
    292       list BRlist = ringlist(Philb);
    293       BRlist[3] = list();
    294       int so = size(ord_P);
    295       if( ord_P[so][1] =="c" || ord_P[so][1] =="C" )
    296       {
    297          list moduleord = ord_P[so];
    298          so = so-1;
    299       }
    300       for (k=1; k<=so; k++)
    301       {
    302          BRlist[3][k] = ord_P[k];
    303       }
    304 
    305       BRlist[3][so+1] = list("dp",1);
    306       w = w,1;
    307 
    308       if( defined(moduleord) )
    309       {
    310         BRlist[3][so+2] = moduleord;
    311       }
     258  string algorithm;       //possibilities: std, slimgb, stdorslimgb
     259  //define algorithm:
     260  if( find(method,"std") && !find(method,"slimgb") )
     261  {
     262    algorithm = "std";
     263  }
     264  if( find(method,"slimgb") && !find(method,"std") )
     265  {
     266    algorithm = "slimgb";
     267  }
     268  if( find(method,"std") && find(method,"slimgb") ||
     269    (!find(method,"std") && !find(method,"slimgb")) )
     270  {
     271    algorithm = "stdorslimgb";
     272  }
     273
     274  if ( algorithm=="std" || ( algorithm=="stdorslimgb" && char(P)>0 ) )
     275  {
     276    if (p_opt) {"std in ring " + string(Philb);}
     277    intvec hi = hilb( std(Id(1)),1,W );
     278  }
     279  if ( algorithm=="slimgb" || ( algorithm=="stdorslimgb" && char(P)==0 ) )
     280  {
     281    intvec hi = hilb(qslimgb(Id(1)),1,W);
     282  }
     283
     284  //-------------- we need another intermediate ring Phelp ----------------
     285  //In Phelp we change the ordering from Philb, otherwise it coincides with
     286  //Philb, that is, it has in addition to P an extra homogenizing variable
     287  //with name @, resp. @(i) if @ and @(1), ..., @(i-1) are defined.
     288  //Phelp has the same ordering as P on common variables. In Phelp
     289  //a quotient ideal from P is added to the input
     290
     291  list BRlist = ringlist(Philb);
     292  BRlist[3] = list();
     293  int so = size(ord_P);
     294  if( ord_P[so][1] =="c" || ord_P[so][1] =="C" )
     295  {
     296    list moduleord = ord_P[so];
     297    so = so-1;
     298  }
     299  for (k=1; k<=so; k++)
     300  {
     301    BRlist[3][k] = ord_P[k];
     302  }
     303
     304  BRlist[3][so+1] = list("dp",1);
     305  w = w,1;
     306
     307  if( defined(moduleord) )
     308  {
     309    BRlist[3][so+2] = moduleord;
     310  }
    312311
    313312//------ change to extended ring and compute std with hilbert series ------
    314       def Phelp = ring(quotientList(BRlist));
    315       setring Phelp;
    316       def i = imap(Philb, Id(1));
    317       kill Philb;
    318 
    319       // compute std with Hilbert series
    320       if (w ==1)
    321       {
    322          if (p_opt){ "std with hilb in " + string(Phelp);}
    323          i = std(i, hi);
    324       }
    325       else
    326       {
    327          if(p_opt){"std with weighted hilb in "+string(Phelp);}
    328          i = std(i, hi, w);
    329       }
     313  def Phelp = ring(quotientList(BRlist));
     314  setring Phelp;
     315  def i = imap(Philb, Id(1));
     316  kill Philb;
     317
     318  // compute std with Hilbert series
     319  if (w ==1)
     320  {
     321    if (p_opt){ "std with hilb in " + string(Phelp);}
     322    i = std(i, hi);
     323  }
     324  else
     325  {
     326    if(p_opt){"std with weighted hilb in "+string(Phelp);}
     327    i = std(i, hi, w);
     328  }
    330329
    331330//-------------------- go back to original ring ---------------------------
    332  //The main computation is done. Do not forget to simplfy before maping.
    333 
    334       // subst 1 for homogenizing var
    335       if ( p_opt )
    336       {
    337           "dehomogenization";
    338       }
    339       i = subst(i, var(nvars(basering)), 1);
    340 
    341        if (p_opt)
    342        {
    343          "simplification";
    344        }
    345        i= simplify(i,34);
    346 
    347        setring P;
    348        if (p_opt)
    349        {
    350          "imap to ring "+string(P);
    351        }
    352        i = imap(Phelp,i);
    353        kill Phelp;
    354        if( was_qring)
    355        {
    356          i = NF(i,std(0));
    357        }
    358        i = simplify(i,34);
    359 
    360        // compute reduced SB
    361        if (find(s_opt, "redSB") > 0)
    362        {
    363          if (p_opt)
    364          {
    365            "//interreduction";
    366          }
    367          i=interred(i);
    368        }
    369        attrib(i, "isSB", 1);
    370        return (i);
     331//The main computation is done. Do not forget to simplfy before maping.
     332
     333  // subst 1 for homogenizing var
     334  if ( p_opt ) { "dehomogenization"; }
     335  i = subst(i, var(nvars(basering)), 1);
     336
     337  if (p_opt) { "simplification"; }
     338  i= simplify(i,34);
     339
     340  setring P;
     341  if (p_opt) { "imap to ring "+string(P); }
     342  i = imap(Phelp,i);
     343  kill Phelp;
     344  if( was_qring)
     345  {
     346    i = NF(i,std(0));
     347  }
     348  i = simplify(i,34);
     349
     350  // compute reduced SB
     351  if (find(s_opt, "redSB") > 0)
     352  {
     353    if (p_opt) { "//interreduction"; }
     354    i=interred(i);
     355  }
     356  attrib(i, "isSB", 1);
     357  return (i);
    371358}
    372359example
     
    405392EXAMPLE: example quotientList; shows an example"
    406393{
    407    def P = basering;
    408    if( size(#) > 0 )
    409    {
    410       if ( #[1] == "isSB")
    411       {
    412          return (RL);
    413       }
    414    }
    415    ideal Qideal  = RL[4];  //##Achtung: falls basering Nullteiler hat, kann
     394  def P = basering;
     395  if( size(#) > 0 )
     396  {
     397    if ( #[1] == "isSB")
     398    {
     399      return (RL);
     400    }
     401  }
     402  ideal Qideal  = RL[4];  //##Achtung: falls basering Nullteiler hat, kann
    416403                           //die SB eines Elements mehrere Elemente enthalten
    417    if( size(Qideal) <= 0)
    418    {
    419       return (RL);
    420    }
    421 
    422    RL[4] = ideal(0);
    423    def Phelp = ring(RL);
    424    setring Phelp;
    425    ideal Qideal = groebner(fetch(P,Qideal));
    426    setring P;
    427    RL[4]=fetch(Phelp,Qideal);
    428    return (RL);
     404  if( size(Qideal) <= 0)
     405  {
     406    return (RL);
     407  }
     408
     409  RL[4] = ideal(0);
     410  def Phelp = ring(RL);
     411  setring Phelp;
     412  ideal Qideal = groebner(fetch(P,Qideal));
     413  setring P;
     414  RL[4]=fetch(Phelp,Qideal);
     415  return (RL);
    429416}
    430417example
     
    459446EXAMPLE: example par2varRing; shows an example"
    460447{
    461    def P = basering;
    462    int npar = npars(P);  //number of parameters
    463    int s = size(#);
    464    int ii;
    465    if ( npar == 0)
    466    {
    467      dbprint(printlevel-voice+3,"// ** no parameters, ring was not changed");
    468      for( ii = 1; ii <= s; ii++)
    469      {
    470         def Id(ii) = #[ii];
    471         export (Id(ii));
    472      }
    473      return(list(P));
    474    }
    475 
    476    list rlist = ringlist(P);
    477    list parlist = rlist[1];
    478    rlist[1] = parlist[1];
    479    poly Minpoly = minpoly;     //check for minpoly:
    480    int sm = size(Minpoly);
    481 
    482    //now create new ring
    483    for( ii = 1; ii <= s; ii++)
    484    {
     448  def P = basering;
     449  int npar = npars(P);  //number of parameters
     450  int s = size(#);
     451  int ii;
     452  if ( npar == 0)
     453  {
     454    dbprint(printlevel-voice+3,"// ** no parameters, ring was not changed");
     455    for( ii = 1; ii <= s; ii++)
     456    {
    485457      def Id(ii) = #[ii];
    486    }
    487    int nvar = size(rlist[2]);
    488    int nblock = size(rlist[3]);
    489    int k;
    490    for (k=1; k<=npar; k++)
    491    {
    492       rlist[2][nvar+k] = parlist[2][k];   //change variable list
    493    }
    494 
    495    //converted parameters get one block dp. If module ordering was in front
    496    //it stays in front, otherwise it will be moved to the end
    497    intvec OW = 1:npar;
    498    if( rlist[3][nblock][1] =="c" || rlist[3][nblock][1] =="C" )
    499    {
    500       rlist[3][nblock+1] = rlist[3][nblock];
    501       rlist[3][nblock] = list("dp",OW);
    502    }
    503    else
    504    {
    505       rlist[3][nblock+1] = list("dp",OW);
    506    }
    507 
    508    def Ppar2var = ring(quotientList(rlist));
    509    setring Ppar2var;
    510    if ( sm == 0 )
    511    {
    512       for( ii = 1; ii <= s; ii++)
    513       {
    514         def Id(ii) = imap(P,Id(ii));
    515         export (Id(ii));
    516       }
    517    }
    518    else
    519    {
    520       if( find(option(),"prot") ){"//add minpoly to input";}
    521       poly Minpoly = imap(P,Minpoly);
    522       for( ii = 1; ii <= s; ii++)
    523       {
    524         def Id(ii) = imap(P,Id(ii));
    525         Id(ii) = Id(ii),Minpoly*freemodule(nrows(Id(ii)));
    526         export (Id(ii));
    527       }
    528    }
    529    list Lpar2var = Ppar2var;
    530    return(Lpar2var);
     458      export (Id(ii));
     459    }
     460    return(list(P));
     461  }
     462
     463  list rlist = ringlist(P);
     464  list parlist = rlist[1];
     465  rlist[1] = parlist[1];
     466  poly Minpoly = minpoly;     //check for minpoly:
     467  int sm = size(Minpoly);
     468
     469  //now create new ring
     470  for( ii = 1; ii <= s; ii++)
     471  {
     472    def Id(ii) = #[ii];
     473  }
     474  int nvar = size(rlist[2]);
     475  int nblock = size(rlist[3]);
     476  int k;
     477  for (k=1; k<=npar; k++)
     478  {
     479    rlist[2][nvar+k] = parlist[2][k];   //change variable list
     480  }
     481
     482  //converted parameters get one block dp. If module ordering was in front
     483  //it stays in front, otherwise it will be moved to the end
     484  intvec OW = 1:npar;
     485  if( rlist[3][nblock][1] =="c" || rlist[3][nblock][1] =="C" )
     486  {
     487    rlist[3][nblock+1] = rlist[3][nblock];
     488    rlist[3][nblock] = list("dp",OW);
     489  }
     490  else
     491  {
     492    rlist[3][nblock+1] = list("dp",OW);
     493  }
     494
     495  def Ppar2var = ring(quotientList(rlist));
     496  setring Ppar2var;
     497  if ( sm == 0 )
     498  {
     499    for( ii = 1; ii <= s; ii++)
     500    {
     501      def Id(ii) = imap(P,Id(ii));
     502      export (Id(ii));
     503    }
     504  }
     505  else
     506  {
     507    if( find(option(),"prot") ){"//add minpoly to input";}
     508    poly Minpoly = imap(P,Minpoly);
     509    for( ii = 1; ii <= s; ii++)
     510    {
     511      def Id(ii) = imap(P,Id(ii));
     512      Id(ii) = Id(ii),Minpoly*freemodule(nrows(Id(ii)));
     513      export (Id(ii));
     514    }
     515  }
     516  list Lpar2var = Ppar2var;
     517  return(Lpar2var);
    531518}
    532519example
     
    566553"
    567554{
    568    def P = basering;
    569    ideal Qideal = ideal(P);    //defining the quotient ideal if P is a qring
    570    if( size(Qideal) != 0 )
    571    {
    572      int is_qring =1;
    573    }
    574    list BRlist = ringlist(P);
    575    BRlist[4] = ideal(0);
    576 
    577    int nvarP = nvars(P);
    578    int s = size(#);
    579    intvec w;                   //for ringweights of basering P
    580    int k;
    581    for(k=1;  k<=nvarP; k++)
    582    {
    583        w[k]=deg(var(k));
    584    }
    585 
    586    for(k = 1; k <= s; k++)
    587    {
    588       def Id(k) = #[k];
    589       int nr(k) = nrows(Id(k));
    590    }
    591 
    592     // a homogenizing variable is added:
    593     // call it @, resp. @(k) if @(1),...,@(k-1) are defined
    594     string homvar;
    595     if ( defined(@)==0 )
    596     {
    597        homvar = "@";
    598     }
    599     else
    600     {
    601        k=1;
    602        while( defined(@(k)) != 0 )
    603        {
    604           k++;
    605        }
    606        homvar = "@("+string(k)+")";
    607     }
    608     BRlist[2][nvarP+1] = homvar;
    609     w[nvarP +1]=1;
    610 
    611     //ordering is set to (dp,C) if weights of all variables are 1
    612     //resp. to (wp(w,1),C) where w are the ringweights of basering P
    613     //homogenizing var gets weight 1:
    614 
    615     BRlist[3] = list();
    616     if(w==1)
    617     {
    618       BRlist[3][1]=list("dp",w);
    619     }
    620     else
    621     {
    622       BRlist[3][1]=list("wp",w);
    623     }
    624     BRlist[3][2]=list("C",intvec(0));
    625 
    626     //change ring and get ideal from previous ring
    627     def Philb = ring(quotientList(BRlist));
    628     kill BRlist;
    629     setring Philb;
    630     if( defined(is_qring) )
    631     {
    632        ideal @Qidealhilb@ =  homog( imap(P,Qideal), `homvar` );
    633        export(@Qidealhilb@);
    634 
    635        if( find(option(),"prot") ){"add quotient ideal to input";}
    636        for(k = 1; k <= s; k++)
    637        {  //homogenize
    638           def Id(k) =  homog( imap(P,Id(k)), `homvar` );
    639               Id(k) =  Id(k),@Qidealhilb@*freemodule(nr(k)) ;
    640           export(Id(k));
    641        }
    642     }
    643     else
    644     {
    645         for(k = 1; k <= s; k++)
    646         { //homogenize
    647             def Id(k) =  homog( imap(P,Id(k)), `homvar` );
    648             export(Id(k));
    649         }
    650     }
    651     list Lhilb = Philb,w;
    652     return(Lhilb);
     555  def P = basering;
     556  ideal Qideal = ideal(P);    //defining the quotient ideal if P is a qring
     557  if( size(Qideal) != 0 )
     558  {
     559    int is_qring =1;
     560  }
     561  list BRlist = ringlist(P);
     562  BRlist[4] = ideal(0);
     563
     564  int nvarP = nvars(P);
     565  int s = size(#);
     566  intvec w;                   //for ringweights of basering P
     567  int k;
     568  for(k=1;  k<=nvarP; k++)
     569  {
     570    w[k]=deg(var(k));
     571  }
     572
     573  for(k = 1; k <= s; k++)
     574  {
     575    def Id(k) = #[k];
     576    int nr(k) = nrows(Id(k));
     577  }
     578
     579  // a homogenizing variable is added:
     580  // call it @, resp. @(k) if @(1),...,@(k-1) are defined
     581  string homvar;
     582  if ( defined(@)==0 )
     583  {
     584    homvar = "@";
     585  }
     586  else
     587  {
     588    k=1;
     589    while( defined(@(k)) != 0 )
     590    {
     591      k++;
     592    }
     593    homvar = "@("+string(k)+")";
     594  }
     595  BRlist[2][nvarP+1] = homvar;
     596  w[nvarP +1]=1;
     597
     598  //ordering is set to (dp,C) if weights of all variables are 1
     599  //resp. to (wp(w,1),C) where w are the ringweights of basering P
     600  //homogenizing var gets weight 1:
     601
     602  BRlist[3] = list();
     603  BRlist[3][2]=list("C",intvec(0));
     604  if(w==1)
     605  {
     606    BRlist[3][1]=list("dp",w);
     607  }
     608  else
     609  {
     610    BRlist[3][1]=list("wp",w);
     611  }
     612
     613  //change ring and get ideal from previous ring
     614  def Philb = ring(quotientList(BRlist));
     615  kill BRlist;
     616  setring Philb;
     617  if( defined(is_qring) )
     618  {
     619    ideal @Qidealhilb@ =  homog( imap(P,Qideal), `homvar` );
     620    export(@Qidealhilb@);
     621
     622    if( find(option(),"prot") ){"add quotient ideal to input";}
     623    for(k = 1; k <= s; k++)
     624    {  //homogenize
     625      def Id(k) =  homog( imap(P,Id(k)), `homvar` );
     626      Id(k) =  Id(k),@Qidealhilb@*freemodule(nr(k)) ;
     627      export(Id(k));
     628    }
     629  }
     630  else
     631  {
     632    for(k = 1; k <= s; k++)
     633    { //homogenize
     634      def Id(k) =  homog( imap(P,Id(k)), `homvar` );
     635      export(Id(k));
     636    }
     637  }
     638  list Lhilb = Philb,w;
     639  return(Lhilb);
    653640}
    654641example
     
    679666EXAMPLE: example qslimgb; shows an example"
    680667{
    681     def P = basering;
    682     ideal Qideal = ideal(P);      //defining the quotient ideal if P is a qring
    683     int p_opt;
    684     if( find(option(),"prot") )
    685     {
    686       p_opt=1;
    687     }
    688     if (size(Qideal) == 0)
    689     {
    690       if (p_opt)
    691       {
    692          "slimgb in ring " + string(P);
    693       }
    694       return(slimgb(i));
    695     }
    696 
    697     //case of a qring; since slimgb does not know qrings we
    698     //delete the quotient ideal and add it to i
    699 
    700     list BRlist = ringlist(P);
    701     BRlist[4] = ideal(0);
    702     def Phelp = ring(BRlist);
    703     kill BRlist;
    704     setring Phelp;
    705     // module case:
    706     def iq = imap(P,i);
    707     iq = iq, imap(P,Qideal)*freemodule(nrows(iq));
    708     if (p_opt)
    709     {
    710        "slimgb in ring " + string(Phelp);
    711        "(with quotient ideal added to input)";
    712     }
    713     iq = slimgb(iq);
    714 
    715     setring P;
    716     if (p_opt)
    717     {
    718        "//imap to original ring";
    719     }
    720     i = imap(Phelp,iq);
    721     kill Phelp;
    722 
    723     if (find(option(),"redSB") > 0)
    724     {
    725        if (p_opt)
    726        {
    727          "//interreduction";
    728        }
    729        i=interred(i);
    730     }
    731     attrib(i, "isSB", 1);
    732     return (i);
     668  def P = basering;
     669  ideal Qideal = ideal(P);      //defining the quotient ideal if P is a qring
     670  int p_opt;
     671  if( find(option(),"prot") )
     672  {
     673    p_opt=1;
     674  }
     675  if (size(Qideal) == 0)
     676  {
     677    if (p_opt) { "slimgb in ring " + string(P); }
     678    return(slimgb(i));
     679  }
     680
     681  //case of a qring; since slimgb does not know qrings we
     682  //delete the quotient ideal and add it to i
     683
     684  list BRlist = ringlist(P);
     685  BRlist[4] = ideal(0);
     686  def Phelp = ring(BRlist);
     687  kill BRlist;
     688  setring Phelp;
     689  // module case:
     690  def iq = imap(P,i);
     691  iq = iq, imap(P,Qideal)*freemodule(nrows(iq));
     692  if (p_opt)
     693  {
     694    "slimgb in ring " + string(Phelp);
     695    "(with quotient ideal added to input)";
     696  }
     697  iq = slimgb(iq);
     698
     699  setring P;
     700  if (p_opt) { "//imap to original ring"; }
     701  i = imap(Phelp,iq);
     702  kill Phelp;
     703
     704  if (find(option(),"redSB") > 0)
     705  {
     706    if (p_opt) { "//interreduction"; }
     707    i=interred(i);
     708  }
     709  attrib(i, "isSB", 1);
     710  return (i);
    733711}
    734712example
     
    788766KEYWORDS: time limit on computations; MP, groebner basis computations
    789767EXAMPLE: example groebner;  shows an example"
    790 {
    791 
     768
     769{
    792770//Vorgabe einer Teilmenge aus {hilb,fglm,par2var,std,slimgb}
    793771//Aktuelle Einstellungen (Jan 2007):
     
    928906  ideal Qideal = ideal(P);      //defining the quotient ideal if P is a qring
    929907  int was_qring;                //remembers if basering was a qring
    930   int is_homog = homog(Qideal); //remembers if Qideal was homog (homog(0)=1)
     908  //int is_homog = 1;
    931909  if (size(Qideal) > 0)
    932910  {
    933911     was_qring = 1;
     912     //is_homog = homog(Qideal); //remembers if Qideal was homog (homog(0)=1)
    934913  }
    935914  list BRlist = ringlist(P);
     
    957936//local or mixed orderings, matrix orderings, extra weight vector and modules
    958937
    959   if(  ( find(ordstr_P,"s") > 0 )
    960     || ( find(ordstr_P,"M") > 0 )
     938  if(  //( find(ordstr_P,"s") > 0 ) || // covered by neg
     939      ( find(ordstr_P,"M") > 0 )
    961940    || ( find(ordstr_P,"a") > 0 )
    962941    || ( neg>0 ) )
     
    971950
    972951 //------------------ classify the possible settings ---------------------
    973  string algorithm;       //possibilities: std, slimgb, stdorslimgb
    974  string conversion;      //possibilities: hilb, fglm, hilborfglm, no
    975  string partovar;        //possibilities: yes, no
    976  string order;           //possibilities: simple, !simple
    977  string direct;          //possibilities: yes, no
     952  string algorithm;       //possibilities: std, slimgb, stdorslimgb
     953  string conversion;      //possibilities: hilb, fglm, hilborfglm, no
     954  string partovar;        //possibilities: yes, no
     955  string order;           //possibilities: simple, !simple
     956  string direct;          //possibilities: yes, no
    978957
    979958  //define algorithm:
    980959  if( find(method,"std") && !find(method,"slimgb") )
    981960  {
    982      algorithm = "std";
     961    algorithm = "std";
    983962  }
    984963  if( find(method,"slimgb") && !find(method,"std") )
    985964  {
    986      algorithm = "slimgb";
     965    algorithm = "slimgb";
    987966  }
    988967  if( find(method,"std") && find(method,"slimgb") ||
    989968      (!find(method,"std") && !find(method,"slimgb")) )
    990969  {
    991      algorithm = "stdorslimgb";
     970    algorithm = "stdorslimgb";
    992971  }
    993972
     
    999978  if( find(method,"fglm") && !find(method,"hilb") )
    1000979  {
    1001      conversion = "fglm";
     980    conversion = "fglm";
    1002981  }
    1003982  if( find(method,"fglm") && find(method,"hilb") )
    1004983  {
    1005      conversion = "hilborfglm";
     984    conversion = "hilborfglm";
    1006985  }
    1007986  if( !find(method,"fglm") && !find(method,"hilb") )
    1008987  {
    1009      conversion = "no";
     988    conversion = "no";
    1010989  }
    1011990
     
    10361015            (find(method,"std") && find(method,"slimgb")) ) ) )
    10371016  {
    1038      direct = "yes";
     1017    direct = "yes";
    10391018  }
    10401019  else
    10411020  {
    1042      direct = "no";
     1021    direct = "no";
    10431022  }
    10441023
     
    10571036  if ( direct == "yes" )
    10581037  {
    1059      if ( algorithm=="std" || (algorithm=="stdorslimgb" && char(P)>0) )
    1060      {
    1061            if (p_opt) { "std in " + string(P); }
    1062            i = std(i);
    1063            return(i);
    1064      }
    1065      if ( algorithm=="slimgb" || (algorithm=="stdorslimgb" && char(P)==0) )
    1066      {
    1067            i = qslimgb(i);
    1068            return(i);
    1069      }
     1038    if ( algorithm=="std" || (algorithm=="stdorslimgb" && char(P)>0) )
     1039    {
     1040      if (p_opt) { "std in " + string(P); }
     1041      return(std(i));
     1042    }
     1043    if ( algorithm=="slimgb" || (algorithm=="stdorslimgb" && char(P)==0) )
     1044    {
     1045      return(qslimgb(i));
     1046    }
    10701047  }
    10711048
     
    10791056
    10801057//------------ case where no parameters are made to variables  -------------
    1081    if (  partovar == "no" && conversion == "hilb"
    1082      || (partovar == "no" && conversion == "fglm" )
    1083      || (partovar == "no" && conversion == "hilborfglm" )
    1084      || (partovar == "no" && conversion == "no" && direct == "no") )
    1085         //last case: heuristic
    1086    {
    1087      if ( conversion=="fglm" )
    1088      {
    1089        if ( algorithm=="std" || (algorithm=="stdorslimgb" && char(P)>0) )
    1090        {
    1091          return (stdfglm(i,"std"));
    1092        }
    1093        if ( algorithm=="slimgb" || (algorithm=="stdorslimgb" && char(P)==0) )
    1094        {
    1095          return (stdfglm(i,"slimgb"));
    1096        }
    1097      }
    1098      else
    1099      {
    1100        if ( algorithm=="std" || (algorithm=="stdorslimgb" && char(P)>0) )
    1101        {
    1102          return (stdhilb(i,"std"));
    1103        }
    1104        if ( algorithm=="slimgb" || (algorithm=="stdorslimgb" && char(P)==0) )
    1105        {
    1106          return (stdhilb(i,"slimgb"));
    1107        }
    1108      }
    1109    }
     1058  if (  partovar == "no" && conversion == "hilb"
     1059    || (partovar == "no" && conversion == "fglm" )
     1060    || (partovar == "no" && conversion == "hilborfglm" )
     1061    || (partovar == "no" && conversion == "no" && direct == "no") )
     1062  //last case: heuristic
     1063  {
     1064    if ( conversion=="fglm" )
     1065    {
     1066      if ( algorithm=="std" || (algorithm=="stdorslimgb" && char(P)>0) )
     1067      {
     1068        return (stdfglm(i,"std"));
     1069      }
     1070      if ( algorithm=="slimgb" || (algorithm=="stdorslimgb" && char(P)==0) )
     1071      {
     1072        return (stdfglm(i,"slimgb"));
     1073      }
     1074    }
     1075    else
     1076    {
     1077      if ( algorithm=="std" || (algorithm=="stdorslimgb" && char(P)>0) )
     1078      {
     1079        return (stdhilb(i,"std"));
     1080      }
     1081      if ( algorithm=="slimgb" || (algorithm=="stdorslimgb" && char(P)==0) )
     1082      {
     1083        return (stdhilb(i,"slimgb"));
     1084      }
     1085    }
     1086  }
    11101087
    11111088//------------ case where parameters are made to variables  ----------------
    11121089//define a ring Phelp via par2varRing in which the parameters are variables
    11131090
    1114    else
    1115    {
    1116       // reset options
    1117       option(none);
    1118       // turn on options prot, mem, redSB, intStrategy if previously set
    1119       if ( find(s_opt, "prot") )
     1091  else
     1092  {
     1093    // reset options
     1094    option(none);
     1095    // turn on options prot, mem, redSB, intStrategy if previously set
     1096    if ( find(s_opt, "prot") )
    11201097      { option(prot); }
    1121       if ( find(s_opt, "mem") )
     1098    if ( find(s_opt, "mem") )
    11221099      { option(mem); }
    1123       if ( find(s_opt, "redSB") )
     1100    if ( find(s_opt, "redSB") )
    11241101      { option(redSB); }
    1125       if ( find(s_opt, "intStrategy") )
     1102    if ( find(s_opt, "intStrategy") )
    11261103      { option(intStrategy); }
    11271104
    1128       is_homog = is_homog*homog(i); //check for homogeneity of i and Qideal
    1129 
    1130      //first clear denominators of parameters
    1131       if (npars_P > 0)
     1105    //first clear denominators of parameters
     1106    if (npars_P > 0)
     1107    {
     1108      for( k=ncols(i); k>0; k-- )
     1109      { i[k]=cleardenom(i[k]); }
     1110    }
     1111
     1112    def Phelp = par2varRing(i)[1];   //minpoly is mapped with i
     1113    setring Phelp;
     1114    def i = Id(1);
     1115    //is_homog = homog(i);
     1116
     1117    //If parameters are converted to ring variables, they appear in an extra
     1118    //block. Therefore we use always hilb for this block ordering:
     1119    if ( conversion=="fglm" )
     1120    {
     1121      i = (stdfglm(i));       //only uesful for 1 parameter with minpoly
     1122    }
     1123    else
     1124    {
     1125      if ( algorithm=="std" || (algorithm=="stdorslimgb" && char(P)>0) )
    11321126      {
    1133          for( k=ncols(i); k>0; k-- )
    1134          { i[k]=cleardenom(i[k]); }
     1127        i = stdhilb(i,"std");
    11351128      }
    1136 
    1137       def Phelp = par2varRing(i)[1];   //minpoly is mapped with i
    1138       setring Phelp;
    1139       def i = Id(1);
    1140       is_homog = homog(i);
    1141 
    1142       //If parameters are converted to ring variables, they appear in an extra
    1143       //block. Therefore we use always hilb for this block ordering:
    1144       if ( conversion=="fglm" )
     1129      if ( algorithm=="slimgb" || (algorithm=="stdorslimgb" && char(P)==0) )
    11451130      {
    1146          i = (stdfglm(i));       //only uesful for 1 parameter with minpoly
     1131        i = stdhilb(i,"slimgb");
    11471132      }
    1148       else
    1149       {
    1150         if ( algorithm=="std" || (algorithm=="stdorslimgb" && char(P)>0) )
    1151         {
    1152            i = stdhilb(i,"std");
    1153         }
    1154         if ( algorithm=="slimgb" || (algorithm=="stdorslimgb" && char(P)==0) )
    1155         {
    1156            i = stdhilb(i,"slimgb");
    1157         }
    1158       }
    1159    }
     1133    }
     1134  }
    11601135
    11611136//-------------------- go back to original ring ---------------------------
     
    11641139//to the basering.
    11651140
    1166        if (p_opt)
    1167        {
    1168          "//simplification";
    1169        }
    1170 
    1171        if (was_minpoly)
    1172        {
    1173           ideal Minpoly = imap(P,Minpoly);
    1174           attrib(Minpoly,"isSB",1);
    1175           i = simplify(NF(i,Minpoly),2);
    1176        }
    1177 
    1178        def Li = lead(i);
    1179        setring P;
    1180        def Li = imap(Phelp,Li);
    1181        Li = simplify(Li,32);
    1182        intvec vi;
    1183        for (k=1; k<=ncols(Li); k++)
    1184        {
    1185          vi[k] = Li[k]==0;
    1186        }
    1187 
    1188        setring Phelp;
    1189        for (k=1;  k<=size(i) ;k++)
    1190        {
    1191            if(vi[k]==1)
    1192            {
    1193               i[k]=0;
    1194            }
    1195        }
    1196        i = simplify(i,2);
    1197 
    1198        setring P;
    1199        if (p_opt)
    1200        {
    1201          "//imap to original ring";
    1202        }
    1203        i = imap(Phelp,i);
    1204        kill Phelp;
    1205        i = simplify(i,34);
    1206 
    1207        // clean-up time
    1208        option(set, opt);
    1209        if (find(s_opt, "redSB") > 0)
    1210        {
    1211          if (p_opt)
    1212          {
    1213            "//interreduction";
    1214          }
    1215          i=interred(i);
    1216        }
    1217        attrib(i, "isSB", 1);
    1218        return (i);
     1141  if (p_opt) { "//simplification"; }
     1142
     1143  if (was_minpoly)
     1144  {
     1145    ideal Minpoly = imap(P,Minpoly);
     1146    attrib(Minpoly,"isSB",1);
     1147    i = simplify(NF(i,Minpoly),2);
     1148  }
     1149
     1150  def Li = lead(i);
     1151  setring P;
     1152  def Li = imap(Phelp,Li);
     1153  Li = simplify(Li,32);
     1154  intvec vi;
     1155  for (k=1; k<=ncols(Li); k++)
     1156  {
     1157    vi[k] = Li[k]==0;
     1158  }
     1159
     1160  setring Phelp;
     1161  for (k=1;  k<=size(i) ;k++)
     1162  {
     1163    if(vi[k]==1)
     1164    {
     1165      i[k]=0;
     1166    }
     1167  }
     1168  i = simplify(i,2);
     1169
     1170  setring P;
     1171  if (p_opt) { "//imap to original ring"; }
     1172  i = imap(Phelp,i);
     1173  kill Phelp;
     1174  i = simplify(i,34);
     1175
     1176  // clean-up time
     1177  option(set, opt);
     1178  if (find(s_opt, "redSB") > 0)
     1179  {
     1180    if (p_opt) { "//interreduction"; }
     1181    i=interred(i);
     1182  }
     1183  attrib(i, "isSB", 1);
     1184  return (i);
    12191185}
    12201186example
Note: See TracChangeset for help on using the changeset viewer.