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 | * Version: $Id$ |
---|
10 | *******************************************************************/ |
---|
11 | |
---|
12 | /*************************************************************** |
---|
13 | * |
---|
14 | * Returns: p*m, ll |
---|
15 | * ll == pLength(p*m) , if on input ll < 0 |
---|
16 | * pLength(p) - pLength(p*m), if on input ll >= 0 |
---|
17 | * Const: p, m |
---|
18 | * |
---|
19 | ***************************************************************/ |
---|
20 | LINKAGE poly pp_Mult_mm_Noether(poly p, const poly m, const poly spNoether, int &ll, const ring ri, poly &last) |
---|
21 | { |
---|
22 | p_Test(p, ri); |
---|
23 | p_LmTest(m, ri); |
---|
24 | assume(spNoether != NULL); |
---|
25 | if (p == NULL) |
---|
26 | { |
---|
27 | ll = 0; |
---|
28 | last = NULL; |
---|
29 | return NULL; |
---|
30 | } |
---|
31 | spolyrec rp; |
---|
32 | poly q = &rp, r; |
---|
33 | const unsigned long *spNoether_exp = spNoether->exp; |
---|
34 | number ln = pGetCoeff(m); |
---|
35 | omBin bin = ri->PolyBin; |
---|
36 | DECLARE_LENGTH(const unsigned long length = ri->ExpL_Size); |
---|
37 | DECLARE_ORDSGN(const long* ordsgn = ri->ordsgn); |
---|
38 | const unsigned long* m_e = m->exp; |
---|
39 | pAssume(!n_IsZero(ln,ri)); |
---|
40 | pAssume1(p_GetComp(m, ri) == 0 || p_MaxComp(p, ri) == 0); |
---|
41 | int l = 0; |
---|
42 | |
---|
43 | do |
---|
44 | { |
---|
45 | p_AllocBin(r, bin, ri); |
---|
46 | p_MemSum(r->exp, p->exp, m_e, length); |
---|
47 | p_MemAddAdjust(r, ri); |
---|
48 | |
---|
49 | p_MemCmp(r->exp, spNoether_exp, length, ordsgn, goto Continue, goto Continue, goto Break); |
---|
50 | |
---|
51 | Break: |
---|
52 | p_FreeBinAddr(r, ri); |
---|
53 | break; |
---|
54 | |
---|
55 | Continue: |
---|
56 | l++; |
---|
57 | q = pNext(q) = r; |
---|
58 | pSetCoeff0(q, n_Mult(ln, pGetCoeff(p), ri)); |
---|
59 | pIter(p); |
---|
60 | } while (p != NULL); |
---|
61 | |
---|
62 | if (ll < 0) |
---|
63 | ll = l; |
---|
64 | else |
---|
65 | ll = pLength(p); |
---|
66 | |
---|
67 | if (q != &rp) |
---|
68 | last = q; |
---|
69 | pNext(q) = NULL; |
---|
70 | |
---|
71 | p_Test(pNext(&rp), ri); |
---|
72 | return pNext(&rp); |
---|
73 | } |
---|
74 | |
---|
75 | |
---|