Changeset 9f93d9 in git


Ignore:
Timestamp:
Jan 30, 2017, 3:16:26 PM (7 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
255be23a24e8d8e66bb9940f2b28682b72397092
Parents:
112f6ef2f15862ab65b71de204f611522d5b55c7
Message:
add: p_GcdMon
Location:
libpolys/polys/monomials
Files:
2 edited

Legend:

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

    r112f6ef r9f93d9  
    47524752}
    47534753
     4754poly p_GcdMon(poly f, poly g, const ring r)
     4755{
     4756  assume(f!=NULL);
     4757  assume(g!=NULL);
     4758  assume(pNext(f)==NULL);
     4759  poly G=p_Head(f,r);
     4760  poly h=g;
     4761  int *mf=(int*)omAlloc((r->N+1)*sizeof(int));
     4762  p_GetExpV(f,mf,r);
     4763  int *mh=(int*)omAlloc((r->N+1)*sizeof(int));
     4764  BOOLEAN const_mon;
     4765  BOOLEAN one_coeff=n_IsOne(pGetCoeff(G),r->cf);
     4766  loop
     4767  {
     4768    if (h==NULL) break;
     4769    one_coeff=TRUE;
     4770    if(!one_coeff)
     4771    {
     4772      number n=n_SubringGcd(pGetCoeff(G),pGetCoeff(h),r->cf);
     4773      one_coeff=n_IsOne(n,r->cf);
     4774      p_SetCoeff(G,n,r);
     4775    }
     4776    p_GetExpV(h,mh,r);
     4777    const_mon=TRUE;
     4778    for(unsigned j=r->N;j!=0;j--)
     4779    {
     4780      if (mh[j]<mf[j]) mf[j]=mh[j];
     4781      if (mf[j]>0) const_mon=FALSE;
     4782    }
     4783    if (one_coeff && const_mon) break;
     4784    pIter(h);
     4785  }
     4786  mf[0]=0;
     4787  p_SetExpV(G,mf,r); // included is p_SetComp, p_Setm
     4788  omFreeSize(mf,(r->N+1)*sizeof(int));
     4789  omFreeSize(mh,(r->N+1)*sizeof(int));
     4790  return G;
     4791}
  • libpolys/polys/monomials/p_polys.h

    r112f6ef r9f93d9  
    20242024
    20252025int p_Compare(const poly a, const poly b, const ring R);
     2026
     2027/// polynomial gcd for f=mon
     2028poly p_GcdMon(poly f, poly g, const ring r);
    20262029#endif // P_POLYS_H
    20272030
Note: See TracChangeset for help on using the changeset viewer.