[35aab3] | 1 | /**************************************** |
---|

| 2 | * Computer Algebra System SINGULAR * |
---|

| 3 | ****************************************/ |
---|

| 4 | /*************************************************************** |
---|

| 5 | * File: pp_Mult_nn__Template.cc |
---|

| 6 | * Purpose: template for pp_Mult_nn |
---|

| 7 | * Author: obachman (Olaf Bachmann) |
---|

| 8 | * Created: 8/00 |
---|

[341696] | 9 | * Version: $Id$ |
---|

[35aab3] | 10 | *******************************************************************/ |
---|

| 11 | |
---|

| 12 | /*************************************************************** |
---|

| 13 | * |
---|

| 14 | * Returns: p*n |
---|

| 15 | * Const: p, n |
---|

| 16 | * |
---|

| 17 | ***************************************************************/ |
---|

| 18 | LINKAGE poly pp_Mult_nn(poly p, const number n, const ring r) |
---|

| 19 | { |
---|

| 20 | pAssume(!n_IsZero(n,r)); |
---|

| 21 | p_Test(p, r); |
---|

| 22 | if (p == NULL) return NULL; |
---|

| 23 | spolyrec rp; |
---|

[a76e11] | 24 | #ifdef HAVE_ZERODIVISORS |
---|

| 25 | rp.next = NULL; |
---|

| 26 | #endif |
---|

[35aab3] | 27 | poly q = &rp; |
---|

| 28 | omBin bin = r->PolyBin; |
---|

| 29 | DECLARE_LENGTH(const unsigned long length = r->ExpL_Size); |
---|

| 30 | |
---|

| 31 | do |
---|

| 32 | { |
---|

[009d80] | 33 | #ifndef HAVE_ZERODIVISORS |
---|

[a09a42] | 34 | p_AllocBin(pNext(q), bin, r); |
---|

[493225] | 35 | pIter(q); |
---|

[a09a42] | 36 | number nc = pGetCoeff(p); |
---|

| 37 | pSetCoeff0(q, n_Mult(n, nc, r)); |
---|

| 38 | p_MemCopy(q->exp, p->exp, length); |
---|

| 39 | #else |
---|

[35aab3] | 40 | number nc = pGetCoeff(p); |
---|

[cea6f3] | 41 | number tmp = n_Mult(n, nc, r); |
---|

[a76e11] | 42 | if (! nIsZero(tmp)) |
---|

[a09a42] | 43 | { |
---|

[cea6f3] | 44 | p_AllocBin(pNext(q), bin, r); |
---|

[493225] | 45 | pIter(q); |
---|

[cea6f3] | 46 | pSetCoeff0(q, tmp); |
---|

| 47 | p_MemCopy(q->exp, p->exp, length); |
---|

| 48 | } |
---|

[a09a42] | 49 | else |
---|

| 50 | n_Delete(&tmp,r); |
---|

[cea6f3] | 51 | #endif |
---|

[35aab3] | 52 | pIter(p); |
---|

| 53 | } |
---|

| 54 | while (p != NULL); |
---|

| 55 | pNext(q) = NULL; |
---|

| 56 | |
---|

| 57 | p_Test(rp.next, r); |
---|

| 58 | return rp.next; |
---|

| 59 | } |
---|

| 60 | |
---|

| 61 | |
---|