source: git/kernel/p_Mult_mm__T.cc @ 009d80

spielwiese
Last change on this file since 009d80 was 009d80, checked in by Oliver Wienand <wienand@…>, 17 years ago
new compile switch: HAVE_RINGS at total there are now: HAVE_RINGS, HAVE_RING2TOM, HAVE_RINGMODN kspoly.cc, kstd1.cc, kstd2.cc, kutil.cc, kspoly.cc, polys.cc, ring.*: adaption of new switches and rField_is_Ring method numbers.*: introduced new operation: nDivBy(a, b) = Is a divisible by b? pDebig.cc, pInline1.h: use of new nDivBy method p_Mult_q: new routine for rings p_*, pp_*: template switch HAVE_ZERODIVISOR polys1.cc: poly exponentation, switches rmodulo*: nDivBy implementation, DBTest structs.h: nDivBy, ringtype, ringflaga, ringflagb git-svn-id: file:///usr/local/Singular/svn/trunk@10029 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • 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: p_Mult_mm__T.cc,v 1.6 2007-05-10 08:12:42 wienand Exp $
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  poly before = p;
22  p_Test(p, ri);
23  p_LmTest(m, ri);
24  if (p == NULL) return NULL;
25  pAssume(m != NULL);
26  poly q = p;
27  number ln = pGetCoeff(m);
28  number pn;
29  DECLARE_LENGTH(const unsigned long length = ri->ExpL_Size);
30  const unsigned long* m_e = m->exp;
31  pAssume(!n_IsZero(ln,ri));
32
33  while (p != NULL)
34  {
35    pn = pGetCoeff(p);
36    number tmp = n_Mult(ln, pn, ri);
37#ifdef HAVE_ZERODIVISORS
38    if (n_IsZero(tmp, ri))
39    {
40      if (before == p)
41      {
42        p = pNext(p);
43        before = p;
44        q = p;
45      }
46      else
47      {
48        pNext(before) = pNext(p);
49        p_LmFree(p, ri);
50        p = pNext(before);
51      }
52    }
53    else
54#endif
55    {
56      pSetCoeff0(p, tmp);
57      n_Delete(&pn, ri);
58      p_MemAdd(p->exp, m_e, length);
59      p_MemAddAdjust(p, ri);
60#ifdef HAVE_ZERODIVISORS
61      before = p;
62#endif
63      p = pNext(p);
64    }
65  }
66  p_Test(q, ri);
67  return q;
68}
69
70
Note: See TracBrowser for help on using the repository browser.