# source:git/kernel/p_Mult_mm__T.cc@341696

spielwiese
Last change on this file since 341696 was 341696, checked in by Hans Schönemann <hannes@…>, 14 years ago
• 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 *  Version: \$Id\$
10 *******************************************************************/
11
12/***************************************************************
13 *
14 *   Returns:  p*m
15 *   Const:    m
16 *   Destroys: p
17 *
18 ***************************************************************/
19LINKAGE poly p_Mult_mm(poly p, const poly m, const ring ri)
20{
21  p_Test(p, ri);
22  p_LmTest(m, ri);
23  if (p == NULL) return NULL;
24  pAssume(m != NULL);
25  poly q = p;
26  number ln = pGetCoeff(m);
27  number pn;
28  DECLARE_LENGTH(const unsigned long length = ri->ExpL_Size);
29  const unsigned long* m_e = m->exp;
30  pAssume(!n_IsZero(ln,ri));
31
32#ifdef HAVE_ZERODIVISORS
33  poly before = p;
34#endif
35  while (p != NULL)
36  {
37    pn = pGetCoeff(p);
38    number tmp = n_Mult(ln, pn, ri);
39#ifdef HAVE_ZERODIVISORS
40    if (n_IsZero(tmp, ri))
41    {
42      n_Delete(&tmp, ri);
43      if (before == p)
44      {
45        p = p_LmDeleteAndNext(p, ri);
46        before = p;
47        q = p;
48      }
49      else
50      {
51        p = p_LmDeleteAndNext(p, ri);
52        pNext(before) = p;
53      }
54    }
55    else
56#endif
57    {
58      pSetCoeff0(p, tmp);
59      n_Delete(&pn, ri);