Changeset 90934a in git


Ignore:
Timestamp:
Mar 15, 2012, 7:37:03 PM (11 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '0604212ebb110535022efecad887940825b97c3f')
Children:
4d94c97313de2ce07f4bfae84308b31c1294a569
Parents:
55e2df02f4f427087fcfc2be9320bbce5142bfe9
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-03-15 19:37:03+01:00
git-committer:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-03-16 19:36:35+01:00
Message:
better rEqual & rSamePolyRep

fix: they both should test the equality of coeffs directly (NOT via type & rPar/Minpoly)
fix: rEqual should use rSamePolyRep
chg: moved documentation to header in doxygen style
Location:
libpolys/polys/monomials
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libpolys/polys/monomials/ring.cc

    r55e2df0 r90934a  
    16451645}
    16461646
    1647 // returns TRUE, if r1 equals r2 FALSE, otherwise Equality is
    1648 // determined componentwise, if qr == 1, then qrideal equality is
    1649 // tested, as well
    16501647BOOLEAN rEqual(ring r1, ring r2, BOOLEAN qr)
    16511648{
     1649  if( !rSamePolyRep(r1, r2) )
     1650    return FALSE;
     1651
    16521652  int i, j;
    16531653
    16541654  if (r1 == r2) return TRUE;
    1655 
    16561655  if (r1 == NULL || r2 == NULL) return FALSE;
    16571656
    1658   if ((r1->cf->type != r2->cf->type)
     1657  assume( r1->cf == r2->cf );
     1658  assume( rVar(r1) == rVar(r2) );
     1659 
     1660  for (i=0; i<rVar(r1); i++)
     1661  {
     1662    if (r1->names[i] != NULL && r2->names[i] != NULL)
     1663    {
     1664      if (strcmp(r1->names[i], r2->names[i])) return FALSE;
     1665    }
     1666    else if ((r1->names[i] != NULL) ^ (r2->names[i] != NULL))
     1667    {
     1668      return FALSE;
     1669    }
     1670  }
     1671
     1672  if (qr)
     1673  {
     1674    if (r1->qideal != NULL)
     1675    {
     1676      ideal id1 = r1->qideal, id2 = r2->qideal;
     1677      int i, n;
     1678      poly *m1, *m2;
     1679
     1680      if (id2 == NULL) return FALSE;
     1681      if ((n = IDELEMS(id1)) != IDELEMS(id2)) return FALSE;
     1682
     1683      {
     1684        m1 = id1->m;
     1685        m2 = id2->m;
     1686        for (i=0; i<n; i++)
     1687          if (! p_EqualPolys(m1[i],m2[i], r1, r2)) return FALSE;
     1688      }
     1689    }
     1690    else if (r2->qideal != NULL) return FALSE;
     1691  }
     1692
     1693  return TRUE;
     1694}
     1695
     1696BOOLEAN rSamePolyRep(ring r1, ring r2)
     1697{
     1698  int i, j;
     1699
     1700  if (r1 == r2) return TRUE;
     1701
     1702  if (r1 == NULL || r2 == NULL) return FALSE;
     1703
     1704  if ((r1->cf != r2->cf)
    16591705  || (rVar(r1) != rVar(r2))
    1660   || (r1->OrdSgn != r2->OrdSgn)
    1661   || (rPar(r1) != rPar(r2)))
     1706  || (r1->OrdSgn != r2->OrdSgn))
    16621707    return FALSE;
    1663 
    1664   for (i=0; i<rVar(r1); i++)
    1665   {
    1666     if (r1->names[i] != NULL && r2->names[i] != NULL)
    1667     {
    1668       if (strcmp(r1->names[i], r2->names[i])) return FALSE;
    1669     }
    1670     else if ((r1->names[i] != NULL) ^ (r2->names[i] != NULL))
    1671     {
    1672       return FALSE;
    1673     }
    1674   }
    16751708
    16761709  i=0;
     
    16951728  if (r2->order[i] != 0) return FALSE;
    16961729
    1697   for (i=0; i<rPar(r1);i++)
    1698   {
    1699       if (strcmp(rParameter(r1)[i], rParameter(r2)[i])!=0)
    1700         return FALSE;
    1701   }
    1702 
    1703   if ( !rMinpolyIsNULL(r1) )
    1704   {
    1705     if ( rMinpolyIsNULL(r2) ) return FALSE;
    1706     if (! p_EqualPolys(r1->cf->extRing->minideal->m[0],
    1707                   r2->cf->extRing->minideal->m[0],
    1708                   r1->cf->extRing))
    1709       return FALSE;
    1710   }
    1711   else if (!rMinpolyIsNULL(r2)) return FALSE;
    1712 
    1713   if (qr)
    1714   {
    1715     if (r1->qideal != NULL)
    1716     {
    1717       ideal id1 = r1->qideal, id2 = r2->qideal;
    1718       int i, n;
    1719       poly *m1, *m2;
    1720 
    1721       if (id2 == NULL) return FALSE;
    1722       if ((n = IDELEMS(id1)) != IDELEMS(id2)) return FALSE;
    1723 
    1724       {
    1725         m1 = id1->m;
    1726         m2 = id2->m;
    1727         for (i=0; i<n; i++)
    1728           if (! p_EqualPolys(m1[i],m2[i],r1)) return FALSE;
    1729       }
    1730     }
    1731     else if (r2->qideal != NULL) return FALSE;
    1732   }
    1733 
    1734   return TRUE;
    1735 }
    1736 
    1737 // returns TRUE, if r1 and r2 represents the monomials in the same way
    1738 // FALSE, otherwise
    1739 // this is an analogue to rEqual but not so strict
    1740 BOOLEAN rSamePolyRep(ring r1, ring r2)
    1741 {
    1742   int i, j;
    1743 
    1744   if (r1 == r2) return TRUE;
    1745 
    1746   if (r1 == NULL || r2 == NULL) return FALSE;
    1747 
    1748   if ((r1->cf->type != r2->cf->type)
    1749   || (rVar(r1) != rVar(r2))
    1750   || (r1->OrdSgn != r2->OrdSgn)
    1751   || (rPar(r1) != rPar(r2)))
    1752     return FALSE;
    1753 
    1754   if (rVar(r1)!=rVar(r2)) return FALSE;
    1755   if (rPar(r1)!=rPar(r2)) return FALSE;
    1756 
    1757   i=0;
    1758   while (r1->order[i] != 0)
    1759   {
    1760     if (r2->order[i] == 0) return FALSE;
    1761     if ((r1->order[i] != r2->order[i])
    1762     || (r1->block0[i] != r2->block0[i])
    1763     || (r1->block1[i] != r2->block1[i]))
    1764       return FALSE;
    1765     if (r1->wvhdl[i] != NULL)
    1766     {
    1767       if (r2->wvhdl[i] == NULL)
    1768         return FALSE;
    1769       for (j=0; j<r1->block1[i]-r1->block0[i]+1; j++)
    1770         if (r2->wvhdl[i][j] != r1->wvhdl[i][j])
    1771           return FALSE;
    1772     }
    1773     else if (r2->wvhdl[i] != NULL) return FALSE;
    1774     i++;
    1775   }
    1776   if (r2->order[i] != 0) return FALSE;
    1777 
     1730  // we do not check variable names
    17781731  // we do not check minpoly/minideal
    17791732  // we do not check qideal
  • libpolys/polys/monomials/ring.h

    r55e2df0 r90934a  
    392392int rSumInternal(ring r1, ring r2, ring &sum, BOOLEAN vartest, BOOLEAN dp_dp);
    393393
    394 BOOLEAN rEqual(ring r1, ring r2, BOOLEAN qr = 1);
     394/// returns TRUE, if r1 equals r2 FALSE, otherwise Equality is
     395/// determined componentwise, if qr == 1, then qrideal equality is
     396/// tested, as well
     397BOOLEAN rEqual(ring r1, ring r2, BOOLEAN qr = TRUE);
     398
     399/// returns TRUE, if r1 and r2 represents the monomials in the same way
     400/// FALSE, otherwise
     401/// this is an analogue to rEqual but not so strict
    395402BOOLEAN rSamePolyRep(ring r1, ring r2);
     403
    396404void   rUnComplete(ring r);
    397405
Note: See TracChangeset for help on using the changeset viewer.