Changeset 1577ebd in git for libpolys/polys


Ignore:
Timestamp:
Sep 27, 2011, 12:54:50 PM (13 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
7f10dcde67f050fefbfeef12ce8d0108889fb6cc
Parents:
31c731745883c6d2ee7aba0e448c9320087d095a
git-author:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2011-09-27 12:54:50+02:00
git-committer:
Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 16:13:37+01:00
Message:
implented: ntGcd, ntLcm
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpolys/polys/ext_fields/transext.cc

    r31c731 r1577ebd  
    876876{
    877877  ntTest(a); ntTest(b);
    878   /* TO BE IMPLEMENTED!
    879      for the time, we simply return NULL, representing the number zero */
    880   Print("// TO BE IMPLEMENTED: transext.cc:ntLcm\n");
     878  fraction fb = (fraction)b;
     879  if ((b==NULL)||(DEN(fb)==NULL)) return ntCopy(a,cf);
     880#ifdef HAVE_FACTORY 
     881  fraction fa = (fraction)a;
     882  /* singclap_gcd destroys its arguments; we hence need copies: */
     883  poly pa = p_Copy(NUM(fa), ntRing);
     884  poly pb = p_Copy(DEN(fb), ntRing);
     885 
     886  /* Note that, over Q, singclap_gcd will remove the denominators in all
     887     rational coefficients of pa and pb, before starting to compute
     888     the gcd. Thus, we do not need to ensure that the coefficients of
     889     pa and pb live in Z; they may well be elements of Q\Z. */
     890  poly pGcd = singclap_gcd(pa, pb, cf->extRing);
     891  if (p_IsConstant(pGcd, ntRing) &&
     892      n_IsOne(p_GetCoeff(pGcd, ntRing), ntCoeffs))
     893  { /* gcd = 1; return pa*pb*/
     894    p_Delete(&pGcd,ntRing);
     895    fraction result = (fraction)omAlloc0Bin(fractionObjectBin);
     896    NUM(result) = pp_Mult_qq(NUM(fa),DEN(fb),ntRing);
     897    return (number)result;
     898  }
     899  else
     900  { /* return pa*pb/gcd */
     901    p_Delete(&pGcd,ntRing);
     902    poly newNum = singclap_pdivide(NUM(fa), pGcd, ntRing);
     903    fraction result = (fraction)omAlloc0Bin(fractionObjectBin);
     904    NUM(result) = p_Mult_q(p_Copy(DEN(fb),ntRing),newNum,ntRing);
     905    return (number)result;
     906  }
     907#else
     908  Print("// factory needed: transext.cc:ntLcm\n");
    881909  return NULL;
     910#endif /* HAVE_FACTORY */
     911  return NULL;
    882912}
    883913
     
    885915{
    886916  ntTest(a); ntTest(b);
    887   /* TO BE IMPLEMENTED!
    888      for the time, we simply return NULL, representing the number zero */
    889   Print("// TO BE IMPLEMENTED: transext.cc:ntGcd\n");
     917  if (a==NULL) return ntCopy(b,cf);
     918  if (b==NULL) return ntCopy(a,cf);
     919#ifdef HAVE_FACTORY 
     920  fraction fa = (fraction)a;
     921  fraction fb = (fraction)b;
     922  /* singclap_gcd destroys its arguments; we hence need copies: */
     923  poly pa = p_Copy(NUM(fa), ntRing);
     924  poly pb = p_Copy(NUM(fb), ntRing);
     925 
     926  /* Note that, over Q, singclap_gcd will remove the denominators in all
     927     rational coefficients of pa and pb, before starting to compute
     928     the gcd. Thus, we do not need to ensure that the coefficients of
     929     pa and pb live in Z; they may well be elements of Q\Z. */
     930  poly pGcd = singclap_gcd(pa, pb, cf->extRing);
     931  fraction result = (fraction)omAlloc0Bin(fractionObjectBin);
     932  NUM(result) = pGcd;
     933  return (number)result;
     934#else
     935  Print("// factory needed: transext.cc:ntGcd\n");
    890936  return NULL;
     937#endif /* HAVE_FACTORY */
    891938}
    892939
Note: See TracChangeset for help on using the changeset viewer.