source: git/kernel/pp_Mult_nn__T.cc @ 07625cb

spielwiese
Last change on this file since 07625cb 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.4 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/***************************************************************
5 *  File:    pp_Mult_nn__Template.cc
6 *  Purpose: template for pp_Mult_nn
7 *  Author:  obachman (Olaf Bachmann)
8 *  Created: 8/00
9 *  Version: $Id: pp_Mult_nn__T.cc,v 1.6 2007-05-10 08:12:43 wienand Exp $
10 *******************************************************************/
11
12/***************************************************************
13 *
14 *   Returns:  p*n
15 *   Const:    p, n
16 *
17 ***************************************************************/
18LINKAGE poly pp_Mult_nn(poly p, const number n, const ring r)
19{
20  pAssume(!n_IsZero(n,r));
21  p_Test(p, r);
22  if (p == NULL) return NULL;
23  spolyrec rp;
24  poly q = &rp;
25  omBin bin = r->PolyBin;
26  DECLARE_LENGTH(const unsigned long length = r->ExpL_Size);
27
28  do
29  {
30#ifndef HAVE_ZERODIVISORS
31    p_AllocBin(pNext(q), bin, r);
32    q = pNext(q);
33    number nc = pGetCoeff(p);
34    pSetCoeff0(q, n_Mult(n, nc, r));
35    p_MemCopy(q->exp, p->exp, length);
36#else
37    number nc = pGetCoeff(p);
38    number tmp = n_Mult(n, nc, r);
39    if (tmp != NULL)
40    {
41      p_AllocBin(pNext(q), bin, r);
42      q = pNext(q);
43      pSetCoeff0(q, tmp);
44      p_MemCopy(q->exp, p->exp, length);
45    }
46    else
47      n_Delete(&tmp,r);
48#endif
49    pIter(p);
50  }
51  while (p != NULL);
52  pNext(q) = NULL;
53
54  p_Test(rp.next, r);
55  return rp.next;
56}
57
58
Note: See TracBrowser for help on using the repository browser.