[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 |
---|
| 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 | ***************************************************************/ |
---|
[38500a] | 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) |
---|
[35aab3] | 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; |
---|
[38500a] | 27 | pAssume(!n_IsZero__T(n,r)); |
---|
[35aab3] | 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 | |
---|
[38500a] | 40 | p_MemDiff__T(ab_e, ((unsigned long*) &(a->exp[0])), ((unsigned long*) &(b->exp[0])), |
---|
[35aab3] | 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: |
---|
| 52 | pAssume(!p_LmDivisibleByNoComp(m, p, r)); |
---|
| 53 | Shorter++; |
---|
| 54 | goto Iter; |
---|
| 55 | |
---|
| 56 | Divisible: |
---|
| 57 | pAssume(p_LmDivisibleByNoComp(m, p, r)); |
---|
| 58 | p_AllocBin(pNext(q), bin, r); |
---|
| 59 | q = pNext(q); |
---|
| 60 | nc = pGetCoeff(p); |
---|
[38500a] | 61 | pSetCoeff0(q, n_Mult__T(n, nc, r)); |
---|
| 62 | p_MemSum__T(q->exp, p->exp, ab_e, length); |
---|
[35aab3] | 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 | |
---|