source: git/Singular/ring.h @ 1aa55bf

fieker-DuValspielwiese
Last change on this file since 1aa55bf was 1aa55bf, checked in by Olaf Bachmann <obachman@…>, 24 years ago
* sparsemat.cc : faster smSelectCopy and relatives * ring: VarL_* stuff * divisiblity tests based on longs git-svn-id: file:///usr/local/Singular/svn/trunk@4644 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 6.7 KB
Line 
1#ifndef RING_H
2#define RING_H
3/****************************************
4*  Computer Algebra System SINGULAR     *
5****************************************/
6/*
7* ABSTRACT - the interpreter related ring operations
8*/
9/* $Id: ring.h,v 1.52 2000-10-16 12:06:40 obachman Exp $ */
10
11/* includes */
12#include "structs.h"
13#include "polys-impl.h"
14
15#define SHORT_REAL_LENGTH 6 // use short reals for real <= 6 digits
16
17
18void   rChangeCurrRing(ring r, BOOLEAN complete = TRUE);
19void   rSetHdl(idhdl h, BOOLEAN complete = TRUE);
20ring   rInit(sleftv* pn, sleftv* rv, sleftv* ord);
21idhdl  rDefault(char *s);
22int    rIsRingVar(char *n);
23char * RingVar(short);
24void   rWrite(ring r);
25void   rKill(idhdl h);
26void   rKill(ring r);
27ring   rCopy(ring r);
28
29
30
31#ifdef PDEBUG
32#define rChangeSComps(c,s,l) rDBChangeSComps(c,s,l)
33#define rGetSComps(c,s,l) rDBGetSComps(c,s,l)
34void rDBChangeSComps(int* currComponents,
35                     long* currShiftedComponents,
36                     int length,
37                     ring r = currRing);
38void rDBGetSComps(int** currComponents,
39                  long** currShiftedComponents,
40                  int *length,
41                  ring r = currRing);
42#else
43#define rChangeSComps(c,s,l) rNChangeSComps(c,s)
44#define rGetSComps(c,s,l) rNGetSComps(c,s)
45#endif
46
47void rNChangeSComps(int* currComponents, long* currShiftedComponents, ring r = currRing);
48void rNGetSComps(int** currComponents, long** currShiftedComponents, ring r = currRing);
49
50idhdl  rFindHdl(ring r, idhdl n, idhdl w);
51int rOrderName(char * ordername);
52char * rOrdStr(ring r);
53char * rVarStr(ring r);
54char * rCharStr(ring r);
55char * rString(ring r);
56int    rChar(ring r=currRing);
57#define rPar(r) (r->P)
58char * rParStr(ring r);
59int    rIsExtension(ring r);
60int    rIsExtension();
61int    rSum(ring r1, ring r2, ring &sum);
62
63BOOLEAN rEqual(ring r1, ring r2, BOOLEAN qr = 1);
64void   rUnComplete(ring r);
65
66#define  rInternalChar(r) ((r)->ch)
67#ifndef ABS
68#define ABS(x) ((x) < 0 ? (-(x)) : (x))
69#endif
70
71BOOLEAN rRing_is_Homog(ring r=currRing);
72BOOLEAN rRing_has_CompLastBlock(ring r=currRing);
73
74inline BOOLEAN rField_is_Zp(ring r=currRing)
75{ return (r->ch > 1) && (r->parameter==NULL); }
76
77inline BOOLEAN rField_is_Zp(ring r, int p)
78{ return (r->ch > 1 && r->ch == ABS(p) && r->parameter==NULL); }
79
80inline BOOLEAN rField_is_Q(ring r=currRing)
81{ return (r->ch == 0) && (r->parameter==NULL); }
82
83inline BOOLEAN rField_is_numeric(ring r=currRing) /* R, long R, long C */
84{ return (r->ch ==  -1); }
85
86inline BOOLEAN rField_is_R(ring r=currRing)
87{
88  if (rField_is_numeric(r) && (r->ch_flags <= (short)SHORT_REAL_LENGTH))
89    return (r->parameter==NULL);
90  return FALSE;
91}
92
93inline BOOLEAN rField_is_GF(ring r=currRing)
94{ return (r->ch > 1) && (r->parameter!=NULL); }
95
96inline BOOLEAN rField_is_GF(ring r, int q)
97{ return (r->ch == q); }
98
99inline BOOLEAN rField_is_Zp_a(ring r=currRing)
100{ return (r->ch < -1); }
101
102inline BOOLEAN rField_is_Zp_a(ring r, int p)
103{ return (r->ch < -1 ) && (-(r->ch) == ABS(p)); }
104
105inline BOOLEAN rField_is_Q_a(ring r=currRing)
106{ return (r->ch == 1); }
107
108inline BOOLEAN rField_is_long_R(ring r=currRing)
109{
110  if (rField_is_numeric(r) && (r->ch_flags >(short)SHORT_REAL_LENGTH))
111    return (r->parameter==NULL);
112  return FALSE;
113}
114
115inline BOOLEAN rField_is_long_C(ring r=currRing)
116{
117  if (rField_is_numeric(r))
118    return (r->parameter!=NULL);
119  return FALSE;
120}
121
122inline BOOLEAN rField_has_simple_inverse(ring r=currRing)
123/* { return (r->ch>1) || (r->ch== -1); } *//* Z/p, GF(p,n), R, long_R, long_C*/
124{ return (r->ch>1) || ((r->ch== -1) && (r->ch_flags < 10)); } /* Z/p, GF(p,n), R, long_R, long_C*/
125
126inline BOOLEAN rField_has_simple_Alloc(ring r=currRing)
127{ return (rField_is_Zp(r) || rField_is_GF(r) || rField_is_R(r)); }
128
129/* Z/p, GF(p,n), R: nCopy, nNew, nDelete are dummies*/
130
131inline BOOLEAN rField_is_Extension(ring r=currRing)
132{ return (rField_is_Q_a(r)) || (rField_is_Zp_a(r)); } /* Z/p(a) and Q(a)*/
133
134// this needs to be called whenever a new ring is created: new fields
135// in ring are created (like VarOffset), unless they already exist
136// with force == 1, new fields are _always_ created (overwritten),
137// even if they exist
138BOOLEAN rComplete(ring r, int force = 0);
139// use this to free fields created by rComplete
140void rUnComplete(ring r);
141inline int rBlocks(ring r)
142{
143  int i=0;
144  while (r->order[i]!=0) i++;
145  return i+1;
146}
147
148typedef enum rRingOrder_t
149{
150  ringorder_no = 0,
151  ringorder_a,
152  ringorder_c,
153  ringorder_C,
154  ringorder_M,
155  ringorder_S,
156  ringorder_s,
157  ringorder_lp,
158  ringorder_dp,
159  ringorder_rp,
160  ringorder_Dp,
161  ringorder_wp,
162  ringorder_Wp,
163  ringorder_ls,
164  ringorder_ds,
165  ringorder_Ds,
166  ringorder_ws,
167  ringorder_Ws,
168  ringorder_L,
169  ringorder_unspec
170} rRingOrder_t;
171
172typedef enum rOrderType_t
173{
174  rOrderType_General = 0, // non-simple ordering as specified by currRing
175  rOrderType_CompExp,     // simple ordering, component has priority
176  rOrderType_ExpComp,     // simple ordering, exponent vector has priority
177                          // component not compatible with exp-vector order
178  rOrderType_Exp,         // simple ordering, exponent vector has priority
179                          // component is compatible with exp-vector order
180  rOrderType_Syz,         // syzygy ordering
181  rOrderType_Schreyer,    // Schreyer ordering
182  rOrderType_Syz2dpc,     // syzcomp2dpc
183  rOrderType_ExpNoComp    // simple ordering, differences in component are
184                          // not considered
185} rOrderType_t;
186
187inline BOOLEAN rIsSyzIndexRing(ring r)
188{ return r->order[0] == ringorder_s;}
189
190inline int rGetCurrSyzLimit()
191{ return (currRing->order[0] == ringorder_s ?
192          currRing->typ[0].data.syz.limit : 0);}
193
194// Ring Manipulations
195ring   rCurrRingAssure_SyzComp();
196void   rSetSyzComp(int k);
197ring   rCurrRingAssure_dp_S();
198ring   rCurrRingAssure_dp_C();
199ring   rCurrRingAssure_C_dp();
200// makes sure that c/C ordering is last ordering
201ring   rCurrRingAssure_CompLastBlock();
202// makes sure that c/C ordering is last ordering and SyzIndex is first
203ring   rCurrRingAssure_SyzComp_CompLastBlock();
204
205// return the max-comonent wchich has syzIndex i
206// Assume: i<= syzIndex_limit
207int rGetMaxSyzComp(int i);
208
209BOOLEAN rHasSimpleOrder(ring r);
210// returns TRUE, if simple lp or ls ordering
211BOOLEAN rHasSimpleLexOrder(ring r);
212// return TRUE if p->exp[r->pOrdIndex] holds total degree of p */
213BOOLEAN rOrd_is_Totaldegree_Ordering(ring r =currRing);
214rOrderType_t    rGetOrderType(ring r);
215BOOLEAN rIsPolyVar(int i); /* returns TRUE if var(i) belongs to p-block */
216
217#ifdef RDEBUG
218#define rTest(r)    rDBTest(r, __FILE__, __LINE__)
219extern BOOLEAN rDBTest(ring r, char* fn, int l);
220#else
221#define rTest(r)
222#endif
223
224ring rModifyRing(ring r, BOOLEAN omit_degree,
225                         BOOLEAN omit_comp,
226                         unsigned long exp_limit);
227void rKillModifiedRing(ring r);
228
229void rDebugPrint(ring r);
230void pDebugPrint(poly p);
231#endif
Note: See TracBrowser for help on using the repository browser.