source: git/libpolys/polys/templates/pp_Mult_nn__T.cc @ 85bcd6

spielwiese
Last change on this file since 85bcd6 was 6ce030f, checked in by Oleksandr Motsak <motsak@…>, 12 years ago
removal of the $Id$ svn tag from everywhere NOTE: the git SHA1 may be used instead (only on special places) NOTE: the libraries Singular/LIB/*.lib still contain the marker due to our current use of svn
  • 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 *******************************************************************/
10
11/***************************************************************
12 *
13 *   Returns:  p*n
14 *   Const:    p, n
15 *
16 ***************************************************************/
17LINKAGE poly pp_Mult_nn__T(poly p, const number n, const ring r)
18{
19  pAssume(!n_IsZero__T(n,r));
20  p_Test(p, r);
21  if (p == NULL) return NULL;
22  spolyrec rp;
23#ifdef HAVE_ZERODIVISORS
24  rp.next = NULL;
25#endif
26  poly q = &rp;
27  omBin bin = r->PolyBin;
28  DECLARE_LENGTH(const unsigned long length = r->ExpL_Size);
29
30  do
31  {
32#ifndef HAVE_ZERODIVISORS
33    p_AllocBin(pNext(q), bin, r);
34    pIter(q);
35    number nc = pGetCoeff(p);
36    pSetCoeff0(q, n_Mult__T(n, nc, r));
37    p_MemCopy__T(q->exp, p->exp, length);
38#else
39    number nc = pGetCoeff(p);
40    number tmp = n_Mult__T(n, nc, r);
41    if (! n_IsZero__T(tmp,r))
42    {
43      p_AllocBin(pNext(q), bin, r);
44      pIter(q);
45      pSetCoeff0(q, tmp);
46      p_MemCopy__T(q->exp, p->exp, length);
47    }
48    else
49      n_Delete__T(&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.