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 | ***************************************************************/ |
---|
19 | LINKAGE poly pp_Mult_mm_Noether__T(poly p, const poly m, const poly spNoether, int &ll, const ring ri) |
---|
20 | { |
---|
21 | p_Test(p, ri); |
---|
22 | p_LmTest(m, ri); |
---|
23 | assume(spNoether != NULL); |
---|
24 | if (p == NULL) |
---|
25 | { |
---|
26 | ll = 0; |
---|
27 | return NULL; |
---|
28 | } |
---|
29 | spolyrec rp; |
---|
30 | poly q = &rp, r; |
---|
31 | const unsigned long *spNoether_exp = spNoether->exp; |
---|
32 | number ln = pGetCoeff(m); |
---|
33 | omBin bin = ri->PolyBin; |
---|
34 | DECLARE_LENGTH(const unsigned long length = ri->ExpL_Size); |
---|
35 | DECLARE_ORDSGN(const long* ordsgn = ri->ordsgn); |
---|
36 | const unsigned long* m_e = m->exp; |
---|
37 | pAssume(!n_IsZero__T(ln,ri)); |
---|
38 | pAssume1(p_GetComp(m, ri) == 0 || p_MaxComp(p, ri) == 0); |
---|
39 | int l = 0; |
---|
40 | |
---|
41 | do |
---|
42 | { |
---|
43 | p_AllocBin(r, bin, ri); |
---|
44 | p_MemSum__T(r->exp, p->exp, m_e, length); |
---|
45 | p_MemAddAdjust__T(r, ri); |
---|
46 | |
---|
47 | p_MemCmp__T(r->exp, spNoether_exp, length, ordsgn, goto Continue, goto Continue, goto Break); |
---|
48 | |
---|
49 | Break: |
---|
50 | p_FreeBinAddr(r, ri); |
---|
51 | break; |
---|
52 | |
---|
53 | Continue: |
---|
54 | l++; |
---|
55 | q = pNext(q) = r; |
---|
56 | pSetCoeff0(q, n_Mult__T(ln, pGetCoeff(p), ri)); |
---|
57 | pIter(p); |
---|
58 | } while (p != NULL); |
---|
59 | |
---|
60 | if (ll < 0) |
---|
61 | ll = l; |
---|
62 | else |
---|
63 | ll = pLength(p); |
---|
64 | |
---|
65 | pNext(q) = NULL; |
---|
66 | |
---|
67 | p_Test(pNext(&rp), ri); |
---|
68 | return pNext(&rp); |
---|
69 | } |
---|
70 | |
---|
71 | |
---|