source: git/libpolys/polys/templates/p_Mult_nn__T.cc @ 85bcd6

spielwiese
Last change on this file since 85bcd6 was 6ce030f, checked in by Oleksandr Motsak <motsak@…>, 12 years ago
removal of the $Id$ svn tag from everywhere NOTE: the git SHA1 may be used instead (only on special places) NOTE: the libraries Singular/LIB/*.lib still contain the marker due to our current use of svn
  • Property mode set to 100644
File size: 1.3 KB
Line 
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));
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);
31    pIter(p);
32#else
33    number tmp = n_Mult__T(n, pGetCoeff(p), r);
34    if (!n_IsZero__T(tmp,r))
35    {
36       number nc = pGetCoeff(p);
37       p_SetCoeff0(p, tmp, r);
38       n_Delete__T(&nc, r);
39       old = p;
40       pIter(p);
41    }
42    else
43    {
44      n_Delete__T(&tmp, r);
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}
Note: See TracBrowser for help on using the repository browser.