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