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