MCPcopy Create free account
hub / github.com/Singular/Singular / cancelunit

Function cancelunit

kernel/GBEngine/kutil.cc:370–439  ·  view source on GitHub ↗

2 *tests if p.p=monomial*unit and cancels the unit */

Source from the content-addressed store, hash-verified

368*tests if p.p=monomial*unit and cancels the unit
369*/
370void cancelunit (LObject* L,BOOLEAN inNF)
371{
372 if(rHasGlobalOrdering (currRing)) return;
373 if(TEST_OPT_CANCELUNIT) return;
374
375 ring r = L->tailRing;
376 poly p = L->GetLmTailRing();
377 if(p_GetComp(p, r) != 0 && !p_OneComp(p, r)) return;
378
379 number lc=NULL; /*dummy, is always set if rField_is_Ring(r) */
380 if (rField_is_Ring(r) /*&& (rHasLocalOrMixedOrdering(r))*/)
381 lc = pGetCoeff(p);
382
383 // Leading coef have to be a unit
384 // example 2x+4x2 should be simplified to 2x*(1+2x)
385 // and 2 is not a unit in Z
386 //if ( !(n_IsUnit(pGetCoeff(p), r->cf)) ) return;
387
388 poly h = pNext(p);
389 int i;
390
391 if(rField_is_Ring(currRing))
392 {
393 loop
394 {
395 if (h==NULL)
396 {
397 p_Delete(&pNext(p), r);
398 if (!inNF)
399 {
400 number eins= nCopy(lc);
401 if (L->p != NULL)
402 {
403 pSetCoeff(L->p,eins);
404 if (L->t_p != NULL)
405 pSetCoeff0(L->t_p,eins);
406 }
407 else
408 pSetCoeff(L->t_p,eins);
409 /* p and t_p share the same coeff, if both are !=NULL */
410 /* p==NULL==t_p cannot happen here */
411 }
412 L->ecart = 0;
413 L->length = 1;
414 //if (L->pLength > 0)
415 L->pLength = 1;
416 L->max_exp = NULL;
417
418 if (L->t_p != NULL && pNext(L->t_p) != NULL)
419 p_Delete(&pNext(L->t_p),r);
420 if (L->p != NULL && pNext(L->p) != NULL)
421 pNext(L->p) = NULL;
422 return;
423 }
424 i = rVar(r);
425 loop
426 {
427 if (p_GetExp(p,i,r) > p_GetExp(h,i,r)) return; // does not divide

Callers 10

k_sca_moraFunction · 0.85
f5cFunction · 0.85
initSFunction · 0.85
initSLFunction · 0.85
initSLSbaFunction · 0.85
redMoraNFFunction · 0.85
kstd1.ccFile · 0.85
redMoraNFRingFunction · 0.85
updateTFunction · 0.85
moraFunction · 0.85

Calls 7

rHasGlobalOrderingFunction · 0.85
p_OneCompFunction · 0.85
p_DeleteFunction · 0.85
p_GetExpFunction · 0.85
n_DivByFunction · 0.85
GetLmTailRingMethod · 0.80
ifFunction · 0.50

Tested by

no test coverage detected