source: git/libpolys/polys/templates/p_Mult_mm__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.6 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/***************************************************************
5 *  File:    p_Mult_mm__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*m
14 *   Const:    m
15 *   Destroys: p
16 *
17 ***************************************************************/
18LINKAGE poly p_Mult_mm__T(poly p, const poly m, const ring ri)
19{
20  p_Test(p, ri);
21  p_LmTest(m, ri);
22  if (p == NULL) return NULL;
23  pAssume(m != NULL);
24  poly q = p;
25  number ln = pGetCoeff(m);
26  number pn;
27  DECLARE_LENGTH(const unsigned long length = ri->ExpL_Size);
28  const unsigned long* m_e = m->exp;
29  pAssume(!n_IsZero__T(ln,ri));
30
31#ifdef HAVE_ZERODIVISORS
32  poly before = p;
33#endif
34  while (p != NULL)
35  {
36    pn = pGetCoeff(p);
37    number tmp = n_Mult__T(ln, pn, ri);
38#ifdef HAVE_ZERODIVISORS
39    if (n_IsZero__T(tmp, ri))
40    {
41      n_Delete__T(&tmp, ri);
42      if (before == p)
43      {
44        p = p_LmDeleteAndNext(p, ri);
45        before = p;
46        q = p;
47      }
48      else
49      {
50        p = p_LmDeleteAndNext(p, ri);
51        pNext(before) = p;
52      }
53    }
54    else
55#endif
56    {
57      pSetCoeff0(p, tmp);
58      n_Delete__T(&pn, ri);
59      p_MemAdd__T(p->exp, m_e, length);
60      p_MemAddAdjust__T(p, ri);
61#ifdef HAVE_ZERODIVISORS
62      before = p;
63#endif
64      p = pNext(p);
65    }
66  }
67  p_Test(q, ri);
68  return q;
69}
70
71
Note: See TracBrowser for help on using the repository browser.