source: git/kernel/sca.h @ 022ef5

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