source: git/Singular/pp_Mult_mm__Template.cc @ a6a239

spielwiese
Last change on this file since a6a239 was a6a239, checked in by Olaf Bachmann <obachman@…>, 24 years ago
* new implementation of polys git-svn-id: file:///usr/local/Singular/svn/trunk@4580 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 1.7 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/***************************************************************
5 *  File:    pp_Mult_mm__Template.cc
6 *  Purpose: template for p_Mult_n
7 *  Author:  obachman (Olaf Bachmann)
8 *  Created: 8/00
9 *  Version: $Id: pp_Mult_mm__Template.cc,v 1.2 2000-09-12 16:01:12 obachman Exp $
10 *******************************************************************/
11
12/***************************************************************
13 *
14 *   Returns:  p*m
15 *   Const:    p, m
16 *   If spNoether != NULL, then monoms which are smaller
17 *   then spNoether are cut
18 *
19 ***************************************************************/
20poly pp_Mult_mm(poly p, const poly m, const poly spNoether, const ring ri)
21{
22  if (p == NULL) return NULL;
23  spolyrec rp;
24  poly q = &rp, r;
25  number ln = pGetCoeff(m);
26  omBin bin = ri->PolyBin;
27  DECLARE_LENGTH(const unsigned long length = ri->ExpLSize);
28  const unsigned long* m_e = m->exp;
29  assume(!p_nIsZero(ln,r));
30
31  if (spNoether == NULL)
32  {
33    do
34    {
35      omTypeAllocBin(poly, pNext(q), bin);
36      q = pNext(q);
37      pSetCoeff0(q, p_nMult(ln, pGetCoeff(p), ri));
38      p_MemSum(q->exp, p->exp, m_e, length);
39      p = pNext(p);
40    }
41    while (p != NULL);
42  }
43  else
44  {
45    poly r;
46    while (p != NULL)
47    {
48      omTypeAllocBin(poly, r, bin);
49      p_MemSum(r->exp, p->exp, m_e, length);
50
51      if (p_LmCmp(r, spNoether, ri) == -1)
52      {
53        omFreeBinAddr(r);
54        break;
55      }
56      q = pNext(q) = r;
57      pSetCoeff0(q, p_nMult(ln, pGetCoeff(p), ri));
58      pIter(p);
59    }
60  }
61  pNext(q) = NULL;
62
63  return pNext(&rp);
64}
65
66
Note: See TracBrowser for help on using the repository browser.