[35aab3] | 1 | /**************************************** |
---|
| 2 | * Computer Algebra System SINGULAR * |
---|
| 3 | ****************************************/ |
---|
| 4 | /*************************************************************** |
---|
| 5 | * File: p_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 |
---|
| 14 | * Const: m |
---|
| 15 | * Destroys: p |
---|
| 16 | * |
---|
| 17 | ***************************************************************/ |
---|
[38500a] | 18 | LINKAGE poly p_Mult_mm__T(poly p, const poly m, const ring ri) |
---|
[35aab3] | 19 | { |
---|
| 20 | p_Test(p, ri); |
---|
| 21 | p_LmTest(m, ri); |
---|
| 22 | pAssume(m != NULL); |
---|
[04b7a73] | 23 | assume(p!=NULL); |
---|
[35aab3] | 24 | poly q = p; |
---|
| 25 | number ln = pGetCoeff(m); |
---|
| 26 | number pn; |
---|
| 27 | DECLARE_LENGTH(const unsigned long length = ri->ExpL_Size); |
---|
| 28 | const unsigned long* m_e = m->exp; |
---|
[c85b30] | 29 | pAssume(!n_IsZero__T(ln,ri->cf)); |
---|
[35aab3] | 30 | |
---|
[ac434f] | 31 | #ifdef HAVE_ZERODIVISORS |
---|
[07b6ac] | 32 | poly before = p; |
---|
| 33 | #endif |
---|
[35aab3] | 34 | while (p != NULL) |
---|
| 35 | { |
---|
| 36 | pn = pGetCoeff(p); |
---|
[c85b30] | 37 | number tmp = n_Mult__T(ln, pn, ri->cf); |
---|
[ac434f] | 38 | #ifdef HAVE_ZERODIVISORS |
---|
[c85b30] | 39 | if (n_IsZero__T(tmp, ri->cf)) |
---|
[a09a42] | 40 | { |
---|
[c85b30] | 41 | n_Delete__T(&tmp, ri->cf); |
---|
[a09a42] | 42 | if (before == p) |
---|
| 43 | { |
---|
[07b6ac] | 44 | p = p_LmDeleteAndNext(p, ri); |
---|
[cea6f3] | 45 | before = p; |
---|
| 46 | q = p; |
---|
| 47 | } |
---|
[a09a42] | 48 | else |
---|
| 49 | { |
---|
[07b6ac] | 50 | p = p_LmDeleteAndNext(p, ri); |
---|
| 51 | pNext(before) = p; |
---|
[cea6f3] | 52 | } |
---|
| 53 | } |
---|
| 54 | else |
---|
| 55 | #endif |
---|
| 56 | { |
---|
| 57 | pSetCoeff0(p, tmp); |
---|
[c85b30] | 58 | n_Delete__T(&pn, ri->cf); |
---|
[38500a] | 59 | p_MemAdd__T(p->exp, m_e, length); |
---|
| 60 | p_MemAddAdjust__T(p, ri); |
---|
[ac434f] | 61 | #ifdef HAVE_ZERODIVISORS |
---|
[cea6f3] | 62 | before = p; |
---|
| 63 | #endif |
---|
| 64 | p = pNext(p); |
---|
| 65 | } |
---|
[35aab3] | 66 | } |
---|
| 67 | p_Test(q, ri); |
---|
| 68 | return q; |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | |
---|