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