Changeset 49b748 in git


Ignore:
Timestamp:
May 27, 2015, 9:23:30 PM (8 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'spielwiese', 'a7324b6e0b44a1a8ed3fa4d9ca3e2ff210ddd52c')
Children:
45df9b36755304e98f8dfcf2af60ecac7d2d7c6b
Parents:
bf36c4396e4648d6cbdf65b5e60114f31d6d9089
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2015-05-27 21:23:30+02:00
git-committer:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2015-05-27 21:24:41+02:00
Message:
Bug fixed in idMinors (wrong ring at idDelete) + code cleanup
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/ideals.cc

    rbf36c4 r49b748  
    17811781}
    17821782#else
    1783 /*2
    1784 * compute all ar-minors of the matrix a
    1785 * the caller of mpRecMin
    1786 * the elements of the result are not in R (if R!=NULL)
    1787 */
     1783
     1784
     1785/// compute all ar-minors of the matrix a
     1786/// the caller of mpRecMin
     1787/// the elements of the result are not in R (if R!=NULL)
    17881788ideal idMinors(matrix a, int ar, ideal R)
    17891789{
    1790   int elems=0;
    1791   int r=a->nrows,c=a->ncols;
    1792   int i;
    1793   matrix b;
    1794   ideal result,h;
    1795   ring origR=currRing;
    1796   ring tmpR;
    1797   long bound;
    1798 
     1790 
     1791  const ring origR=currRing;
     1792  id_Test((ideal)a, origR);
     1793
     1794  const int r = a->nrows;
     1795  const int c = a->ncols;
     1796 
    17991797  if((ar<=0) || (ar>r) || (ar>c))
    18001798  {
     
    18021800    return NULL;
    18031801  }
    1804   h = id_Matrix2Module(mp_Copy(a,origR),origR);
    1805   bound = sm_ExpBound(h,c,r,ar,origR);
    1806   idDelete(&h);
    1807   tmpR=sm_RingChange(origR,bound);
    1808   b = mpNew(r,c);
    1809   for (i=r*c-1;i>=0;i--)
    1810   {
    1811     if (a->m[i])
     1802 
     1803  ideal h = id_Matrix2Module(mp_Copy(a,origR),origR); 
     1804  long bound = sm_ExpBound(h,c,r,ar,origR);
     1805  id_Delete(&h, origR);
     1806 
     1807  ring tmpR = sm_RingChange(origR,bound);
     1808 
     1809  matrix b = mpNew(r,c);
     1810 
     1811  for (int i=r*c-1;i>=0;i--)
     1812    if (a->m[i] != NULL)
    18121813      b->m[i] = prCopyR(a->m[i],origR,tmpR);
    1813   }
     1814 
     1815  id_Test( (ideal)b, tmpR);
     1816 
    18141817  if (R!=NULL)
    18151818  {
    1816     R = idrCopyR(R,origR,tmpR);
     1819    R = idrCopyR(R,origR,tmpR); // TODO: overwrites R? memory leak?
    18171820    //if (ar>1) // otherwise done in mpMinorToResult
    18181821    //{
     
    18211824    //  idDelete((ideal*)&b); b=bb;
    18221825    //}
    1823   }
    1824   result=idInit(32,1);
    1825   if(ar>1) mp_RecMin(ar-1,result,elems,b,r,c,NULL,R,tmpR);
    1826   else mp_MinorToResult(result,elems,b,r,c,R,tmpR);
    1827   idDelete((ideal *)&b);
     1826    id_Test( R, tmpR);
     1827  }
     1828 
     1829 
     1830  ideal result = idInit(32,1);
     1831
     1832  int elems = 0;
     1833 
     1834  if(ar>1)
     1835    mp_RecMin(ar-1,result,elems,b,r,c,NULL,R,tmpR);
     1836  else
     1837    mp_MinorToResult(result,elems,b,r,c,R,tmpR);
     1838 
     1839  id_Test( (ideal)b, tmpR);
     1840 
     1841  id_Delete((ideal *)&b, tmpR);
     1842 
    18281843  if (R!=NULL) idDelete(&R);
     1844 
    18291845  idSkipZeroes(result);
    18301846  rChangeCurrRing(origR);
Note: See TracChangeset for help on using the changeset viewer.