# source:git/kernel/pp_Mult_nn__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.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_ZERODIVISORS
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
31  do
32  {
33#ifndef HAVE_ZERODIVISORS
34    p_AllocBin(pNext(q), bin, r);
35    q = pNext(q);
36    number nc = pGetCoeff(p);
37    pSetCoeff0(q, n_Mult(n, nc, r));
38    p_MemCopy(q->exp, p->exp, length);
39#else
40    number nc = pGetCoeff(p);
41    number tmp = n_Mult(n, nc, r);
42    if (! nIsZero(tmp))
43    {
44      p_AllocBin(pNext(q), bin, r);
45      q = pNext(q);
46      pSetCoeff0(q, tmp);
47      p_MemCopy(q->exp, p->exp, length);
48    }
49    else
50      n_Delete(&tmp,r);
51#endif
52    pIter(p);
53  }
54  while (p != NULL);
55  pNext(q) = NULL;
56
57  p_Test(rp.next, r);
58  return rp.next;
59}
60
61
Note: See TracBrowser for help on using the repository browser.