source: git/kernel/pp_Mult_nn__T.cc @ e7c6b22

spielwiese
Last change on this file since e7c6b22 was a76e11, checked in by Oliver Wienand <wienand@…>, 16 years ago
kutilc.cc: use pp_Mult_nn instead of copy and p_Mult_nn p_Minus...: compute length correct pp_Mult: return null in case of null git-svn-id: file:///usr/local/Singular/svn/trunk@10567 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 1.5 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.8 2008-02-07 08:41:00 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#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.