Changeset e7c67af in git


Ignore:
Timestamp:
Mar 29, 2011, 4:12:19 PM (12 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
Children:
166ebd23be74a96b55b07ae3ee7b95a6fff5d62a
Parents:
bc4941560856aa3e6fb913d32837d1d18ad1e01e
Message:
FIX: pushForward/getLattice by eliminating dangerous 'defined()'-calls
*Lars Kastner: Added comments to pushForward.

From: Oleksandr Motsak <motsak@mathematik.uni-kl.de>

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

Legend:

Unmodified
Added
Removed
  • Singular/LIB/multigrading.lib

    rbc49415 re7c67af  
    308308    }
    309309  }
    310   if( !defined(S) )
    311   {}
    312310*/
    313311
     
    318316
    319317  def H = attrib(L, attrGroupHNF);
    320   if( !defined(H) || typeof(H) != "intmat")
     318  if( typeof(H) != "intmat")
    321319  {
    322320    attrib(L, attrGroupHNF, hermiteNormalForm(L));
     
    324322
    325323  def HH = attrib(L, attrGroupSNF);
    326   if( !defined(HH) || typeof(HH) != "intmat")
     324  if( typeof(HH) != "intmat")
    327325  {
    328326    attrib(L, attrGroupSNF, smithNormalForm(L));
     
    470468  string attrGradingGroup = "gradingGroup";
    471469
    472   if( size(#) > 0 )
    473   {
    474     if( typeof(#[1]) == "intmat" )
    475     {
    476       def L = createGroup(M, #[1]);
    477     }
    478 
    479     if( isGroup(#[1]) )
    480     {
    481       def L = #[1];
     470  int i = 1;
     471  if( size(#) >= i )
     472  {
     473    def a = #[i];
     474    if( typeof(a) == "intmat" )
     475    {
     476      def L = createGroup(M, a);
     477      i++;
     478    }
     479
     480    if( isGroup(a) )
     481    {
     482      def L = a;
    482483
    483484      if( !isSublattice(M, L[1]) )
     
    485486        ERROR("Multigrading is not contained in the grading group!");
    486487      }
    487     }
     488      i++;
     489    }
     490    if( i == 1 ){ ERROR("Wrong arguments: no group given?"); }
     491    kill a;
    488492  }
    489493  else
     
    492496  }
    493497
    494   if( !defined(L) ){ ERROR("Wrong arguments: no group given?"); }
    495498
    496499  attrib(basering, attrMgrad, M);
    497500  attrib(basering, attrGradingGroup, L);
    498501
    499   ideal Q = ideal(basering);
    500   if( !isHomogeneous(Q) ) // easy now, but would be hard before setting ring attributes!
     502  ideal Q = ideal(basering); // quotient ideal is assumed to be a GB!
     503  if( !isHomogeneous(Q, "checkGens") ) // easy now, but would be hard before setting ring attributes!
    501504  {
    502505    "Warning: your quotient ideal is not homogenous (multigrading was set anyway)!";
     
    704707  }
    705708
    706   if( !defined(R) )
     709  if( i == 1 )
    707710  {
    708711    def R = basering;
     
    805808  if( size(#) >= i )
    806809  {
    807     if( ( typeof(#[i]) == "ring" ) or ( typeof(#[i]) == "qring" ) )
     810    def a = #[i];
     811    if( ( typeof(a) == "ring" ) or ( typeof(a) == "qring" ) )
    808812    {
    809813      i++;
    810814    }
     815    kill a;
    811816  }
    812817
     
    820825
    821826
    822   def T = G[2];
     827  def T = G[2]; 
    823828
    824829  if( size(#) >= i )
    825830  {
    826     if( #[i] == "hermite" )
     831    def a = #[i];
     832
     833    if( typeof(a) != "string" )
     834    {
     835      ERROR("Sorry wrong arguments!");
     836    }
     837   
     838    if( a == "hermite" )
    827839    {
    828840      def M = attrib(T, attrGradingGroupHNF);
    829       if( (!defined(M)) or (typeof(M) != "intmat") )
     841      if( typeof(M) != "intmat" )
    830842      {
    831843        if( size(G) > 2 )
     
    840852    }
    841853
    842     if( #[i] == "smith" )
     854    if( a == "smith" )
    843855    {
    844856      def M = attrib(T, attrGradingGroupSNF);
    845       if( (!defined(M)) or (typeof(M) != "intmat") )
     857      if( typeof(M) != "intmat" )
    846858      {
    847859        if( size(G) > 2 )
     
    17361748"
    17371749{
    1738   if( size(#) > 0 )
    1739   {
    1740     if( typeof(#[1]) == "intmat" )
    1741     {
    1742       intmat H = hermiteNormalForm(#[1]);
    1743     } else
    1744     {
    1745       if( typeof(#[1]) == "list" )
    1746       {
    1747         list L = #[1];
    1748         intmat H = attrib(L, "hermite"); // todo
    1749       }
    1750     }
    1751 
    1752   }
    1753   if( !defined(H) )
     1750  int i = 1;
     1751  if( size(#) >= i )
     1752  {
     1753    def a = #[1];
     1754    if( typeof(a) == "intmat" )
     1755    {
     1756      intmat H = hermiteNormalForm(a);
     1757      i++;
     1758    }
     1759    if( typeof(a) == "list" )
     1760    {
     1761      list L = a;
     1762      intmat H = attrib(L, "hermite"); // todo
     1763      i++;
     1764    }
     1765    kill a;
     1766  }
     1767 
     1768  if( i == 1 )
    17541769  {
    17551770    intmat H = getLattice("hermite");
    17561771  }
    17571772
    1758   int x, k, i, row;
     1773  int x, k, row;
    17591774
    17601775  int r = nrows(H);
     
    18401855"
    18411856{
    1842   if( size(#) > 0 )
    1843   {
    1844     if( typeof(#[1]) == "intmat" )
    1845     {
    1846       intmat grad = #[1];
    1847     }
    1848   }
    1849 
    1850   if( !defined(grad) )
     1857  int i = 1;
     1858  if( size(#) >= i )
     1859  {
     1860    def a = #[1];
     1861    if( typeof(a) == "intmat" )
     1862    {
     1863      intmat grad = a;
     1864      i++;
     1865    }
     1866    kill a;
     1867  }
     1868
     1869  if( i == 1 )
    18511870  {
    18521871    intmat grad = getVariableWeights();
     
    18541873
    18551874  intmat newgg[nrows(grad)][size(f)-1];
    1856   int i,j;
     1875  int j;
    18571876  intvec l = grad*leadexp(f);
    18581877  intvec v;
     
    19611980
    19621981  intmat oldgrad=getVariableWeights(pre);
    1963   intmat oldtor=getLattice(pre);
     1982  intmat oldlat=getLattice(pre);
    19641983
    19651984  int n=nvars(pre);
     
    19701989  intmat newgrad[pp][np];
    19711990
     1991  //This will set the finest grading on the image ring. We will proceed by coarsening this grading until f becomes homogeneous.
    19721992  for(i=1;i<=np;i++){ newgrad[p+i,i]=1;}
    19731993
     
    19761996
    19771997
    1978   list newtor;
     1998  list newlat;
    19791999  intmat toadd;
    19802000  int columns=0;
     
    19872007    for(j=1;j<=n;j++){ toadd1[i,j]=oldgrad[i,j];}
    19882008  }
    1989 
     2009 
     2010  // This will make the images of homogeneous elements homogeneous, namely the variables of the preimage ring.
    19902011  for(i=1;i<=n;i++){
    19912012    im=f[i];
    19922013    //im;
    19932014    toadd = defineHomogeneous(im, newgrad);
    1994     newtor=insert(newtor,toadd);
     2015    newlat=insert(newlat,toadd);
    19952016    columns=columns+ncols(toadd);
    19962017
     
    19992020  }
    20002021
    2001   newtor=insert(newtor,toadd1);
     2022  newlat=insert(newlat,toadd1);
    20022023  columns=columns+ncols(toadd1);
    20032024
    2004 
     2025  //If the image ring is a quotient ring by some ideal, we have to coarsen the grading in order to make the ideal homogeneous.
    20052026  if(typeof(basering)=="qring"){
    20062027    //"Entering qring";
     
    20102031      //toadd;
    20112032      columns=columns+ncols(toadd);
    2012       newtor=insert(newtor,toadd);
    2013     }
    2014   }
    2015 
    2016   //newtor;
    2017   intmat imofoldtor[pp][ncols(oldtor)];
    2018   for(i=1; i<=nrows(oldtor);i++){
    2019     for(j=1; j<=ncols(oldtor); j++){
    2020       imofoldtor[i,j]=oldtor[i,j];
    2021     }
    2022   }
    2023 
    2024   columns=columns+ncols(oldtor);
    2025   newtor=insert(newtor, imofoldtor);
     2033      newlat=insert(newlat,toadd);
     2034    }
     2035  }
     2036
     2037  //The grading group of the preimage ring might not have been torsion free. We have to add this torsion to the grading group of the image ring.
     2038  intmat imofoldlat[pp][ncols(oldlat)];
     2039  for(i=1; i<=nrows(oldlat);i++){
     2040    for(j=1; j<=ncols(oldlat); j++){
     2041      imofoldlat[i,j]=oldlat[i,j];
     2042    }
     2043  }
     2044
     2045  columns=columns+ncols(oldlat);
     2046  newlat=insert(newlat, imofoldlat);
    20262047
    20272048  intmat gragr[pp][columns];
    20282049  columns=0;
    2029   for(k=1;k<=size(newtor);k++){
     2050  for(k=1;k<=size(newlat);k++){
    20302051    for(i=1;i<=pp;i++){
    2031       for(j=1;j<=ncols(newtor[k]);j++){gragr[i,j+columns]=newtor[k][i,j];}
    2032     }
    2033     columns=columns+ncols(newtor[k]);
    2034   }
    2035 
     2052      for(j=1;j<=ncols(newlat[k]);j++){gragr[i,j+columns]=newlat[k][i,j];}
     2053    }
     2054    columns=columns+ncols(newlat[k]);
     2055  }
     2056 
     2057  //The following is just for reducing the size of the matrices.
    20362058  gragr=hermiteNormalForm(gragr);
    20372059  intmat result[pp][pp];
     
    23892411"
    23902412{
    2391   if( defined(attrib(A, "grad")) > 0 )
    2392   {
    2393     return (attrib(A, "grad"));
     2413  def a = attrib(A, "grad");
     2414  if( typeof(a) == "intvec" || typeof(a) == "intmat" )
     2415  {
     2416    return (a);
    23942417  }
    23952418
     
    26022625    ideal I;
    26032626    poly mp, t, tt;
     2627    intmat V;
    26042628  }
    26052629  else
     
    26092633      module I;
    26102634      vector mp, t, tt;
     2635      intmat V = getModuleGrading(p);
    26112636    }
    26122637    else
     
    26142639      ERROR("Wrong ARGUMENT type!");
    26152640    }
    2616   }
    2617 
    2618   if( typeof(p) == "vector" )
    2619   {
    2620     intmat V = getModuleGrading(p);
    2621   }
    2622   else
    2623   {
    2624     intmat V;
    26252641  }
    26262642
     
    28322848"
    28332849{
     2850  int @bf = 0;
    28342851  if( nameof(basering) != "basering" )
    28352852  {
    2836     def save = basering;
     2853    @bf = 1;
     2854    def @save@ = basering;
    28372855  }
    28382856
     
    28492867  intmat R = (  matrix2intmat( MM ) ); // transpose
    28502868
    2851   if( defined(save) > 0 )
    2852   {
    2853     setring save;
     2869  if( @bf == 1 )
     2870  {
     2871    setring @save@;
    28542872  }
    28552873
Note: See TracChangeset for help on using the changeset viewer.