source: git/kernel/sca.h @ 8627ad

spielwiese
Last change on this file since 8627ad was 52e2f6, checked in by Motsak Oleksandr <motsak@…>, 16 years ago
*motsak: major redesign of NC Subsystem, maybe something more... git-svn-id: file:///usr/local/Singular/svn/trunk@10739 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 5.1 KB
Line 
1#ifndef SCA_H
2#define SCA_H
3
4/****************************************
5*  Computer Algebra System SINGULAR     *
6****************************************/
7/* $Id: sca.h,v 1.12 2008-06-10 10:17:33 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!
16inline 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// we must always have this test!
27inline ideal SCAQuotient(const ring r)
28{
29  if( !rIsSCA(r) ) 
30    return currQuotient;
31
32  // SCA!
33#ifdef HAVE_PLURAL
34  return r->GetNC()->SCAQuotient();
35#else
36  // for sainity
37  return NULL;
38#endif
39}
40
41
42#ifdef HAVE_PLURAL
43#include <gring.h>
44
45
46inline unsigned int scaFirstAltVar(ring r)
47{
48  assume(rIsSCA(r));
49
50  return (r->GetNC()->FirstAltVar());
51};
52
53inline unsigned int scaLastAltVar(ring r)
54{
55  assume(rIsSCA(r));
56
57  return (r->GetNC()->LastAltVar());
58};
59
60
61// The following inlines are just helpers for setup functions.
62inline void scaFirstAltVar(ring r, int n)
63{
64  assume(rIsSCA(r));
65
66  r->GetNC()->FirstAltVar() = n;
67};
68
69inline void scaLastAltVar(ring r, int n)
70{
71  assume(rIsSCA(r));
72
73  r->GetNC()->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.
84poly sca_pp_Mult_xi_pp(unsigned int i, const poly pPoly, const ring rRing);
85
86// set pProcs for r and the variable p_Procs
87// should be used by nc_p_ProcsSet in "gring.h"
88void sca_p_ProcsSet(ring rGR, p_Procs_s* p_Procs);
89
90//////////////////////////////////////////////////////////////////////////////////////
91
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).
96bool p_IsBiHomogeneous(const poly p, 
97  const intvec *wx, const intvec *wy, 
98  const intvec *wCx, const intvec *wCy, 
99  int &dx, int &dy,
100  const ring r);
101 
102   
103//////////////////////////////////////////////////////////////////////////////////////
104
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.
107bool id_IsBiHomogeneous(const ideal id, 
108  const intvec *wx, const intvec *wy, 
109  const intvec *wCx, const intvec *wCy,
110  const ring r);
111
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
120intvec *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
125intvec *ivGetSCAYVarWeights(const ring r);
126
127
128inline 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
147inline 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
164//////////////////////////////////////////////////////////////////////////////////////
165
166// reduce polynomial p modulo <y_i^2> , i = iFirstAltVar .. iLastAltVar
167poly p_KillSquares(const poly p, 
168  const unsigned int iFirstAltVar, const unsigned int iLastAltVar, 
169  const ring r); 
170
171//////////////////////////////////////////////////////////////////////////////////////
172
173// reduce ideal id modulo <y_i^2> , i = iFirstAltVar .. iLastAltVar
174ideal id_KillSquares(const ideal id, 
175  const unsigned int iFirstAltVar, const unsigned int iLastAltVar, 
176  const ring r); 
177
178// for benchmarking
179bool sca_ForceCommutative(ring rGR, int b, int e);
180
181
182#ifdef PLURAL_INTERNAL_DECLARATIONS
183
184// should be used only inside nc_SetupQuotient!
185// Check whether this our case:
186//  1. rG is  a commutative polynomial ring \otimes anticommutative algebra
187//  2. factor ideal rGR->qideal contains squares of all alternating variables.
188//
189// if yes, make rGR a super-commutative algebra!
190// NOTE: Factors of SuperCommutative Algebras are supported this way!
191//
192//  rG == NULL means that there is no separate base G-algebra in this case take rGR == rG
193bool sca_SetupQuotient(ring rGR, ring rG);
194
195#endif // PLURAL_INTERNAL_DECLARATIONS
196
197
198#else
199// these must not be used at all.
200// #define scaFirstAltVar(R) 0
201// #define scaLastAltVar(R) 0
202#endif
203#endif // #ifndef SCA_H
Note: See TracBrowser for help on using the repository browser.