Changeset 7b5d0a in git for Singular/lists.cc


Ignore:
Timestamp:
Apr 1, 1998, 8:59:29 PM (26 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b4f17ed1d25f93d46dbe29e4b499baecc2fd51bb')
Children:
9917052fb66734c3cc2e6270ba510557c9250002
Parents:
3ebd198f5ff9a3039d51bd30067bf71868c1112b
Message:
* hannes: lists.cc: fixed bug in conversion (list<->res.):
          handling "empty" case


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

Legend:

Unmodified
Added
Removed
  • Singular/lists.cc

    r3ebd198 r7b5d0a  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: lists.cc,v 1.5 1997-04-13 12:43:01 Singular Exp $ */
     4/* $Id: lists.cc,v 1.6 1998-04-01 18:59:29 Singular Exp $ */
    55/*
    66* ABSTRACT: handling of the list type
     
    195195{
    196196  lists L=(lists)Alloc0(sizeof(slists));
    197   int oldlength=length;
    198   while (r[length-1]==NULL) length--;
    199   if (reallen<=0) reallen=pVariables;
    200   reallen=max(reallen,length);
    201   L->Init(reallen);
    202   int i=0;
    203 
    204   while (i<length)
    205   {
    206     if (r[i]!=NULL)
    207     {
    208       if (i==0)
    209       {
    210         L->m[i].rtyp=typ0;
    211       }
    212       else
    213       {
    214         L->m[i].rtyp=MODUL_CMD;
    215         int rank=IDELEMS(r[i-1]);
    216         if (idIs0(r[i-1]))
     197  if (length<=0)
     198  {
     199    // handle "empty" resolutions
     200    L->Init(0);
     201  }
     202  else
     203  {
     204    int oldlength=length;
     205    while (r[length-1]==NULL) length--;
     206    if (reallen<=0) reallen=pVariables;
     207    reallen=max(reallen,length);
     208    L->Init(reallen);
     209    int i=0;
     210 
     211    while (i<length)
     212    {
     213      if (r[i]!=NULL)
     214      {
     215        if (i==0)
    217216        {
    218           idDelete(&(r[i]));
    219           r[i]=idFreeModule(rank);
     217          L->m[i].rtyp=typ0;
    220218        }
    221219        else
    222220        {
    223           r[i]->rank=max(rank,idRankFreeModule(r[i]));
     221          L->m[i].rtyp=MODUL_CMD;
     222          int rank=IDELEMS(r[i-1]);
     223          if (idIs0(r[i-1]))
     224          {
     225            idDelete(&(r[i]));
     226            r[i]=idFreeModule(rank);
     227          }
     228          else
     229          {
     230            r[i]->rank=max(rank,idRankFreeModule(r[i]));
     231          }
     232          idSkipZeroes(r[i]);
    224233        }
    225         idSkipZeroes(r[i]);
    226       }
    227       L->m[i].data=(void *)r[i];
    228       if ((weights!=NULL) && (weights[i]!=NULL))
    229       {
    230         atSet((idhdl)&L->m[i],mstrdup("isHomog"),weights[i],INTVEC_CMD);
    231         weights[i] = NULL;
    232       }
    233     }
    234     else
    235     {
    236       // should not happen:
    237       Warn("internal NULL in resolvente");
    238       L->m[i].data=(void *)idInit(1,1);
    239     }
    240     i++;
    241   }
    242   Free((ADDRESS)r,oldlength*sizeof(ideal));
    243   if (i==0)
    244   {
    245     L->m[0].rtyp=typ0;
    246     L->m[0].data=(char *)idInit(1,1);
    247     i=1;
    248   }
    249   while (i<reallen)
    250   {
    251     L->m[i].rtyp=MODUL_CMD;
    252     ideal I=(ideal)L->m[i-1].data;
    253     ideal J;
    254     int rank=IDELEMS(I);
    255     if (idIs0(I))
    256     {
    257       J=idFreeModule(rank);
    258     }
    259     else
    260     {
    261       J=idInit(1,rank);
    262     }
    263     L->m[i].data=(void *)J;
    264     i++;
    265   }
    266   //Print("make res of length %d (0..%d) L:%d\n",length,length-1,L->nr);
     234        L->m[i].data=(void *)r[i];
     235        if ((weights!=NULL) && (weights[i]!=NULL))
     236        {
     237          atSet((idhdl)&L->m[i],mstrdup("isHomog"),weights[i],INTVEC_CMD);
     238          weights[i] = NULL;
     239        }
     240      }
     241      else
     242      {
     243        // should not happen:
     244        Warn("internal NULL in resolvente");
     245        L->m[i].data=(void *)idInit(1,1);
     246      }
     247      i++;
     248    }
     249    Free((ADDRESS)r,oldlength*sizeof(ideal));
     250    if (i==0)
     251    {
     252      L->m[0].rtyp=typ0;
     253      L->m[0].data=(char *)idInit(1,1);
     254      i=1;
     255    }
     256    while (i<reallen)
     257    {
     258      L->m[i].rtyp=MODUL_CMD;
     259      ideal I=(ideal)L->m[i-1].data;
     260      ideal J;
     261      int rank=IDELEMS(I);
     262      if (idIs0(I))
     263      {
     264        J=idFreeModule(rank);
     265      }
     266      else
     267      {
     268        J=idInit(1,rank);
     269      }
     270      L->m[i].data=(void *)J;
     271      i++;
     272    }
     273    //Print("make res of length %d (0..%d) L:%d\n",length,length-1,L->nr);
     274  }
    267275  return L;
    268276}
Note: See TracChangeset for help on using the changeset viewer.