1 | /**************************************** |
---|
2 | * Computer Algebra System SINGULAR * |
---|
3 | ****************************************/ |
---|
4 | /* $Id: mpsr_Put.h,v 1.6 1998-01-16 14:29:56 krueger Exp $ */ |
---|
5 | /*************************************************************** |
---|
6 | * |
---|
7 | * File: mpsr_Put.h |
---|
8 | * Purpose: declarations for put routines for MP connection to Singular |
---|
9 | * Author: Olaf Bachmann (10/95) |
---|
10 | * |
---|
11 | * Change History (most recent first): |
---|
12 | * o 1/97 obachman |
---|
13 | * Updated putting routines to MP and MPP v1.1 |
---|
14 | * |
---|
15 | ***************************************************************/ |
---|
16 | |
---|
17 | #ifndef __MPSR_PUT__ |
---|
18 | #define __MPSR_PUT__ |
---|
19 | |
---|
20 | #include"mod2.h" |
---|
21 | |
---|
22 | #include"mpsr.h" |
---|
23 | |
---|
24 | #include"structs.h" |
---|
25 | #include"febase.h" |
---|
26 | #include"tok.h" |
---|
27 | #include"ipid.h" |
---|
28 | |
---|
29 | /*************************************************************** |
---|
30 | * 1.) Some handy macros |
---|
31 | * |
---|
32 | ***************************************************************/ |
---|
33 | // some often used flags settings for annotations |
---|
34 | #define MP_AnnotReqValTree \ |
---|
35 | (MP_AnnotRequired | MP_AnnotValuated | MP_AnnotTreeScope) |
---|
36 | |
---|
37 | #define MP_AnnotReqValNode \ |
---|
38 | (MP_AnnotRequired | MP_AnnotValuated) |
---|
39 | |
---|
40 | |
---|
41 | /*************************************************************** |
---|
42 | * |
---|
43 | * There are 4 different layers on which things are put: |
---|
44 | * 1.) Singular Top-level Data (chains of leftv's) |
---|
45 | * 2.) Leftv Data |
---|
46 | * 3.) Plain Singular data |
---|
47 | * 4.) MP primitive polynomial data |
---|
48 | * |
---|
49 | ***************************************************************/ |
---|
50 | |
---|
51 | /*************************************************************** |
---|
52 | * 4.) Low-level polynomial data -- they should only be used internally |
---|
53 | * |
---|
54 | ***************************************************************/ |
---|
55 | extern mpsr_Status_t mpsr_PutPolyData(MP_Link_pt link, poly p, ring cring); |
---|
56 | extern mpsr_Status_t mpsr_PutPolyVectorData(MP_Link_pt link, poly p,ring cring); |
---|
57 | extern int mpsr_GetNumOfRingAnnots(ring cring, BOOLEAN mv); |
---|
58 | extern mpsr_Status_t mpsr_PutRingAnnots(MP_Link_pt link, ring cring,BOOLEAN mv); |
---|
59 | |
---|
60 | /*************************************************************** |
---|
61 | * 3.) Routines for Putting Plain Singular data |
---|
62 | * |
---|
63 | ***************************************************************/ |
---|
64 | // First, ring-independent data |
---|
65 | inline mpsr_Status_t mpsr_PutInt(MP_Link_pt link, int i) |
---|
66 | { |
---|
67 | mp_return(MP_PutSint32Packet(link, (MP_Sint32_t) i, 0)); |
---|
68 | } |
---|
69 | extern mpsr_Status_t mpsr_PutIntVec(MP_Link_pt link, intvec *iv); |
---|
70 | extern mpsr_Status_t mpsr_PutIntMat(MP_Link_pt link, intvec *iv); |
---|
71 | inline mpsr_Status_t mpsr_PutString(MP_Link_pt link, char *str) |
---|
72 | { |
---|
73 | if (strcmp(str, MPSR_QUIT_STRING) == 0) |
---|
74 | mp_return(MP_PutCommonOperatorPacket(link, |
---|
75 | MP_MpDict, |
---|
76 | MP_CopMpEndSession, |
---|
77 | 0, 0)); |
---|
78 | else |
---|
79 | mp_return(MP_PutStringPacket(link, str, 0)); |
---|
80 | } |
---|
81 | extern mpsr_Status_t mpsr_PutRing(MP_Link_pt link, ring r); |
---|
82 | extern mpsr_Status_t mpsr_PutProc(MP_Link_pt link, char *pname,procinfov proc); |
---|
83 | inline mpsr_Status_t mpsr_PutDef(MP_Link_pt link, char *name) |
---|
84 | { |
---|
85 | mp_return(MP_PutIdentifierPacket(link, MP_SingularDict, name, 0)); |
---|
86 | } |
---|
87 | // next, ring-dependent data |
---|
88 | extern mpsr_Status_t mpsr_PutList(MP_Link_pt link, lists l, ring cring); |
---|
89 | extern mpsr_Status_t mpsr_PutCopCommand(MP_Link_pt link, command c, ring cring); |
---|
90 | extern mpsr_Status_t mpsr_PutOpCommand(MP_Link_pt link, command c, ring cring); |
---|
91 | extern mpsr_Status_t mpsr_PutNumber(MP_Link_pt link,number n,ring cring); |
---|
92 | extern mpsr_Status_t mpsr_PutPoly(MP_Link_pt link,poly p,ring cring); |
---|
93 | extern mpsr_Status_t mpsr_PutPolyVector(MP_Link_pt link,poly p,ring cring); |
---|
94 | extern mpsr_Status_t mpsr_PutIdeal(MP_Link_pt link, ideal id, ring cring); |
---|
95 | extern mpsr_Status_t mpsr_PutModule(MP_Link_pt link, ideal id, ring cring); |
---|
96 | extern mpsr_Status_t mpsr_PutMatrix(MP_Link_pt link, ideal id, ring cring); |
---|
97 | extern mpsr_Status_t mpsr_PutMap(MP_Link_pt link, map m, ring cring); |
---|
98 | |
---|
99 | |
---|
100 | |
---|
101 | /*************************************************************** |
---|
102 | * 2.) Routines for Putting Singular Leftv's |
---|
103 | * |
---|
104 | * |
---|
105 | ***************************************************************/ |
---|
106 | // The "Master routine, which takes any leftv, and calls the respective |
---|
107 | // Put routine |
---|
108 | extern mpsr_Status_t mpsr_PutLeftv(MP_Link_pt link, leftv v, ring cring); |
---|
109 | |
---|
110 | // A handy macro which checks for the type of leftvs |
---|
111 | #ifdef MPSR_DEBUG |
---|
112 | #define typecheck(v,type) \ |
---|
113 | do if ((v)->Typ() != (type)) \ |
---|
114 | { \ |
---|
115 | return mpsr_SetError(mpsr_WrongLeftvType); \ |
---|
116 | } \ |
---|
117 | while (0) |
---|
118 | #else |
---|
119 | #define typecheck(v,type) ((void) 0) |
---|
120 | #endif |
---|
121 | |
---|
122 | // First, ring-independent data |
---|
123 | inline mpsr_Status_t mpsr_PutIntLeftv(MP_Link_pt link, leftv v) |
---|
124 | { |
---|
125 | typecheck(v, INT_CMD); |
---|
126 | mp_return(MP_PutSint32Packet(link, (MP_Sint32_t) v->Data(), 0)); |
---|
127 | } |
---|
128 | inline mpsr_Status_t mpsr_PutIntVecLeftv(MP_Link_pt link, leftv v) |
---|
129 | { |
---|
130 | typecheck(v, INTVEC_CMD); |
---|
131 | return mpsr_PutIntVec(link, (intvec *) v->Data()); |
---|
132 | } |
---|
133 | inline mpsr_Status_t mpsr_PutIntMatLeftv(MP_Link_pt link, leftv v) |
---|
134 | { |
---|
135 | typecheck(v, INTMAT_CMD); |
---|
136 | return mpsr_PutIntMat(link, (intvec *) v->Data()); |
---|
137 | } |
---|
138 | inline mpsr_Status_t mpsr_PutStringLeftv(MP_Link_pt link, leftv v) |
---|
139 | { |
---|
140 | typecheck(v, STRING_CMD); |
---|
141 | return mpsr_PutString(link, (char *) v->Data()); |
---|
142 | } |
---|
143 | inline mpsr_Status_t mpsr_PutRingLeftv(MP_Link_pt link, leftv v) |
---|
144 | { |
---|
145 | typecheck(v, RING_CMD); |
---|
146 | return mpsr_PutRing(link, (ring) v->Data()); |
---|
147 | } |
---|
148 | inline mpsr_Status_t mpsr_PutQRingLeftv(MP_Link_pt link, leftv v) |
---|
149 | { |
---|
150 | typecheck(v, QRING_CMD); |
---|
151 | return mpsr_PutRing(link, (ring) v->Data()); |
---|
152 | } |
---|
153 | inline mpsr_Status_t mpsr_PutProcLeftv(MP_Link_pt link, leftv v) |
---|
154 | { |
---|
155 | typecheck(v, PROC_CMD); |
---|
156 | return mpsr_PutProc(link, v->name, (procinfov) v->Data()); |
---|
157 | } |
---|
158 | inline mpsr_Status_t mpsr_PutDefLeftv(MP_Link_pt link, leftv v) |
---|
159 | { |
---|
160 | typecheck(v, DEF_CMD); |
---|
161 | return mpsr_PutDef(link, (char *) v->name); |
---|
162 | } |
---|
163 | // now the ring-dependent leftv's |
---|
164 | inline mpsr_Status_t mpsr_PutListLeftv(MP_Link_pt link, leftv v, ring cring) |
---|
165 | { |
---|
166 | typecheck(v, LIST_CMD); |
---|
167 | return mpsr_PutList(link, (lists) v->Data(), cring); |
---|
168 | } |
---|
169 | inline mpsr_Status_t mpsr_PutCommandLeftv(MP_Link_pt link, leftv v, ring cring) |
---|
170 | { |
---|
171 | command cmd = (command) v->Data(); |
---|
172 | |
---|
173 | typecheck(v, COMMAND); |
---|
174 | if (cmd->op == PROC_CMD) |
---|
175 | return mpsr_PutOpCommand(link, cmd, cring); |
---|
176 | else |
---|
177 | return mpsr_PutCopCommand(link, cmd , cring); |
---|
178 | } |
---|
179 | inline mpsr_Status_t mpsr_PutNumberLeftv(MP_Link_pt link, leftv v, ring cring) |
---|
180 | { |
---|
181 | typecheck(v, NUMBER_CMD); |
---|
182 | return mpsr_PutNumber(link, (number) v->Data(), cring); |
---|
183 | } |
---|
184 | inline mpsr_Status_t mpsr_PutPolyLeftv(MP_Link_pt link, leftv v, ring cring) |
---|
185 | { |
---|
186 | typecheck(v, POLY_CMD); |
---|
187 | return mpsr_PutPoly(link, (poly) v->Data(), cring); |
---|
188 | } |
---|
189 | inline mpsr_Status_t mpsr_PutIdealLeftv(MP_Link_pt link, leftv v, ring cring) |
---|
190 | { |
---|
191 | typecheck(v, IDEAL_CMD); |
---|
192 | return mpsr_PutIdeal(link, (ideal) v->Data(), cring); |
---|
193 | } |
---|
194 | inline mpsr_Status_t mpsr_PutVectorLeftv(MP_Link_pt link, leftv v, ring cring) |
---|
195 | { |
---|
196 | typecheck(v, VECTOR_CMD); |
---|
197 | return mpsr_PutPolyVector(link, (poly) v->Data(), cring); |
---|
198 | } |
---|
199 | inline mpsr_Status_t mpsr_PutMatrixLeftv(MP_Link_pt link, leftv v, ring cring) |
---|
200 | { |
---|
201 | typecheck(v, MATRIX_CMD); |
---|
202 | return mpsr_PutMatrix(link, (ideal) v->Data(), cring); |
---|
203 | } |
---|
204 | inline mpsr_Status_t mpsr_PutModuleLeftv(MP_Link_pt link, leftv v, ring cring) |
---|
205 | { |
---|
206 | typecheck(v, MODUL_CMD); |
---|
207 | return mpsr_PutModule(link, (ideal) v->Data(), cring); |
---|
208 | } |
---|
209 | inline mpsr_Status_t mpsr_PutMapLeftv(MP_Link_pt link, leftv v, ring cring) |
---|
210 | { |
---|
211 | typecheck(v, MAP_CMD); |
---|
212 | return mpsr_PutMap(link, (map) v->Data(), cring); |
---|
213 | } |
---|
214 | |
---|
215 | /*************************************************************** |
---|
216 | * 1.) Singular Top-level Data (chains of leftv's) |
---|
217 | * They are send as on MP mesg |
---|
218 | * |
---|
219 | ***************************************************************/ |
---|
220 | extern mpsr_Status_t mpsr_PutMsg(MP_Link_pt l, leftv v); |
---|
221 | |
---|
222 | #endif |
---|