# source:git/Singular/pp_Mult_Coeff_mm_DivSelectMult__Template.cc@fa1f52

spielwiese
Last change on this file since fa1f52 was fa1f52, checked in by Olaf Bachmann <obachman@…>, 23 years ago
• Property mode set to `100644`
File size: 2.3 KB
Line
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/***************************************************************
5 *  File:    pp_Mult_Coeff_mm_DivSelectMult__Template.cc
6 *  Purpose: template for pp_Mult_Coeff_mm__DivSelectMult
7 *  Author:  obachman (Olaf Bachmann)
8 *  Created: 8/00
9 *  Version: \$Id: pp_Mult_Coeff_mm_DivSelectMult__Template.cc,v 1.2 2000-12-31 15:54:47 obachman Exp \$
10 *******************************************************************/
11
12/***************************************************************
13 *
14 *   Returns:  p*Coeff(m)*a/b for such monomials pm of p, for which
15 *             m is divisble by pm, shorter == #of monomials left out
16 *   Assumes:  m, a, b are monomials, ordering is (c, dp),
17 *            (p*a) is divisble by b for all monimials in question
18 *   Const:    p, m, a, b
19 *
20 ***************************************************************/
22  (poly p,const poly m, const poly a, const poly b, int &shorter,const ring r)
23{
24  assume(rOrd_is_Comp_dp(r) && r->ExpL_Size > 2);
25  p_Test(p, r);
26  if (p == NULL) return NULL;
27  number n = pGetCoeff(m);
28  number nc;
29  pAssume(!n_IsZero(n,r));
30
31  spolyrec rp;
32  omBin bin = r->PolyBin;
34  const unsigned long* m_e = &(m->exp[2]);
35  DECLARE_LENGTH(const unsigned long length = r->ExpL_Size);
36  DECLARE_LENGTH_2(const unsigned long length_2 = length - 2);
37
38  poly ab;
39  p_AllocBin(ab, bin, r);
40  unsigned long* ab_e = &(ab->exp[0]);
41
42  p_MemDiff(ab_e, ((unsigned long*) &(a->exp[0])), ((unsigned long*) &(b->exp[0])),
43            length);
44
45  int Shorter = 0;
46  poly q = &rp;
47
48  do
49  {
51                       goto Divisible, goto NotDivisible);
52
53    NotDivisible:
54    pAssume(!p_LmDivisibleByNoComp(m, p, r));
55    Shorter++;
56    goto Iter;
57
58    Divisible:
59    pAssume(p_LmDivisibleByNoComp(m, p, r));
60    p_AllocBin(pNext(q), bin, r);
61    q = pNext(q);
62    nc = pGetCoeff(p);
63    pSetCoeff0(q, n_Mult(n, nc, r));
64    p_MemSum(q->exp, p->exp, ab_e, length);
65
66    Iter:
67    pIter(p);
68  }
69  while (p != NULL);
70
71  pNext(q) = NULL;