source: git/kernel/p_Mult_nn__T.cc @ 4e35a89

spielwiese
Last change on this file since 4e35a89 was 4e35a89, checked in by Hans Schoenemann <hannes@…>, 13 years ago
nlInpMult used in p_Mult_nn git-svn-id: file:///usr/local/Singular/svn/trunk@14291 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[35aab3]1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/***************************************************************
5 *  File:    p_Mult_n__Template.cc
6 *  Purpose: template for p_Mult_n
7 *  Author:  obachman (Olaf Bachmann)
8 *  Created: 8/00
[341696]9 *  Version: $Id$
[35aab3]10 *******************************************************************/
11
12/***************************************************************
13 *
14 *   Returns:  p*n
15 *   Destroys: p
16 *   Const:    n
17 *
18 ***************************************************************/
19LINKAGE poly p_Mult_nn(poly p, const number n, const ring r)
20{
21  pAssume(!n_IsZero(n,r));
22  p_Test(p, r);
23
24  poly q = p;
[ac434f]25#ifdef HAVE_ZERODIVISORS
[32ed4f]26  poly old = NULL;
27#endif
[35aab3]28  while (p != NULL)
29  {
[ac434f]30#ifndef HAVE_ZERODIVISORS
[4e35a89]31    n_InpMult(pGetCoeff(p), n, r);
[a09a42]32    pIter(p);
33#else
[cea6f3]34    number tmp = n_Mult(n, pGetCoeff(p), r);
[af378f7]35    if (!nIsZero(tmp))
[a09a42]36    {
[af378f7]37       number nc = pGetCoeff(p);
38       p_SetCoeff0(p, tmp, r);
39       n_Delete(&nc, r);
[32ed4f]40       old = p;
[cea6f3]41       pIter(p);
42    }
[a09a42]43    else
44    {
45      n_Delete(&tmp, r);
[af378f7]46      if (old == NULL)
47      {
48        pIter(p);
[fb82895]49        p_LmDelete(&q, r);
[af378f7]50      }
51      else
52      { 
[fb82895]53        p_LmDelete(&p, r); 
[af378f7]54        pNext(old) = p;
55      }
[cea6f3]56    }
57#endif
[35aab3]58  }
59  p_Test(q, r);
60  return q;
61}
Note: See TracBrowser for help on using the repository browser.