source: git/kernel/p_Mult_nn__T.cc @ 18ff4c

spielwiese
Last change on this file since 18ff4c 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.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 *  Version: $Id: p_Mult_nn__T.cc,v 1.9 2007-05-10 08:12:42 wienand Exp $
10 *******************************************************************/
11
12/***************************************************************
13 *
14 *   Returns:  p*n
15 *   Destroys: p
16 *   Const:    n
17 *
18 ***************************************************************/
19LINKAGE poly p_Mult_nn(poly p, const number n, const ring r)
20{
21  pAssume(!n_IsZero(n,r));
22  p_Test(p, r);
23
24  poly q = p;
25#ifdef HAVE_ZERODIVISORS
26  poly old = NULL;
27#endif
28  while (p != NULL)
29  {
30#ifndef HAVE_ZERODIVISORS
31    number nc = pGetCoeff(p);
32    pSetCoeff0(p, n_Mult(n, nc, r));
33    n_Delete(&nc, r);
34    pIter(p);
35#else
36    number tmp = n_Mult(n, pGetCoeff(p), r);
37    if (tmp != NULL)
38    {
39       p_SetCoeff(p, tmp, r);
40       old = p;
41       pIter(p);
42    }
43    else
44    {
45      n_Delete(&tmp, r);
46      if (old == NULL) { q = pNext(q); }
47      else { pNext(old) = pNext(p); }
48      pIter(p);    // TODO Free Monom OLIVER
49    }
50#endif
51  }
52  p_Test(q, r);
53  return q;
54}
Note: See TracBrowser for help on using the repository browser.