source: git/libpolys/polys/templates/pp_Mult_Coeff_mm_DivSelectMult__T.cc @ 4e654a2

fieker-DuValspielwiese
Last change on this file since 4e654a2 was 38500a, checked in by Oleksandr Motsak <motsak@…>, 13 years ago
- further template fix: added "__T" suffix to _all_ labels (incl. func. names!) - todo: finish p_Numbers.h
  • Property mode set to 100644
File size: 2.2 KB
RevLine 
[35aab3]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
[341696]9 *  Version: $Id$
[35aab3]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 ***************************************************************/
[38500a]21LINKAGE poly pp_Mult_Coeff_mm_DivSelectMult__T(poly p,const poly m, const poly a, const poly b, int &shorter,const ring r)
[35aab3]22{
23  assume(rOrd_is_Comp_dp(r) && r->ExpL_Size > 2);
24  p_Test(p, r);
25  if (p == NULL) return NULL;
26  number n = pGetCoeff(m);
27  number nc;
[38500a]28  pAssume(!n_IsZero__T(n,r));
[35aab3]29
30  spolyrec rp;
31  omBin bin = r->PolyBin;
32  const unsigned long bitmask = r->divmask;
33  const unsigned long* m_e = &(m->exp[2]);
34  DECLARE_LENGTH(const unsigned long length = r->ExpL_Size);
35  DECLARE_LENGTH_2(const unsigned long length_2 = length - 2);
36
37  poly ab;
38  p_AllocBin(ab, bin, r);
39  unsigned long* ab_e = &(ab->exp[0]);
40
[38500a]41  p_MemDiff__T(ab_e, ((unsigned long*) &(a->exp[0])), ((unsigned long*) &(b->exp[0])),
[35aab3]42            length);
43
44  int Shorter = 0;
45  poly q = &rp;
46
47  do
48  {
49    p_MemCmp_Bitmask_2(m_e, &(p->exp[2]), bitmask, length_2,
50                       goto Divisible, goto NotDivisible);
51
52    NotDivisible:
53    pAssume(!p_LmDivisibleByNoComp(m, p, r));
54    Shorter++;
55    goto Iter;
56
57    Divisible:
58    pAssume(p_LmDivisibleByNoComp(m, p, r));
59    p_AllocBin(pNext(q), bin, r);
60    q = pNext(q);
61    nc = pGetCoeff(p);
[38500a]62    pSetCoeff0(q, n_Mult__T(n, nc, r));
63    p_MemSum__T(q->exp, p->exp, ab_e, length);
[35aab3]64
65    Iter:
66    pIter(p);
67  }
68  while (p != NULL);
69
70  pNext(q) = NULL;
71  p_FreeBinAddr(ab, r);
72
73  shorter = Shorter;
74  p_Test(rp.next, r);
75  return rp.next;
76}
77
78
Note: See TracBrowser for help on using the repository browser.