Changeset 02d009 in git
- Timestamp:
- Feb 15, 2021, 6:01:06 PM (2 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- 7b5b095ed2434be9e1783ac23414e01c2a75fec4
- Parents:
- e6f77c64ad84a4393b83a375b4207c80fe495718
- Location:
- libpolys/polys/monomials
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/polys/monomials/p_polys.cc
re6f77c6 r02d009 2337 2337 } 2338 2338 2339 void 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 } 2398 content_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 2339 2408 #define CLEARENUMERATORS 1 2340 2409 -
libpolys/polys/monomials/p_polys.h
re6f77c6 r02d009 212 212 void p_ContentForGB(poly p, const ring r); 213 213 void p_Content(poly p, const ring r); 214 void p_Content_n(poly p, number &c,const ring r); 214 215 #if 1 215 216 // currently only used by Singular/janet
Note: See TracChangeset
for help on using the changeset viewer.