source: git/libpolys/polys/nc/sca.h @ ee33a7

spielwiese
Last change on this file since ee33a7 was ee33a7, checked in by Oleksandr Motsak <motsak@…>, 12 years ago
FIX: eliminate some minor warnings (";")
  • Property mode set to 100644
File size: 4.9 KB
Line 
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!
10inline ideal SCAQuotient(const ring r)
11{
12  assume(rIsSCA(r));
13  return r->GetNC()->SCAQuotient();
14}
15
16
17
18static inline unsigned int scaFirstAltVar(ring r)
19{
20  assume(rIsSCA(r));
21
22  return (r->GetNC()->FirstAltVar());
23}
24
25static inline unsigned int 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.
34static inline void scaFirstAltVar(ring r, int n)
35{
36  assume(rIsSCA(r));
37
38  r->GetNC()->FirstAltVar() = n;
39}
40
41static inline void scaLastAltVar(ring r, int 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.
56poly sca_pp_Mult_xi_pp(unsigned int i, const poly pPoly, const ring rRing);
57
58// set pProcs for r and the variable p_Procs
59// should be used by nc_p_ProcsSet in "gring.h"
60void sca_p_ProcsSet(ring rGR, p_Procs_s* p_Procs);
61
62//////////////////////////////////////////////////////////////////////////////////////
63
64// TODO: correct the following descriptions...
65
66// tests whether p is bi-homogeneous with respect to the given variable'(component')-weights
67// ps: polynomial is bi-homogeneous iff all terms have the same bi-degree (x,y).
68bool p_IsBiHomogeneous(const poly p,
69  const intvec *wx, const intvec *wy,
70  const intvec *wCx, const intvec *wCy,
71  int &dx, int &dy,
72  const ring r);
73
74
75//////////////////////////////////////////////////////////////////////////////////////
76
77// tests whether p is bi-homogeneous with respect to the given variable'(component')-weights
78// ps: ideal is bi-homogeneous iff all its generators are bi-homogeneous polynomials.
79bool id_IsBiHomogeneous(const ideal id,
80  const intvec *wx, const intvec *wy,
81  const intvec *wCx, const intvec *wCy,
82  const ring r);
83
84
85//////////////////////////////////////////////////////////////////////////////////////
86
87// Scecial for SCA:
88
89// returns an intvector with [nvars(r)] integers [1/0]
90// 1 - for commutative variables
91// 0 - for anticommutative variables
92intvec *ivGetSCAXVarWeights(const ring r);
93
94// returns an intvector with [nvars(r)] integers [1/0]
95// 0 - for commutative variables
96// 1 - for anticommutative variables
97intvec *ivGetSCAYVarWeights(const ring r);
98
99
100static inline bool p_IsSCAHomogeneous(const poly p,
101  const intvec *wCx, const intvec *wCy,
102  const ring r)
103{
104  // inefficient! don't use it in time-critical code!
105  intvec *wx = ivGetSCAXVarWeights(r);
106  intvec *wy = ivGetSCAYVarWeights(r);
107
108  int x,y;
109
110  bool homog = p_IsBiHomogeneous( p, wx, wy, wCx, wCy, x, y, r );
111
112  delete wx;
113  delete wy;
114
115  return homog;
116}
117
118
119static inline bool id_IsSCAHomogeneous(const ideal id,
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  bool homog = id_IsBiHomogeneous( id, wx, wy, wCx, wCy, r );
128
129  delete wx;
130  delete wy;
131
132  return homog;
133}
134
135
136//////////////////////////////////////////////////////////////////////////////////////
137
138// reduce polynomial p modulo <y_i^2> , i = iFirstAltVar .. iLastAltVar
139poly p_KillSquares(const poly p,
140  const unsigned int iFirstAltVar, const unsigned int iLastAltVar,
141  const ring r);
142
143//////////////////////////////////////////////////////////////////////////////////////
144
145// reduce ideal id modulo <y_i^2> , i = iFirstAltVar .. iLastAltVar
146// optional argument bSkipZeroes allow skipping of zero entries, by
147// default - no skipping!
148ideal id_KillSquares(const ideal id,
149  const unsigned int iFirstAltVar, const unsigned int iLastAltVar,
150  const ring r, const bool bSkipZeroes = false);
151
152// for benchmarking
153bool sca_Force(ring rGR, int b, int e);
154
155
156#ifdef PLURAL_INTERNAL_DECLARATIONS
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!)
172bool 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
182#endif // #ifndef SCA_H
Note: See TracBrowser for help on using the repository browser.