My Project
Loading...
Searching...
No Matches
p_Mult_nn__T.cc
Go to the documentation of this file.
1/****************************************
2* Computer Algebra System SINGULAR *
3****************************************/
4/***************************************************************
5 * File: p_Mult_n__Template.cc
6 * Purpose: template for p_Mult_n
7 * Author: obachman (Olaf Bachmann)
8 * Created: 8/00
9 *******************************************************************/
10
11/***************************************************************
12 *
13 * Returns: p*n
14 * Destroys: p
15 * Const: n
16 *
17 ***************************************************************/
18LINKAGE poly p_Mult_nn__T(poly p, const number n, const ring r)
19{
20 pAssume(!n_IsZero__T(n,r->cf));
21 p_Test(p, r);
22
23 poly q = p;
24#ifdef HAVE_ZERODIVISORS
25 poly old = NULL;
26#endif
27 while (p!=NULL)
28 {
29#ifndef HAVE_ZERODIVISORS
30 n_InpMult__T(pGetCoeff(p), n, r->cf);
31 pIter(p);
32#else
33 number tmp = n_Mult__T(n, pGetCoeff(p), r->cf);
34 if (!n_IsZero__T(tmp,r->cf))
35 {
36 number nc = pGetCoeff(p);
37 p_SetCoeff0(p, tmp, r);
38 n_Delete__T(&nc, r->cf);
39 old = p;
40 pIter(p);
41 }
42 else
43 {
44 n_Delete__T(&tmp, r->cf);
45 if (old == NULL)
46 {
47 pIter(p);
48 p_LmDelete(&q, r);
49 }
50 else
51 {
52 p_LmDelete(&p, r);
53 pNext(old) = p;
54 }
55 }
56#endif
57 }
58 p_Test(q, r);
59 return q;
60}
int p
Definition: cfModGcd.cc:4078
#define LINKAGE
Definition: mod2.h:140
#define p_SetCoeff0(p, n, r)
Definition: monomials.h:60
#define pIter(p)
Definition: monomials.h:37
#define pNext(p)
Definition: monomials.h:36
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
#define pAssume(cond)
Definition: monomials.h:90
#define NULL
Definition: omList.c:12
LINKAGE poly p_Mult_nn__T(poly p, const number n, const ring r)
Definition: p_Mult_nn__T.cc:18
#define n_Delete__T(n, r)
Definition: p_polys.cc:4841
static void p_LmDelete(poly p, const ring r)
Definition: p_polys.h:721
#define p_Test(p, r)
Definition: p_polys.h:159