1 #ifndef IPSHELL_H
2 #define IPSHELL_H
3 /****************************************
4 * Computer Algebra System SINGULAR *
5 ****************************************/
6 /*
7 * ABSTRACT
8 */
9 #include <stdio.h>
10 //#include "kernel/structs.h"
11 #include "kernel/ideals.h"
12 #include "Singular/lists.h"
13 #include "Singular/fevoices.h"
14
15 struct _ssubexpr;
16 typedef struct _ssubexpr *Subexpr;
17
18 BOOLEAN spectrumProc ( leftv,leftv );
19 BOOLEAN spectrumfProc( leftv,leftv );
20 BOOLEAN spaddProc ( leftv,leftv,leftv );
21 BOOLEAN spmulProc ( leftv,leftv,leftv );
22 BOOLEAN semicProc ( leftv,leftv,leftv );
23 BOOLEAN semicProc3 ( leftv,leftv,leftv,leftv );
24
25 BOOLEAN iiAssignCR(leftv, leftv);
26
27 BOOLEAN iiARROW (leftv, char*,char *);
28
29 EXTERN_VAR leftv iiCurrArgs;
30 EXTERN_VAR idhdl iiCurrProc;
31 EXTERN_VAR int iiOp; /* the current operation*/
32 extern const char * currid;
33 EXTERN_VAR int iiRETURNEXPR_len;
34 EXTERN_INST_VAR sleftv iiRETURNEXPR;
35 EXTERN_VAR ring *iiLocalRing;
36 //extern cmdnames cmds[];
37 extern const char *lastreserved;
38 EXTERN_VAR int myynest;
39 EXTERN_VAR int printlevel;
40 EXTERN_VAR int si_echo;
41
42
43 EXTERN_VAR BOOLEAN yyInRingConstruction; /* 1: during ring construction */
44
45 int IsCmd(const char *n, int & tok);
46
47 BOOLEAN iiPStart(idhdl pn, leftv sl);
48 BOOLEAN iiEStart(char* example, procinfo *pi);
49 BOOLEAN iiAllStart(procinfov pi, const char *p,feBufferTypes t, int l);
50 void type_cmd(leftv v);
51 void test_cmd(int i);
52 void list_cmd(int typ, const char* what, const char * prefix,
53 BOOLEAN iterate, BOOLEAN fullname=FALSE);
54 //char * iiStringMatrix(matrix im, int dim, char ch=',');
55 void killlocals(int v);
56 int exprlist_length(leftv v);
57 const char * Tok2Cmdname(int i);
58 const char * iiTwoOps(int t);
59 int iiOpsTwoChar(const char *s);
60
61 BOOLEAN iiWRITE(leftv res,leftv exprlist);
62 BOOLEAN iiExport(leftv v, int toLev);
63 BOOLEAN iiExport(leftv v, int toLev, package pack);
64 BOOLEAN iiInternalExport (leftv v, int toLev, package pack);
65 /// find the library of an proc
iiGetLibName(const procinfov pi)66 static inline char * iiGetLibName(const procinfov pi) { return pi->libname; }
67 char * iiGetLibProcBuffer( procinfov pi, int part=1 );
68 char * iiProcName(char *buf, char & ct, char* &e);
69 char * iiProcArgs(char *e,BOOLEAN withParenth);
70 BOOLEAN iiLibCmd( const char *newlib, BOOLEAN autoexport, BOOLEAN tellerror, BOOLEAN force );
71 /* sees wheter library lib has already been loaded
72 if yes, writes filename of lib into where and returns TRUE,
73 if no, returns FALSE
74 */
75 /// load lib/module given in v
76 BOOLEAN jjLOAD(const char *s, BOOLEAN autoexport = FALSE);
77 BOOLEAN jjLOAD_TRY(const char *s);
78 BOOLEAN iiLocateLib(const char* lib, char* where);
79 leftv iiMap(map theMap, const char * what);
80 void iiMakeResolv(resolvente r, int length, int rlen, char * name, int typ0,
81 intvec ** weights=NULL);
82 BOOLEAN jjMINRES(leftv res, leftv v);
83 BOOLEAN jjBETTI(leftv res, leftv v);
84 BOOLEAN jjBETTI2(leftv res, leftv u, leftv v);
85 BOOLEAN jjBETTI2_ID(leftv res, leftv u, leftv v);
86 BOOLEAN jjIMPORTFROM(leftv res, leftv u, leftv v);
87 BOOLEAN jjLIST_PL(leftv res, leftv v);
88
89 BOOLEAN jjVARIABLES_P(leftv res, leftv u);
90 BOOLEAN jjVARIABLES_ID(leftv res, leftv u);
91
92 int iiRegularity(lists L);
93 leftv singular_system(sleftv h);
94 BOOLEAN jjSYSTEM(leftv res, leftv v);
95 void iiDebug();
96 BOOLEAN iiCheckRing(int i);
97 poly iiHighCorner(ideal i, int ak);
98 char * iiConvName(const char *libname);
99 BOOLEAN iiGetLibStatus(const char *lib);
100 BOOLEAN iiLoadLIB(FILE *fp, const char *libnamebuf, const char *newlib,
101 idhdl pl, BOOLEAN autoexport, BOOLEAN tellerror);
102
103 // converts a resolution into a list of modules
104 lists syConvRes(syStrategy syzstr,BOOLEAN toDel=FALSE,int add_row_shift=0);
105 // converts a list of modules into a minimal resolution
106 syStrategy syForceMin(lists li);
107 // converts a list of modules into a resolution
108 syStrategy syConvList(lists li);
109
110 BOOLEAN syBetti1(leftv res, leftv u);
111 BOOLEAN syBetti2(leftv res, leftv u, leftv w);
112
113 /* ================================================================== */
114 /* Expressions : */
115 BOOLEAN iiExprArith1(leftv res, sleftv* a, int op);
116 BOOLEAN iiExprArith2(leftv res, sleftv* a, int op, sleftv* b,
117 BOOLEAN proccall=FALSE);
118 BOOLEAN iiExprArith3(leftv res, int op, leftv a, leftv b, leftv c);
119 BOOLEAN iiExprArithM(leftv res, sleftv* a, int op);
120 BOOLEAN iiApply(leftv res,leftv a, int op, leftv proc);
121
122 typedef BOOLEAN (*proc1)(leftv,leftv);
123
124 #ifdef GENTABLE
125 struct sValCmd1
126 {
127 proc1 p;
128 short cmd;
129 short res;
130 short arg;
131 short valid_for;
132 };
133
134 typedef BOOLEAN (*proc2)(leftv,leftv,leftv);
135 struct sValCmd2
136 {
137 proc2 p;
138 short cmd;
139 short res;
140 short arg1;
141 short arg2;
142 short valid_for;
143 };
144
145 typedef BOOLEAN (*proc3)(leftv,leftv,leftv,leftv);
146 struct sValCmd3
147 {
148 proc3 p;
149 short cmd;
150 short res;
151 short arg1;
152 short arg2;
153 short arg3;
154 short valid_for;
155 };
156 struct sValCmdM
157 {
158 proc1 p;
159 short cmd;
160 short res;
161 short number_of_args; /* -1: any, -2: any >0, .. */
162 short valid_for;
163 };
164 extern const struct sValCmd2 dArith2[];
165 extern const struct sValCmd1 dArith1[];
166 extern const struct sValCmd3 dArith3[];
167 extern const struct sValCmdM dArithM[];
168 #endif
169
170 /* ================================================================== */
171 /* Assigments : */
172 BOOLEAN iiAssign(leftv left, leftv right, BOOLEAN toplevel=TRUE);
173 coeffs jjSetMinpoly(coeffs cf, number a);
174
175 typedef BOOLEAN (*proci)(leftv,leftv,Subexpr);
176 struct sValAssign_sys
177 {
178 proc1 p;
179 short res;
180 short arg;
181 };
182
183 struct sValAssign
184 {
185 proci p;
186 short res;
187 short arg;
188 };
189
190 BOOLEAN iiParameter(leftv p);
191 BOOLEAN iiAlias(leftv p);
192
193 int iiTokType(int op);
194 /* ================================================================== */
195 int iiDeclCommand(leftv sy, leftv name, int lev, int t, idhdl* root,
196 BOOLEAN isring = FALSE, BOOLEAN init_b=TRUE);
197 BOOLEAN iiMake_proc(idhdl pn, package pack, leftv sl);
198 void* iiCallLibProc1(const char* n, void *arg, int arg_type, BOOLEAN &err);
199 leftv ii_CallLibProcM(const char* n, void **args, int *arg_types, const ring R, BOOLEAN &err);
200 ideal ii_CallProcId2Id(const char* lib,const char* proc, ideal arg,const ring R);
201 int ii_CallProcId2Int(const char* lib,const char* proc, ideal arg,const ring R);
202 // from misc.cc:
203 char * showOption();
204 BOOLEAN setOption(leftv res, leftv v);
205 /* ================================================================== */
206 char * versionString();
207 /* ================================================================== */
208 void singular_example(char *str);
209
210 BOOLEAN iiTryLoadLib(leftv v, const char *id);
211
212 int iiAddCproc(const char *libname, const char *procname, BOOLEAN pstatic,
213 BOOLEAN(*func)(leftv res, leftv v));
214
215 void iiCheckPack(package &p);
216 #ifndef SING_NDEBUG
217 void checkall();
218 #endif
219
220 void rSetHdl(idhdl h);
221 ring rInit(leftv pn, leftv rv, leftv ord);
222 idhdl rDefault(const char *s);
223
224 idhdl rFindHdl(ring r, idhdl n);
225 void rKill(idhdl h);
226 void rKill(ring r);
227 lists scIndIndset(ideal S, BOOLEAN all, ideal Q);
228 BOOLEAN mpKoszul(leftv res,leftv c/*ip*/, leftv b/*in*/, leftv id);
229 BOOLEAN mpJacobi(leftv res,leftv a);
230 BOOLEAN jjRESULTANT(leftv res, leftv u, leftv v, leftv w);
231 BOOLEAN kQHWeight(leftv res,leftv v);
232 BOOLEAN kWeight(leftv res,leftv id);
233 BOOLEAN loSimplex( leftv res, leftv args );
234 BOOLEAN loNewtonP( leftv res, leftv arg1 );
235 BOOLEAN nuMPResMat( leftv res, leftv arg1, leftv arg2 );
236 BOOLEAN nuLagSolve( leftv res, leftv arg1, leftv arg2, leftv arg3 );
237 BOOLEAN nuVanderSys( leftv res, leftv arg1, leftv arg2, leftv arg3);
238 BOOLEAN nuUResSolve( leftv res, leftv args );
239
240 BOOLEAN jjCHARSERIES(leftv res, leftv u);
241 /*
242 BOOLEAN jjRESULTANT(leftv res, leftv u, leftv v, leftv w);
243 #if 0
244 BOOLEAN jjIS_SQR_FREE(leftv res, leftv u);
245 #endif
246 */
247 /* ================================================================== */
248 void paPrint(const char *n,package p);
249 /* ================================================================== */
250
251
252 BOOLEAN iiTestAssume(leftv a, leftv b);
253
254 /* table interface for iiAddCproc */
255 /// apply an operation 'op' to an argument a
256 /// return TRUE on failure
257 BOOLEAN iiExprArith1Tab(leftv res,///< [out] pre-allocated result
258 leftv a, ///< [in] argument
259 int op, ///< [in] operation
260 const struct sValCmd1* dA1, ///< [in] table of possible proc
261 ///< assumes dArith1[0].cmd==op
262 int at, ///< [in] a->Typ()
263 const struct sConvertTypes *dConvertTypes ///< [in] table of type conversions
264 );
265 /// apply an operation 'op' to arguments a and a->next
266 /// return TRUE on failure
267 BOOLEAN iiExprArith2Tab(leftv res,///< [out] pre-allocated result
268 leftv a, ///< [in] 2 arguments
269 int op, ///< [in] operation
270 const struct sValCmd2* dA2,///< [in] table of possible proc
271 ///< assumes dA2[0].cmd==op
272 int at, ///< [in] a->Typ()
273 const struct sConvertTypes *dConvertTypes ///< [in] table of type conversions
274 );
275 /// apply an operation 'op' to arguments a, a->next and a->next->next
276 /// return TRUE on failure
277 BOOLEAN iiExprArith3Tab(leftv res, ///< [out] pre-allocated result
278 leftv a, ///< [in] 3 arguments
279 int op, ///< [in] operation
280 const struct sValCmd3* dA3,///< [in] table of possible proc
281 ///< assumes dA3[0].cmd==op
282 int at, ///< [in] a->Typ()
283 const struct sConvertTypes *dConvertTypes ///< [in] table of type conversions
284 );
285
286 /// check a list of arguemys against a given field of types
287 /// return TRUE if the types match
288 /// return FALSE (and, if report) report an error via Werror otherwise
289 BOOLEAN iiCheckTypes(leftv args,/// < [in] argument list (may be NULL)
290 const short *type_list,///< [in] field of types
291 ///< len, t1,t2,...
292 int report=0 /// ;in] report error?
293 );
294
295 BOOLEAN iiBranchTo(leftv r, leftv args);
296
297 lists rDecompose(const ring r);
298
299 lists rDecompose_list_cf(const ring r);
300 BOOLEAN rDecompose_CF(leftv res,const coeffs C);
301 ring rCompose(const lists L, const BOOLEAN check_comp=TRUE, const long bitmask=0x7fff, const int isLetterplace=FALSE);
302
303 void iiSetReturn(const leftv h);
304 #endif
305
306