spielwiese
Last change
on this file since 341696 was
341696,
checked in by Hans Schönemann <hannes@…>, 14 years ago
|
Adding Id property to all files
git-svn-id: file:///usr/local/Singular/svn/trunk@12231 2c84dea3-7e68-4137-9b89-c4e89433aadc
|
-
Property mode set to
100644
|
File size:
1.6 KB
|
Line | |
---|
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 | * Version: $Id$ |
---|
10 | *******************************************************************/ |
---|
11 | |
---|
12 | /*************************************************************** |
---|
13 | * |
---|
14 | * Returns: p*m |
---|
15 | * Const: m |
---|
16 | * Destroys: p |
---|
17 | * |
---|
18 | ***************************************************************/ |
---|
19 | LINKAGE poly p_Mult_mm(poly p, const poly m, const ring ri) |
---|
20 | { |
---|
21 | p_Test(p, ri); |
---|
22 | p_LmTest(m, ri); |
---|
23 | if (p == NULL) return NULL; |
---|
24 | pAssume(m != NULL); |
---|
25 | poly q = p; |
---|
26 | number ln = pGetCoeff(m); |
---|
27 | number pn; |
---|
28 | DECLARE_LENGTH(const unsigned long length = ri->ExpL_Size); |
---|
29 | const unsigned long* m_e = m->exp; |
---|
30 | pAssume(!n_IsZero(ln,ri)); |
---|
31 | |
---|
32 | #ifdef HAVE_ZERODIVISORS |
---|
33 | poly before = p; |
---|
34 | #endif |
---|
35 | while (p != NULL) |
---|
36 | { |
---|
37 | pn = pGetCoeff(p); |
---|
38 | number tmp = n_Mult(ln, pn, ri); |
---|
39 | #ifdef HAVE_ZERODIVISORS |
---|
40 | if (n_IsZero(tmp, ri)) |
---|
41 | { |
---|
42 | n_Delete(&tmp, ri); |
---|
43 | if (before == p) |
---|
44 | { |
---|
45 | p = p_LmDeleteAndNext(p, ri); |
---|
46 | before = p; |
---|
47 | q = p; |
---|
48 | } |
---|
49 | else |
---|
50 | { |
---|
51 | p = p_LmDeleteAndNext(p, ri); |
---|
52 | pNext(before) = p; |
---|
53 | } |
---|
54 | } |
---|
55 | else |
---|
56 | #endif |
---|
57 | { |
---|
58 | pSetCoeff0(p, tmp); |
---|
59 | n_Delete(&pn, ri); |
---|
60 | p_MemAdd(p->exp, m_e, length); |
---|
61 | p_MemAddAdjust(p, ri); |
---|
62 | #ifdef HAVE_ZERODIVISORS |
---|
63 | before = p; |
---|
64 | #endif |
---|
65 | p = pNext(p); |
---|
66 | } |
---|
67 | } |
---|
68 | p_Test(q, ri); |
---|
69 | return q; |
---|
70 | } |
---|
71 | |
---|
72 | |
---|
Note: See
TracBrowser
for help on using the repository browser.