[35aab3] | 1 | /**************************************** |
---|
| 2 | * Computer Algebra System SINGULAR * |
---|
| 3 | ****************************************/ |
---|
| 4 | /*************************************************************** |
---|
| 5 | * File: pp_Mult_mm__Template.cc |
---|
| 6 | * Purpose: template for p_Mult_n |
---|
| 7 | * Author: obachman (Olaf Bachmann) |
---|
| 8 | * Created: 8/00 |
---|
| 9 | *******************************************************************/ |
---|
| 10 | |
---|
| 11 | /*************************************************************** |
---|
| 12 | * |
---|
| 13 | * Returns: p*m, ll |
---|
| 14 | * ll == pLength(p*m) , if on input ll < 0 |
---|
| 15 | * pLength(p) - pLength(p*m), if on input ll >= 0 |
---|
| 16 | * Const: p, m |
---|
| 17 | * |
---|
| 18 | ***************************************************************/ |
---|
[38500a] | 19 | LINKAGE poly pp_Mult_mm_Noether__T(poly p, const poly m, const poly spNoether, int &ll, const ring ri, poly &last) |
---|
[35aab3] | 20 | { |
---|
| 21 | p_Test(p, ri); |
---|
| 22 | p_LmTest(m, ri); |
---|
| 23 | assume(spNoether != NULL); |
---|
| 24 | if (p == NULL) |
---|
| 25 | { |
---|
| 26 | ll = 0; |
---|
| 27 | last = NULL; |
---|
| 28 | return NULL; |
---|
| 29 | } |
---|
| 30 | spolyrec rp; |
---|
| 31 | poly q = &rp, r; |
---|
| 32 | const unsigned long *spNoether_exp = spNoether->exp; |
---|
| 33 | number ln = pGetCoeff(m); |
---|
| 34 | omBin bin = ri->PolyBin; |
---|
| 35 | DECLARE_LENGTH(const unsigned long length = ri->ExpL_Size); |
---|
| 36 | DECLARE_ORDSGN(const long* ordsgn = ri->ordsgn); |
---|
| 37 | const unsigned long* m_e = m->exp; |
---|
[38500a] | 38 | pAssume(!n_IsZero__T(ln,ri)); |
---|
[35aab3] | 39 | pAssume1(p_GetComp(m, ri) == 0 || p_MaxComp(p, ri) == 0); |
---|
| 40 | int l = 0; |
---|
| 41 | |
---|
| 42 | do |
---|
| 43 | { |
---|
| 44 | p_AllocBin(r, bin, ri); |
---|
[38500a] | 45 | p_MemSum__T(r->exp, p->exp, m_e, length); |
---|
| 46 | p_MemAddAdjust__T(r, ri); |
---|
[35aab3] | 47 | |
---|
[38500a] | 48 | p_MemCmp__T(r->exp, spNoether_exp, length, ordsgn, goto Continue, goto Continue, goto Break); |
---|
[35aab3] | 49 | |
---|
| 50 | Break: |
---|
| 51 | p_FreeBinAddr(r, ri); |
---|
| 52 | break; |
---|
| 53 | |
---|
| 54 | Continue: |
---|
| 55 | l++; |
---|
| 56 | q = pNext(q) = r; |
---|
[38500a] | 57 | pSetCoeff0(q, n_Mult__T(ln, pGetCoeff(p), ri)); |
---|
[35aab3] | 58 | pIter(p); |
---|
| 59 | } while (p != NULL); |
---|
| 60 | |
---|
| 61 | if (ll < 0) |
---|
| 62 | ll = l; |
---|
| 63 | else |
---|
| 64 | ll = pLength(p); |
---|
| 65 | |
---|
| 66 | if (q != &rp) |
---|
| 67 | last = q; |
---|
| 68 | pNext(q) = NULL; |
---|
| 69 | |
---|
| 70 | p_Test(pNext(&rp), ri); |
---|
| 71 | return pNext(&rp); |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | |
---|