source: git/kernel/sca.h @ e2efe91

spielwiese
Last change on this file since e2efe91 was e2efe91, checked in by Motsak Oleksandr <motsak@…>, 15 years ago
*motsak: id_KillSquares doesn't call SkipZeroes by default git-svn-id: file:///usr/local/Singular/svn/trunk@11512 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.16 2009-03-02 18:06:54 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#ifdef HAVE_PLURAL
27// we must always have this test!
28inline ideal SCAQuotient(const ring r)
29{
30  assume(rIsSCA(r));
31  return r->GetNC()->SCAQuotient();
32}
33
34#include <gring.h>
35
36
37inline unsigned int scaFirstAltVar(ring r)
38{
39  assume(rIsSCA(r));
40
41  return (r->GetNC()->FirstAltVar());
42};
43
44inline 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.
53inline void scaFirstAltVar(ring r, int n)
54{
55  assume(rIsSCA(r));
56
57  r->GetNC()->FirstAltVar() = n;
58};
59
60inline 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.
75poly 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"
79void 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).
87bool 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.
98bool 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
111intvec *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
116intvec *ivGetSCAYVarWeights(const ring r);
117
118
119inline 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
138inline 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
158poly 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// optional argument bSkipZeroes allow skipping of zero entries, by
166// default - no skipping!
167ideal id_KillSquares(const ideal id,
168  const unsigned int iFirstAltVar, const unsigned int iLastAltVar,
169  const ring r, const bool bSkipZeroes = false);
170
171// for benchmarking
172bool sca_Force(ring rGR, int b, int e);
173
174
175#ifdef PLURAL_INTERNAL_DECLARATIONS
176
177// should be used only inside nc_SetupQuotient!
178// Check whether this our case:
179//  1. rG is  a commutative polynomial ring \otimes anticommutative algebra
180//  2. factor ideal rGR->qideal contains squares of all alternating variables.
181//
182// if yes, make rGR a super-commutative algebra!
183// NOTE: Factors of SuperCommutative Algebras are supported this way!
184//
185//  rG == NULL means that there is no separate base G-algebra in this
186//  case take rGR == rG
187
188// special case: bCopy == true (default value: false)
189// meaning: rGR copies structure from rG
190// (maybe with some minor changes, which don't change the type!)
191bool sca_SetupQuotient(ring rGR, ring rG, bool bCopy);
192
193#endif // PLURAL_INTERNAL_DECLARATIONS
194
195
196#else
197// these must not be used at all.
198// #define scaFirstAltVar(R) 0
199// #define scaLastAltVar(R) 0
200#endif
201#endif // #ifndef SCA_H
Note: See TracBrowser for help on using the repository browser.