1 | /**************************************** |
---|
2 | * Computer Algebra System SINGULAR * |
---|
3 | ****************************************/ |
---|
4 | /*************************************************************** |
---|
5 | * File: pInline.cc |
---|
6 | * Purpose: implementation of poly Level 0 functions |
---|
7 | * Author: obachman (Olaf Bachmann) |
---|
8 | * Created: 8/00 |
---|
9 | * Version: $Id: pInline0.h,v 1.5 2000-11-23 17:34:11 obachman Exp $ |
---|
10 | *******************************************************************/ |
---|
11 | #ifndef PINLINE0_H |
---|
12 | #define PINLINE0_H |
---|
13 | |
---|
14 | #if defined(DO_PINLINE0) |
---|
15 | #define PINLINE0 static inline |
---|
16 | #else |
---|
17 | #define PINLINE0 |
---|
18 | #endif |
---|
19 | |
---|
20 | #include "mod2.h" |
---|
21 | #include "p_polys.h" |
---|
22 | |
---|
23 | PINLINE0 void p_SetCompP(poly p, int i, ring r) |
---|
24 | { |
---|
25 | while (p != NULL) |
---|
26 | { |
---|
27 | p_SetComp(p, i, r); |
---|
28 | p_SetmComp(p, r); |
---|
29 | pIter(p); |
---|
30 | } |
---|
31 | } |
---|
32 | |
---|
33 | PINLINE0 void p_SetCompP(poly p, int i, ring lmRing, ring tailRing) |
---|
34 | { |
---|
35 | if (p != NULL) |
---|
36 | { |
---|
37 | p_SetComp(p, i, lmRing); |
---|
38 | p_SetmComp(p, lmRing); |
---|
39 | p_SetCompP(pNext(p), i, tailRing); |
---|
40 | } |
---|
41 | } |
---|
42 | |
---|
43 | // returns minimal column number in the modul element a (or 0) |
---|
44 | PINLINE0 long p_MinComp(poly p, ring lmRing, ring tailRing) |
---|
45 | { |
---|
46 | long result,i; |
---|
47 | |
---|
48 | if(p==NULL) return 0; |
---|
49 | result = p_GetComp(p,lmRing); |
---|
50 | if (result != 0) |
---|
51 | { |
---|
52 | while (pNext(p)!=NULL) |
---|
53 | { |
---|
54 | pIter(p); |
---|
55 | i = p_GetComp(p,tailRing); |
---|
56 | if (i<result) result = i; |
---|
57 | } |
---|
58 | } |
---|
59 | return result; |
---|
60 | } |
---|
61 | |
---|
62 | // returns maximal column number in the modul element a (or 0) |
---|
63 | PINLINE0 long p_MaxComp(poly p, ring lmRing, ring tailRing) |
---|
64 | { |
---|
65 | long result,i; |
---|
66 | |
---|
67 | if(p==NULL) return 0; |
---|
68 | result = p_GetComp(p, lmRing); |
---|
69 | if (result != 0) |
---|
70 | { |
---|
71 | while (pNext(p)!=NULL) |
---|
72 | { |
---|
73 | pIter(p); |
---|
74 | i = p_GetComp(p, tailRing); |
---|
75 | if (i>result) result = i; |
---|
76 | } |
---|
77 | } |
---|
78 | return result; |
---|
79 | } |
---|
80 | |
---|
81 | /*************************************************************** |
---|
82 | * |
---|
83 | * poly things which are independent of ring |
---|
84 | * |
---|
85 | ***************************************************************/ |
---|
86 | PINLINE0 poly pReverse(poly p) |
---|
87 | { |
---|
88 | if (p == NULL || pNext(p) == NULL) return p; |
---|
89 | |
---|
90 | poly q = pNext(p), // == pNext(p) |
---|
91 | qn; |
---|
92 | pNext(p) = NULL; |
---|
93 | do |
---|
94 | { |
---|
95 | qn = pNext(q); |
---|
96 | pNext(q) = p; |
---|
97 | p = q; |
---|
98 | q = qn; |
---|
99 | } |
---|
100 | while (qn != NULL); |
---|
101 | return p; |
---|
102 | } |
---|
103 | |
---|
104 | |
---|
105 | /*2 |
---|
106 | * returns the length of a (numbers of monomials) |
---|
107 | */ |
---|
108 | PINLINE0 int pLength(poly a) |
---|
109 | { |
---|
110 | int l = 0; |
---|
111 | |
---|
112 | while (a!=NULL) |
---|
113 | { |
---|
114 | pIter(a); |
---|
115 | l++; |
---|
116 | } |
---|
117 | return l; |
---|
118 | } |
---|
119 | |
---|
120 | /*2 |
---|
121 | * returns the length of a (numbers of monomials) |
---|
122 | */ |
---|
123 | PINLINE0 poly pLast(poly a, int &l) |
---|
124 | { |
---|
125 | if (a == NULL) |
---|
126 | { |
---|
127 | l = 0; |
---|
128 | return NULL; |
---|
129 | } |
---|
130 | l = 1; |
---|
131 | while (pNext(a)!=NULL) |
---|
132 | { |
---|
133 | pIter(a); |
---|
134 | l++; |
---|
135 | } |
---|
136 | return a; |
---|
137 | } |
---|
138 | |
---|
139 | #endif // PINLINE_CC |
---|
140 | |
---|