source: git/Singular/mpsr_Put.h @ 6ce030f

jengelh-datetimespielwiese
Last change on this file since 6ce030f was 6ce030f, checked in by Oleksandr Motsak <motsak@…>, 11 years ago
removal of the $Id$ svn tag from everywhere NOTE: the git SHA1 may be used instead (only on special places) NOTE: the libraries Singular/LIB/*.lib still contain the marker due to our current use of svn
  • Property mode set to 100644
File size: 8.0 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/***************************************************************
5 *
6 * File:       mpsr_Put.h
7 * Purpose:    declarations for put routines for MP connection to Singular
8 * Author:     Olaf Bachmann (10/95)
9 *
10 * Change History (most recent first):
11 *  o 1/97 obachman
12 *    Updated putting routines to MP and MPP v1.1
13 *
14 ***************************************************************/
15
16#ifndef __MPSR_PUT__
17#define __MPSR_PUT__
18
19
20#ifdef HAVE_MPSR
21
22#include <kernel/structs.h>
23#include <kernel/febase.h>
24
25#include <Singular/mpsr.h>
26#include <Singular/tok.h>
27#include <Singular/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 ***************************************************************/
55extern mpsr_Status_t mpsr_PutPolyData(MP_Link_pt link, poly p, ring cring);
56extern mpsr_Status_t mpsr_PutPolyVectorData(MP_Link_pt link, poly p,ring cring);
57extern int          mpsr_GetNumOfRingAnnots(ring cring, BOOLEAN mv);
58extern 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
65inline mpsr_Status_t mpsr_PutInt(MP_Link_pt link, int i)
66{
67  mp_return(MP_PutSint32Packet(link, (MP_Sint32_t) i, 0));
68}
69extern mpsr_Status_t mpsr_PutIntVec(MP_Link_pt link, intvec *iv);
70extern mpsr_Status_t mpsr_PutIntMat(MP_Link_pt link, intvec *iv);
71inline 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}
81extern mpsr_Status_t mpsr_PutRing(MP_Link_pt link, ring r);
82extern mpsr_Status_t mpsr_PutProc(MP_Link_pt link, const char *pname,procinfov proc);
83extern mpsr_Status_t mpsr_PutPackage(MP_Link_pt link, package pack);
84inline mpsr_Status_t mpsr_PutDef(MP_Link_pt link, char *name)
85{
86  mp_return(MP_PutIdentifierPacket(link, MP_SingularDict, name, 0));
87}
88// next, ring-dependent data
89extern mpsr_Status_t mpsr_PutList(MP_Link_pt link, lists l, ring cring);
90extern mpsr_Status_t mpsr_PutCopCommand(MP_Link_pt link, command c, ring cring);
91extern mpsr_Status_t mpsr_PutOpCommand(MP_Link_pt link, command c, ring cring);
92extern mpsr_Status_t mpsr_PutNumber(MP_Link_pt link,number n,ring cring);
93extern mpsr_Status_t mpsr_PutPoly(MP_Link_pt link,poly p,ring cring);
94extern mpsr_Status_t mpsr_PutPolyVector(MP_Link_pt link,poly p,ring cring);
95extern mpsr_Status_t mpsr_PutIdeal(MP_Link_pt link, ideal id, ring cring);
96extern mpsr_Status_t mpsr_PutModule(MP_Link_pt link, ideal id, ring cring);
97extern mpsr_Status_t mpsr_PutMatrix(MP_Link_pt link, ideal id, ring cring);
98extern mpsr_Status_t mpsr_PutMap(MP_Link_pt link, map m, ring cring);
99
100
101
102/***************************************************************
103 * 2.) Routines for Putting Singular Leftv's
104 *
105 *
106 ***************************************************************/
107// The "Master routine, which takes any leftv, and calls the respective
108// Put routine
109extern mpsr_Status_t mpsr_PutLeftv(MP_Link_pt link, leftv v, ring cring);
110
111// A handy macro which checks for the type of leftvs
112#ifdef MPSR_DEBUG
113#define typecheck(v,type)                           \
114do if ((v)->Typ() != (type))                        \
115{                                                   \
116  return mpsr_SetError(mpsr_WrongLeftvType);        \
117}                                                   \
118while (0)
119#else
120#define typecheck(v,type)   ((void) 0)
121#endif
122
123// First, ring-independent data
124inline mpsr_Status_t mpsr_PutIntLeftv(MP_Link_pt link, leftv v)
125{
126  typecheck(v, INT_CMD);
127  mp_return(MP_PutSint32Packet(link, (MP_Sint32_t) v->Data(), 0));
128}
129inline mpsr_Status_t mpsr_PutIntVecLeftv(MP_Link_pt link, leftv v)
130{
131  typecheck(v, INTVEC_CMD);
132  return mpsr_PutIntVec(link, (intvec *) v->Data());
133}
134inline mpsr_Status_t mpsr_PutIntMatLeftv(MP_Link_pt link, leftv v)
135{
136  typecheck(v, INTMAT_CMD);
137  return mpsr_PutIntMat(link, (intvec *) v->Data());
138}
139inline mpsr_Status_t mpsr_PutStringLeftv(MP_Link_pt link, leftv v)
140{
141  typecheck(v, STRING_CMD);
142  return   mpsr_PutString(link, (char *) v->Data());
143}
144inline mpsr_Status_t mpsr_PutRingLeftv(MP_Link_pt link, leftv v)
145{
146  typecheck(v, RING_CMD);
147  return mpsr_PutRing(link, (ring) v->Data());
148}
149inline mpsr_Status_t mpsr_PutQRingLeftv(MP_Link_pt link, leftv v)
150{
151  typecheck(v, QRING_CMD);
152  return mpsr_PutRing(link, (ring) v->Data());
153}
154inline mpsr_Status_t mpsr_PutProcLeftv(MP_Link_pt link, leftv v)
155{
156  typecheck(v, PROC_CMD);
157  return mpsr_PutProc(link, v->name, (procinfov) v->Data());
158}
159inline mpsr_Status_t mpsr_PutDefLeftv(MP_Link_pt link, leftv v)
160{
161  typecheck(v, DEF_CMD);
162  return mpsr_PutDef(link, (char *) v->name);
163}
164// now the ring-dependent leftv's
165inline mpsr_Status_t mpsr_PutListLeftv(MP_Link_pt link, leftv v, ring cring)
166{
167  typecheck(v, LIST_CMD);
168  return mpsr_PutList(link, (lists) v->Data(), cring);
169}
170inline mpsr_Status_t mpsr_PutCommandLeftv(MP_Link_pt link, leftv v, ring cring)
171{
172  command cmd = (command) v->Data();
173
174  typecheck(v, COMMAND);
175  if (cmd->op == PROC_CMD)
176    return mpsr_PutOpCommand(link, cmd, cring);
177  else
178    return mpsr_PutCopCommand(link, cmd , cring);
179}
180inline mpsr_Status_t mpsr_PutNumberLeftv(MP_Link_pt link, leftv v, ring cring)
181{
182  typecheck(v, NUMBER_CMD);
183  return mpsr_PutNumber(link, (number) v->Data(), cring);
184}
185inline mpsr_Status_t mpsr_PutPolyLeftv(MP_Link_pt link, leftv v, ring cring)
186{
187  typecheck(v, POLY_CMD);
188  return mpsr_PutPoly(link, (poly) v->Data(), cring);
189}
190inline mpsr_Status_t mpsr_PutIdealLeftv(MP_Link_pt link, leftv v, ring cring)
191{
192  typecheck(v, IDEAL_CMD);
193  return mpsr_PutIdeal(link, (ideal) v->Data(), cring);
194}
195inline mpsr_Status_t mpsr_PutVectorLeftv(MP_Link_pt link, leftv v, ring cring)
196{
197  typecheck(v, VECTOR_CMD);
198  return mpsr_PutPolyVector(link, (poly) v->Data(), cring);
199}
200inline mpsr_Status_t mpsr_PutMatrixLeftv(MP_Link_pt link, leftv v, ring cring)
201{
202  typecheck(v, MATRIX_CMD);
203  return mpsr_PutMatrix(link, (ideal) v->Data(), cring);
204}
205inline mpsr_Status_t mpsr_PutModuleLeftv(MP_Link_pt link, leftv v, ring cring)
206{
207  typecheck(v, MODUL_CMD);
208  return mpsr_PutModule(link, (ideal) v->Data(), cring);
209}
210inline mpsr_Status_t mpsr_PutMapLeftv(MP_Link_pt link, leftv v, ring cring)
211{
212  typecheck(v, MAP_CMD);
213  return mpsr_PutMap(link, (map) v->Data(), cring);
214}
215/* inline mpsr_Status_t mpsr_PutAliasLeftv(MP_Link_pt link, leftv v) */
216/* { */
217/*   typecheck(v, ALIAS_CMD); */
218/*   return mpsr_PutAlias(link, v->name, (idhdl) v->Data()); */
219/* } */
220inline mpsr_Status_t mpsr_PutPackageLeftv(MP_Link_pt link, leftv v)
221{
222  typecheck(v, PACKAGE_CMD);
223  return mpsr_PutPackage(link, (package) v->Data());
224}
225
226/***************************************************************
227 * 1.)  Singular Top-level Data (chains of leftv's)
228 *      They are send as on MP mesg
229 *
230 ***************************************************************/
231extern mpsr_Status_t mpsr_PutMsg(MP_Link_pt l, leftv v);
232
233
234#endif // #ifdef HAVE_MPSR
235
236
237#endif
Note: See TracBrowser for help on using the repository browser.