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

spielwiese
Last change on this file since 6ae4f5 was 6ae4f5, checked in by Hans Schönemann <hannes@…>, 27 years ago
* hannes: - corrected scanner.l: parsing of strings in blocks: if (1) { write("","}"); } - corrected ipassign.cc: assignment of "dummy" types: DEF, NONE - corrected sleftv::Print(_), initialisation of _ - added conversion int->def - added CopyD(DEF) - in insert(..): object should not be of type NONE (lists.cc:lInsert0) - added int*intvec, int*intmat to iparith.cc git-svn-id: file:///usr/local/Singular/svn/trunk@145 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.4 1997-04-09 12:20:01 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#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    "MPSR::Quit"
124#define MPSR_DEFAULT_DUMP_FILE "mpsr_dump.mp"
125
126// some handy Macros for error handlings
127#ifdef MPSR_DEBUG
128
129#undef failr
130#define failr(x)                                                    \
131do                                                                  \
132{                                                                   \
133  mpsr_Status_t _status = x;                                        \
134  if (_status != mpsr_Success)                                            \
135    Werror("failr violation in %s line %d:",__FILE__, __LINE__);    \
136  if (_status != mpsr_Success) return _status;                      \
137}                                                                   \
138while (0)
139
140#undef mp_failr
141#define mp_failr(x)                                                 \
142do                                                                  \
143{                                                                   \
144  if (x != MP_Success)                                              \
145  {                                                                 \
146    Werror("mp_failr violation in %s line %d:",__FILE__, __LINE__); \
147    return mpsr_SetError(link);                                     \
148  }                                                                 \
149}                                                                   \
150while (0)
151
152#undef mp_return
153#define mp_return(x)                                                    \
154do                                                                      \
155{                                                                       \
156  if (x != MP_Success)                                                  \
157  {                                                                     \
158   Werror("mp_return violation in %s line %d:",__FILE__, __LINE__);     \
159   return mpsr_SetError(link);                                          \
160  }                                                                     \
161  else return mpsr_Success;                                             \
162}                                                                       \
163while (0)
164
165#undef mpt_failr
166#define mpt_failr(x)                                                 \
167do                                                                  \
168{                                                                   \
169  if (x != MPT_Success)                                              \
170  {                                                                 \
171    Werror("mpr_failr violation in %s line %d:",__FILE__, __LINE__); \
172    return mpsr_SetError(mpsr_MPT_Failure);                           \
173  }                                                                 \
174}                                                                   \
175while (0)
176#undef mpt_return
177#define mpt_return(x)                                                    \
178do                                                                      \
179{                                                                       \
180  if (x != MPT_Success)                                                  \
181  {                                                                     \
182   Werror("mpt_return violation in %s line %d:",__FILE__, __LINE__);     \
183   return mpsr_SetError(mpsr_MPT_Failure);                                \
184  }                                                                     \
185  else return mpsr_Success;                                             \
186}                                                                       \
187while (0)
188
189#undef mpsr_assume
190#define mpsr_assume(cond)                                               \
191do                                                                      \
192{                                                                       \
193  if ( ! (cond))                                                        \
194    Werror("mpsr_assume violation in %s line %d",__FILE__, __LINE__);   \
195} while (0)
196
197#else
198#undef failr
199#define failr(x)                                \
200do                                              \
201{                                               \
202  mpsr_Status_t _status = x;                    \
203  if (_status != mpsr_Success) return _status;              \
204}                                               \
205while (0)
206#undef mp_failr
207#define mp_failr(x)                             \
208do                                              \
209{                                               \
210  if (x != MP_Success)                          \
211    return mpsr_SetError(link);                 \
212}                                               \
213while (0)
214#undef mp_return
215#define mp_return(x)                                \
216do                                                  \
217{                                                   \
218  if (x != MP_Success) return mpsr_SetError(link);  \
219  else return mpsr_Success;                         \
220}                                                   \
221while (0)
222#undef mpt_failr
223#define mpt_failr(x)                             \
224do                                              \
225{                                               \
226  if (x != MPT_Success)                          \
227    return mpsr_SetError(mpsr_MPT_Failure);                 \
228}                                               \
229while (0)
230#undef mpt_return
231#define mpt_return(x)                                \
232do                                                  \
233{                                                   \
234  if (x != MPT_Success) return mpsr_SetError(mpsr_MPT_Failure);  \
235  else return mpsr_Success;                         \
236}                                                   \
237while (0)
238#undef mpsr_assume   
239#define mpsr_assume(cond) ((void) 0)
240
241#endif // MPSR_DEBUG
242
243// those defines are from longrat.cc
244// It would be nice if we could include them, but they are not defined
245// in a header file
246
247#define SR_HDL(A) ((long)(A))
248#define SR_INT    1
249#define INT_TO_SR(INT)  ((number) (((long)INT << 2) + SR_INT))
250#define SR_TO_INT(SR)   (((long)SR) >> 2)
251
252union nf
253{
254  float _f;
255  number _n;
256  nf(float f) {_f = f;}
257  nf(number n) {_n = n;}
258  float F() const {return _f;}
259  number N() const {return _n;}
260};
261
262#define Real32_2_Number(r) nf(nf(r).F()).N()
263#define Number_2_Real32(n) nf(n).F()
264
265
266#endif
267#endif
Note: See TracBrowser for help on using the repository browser.