1 | #ifndef GRING_H |
---|
2 | #define GRING_H |
---|
3 | /**************************************** |
---|
4 | * Computer Algebra System SINGULAR * |
---|
5 | ****************************************/ |
---|
6 | /* $Id: gring.h,v 1.27 2009-04-03 18:28:53 motsak Exp $ */ |
---|
7 | /* |
---|
8 | * ABSTRACT additional defines etc for --with-plural |
---|
9 | */ |
---|
10 | |
---|
11 | #ifdef HAVE_PLURAL |
---|
12 | |
---|
13 | |
---|
14 | #include <structs.h> |
---|
15 | #include <ring.h> |
---|
16 | #include <matpol.h> |
---|
17 | |
---|
18 | // the part, related to the interface |
---|
19 | // Changes r, Assumes that all other input belongs to currRing |
---|
20 | BOOLEAN nc_CallPlural(matrix CC, matrix DD, poly CN, poly DN, ring r, |
---|
21 | bool bSetupQuotient = false, |
---|
22 | bool bCopyInput = true, |
---|
23 | bool bBeQuiet = false, |
---|
24 | ring curr = currRing); |
---|
25 | |
---|
26 | // BOOLEAN nc_CheckOrdCondition(matrix D, ring r); |
---|
27 | // BOOLEAN nc_CheckOrdCondition(ring r); // with D == r->GetNC()->D |
---|
28 | |
---|
29 | BOOLEAN nc_CheckSubalgebra(poly PolyVar, ring r); |
---|
30 | |
---|
31 | // BOOLEAN nc_InitMultiplication(ring r); // should call nc_p_ProcsSet! |
---|
32 | // NOTE: instead of constructing nc_struct and calling nc_InitMultiplication yourself - just create C, D and call nc_CallPlural!!! |
---|
33 | |
---|
34 | |
---|
35 | BOOLEAN rIsLikeOpposite(ring rBase, ring rCandidate); |
---|
36 | |
---|
37 | |
---|
38 | // set pProcs table for rGR and global variable p_Procs |
---|
39 | // this should be used by p_ProcsSet in p_Procs_Set.h |
---|
40 | void nc_p_ProcsSet(ring rGR, p_Procs_s* p_Procs); |
---|
41 | |
---|
42 | // this function should be used inside QRing definition! |
---|
43 | // we go from rG into factor ring rGR with factor ideal rGR->qideal. |
---|
44 | bool nc_SetupQuotient(ring rGR, const ring rG = NULL, bool bCopy = false); // rG == NULL means that there is no base G-algebra |
---|
45 | |
---|
46 | |
---|
47 | // used by "rSum" from ring.cc only! |
---|
48 | // purpose init nc structure for initially commutative ring: |
---|
49 | // "creates a commutative nc extension; "converts" comm.ring to a Plural ring" |
---|
50 | ring nc_rCreateNCcomm(ring r); |
---|
51 | |
---|
52 | void nc_rKill(ring r); // complete destructor |
---|
53 | |
---|
54 | BOOLEAN nc_rComplete(const ring src, ring dest, bool bSetupQuotient = true); // in ring.cc |
---|
55 | |
---|
56 | bool nc_rCopy(ring res, const ring r, bool bSetupQuotient); |
---|
57 | |
---|
58 | // for p_Minus_mm_Mult_qq in pInline2.h |
---|
59 | poly nc_p_Minus_mm_Mult_qq(poly p, const poly m, const poly q, int &lp, |
---|
60 | const int, const poly, const ring r); |
---|
61 | |
---|
62 | // // for p_Plus_mm_Mult_qq in pInline2.h |
---|
63 | // returns p + m*q destroys p, const: q, m |
---|
64 | poly nc_p_Plus_mm_Mult_qq(poly p, const poly m, const poly q, int &lp, |
---|
65 | const int, const ring r); |
---|
66 | |
---|
67 | |
---|
68 | // poly _gnc_p_Mult_q(poly p, poly q, const int copy, const ring r); |
---|
69 | |
---|
70 | // general multiplication: |
---|
71 | poly _nc_p_Mult_q(poly p, poly q, const ring r); |
---|
72 | poly _nc_pp_Mult_qq(const poly p, const poly q, const ring r); |
---|
73 | |
---|
74 | |
---|
75 | /* subst: */ |
---|
76 | poly nc_pSubst(poly p, int n, poly e); |
---|
77 | |
---|
78 | /* copy : */ |
---|
79 | poly nc_p_CopyGet(poly a, const ring r); |
---|
80 | poly nc_p_CopyPut(poly a, const ring r); |
---|
81 | |
---|
82 | void nc_PolyPolyRed(poly &b, poly p, number *c); |
---|
83 | |
---|
84 | |
---|
85 | |
---|
86 | poly nc_CreateShortSpoly(poly p1, poly p2, const ring r=currRing); |
---|
87 | |
---|
88 | |
---|
89 | /* brackets: p will be destroyed... */ |
---|
90 | poly nc_p_Bracket_qq(poly p, const poly q); |
---|
91 | |
---|
92 | /* twostd: */ |
---|
93 | ideal twostd(ideal I); |
---|
94 | /* Ann: */ |
---|
95 | ideal Approx_Step(ideal L); |
---|
96 | |
---|
97 | /* complete reduction routines */ |
---|
98 | |
---|
99 | matrix nc_PrintMat(int a, int b, ring r, int metric); |
---|
100 | |
---|
101 | poly p_CopyEmbed(poly p, ring srcRing, int shift, int par_shift); |
---|
102 | poly pOppose(ring Rop, poly p); |
---|
103 | ideal idOppose(ring Rop, ideal I); |
---|
104 | |
---|
105 | |
---|
106 | |
---|
107 | |
---|
108 | // returns the LCM of the head terms of a and b with the given component |
---|
109 | // NOTE: coeff will be created but remains undefined(zero?) |
---|
110 | poly p_Lcm(const poly a, const poly b, const long lCompM, const ring r); |
---|
111 | |
---|
112 | // returns the LCM of the head terms of a and b with component = max comp. of a & b |
---|
113 | // NOTE: coeff will be created but remains undefined(zero?) |
---|
114 | poly p_Lcm(const poly a, const poly b, const ring r); |
---|
115 | |
---|
116 | |
---|
117 | |
---|
118 | // //////////////////////////////////////////////////////////////////////// // |
---|
119 | // NC inlines |
---|
120 | |
---|
121 | inline nc_struct*& GetNC(ring r) |
---|
122 | { |
---|
123 | return r->GetNC(); |
---|
124 | }; |
---|
125 | |
---|
126 | inline nc_type& ncRingType(nc_struct* p) |
---|
127 | { |
---|
128 | assume(p!=NULL); |
---|
129 | return (p->ncRingType()); |
---|
130 | }; |
---|
131 | |
---|
132 | inline nc_type ncRingType(ring r) // Get |
---|
133 | { |
---|
134 | if(rIsPluralRing(r)) |
---|
135 | return (ncRingType(r->GetNC())); |
---|
136 | else |
---|
137 | return (nc_error); |
---|
138 | }; |
---|
139 | |
---|
140 | inline void ncRingType(ring r, nc_type t) // Set |
---|
141 | { |
---|
142 | assume((r != NULL) && (r->GetNC() != NULL)); |
---|
143 | ncRingType(r->GetNC()) = t; |
---|
144 | }; |
---|
145 | |
---|
146 | |
---|
147 | inline void ncRingType(nc_struct* p, nc_type t) // Set |
---|
148 | { |
---|
149 | assume(p!=NULL); |
---|
150 | ncRingType(p) = t; |
---|
151 | }; |
---|
152 | |
---|
153 | |
---|
154 | |
---|
155 | |
---|
156 | |
---|
157 | // ////////////////////////////////////////////////////// |
---|
158 | |
---|
159 | // returns m*p, does neither destroy p nor m |
---|
160 | inline poly nc_mm_Mult_pp(const poly m, const poly p, const ring r) |
---|
161 | { |
---|
162 | assume(rIsPluralRing(r)); |
---|
163 | assume(r->GetNC()->p_Procs.mm_Mult_pp!=NULL); |
---|
164 | return r->GetNC()->p_Procs.mm_Mult_pp(m, p, r); |
---|
165 | // return pp_Mult_mm( p, m, r); |
---|
166 | } |
---|
167 | |
---|
168 | |
---|
169 | // returns m*p, does destroy p, preserves m |
---|
170 | inline poly nc_mm_Mult_p(const poly m, poly p, const ring r) |
---|
171 | { |
---|
172 | assume(rIsPluralRing(r)); |
---|
173 | assume(r->GetNC()->p_Procs.mm_Mult_p!=NULL); |
---|
174 | return r->GetNC()->p_Procs.mm_Mult_p(m, p, r); |
---|
175 | // return p_Mult_mm( p, m, r); |
---|
176 | } |
---|
177 | |
---|
178 | inline poly nc_CreateSpoly(const poly p1, const poly p2, const ring r) |
---|
179 | { |
---|
180 | assume(rIsPluralRing(r)); |
---|
181 | assume(r->GetNC()->p_Procs.SPoly!=NULL); |
---|
182 | return r->GetNC()->p_Procs.SPoly(p1, p2, r); |
---|
183 | } |
---|
184 | |
---|
185 | inline poly nc_ReduceSpoly(const poly p1, poly p2, const ring r) |
---|
186 | { |
---|
187 | assume(rIsPluralRing(r)); |
---|
188 | assume(r->GetNC()->p_Procs.ReduceSPoly!=NULL); |
---|
189 | #ifdef PDEBUG |
---|
190 | // assume(p_LmDivisibleBy(p1, p2, r)); |
---|
191 | #endif |
---|
192 | return r->GetNC()->p_Procs.ReduceSPoly(p1, p2, r); |
---|
193 | } |
---|
194 | |
---|
195 | /* |
---|
196 | inline void nc_PolyReduce(poly &b, const poly p, number *c, const ring r) // nc_PolyPolyRed |
---|
197 | { |
---|
198 | assume(rIsPluralRing(r)); |
---|
199 | // assume(r->GetNC()->p_Procs.PolyReduce!=NULL); |
---|
200 | // r->GetNC()->p_Procs.PolyReduce(b, p, c, r); |
---|
201 | } |
---|
202 | */ |
---|
203 | |
---|
204 | inline void nc_kBucketPolyRed(kBucket_pt b, poly p, number *c) |
---|
205 | { |
---|
206 | assume(rIsPluralRing(currRing)); |
---|
207 | |
---|
208 | // return gnc_kBucketPolyRedNew(b, p, c); |
---|
209 | |
---|
210 | assume(currRing->GetNC()->p_Procs.BucketPolyRed!=NULL); |
---|
211 | return currRing->GetNC()->p_Procs.BucketPolyRed(b, p, c); |
---|
212 | } |
---|
213 | |
---|
214 | inline void nc_BucketPolyRed_Z(kBucket_pt b, poly p, number *c) |
---|
215 | { |
---|
216 | assume(rIsPluralRing(currRing)); |
---|
217 | |
---|
218 | // return gnc_kBucketPolyRed_ZNew(b, p, c); |
---|
219 | |
---|
220 | assume(currRing->GetNC()->p_Procs.BucketPolyRed_Z!=NULL); |
---|
221 | return currRing->GetNC()->p_Procs.BucketPolyRed_Z(b, p, c); |
---|
222 | |
---|
223 | } |
---|
224 | |
---|
225 | inline ideal nc_GB(const ideal F, const ideal Q, const intvec *w, const intvec *hilb, kStrategy strat) |
---|
226 | { |
---|
227 | assume(rIsPluralRing(currRing)); |
---|
228 | |
---|
229 | assume(currRing->GetNC()->p_Procs.GB!=NULL); |
---|
230 | return currRing->GetNC()->p_Procs.GB(F, Q, w, hilb, strat); |
---|
231 | |
---|
232 | /* |
---|
233 | if (rHasLocalOrMixedOrder(currRing)) |
---|
234 | { |
---|
235 | assume(currRing->GetNC()->p_Procs.LocalGB!=NULL); |
---|
236 | return currRing->GetNC()->p_Procs.LocalGB(F, Q, w, hilb, strat); |
---|
237 | } else |
---|
238 | { |
---|
239 | assume(currRing->GetNC()->p_Procs.GlobalGB!=NULL); |
---|
240 | return currRing->GetNC()->p_Procs.GlobalGB(F, Q, w, hilb, strat); |
---|
241 | } |
---|
242 | */ |
---|
243 | } |
---|
244 | |
---|
245 | |
---|
246 | // Macros used to access upper triangle matrices C,D... (which are actually ideals) // afaik |
---|
247 | #define UPMATELEM(i,j,nVar) ( (nVar * ((i)-1) - ((i) * ((i)-1))/2 + (j)-1)-(i) ) |
---|
248 | |
---|
249 | |
---|
250 | // inline const nc_struct* GetNC() const { return GetBasering()->GetNC(); }; |
---|
251 | |
---|
252 | |
---|
253 | // read only access to NC matrices C/D: |
---|
254 | // get C_{i,j}, 1 <= row = i < j = col <= N |
---|
255 | inline poly GetC( const ring r, int i, int j ) |
---|
256 | { |
---|
257 | assume(r!= NULL && rIsPluralRing(r)); |
---|
258 | const matrix C = GetNC(r)->C; |
---|
259 | assume(C != NULL); |
---|
260 | const int ncols = C->ncols; |
---|
261 | assume( (i > 0) && (i < j) && (j <= ncols) ); |
---|
262 | return ( C->m[ncols * ((i)-1) + (j)-1] ); |
---|
263 | }; |
---|
264 | |
---|
265 | // get D_{i,j}, 1 <= row = i < j = col <= N |
---|
266 | inline poly GetD( const ring r, int i, int j ) |
---|
267 | { |
---|
268 | assume(r!= NULL && rIsPluralRing(r)); |
---|
269 | const matrix D = GetNC(r)->D; |
---|
270 | assume(D != NULL); |
---|
271 | const int ncols = D->ncols; |
---|
272 | assume( (i > 0) && (i < j) && (j <= ncols) ); |
---|
273 | return ( D->m[ncols * ((i)-1) + (j)-1] ); |
---|
274 | }; |
---|
275 | |
---|
276 | |
---|
277 | #ifdef PLURAL_INTERNAL_DECLARATIONS |
---|
278 | |
---|
279 | // we need nc_gr_initBba for sca_gr_bba and gr_bba. |
---|
280 | void nc_gr_initBba(ideal F,kStrategy strat); |
---|
281 | BOOLEAN gnc_InitMultiplication(ring r, bool bSetupQuotient = false); // just for a moment |
---|
282 | |
---|
283 | #endif // PLURAL_INTERNAL_DECLARATIONS |
---|
284 | |
---|
285 | #endif // HAVE_PLURAL :( |
---|
286 | #endif // |
---|