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.29 1999-07-08 13:38:42 Singular 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 | |
---|
18 | #ifdef DRING |
---|
19 | void rChangeCurrRing(ring r, BOOLEAN complete = TRUE, idhdl h = NULL); |
---|
20 | #else |
---|
21 | void rChangeCurrRing(ring r, BOOLEAN complete = TRUE); |
---|
22 | #endif |
---|
23 | void rSetHdl(idhdl h, BOOLEAN complete = TRUE); |
---|
24 | idhdl rInit(char *s, sleftv* pn, sleftv* rv, sleftv* ord, |
---|
25 | BOOLEAN isDRing); |
---|
26 | idhdl rDefault(char *s); |
---|
27 | int rIsRingVar(char *n); |
---|
28 | char * RingVar(short); |
---|
29 | void rWrite(ring r); |
---|
30 | void rKill(idhdl h); |
---|
31 | void rKill(ring r); |
---|
32 | ring rCopy(ring r); |
---|
33 | idhdl rFindHdl(ring r, idhdl n, idhdl w); |
---|
34 | #ifdef DRING |
---|
35 | void rDSet(); |
---|
36 | #endif |
---|
37 | void rDInit(); |
---|
38 | int rOrderName(char * ordername); |
---|
39 | char * rOrdStr(ring r); |
---|
40 | char * rVarStr(ring r); |
---|
41 | char * rCharStr(ring r); |
---|
42 | char * rString(ring r); |
---|
43 | int rChar(ring r=currRing); |
---|
44 | #define rPar(r) (r->P) |
---|
45 | char * rParStr(ring r); |
---|
46 | int rIsExtension(ring r); |
---|
47 | int rIsExtension(); |
---|
48 | int rSum(ring r1, ring r2, ring &sum); |
---|
49 | BOOLEAN rComplete(ring r, int force = 0); |
---|
50 | void rUnComplete(ring r); |
---|
51 | int rBlocks(ring r); |
---|
52 | |
---|
53 | #define rInternalChar(r) ((r)->ch) |
---|
54 | #ifndef ABS |
---|
55 | #define ABS(x) ((x) < 0 ? (-(x)) : (x)) |
---|
56 | #endif |
---|
57 | inline BOOLEAN rField_is_Zp(ring r=currRing) |
---|
58 | { return (r->ch > 1) && (r->parameter==NULL); } |
---|
59 | inline BOOLEAN rField_is_Zp(ring r, int p) |
---|
60 | { return (r->ch > 1 && r->ch == ABS(p) && r->parameter==NULL); } |
---|
61 | inline BOOLEAN rField_is_Q(ring r=currRing) |
---|
62 | { return (r->ch == 0) && (r->parameter==NULL); } |
---|
63 | inline BOOLEAN rField_is_numeric(ring r=currRing) /* R, long R, long C */ |
---|
64 | { return (r->ch == -1); } |
---|
65 | inline BOOLEAN rField_is_R(ring r=currRing) |
---|
66 | { |
---|
67 | if (rField_is_numeric(r) && (r->ch_flags <= (short)SHORT_REAL_LENGTH)) |
---|
68 | return (r->parameter==NULL); |
---|
69 | return FALSE; |
---|
70 | } |
---|
71 | inline BOOLEAN rField_is_GF(ring r=currRing) |
---|
72 | { return (r->ch > 1) && (r->parameter!=NULL); } |
---|
73 | inline BOOLEAN rField_is_Zp_a(ring r=currRing) |
---|
74 | { return (r->ch < -1); } |
---|
75 | inline BOOLEAN rField_is_Zp_a(ring r, int p) |
---|
76 | { return (r->ch < -1 ) && (-(r->ch) == ABS(p)); } |
---|
77 | inline BOOLEAN rField_is_Q_a(ring r=currRing) |
---|
78 | { return (r->ch == 1); } |
---|
79 | inline BOOLEAN rField_is_long_R(ring r=currRing) |
---|
80 | { |
---|
81 | if (rField_is_numeric(r) && (r->ch_flags >(short)SHORT_REAL_LENGTH)) |
---|
82 | return (r->parameter==NULL); |
---|
83 | return FALSE; |
---|
84 | } |
---|
85 | inline BOOLEAN rField_is_long_C(ring r=currRing) |
---|
86 | { |
---|
87 | if (rField_is_numeric(r)) |
---|
88 | return (r->parameter!=NULL); |
---|
89 | return FALSE; |
---|
90 | } |
---|
91 | inline BOOLEAN rField_has_simple_inverse(ring r=currRing) |
---|
92 | { return (r->ch>1) || (r->ch== -1); } /* Z/p, GF(p,n), R, long_R, long_C*/ |
---|
93 | inline BOOLEAN rField_is_Extension(ring r=currRing) |
---|
94 | { return (rField_is_Q_a(r)) || (rField_is_Zp_a(r)); } /* Z/p(a) and Q(a)*/ |
---|
95 | |
---|
96 | enum |
---|
97 | { |
---|
98 | ringorder_no = 0, |
---|
99 | ringorder_a, |
---|
100 | ringorder_c, |
---|
101 | ringorder_C, |
---|
102 | ringorder_M, |
---|
103 | ringorder_lp, |
---|
104 | ringorder_dp, |
---|
105 | ringorder_Dp, |
---|
106 | ringorder_wp, |
---|
107 | ringorder_Wp, |
---|
108 | ringorder_ls, |
---|
109 | ringorder_ds, |
---|
110 | ringorder_Ds, |
---|
111 | ringorder_ws, |
---|
112 | ringorder_Ws, |
---|
113 | ringorder_unspec |
---|
114 | }; |
---|
115 | |
---|
116 | typedef enum rOrderType_t |
---|
117 | { |
---|
118 | rOrderType_General = 0, // non-simple ordering as specified by currRing |
---|
119 | rOrderType_CompExp, // simple ordering, component has priority |
---|
120 | rOrderType_ExpComp, // simple ordering, exponent vector has priority |
---|
121 | // component not compatible with exp-vector order |
---|
122 | rOrderType_Exp, // simple ordering, exponent vector has priority |
---|
123 | // component is compatible with exp-vector order |
---|
124 | rOrderType_Syz, // syzygy ordering |
---|
125 | rOrderType_Schreyer, // Schreyer ordering |
---|
126 | rOrderType_Syz2dpc, // syzcomp2dpc |
---|
127 | rOrderType_ExpNoComp // simple ordering, differences in component are |
---|
128 | // not considered |
---|
129 | } rOrderType_t; |
---|
130 | |
---|
131 | BOOLEAN rHasSimpleOrder(ring r); |
---|
132 | // returns TRUE, if simple lp or ls ordering |
---|
133 | BOOLEAN rHasSimpleLexOrder(ring r); |
---|
134 | rOrderType_t rGetOrderType(ring r); |
---|
135 | BOOLEAN rIsPolyVar(int i); /* returns TRUE if var(i) belongs to p-block */ |
---|
136 | |
---|
137 | void rOptimizeOrder(ring r); |
---|
138 | |
---|
139 | #ifdef RDEBUG |
---|
140 | extern short rNumber; /* current ring id (r->no) */ |
---|
141 | #define rTest(r) rDBTest(r, __FILE__, __LINE__) |
---|
142 | extern BOOLEAN rDBTest(ring r, char* fn, int l); |
---|
143 | #else |
---|
144 | #define rTest(r) |
---|
145 | #endif |
---|
146 | |
---|
147 | #endif |
---|
148 | |
---|