Loading...
Searching...
No Matches
p_Mult_nn__T.cc
Go to the documentation of this file.
/****************************************
* Computer Algebra System SINGULAR *
****************************************/
/***************************************************************
* File: p_Mult_n__Template.cc
* Purpose: template for p_Mult_n
* Author: obachman (Olaf Bachmann)
* Created: 8/00
*******************************************************************/
/***************************************************************
*
* Returns: p*n
* Destroys: p
* Const: n
*
***************************************************************/
LINKAGE poly p_Mult_nn__T(poly p, const number n, const ring r)
{
pAssume(!n_IsZero__T(n,r->cf));
p_Test(p, r);
poly q = p;
#ifdef HAVE_ZERODIVISORS
poly old = NULL;
#endif
while (p!=NULL)
{
#ifndef HAVE_ZERODIVISORS
n_InpMult__T(pGetCoeff(p), n, r->cf);
pIter(p);
#else
number tmp = n_Mult__T(n, pGetCoeff(p), r->cf);
if (!n_IsZero__T(tmp,r->cf))
{
number nc = pGetCoeff(p);
p_SetCoeff0(p, tmp, r);
n_Delete__T(&nc, r->cf);
old = p;
pIter(p);
}
else
{
n_Delete__T(&tmp, r->cf);
if (old == NULL)
{
pIter(p);
p_LmDelete(&q, r);
}
else
{
p_LmDelete(&p, r);
pNext(old) = p;
}
}
#endif
}
p_Test(q, r);
return q;
}
p
int p
Definition cfModGcd.cc:4086
LINKAGE
#define LINKAGE
Definition mod2.h:140
p_SetCoeff0
#define p_SetCoeff0(p, n, r)
Definition monomials.h:60
pIter
#define pIter(p)
Definition monomials.h:37
pNext
#define pNext(p)
Definition monomials.h:36
pGetCoeff
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition monomials.h:44
pAssume
#define pAssume(cond)
Definition monomials.h:90
NULL
#define NULL
Definition omList.c:12
p_Mult_nn__T
LINKAGE poly p_Mult_nn__T(poly p, const number n, const ring r)
Definition p_Mult_nn__T.cc:18
n_Delete__T
#define n_Delete__T(n, r)
Definition p_polys.cc:5042
p_LmDelete
static void p_LmDelete(poly p, const ring r)
Definition p_polys.h:725
p_Test
#define p_Test(p, r)
Definition p_polys.h:161