source: git/Singular/mpsr.h @ c4bbf1f

fieker-DuValspielwiese
Last change on this file since c4bbf1f was 550b4c, checked in by Olaf Bachmann <obachman@…>, 26 years ago
* Exponents in parameter (polys) are typedef'ed to EXPONENT_TYPE git-svn-id: file:///usr/local/Singular/svn/trunk@1408 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 9.7 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/* $Id: mpsr.h,v 1.8 1998-04-21 10:59:27 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
112extern MP_Sint32_t *gTa;
113extern MP_Sint32_t gTa_Length;
114
115
116inline void mpsr_InitTempArray(int length)
117{
118  if (gTa_Length < length)
119    {
120      Free(gTa, gTa_Length*sizeof(MP_Sint32_t));
121      gTa = (MP_Sint32_t *) Alloc((length)*sizeof(MP_Sint32_t));
122      gTa_Length = length;
123    }
124}
125
126/***************************************************************
127 *
128 * Macros
129 *
130 ***************************************************************/
131
132// is application specific Dictionary
133#define MP_SingularDict 129
134// remove this, once the Galois field stuff is done properly
135#define MP_AnnotSingularGalois  1
136// String used to indicate the end of a communication
137#define MPSR_QUIT_STRING    "MPtcp:quit"
138
139// some handy Macros for error handlings
140#ifdef MPSR_DEBUG
141
142#undef failr
143#define failr(x)                                                    \
144do                                                                  \
145{                                                                   \
146  mpsr_Status_t _status = x;                                        \
147  if (_status != mpsr_Success)                                            \
148    Werror("failr violation in %s line %d:",__FILE__, __LINE__);    \
149  if (_status != mpsr_Success) return _status;                      \
150}                                                                   \
151while (0)
152
153#undef mp_failr
154#define mp_failr(x)                                                 \
155do                                                                  \
156{                                                                   \
157  if (x != MP_Success)                                              \
158  {                                                                 \
159    Werror("mp_failr violation in %s line %d:",__FILE__, __LINE__); \
160    return mpsr_SetError(link);                                     \
161  }                                                                 \
162}                                                                   \
163while (0)
164
165#undef mp_return
166#define mp_return(x)                                                    \
167do                                                                      \
168{                                                                       \
169  if (x != MP_Success)                                                  \
170  {                                                                     \
171   Werror("mp_return violation in %s line %d:",__FILE__, __LINE__);     \
172   return mpsr_SetError(link);                                          \
173  }                                                                     \
174  else return mpsr_Success;                                             \
175}                                                                       \
176while (0)
177
178#undef mpt_failr
179#define mpt_failr(x)                                                 \
180do                                                                  \
181{                                                                   \
182  if (x != MPT_Success)                                              \
183  {                                                                 \
184    Werror("mpt_failr violation in %s line %d:",__FILE__, __LINE__); \
185    return mpsr_SetError(mpsr_MPT_Failure);                           \
186  }                                                                 \
187}                                                                   \
188while (0)
189#undef mpt_return
190#define mpt_return(x)                                                    \
191do                                                                      \
192{                                                                       \
193  if (x != MPT_Success)                                                  \
194  {                                                                     \
195   Werror("mpt_return violation in %s line %d:",__FILE__, __LINE__);     \
196   return mpsr_SetError(mpsr_MPT_Failure);                                \
197  }                                                                     \
198  else return mpsr_Success;                                             \
199}                                                                       \
200while (0)
201
202#undef mpsr_assume
203#define mpsr_assume(cond)                                               \
204do                                                                      \
205{                                                                       \
206  if ( ! (cond))                                                        \
207    Werror("mpsr_assume violation in %s line %d",__FILE__, __LINE__);   \
208} while (0)
209
210#else
211#undef failr
212#define failr(x)                                \
213do                                              \
214{                                               \
215  mpsr_Status_t _status = x;                    \
216  if (_status != mpsr_Success) return _status;              \
217}                                               \
218while (0)
219#undef mp_failr
220#define mp_failr(x)                             \
221do                                              \
222{                                               \
223  if (x != MP_Success)                          \
224    return mpsr_SetError(link);                 \
225}                                               \
226while (0)
227#undef mp_return
228#define mp_return(x)                                \
229do                                                  \
230{                                                   \
231  if (x != MP_Success) return mpsr_SetError(link);  \
232  else return mpsr_Success;                         \
233}                                                   \
234while (0)
235#undef mpt_failr
236#define mpt_failr(x)                             \
237do                                              \
238{                                               \
239  if (x != MPT_Success)                          \
240    return mpsr_SetError(mpsr_MPT_Failure);                 \
241}                                               \
242while (0)
243#undef mpt_return
244#define mpt_return(x)                                \
245do                                                  \
246{                                                   \
247  if (x != MPT_Success) return mpsr_SetError(mpsr_MPT_Failure);  \
248  else return mpsr_Success;                         \
249}                                                   \
250while (0)
251#undef mpsr_assume   
252#define mpsr_assume(cond) ((void) 0)
253
254#endif // MPSR_DEBUG
255
256// those defines are from longrat.cc
257// It would be nice if we could include them, but they are not defined
258// in a header file
259
260#define SR_HDL(A) ((long)(A))
261#define SR_INT    1
262#define INT_TO_SR(INT)  ((number) (((long)INT << 2) + SR_INT))
263#define SR_TO_INT(SR)   (((long)SR) >> 2)
264
265union nf
266{
267  float _f;
268  number _n;
269  nf(float f) {_f = f;}
270  nf(number n) {_n = n;}
271  float F() const {return _f;}
272  number N() const {return _n;}
273};
274
275#define Real32_2_Number(r) nf(nf(r).F()).N()
276#define Number_2_Real32(n) nf(n).F()
277
278
279#endif
280#endif
Note: See TracBrowser for help on using the repository browser.