Changeset 02d009 in git for libpolys


Ignore:
Timestamp:
Feb 15, 2021, 6:01:06 PM (3 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '4188d308699580d975efd0f6cca8dcb41c396f70')
Children:
7b5b095ed2434be9e1783ac23414e01c2a75fec4
Parents:
e6f77c64ad84a4393b83a375b4207c80fe495718
Message:
add: p_Content_n
Location:
libpolys/polys/monomials
Files:
2 edited

Legend:

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

    re6f77c6 r02d009  
    23372337}
    23382338
     2339void p_Content_n(poly ph, number &c,const ring r)
     2340{
     2341  if (ph==NULL)
     2342  {
     2343    c=n_Init(1,r->cf);
     2344    return;
     2345  }
     2346  const coeffs cf=r->cf;
     2347  if (pNext(ph)==NULL)
     2348  {
     2349    c=pGetCoeff(ph);
     2350    p_SetCoeff0(ph,n_Init(1,cf),r);
     2351  }
     2352  if ((cf->cfSubringGcd==ndGcd)
     2353  || (cf->cfGcd==ndGcd)) /* trivial gcd*/
     2354  {
     2355    c=n_Init(1,r->cf);
     2356    return;
     2357  }
     2358  number h;
     2359  if ((rField_is_Q(r))
     2360  || (rField_is_Q_a(r))
     2361  || (rField_is_Zp_a)(r)
     2362  || (rField_is_Z(r))
     2363  )
     2364  {
     2365    h=p_InitContent(ph,r); /* first guess of a gcd of all coeffs */
     2366  }
     2367  else
     2368  {
     2369    h=n_Copy(pGetCoeff(ph),cf);
     2370  }
     2371  poly p;
     2372  if(n_IsOne(h,cf))
     2373  {
     2374    goto content_finish;
     2375  }
     2376  p=ph;
     2377  // take the SubringGcd of all coeffs
     2378  while (p!=NULL)
     2379  {
     2380    n_Normalize(pGetCoeff(p),cf);
     2381    number d=n_SubringGcd(h,pGetCoeff(p),cf);
     2382    n_Delete(&h,cf);
     2383    h = d;
     2384    if(n_IsOne(h,cf))
     2385    {
     2386      goto content_finish;
     2387    }
     2388    pIter(p);
     2389  }
     2390  // if found<>1, divide by it
     2391  p = ph;
     2392  while (p!=NULL)
     2393  {
     2394    number d = n_ExactDiv(pGetCoeff(p),h,cf);
     2395    p_SetCoeff(p,d,r);
     2396    pIter(p);
     2397  }
     2398content_finish:
     2399  c=h;
     2400  // and last: check leading sign:
     2401  if(!n_GreaterZero(pGetCoeff(ph),r->cf))
     2402  {
     2403    c = n_InpNeg(c,r->cf);
     2404    ph = p_Neg(ph,r);
     2405  }
     2406}
     2407
    23392408#define CLEARENUMERATORS 1
    23402409
  • libpolys/polys/monomials/p_polys.h

    re6f77c6 r02d009  
    212212void      p_ContentForGB(poly p, const ring r);
    213213void      p_Content(poly p, const ring r);
     214void      p_Content_n(poly p, number &c,const ring r);
    214215#if 1
    215216// currently only used by Singular/janet
Note: See TracChangeset for help on using the changeset viewer.