source: git/Singular/mpsr.h @ 28ea37

spielwiese
Last change on this file since 28ea37 was 28ea37, checked in by Hans Schönemann <hannes@…>, 18 years ago
*hannes: sunos/i386-cc git-svn-id: file:///usr/local/Singular/svn/trunk@9252 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 9.3 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/* $Id: mpsr.h,v 1.23 2006-06-21 17:23:34 Singular 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// now the MP include stuff (is surrounded by ifndef there)
20#include"MP.h"
21
22#include"MPT.h"
23#include"structs.h"
24#include"subexpr.h"
25#include"omalloc.h"
26#include"polys.h"
27#include"numbers.h"
28#include"ring.h"
29
30/***************************************************************
31 *
32 * prototype declarations of routines we provide for the outer world
33 *
34 *
35 ***************************************************************/
36// from mpsr_Error.c
37typedef enum mpsr_Status_t
38{
39  mpsr_Failure,
40  mpsr_Success,
41  mpsr_MP_Failure,
42  mpsr_MPT_Failure,
43  mpsr_UnknownLeftvType,
44  mpsr_WrongLeftvType,
45  mpsr_UnknownSingularToken,
46  mpsr_UnknownDictionary,
47  mpsr_UnkownOperator,
48  mpsr_UnknownMPNodeType,
49  mpsr_CanNotHandlePrototype,
50  mpsr_WrongNumofArgs,
51  mpsr_WrongArgumentType,
52  mpsr_WrongNodeType,
53  mpsr_ReqAnnotSkip,
54  mpsr_WrongUnionDiscriminator,
55  mpsr_UnknownCoeffDomain,
56  mpsr_MaxError
57} mpsr_Status_t;
58
59extern mpsr_Status_t mpsr_SetError(mpsr_Status_t error);
60extern mpsr_Status_t mpsr_SetError(MP_Link_pt link);
61extern void mpsr_PrintError(mpsr_Status_t error);
62extern void mpsr_PrintError();
63extern void mpsr_PrintError(MP_Link_pt link);
64extern void mpsr_PrintError(mpsr_Status_t error, MP_Link_pt link);
65extern mpsr_Status_t mpsr_GetError();
66extern void mpsr_ClearError();
67
68// from mpsr_Get.cc
69extern mpsr_Status_t mpsr_GetMsg(MP_Link_pt link, leftv &lv);
70extern mpsr_Status_t mpsr_GetDump(MP_Link_pt link);
71// from mpsr_Put.cc
72extern mpsr_Status_t mpsr_PutMsg(MP_Link_pt link, leftv lv);
73extern mpsr_Status_t mpsr_PutDump(MP_Link_pt link);
74
75
76/***************************************************************
77 *
78 * Inline's
79 *
80 ***************************************************************/
81inline leftv mpsr_InitLeftv(short tok, void *data)
82{
83  leftv lv = (leftv) omAlloc0Bin(sleftv_bin);
84  lv->data = data;
85  lv->rtyp = tok;
86  return lv;
87}
88
89// this is only for intermediate ring changes by mpsr
90// a "proper" setting of the global ring is done at the end of all the
91// getting
92extern BOOLEAN currComplete;
93
94inline void mpsr_SetCurrRing(ring rg, BOOLEAN complete)
95{
96  if (currRing != rg || (complete && ! currComplete))
97  {
98#ifdef PDEBUG
99    nSetChar(rg);
100#else
101    nSetChar(rg);
102#endif
103    rComplete(rg);
104    pSetGlobals(rg);
105    currRing = rg;
106    currComplete = complete;
107  }
108}
109
110extern MP_Sint32_t *gTa;
111extern MP_Sint32_t gTa_Length;
112
113
114inline void mpsr_InitTempArray(int length)
115{
116  if (gTa_Length < length)
117    {
118      if (gTa != NULL)
119        omFreeSize(gTa, gTa_Length*sizeof(MP_Sint32_t));
120      gTa = (MP_Sint32_t *) omAlloc((length)*sizeof(MP_Sint32_t));
121      gTa_Length = length;
122    }
123}
124
125/***************************************************************
126 *
127 * Macros
128 *
129 ***************************************************************/
130
131// is application specific Dictionary
132#define MP_SingularDict 129
133// remove this, once the Galois field stuff is done properly
134#define MP_AnnotSingularGalois  1
135// String used to indicate the end of a communication
136#define MPSR_QUIT_STRING    "MPtcp:quit"
137
138// some handy Macros for error handlings
139#ifdef MPSR_DEBUG
140
141#undef failr
142#define failr(x)                                                    \
143do                                                                  \
144{                                                                   \
145  mpsr_Status_t _status = x;                                        \
146  if (_status != mpsr_Success)                                            \
147    Werror("failr violation in %s line %d:",__FILE__, __LINE__);    \
148  if (_status != mpsr_Success) return _status;                      \
149}                                                                   \
150while (0)
151
152#undef mp_failr
153#define mp_failr(x)                                                 \
154do                                                                  \
155{                                                                   \
156  if (x != MP_Success)                                              \
157  {                                                                 \
158    Werror("mp_failr violation in %s line %d:",__FILE__, __LINE__); \
159    return mpsr_SetError(link);                                     \
160  }                                                                 \
161}                                                                   \
162while (0)
163
164#undef mp_return
165#define mp_return(x)                                                    \
166do                                                                      \
167{                                                                       \
168  if (x != MP_Success)                                                  \
169  {                                                                     \
170   Werror("mp_return violation in %s line %d:",__FILE__, __LINE__);     \
171   return mpsr_SetError(link);                                          \
172  }                                                                     \
173  else return mpsr_Success;                                             \
174}                                                                       \
175while (0)
176
177#undef mpt_failr
178#define mpt_failr(x)                                                 \
179do                                                                  \
180{                                                                   \
181  if (x != MPT_Success)                                              \
182  {                                                                 \
183    Werror("mpt_failr violation in %s line %d:",__FILE__, __LINE__); \
184    return mpsr_SetError(mpsr_MPT_Failure);                           \
185  }                                                                 \
186}                                                                   \
187while (0)
188#undef mpt_return
189#define mpt_return(x)                                                    \
190do                                                                      \
191{                                                                       \
192  if (x != MPT_Success)                                                  \
193  {                                                                     \
194   Werror("mpt_return violation in %s line %d:",__FILE__, __LINE__);     \
195   return mpsr_SetError(mpsr_MPT_Failure);                                \
196  }                                                                     \
197  else return mpsr_Success;                                             \
198}                                                                       \
199while (0)
200
201#undef mpsr_assume
202#define mpsr_assume(cond)                                               \
203do                                                                      \
204{                                                                       \
205  if ( ! (cond))                                                        \
206    Werror("mpsr_assume violation in %s line %d",__FILE__, __LINE__);   \
207} while (0)
208
209#else
210#undef failr
211#define failr(x)                                \
212do                                              \
213{                                               \
214  mpsr_Status_t _status = x;                    \
215  if (_status != mpsr_Success) return _status;              \
216}                                               \
217while (0)
218#undef mp_failr
219#define mp_failr(x)                             \
220do                                              \
221{                                               \
222  if (x != MP_Success)                          \
223    return mpsr_SetError(link);                 \
224}                                               \
225while (0)
226#undef mp_return
227#define mp_return(x)                                \
228do                                                  \
229{                                                   \
230  if (x != MP_Success) return mpsr_SetError(link);  \
231  else return mpsr_Success;                         \
232}                                                   \
233while (0)
234#undef mpt_failr
235#define mpt_failr(x)                             \
236do                                              \
237{                                               \
238  if (x != MPT_Success)                          \
239    return mpsr_SetError(mpsr_MPT_Failure);                 \
240}                                               \
241while (0)
242#undef mpt_return
243#define mpt_return(x)                                \
244do                                                  \
245{                                                   \
246  if (x != MPT_Success) return mpsr_SetError(mpsr_MPT_Failure);  \
247  else return mpsr_Success;                         \
248}                                                   \
249while (0)
250#undef mpsr_assume
251#define mpsr_assume(cond) ((void) 0)
252
253#endif // MPSR_DEBUG
254
255union nf
256{
257  float _f;
258  number _n;
259  nf(float f) {_f = f;}
260  nf(number n) {_n = n;}
261  float F() const {return _f;}
262  number N() const {return _n;}
263};
264
265#define Real32_2_Number(r) nf(nf(r).F()).N()
266#define Number_2_Real32(n) nf(n).F()
267
268
269#endif
270#endif
Note: See TracBrowser for help on using the repository browser.