source: git/kernel/pp_Mult_nn__T.cc @ b12a68

spielwiese
Last change on this file since b12a68 was b12a68, checked in by Frank Seelisch <seelisch@…>, 13 years ago
removed old switch HAVE_ZERODIVISORS git-svn-id: file:///usr/local/Singular/svn/trunk@13988 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$
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#ifdef HAVE_RINGS
25  rp.next = NULL;
26#endif
27  poly q = &rp;
28  omBin bin = r->PolyBin;
29  DECLARE_LENGTH(const unsigned long length = r->ExpL_Size);
30  do
31  {
32#ifndef HAVE_RINGS
33    p_AllocBin(pNext(q), bin, r);
34    pIter(q);
35    number nc = pGetCoeff(p);
36    pSetCoeff0(q, n_Mult(n, nc, r));
37    p_MemCopy(q->exp, p->exp, length);
38#else
39    number nc = pGetCoeff(p);
40    number tmp = n_Mult(n, nc, r);
41    if (! nIsZero(tmp))
42    {
43      p_AllocBin(pNext(q), bin, r);
44      pIter(q);
45      pSetCoeff0(q, tmp);
46      p_MemCopy(q->exp, p->exp, length);
47    }
48    else
49      n_Delete(&tmp,r);
50#endif
51    pIter(p);
52  }
53  while (p != NULL);
54  pNext(q) = NULL;
55
56  p_Test(rp.next, r);
57  return rp.next;
58}
59
60
Note: See TracBrowser for help on using the repository browser.