My Project
pp_Mult_Coeff_mm_DivSelectMult__T.cc
Go to the documentation of this file.
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  *******************************************************************/
10 
11 /***************************************************************
12  *
13  * Returns: p*Coeff(m)*a/b for such monomials pm of p, for which
14  * m is divisble by pm, shorter == #of monomials left out
15  * Assumes: m, a, b are monomials, ordering is (c, dp),
16  * (p*a) is divisble by b for all monimials in question
17  * Const: p, m, a, b
18  *
19  ***************************************************************/
20 LINKAGE poly pp_Mult_Coeff_mm_DivSelectMult__T(poly p,const poly m, const poly a, const poly b, int &shorter,const ring r)
21 {
22  assume(rOrd_is_Comp_dp(r) && r->ExpL_Size > 2);
23  p_Test(p, r);
24  if (p == NULL) return NULL;
25  number n = pGetCoeff(m);
26  number nc;
27  pAssume(!n_IsZero__T(n,r->cf));
28 
29  spolyrec rp;
30  omBin bin = r->PolyBin;
31  const unsigned long bitmask = r->divmask;
32  const unsigned long* m_e = &(m->exp[2]);
33  DECLARE_LENGTH(const unsigned long length = r->ExpL_Size);
34  DECLARE_LENGTH_2(const unsigned long length_2 = length - 2);
35 
36  poly ab;
37  p_AllocBin(ab, bin, r);
38  unsigned long* ab_e = &(ab->exp[0]);
39 
40  p_MemDiff__T(ab_e, ((unsigned long*) &(a->exp[0])), ((unsigned long*) &(b->exp[0])),
41  length);
42 
43  int Shorter = 0;
44  poly q = &rp;
45 
46  do
47  {
48  p_MemCmp_Bitmask_2(m_e, &(p->exp[2]), bitmask, length_2,
49  goto Divisible, goto NotDivisible);
50 
51  NotDivisible:
53  Shorter++;
54  goto Iter;
55 
56  Divisible:
58  p_AllocBin(pNext(q), bin, r);
59  q = pNext(q);
60  nc = pGetCoeff(p);
61  pSetCoeff0(q, n_Mult__T(n, nc, r->cf));
62  p_MemSum__T(q->exp, p->exp, ab_e, length);
63 
64  Iter:
65  pIter(p);
66  }
67  while (p != NULL);
68 
69  pNext(q) = NULL;
70  p_FreeBinAddr(ab, r);
71 
72  shorter = Shorter;
73  p_Test(rp.next, r);
74  return rp.next;
75 }
76 
77 
int m
Definition: cfEzgcd.cc:128
int p
Definition: cfModGcd.cc:4078
CanonicalForm b
Definition: cfModGcd.cc:4103
static BOOLEAN length(leftv result, leftv arg)
Definition: interval.cc:257
#define assume(x)
Definition: mod2.h:387
#define LINKAGE
Definition: mod2.h:138
#define p_FreeBinAddr(p, r)
Definition: monomials.h:255
poly next
Definition: monomials.h:24
#define pIter(p)
Definition: monomials.h:37
#define pNext(p)
Definition: monomials.h:36
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition: monomials.h:44
#define pSetCoeff0(p, n)
Definition: monomials.h:59
#define p_AllocBin(p, bin, r)
Definition: monomials.h:248
#define pAssume(cond)
Definition: monomials.h:90
#define NULL
Definition: omList.c:12
omBin_t * omBin
Definition: omStructs.h:12
static BOOLEAN p_LmDivisibleByNoComp(poly a, poly b, const ring r)
Definition: p_polys.h:1861
#define p_Test(p, r)
Definition: p_polys.h:162
LINKAGE poly pp_Mult_Coeff_mm_DivSelectMult__T(poly p, const poly m, const poly a, const poly b, int &shorter, const ring r)
static BOOLEAN rOrd_is_Comp_dp(const ring r)
Definition: ring.h:776