[35aab3] | 1 | #ifndef GRING_H |
---|
| 2 | #define GRING_H |
---|
| 3 | /**************************************** |
---|
| 4 | * Computer Algebra System SINGULAR * |
---|
| 5 | ****************************************/ |
---|
[69262fa] | 6 | /* $Id: gring.h,v 1.27 2009-04-03 18:28:53 motsak Exp $ */ |
---|
[35aab3] | 7 | /* |
---|
| 8 | * ABSTRACT additional defines etc for --with-plural |
---|
| 9 | */ |
---|
| 10 | |
---|
[d312f6] | 11 | #ifdef HAVE_PLURAL |
---|
[86016d] | 12 | |
---|
[52e2f6] | 13 | |
---|
[86016d] | 14 | #include <structs.h> |
---|
| 15 | #include <ring.h> |
---|
[1495df4] | 16 | #include <matpol.h> |
---|
[35aab3] | 17 | |
---|
[52e2f6] | 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 |
---|
[86016d] | 28 | |
---|
[e5fc4d4] | 29 | BOOLEAN nc_CheckSubalgebra(poly PolyVar, ring r); |
---|
[52e2f6] | 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 | |
---|
[b39bc1f] | 35 | BOOLEAN rIsLikeOpposite(ring rBase, ring rCandidate); |
---|
[6c0f53] | 36 | |
---|
[5a9e7b] | 37 | |
---|
[86016d] | 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); |
---|
[5a9e7b] | 41 | |
---|
[86016d] | 42 | // this function should be used inside QRing definition! |
---|
| 43 | // we go from rG into factor ring rGR with factor ideal rGR->qideal. |
---|
[022ef5] | 44 | bool nc_SetupQuotient(ring rGR, const ring rG = NULL, bool bCopy = false); // rG == NULL means that there is no base G-algebra |
---|
[5a9e7b] | 45 | |
---|
[35aab3] | 46 | |
---|
[86016d] | 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); |
---|
[35aab3] | 51 | |
---|
[022ef5] | 52 | void nc_rKill(ring r); // complete destructor |
---|
[5a9e7b] | 53 | |
---|
[52e2f6] | 54 | BOOLEAN nc_rComplete(const ring src, ring dest, bool bSetupQuotient = true); // in ring.cc |
---|
| 55 | |
---|
[022ef5] | 56 | bool nc_rCopy(ring res, const ring r, bool bSetupQuotient); |
---|
[5a9e7b] | 57 | |
---|
[86016d] | 58 | // for p_Minus_mm_Mult_qq in pInline2.h |
---|
[5a9e7b] | 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); |
---|
[86016d] | 61 | |
---|
| 62 | // // for p_Plus_mm_Mult_qq in pInline2.h |
---|
[5a9e7b] | 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 | |
---|
[35aab3] | 74 | |
---|
[68349d] | 75 | /* subst: */ |
---|
| 76 | poly nc_pSubst(poly p, int n, poly e); |
---|
| 77 | |
---|
| 78 | /* copy : */ |
---|
[5e051b] | 79 | poly nc_p_CopyGet(poly a, const ring r); |
---|
| 80 | poly nc_p_CopyPut(poly a, const ring r); |
---|
[35aab3] | 81 | |
---|
[5a9e7b] | 82 | void nc_PolyPolyRed(poly &b, poly p, number *c); |
---|
[8fbdb2] | 83 | |
---|
| 84 | |
---|
| 85 | |
---|
[f2109c] | 86 | poly nc_CreateShortSpoly(poly p1, poly p2, const ring r=currRing); |
---|
[35aab3] | 87 | |
---|
[5a9e7b] | 88 | |
---|
[69262fa] | 89 | /* brackets: p will be destroyed... */ |
---|
| 90 | poly nc_p_Bracket_qq(poly p, const poly q); |
---|
[35aab3] | 91 | |
---|
[68349d] | 92 | /* twostd: */ |
---|
[35aab3] | 93 | ideal twostd(ideal I); |
---|
[8e165ec] | 94 | /* Ann: */ |
---|
| 95 | ideal Approx_Step(ideal L); |
---|
[35aab3] | 96 | |
---|
[68349d] | 97 | /* complete reduction routines */ |
---|
[35aab3] | 98 | |
---|
| 99 | matrix nc_PrintMat(int a, int b, ring r, int metric); |
---|
| 100 | |
---|
[eb234f] | 101 | poly p_CopyEmbed(poly p, ring srcRing, int shift, int par_shift); |
---|
[b39bc1f] | 102 | poly pOppose(ring Rop, poly p); |
---|
| 103 | ideal idOppose(ring Rop, ideal I); |
---|
[8e165ec] | 104 | |
---|
[5a9e7b] | 105 | |
---|
| 106 | |
---|
| 107 | |
---|
[151000] | 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?) |
---|
[52e2f6] | 110 | poly p_Lcm(const poly a, const poly b, const long lCompM, const ring r); |
---|
[5a9e7b] | 111 | |
---|
[52e2f6] | 112 | // returns the LCM of the head terms of a and b with component = max comp. of a & b |
---|
[151000] | 113 | // NOTE: coeff will be created but remains undefined(zero?) |
---|
[52e2f6] | 114 | poly p_Lcm(const poly a, const poly b, const ring r); |
---|
[5a9e7b] | 115 | |
---|
[52e2f6] | 116 | |
---|
| 117 | |
---|
| 118 | // //////////////////////////////////////////////////////////////////////// // |
---|
| 119 | // NC inlines |
---|
| 120 | |
---|
[cf315c] | 121 | inline nc_struct*& GetNC(ring r) |
---|
| 122 | { |
---|
| 123 | return r->GetNC(); |
---|
| 124 | }; |
---|
| 125 | |
---|
[52e2f6] | 126 | inline nc_type& ncRingType(nc_struct* p) |
---|
[5a9e7b] | 127 | { |
---|
[52e2f6] | 128 | assume(p!=NULL); |
---|
[022ef5] | 129 | return (p->ncRingType()); |
---|
[5a9e7b] | 130 | }; |
---|
[35aab3] | 131 | |
---|
[cf315c] | 132 | inline nc_type ncRingType(ring r) // Get |
---|
[5a9e7b] | 133 | { |
---|
[cf315c] | 134 | if(rIsPluralRing(r)) |
---|
| 135 | return (ncRingType(r->GetNC())); |
---|
| 136 | else |
---|
| 137 | return (nc_error); |
---|
[52e2f6] | 138 | }; |
---|
[5a9e7b] | 139 | |
---|
[52e2f6] | 140 | inline void ncRingType(ring r, nc_type t) // Set |
---|
| 141 | { |
---|
| 142 | assume((r != NULL) && (r->GetNC() != NULL)); |
---|
[cf315c] | 143 | ncRingType(r->GetNC()) = t; |
---|
[5a9e7b] | 144 | }; |
---|
| 145 | |
---|
[cf315c] | 146 | |
---|
| 147 | inline void ncRingType(nc_struct* p, nc_type t) // Set |
---|
[52e2f6] | 148 | { |
---|
[cf315c] | 149 | assume(p!=NULL); |
---|
| 150 | ncRingType(p) = t; |
---|
| 151 | }; |
---|
| 152 | |
---|
[52e2f6] | 153 | |
---|
[5a9e7b] | 154 | |
---|
| 155 | |
---|
| 156 | |
---|
| 157 | // ////////////////////////////////////////////////////// |
---|
| 158 | |
---|
| 159 | // returns m*p, does neither destroy p nor m |
---|
[d5f9aea] | 160 | inline poly nc_mm_Mult_pp(const poly m, const poly p, const ring r) |
---|
[5a9e7b] | 161 | { |
---|
| 162 | assume(rIsPluralRing(r)); |
---|
[52e2f6] | 163 | assume(r->GetNC()->p_Procs.mm_Mult_pp!=NULL); |
---|
| 164 | return r->GetNC()->p_Procs.mm_Mult_pp(m, p, r); |
---|
[5a9e7b] | 165 | // return pp_Mult_mm( p, m, r); |
---|
| 166 | } |
---|
| 167 | |
---|
| 168 | |
---|
| 169 | // returns m*p, does destroy p, preserves m |
---|
[86016d] | 170 | inline poly nc_mm_Mult_p(const poly m, poly p, const ring r) |
---|
[5a9e7b] | 171 | { |
---|
| 172 | assume(rIsPluralRing(r)); |
---|
[52e2f6] | 173 | assume(r->GetNC()->p_Procs.mm_Mult_p!=NULL); |
---|
| 174 | return r->GetNC()->p_Procs.mm_Mult_p(m, p, r); |
---|
[5a9e7b] | 175 | // return p_Mult_mm( p, m, r); |
---|
| 176 | } |
---|
| 177 | |
---|
[19370c] | 178 | inline poly nc_CreateSpoly(const poly p1, const poly p2, const ring r) |
---|
[5a9e7b] | 179 | { |
---|
| 180 | assume(rIsPluralRing(r)); |
---|
[52e2f6] | 181 | assume(r->GetNC()->p_Procs.SPoly!=NULL); |
---|
| 182 | return r->GetNC()->p_Procs.SPoly(p1, p2, r); |
---|
[5a9e7b] | 183 | } |
---|
| 184 | |
---|
[19370c] | 185 | inline poly nc_ReduceSpoly(const poly p1, poly p2, const ring r) |
---|
[5a9e7b] | 186 | { |
---|
| 187 | assume(rIsPluralRing(r)); |
---|
[52e2f6] | 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); |
---|
[5a9e7b] | 193 | } |
---|
| 194 | |
---|
[8fbdb2] | 195 | /* |
---|
| 196 | inline void nc_PolyReduce(poly &b, const poly p, number *c, const ring r) // nc_PolyPolyRed |
---|
| 197 | { |
---|
| 198 | assume(rIsPluralRing(r)); |
---|
[52e2f6] | 199 | // assume(r->GetNC()->p_Procs.PolyReduce!=NULL); |
---|
| 200 | // r->GetNC()->p_Procs.PolyReduce(b, p, c, r); |
---|
[8fbdb2] | 201 | } |
---|
| 202 | */ |
---|
| 203 | |
---|
[19370c] | 204 | inline void nc_kBucketPolyRed(kBucket_pt b, poly p, number *c) |
---|
[5a9e7b] | 205 | { |
---|
| 206 | assume(rIsPluralRing(currRing)); |
---|
| 207 | |
---|
| 208 | // return gnc_kBucketPolyRedNew(b, p, c); |
---|
| 209 | |
---|
[52e2f6] | 210 | assume(currRing->GetNC()->p_Procs.BucketPolyRed!=NULL); |
---|
| 211 | return currRing->GetNC()->p_Procs.BucketPolyRed(b, p, c); |
---|
[5a9e7b] | 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 | |
---|
[52e2f6] | 220 | assume(currRing->GetNC()->p_Procs.BucketPolyRed_Z!=NULL); |
---|
| 221 | return currRing->GetNC()->p_Procs.BucketPolyRed_Z(b, p, c); |
---|
[5a9e7b] | 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 | |
---|
[52e2f6] | 229 | assume(currRing->GetNC()->p_Procs.GB!=NULL); |
---|
| 230 | return currRing->GetNC()->p_Procs.GB(F, Q, w, hilb, strat); |
---|
[5a9e7b] | 231 | |
---|
| 232 | /* |
---|
[b9642b1] | 233 | if (rHasLocalOrMixedOrder(currRing)) |
---|
[5a9e7b] | 234 | { |
---|
[52e2f6] | 235 | assume(currRing->GetNC()->p_Procs.LocalGB!=NULL); |
---|
| 236 | return currRing->GetNC()->p_Procs.LocalGB(F, Q, w, hilb, strat); |
---|
[5a9e7b] | 237 | } else |
---|
| 238 | { |
---|
[52e2f6] | 239 | assume(currRing->GetNC()->p_Procs.GlobalGB!=NULL); |
---|
| 240 | return currRing->GetNC()->p_Procs.GlobalGB(F, Q, w, hilb, strat); |
---|
[5a9e7b] | 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 | |
---|
[86016d] | 249 | |
---|
[1495df4] | 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 | |
---|
[86016d] | 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); |
---|
[52e2f6] | 281 | BOOLEAN gnc_InitMultiplication(ring r, bool bSetupQuotient = false); // just for a moment |
---|
[86016d] | 282 | |
---|
| 283 | #endif // PLURAL_INTERNAL_DECLARATIONS |
---|
| 284 | |
---|
| 285 | #endif // HAVE_PLURAL :( |
---|
| 286 | #endif // |
---|