source: git/libpolys/polys/templates/pp_Mult_nn__T.cc @ 38500a

spielwiese
Last change on this file since 38500a was 38500a, checked in by Oleksandr Motsak <motsak@…>, 13 years ago
- further template fix: added "__T" suffix to _all_ labels (incl. func. names!) - todo: finish p_Numbers.h
  • 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__T(poly p, const number n, const ring r)
19{
20  pAssume(!n_IsZero__T(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    pIter(q);
36    number nc = pGetCoeff(p);
37    pSetCoeff0(q, n_Mult__T(n, nc, r));
38    p_MemCopy__T(q->exp, p->exp, length);
39#else
40    number nc = pGetCoeff(p);
41    number tmp = n_Mult__T(n, nc, r);
42    if (! nIsZero(tmp))
43    {
44      p_AllocBin(pNext(q), bin, r);
45      pIter(q);
46      pSetCoeff0(q, tmp);
47      p_MemCopy__T(q->exp, p->exp, length);
48    }
49    else
50      n_Delete__T(&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.