[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 | ***************************************************************/ |
---|
| 21 | LINKAGE poly pp_Mult_Coeff_mm_DivSelectMult |
---|
| 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; |
---|
| 33 | const unsigned long bitmask = r->divmask; |
---|
| 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 | { |
---|
| 50 | p_MemCmp_Bitmask_2(m_e, &(p->exp[2]), bitmask, length_2, |
---|
| 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; |
---|
| 72 | p_FreeBinAddr(ab, r); |
---|
| 73 | |
---|
| 74 | shorter = Shorter; |
---|
| 75 | p_Test(rp.next, r); |
---|
| 76 | return rp.next; |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | |
---|