[94e04a] | 1 | #ifndef SCA_H |
---|
| 2 | #define SCA_H |
---|
[6dbc96] | 3 | |
---|
| 4 | /**************************************** |
---|
| 5 | * Computer Algebra System SINGULAR * |
---|
| 6 | ****************************************/ |
---|
[94e04a] | 7 | /* $Id: sca.h,v 1.10 2007-07-24 11:15:26 Singular Exp $ */ |
---|
[6dbc96] | 8 | |
---|
[86016d] | 9 | #include <ring.h> |
---|
[1daae71] | 10 | #include <gring.h> |
---|
[6dbc96] | 11 | #include <structs.h> |
---|
[ab5a00] | 12 | #include <intvec.h> |
---|
[6dbc96] | 13 | |
---|
| 14 | |
---|
[86016d] | 15 | // we must always have this test! |
---|
| 16 | inline bool rIsSCA(const ring r) |
---|
| 17 | { |
---|
| 18 | #ifdef HAVE_PLURAL |
---|
| 19 | return rIsPluralRing(r) && (ncRingType(r) == nc_exterior); |
---|
| 20 | #else |
---|
| 21 | return false; |
---|
| 22 | #endif |
---|
[6dbc96] | 23 | } |
---|
| 24 | |
---|
[47a0ae] | 25 | |
---|
| 26 | // we must always have this test! |
---|
| 27 | inline ideal SCAQuotient(const ring r) |
---|
| 28 | { |
---|
| 29 | if( !rIsSCA(r) ) |
---|
| 30 | return currQuotient; |
---|
| 31 | |
---|
| 32 | // SCA! |
---|
| 33 | #ifdef HAVE_PLURAL |
---|
| 34 | return r->nc->SCAQuotient(); |
---|
| 35 | #else |
---|
| 36 | // for sainity |
---|
| 37 | return NULL; |
---|
| 38 | #endif |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | |
---|
[86016d] | 42 | #ifdef HAVE_PLURAL |
---|
| 43 | #include <gring.h> |
---|
| 44 | |
---|
[6dbc96] | 45 | |
---|
| 46 | inline unsigned int scaFirstAltVar(ring r) |
---|
| 47 | { |
---|
| 48 | assume(rIsSCA(r)); |
---|
| 49 | |
---|
| 50 | return (r->nc->FirstAltVar()); |
---|
| 51 | }; |
---|
| 52 | |
---|
| 53 | inline unsigned int scaLastAltVar(ring r) |
---|
| 54 | { |
---|
| 55 | assume(rIsSCA(r)); |
---|
| 56 | |
---|
| 57 | return (r->nc->LastAltVar()); |
---|
| 58 | }; |
---|
| 59 | |
---|
[86016d] | 60 | |
---|
| 61 | // The following inlines are just helpers for setup functions. |
---|
[6dbc96] | 62 | inline void scaFirstAltVar(ring r, int n) |
---|
| 63 | { |
---|
| 64 | assume(rIsSCA(r)); |
---|
| 65 | |
---|
| 66 | r->nc->FirstAltVar() = n; |
---|
| 67 | }; |
---|
| 68 | |
---|
| 69 | inline void scaLastAltVar(ring r, int n) |
---|
| 70 | { |
---|
| 71 | assume(rIsSCA(r)); |
---|
| 72 | |
---|
| 73 | r->nc->LastAltVar() = n; |
---|
| 74 | }; |
---|
| 75 | |
---|
| 76 | |
---|
| 77 | |
---|
| 78 | /////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 79 | // fast procedures for for SuperCommutative Algebras: |
---|
| 80 | /////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 81 | |
---|
| 82 | // this is not a basic operation... but it for efficiency we did it specially for SCA: |
---|
| 83 | // return x_i * pPoly; preserve pPoly. |
---|
[651f6f] | 84 | poly sca_pp_Mult_xi_pp(unsigned int i, const poly pPoly, const ring rRing); |
---|
[6dbc96] | 85 | |
---|
| 86 | // set pProcs for r and the variable p_Procs |
---|
[86016d] | 87 | // should be used by nc_p_ProcsSet in "gring.h" |
---|
| 88 | void sca_p_ProcsSet(ring rGR, p_Procs_s* p_Procs); |
---|
[651f6f] | 89 | |
---|
[86016d] | 90 | ////////////////////////////////////////////////////////////////////////////////////// |
---|
[6dbc96] | 91 | |
---|
[ab5a00] | 92 | // TODO: correct the following descriptions... |
---|
| 93 | |
---|
| 94 | // tests whether p is bi-homogeneous with respect to the given variable'(component')-weights |
---|
| 95 | // ps: polynomial is bi-homogeneous iff all terms have the same bi-degree (x,y). |
---|
[86016d] | 96 | bool p_IsBiHomogeneous(const poly p, |
---|
[ab5a00] | 97 | const intvec *wx, const intvec *wy, |
---|
| 98 | const intvec *wCx, const intvec *wCy, |
---|
| 99 | int &dx, int &dy, |
---|
[86016d] | 100 | const ring r); |
---|
[ab5a00] | 101 | |
---|
| 102 | |
---|
[86016d] | 103 | ////////////////////////////////////////////////////////////////////////////////////// |
---|
[6dbc96] | 104 | |
---|
[ab5a00] | 105 | // tests whether p is bi-homogeneous with respect to the given variable'(component')-weights |
---|
| 106 | // ps: ideal is bi-homogeneous iff all its generators are bi-homogeneous polynomials. |
---|
[86016d] | 107 | bool id_IsBiHomogeneous(const ideal id, |
---|
[ab5a00] | 108 | const intvec *wx, const intvec *wy, |
---|
| 109 | const intvec *wCx, const intvec *wCy, |
---|
[86016d] | 110 | const ring r); |
---|
[6dbc96] | 111 | |
---|
[ab5a00] | 112 | |
---|
| 113 | ////////////////////////////////////////////////////////////////////////////////////// |
---|
| 114 | |
---|
| 115 | // Scecial for SCA: |
---|
| 116 | |
---|
| 117 | // returns an intvector with [nvars(r)] integers [1/0] |
---|
| 118 | // 1 - for commutative variables |
---|
| 119 | // 0 - for anticommutative variables |
---|
| 120 | intvec *ivGetSCAXVarWeights(const ring r); |
---|
| 121 | |
---|
| 122 | // returns an intvector with [nvars(r)] integers [1/0] |
---|
| 123 | // 0 - for commutative variables |
---|
| 124 | // 1 - for anticommutative variables |
---|
| 125 | intvec *ivGetSCAYVarWeights(const ring r); |
---|
| 126 | |
---|
| 127 | |
---|
| 128 | inline bool p_IsSCAHomogeneous(const poly p, |
---|
| 129 | const intvec *wCx, const intvec *wCy, |
---|
| 130 | const ring r) |
---|
| 131 | { |
---|
| 132 | // inefficient! don't use it in time-critical code! |
---|
| 133 | intvec *wx = ivGetSCAXVarWeights(r); |
---|
| 134 | intvec *wy = ivGetSCAYVarWeights(r); |
---|
| 135 | |
---|
| 136 | int x,y; |
---|
| 137 | |
---|
| 138 | bool homog = p_IsBiHomogeneous( p, wx, wy, wCx, wCy, x, y, r ); |
---|
| 139 | |
---|
| 140 | delete wx; |
---|
| 141 | delete wy; |
---|
| 142 | |
---|
| 143 | return homog; |
---|
| 144 | } |
---|
| 145 | |
---|
| 146 | |
---|
| 147 | inline bool id_IsSCAHomogeneous(const ideal id, |
---|
| 148 | const intvec *wCx, const intvec *wCy, |
---|
| 149 | const ring r) |
---|
| 150 | { |
---|
| 151 | // inefficient! don't use it in time-critical code! |
---|
| 152 | intvec *wx = ivGetSCAXVarWeights(r); |
---|
| 153 | intvec *wy = ivGetSCAYVarWeights(r); |
---|
| 154 | |
---|
| 155 | bool homog = id_IsBiHomogeneous( id, wx, wy, wCx, wCy, r ); |
---|
| 156 | |
---|
| 157 | delete wx; |
---|
| 158 | delete wy; |
---|
| 159 | |
---|
| 160 | return homog; |
---|
| 161 | } |
---|
| 162 | |
---|
| 163 | |
---|
[86016d] | 164 | ////////////////////////////////////////////////////////////////////////////////////// |
---|
[6dbc96] | 165 | |
---|
[86016d] | 166 | // reduce polynomial p modulo <y_i^2> , i = iFirstAltVar .. iLastAltVar |
---|
| 167 | poly p_KillSquares(const poly p, |
---|
| 168 | const unsigned int iFirstAltVar, const unsigned int iLastAltVar, |
---|
| 169 | const ring r); |
---|
[6dbc96] | 170 | |
---|
[86016d] | 171 | ////////////////////////////////////////////////////////////////////////////////////// |
---|
[6dbc96] | 172 | |
---|
[86016d] | 173 | // reduce ideal id modulo <y_i^2> , i = iFirstAltVar .. iLastAltVar |
---|
| 174 | ideal id_KillSquares(const ideal id, |
---|
| 175 | const unsigned int iFirstAltVar, const unsigned int iLastAltVar, |
---|
| 176 | const ring r); |
---|
[6dbc96] | 177 | |
---|
| 178 | |
---|
| 179 | #ifdef PLURAL_INTERNAL_DECLARATIONS |
---|
| 180 | |
---|
[86016d] | 181 | // should be used only inside nc_SetupQuotient! |
---|
| 182 | // Check whether this our case: |
---|
| 183 | // 1. rG is a commutative polynomial ring \otimes anticommutative algebra |
---|
| 184 | // 2. factor ideal rGR->qideal contains squares of all alternating variables. |
---|
| 185 | // |
---|
| 186 | // if yes, make rGR a super-commutative algebra! |
---|
| 187 | // NOTE: Factors of SuperCommutative Algebras are supported this way! |
---|
| 188 | bool sca_SetupQuotient(ring rGR, const ring rG); |
---|
[6dbc96] | 189 | |
---|
[86016d] | 190 | #endif // PLURAL_INTERNAL_DECLARATIONS |
---|
[6dbc96] | 191 | |
---|
| 192 | |
---|
[1daae71] | 193 | #else |
---|
[86016d] | 194 | // these must not be used at all. |
---|
| 195 | // #define scaFirstAltVar(R) 0 |
---|
| 196 | // #define scaLastAltVar(R) 0 |
---|
[d312f6] | 197 | #endif |
---|
[94e04a] | 198 | #endif // #ifndef SCA_H |
---|