My Project
Loading...
Searching...
No Matches
nc.h
Go to the documentation of this file.
1#ifndef POLYS_NC_H
2#define POLYS_NC_H
3
5#include "polys/kbuckets.h"
6#include "polys/matpol.h"
7
8#ifdef HAVE_PLURAL
9
10matrix nc_PrintMat(int a, int b, ring r, int metric);
11
13{
14 nc_error = -1, // Something's gone wrong!
15 nc_general = 0, /* yx=q xy+... */
16 nc_skew, /*1*/ /* yx=q xy */
17 nc_comm, /*2*/ /* yx= xy */
18 nc_lie, /*3*/ /* yx=xy+... */
19 nc_undef, /*4*/ /* for internal reasons */
20
21 nc_exterior /*5*/ // Exterior Algebra(SCA): yx= -xy & (!:) x^2 = 0
22};
23
24
25// //////////////////////////////////////////////////////
26
27
28/// checks whether rings rBase and rCandidate
29/// could be opposite to each other
30/// returns TRUE if it is so
31BOOLEAN rIsLikeOpposite(ring rBase, ring rCandidate);
32
33
34
35// Macros used to access upper triangle matrices C,D... (which are actually ideals) // afaik
36#define UPMATELEM(i,j,nVar) ( (nVar * ((i)-1) - ((i) * ((i)-1))/2 + (j)-1)-(i) )
37
38/// complete destructor
39void nc_rKill(ring r);
40
41
42BOOLEAN nc_CheckSubalgebra(poly PolyVar, ring r);
43
44// NC pProcs:
45typedef poly (*SPoly_Proc_Ptr)(const poly p1, const poly p2, const ring r);
46typedef poly (*SPolyReduce_Proc_Ptr)(const poly p1, poly p2, const ring r);
47
48typedef void (*bucket_Proc_Ptr)(kBucket_pt b, poly p, number *c, BOOLEAN reduce);
49
51{
52public:
53 bucket_Proc_Ptr BucketPolyRed_NF; /* reduce b with p, c==1*/
54 bucket_Proc_Ptr BucketPolyRed_Z; /* reduce c*b with p, return also c */
55
58
59 void* GB; ///< From "gb_hack.h"
60// GlobalGB, // BBA
61// LocalGB; // MORA
62};
63
66
68{
70 //ring basering; // the ring C,D,.. live in (commutative ring with this NC structure!)
71
72 // initial data: square matrices rVar() x rVar()
73 // logically: upper triangular!!!
74 // TODO: eliminate this waste of memory!!!!
77
78 // computed data:
79 matrix *MT; // size 0.. (rVar()*rVar()-1)/2
81 int *MTsize; // size 0.. (rVar()*rVar()-1)/2
82
83 // IsSkewConstant indicates whethere coeffs C_ij are all equal,
84 // effective together with nc_type=nc_skew
86
87 private:
88 // internal data for different implementations
89 // if dynamic => must be deallocated in destructor (nc_rKill!)
90 union
91 {
92 struct
93 {
94 // treat variables from iAltVarsStart till iAltVarsEnd as alternating vars.
95 // these variables should have odd degree, though that will not be checked
96 // iAltVarsStart, iAltVarsEnd are only used together with nc_type=nc_exterior
97 // 1 <= iAltVarsStart <= iAltVarsEnd <= r->N
98 short iFirstAltVar, iLastAltVar; // = 0 by default
99
100 // for factors of super-commutative algebras we need
101 // the part of general quotient ideal modulo squares!
102 ideal idSCAQuotient; // = NULL by default. // must be deleted in Kill!
103 } sca;
105
106 public:
107
108 inline nc_type& ncRingType() { return (type); };
109 inline nc_type ncRingType() const { return (type); };
110
111 inline short& FirstAltVar()
112 { assume(ncRingType() == nc_exterior); return (data.sca.iFirstAltVar); };
113 inline short& LastAltVar ()
114 { assume(ncRingType() == nc_exterior); return (data.sca.iLastAltVar ); };
115
116 inline short FirstAltVar() const
117 { assume(ncRingType() == nc_exterior); return (data.sca.iFirstAltVar); };
118 inline short LastAltVar () const
119 { assume(ncRingType() == nc_exterior); return (data.sca.iLastAltVar ); };
120
121 inline ideal& SCAQuotient()
122 { assume(ncRingType() == nc_exterior); return (data.sca.idSCAQuotient); };
123 private:
124
127
128 public:
129
131 { return (m_Multiplier); };
132
134 { return (m_Multiplier); };
135
136
138 { return (m_PowerMultiplier); };
139
141 { return (m_PowerMultiplier); };
142
143 public:
144 nc_pProcs p_Procs; // NC procedures.
145
146};
147
148
149
150
151// //////////////////////////////////////////////////////////////////////// //
152// NC inlines
153
154static inline nc_struct*& GetNC(ring r)
155{
156 return r->GetNC();
157}
158
160{
161 assume(p!=NULL);
162 return (p->ncRingType());
163}
164
165static inline nc_type ncRingType(ring r) // Get
166{
167 if(rIsPluralRing(r))
168 return (ncRingType(r->GetNC()));
169 else
170 return (nc_error);
171}
172
173static inline void ncRingType(ring r, nc_type t) // Set
174{
175 assume((r != NULL) && (r->GetNC() != NULL));
176 ncRingType(r->GetNC()) = t;
177}
178
179static inline void ncRingType(nc_struct* p, nc_type t) // Set
180{
181 assume(p!=NULL);
182 ncRingType(p) = t;
183}
184
185
186
187
188// //////////////////////////////////////////////////////////////////////// //
189// we must always have this test!?
190static inline bool rIsSCA(const ring r)
191{
192#ifdef HAVE_PLURAL
193 return rIsPluralRing(r) && (ncRingType(r) == nc_exterior);
194#else
195 return false;
196#endif
197}
198
199// //////////////////////////////////////////////////////////////////////// //
200// NC inlines
201
202
203/// general NC-multiplication with destruction
204poly _nc_p_Mult_q(poly p, poly q, const ring r);
205
206/// general NC-multiplication without destruction
207poly _nc_pp_Mult_qq(const poly p, const poly q, const ring r);
208
209
210
211/// for p_Minus_mm_Mult_qq in pInline2.h
212poly nc_p_Minus_mm_Mult_qq(poly p, const poly m, const poly q, int &lp,
213 const poly, const ring r);
214
215// // for p_Plus_mm_Mult_qq in pInline2.h
216// returns p + m*q destroys p, const: q, m
217poly nc_p_Plus_mm_Mult_qq(poly p, const poly m, const poly q, int &lp,
218 const int, const ring r);
219
220
221
222
223// returns m*p, does neither destroy p nor m
224static inline poly nc_mm_Mult_pp(const poly m, const poly p, const ring r)
225{
226 assume(rIsNCRing(r));
227 assume(r->p_Procs->pp_mm_Mult!=NULL);
228 return r->p_Procs->pp_mm_Mult(p, m, r);
229}
230
231
232// returns m*p, does destroy p, preserves m
233static inline poly nc_mm_Mult_p(const poly m, poly p, const ring r)
234{
236 assume(r->p_Procs->p_mm_Mult!=NULL);
237 return r->p_Procs->p_mm_Mult(p, m, r);
238// return p_Mult_mm( p, m, r);
239}
240
241static inline poly nc_CreateSpoly(const poly p1, const poly p2, const ring r)
242{
244 assume(r->GetNC()->p_Procs.SPoly!=NULL);
245 return r->GetNC()->p_Procs.SPoly(p1, p2, r);
246}
247
248// ?
249poly nc_CreateShortSpoly(poly p1, poly p2, const ring r);
250
251/* brackets: p will be destroyed... */
252poly nc_p_Bracket_qq(poly p, const poly q, const ring r);
253
254static inline poly nc_ReduceSpoly(const poly p1, poly p2, const ring r)
255{
257 assume(r->GetNC()->p_Procs.ReduceSPoly!=NULL);
258#ifdef PDEBUG
259// assume(p_LmDivisibleBy(p1, p2, r));
260#endif
261 return r->GetNC()->p_Procs.ReduceSPoly(p1, p2, r);
262}
263
264void nc_PolyPolyRed(poly &b, poly p, number *c, const ring r);
265
266/*
267static inline void nc_PolyReduce(poly &b, const poly p, number *c, const ring r) // nc_PolyPolyRed
268{
269 assume(rIsPluralRing(r));
270// assume(r->GetNC()->p_Procs.PolyReduce!=NULL);
271// r->GetNC()->p_Procs.PolyReduce(b, p, c, r);
272}
273*/
274
275static inline void nc_kBucketPolyRed_NF(kBucket_pt b, poly p, number *c, BOOLEAN reduce)
276{
277 const ring r = b->bucket_ring;
279
280 assume(r->GetNC()->p_Procs.BucketPolyRed_NF!=NULL);
281 return r->GetNC()->p_Procs.BucketPolyRed_NF(b, p, c, reduce);
282}
283
284static inline void nc_kBucketPolyRed_Z(kBucket_pt b, poly p, number *c, BOOLEAN reduce)
285{
286 const ring r = b->bucket_ring;
288
289 assume(r->GetNC()->p_Procs.BucketPolyRed_Z!=NULL);
290 return r->GetNC()->p_Procs.BucketPolyRed_Z(b, p, c, reduce);
291
292}
293
294/* subst: */
295poly nc_pSubst(poly p, int n, poly e, const ring r);
296
297// the part, related to the interface
298// Changes r, Assumes that all other input belongs to curr
299BOOLEAN nc_CallPlural(matrix cc, matrix dd, poly cn, poly dn, ring r,
300 bool bSetupQuotient, //< false
301 bool bCopyInput, //< true
302 bool bBeQuiet, //< false
303 ring curr,
304 bool dummy_ring = false
305 /* allow to create a nc-ring with 1 variable*/);
306
307
308// this function should be used inside QRing definition!
309// we go from rG into factor ring rGR with factor ideal rGR->qideal.
310bool nc_SetupQuotient(ring rGR, const ring rG = NULL, bool bCopy = false); // rG == NULL means that there is no base G-algebra
311
312BOOLEAN nc_rComplete(const ring src, ring dest, bool bSetupQuotient = true); // in ring.cc
313
314bool nc_rCopy(ring res, const ring r, bool bSetupQuotient);
315
316poly pOppose(ring Rop_src, poly p, const ring Rop_dst);
317ideal idOppose(ring Rop_src, ideal I, const ring Rop_dst);
318
319const int GENERICMASK = 0x000; // gnc... must do its dirty job first!
320const int SCAMASK = 0x001;
321
322#if 0
323static const bool bNoPluralMultiplication = false; // use only formula shortcuts in my OOP Multiplier
324// the following make sense only if bNoPluralMultiplication is false:
325static const bool bNoFormula = true; // don't use any formula shortcuts
326static const bool bNoCache = false; // only formula whenever possible, only make sanse if bNoFormula is false!
327#endif
328
329// false, true, false == old "good" Plural
330// false, false ==>> Plural + Cache + Direct Formula - not much
331// false, false, true ==>> Plural Mult + Direct Formula (no ~cache)
332// true, *, * == new OOP multiplication!
333
334const int NOPLURALMASK= 0x002; // bNoPluralMultiplication
335const int NOFORMULAMASK=0x004; // bNoFormula
336const int NOCACHEMASK = 0x008; // bNoCache
337
338const int TESTSYZSCAMASK = 0x0100 | SCAMASK;
339
340
341
342// NCExtensions Mask Property
343int& getNCExtensions();
344int setNCExtensions(int iMask);
345
346// Test
347bool ncExtensions(int iMask); // = 0x0FFFF
348
349
350
351#ifdef PLURAL_INTERNAL_DECLARATIONS
352
353// set pProcs table for rGR and global variable p_Procs
354// this should be used by p_ProcsSet in p_Procs_Set.h
355void nc_p_ProcsSet(ring rGR, p_Procs_s* p_Procs);
356
357
358#include "polys/matpol.h"
359
360// read only access to NC matrices C/D:
361// get C_{i,j}, 1 <= row = i < j = col <= N
362static inline poly GetC( const ring r, int i, int j )
363{
364 assume(r!= NULL && rIsPluralRing(r));
365 const matrix C = GetNC(r)->C;
366 assume(C != NULL);
367 const int ncols = C->ncols;
368 assume( (i > 0) && (i < j) && (j <= ncols) );
369 return ( C->m[ncols * ((i)-1) + (j)-1] );
370}
371
372// get D_{i,j}, 1 <= row = i < j = col <= N
373static inline poly GetD( const ring r, int i, int j )
374{
375 assume(r!= NULL && rIsPluralRing(r));
376 const matrix D = GetNC(r)->D;
377 assume(D != NULL);
378 const int ncols = D->ncols;
379 assume( (i > 0) && (i < j) && (j <= ncols) );
380 return ( D->m[ncols * ((i)-1) + (j)-1] );
381}
382
383#endif // PLURAL_INTERNAL_DECLARATIONS
384
385#endif /* HAVE_PLURAL */
386
387#endif /* POLYS_NC_H */
int BOOLEAN
Definition: auxiliary.h:87
CanonicalForm reduce(const CanonicalForm &f, const CanonicalForm &M)
polynomials in M.mvar() are considered coefficients M univariate monic polynomial the coefficients of...
Definition: cf_ops.cc:660
int m
Definition: cfEzgcd.cc:128
int i
Definition: cfEzgcd.cc:132
int p
Definition: cfModGcd.cc:4078
CanonicalForm b
Definition: cfModGcd.cc:4103
int int ncols
Definition: cf_linsys.cc:32
int ncols
Definition: matpol.h:21
poly * m
Definition: matpol.h:18
CanonicalForm res
Definition: facAbsFact.cc:60
int j
Definition: facHensel.cc:110
#define D(A)
Definition: gentable.cc:131
static nc_struct *& GetNC(ring r)
Definition: nc.h:154
static void nc_kBucketPolyRed_Z(kBucket_pt b, poly p, number *c, BOOLEAN reduce)
Definition: nc.h:284
static poly nc_mm_Mult_pp(const poly m, const poly p, const ring r)
Definition: nc.h:224
SPoly_Proc_Ptr SPoly
Definition: nc.h:56
static bool rIsSCA(const ring r)
Definition: nc.h:190
static poly nc_CreateSpoly(const poly p1, const poly p2, const ring r)
Definition: nc.h:241
ideal idOppose(ring Rop_src, ideal I, const ring Rop_dst)
opposes a module I from Rop to currRing(dst)
Definition: old.gring.cc:3389
void nc_p_ProcsSet(ring rGR, p_Procs_s *p_Procs)
Definition: old.gring.cc:3187
poly pOppose(ring Rop_src, poly p, const ring Rop_dst)
opposes a vector p from Rop to currRing (dst!)
Definition: old.gring.cc:3350
const int NOPLURALMASK
Definition: nc.h:334
static poly GetD(const ring r, int i, int j)
Definition: nc.h:373
void * GB
From "gb_hack.h".
Definition: nc.h:59
const int NOCACHEMASK
Definition: nc.h:336
void nc_PolyPolyRed(poly &b, poly p, number *c, const ring r)
Definition: old.gring.cc:2238
poly nc_pSubst(poly p, int n, poly e, const ring r)
substitute the n-th variable by e in p destroy p e is not a constant
Definition: old.gring.cc:3211
poly(* SPoly_Proc_Ptr)(const poly p1, const poly p2, const ring r)
Definition: nc.h:45
poly nc_CreateShortSpoly(poly p1, poly p2, const ring r)
Definition: old.gring.cc:1879
static void nc_kBucketPolyRed_NF(kBucket_pt b, poly p, number *c, BOOLEAN reduce)
Definition: nc.h:275
bool nc_rCopy(ring res, const ring r, bool bSetupQuotient)
Definition: old.gring.cc:3011
bucket_Proc_Ptr BucketPolyRed_NF
Definition: nc.h:53
int & getNCExtensions()
Definition: old.gring.cc:82
bool ncExtensions(int iMask)
Definition: old.gring.cc:94
BOOLEAN nc_rComplete(const ring src, ring dest, bool bSetupQuotient=true)
Definition: ring.cc:5685
bool nc_SetupQuotient(ring rGR, const ring rG=NULL, bool bCopy=false)
Definition: old.gring.cc:3411
nc_type
Definition: nc.h:13
@ nc_skew
Definition: nc.h:16
@ nc_lie
Definition: nc.h:18
@ nc_error
Definition: nc.h:14
@ nc_general
Definition: nc.h:15
@ nc_exterior
Definition: nc.h:21
@ nc_undef
Definition: nc.h:19
@ nc_comm
Definition: nc.h:17
const int GENERICMASK
Definition: nc.h:319
poly(* SPolyReduce_Proc_Ptr)(const poly p1, poly p2, const ring r)
Definition: nc.h:46
static poly nc_mm_Mult_p(const poly m, poly p, const ring r)
Definition: nc.h:233
SPolyReduce_Proc_Ptr ReduceSPoly
Definition: nc.h:57
static poly GetC(const ring r, int i, int j)
Definition: nc.h:362
static nc_type & ncRingType(nc_struct *p)
Definition: nc.h:159
const int NOFORMULAMASK
Definition: nc.h:335
void(* bucket_Proc_Ptr)(kBucket_pt b, poly p, number *c, BOOLEAN reduce)
Definition: nc.h:48
int setNCExtensions(int iMask)
Definition: old.gring.cc:87
BOOLEAN rIsLikeOpposite(ring rBase, ring rCandidate)
checks whether rings rBase and rCandidate could be opposite to each other returns TRUE if it is so
Definition: old.gring.cc:3323
poly nc_p_Plus_mm_Mult_qq(poly p, const poly m, const poly q, int &lp, const int, const ring r)
Definition: old.gring.cc:168
static poly nc_ReduceSpoly(const poly p1, poly p2, const ring r)
Definition: nc.h:254
BOOLEAN nc_CheckSubalgebra(poly PolyVar, ring r)
Definition: old.gring.cc:2576
const int SCAMASK
Definition: nc.h:320
BOOLEAN nc_CallPlural(matrix cc, matrix dd, poly cn, poly dn, ring r, bool bSetupQuotient, bool bCopyInput, bool bBeQuiet, ring curr, bool dummy_ring=false)
returns TRUE if there were errors analyze inputs, check them for consistency detects nc_type,...
Definition: old.gring.cc:2690
poly nc_p_Bracket_qq(poly p, const poly q, const ring r)
returns [p,q], destroys p
Definition: old.gring.cc:2251
poly _nc_pp_Mult_qq(const poly p, const poly q, const ring r)
general NC-multiplication without destruction
Definition: old.gring.cc:254
poly _nc_p_Mult_q(poly p, poly q, const ring r)
general NC-multiplication with destruction
Definition: old.gring.cc:215
void nc_rKill(ring r)
complete destructor
Definition: old.gring.cc:2483
bucket_Proc_Ptr BucketPolyRed_Z
Definition: nc.h:54
poly nc_p_Minus_mm_Mult_qq(poly p, const poly m, const poly q, int &lp, const poly, const ring r)
for p_Minus_mm_Mult_qq in pInline2.h
Definition: old.gring.cc:150
matrix nc_PrintMat(int a, int b, ring r, int metric)
returns matrix with the info on noncomm multiplication
Definition: old.gring.cc:2402
const int TESTSYZSCAMASK
Definition: nc.h:338
Definition: nc.h:51
#define assume(x)
Definition: mod2.h:389
#define NULL
Definition: omList.c:12
struct p_Procs_s p_Procs_s
Definition: ring.h:23
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:400
static BOOLEAN rIsNCRing(const ring r)
Definition: ring.h:421
Definition: nc.h:68
CGlobalMultiplier * GetGlobalMultiplier() const
Definition: nc.h:130
nc_type type
Definition: nc.h:69
matrix C
Definition: nc.h:75
ideal & SCAQuotient()
Definition: nc.h:121
nc_type & ncRingType()
Definition: nc.h:108
CFormulaPowerMultiplier * GetFormulaPowerMultiplier() const
Definition: nc.h:137
CGlobalMultiplier *& GetGlobalMultiplier()
Definition: nc.h:133
nc_type ncRingType() const
Definition: nc.h:109
CFormulaPowerMultiplier *& GetFormulaPowerMultiplier()
Definition: nc.h:140
CFormulaPowerMultiplier * m_PowerMultiplier
Definition: nc.h:126
short & LastAltVar()
Definition: nc.h:113
int * MTsize
Definition: nc.h:81
short FirstAltVar() const
Definition: nc.h:116
int IsSkewConstant
Definition: nc.h:85
short LastAltVar() const
Definition: nc.h:118
union nc_struct::@2 data
matrix D
Definition: nc.h:76
matrix COM
Definition: nc.h:80
short & FirstAltVar()
Definition: nc.h:111
CGlobalMultiplier * m_Multiplier
Definition: nc.h:125
matrix * MT
Definition: nc.h:79
nc_pProcs p_Procs
Definition: nc.h:144