source: git/Singular/mpsr.h @ 6d09c56

fieker-DuValspielwiese
Last change on this file since 6d09c56 was feaddd, checked in by Olaf Bachmann <obachman@…>, 27 years ago
Thu Apr 10 11:59:41 1997 Olaf Bachmann <obachman@ratchwum.mathematik.uni-kl.de (Olaf Bachmann)> * remote quit is now arranged using MP_CopMpQuit * Updated mpsr_* files for new naming convention of MP v:1.1.2 git-svn-id: file:///usr/local/Singular/svn/trunk@146 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 9.4 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/* $Id: mpsr.h,v 1.5 1997-04-10 13:08:35 obachman Exp $ */
5/***************************************************************
6 *
7 * File:       mpsr.h
8 * Purpose:    Global Header file for MP connection to Singular
9 * Author:     Olaf Bachmann (10/95)
10 *
11 * Change History (most recent first):
12 *
13 ***************************************************************/
14#ifdef HAVE_MPSR
15
16#ifndef __MPSR__
17#define __MPSR__
18
19#include"structs.h"
20#include"mmemory.h"
21#include"ipid.h"
22#include"polys.h"
23#include"numbers.h"
24
25// now the MP include stuff (is surrounded by ifndef there)
26extern "C"
27{
28#include"MP.h"
29#include"MPT.h"
30}
31
32/***************************************************************
33 *
34 * prototype declarations of routines we provide for the outer world
35 *
36 *
37 ***************************************************************/
38// from mpsr_Error.c
39typedef enum mpsr_Status_t
40{
41  mpsr_Failure,
42  mpsr_Success,
43  mpsr_MP_Failure,
44  mpsr_MPT_Failure,
45  mpsr_UnknownLeftvType,
46  mpsr_WrongLeftvType,
47  mpsr_UnknownSingularToken,
48  mpsr_UnknownDictionary,
49  mpsr_UnkownOperator,
50  mpsr_UnknownMPNodeType,
51  mpsr_CanNotHandlePrototype,
52  mpsr_WrongNumofArgs,
53  mpsr_WrongArgumentType,
54  mpsr_WrongNodeType,
55  mpsr_ReqAnnotSkip,
56  mpsr_WrongUnionDiscriminator,
57  mpsr_UnknownCoeffDomain,
58  mpsr_MaxError
59} mpsr_Status_t;
60
61extern mpsr_Status_t mpsr_SetError(mpsr_Status_t error);
62extern mpsr_Status_t mpsr_SetError(MP_Link_pt link);
63extern void mpsr_PrintError(mpsr_Status_t error);
64extern void mpsr_PrintError();
65extern void mpsr_PrintError(MP_Link_pt link);
66extern void mpsr_PrintError(mpsr_Status_t error, MP_Link_pt link);
67extern mpsr_Status_t mpsr_GetError();
68extern void mpsr_ClearError();
69
70// from mpsr_Get.cc
71extern mpsr_Status_t mpsr_GetMsg(MP_Link_pt link, leftv &lv);
72extern mpsr_Status_t mpsr_GetDump(MP_Link_pt link);
73// from mpsr_Put.cc
74extern mpsr_Status_t mpsr_PutMsg(MP_Link_pt link, leftv lv);
75extern mpsr_Status_t mpsr_PutDump(MP_Link_pt link);
76
77
78/***************************************************************
79 *
80 * Inline's
81 *
82 ***************************************************************/
83inline leftv mpsr_InitLeftv(short tok, void *data)
84{
85  leftv lv = (leftv) Alloc0(sizeof(sleftv));
86  lv->data = data;
87  lv->rtyp = tok;
88  return lv;
89}
90
91// this is only for intermediate ring changes by mpsr
92// a "proper" setting of the global ring is done at the end of all the
93// getting
94extern BOOLEAN currComplete;
95
96inline void mpsr_SetCurrRing(ring rg, BOOLEAN complete)
97{
98  if (currRing != rg || (complete && ! currComplete))
99  {
100#ifdef PDEBUG
101    nSetChar(rg->ch, TRUE, rg->parameter,rg->P);
102#else
103    nSetChar(rg->ch, complete, rg->parameter,rg->P);
104#endif   
105    pChangeRing(rg->N, rg->OrdSgn, rg->order, rg->block0, rg->block1,
106                rg->wvhdl);
107    currRing = rg;
108    currComplete = complete;
109  }
110}
111
112/***************************************************************
113 *
114 * Macros
115 *
116 ***************************************************************/
117
118// 129 is application specific Dictionary
119#define MP_SingularDict 129
120// remove this, once the Galois field stuff is done properly
121#define MP_AnnotSingularGalois  1
122// String used to indicate the end of a communication
123#define MPSR_QUIT_STRING    "MPtcp:quit"
124
125// some handy Macros for error handlings
126#ifdef MPSR_DEBUG
127
128#undef failr
129#define failr(x)                                                    \
130do                                                                  \
131{                                                                   \
132  mpsr_Status_t _status = x;                                        \
133  if (_status != mpsr_Success)                                            \
134    Werror("failr violation in %s line %d:",__FILE__, __LINE__);    \
135  if (_status != mpsr_Success) return _status;                      \
136}                                                                   \
137while (0)
138
139#undef mp_failr
140#define mp_failr(x)                                                 \
141do                                                                  \
142{                                                                   \
143  if (x != MP_Success)                                              \
144  {                                                                 \
145    Werror("mp_failr violation in %s line %d:",__FILE__, __LINE__); \
146    return mpsr_SetError(link);                                     \
147  }                                                                 \
148}                                                                   \
149while (0)
150
151#undef mp_return
152#define mp_return(x)                                                    \
153do                                                                      \
154{                                                                       \
155  if (x != MP_Success)                                                  \
156  {                                                                     \
157   Werror("mp_return violation in %s line %d:",__FILE__, __LINE__);     \
158   return mpsr_SetError(link);                                          \
159  }                                                                     \
160  else return mpsr_Success;                                             \
161}                                                                       \
162while (0)
163
164#undef mpt_failr
165#define mpt_failr(x)                                                 \
166do                                                                  \
167{                                                                   \
168  if (x != MPT_Success)                                              \
169  {                                                                 \
170    Werror("mpr_failr violation in %s line %d:",__FILE__, __LINE__); \
171    return mpsr_SetError(mpsr_MPT_Failure);                           \
172  }                                                                 \
173}                                                                   \
174while (0)
175#undef mpt_return
176#define mpt_return(x)                                                    \
177do                                                                      \
178{                                                                       \
179  if (x != MPT_Success)                                                  \
180  {                                                                     \
181   Werror("mpt_return violation in %s line %d:",__FILE__, __LINE__);     \
182   return mpsr_SetError(mpsr_MPT_Failure);                                \
183  }                                                                     \
184  else return mpsr_Success;                                             \
185}                                                                       \
186while (0)
187
188#undef mpsr_assume
189#define mpsr_assume(cond)                                               \
190do                                                                      \
191{                                                                       \
192  if ( ! (cond))                                                        \
193    Werror("mpsr_assume violation in %s line %d",__FILE__, __LINE__);   \
194} while (0)
195
196#else
197#undef failr
198#define failr(x)                                \
199do                                              \
200{                                               \
201  mpsr_Status_t _status = x;                    \
202  if (_status != mpsr_Success) return _status;              \
203}                                               \
204while (0)
205#undef mp_failr
206#define mp_failr(x)                             \
207do                                              \
208{                                               \
209  if (x != MP_Success)                          \
210    return mpsr_SetError(link);                 \
211}                                               \
212while (0)
213#undef mp_return
214#define mp_return(x)                                \
215do                                                  \
216{                                                   \
217  if (x != MP_Success) return mpsr_SetError(link);  \
218  else return mpsr_Success;                         \
219}                                                   \
220while (0)
221#undef mpt_failr
222#define mpt_failr(x)                             \
223do                                              \
224{                                               \
225  if (x != MPT_Success)                          \
226    return mpsr_SetError(mpsr_MPT_Failure);                 \
227}                                               \
228while (0)
229#undef mpt_return
230#define mpt_return(x)                                \
231do                                                  \
232{                                                   \
233  if (x != MPT_Success) return mpsr_SetError(mpsr_MPT_Failure);  \
234  else return mpsr_Success;                         \
235}                                                   \
236while (0)
237#undef mpsr_assume   
238#define mpsr_assume(cond) ((void) 0)
239
240#endif // MPSR_DEBUG
241
242// those defines are from longrat.cc
243// It would be nice if we could include them, but they are not defined
244// in a header file
245
246#define SR_HDL(A) ((long)(A))
247#define SR_INT    1
248#define INT_TO_SR(INT)  ((number) (((long)INT << 2) + SR_INT))
249#define SR_TO_INT(SR)   (((long)SR) >> 2)
250
251union nf
252{
253  float _f;
254  number _n;
255  nf(float f) {_f = f;}
256  nf(number n) {_n = n;}
257  float F() const {return _f;}
258  number N() const {return _n;}
259};
260
261#define Real32_2_Number(r) nf(nf(r).F()).N()
262#define Number_2_Real32(n) nf(n).F()
263
264
265#endif
266#endif
Note: See TracBrowser for help on using the repository browser.