Changeset dd930e5 in git


Ignore:
Timestamp:
Sep 9, 2016, 2:43:10 PM (7 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a657104b677b4c461d018cbf3204d72d34ad66a9')
Children:
1ca2af82a3bd8eac81ea5d1768cd152322082b89
Parents:
8222d62826a4a1e61a9e22bfbb98e742f896d780
Message:
add: mp_Compare
Location:
libpolys/polys
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libpolys/polys/matpol.cc

    r8222d6 rdd930e5  
    574574    v = v->next;
    575575  }
    576 }
    577 
    578 
    579 BOOLEAN mp_Equal(matrix a, matrix b, const ring R)
    580 {
    581   if ((MATCOLS(a)!=MATCOLS(b)) || (MATROWS(a)!=MATROWS(b)))
    582     return FALSE;
    583   int i=MATCOLS(a)*MATROWS(b)-1;
    584   while (i>=0)
    585   {
    586     if (a->m[i]==NULL)
    587     {
    588       if (b->m[i]!=NULL) return FALSE;
    589     }
    590     else
    591       if (b->m[i]==NULL) return FALSE;
    592       else if (p_Cmp(a->m[i],b->m[i], R)!=0) return FALSE;
    593     i--;
    594   }
    595   i=MATCOLS(a)*MATROWS(b)-1;
    596   while (i>=0)
    597   {
    598 #if 0
    599     poly tt=p_Sub(p_Copy(a->m[i], R),p_Copy(b->m[i], R), R);
    600     if (tt!=NULL)
    601     {
    602       p_Delete(&tt, R);
    603       return FALSE;
    604     }
    605 #else
    606     if(!p_EqualPolys(a->m[i],b->m[i], R)) return FALSE;
    607 #endif
    608     i--;
    609   }
    610   return TRUE;
    611576}
    612577
     
    17031668  return (result);
    17041669}
     1670int mp_Compare(matrix a, matrix b, const ring R)
     1671{
     1672  if (MATCOLS(a)<MATCOLS(b)) return -1;
     1673  else if (MATCOLS(a)>MATCOLS(b)) return 1;
     1674  if (MATROWS(a)<MATROWS(b)) return -1;
     1675  else if (MATROWS(a)<MATROWS(b)) return 1;
     1676
     1677  int i=MATCOLS(a)*MATROWS(b)-1;
     1678  int c;
     1679  while (i>=0)
     1680  {
     1681    if (a->m[i]==NULL)
     1682    {
     1683      if (b->m[i]!=NULL) return -1;
     1684    }
     1685    else
     1686      if (b->m[i]==NULL) return 1;
     1687      else if ((c=p_Cmp(a->m[i],b->m[i], R))!=0) return c;
     1688    i--;
     1689  }
     1690  unsigned ii=MATCOLS(a)*MATROWS(b)-1;
     1691  unsigned j=0;
     1692  int r=0;
     1693  while (j<=ii)
     1694  {
     1695    r=p_Compare(a->m[j],b->m[j],R);
     1696    if (r!=0) return r;
     1697    j++;
     1698  }
     1699  return r;
     1700}
     1701
     1702BOOLEAN mp_Equal(matrix a, matrix b, const ring R)
     1703{
     1704  int r=mp_Compare(a,b,R);
     1705  return (r==0);
     1706}
     1707
  • libpolys/polys/matpol.h

    r8222d6 rdd930e5  
    9393extern omBin ip_smatrix_bin;
    9494
     95int mp_Compare(matrix a, matrix b, const ring r);
    9596#endif/* MATPOL_H */
Note: See TracChangeset for help on using the changeset viewer.