My Project  UNKNOWN_GIT_VERSION
iparith.cc
Go to the documentation of this file.
1 /****************************************
2 * Computer Algebra System SINGULAR *
3 ****************************************/
4 
5 /*
6 * ABSTRACT: table driven kernel interface, used by interpreter
7 */
8 //long all_farey=0L;
9 //long farey_cnt=0L;
10 
11 #include "kernel/mod2.h"
12 
13 #include "omalloc/omalloc.h"
14 
15 #include "factory/factory.h"
16 
17 #include "coeffs/bigintmat.h"
18 #include "coeffs/coeffs.h"
19 #include "coeffs/numbers.h"
20 
21 #include "misc/options.h"
22 #include "misc/intvec.h"
23 #include "misc/sirandom.h"
24 #include "misc/prime.h"
25 
26 #include "polys/matpol.h"
27 #include "polys/monomials/maps.h"
28 #include "polys/sparsmat.h"
29 #include "polys/weight.h"
31 #include "polys/clapsing.h"
32 
35 
39 
40 #include "kernel/spectrum/GMPrat.h"
42 #include "kernel/oswrapper/timer.h"
43 #include "kernel/fglm/fglm.h"
44 
46 #include "kernel/GBEngine/syz.h"
47 #include "kernel/GBEngine/kstd1.h"
48 #include "kernel/GBEngine/units.h"
49 #include "kernel/GBEngine/tgb.h"
50 
51 #include "kernel/preimage.h"
52 #include "kernel/polys.h"
53 #include "kernel/ideals.h"
54 
55 #include "Singular/mod_lib.h"
56 #include "Singular/fevoices.h"
57 #include "Singular/tok.h"
58 #include "Singular/ipid.h"
59 #include "Singular/sdb.h"
60 #include "Singular/subexpr.h"
61 #include "Singular/lists.h"
62 #include "Singular/maps_ip.h"
63 
64 #include "Singular/ipconv.h"
65 #include "Singular/ipprint.h"
66 #include "Singular/attrib.h"
67 #include "Singular/links/silink.h"
68 #include "Singular/misc_ip.h"
70 
71 #include "Singular/number2.h"
72 
73 #include "Singular/fglm.h"
74 
75 #include "Singular/blackbox.h"
76 #include "Singular/newstruct.h"
77 #include "Singular/ipshell.h"
78 //#include "kernel/mpr_inout.h"
79 #include "reporter/si_signals.h"
80 
81 #include <ctype.h>
82 
83 // defaults for all commands: NO_NC | NO_RING | ALLOW_ZERODIVISOR
84 
85 #ifdef HAVE_PLURAL
87  #include "kernel/GBEngine/nc.h"
88  #include "polys/nc/nc.h"
89  #include "polys/nc/sca.h"
90  #define NC_MASK (3+64)
91 #else /* HAVE_PLURAL */
92  #define NC_MASK 0
93 #endif /* HAVE_PLURAL */
94 
95 #ifdef HAVE_RINGS
96  #define RING_MASK 4
97  #define ZERODIVISOR_MASK 8
98 #else
99  #define RING_MASK 0
100  #define ZERODIVISOR_MASK 0
101 #endif
102 #define ALLOW_PLURAL 1
103 #define NO_NC 0
104 #define COMM_PLURAL 2
105 #define ALLOW_RING 4
106 #define NO_RING 0
107 #define NO_ZERODIVISOR 8
108 #define ALLOW_ZERODIVISOR 0
109 #define ALLOW_LP 64
110 #define ALLOW_NC ALLOW_LP|ALLOW_PLURAL
111 
112 #define ALLOW_ZZ (ALLOW_RING|NO_ZERODIVISOR)
113 
114 
115 // bit 4 for warning, if used at toplevel
116 #define WARN_RING 16
117 // bit 5: do no try automatic conversions
118 #define NO_CONVERSION 32
119 
120 static BOOLEAN check_valid(const int p, const int op);
121 
122 /*=============== types =====================*/
124 {
125  short cmd;
126  short start;
127 };
128 
130 
131 struct _scmdnames
132 {
133  char *name;
134  short alias;
135  short tokval;
136  short toktype;
137 };
138 typedef struct _scmdnames cmdnames;
139 
140 struct sValCmd1
141 {
143  short cmd;
144  short res;
145  short arg;
146  short valid_for;
147 };
148 
150 struct sValCmd2
151 {
153  short cmd;
154  short res;
155  short arg1;
156  short arg2;
157  short valid_for;
158 };
159 
161 struct sValCmd3
162 {
164  short cmd;
165  short res;
166  short arg1;
167  short arg2;
168  short arg3;
169  short valid_for;
170 };
171 struct sValCmdM
172 {
174  short cmd;
175  short res;
176  short number_of_args; /* -1: any, -2: any >0, .. */
177  short valid_for;
178 };
179 
180 typedef struct
181 {
182  cmdnames *sCmds; /**< array of existing commands */
187  unsigned nCmdUsed; /**< number of commands used */
188  unsigned nCmdAllocated; /**< number of commands-slots allocated */
189  unsigned nLastIdentifier; /**< valid indentifieres are slot 1..nLastIdentifier */
190 } SArithBase;
191 
192 /*---------------------------------------------------------------------*
193  * File scope Variables (Variables share by several functions in
194  * the same file )
195  *
196  *---------------------------------------------------------------------*/
197 static SArithBase sArithBase; /**< Base entry for arithmetic */
198 
199 /*---------------------------------------------------------------------*
200  * Extern Functions declarations
201  *
202  *---------------------------------------------------------------------*/
203 static int _gentable_sort_cmds(const void *a, const void *b);
204 extern int iiArithRemoveCmd(char *szName);
205 extern int iiArithAddCmd(const char *szName, short nAlias, short nTokval,
206  short nToktype, short nPos=-1);
207 
208 /*============= proc =======================*/
209 static int iiTabIndex(const jjValCmdTab dArithTab, const int len, const int op);
210 static Subexpr jjMakeSub(leftv e);
211 
212 /*============= vars ======================*/
213 extern int cmdtok;
214 extern BOOLEAN expected_parms;
215 
216 #define ii_div_by_0 "div. by 0"
217 
218 int iiOp; /* the current operation*/
219 
220 /*=================== simple helpers =================*/
221 static int iin_Int(number &n,coeffs cf)
222 {
223  long l=n_Int(n,cf);
224  int i=(int)l;
225  if ((long)i==l) return l;
226  return 0;
227 }
228 poly pHeadProc(poly p)
229 {
230  return pHead(p);
231 }
232 
233 int iiTokType(int op)
234 {
235  for (unsigned i=0;i<sArithBase.nCmdUsed;i++)
236  {
237  if (sArithBase.sCmds[i].tokval==op)
238  return sArithBase.sCmds[i].toktype;
239  }
240  return 0;
241 }
242 
243 /*=================== operations with 2 args.: static proc =================*/
244 /* must be ordered: first operations for chars (infix ops),
245  * then alphabetically */
246 
248 {
249  bigintmat* aa= (bigintmat *)u->Data();
250  int bb = (int)(long)(v->Data());
251  if (errorreported) return TRUE;
252  bigintmat *cc=NULL;
253  switch (iiOp)
254  {
255  case '+': cc=bimAdd(aa,bb); break;
256  case '-': cc=bimSub(aa,bb); break;
257  case '*': cc=bimMult(aa,bb); break;
258  }
259  res->data=(char *)cc;
260  return cc==NULL;
261 }
263 {
264  return jjOP_BIM_I(res, v, u);
265 }
267 {
268  bigintmat* aa= (bigintmat *)u->Data();
269  number bb = (number)(v->Data());
270  if (errorreported) return TRUE;
271  bigintmat *cc=NULL;
272  switch (iiOp)
273  {
274  case '*': cc=bimMult(aa,bb,coeffs_BIGINT); break;
275  }
276  res->data=(char *)cc;
277  return cc==NULL;
278 }
280 {
281  return jjOP_BIM_BI(res, v, u);
282 }
284 {
285  intvec* aa= (intvec *)u->CopyD(INTVEC_CMD);
286  int bb = (int)(long)(v->Data());
287  if (errorreported) return TRUE;
288  switch (iiOp)
289  {
290  case '+': (*aa) += bb; break;
291  case '-': (*aa) -= bb; break;
292  case '*': (*aa) *= bb; break;
293  case '/':
294  case INTDIV_CMD: (*aa) /= bb; break;
295  case '%': (*aa) %= bb; break;
296  }
297  res->data=(char *)aa;
298  return FALSE;
299 }
301 {
302  return jjOP_IV_I(res,v,u);
303 }
305 {
306  intvec* aa= (intvec *)u->CopyD(INTVEC_CMD);
307  int bb = (int)(long)(v->Data());
308  int i=si_min(aa->rows(),aa->cols());
309  switch (iiOp)
310  {
311  case '+': for (;i>0;i--) IMATELEM(*aa,i,i) += bb;
312  break;
313  case '-': for (;i>0;i--) IMATELEM(*aa,i,i) -= bb;
314  break;
315  }
316  res->data=(char *)aa;
317  return FALSE;
318 }
320 {
321  return jjOP_IM_I(res,v,u);
322 }
324 {
325  int l=(int)(long)v->Data();
326  if (l>=0)
327  {
328  int d=(int)(long)u->Data();
329  intvec *vv=new intvec(l);
330  int i;
331  for(i=l-1;i>=0;i--) { (*vv)[i]=d; }
332  res->data=(char *)vv;
333  }
334  return (l<0);
335 }
337 {
338  res->data=(char *)new intvec((int)(long)u->Data(),(int)(long)v->Data());
339  return FALSE;
340 }
341 static void jjEQUAL_REST(leftv res,leftv u,leftv v);
343 {
344  intvec* a = (intvec * )(u->Data());
345  intvec* b = (intvec * )(v->Data());
346  int r=a->compare(b);
347  switch (iiOp)
348  {
349  case '<':
350  res->data = (char *) (r<0);
351  break;
352  case '>':
353  res->data = (char *) (r>0);
354  break;
355  case LE:
356  res->data = (char *) (r<=0);
357  break;
358  case GE:
359  res->data = (char *) (r>=0);
360  break;
361  case EQUAL_EQUAL:
362  case NOTEQUAL: /* negation handled by jjEQUAL_REST */
363  res->data = (char *) (r==0);
364  break;
365  }
366  jjEQUAL_REST(res,u,v);
367  if(r==-2) { WerrorS("size incompatible"); return TRUE; }
368  return FALSE;
369 }
371 {
372  bigintmat* a = (bigintmat * )(u->Data());
373  bigintmat* b = (bigintmat * )(v->Data());
374  int r=a->compare(b);
375  switch (iiOp)
376  {
377  case '<':
378  res->data = (char *) (r<0);
379  break;
380  case '>':
381  res->data = (char *) (r>0);
382  break;
383  case LE:
384  res->data = (char *) (r<=0);
385  break;
386  case GE:
387  res->data = (char *) (r>=0);
388  break;
389  case EQUAL_EQUAL:
390  case NOTEQUAL: /* negation handled by jjEQUAL_REST */
391  res->data = (char *) (r==0);
392  break;
393  }
394  jjEQUAL_REST(res,u,v);
395  if(r==-2) { WerrorS("size incompatible"); return TRUE; }
396  return FALSE;
397 }
399 {
400  intvec* a = (intvec * )(u->Data());
401  int b = (int)(long)(v->Data());
402  int r=a->compare(b);
403  switch (iiOp)
404  {
405  case '<':
406  res->data = (char *) (r<0);
407  break;
408  case '>':
409  res->data = (char *) (r>0);
410  break;
411  case LE:
412  res->data = (char *) (r<=0);
413  break;
414  case GE:
415  res->data = (char *) (r>=0);
416  break;
417  case EQUAL_EQUAL:
418  case NOTEQUAL: /* negation handled by jjEQUAL_REST */
419  res->data = (char *) (r==0);
420  break;
421  }
422  jjEQUAL_REST(res,u,v);
423  return FALSE;
424 }
426 {
427  //Print("in: >>%s<<\n",my_yylinebuf);
428  matrix a=(matrix)u->Data();
429  matrix b=(matrix)v->Data();
430  int r=mp_Compare(a,b,currRing);
431  switch (iiOp)
432  {
433  case '<':
434  res->data = (char *) (long)(r < 0);
435  break;
436  case '>':
437  res->data = (char *) (long)(r > 0);
438  break;
439  case LE:
440  res->data = (char *) (long)(r <= 0);
441  break;
442  case GE:
443  res->data = (char *) (long)(r >= 0);
444  break;
445  case EQUAL_EQUAL:
446  case NOTEQUAL: /* negation handled by jjEQUAL_REST */
447  res->data = (char *)(long) (r == 0);
448  break;
449  }
450  jjEQUAL_REST(res,u,v);
451  return FALSE;
452 }
454 {
455  poly p=(poly)u->Data();
456  poly q=(poly)v->Data();
457  int r=p_Compare(p,q,currRing);
458  switch (iiOp)
459  {
460  case '<':
461  res->data = (char *) (r < 0);
462  break;
463  case '>':
464  res->data = (char *) (r > 0);
465  break;
466  case LE:
467  res->data = (char *) (r <= 0);
468  break;
469  case GE:
470  res->data = (char *) (r >= 0);
471  break;
472  //case EQUAL_EQUAL:
473  //case NOTEQUAL: /* negation handled by jjEQUAL_REST */
474  // res->data = (char *) (r == 0);
475  // break;
476  }
477  jjEQUAL_REST(res,u,v);
478  return FALSE;
479 }
481 {
482  char* a = (char * )(u->Data());
483  char* b = (char * )(v->Data());
484  int result = strcmp(a,b);
485  switch (iiOp)
486  {
487  case '<':
488  res->data = (char *) (result < 0);
489  break;
490  case '>':
491  res->data = (char *) (result > 0);
492  break;
493  case LE:
494  res->data = (char *) (result <= 0);
495  break;
496  case GE:
497  res->data = (char *) (result >= 0);
498  break;
499  case EQUAL_EQUAL:
500  case NOTEQUAL: /* negation handled by jjEQUAL_REST */
501  res->data = (char *) (result == 0);
502  break;
503  }
504  jjEQUAL_REST(res,u,v);
505  return FALSE;
506 }
508 {
509  if (u->Next()!=NULL)
510  {
511  u=u->next;
512  res->next = (leftv)omAllocBin(sleftv_bin);
513  return iiExprArith2(res->next,u,iiOp,v);
514  }
515  else if (v->Next()!=NULL)
516  {
517  v=v->next;
518  res->next = (leftv)omAllocBin(sleftv_bin);
519  return iiExprArith2(res->next,u,iiOp,v);
520  }
521  return FALSE;
522 }
524 {
525  int b=(int)(long)u->Data();
526  int e=(int)(long)v->Data();
527  int rc = 1;
528  BOOLEAN overflow=FALSE;
529  if (e >= 0)
530  {
531  if (b==0)
532  {
533  rc=(e==0);
534  }
535  else if ((e==0)||(b==1))
536  {
537  rc= 1;
538  }
539  else if (b== -1)
540  {
541  if (e&1) rc= -1;
542  else rc= 1;
543  }
544  else
545  {
546  int oldrc;
547  while ((e--)!=0)
548  {
549  oldrc=rc;
550  rc *= b;
551  if (!overflow)
552  {
553  if(rc/b!=oldrc) overflow=TRUE;
554  }
555  }
556  if (overflow)
557  WarnS("int overflow(^), result may be wrong");
558  }
559  res->data = (char *)((long)rc);
560  if (u!=NULL) return jjOP_REST(res,u,v);
561  return FALSE;
562  }
563  else
564  {
565  WerrorS("exponent must be non-negative");
566  return TRUE;
567  }
568 }
570 {
571  int e=(int)(long)v->Data();
572  number n=(number)u->Data();
573  if (e>=0)
574  {
575  n_Power(n,e,(number*)&res->data,coeffs_BIGINT);
576  }
577  else
578  {
579  WerrorS("exponent must be non-negative");
580  return TRUE;
581  }
582  if (u!=NULL) return jjOP_REST(res,u,v);
583  return FALSE;
584 }
586 {
587  int e=(int)(long)v->Data();
588  number n=(number)u->Data();
589  int d=0;
590  if (e<0)
591  {
592  n=nInvers(n);
593  e=-e;
594  d=1;
595  }
596  number r;
597  nPower(n,e,(number*)&r);
598  res->data=(char*)r;
599  if (d) nDelete(&n);
600  if (u!=NULL) return jjOP_REST(res,u,v);
601  return FALSE;
602 }
604 {
605  int v_i=(int)(long)v->Data();
606  if (v_i<0)
607  {
608  WerrorS("exponent must be non-negative");
609  return TRUE;
610  }
611  poly u_p=(poly)u->CopyD(POLY_CMD);
612  if ((u_p!=NULL)
613  && ((v_i!=0) &&
614  ((long)pTotaldegree(u_p) > (signed long)currRing->bitmask / (signed long)v_i/2)))
615  {
616  Werror("OVERFLOW in power(d=%ld, e=%d, max=%ld)",
617  pTotaldegree(u_p),v_i,currRing->bitmask/2);
618  pDelete(&u_p);
619  return TRUE;
620  }
621  res->data = (char *)pPower(u_p,v_i);
622  if (u!=NULL) return jjOP_REST(res,u,v);
623  return errorreported; /* pPower may set errorreported via Werror */
624 }
626 {
627  res->data = (char *)id_Power((ideal)(u->Data()),(int)(long)(v->Data()), currRing);
628  if (u!=NULL) return jjOP_REST(res,u,v);
629  return FALSE;
630 }
632 {
633  u=u->next;
634  v=v->next;
635  if (u==NULL)
636  {
637  if (v==NULL) return FALSE; /* u==NULL, v==NULL */
638  if (iiOp=='-') /* u==NULL, v<>NULL, iiOp=='-'*/
639  {
640  do
641  {
642  if (res->next==NULL)
643  res->next = (leftv)omAlloc0Bin(sleftv_bin);
644  leftv tmp_v=v->next;
645  v->next=NULL;
646  BOOLEAN b=iiExprArith1(res->next,v,'-');
647  v->next=tmp_v;
648  if (b)
649  return TRUE;
650  v=tmp_v;
651  res=res->next;
652  } while (v!=NULL);
653  return FALSE;
654  }
655  loop /* u==NULL, v<>NULL, iiOp=='+' */
656  {
657  res->next = (leftv)omAlloc0Bin(sleftv_bin);
658  res=res->next;
659  res->data = v->CopyD();
660  res->rtyp = v->Typ();
661  v=v->next;
662  if (v==NULL) return FALSE;
663  }
664  }
665  if (v!=NULL) /* u<>NULL, v<>NULL */
666  {
667  do
668  {
669  res->next = (leftv)omAlloc0Bin(sleftv_bin);
670  leftv tmp_u=u->next; u->next=NULL;
671  leftv tmp_v=v->next; v->next=NULL;
672  BOOLEAN b=iiExprArith2(res->next,u,iiOp,v);
673  u->next=tmp_u;
674  v->next=tmp_v;
675  if (b)
676  return TRUE;
677  u=tmp_u;
678  v=tmp_v;
679  res=res->next;
680  } while ((u!=NULL) && (v!=NULL));
681  return FALSE;
682  }
683  loop /* u<>NULL, v==NULL */
684  {
685  res->next = (leftv)omAlloc0Bin(sleftv_bin);
686  res=res->next;
687  res->data = u->CopyD();
688  res->rtyp = u->Typ();
689  u=u->next;
690  if (u==NULL) return FALSE;
691  }
692 }
694 {
695  switch(u->Typ())
696  {
697  case 0:
698  {
699  int name_err=0;
700  if(isupper(u->name[0]))
701  {
702  const char *c=u->name+1;
703  while((*c!='\0')&&(islower(*c)||(isdigit(*c))||(*c=='_'))) c++;
704  if (*c!='\0')
705  name_err=1;
706  else
707  {
708  Print("%s of type 'ANY'. Trying load.\n", u->name);
709  if(iiTryLoadLib(u, u->name))
710  {
711  Werror("'%s' no such package", u->name);
712  return TRUE;
713  }
714  syMake(u,u->name,NULL);
715  }
716  }
717  else name_err=1;
718  if(name_err)
719  { Werror("'%s' is an invalid package name",u->name);return TRUE;}
720  // and now, after the loading: use next case !!! no break !!!
721  }
722  case PACKAGE_CMD:
723  {
724  package pa=(package)u->Data();
725  if (u->rtyp==IDHDL) pa=IDPACKAGE((idhdl)u->data);
726  if((!pa->loaded)
727  && (pa->language > LANG_TOP))
728  {
729  Werror("'%s' not loaded", u->name);
730  return TRUE;
731  }
732  if(v->rtyp == IDHDL)
733  {
734  v->name = omStrDup(v->name);
735  }
736  else if (v->rtyp!=0)
737  {
738  WerrorS("reserved name with ::");
739  return TRUE;
740  }
741  v->req_packhdl=pa;
742  syMake(v, v->name, pa);
743  memcpy(res, v, sizeof(sleftv));
744  memset(v, 0, sizeof(sleftv));
745  }
746  break;
747  case DEF_CMD:
748  break;
749  default:
750  WerrorS("<package>::<id> expected");
751  return TRUE;
752  }
753  return FALSE;
754 }
756 {
757  unsigned int a=(unsigned int)(unsigned long)u->Data();
758  unsigned int b=(unsigned int)(unsigned long)v->Data();
759  unsigned int c=a+b;
760  res->data = (char *)((long)c);
761  if (((Sy_bit(31)&a)==(Sy_bit(31)&b))&&((Sy_bit(31)&a)!=(Sy_bit(31)&c)))
762  {
763  WarnS("int overflow(+), result may be wrong");
764  }
765  return jjPLUSMINUS_Gen(res,u,v);
766 }
768 {
769  res->data = (char *)(n_Add((number)u->Data(), (number)v->Data(),coeffs_BIGINT));
770  return jjPLUSMINUS_Gen(res,u,v);
771 }
773 {
774  res->data = (char *)(nAdd((number)u->Data(), (number)v->Data()));
775  return jjPLUSMINUS_Gen(res,u,v);
776 }
778 {
779  res->data = (char *)(pAdd((poly)u->CopyD(POLY_CMD) , (poly)v->CopyD(POLY_CMD)));
780  return jjPLUSMINUS_Gen(res,u,v);
781 }
783 {
784  //res->data = (char *)(pAdd((poly)u->CopyD(POLY_CMD) , (poly)v->CopyD(POLY_CMD)));
786  poly p=(poly)u->CopyD(POLY_CMD);
787  int l=pLength(p);
788  sBucket_Add_p(b,p,l);
789  p= (poly)v->CopyD(POLY_CMD);
790  l=pLength(p);
791  sBucket_Add_p(b,p,l);
792  res->data=(void*)b;
793  return jjPLUSMINUS_Gen(res,u,v);
794 }
796 {
798  poly p= (poly)v->CopyD(POLY_CMD);
799  int l=pLength(p);
800  sBucket_Add_p(b,p,l);
801  res->data=(void*)b;
802  return jjPLUSMINUS_Gen(res,u,v);
803 }
805 {
806  res->data = (char *)ivAdd((intvec*)(u->Data()), (intvec*)(v->Data()));
807  if (res->data==NULL)
808  {
809  WerrorS("intmat size not compatible");
810  return TRUE;
811  }
812  return jjPLUSMINUS_Gen(res,u,v);
813 }
815 {
816  res->data = (char *)bimAdd((bigintmat*)(u->Data()), (bigintmat*)(v->Data()));
817  if (res->data==NULL)
818  {
819  WerrorS("bigintmat/cmatrix not compatible");
820  return TRUE;
821  }
822  return jjPLUSMINUS_Gen(res,u,v);
823 }
825 {
826  matrix A=(matrix)u->Data(); matrix B=(matrix)v->Data();
827  res->data = (char *)(mp_Add(A , B, currRing));
828  if (res->data==NULL)
829  {
830  Werror("matrix size not compatible(%dx%d, %dx%d)",
832  return TRUE;
833  }
834  return jjPLUSMINUS_Gen(res,u,v);
835 }
837 {
838  ideal A=(ideal)u->Data(); ideal B=(ideal)v->Data();
839  res->data = (char *)(sm_Add(A , B, currRing));
840  if (res->data==NULL)
841  {
842  Werror("matrix size not compatible(%dx%d, %dx%d)",
843  (int)A->rank,IDELEMS(A),(int)B->rank,IDELEMS(B));
844  return TRUE;
845  }
846  return jjPLUSMINUS_Gen(res,u,v);
847 }
849 {
850  matrix m=(matrix)u->Data();
851  matrix p= mp_InitP(m->nrows,m->ncols,(poly)(v->CopyD(POLY_CMD)),currRing);
852  if (iiOp=='+')
853  res->data = (char *)mp_Add(m , p,currRing);
854  else
855  res->data = (char *)mp_Sub(m , p,currRing);
856  idDelete((ideal *)&p);
857  return jjPLUSMINUS_Gen(res,u,v);
858 }
860 {
861  return jjPLUS_MA_P(res,v,u);
862 }
864 {
865  char* a = (char * )(u->Data());
866  char* b = (char * )(v->Data());
867  char* r = (char * )omAlloc(strlen(a) + strlen(b) + 1);
868  strcpy(r,a);
869  strcat(r,b);
870  res->data=r;
871  return jjPLUSMINUS_Gen(res,u,v);
872 }
874 {
875  res->data = (char *)idAdd((ideal)u->Data(),(ideal)v->Data());
876  return jjPLUSMINUS_Gen(res,u,v);
877 }
879 {
880  void *ap=u->Data(); void *bp=v->Data();
881  int aa=(int)(long)ap;
882  int bb=(int)(long)bp;
883  int cc=aa-bb;
884  unsigned int a=(unsigned int)(unsigned long)ap;
885  unsigned int b=(unsigned int)(unsigned long)bp;
886  unsigned int c=a-b;
887  if (((Sy_bit(31)&a)!=(Sy_bit(31)&b))&&((Sy_bit(31)&a)!=(Sy_bit(31)&c)))
888  {
889  WarnS("int overflow(-), result may be wrong");
890  }
891  res->data = (char *)((long)cc);
892  return jjPLUSMINUS_Gen(res,u,v);
893 }
895 {
896  res->data = (char *)(n_Sub((number)u->Data(), (number)v->Data(),coeffs_BIGINT));
897  return jjPLUSMINUS_Gen(res,u,v);
898 }
900 {
901  res->data = (char *)(nSub((number)u->Data(), (number)v->Data()));
902  return jjPLUSMINUS_Gen(res,u,v);
903 }
905 {
906  res->data = (char *)(pSub((poly)u->CopyD(POLY_CMD) , (poly)v->CopyD(POLY_CMD)));
907  return jjPLUSMINUS_Gen(res,u,v);
908 }
910 {
912  poly p= (poly)v->CopyD(POLY_CMD);
913  int l=pLength(p);
914  p=p_Neg(p,currRing);
915  sBucket_Add_p(b,p,l);
916  res->data=(void*)b;
917  return jjPLUSMINUS_Gen(res,u,v);
918 }
920 {
922  poly p=(poly)u->CopyD(POLY_CMD);
923  int l=pLength(p);
924  sBucket_Add_p(b,p,l);
925  p= (poly)v->CopyD(POLY_CMD);
926  p=p_Neg(p,currRing);
927  l=pLength(p);
928  sBucket_Add_p(b,p,l);
929  res->data=(void*)b;
930  return jjPLUSMINUS_Gen(res,u,v);
931 }
933 {
934  res->data = (char *)ivSub((intvec*)(u->Data()), (intvec*)(v->Data()));
935  if (res->data==NULL)
936  {
937  WerrorS("intmat size not compatible");
938  return TRUE;
939  }
940  return jjPLUSMINUS_Gen(res,u,v);
941 }
943 {
944  res->data = (char *)bimSub((bigintmat*)(u->Data()), (bigintmat*)(v->Data()));
945  if (res->data==NULL)
946  {
947  WerrorS("bigintmat/cmatrix not compatible");
948  return TRUE;
949  }
950  return jjPLUSMINUS_Gen(res,u,v);
951 }
953 {
954  matrix A=(matrix)u->Data(); matrix B=(matrix)v->Data();
955  res->data = (char *)(mp_Sub(A , B, currRing));
956  if (res->data==NULL)
957  {
958  Werror("matrix size not compatible(%dx%d, %dx%d)",
960  return TRUE;
961  }
962  return jjPLUSMINUS_Gen(res,u,v);
963  return FALSE;
964 }
966 {
967  ideal A=(ideal)u->Data(); ideal B=(ideal)v->Data();
968  res->data = (char *)(sm_Sub(A , B, currRing));
969  if (res->data==NULL)
970  {
971  Werror("matrix size not compatible(%dx%d, %dx%d)",
972  (int)A->rank,IDELEMS(A),(int)B->rank,IDELEMS(B));
973  return TRUE;
974  }
975  return jjPLUSMINUS_Gen(res,u,v);
976  return FALSE;
977 }
979 {
980  int a=(int)(long)u->Data();
981  int b=(int)(long)v->Data();
982  int64 c=(int64)a * (int64)b;
983  if ((c>INT_MAX)||(c<INT_MIN))
984  WarnS("int overflow(*), result may be wrong");
985  res->data = (char *)((long)((int)c));
986  if ((u->Next()!=NULL) || (v->Next()!=NULL))
987  return jjOP_REST(res,u,v);
988  return FALSE;
989 }
991 {
992  res->data = (char *)(n_Mult( (number)u->Data(), (number)v->Data(),coeffs_BIGINT));
993  if ((v->next!=NULL) || (u->next!=NULL))
994  return jjOP_REST(res,u,v);
995  return FALSE;
996 }
998 {
999  res->data = (char *)(nMult( (number)u->Data(), (number)v->Data()));
1000  number n=(number)res->data;
1001  nNormalize(n);
1002  res->data=(char *)n;
1003  if ((v->next!=NULL) || (u->next!=NULL))
1004  return jjOP_REST(res,u,v);
1005  return FALSE;
1006 }
1008 {
1009  poly a;
1010  poly b;
1011  if (v->next==NULL)
1012  {
1013  a=(poly)u->CopyD(POLY_CMD); // works also for VECTOR_CMD
1014  if (u->next==NULL)
1015  {
1016  b=(poly)v->CopyD(POLY_CMD); // works also for VECTOR_CMD
1017  if ((a!=NULL) && (b!=NULL)
1018  && ((long)pTotaldegree(a)>si_max((long)rVar(currRing),(long)currRing->bitmask/2)-(long)pTotaldegree(b)))
1019  {
1020  Warn("possible OVERFLOW in mult(d=%ld, d=%ld, max=%ld)",
1021  pTotaldegree(a),pTotaldegree(b),currRing->bitmask/2);
1022  }
1023  res->data = (char *)(pMult( a, b));
1024  pNormalize((poly)res->data);
1025  return FALSE;
1026  }
1027  // u->next exists: copy v
1028  b=pCopy((poly)v->Data());
1029  if ((a!=NULL) && (b!=NULL)
1030  && (pTotaldegree(a)+pTotaldegree(b)>si_max((long)rVar(currRing),(long)currRing->bitmask/2)))
1031  {
1032  Warn("possible OVERFLOW in mult(d=%ld, d=%ld, max=%ld)",
1033  pTotaldegree(a),pTotaldegree(b),currRing->bitmask/2);
1034  }
1035  res->data = (char *)(pMult( a, b));
1036  pNormalize((poly)res->data);
1037  return jjOP_REST(res,u,v);
1038  }
1039  // v->next exists: copy u
1040  a=pCopy((poly)u->Data());
1041  b=(poly)v->CopyD(POLY_CMD); // works also for VECTOR_CMD
1042  if ((a!=NULL) && (b!=NULL)
1043  && ((unsigned long)(pTotaldegree(a)+pTotaldegree(b))>=currRing->bitmask/2))
1044  {
1045  pDelete(&a);
1046  pDelete(&b);
1047  WerrorS("OVERFLOW");
1048  return TRUE;
1049  }
1050  res->data = (char *)(pMult( a, b));
1051  pNormalize((poly)res->data);
1052  return jjOP_REST(res,u,v);
1053 }
1055 {
1056  res->data = (char *)idMult((ideal)u->Data(),(ideal)v->Data());
1057  id_Normalize((ideal)res->data,currRing);
1058  if ((v->next!=NULL) || (u->next!=NULL))
1059  return jjOP_REST(res,u,v);
1060  return FALSE;
1061 }
1063 {
1064  res->data = (char *)ivMult((intvec*)(u->Data()), (intvec*)(v->Data()));
1065  if (res->data==NULL)
1066  {
1067  WerrorS("intmat size not compatible");
1068  return TRUE;
1069  }
1070  if ((v->next!=NULL) || (u->next!=NULL))
1071  return jjOP_REST(res,u,v);
1072  return FALSE;
1073 }
1075 {
1076  res->data = (char *)bimMult((bigintmat*)(u->Data()), (bigintmat*)(v->Data()));
1077  if (res->data==NULL)
1078  {
1079  WerrorS("bigintmat/cmatrix not compatible");
1080  return TRUE;
1081  }
1082  if ((v->next!=NULL) || (u->next!=NULL))
1083  return jjOP_REST(res,u,v);
1084  return FALSE;
1085 }
1087 {
1089  if (nMap==NULL) return TRUE;
1090  number n=nMap((number)v->Data(),coeffs_BIGINT,currRing->cf);
1091  poly p=pNSet(n);
1092  ideal I= (ideal)mp_MultP((matrix)u->CopyD(MATRIX_CMD),p,currRing);
1093  res->data = (char *)I;
1094  return FALSE;
1095 }
1097 {
1098  return jjTIMES_MA_BI1(res,v,u);
1099 }
1101 {
1102  poly p=(poly)v->CopyD(POLY_CMD);
1103  int r=pMaxComp(p);/* recompute the rank for the case ideal*vector*/
1104  ideal I= (ideal)mp_MultP((matrix)u->CopyD(MATRIX_CMD),p,currRing);
1105  if (r>0) I->rank=r;
1107  res->data = (char *)I;
1108  return FALSE;
1109 }
1111 {
1112  poly p=(poly)u->CopyD(POLY_CMD);
1113  int r=pMaxComp(p);/* recompute the rank for the case ideal*vector*/
1114  ideal I= (ideal)pMultMp(p,(matrix)v->CopyD(MATRIX_CMD),currRing);
1115  if (r>0) I->rank=r;
1117  res->data = (char *)I;
1118  return FALSE;
1119 }
1121 {
1122  number n=(number)v->CopyD(NUMBER_CMD);
1123  poly p=pNSet(n);
1124  res->data = (char *)mp_MultP((matrix)u->CopyD(MATRIX_CMD),p,currRing);
1125  id_Normalize((ideal)res->data,currRing);
1126  return FALSE;
1127 }
1129 {
1130  return jjTIMES_MA_N1(res,v,u);
1131 }
1133 {
1134  res->data = (char *)mp_MultI((matrix)u->CopyD(MATRIX_CMD),(int)(long)v->Data(),currRing);
1135  id_Normalize((ideal)res->data,currRing);
1136  return FALSE;
1137 }
1139 {
1140  return jjTIMES_MA_I1(res,v,u);
1141 }
1143 {
1144  matrix A=(matrix)u->Data(); matrix B=(matrix)v->Data();
1145  res->data = (char *)mp_Mult(A,B,currRing);
1146  if (res->data==NULL)
1147  {
1148  Werror("matrix size not compatible(%dx%d, %dx%d) in *",
1150  return TRUE;
1151  }
1152  id_Normalize((ideal)res->data,currRing);
1153  if ((v->next!=NULL) || (u->next!=NULL))
1154  return jjOP_REST(res,u,v);
1155  return FALSE;
1156 }
1158 {
1159  ideal A=(ideal)u->Data(); ideal B=(ideal)v->Data();
1160  res->data = (char *)sm_Mult(A,B,currRing);
1161  if (res->data==NULL)
1162  {
1163  Werror("matrix size not compatible(%dx%d, %dx%d) in *",
1164  (int)A->rank,IDELEMS(A),(int)B->rank,IDELEMS(B));
1165  return TRUE;
1166  }
1167  id_Normalize((ideal)res->data,currRing);
1168  if ((v->next!=NULL) || (u->next!=NULL))
1169  return jjOP_REST(res,u,v);
1170  return FALSE;
1171 }
1173 {
1174  number h=n_Sub((number)u->Data(),(number)v->Data(),coeffs_BIGINT);
1175  res->data = (char *) (n_GreaterZero(h,coeffs_BIGINT)||(n_IsZero(h,coeffs_BIGINT)));
1177  return FALSE;
1178 }
1180 {
1181  res->data = (char *)(long)((int)((long)u->Data()) >= (int)((long)v->Data()));
1182  return FALSE;
1183 }
1185 {
1186  res->data = (char *)(long) (nGreater((number)u->Data(),(number)v->Data())
1187  || nEqual((number)u->Data(),(number)v->Data()));
1188  return FALSE;
1189 }
1191 {
1192  number h=n_Sub((number)u->Data(),(number)v->Data(),coeffs_BIGINT);
1193  res->data = (char *)(long) (n_GreaterZero(h,coeffs_BIGINT)&&(!n_IsZero(h,coeffs_BIGINT)));
1195  return FALSE;
1196 }
1198 {
1199  res->data = (char *)(long)((int)((long)u->Data()) > (int)((long)v->Data()));
1200  return FALSE;
1201 }
1203 {
1204  res->data = (char *)(long)(nGreater((number)u->Data(),(number)v->Data()));
1205  return FALSE;
1206 }
1208 {
1209  return jjGE_BI(res,v,u);
1210 }
1212 {
1213  res->data = (char *)(long)((int)((long)u->Data()) <= (int)((long)v->Data()));
1214  return FALSE;
1215 }
1217 {
1218  return jjGE_N(res,v,u);
1219 }
1221 {
1222  return jjGT_BI(res,v,u);
1223 }
1225 {
1226  res->data = (char *)(long)((int)((long)u->Data()) < (int)((long)v->Data()));
1227  return FALSE;
1228 }
1230 {
1231  return jjGT_N(res,v,u);
1232 }
1234 {
1235  if (iiOp=='/') Warn("int division with `/`: use `div` instead in line >>%s<<",my_yylinebuf);
1236  int a= (int)(long)u->Data();
1237  int b= (int)(long)v->Data();
1238  if (b==0)
1239  {
1241  return TRUE;
1242  }
1243  int c=a%b;
1244  int r=0;
1245  switch (iiOp)
1246  {
1247  case '%':
1248  r=c; break;
1249  case '/':
1250  case INTDIV_CMD:
1251  r=((a-c) /b); break;
1252  }
1253  res->data=(void *)((long)r);
1254  return FALSE;
1255 }
1257 {
1258  number q=(number)v->Data();
1259  if (n_IsZero(q,coeffs_BIGINT))
1260  {
1262  return TRUE;
1263  }
1264  q = n_Div((number)u->Data(),q,coeffs_BIGINT);
1266  res->data = (char *)q;
1267  return FALSE;
1268 }
1270 {
1271  number q=(number)v->Data();
1272  if (nIsZero(q))
1273  {
1275  return TRUE;
1276  }
1277  q = nDiv((number)u->Data(),q);
1278  nNormalize(q);
1279  res->data = (char *)q;
1280  return FALSE;
1281 }
1283 {
1284  poly q=(poly)v->CopyD();
1285  poly p=(poly)(u->CopyD());
1286  res->data=(void*)(p_Divide(p /*(poly)(u->CopyD())*/ ,
1287  q /*(poly)(v->CopyD())*/ ,currRing));
1288  if (res->data!=NULL) pNormalize((poly)res->data);
1289  return errorreported; /*there may be errors in p_Divide: div. ny 0, etc.*/
1290 }
1292 {
1293  poly q=(poly)v->Data();
1294  if (q==NULL)
1295  {
1297  return TRUE;
1298  }
1299  matrix m=(matrix)(u->Data());
1300  int r=m->rows();
1301  int c=m->cols();
1302  matrix mm=mpNew(r,c);
1303  unsigned i,j;
1304  for(i=r;i>0;i--)
1305  {
1306  for(j=c;j>0;j--)
1307  {
1308  if (pNext(q)!=NULL)
1309  {
1310  MATELEM(mm,i,j) = singclap_pdivide( MATELEM(m,i,j) ,
1311  q /*(poly)(v->Data())*/, currRing );
1312  }
1313  else
1314  MATELEM(mm,i,j) = pDivideM(pCopy(MATELEM(m,i,j)),pHead(q));
1315  }
1316  }
1317  id_Normalize((ideal)mm,currRing);
1318  res->data=(char *)mm;
1319  return FALSE;
1320 }
1322 {
1323  res->data = (char *)((long)n_Equal((number)u->Data(),(number)v->Data(),coeffs_BIGINT));
1324  jjEQUAL_REST(res,u,v);
1325  return FALSE;
1326 }
1328 {
1329  res->data = (char *)((int)((long)u->Data()) == (int)((long)v->Data()));
1330  jjEQUAL_REST(res,u,v);
1331  return FALSE;
1332 }
1334 {
1335  res->data = (char *)((long)mp_Equal((matrix)u->Data(),(matrix)v->Data(),currRing));
1336  jjEQUAL_REST(res,u,v);
1337  return FALSE;
1338 }
1340 {
1341  res->data = (char *)((long)sm_Equal((ideal)u->Data(),(ideal)v->Data(),currRing));
1342  jjEQUAL_REST(res,u,v);
1343  return FALSE;
1344 }
1346 {
1347  res->data = (char *)(long)(u->Data()==v->Data());
1348  jjEQUAL_REST(res,u,v);
1349  return FALSE;
1350 }
1352 {
1353  res->data = (char *)((long)nEqual((number)u->Data(),(number)v->Data()));
1354  jjEQUAL_REST(res,u,v);
1355  return FALSE;
1356 }
1358 {
1359  poly p=(poly)u->Data();
1360  poly q=(poly)v->Data();
1361  res->data = (char *) ((long)pEqualPolys(p,q));
1362  jjEQUAL_REST(res,u,v);
1363  return FALSE;
1364 }
1366 {
1367  if ((res->data) && (u->next!=NULL) && (v->next!=NULL))
1368  {
1369  int save_iiOp=iiOp;
1370  if (iiOp==NOTEQUAL)
1372  else
1373  iiExprArith2(res,u->next,iiOp,v->next);
1374  iiOp=save_iiOp;
1375  }
1376  if (iiOp==NOTEQUAL) res->data=(char *)(!(long)res->data);
1377 }
1379 {
1380  res->data = (char *)((long)u->Data() && (long)v->Data());
1381  return FALSE;
1382 }
1384 {
1385  res->data = (char *)((long)u->Data() || (long)v->Data());
1386  return FALSE;
1387 }
1389 {
1390  res->rtyp=u->rtyp; u->rtyp=0;
1391  res->data=u->data; u->data=NULL;
1392  res->name=u->name; u->name=NULL;
1393  res->e=u->e; u->e=NULL;
1394  if (res->e==NULL) res->e=jjMakeSub(v);
1395  else
1396  {
1397  Subexpr sh=res->e;
1398  while (sh->next != NULL) sh=sh->next;
1399  sh->next=jjMakeSub(v);
1400  }
1401  if (u->next!=NULL)
1402  {
1404  BOOLEAN bo=iiExprArith2(rn,u->next,iiOp,v);
1405  res->next=rn;
1406  return bo;
1407  }
1408  return FALSE;
1409 }
1411 {
1412  if ((u->rtyp!=IDHDL)||(u->e!=NULL))
1413  {
1414  WerrorS("indexed object must have a name");
1415  return TRUE;
1416  }
1417  intvec * iv=(intvec *)v->Data();
1418  leftv p=NULL;
1419  int i;
1420  sleftv t;
1421  memset(&t,0,sizeof(t));
1422  t.rtyp=INT_CMD;
1423  for (i=0;i<iv->length(); i++)
1424  {
1425  t.data=(char *)((long)(*iv)[i]);
1426  if (p==NULL)
1427  {
1428  p=res;
1429  }
1430  else
1431  {
1432  p->next=(leftv)omAlloc0Bin(sleftv_bin);
1433  p=p->next;
1434  }
1435  p->rtyp=IDHDL;
1436  p->data=u->data;
1437  p->name=u->name;
1438  p->flag=u->flag;
1439  p->e=jjMakeSub(&t);
1440  }
1441  u->rtyp=0;
1442  u->data=NULL;
1443  u->name=NULL;
1444  return FALSE;
1445 }
1447 {
1448  poly p=(poly)u->Data();
1449  int i=(int)(long)v->Data();
1450  int j=0;
1451  while (p!=NULL)
1452  {
1453  j++;
1454  if (j==i)
1455  {
1456  res->data=(char *)pHead(p);
1457  return FALSE;
1458  }
1459  pIter(p);
1460  }
1461  return FALSE;
1462 }
1464 {
1465  sBucket_pt b=(sBucket_pt)u->CopyD();
1467  int l; poly p,pp;
1468  sBucketDestroyAdd(b, &pp, &l);
1469  int i=(int)(long)v->Data();
1470  int j=0;
1471  p=pp;
1472  while (p!=NULL)
1473  {
1474  j++;
1475  if (j==i)
1476  {
1477  res->data=(char *)pHead(p);
1478  p_Delete(&pp,currRing);
1479  return FALSE;
1480  }
1481  pIter(p);
1482  }
1483  p_Delete(&pp,currRing);
1484  return FALSE;
1485 }
1487 {
1488  poly p=(poly)u->Data();
1489  poly r=NULL;
1490  intvec *iv=(intvec *)v->CopyD(INTVEC_CMD);
1491  int i;
1492  int sum=0;
1493  for(i=iv->length()-1;i>=0;i--)
1494  sum+=(*iv)[i];
1495  int j=0;
1496  while ((p!=NULL) && (sum>0))
1497  {
1498  j++;
1499  for(i=iv->length()-1;i>=0;i--)
1500  {
1501  if (j==(*iv)[i])
1502  {
1503  r=pAdd(r,pHead(p));
1504  sum-=j;
1505  (*iv)[i]=0;
1506  break;
1507  }
1508  }
1509  pIter(p);
1510  }
1511  delete iv;
1512  res->data=(char *)r;
1513  return FALSE;
1514 }
1516 {
1517  poly p=(poly)u->Data();
1518  int i=(int)(long)v->Data();
1519  res->data=(char *)p_Vec2Poly(p,i,currRing);
1520  return FALSE;
1521 }
1523 {
1524  poly p=(poly)u->CopyD(VECTOR_CMD);
1525  if (p!=NULL)
1526  {
1527  poly r=pOne();
1528  poly hp=r;
1529  intvec *iv=(intvec *)v->Data();
1530  int i;
1531  loop
1532  {
1533  for(i=0;i<iv->length();i++)
1534  {
1535  if (((int)pGetComp(p))==(*iv)[i])
1536  {
1537  poly h;
1538  pSplit(p,&h);
1539  pNext(hp)=p;
1540  p=h;
1541  pIter(hp);
1542  break;
1543  }
1544  }
1545  if (p==NULL) break;
1546  if (i==iv->length())
1547  {
1548  pLmDelete(&p);
1549  if (p==NULL) break;
1550  }
1551  }
1552  pLmDelete(&r);
1553  res->data=(char *)r;
1554  }
1555  return FALSE;
1556 }
1559 {
1560  if(u->name==NULL) return TRUE;
1561  char * nn = (char *)omAlloc(strlen(u->name) + 14);
1562  sprintf(nn,"%s(%d)",u->name,(int)(long)v->Data());
1563  omFree((ADDRESS)u->name);
1564  u->name=NULL;
1565  char *n=omStrDup(nn);
1566  omFree((ADDRESS)nn);
1567  syMake(res,n);
1568  if (u->next!=NULL) return jjKLAMMER_rest(res,u->next,v);
1569  return FALSE;
1570 }
1572 {
1573  intvec * iv=(intvec *)v->Data();
1574  leftv p=NULL;
1575  int i;
1576  long slen = strlen(u->name) + 14;
1577  char *n = (char*) omAlloc(slen);
1578 
1579  for (i=0;i<iv->length(); i++)
1580  {
1581  if (p==NULL)
1582  {
1583  p=res;
1584  }
1585  else
1586  {
1587  p->next=(leftv)omAlloc0Bin(sleftv_bin);
1588  p=p->next;
1589  }
1590  sprintf(n,"%s(%d)",u->name,(*iv)[i]);
1591  syMake(p,omStrDup(n));
1592  }
1593  omFree((ADDRESS)u->name);
1594  u->name = NULL;
1595  omFreeSize(n, slen);
1596  if (u->next!=NULL) return jjKLAMMER_rest(res,u->next,v);
1597  return FALSE;
1598 }
1600 {
1602  memset(tmp,0,sizeof(sleftv));
1603  BOOLEAN b;
1604  if (v->Typ()==INTVEC_CMD)
1605  b=jjKLAMMER_IV(tmp,u,v);
1606  else
1607  b=jjKLAMMER(tmp,u,v);
1608  if (b)
1609  {
1610  omFreeBin(tmp,sleftv_bin);
1611  return TRUE;
1612  }
1613  leftv h=res;
1614  while (h->next!=NULL) h=h->next;
1615  h->next=tmp;
1616  return FALSE;
1617 }
1619 {
1620  void *d;
1621  Subexpr e;
1622  int typ;
1623  BOOLEAN t=FALSE;
1624  idhdl tmp_proc=NULL;
1625  if ((u->rtyp!=IDHDL)||(u->e!=NULL))
1626  {
1627  tmp_proc=(idhdl)omAlloc0(sizeof(idrec));
1628  tmp_proc->id="_auto";
1629  tmp_proc->typ=PROC_CMD;
1630  tmp_proc->data.pinf=(procinfo *)u->Data();
1631  tmp_proc->ref=1;
1632  d=u->data; u->data=(void *)tmp_proc;
1633  e=u->e; u->e=NULL;
1634  t=TRUE;
1635  typ=u->rtyp; u->rtyp=IDHDL;
1636  }
1637  BOOLEAN sl;
1638  if (u->req_packhdl==currPack)
1639  sl = iiMake_proc((idhdl)u->data,NULL,v);
1640  else
1641  sl = iiMake_proc((idhdl)u->data,u->req_packhdl,v);
1642  if (t)
1643  {
1644  u->rtyp=typ;
1645  u->data=d;
1646  u->e=e;
1647  omFreeSize(tmp_proc,sizeof(idrec));
1648  }
1649  if (sl) return TRUE;
1650  memcpy(res,&iiRETURNEXPR,sizeof(sleftv));
1651  iiRETURNEXPR.Init();
1652  return FALSE;
1653 }
1655 {
1656  //Print("try to map %s with %s\n",$3.Name(),$1.Name());
1657  leftv sl=NULL;
1658  if ((v->e==NULL)&&(v->name!=NULL))
1659  {
1660  map m=(map)u->Data();
1661  sl=iiMap(m,v->name);
1662  }
1663  else
1664  {
1665  Werror("%s(<name>) expected",u->Name());
1666  }
1667  if (sl==NULL) return TRUE;
1668  memcpy(res,sl,sizeof(sleftv));
1670  return FALSE;
1671 }
1673 {
1674  u->next=(leftv)omAlloc(sizeof(sleftv));
1675  memcpy(u->next,v,sizeof(sleftv));
1676  memset(v,0,sizeof(sleftv));
1677  BOOLEAN bo=iiExprArithM(res,u,'[');
1678  u->next=NULL;
1679  return bo;
1680 }
1682 {
1683  intvec *c=(intvec*)u->Data();
1684  intvec* p=(intvec*)v->Data();
1685  int rl=p->length();
1686  number *x=(number *)omAlloc(rl*sizeof(number));
1687  number *q=(number *)omAlloc(rl*sizeof(number));
1688  int i;
1689  for(i=rl-1;i>=0;i--)
1690  {
1691  q[i]=n_Init((*p)[i], coeffs_BIGINT);
1692  x[i]=n_Init((*c)[i], coeffs_BIGINT);
1693  }
1694  CFArray iv(rl);
1695  number n=n_ChineseRemainderSym(x,q,rl,FALSE,iv,coeffs_BIGINT);
1696  for(i=rl-1;i>=0;i--)
1697  {
1698  n_Delete(&(q[i]),coeffs_BIGINT);
1699  n_Delete(&(x[i]),coeffs_BIGINT);
1700  }
1701  omFree(x); omFree(q);
1702  res->data=(char *)n;
1703  return FALSE;
1704 }
1705 #if 0
1706 static BOOLEAN jjCHINREM_P(leftv res, leftv u, leftv v)
1707 {
1708  lists c=(lists)u->CopyD(); // list of poly
1709  intvec* p=(intvec*)v->Data();
1710  int rl=p->length();
1711  poly r=NULL,h, result=NULL;
1712  number *x=(number *)omAlloc(rl*sizeof(number));
1713  number *q=(number *)omAlloc(rl*sizeof(number));
1714  int i;
1715  for(i=rl-1;i>=0;i--)
1716  {
1717  q[i]=nlInit((*p)[i]);
1718  }
1719  loop
1720  {
1721  for(i=rl-1;i>=0;i--)
1722  {
1723  if (c->m[i].Typ()!=POLY_CMD)
1724  {
1725  Werror("poly expected at pos %d",i+1);
1726  for(i=rl-1;i>=0;i--)
1727  {
1728  nlDelete(&(q[i]),currRing);
1729  }
1730  omFree(x); omFree(q); // delete c
1731  return TRUE;
1732  }
1733  h=((poly)c->m[i].Data());
1734  if (r==NULL) r=h;
1735  else if (pLmCmp(r,h)==-1) r=h;
1736  }
1737  if (r==NULL) break;
1738  for(i=rl-1;i>=0;i--)
1739  {
1740  h=((poly)c->m[i].Data());
1741  if (pLmCmp(r,h)==0)
1742  {
1743  x[i]=pGetCoeff(h);
1744  h=pLmFreeAndNext(h);
1745  c->m[i].data=(char*)h;
1746  }
1747  else
1748  x[i]=nlInit(0);
1749  }
1750  number n=n_ChineseRemainder(x,q,rl,currRing->cf);
1751  for(i=rl-1;i>=0;i--)
1752  {
1753  nlDelete(&(x[i]),currRing);
1754  }
1755  h=pHead(r);
1756  pSetCoeff(h,n);
1757  result=pAdd(result,h);
1758  }
1759  for(i=rl-1;i>=0;i--)
1760  {
1761  nlDelete(&(q[i]),currRing);
1762  }
1763  omFree(x); omFree(q);
1764  res->data=(char *)result;
1765  return FALSE;
1766 }
1767 #endif
1769 {
1770  poly p=(poly)u->CopyD();
1771  int s=(int)(long)v->Data();
1772  if (s+p_MinComp(p,currRing)<=0)
1773  { p_Delete(&p,currRing);return TRUE;}
1774  p_Shift(&p,s,currRing);
1775  res->data=p;
1776  return FALSE;
1777 }
1779 {
1780  ideal M=(ideal)u->CopyD();
1781  int s=(int)(long)v->Data();
1782  for(int i=IDELEMS(M)-1; i>=0;i--)
1783  {
1784  if (s+p_MinComp(M->m[i],currRing)<=0)
1785  { id_Delete(&M,currRing);return TRUE;}
1786  }
1787  id_Shift(M,s,currRing);
1788  res->data=M;
1789  return FALSE;
1790 }
1791 static BOOLEAN jjCHINREM_ID(leftv res, leftv u, leftv v);
1793 {
1794  poly p=(poly)v->Data();
1795  if ((p==NULL)||(pNext(p)!=NULL)) return TRUE;
1796  res->data=(char *)mp_CoeffProc((poly)u->Data(),p /*(poly)v->Data()*/,currRing);
1797  return FALSE;
1798 }
1800 {
1801  poly p=(poly)v->Data();
1802  if ((p==NULL)||(pNext(p)!=NULL)) return TRUE;
1803  res->data=(char *)mp_CoeffProcId((ideal)u->Data(),p /*(poly)v->Data()*/,currRing);
1804  return FALSE;
1805 }
1807 {
1808  int i=pVar((poly)v->Data());
1809  if (i==0)
1810  {
1811  WerrorS("ringvar expected");
1812  return TRUE;
1813  }
1814  res->data=(char *)mp_Coeffs((ideal)u->CopyD(),i,currRing);
1815  return FALSE;
1816 }
1818 {
1819  poly p = pInit();
1820  int i;
1821  for (i=1; i<=currRing->N; i++)
1822  {
1823  pSetExp(p, i, 1);
1824  }
1825  pSetm(p);
1826  res->data = (void*)idCoeffOfKBase((ideal)(u->Data()),
1827  (ideal)(v->Data()), p);
1828  pLmFree(&p);
1829  return FALSE;
1830 }
1832 {
1833  res->data=(char *)idDiffOp((ideal)u->Data(),(ideal)v->Data(),FALSE);
1834  return FALSE;
1835 }
1837 {
1838  short *iv=iv2array((intvec *)v->Data(),currRing);
1839  ideal I=(ideal)u->Data();
1840  int d=-1;
1841  int i;
1842  for(i=IDELEMS(I);i>=0;i--) d=si_max(d,(int)p_DegW(I->m[i],iv,currRing));
1843  omFreeSize( (ADDRESS)iv, (rVar(currRing)+1)*sizeof(short) );
1844  res->data = (char *)((long)d);
1845  return FALSE;
1846 }
1848 {
1849  poly p=(poly)u->Data();
1850  if (p!=NULL)
1851  {
1852  short *iv=iv2array((intvec *)v->Data(),currRing);
1853  const long d = p_DegW(p,iv,currRing);
1854  omFreeSize( (ADDRESS)iv, (rVar(currRing)+1)*sizeof(short) );
1855  res->data = (char *)(d);
1856  }
1857  else
1858  res->data=(char *)(long)(-1);
1859  return FALSE;
1860 }
1862 {
1863  int pos=(int)(long)v->Data();
1864  intvec *iv=(intvec*)u->Data();
1865  res->data=(void*)iv->delete_pos(pos-1);
1866  return res->data==NULL;
1867 }
1869 {
1870  int pos=(int)(long)v->Data();
1871  ideal I=(ideal)u->Data();
1872  res->data=(void*)id_Delete_Pos(I,pos-1,currRing);
1873  return res->data==NULL;
1874 }
1876 {
1877  int i=pVar((poly)v->Data());
1878  if (i==0)
1879  {
1880  WerrorS("ringvar expected");
1881  return TRUE;
1882  }
1883  res->data=(char *)pDiff((poly)(u->Data()),i);
1884  return FALSE;
1885 }
1887 {
1888  int i=pVar((poly)v->Data());
1889  if (i==0)
1890  {
1891  WerrorS("ringvar expected");
1892  return TRUE;
1893  }
1894  res->data=(char *)idDiff((matrix)(u->Data()),i);
1895  return FALSE;
1896 }
1898 {
1899  res->data=(char *)idDiffOp((ideal)u->Data(),(ideal)v->Data());
1900  return FALSE;
1901 }
1903 {
1904  assumeStdFlag(v);
1906  {
1907  Warn("dim(%s,...) may be wrong because the mixed monomial ordering",v->Name());
1908  }
1909 #ifdef HAVE_RINGS
1910  if (rField_is_Ring(currRing))
1911  {
1912  ideal vid = (ideal)v->Data();
1913  int i = idPosConstant(vid);
1914  if ((i != -1) && (n_IsUnit(pGetCoeff(vid->m[i]),currRing->cf)))
1915  { /* ideal v contains unit; dim = -1 */
1916  res->data = (char *)-1;
1917  return FALSE;
1918  }
1919  ideal vv = id_Copy(vid, currRing);
1920  ideal ww = id_Copy((ideal)w->Data(), currRing);
1921  /* drop degree zero generator from vv (if any) */
1922  if (i != -1) pDelete(&vv->m[i]);
1923  long d = (long)scDimInt(vv, ww);
1924  if (rField_is_Z(currRing) && (i == -1)) d++;
1925  res->data = (char *)d;
1926  idDelete(&vv); idDelete(&ww);
1927  return FALSE;
1928  }
1929 #endif
1930  if(currRing->qideal==NULL)
1931  res->data = (char *)((long)scDimInt((ideal)(v->Data()),(ideal)w->Data()));
1932  else
1933  {
1934  ideal q=idSimpleAdd(currRing->qideal,(ideal)w->Data());
1935  res->data = (char *)((long)scDimInt((ideal)(v->Data()),q));
1936  idDelete(&q);
1937  }
1938  return FALSE;
1939 }
1941 {
1942  ideal vi=(ideal)v->Data();
1943  int vl= IDELEMS(vi);
1944  ideal ui=(ideal)u->Data();
1945  unsigned ul= IDELEMS(ui);
1946  ideal R; matrix U;
1947  ideal m = idLift(vi,ui,&R, FALSE,hasFlag(v,FLAG_STD),TRUE,&U);
1948  if (m==NULL) return TRUE;
1949  // now make sure that all matrices have the corect size:
1951  int i;
1952  if (MATCOLS(U) != (int)ul)
1953  {
1954  unsigned mul=si_min(ul,MATCOLS(U));
1955  matrix UU=mpNew(ul,ul);
1956  unsigned j;
1957  for(i=mul;i>0;i--)
1958  {
1959  for(j=mul;j>0;j--)
1960  {
1961  MATELEM(UU,i,j)=MATELEM(U,i,j);
1962  MATELEM(U,i,j)=NULL;
1963  }
1964  }
1965  idDelete((ideal *)&U);
1966  U=UU;
1967  }
1968  // make sure that U is a diagonal matrix of units
1969  for(i=ul;i>0;i--)
1970  {
1971  if(MATELEM(U,i,i)==NULL) MATELEM(U,i,i)=pOne();
1972  }
1974  L->Init(3);
1975  L->m[0].rtyp=MATRIX_CMD; L->m[0].data=(void *)T;
1976  L->m[1].rtyp=u->Typ(); L->m[1].data=(void *)R;
1977  L->m[2].rtyp=MATRIX_CMD; L->m[2].data=(void *)U;
1978  res->data=(char *)L;
1979  return FALSE;
1980 }
1982 {
1983  res->data=(char *)idElimination((ideal)u->Data(),(poly)v->Data());
1984  //setFlag(res,FLAG_STD);
1985  return v->next!=NULL; //do not allow next like in eliminate(I,a(1..4))
1986 }
1988 {
1989  poly p=pOne();
1990  intvec *iv=(intvec*)v->Data();
1991  for(int i=iv->length()-1; i>=0; i--)
1992  {
1993  pSetExp(p,(*iv)[i],1);
1994  }
1995  pSetm(p);
1996  res->data=(char *)idElimination((ideal)u->Data(),p);
1997  pLmDelete(&p);
1998  //setFlag(res,FLAG_STD);
1999  return FALSE;
2000 }
2002 {
2003  //Print("exportto %s -> %s\n",v->Name(),u->Name() );
2004  return iiExport(v,0,IDPACKAGE((idhdl)u->data));
2005 }
2007 {
2008  WerrorS((char *)u->Data());
2009  extern int inerror;
2010  inerror=3;
2011  return TRUE;
2012 }
2014 {
2015  number uu=(number)u->Data();number vv=(number)v->Data();
2017  number a,b;
2018  number p0=n_ExtGcd(uu,vv,&a,&b,coeffs_BIGINT);
2019  L->Init(3);
2020  L->m[0].rtyp=BIGINT_CMD; L->m[0].data=(void *)p0;
2021  L->m[1].rtyp=BIGINT_CMD; L->m[1].data=(void *)a;
2022  L->m[2].rtyp=BIGINT_CMD; L->m[2].data=(void *)b;
2023  res->rtyp=LIST_CMD;
2024  res->data=(char *)L;
2025  return FALSE;
2026 }
2028 {
2029  int uu=(int)(long)u->Data();int vv=(int)(long)v->Data();
2030  int p0=ABS(uu),p1=ABS(vv);
2031  int f0 = 1, f1 = 0, g0 = 0, g1 = 1, q, r;
2032 
2033  while ( p1!=0 )
2034  {
2035  q=p0 / p1;
2036  r=p0 % p1;
2037  p0 = p1; p1 = r;
2038  r = g0 - g1 * q;
2039  g0 = g1; g1 = r;
2040  r = f0 - f1 * q;
2041  f0 = f1; f1 = r;
2042  }
2043  int a = f0;
2044  int b = g0;
2045  if ( uu /*(int)(long)u->Data()*/ < 0 ) a=-a;
2046  if ( vv /*(int)(long)v->Data()*/ < 0 ) b=-b;
2048  L->Init(3);
2049  L->m[0].rtyp=INT_CMD; L->m[0].data=(void *)(long)p0;
2050  L->m[1].rtyp=INT_CMD; L->m[1].data=(void *)(long)a;
2051  L->m[2].rtyp=INT_CMD; L->m[2].data=(void *)(long)b;
2052  res->rtyp=LIST_CMD;
2053  res->data=(char *)L;
2054  return FALSE;
2055 }
2057 {
2058  poly r,pa,pb;
2059  BOOLEAN ret=singclap_extgcd((poly)u->Data(),(poly)v->Data(),r,pa,pb,currRing);
2060  if (ret) return TRUE;
2062  L->Init(3);
2063  res->data=(char *)L;
2064  L->m[0].data=(void *)r;
2065  L->m[0].rtyp=POLY_CMD;
2066  L->m[1].data=(void *)pa;
2067  L->m[1].rtyp=POLY_CMD;
2068  L->m[2].data=(void *)pb;
2069  L->m[2].rtyp=POLY_CMD;
2070  return FALSE;
2071 }
2072 extern int singclap_factorize_retry;
2074 {
2075  intvec *v=NULL;
2076  int sw=(int)(long)dummy->Data();
2077  int fac_sw=sw;
2078  if ((sw<0)||(sw>2)) fac_sw=1;
2080  ideal f=singclap_factorize((poly)(u->CopyD()), &v, fac_sw,currRing);
2081  if (f==NULL)
2082  return TRUE;
2083  switch(sw)
2084  {
2085  case 0:
2086  case 2:
2087  {
2089  l->Init(2);
2090  l->m[0].rtyp=IDEAL_CMD;
2091  l->m[0].data=(void *)f;
2092  l->m[1].rtyp=INTVEC_CMD;
2093  l->m[1].data=(void *)v;
2094  res->data=(void *)l;
2095  res->rtyp=LIST_CMD;
2096  return FALSE;
2097  }
2098  case 1:
2099  res->data=(void *)f;
2100  return FALSE;
2101  case 3:
2102  {
2103  poly p=f->m[0];
2104  int i=IDELEMS(f);
2105  f->m[0]=NULL;
2106  while(i>1)
2107  {
2108  i--;
2109  p=pMult(p,f->m[i]);
2110  f->m[i]=NULL;
2111  }
2112  res->data=(void *)p;
2113  res->rtyp=POLY_CMD;
2114  }
2115  return FALSE;
2116  }
2117  WerrorS("invalid switch");
2118  return TRUE;
2119 }
2121 {
2122  ideal_list p,h;
2123  h=kStdfac((ideal)v->Data(),NULL,testHomog,NULL,(ideal)w->Data());
2124  p=h;
2125  int l=0;
2126  while (p!=NULL) { p=p->next;l++; }
2128  L->Init(l);
2129  l=0;
2130  while(h!=NULL)
2131  {
2132  L->m[l].data=(char *)h->d;
2133  L->m[l].rtyp=IDEAL_CMD;
2134  p=h->next;
2135  omFreeSize(h,sizeof(*h));
2136  h=p;
2137  l++;
2138  }
2139  res->data=(void *)L;
2140  return FALSE;
2141 }
2143 {
2144  if (rField_is_Q(currRing))
2145  {
2146  number uu=(number)u->Data();
2147  number vv=(number)v->Data();
2148  res->data=(char *)n_Farey(uu,vv,currRing->cf);
2149  return FALSE;
2150  }
2151  else return TRUE;
2152 }
2154 {
2155  ideal uu=(ideal)u->Data();
2156  number vv=(number)v->Data();
2157  //timespec buf1,buf2;
2158  //clock_gettime(CLOCK_THREAD_CPUTIME_ID,&buf1);
2159  res->data=(void*)id_Farey(uu,vv,currRing);
2160  //clock_gettime(CLOCK_THREAD_CPUTIME_ID,&buf2);
2161  //const unsigned long SEC = 1000L*1000L*1000L;
2162  //all_farey+=((buf2.tv_sec-buf1.tv_sec)*SEC+
2163  // buf2.tv_nsec-buf1.tv_nsec);
2164  //farey_cnt++;
2165  return FALSE;
2166 }
2167 static BOOLEAN jjFAREY_LI(leftv res, leftv u, leftv v);
2169 {
2170  ring r=(ring)u->Data();
2171  idhdl w;
2172  int op=iiOp;
2173  nMapFunc nMap;
2174 
2175  if ((w=r->idroot->get(v->Name(),myynest))!=NULL)
2176  {
2177  int *perm=NULL;
2178  int *par_perm=NULL;
2179  int par_perm_size=0;
2180  BOOLEAN bo;
2181  if ((nMap=n_SetMap(r->cf,currRing->cf))==NULL)
2182  {
2183  // Allow imap/fetch to be make an exception only for:
2184  if (nCoeff_is_Extension(r->cf) && // Q(a..) -> Q(a..) || Q || Zp || Zp(a)
2185  ((n_SetMap(r->cf->extRing->cf,currRing->cf)!=NULL)
2186  || (nCoeff_is_Extension(currRing->cf) && (n_SetMap(r->cf->extRing->cf,currRing->cf->extRing->cf)!=NULL))))
2187  {
2188  par_perm_size=rPar(r);
2189  }
2190  else
2191  {
2192  goto err_fetch;
2193  }
2194  }
2195  if ((iiOp!=FETCH_CMD) || (r->N!=currRing->N) || (rPar(r)!=rPar(currRing)))
2196  {
2197  perm=(int *)omAlloc0((r->N+1)*sizeof(int));
2198  if (par_perm_size!=0)
2199  par_perm=(int *)omAlloc0(par_perm_size*sizeof(int));
2200  op=IMAP_CMD;
2201  if (iiOp==IMAP_CMD)
2202  {
2203  int r_par=0;
2204  char ** r_par_names=NULL;
2205  if (r->cf->extRing!=NULL)
2206  {
2207  r_par=r->cf->extRing->N;
2208  r_par_names=r->cf->extRing->names;
2209  }
2210  int c_par=0;
2211  char ** c_par_names=NULL;
2212  if (currRing->cf->extRing!=NULL)
2213  {
2214  c_par=currRing->cf->extRing->N;
2215  c_par_names=currRing->cf->extRing->names;
2216  }
2217  maFindPerm(r->names, r->N, r_par_names, r_par,
2218  currRing->names,currRing->N,c_par_names, c_par,
2219  perm,par_perm, currRing->cf->type);
2220  }
2221  else
2222  {
2223  unsigned i;
2224  if (par_perm_size!=0)
2225  for(i=si_min(rPar(r),rPar(currRing));i>0;i--) par_perm[i-1]=-i;
2226  for(i=si_min(r->N,currRing->N);i>0;i--) perm[i]=i;
2227  }
2228  }
2229  if ((iiOp==FETCH_CMD) &&(BVERBOSE(V_IMAP)))
2230  {
2231  unsigned i;
2232  for(i=0;i<(unsigned)si_min(r->N,currRing->N);i++)
2233  {
2234  Print("// var nr %d: %s -> %s\n",i,r->names[i],currRing->names[i]);
2235  }
2236  for(i=0;i<(unsigned)si_min(rPar(r),rPar(currRing));i++) // possibly empty loop
2237  {
2238  Print("// par nr %d: %s -> %s\n",
2239  i,rParameter(r)[i],rParameter(currRing)[i]);
2240  }
2241  }
2242  if (IDTYP(w)==ALIAS_CMD) w=(idhdl)IDDATA(w);
2243  sleftv tmpW;
2244  memset(&tmpW,0,sizeof(sleftv));
2245  tmpW.rtyp=IDTYP(w);
2246  tmpW.data=IDDATA(w);
2247  if ((bo=maApplyFetch(op,NULL,res,&tmpW, r,
2248  perm,par_perm,par_perm_size,nMap)))
2249  {
2250  Werror("cannot map %s of type %s(%d)",v->name, Tok2Cmdname(w->typ),w->typ);
2251  }
2252  if (perm!=NULL)
2253  omFreeSize((ADDRESS)perm,(r->N+1)*sizeof(int));
2254  if (par_perm!=NULL)
2255  omFreeSize((ADDRESS)par_perm,par_perm_size*sizeof(int));
2256  return bo;
2257  }
2258  else
2259  {
2260  Werror("identifier %s not found in %s",v->Fullname(),u->Fullname());
2261  }
2262  return TRUE;
2263 err_fetch:
2264  char *s1=nCoeffString(r->cf);
2265  char *s2=nCoeffString(currRing->cf);
2266  Werror("no identity map from %s (%s -> %s)",u->Fullname(),s1,s2);
2267  omFree(s2); omFree(s1);
2268  return TRUE;
2269 }
2271 {
2272  /*4
2273  * look for the substring what in the string where
2274  * return the position of the first char of what in where
2275  * or 0
2276  */
2277  char *where=(char *)u->Data();
2278  char *what=(char *)v->Data();
2279  char *found = strstr(where,what);
2280  if (found != NULL)
2281  {
2282  res->data=(char *)((found-where)+1);
2283  }
2284  /*else res->data=NULL;*/
2285  return FALSE;
2286 }
2287 
2289 {
2290  assumeStdFlag(u);
2291  ideal id = (ideal)u->Data();
2292  int max_length = (int)(long)v->Data();
2293  if (max_length < 0) {
2294  WerrorS("length for fres must not be negative");
2295  return TRUE;
2296  }
2297  if (max_length == 0) {
2298  max_length = currRing->N+1;
2299  if (currRing->qideal != NULL) {
2300  Warn("full resolution in a qring may be infinite, "
2301  "setting max length to %d", max_length);
2302  }
2303  }
2304  char *method = (char *)w->Data();
2305  /* For the moment, only "complete" (default), "frame", or "extended frame"
2306  * are allowed. Another useful option would be "linear strand".
2307  */
2308  if (strcmp(method, "complete") != 0
2309  && strcmp(method, "frame") != 0
2310  && strcmp(method, "extended frame") != 0
2311  && strcmp(method, "single module") != 0) {
2312  WerrorS("wrong optional argument for fres");
2313  }
2314  syStrategy r = syFrank(id, max_length, method);
2315  assume(r->fullres != NULL);
2316  res->data = (void *)r;
2317  return FALSE;
2318 }
2319 
2321 {
2322  leftv w = (leftv)omAlloc0(sizeof(sleftv));
2323  w->rtyp = STRING_CMD;
2324  w->data = (char *)"complete"; // default
2325  BOOLEAN RES = jjFRES3(res, u, v, w);
2326  omFree(w);
2327  return RES;
2328 }
2329 
2331 {
2332  res->data=(char *)fractalWalkProc(u,v);
2333  setFlag( res, FLAG_STD );
2334  return FALSE;
2335 }
2337 {
2338  int uu=(int)(long)u->Data();int vv=(int)(long)v->Data();
2339  int p0=ABS(uu),p1=ABS(vv);
2340  int r;
2341  while ( p1!=0 )
2342  {
2343  r=p0 % p1;
2344  p0 = p1; p1 = r;
2345  }
2346  res->rtyp=INT_CMD;
2347  res->data=(char *)(long)p0;
2348  return FALSE;
2349 }
2351 {
2352  number n1 = (number) u->Data();
2353  number n2 = (number) v->Data();
2354  res->data = n_Gcd(n1,n2,coeffs_BIGINT);
2355  return FALSE;
2356 }
2358 {
2359  number a=(number) u->Data();
2360  number b=(number) v->Data();
2361  if (nIsZero(a))
2362  {
2363  if (nIsZero(b)) res->data=(char *)nInit(1);
2364  else res->data=(char *)nCopy(b);
2365  }
2366  else
2367  {
2368  if (nIsZero(b)) res->data=(char *)nCopy(a);
2369  //else res->data=(char *)n_Gcd(a, b, currRing->cf);
2370  else res->data=(char *)n_SubringGcd(a, b, currRing->cf);
2371  }
2372  return FALSE;
2373 }
2375 {
2376  res->data=(void *)singclap_gcd((poly)(u->CopyD(POLY_CMD)),
2377  (poly)(v->CopyD(POLY_CMD)),currRing);
2378  return FALSE;
2379 }
2381 {
2382 #ifdef HAVE_RINGS
2383  if (rField_is_Z(currRing))
2384  {
2385  PrintS("// NOTE: computation of Hilbert series etc. is being\n");
2386  PrintS("// performed for generic fibre, that is, over Q\n");
2387  }
2388 #endif
2389  assumeStdFlag(u);
2390  intvec *module_w=(intvec*)atGet(u,"isHomog",INTVEC_CMD);
2391  intvec *iv=hFirstSeries((ideal)u->Data(),module_w,currRing->qideal);
2392  if (errorreported) return TRUE;
2393 
2394  switch((int)(long)v->Data())
2395  {
2396  case 1:
2397  res->data=(void *)iv;
2398  return FALSE;
2399  case 2:
2400  res->data=(void *)hSecondSeries(iv);
2401  delete iv;
2402  return FALSE;
2403  }
2404  delete iv;
2406  return TRUE;
2407 }
2409 {
2410  int i=pVar((poly)v->Data());
2411  if (i==0)
2412  {
2413  WerrorS("ringvar expected");
2414  return TRUE;
2415  }
2416  poly p=pOne(); pSetExp(p,i,1); pSetm(p);
2417  int d=pWTotaldegree(p);
2418  pLmDelete(p);
2419  if (d==1)
2420  res->data = (char *)p_Homogen((poly)u->Data(), i, currRing);
2421  else
2422  WerrorS("variable must have weight 1");
2423  return (d!=1);
2424 }
2426 {
2427  int i=pVar((poly)v->Data());
2428  if (i==0)
2429  {
2430  WerrorS("ringvar expected");
2431  return TRUE;
2432  }
2433  pFDegProc deg;
2434  if (currRing->pLexOrder && (currRing->order[0]==ringorder_lp))
2435  deg=p_Totaldegree;
2436  else
2437  deg=currRing->pFDeg;
2438  poly p=pOne(); pSetExp(p,i,1); pSetm(p);
2439  int d=deg(p,currRing);
2440  pLmDelete(p);
2441  if (d==1)
2442  res->data = (char *)id_Homogen((ideal)u->Data(), i, currRing);
2443  else
2444  WerrorS("variable must have weight 1");
2445  return (d!=1);
2446 }
2448 {
2449  intvec *w=new intvec(rVar(currRing));
2450  intvec *vw=(intvec*)u->Data();
2451  ideal v_id=(ideal)v->Data();
2452  pFDegProc save_FDeg=currRing->pFDeg;
2453  pLDegProc save_LDeg=currRing->pLDeg;
2454  BOOLEAN save_pLexOrder=currRing->pLexOrder;
2455  currRing->pLexOrder=FALSE;
2456  kHomW=vw;
2457  kModW=w;
2459  res->data=(void *)(long)idHomModule(v_id,currRing->qideal,&w);
2460  currRing->pLexOrder=save_pLexOrder;
2461  kHomW=NULL;
2462  kModW=NULL;
2463  pRestoreDegProcs(currRing,save_FDeg,save_LDeg);
2464  if (w!=NULL) delete w;
2465  return FALSE;
2466 }
2468 {
2469  assumeStdFlag(u);
2470  res->data=(void *)scIndIndset((ideal)(u->Data()),(int)(long)(v->Data()),
2471  currRing->qideal);
2472  return FALSE;
2473 }
2475 {
2476  res->data=(char *)idSect((ideal)u->Data(),(ideal)v->Data());
2478  return FALSE;
2479 }
2481 {
2482  const lists L = (lists)l->Data();
2483  const int n = L->nr; assume (n >= 0);
2484  std::vector<ideal> V(n + 1);
2485 
2486  for(int i = n; i >= 0; i--) V[i] = (ideal)(L->m[i].Data());
2487 
2488  res->data=interpolation(V, (intvec*)v->Data());
2489  setFlag(res,FLAG_STD);
2490  return errorreported;
2491 }
2493 {
2494  extern BOOLEAN jjStdJanetBasis(leftv res, leftv v,int flag);
2495  return jjStdJanetBasis(res,u,(int)(long)v->Data());
2496 }
2497 
2499 {
2500  extern BOOLEAN jjStdJanetBasis(leftv res, leftv v,int flag);
2501  return jjStdJanetBasis(res,v,0);
2502 }
2504 {
2505  res->data = (char *)pJet((poly)u->CopyD(), (int)(long)v->Data());
2506  return FALSE;
2507 }
2509 {
2510  res->data = (char *)id_Jet((ideal)u->Data(),(int)(long)v->Data(),currRing);
2511  return FALSE;
2512 }
2514 {
2515  assumeStdFlag(u);
2516  intvec *w_u=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
2517  res->data = (char *)scKBase((int)(long)v->Data(),
2518  (ideal)(u->Data()),currRing->qideal, w_u);
2519  if (w_u!=NULL)
2520  {
2521  atSet(res,omStrDup("isHomog"),ivCopy(w_u),INTVEC_CMD);
2522  }
2523  return FALSE;
2524 }
2525 static BOOLEAN jjPREIMAGE(leftv res, leftv u, leftv v, leftv w);
2527 {
2528  return jjPREIMAGE(res,u,v,NULL);
2529 }
2531 {
2532  return mpKoszul(res, u,v,NULL);
2533 }
2535 {
2536  sleftv h;
2537  memset(&h,0,sizeof(sleftv));
2538  h.rtyp=INT_CMD;
2539  h.data=(void *)(long)IDELEMS((ideal)v->Data());
2540  return mpKoszul(res, u, &h, v);
2541 }
2543 {
2544  int ul= IDELEMS((ideal)u->Data());
2545  int vl= IDELEMS((ideal)v->Data());
2546  ideal m = idLift((ideal)u->Data(),(ideal)v->Data(),NULL,FALSE,
2547  hasFlag(u,FLAG_STD));
2548  if (m==NULL) return TRUE;
2549  res->data = (char *)id_Module2formatedMatrix(m,ul,vl,currRing);
2550  return FALSE;
2551 }
2553 {
2554  if ((v->rtyp!=IDHDL)||(v->e!=NULL)) return TRUE;
2555  idhdl h=(idhdl)v->data;
2556  // CopyD for IDEAL_CMD and MODUL_CMD are identical:
2557  res->data = (char *)idLiftStd((ideal)u->Data(),
2558  &(h->data.umatrix),testHomog);
2559  setFlag(res,FLAG_STD); v->flag=0;
2560  return FALSE;
2561 }
2562 static BOOLEAN jjLOAD2(leftv /*res*/, leftv/* LIB */ , leftv v)
2563 {
2564  return jjLOAD((char*)v->Data(),TRUE);
2565 }
2566 static BOOLEAN jjLOAD_E(leftv /*res*/, leftv v, leftv u)
2567 {
2568  char * s=(char *)u->Data();
2569  if(strcmp(s, "with")==0)
2570  return jjLOAD((char*)v->Data(), TRUE);
2571  if (strcmp(s,"try")==0)
2572  return jjLOAD_TRY((char*)v->Data());
2573  WerrorS("invalid second argument");
2574  WerrorS("load(\"libname\" [,option]);");
2575  return TRUE;
2576 }
2578 {
2579  intvec *w_u=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
2580  tHomog hom=testHomog;
2581  if (w_u!=NULL)
2582  {
2583  w_u=ivCopy(w_u);
2584  hom=isHomog;
2585  }
2586  intvec *w_v=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
2587  if (w_v!=NULL)
2588  {
2589  w_v=ivCopy(w_v);
2590  hom=isHomog;
2591  }
2592  if ((w_u!=NULL) && (w_v==NULL))
2593  w_v=ivCopy(w_u);
2594  if ((w_v!=NULL) && (w_u==NULL))
2595  w_u=ivCopy(w_v);
2596  ideal u_id=(ideal)u->Data();
2597  ideal v_id=(ideal)v->Data();
2598  if (w_u!=NULL)
2599  {
2600  if ((*w_u).compare((w_v))!=0)
2601  {
2602  WarnS("incompatible weights");
2603  delete w_u; w_u=NULL;
2604  hom=testHomog;
2605  }
2606  else
2607  {
2608  if ((!idTestHomModule(u_id,currRing->qideal,w_v))
2609  || (!idTestHomModule(v_id,currRing->qideal,w_v)))
2610  {
2611  WarnS("wrong weights");
2612  delete w_u; w_u=NULL;
2613  hom=testHomog;
2614  }
2615  }
2616  }
2617  res->data = (char *)idModulo(u_id,v_id ,hom,&w_u);
2618  if (w_u!=NULL)
2619  {
2620  atSet(res,omStrDup("isHomog"),w_u,INTVEC_CMD);
2621  }
2622  delete w_v;
2623  //if (TEST_OPT_RETURN_SB) setFlag(res,FLAG_STD);
2624  return FALSE;
2625 }
2627 {
2628  number q=(number)v->Data();
2629  if (n_IsZero(q,coeffs_BIGINT))
2630  {
2632  return TRUE;
2633  }
2634  res->data =(char *) n_IntMod((number)u->Data(),q,coeffs_BIGINT);
2635  return FALSE;
2636 }
2638 {
2639  number q=(number)v->Data();
2640  if (nIsZero(q))
2641  {
2643  return TRUE;
2644  }
2645  res->data =(char *) n_IntMod((number)u->Data(),q,currRing->cf);
2646  return FALSE;
2647 }
2649 {
2650  poly q=(poly)v->Data();
2651  if (q==NULL)
2652  {
2654  return TRUE;
2655  }
2656  poly p=(poly)(u->Data());
2657  if (p==NULL)
2658  {
2659  res->data=NULL;
2660  return FALSE;
2661  }
2662  res->data=(void*)(singclap_pmod(p /*(poly)(u->Data())*/ ,
2663  q /*(poly)(v->Data())*/ ,currRing));
2664  return FALSE;
2665 }
2666 static BOOLEAN jjMONITOR2(leftv res, leftv u,leftv v);
2668 {
2669  return jjMONITOR2(res,v,NULL);
2670 }
2672 {
2673 #if 0
2674  char *opt=(char *)v->Data();
2675  int mode=0;
2676  while(*opt!='\0')
2677  {
2678  if (*opt=='i') mode |= SI_PROT_I;
2679  else if (*opt=='o') mode |= SI_PROT_O;
2680  opt++;
2681  }
2682  monitor((char *)(u->Data()),mode);
2683 #else
2684  si_link l=(si_link)u->Data();
2685  if (slOpen(l,SI_LINK_WRITE,u)) return TRUE;
2686  if(strcmp(l->m->type,"ASCII")!=0)
2687  {
2688  Werror("ASCII link required, not `%s`",l->m->type);
2689  slClose(l);
2690  return TRUE;
2691  }
2692  SI_LINK_SET_CLOSE_P(l); // febase handles the FILE*
2693  if ( l->name[0]!='\0') // "" is the stop condition
2694  {
2695  const char *opt;
2696  int mode=0;
2697  if (v==NULL) opt=(const char*)"i";
2698  else opt=(const char *)v->Data();
2699  while(*opt!='\0')
2700  {
2701  if (*opt=='i') mode |= SI_PROT_I;
2702  else if (*opt=='o') mode |= SI_PROT_O;
2703  opt++;
2704  }
2705  monitor((FILE *)l->data,mode);
2706  }
2707  else
2708  monitor(NULL,0);
2709  return FALSE;
2710 #endif
2711 }
2713 {
2714  intvec *iv=(intvec *)v->Data();
2715  poly p=pOne();
2716  int e;
2717  BOOLEAN err=FALSE;
2718  for(unsigned i=si_min(currRing->N,iv->length()); i>0; i--)
2719  {
2720  e=(*iv)[i-1];
2721  if (e>=0) pSetExp(p,i,e);
2722  else err=TRUE;
2723  }
2724  if (iv->length()==(currRing->N+1))
2725  {
2726  res->rtyp=VECTOR_CMD;
2727  e=(*iv)[currRing->N];
2728  if (e>=0) pSetComp(p,e);
2729  else err=TRUE;
2730  }
2731  pSetm(p);
2732  res->data=(char*)p;
2733  if(err) { pDelete(&p); WerrorS("no negative exponent allowed"); }
2734  return err;
2735 }
2737 {
2738  // u: the name of the new type
2739  // v: the elements
2740  const char *s=(const char *)u->Data();
2741  newstruct_desc d=NULL;
2742  if (strlen(s)>=2)
2743  {
2744  d=newstructFromString((const char *)v->Data());
2745  if (d!=NULL) newstruct_setup(s,d);
2746  }
2747  else WerrorS("name of newstruct must be longer than 1 character");
2748  return d==NULL;
2749 }
2751 {
2752  idhdl h=(idhdl)u->data;
2753  int i=(int)(long)v->Data();
2754  int p=0;
2755  if ((0<i)
2756  && (rParameter(IDRING(h))!=NULL)
2757  && (i<=(p=rPar(IDRING(h)))))
2758  res->data=omStrDup(rParameter(IDRING(h))[i-1]);
2759  else
2760  {
2761  Werror("par number %d out of range 1..%d",i,p);
2762  return TRUE;
2763  }
2764  return FALSE;
2765 }
2766 #ifdef HAVE_PLURAL
2768 {
2769  if( currRing->qideal != NULL )
2770  {
2771  WerrorS("basering must NOT be a qring!");
2772  return TRUE;
2773  }
2774 
2775  if (iiOp==NCALGEBRA_CMD)
2776  {
2777  return nc_CallPlural(NULL,NULL,(poly)a->Data(),(poly)b->Data(),currRing,false,true,false,currRing);
2778  }
2779  else
2780  {
2781  ring r=rCopy(currRing);
2782  BOOLEAN result=nc_CallPlural(NULL,NULL,(poly)a->Data(),(poly)b->Data(),r,false,true,false,currRing);
2783  res->data=r;
2784  return result;
2785  }
2786 }
2788 {
2789  if( currRing->qideal != NULL )
2790  {
2791  WerrorS("basering must NOT be a qring!");
2792  return TRUE;
2793  }
2794 
2795  if (iiOp==NCALGEBRA_CMD)
2796  {
2797  return nc_CallPlural(NULL,(matrix)b->Data(),(poly)a->Data(),NULL,currRing,false,true,false,currRing);
2798  }
2799  else
2800  {
2801  ring r=rCopy(currRing);
2802  BOOLEAN result=nc_CallPlural(NULL,(matrix)b->Data(),(poly)a->Data(),NULL,r,false,true,false,currRing);
2803  res->data=r;
2804  return result;
2805  }
2806 }
2808 {
2809  if( currRing->qideal != NULL )
2810  {
2811  WerrorS("basering must NOT be a qring!");
2812  return TRUE;
2813  }
2814 
2815  if (iiOp==NCALGEBRA_CMD)
2816  {
2817  return nc_CallPlural((matrix)a->Data(),NULL,NULL,(poly)b->Data(),currRing,false,true,false,currRing);
2818  }
2819  else
2820  {
2821  ring r=rCopy(currRing);
2822  BOOLEAN result=nc_CallPlural((matrix)a->Data(),NULL,NULL,(poly)b->Data(),r,false,true,false,currRing);
2823  res->data=r;
2824  return result;
2825  }
2826 }
2828 {
2829  if( currRing->qideal != NULL )
2830  {
2831  WerrorS("basering must NOT be a qring!");
2832  return TRUE;
2833  }
2834 
2835  if (iiOp==NCALGEBRA_CMD)
2836  {
2837  return nc_CallPlural((matrix)a->Data(),(matrix)b->Data(),NULL,NULL,currRing,false,true,false,currRing);
2838  }
2839  else
2840  {
2841  ring r=rCopy(currRing);
2842  BOOLEAN result=nc_CallPlural((matrix)a->Data(),(matrix)b->Data(),NULL,NULL,r,false,true,false,currRing);
2843  res->data=r;
2844  return result;
2845  }
2846 }
2848 {
2849  res->data=NULL;
2850 
2851  if (rIsPluralRing(currRing))
2852  {
2853  const poly q = (poly)b->Data();
2854 
2855  if( q != NULL )
2856  {
2857  if( (poly)a->Data() != NULL )
2858  {
2859  poly p = (poly)a->CopyD(POLY_CMD); // p = copy!
2860  res->data = nc_p_Bracket_qq(p,q, currRing); // p will be destroyed!
2861  }
2862  }
2863  }
2864  return FALSE;
2865 }
2867 {
2868  /* number, poly, vector, ideal, module, matrix */
2869  ring r = (ring)a->Data();
2870  if (r == currRing)
2871  {
2872  res->data = b->Data();
2873  res->rtyp = b->rtyp;
2874  return FALSE;
2875  }
2876  if (!rIsLikeOpposite(currRing, r))
2877  {
2878  Werror("%s is not an opposite ring to current ring",a->Fullname());
2879  return TRUE;
2880  }
2881  idhdl w;
2882  if( ((w=r->idroot->get(b->Name(),myynest))!=NULL) && (b->e==NULL))
2883  {
2884  int argtype = IDTYP(w);
2885  switch (argtype)
2886  {
2887  case NUMBER_CMD:
2888  {
2889  /* since basefields are equal, we can apply nCopy */
2890  res->data = nCopy((number)IDDATA(w));
2891  res->rtyp = argtype;
2892  break;
2893  }
2894  case POLY_CMD:
2895  case VECTOR_CMD:
2896  {
2897  poly q = (poly)IDDATA(w);
2898  res->data = pOppose(r,q,currRing);
2899  res->rtyp = argtype;
2900  break;
2901  }
2902  case IDEAL_CMD:
2903  case MODUL_CMD:
2904  {
2905  ideal Q = (ideal)IDDATA(w);
2906  res->data = idOppose(r,Q,currRing);
2907  res->rtyp = argtype;
2908  break;
2909  }
2910  case MATRIX_CMD:
2911  {
2912  ring save = currRing;
2913  rChangeCurrRing(r);
2914  matrix m = (matrix)IDDATA(w);
2916  rChangeCurrRing(save);
2917  ideal S = idOppose(r,Q,currRing);
2918  id_Delete(&Q, r);
2919  res->data = id_Module2Matrix(S,currRing);
2920  res->rtyp = argtype;
2921  break;
2922  }
2923  default:
2924  {
2925  WerrorS("unsupported type in oppose");
2926  return TRUE;
2927  }
2928  }
2929  }
2930  else
2931  {
2932  Werror("identifier %s not found in %s",b->Fullname(),a->Fullname());
2933  return TRUE;
2934  }
2935  return FALSE;
2936 }
2937 #endif /* HAVE_PLURAL */
2938 
2940 {
2941  res->data = (char *)idQuot((ideal)u->Data(),(ideal)v->Data(),
2942  hasFlag(u,FLAG_STD),u->Typ()==v->Typ());
2943  id_DelMultiples((ideal)(res->data),currRing);
2945  return FALSE;
2946 }
2948 {
2949  int i=(int)(long)u->Data();
2950  int j=(int)(long)v->Data();
2951  if (j-i <0) {WerrorS("invalid range for random"); return TRUE;}
2952  res->data =(char *)(long)((i > j) ? i : (siRand() % (j-i+1)) + i);
2953  return FALSE;
2954 }
2956 {
2957  matrix m =(matrix)u->Data();
2958  int isRowEchelon = (int)(long)v->Data();
2959  if (isRowEchelon != 1) isRowEchelon = 0;
2960  int rank = luRank(m, isRowEchelon);
2961  res->data =(char *)(long)rank;
2962  return FALSE;
2963 }
2965 {
2966  si_link l=(si_link)u->Data();
2967  leftv r=slRead(l,v);
2968  if (r==NULL)
2969  {
2970  const char *s;
2971  if ((l!=NULL)&&(l->name!=NULL)) s=l->name;
2972  else s=sNoName_fe;
2973  Werror("cannot read from `%s`",s);
2974  return TRUE;
2975  }
2976  memcpy(res,r,sizeof(sleftv));
2978  return FALSE;
2979 }
2981 {
2982  ideal vi=(ideal)v->Data();
2983  if (currRing->qideal!=NULL || vi->ncols>1 || rIsPluralRing(currRing))
2984  assumeStdFlag(v);
2985  res->data = (char *)kNF(vi,currRing->qideal,(poly)u->Data());
2986  return FALSE;
2987 }
2989 {
2990  ideal ui=(ideal)u->Data();
2991  ideal vi=(ideal)v->Data();
2992  if (currRing->qideal!=NULL || vi->ncols>1 || rIsPluralRing(currRing))
2993  assumeStdFlag(v);
2994  res->data = (char *)kNF(vi,currRing->qideal,ui);
2995  return FALSE;
2996 }
2998 {
2999  int maxl=(int)(long)v->Data();
3000  if (maxl<0)
3001  {
3002  WerrorS("length for res must not be negative");
3003  return TRUE;
3004  }
3005  syStrategy r;
3006  intvec *weights=NULL;
3007  int wmaxl=maxl;
3008  ideal u_id=(ideal)u->Data();
3009 
3010  maxl--;
3011  if (/*(*/ maxl==-1 /*)*/) /*&& (iiOp!=MRES_CMD)*/
3012  {
3013  maxl = currRing->N-1+2*(iiOp==MRES_CMD);
3014  if (currRing->qideal!=NULL)
3015  {
3016  Warn(
3017  "full resolution in a qring may be infinite, setting max length to %d",
3018  maxl+1);
3019  }
3020  }
3021  weights=(intvec*)atGet(u,"isHomog",INTVEC_CMD);
3022  if (weights!=NULL)
3023  {
3024  if (!idTestHomModule(u_id,currRing->qideal,weights))
3025  {
3026  WarnS("wrong weights given:");weights->show();PrintLn();
3027  weights=NULL;
3028  }
3029  }
3030  intvec *ww=NULL;
3031  int add_row_shift=0;
3032  if (weights!=NULL)
3033  {
3034  ww=ivCopy(weights);
3035  add_row_shift = ww->min_in();
3036  (*ww) -= add_row_shift;
3037  }
3038  if ((iiOp == RES_CMD) || (iiOp == MRES_CMD))
3039  {
3040  r=syResolution(u_id,maxl, ww, iiOp==MRES_CMD);
3041  }
3042  else if (iiOp==SRES_CMD)
3043  // r=sySchreyerResolvente(u_id,maxl+1,&l);
3044  r=sySchreyer(u_id,maxl+1);
3045  else if (iiOp == LRES_CMD)
3046  {
3047  int dummy;
3048  if((currRing->qideal!=NULL)||
3049  (!idHomIdeal (u_id,NULL)))
3050  {
3051  WerrorS
3052  ("`lres` not implemented for inhomogeneous input or qring");
3053  return TRUE;
3054  }
3055  if(currRing->N == 1)
3056  WarnS("the current implementation of `lres` may not work in the case of a single variable");
3057  r=syLaScala3(u_id,&dummy);
3058  }
3059  else if (iiOp == KRES_CMD)
3060  {
3061  int dummy;
3062  if((currRing->qideal!=NULL)||
3063  (!idHomIdeal (u_id,NULL)))
3064  {
3065  WerrorS
3066  ("`kres` not implemented for inhomogeneous input or qring");
3067  return TRUE;
3068  }
3069  r=syKosz(u_id,&dummy);
3070  }
3071  else
3072  {
3073  int dummy;
3074  if((currRing->qideal!=NULL)||
3075  (!idHomIdeal (u_id,NULL)))
3076  {
3077  WerrorS
3078  ("`hres` not implemented for inhomogeneous input or qring");
3079  return TRUE;
3080  }
3081  ideal u_id_copy=idCopy(u_id);
3082  idSkipZeroes(u_id_copy);
3083  r=syHilb(u_id_copy,&dummy);
3084  idDelete(&u_id_copy);
3085  }
3086  if (r==NULL) return TRUE;
3087  if (r->list_length>wmaxl)
3088  {
3089  for(int i=wmaxl-1;i>=r->list_length;i--)
3090  {
3091  if (r->fullres[i]!=NULL) id_Delete(&r->fullres[i],currRing);
3092  if (r->minres[i]!=NULL) id_Delete(&r->minres[i],currRing);
3093  }
3094  }
3095  r->list_length=wmaxl;
3096  res->data=(void *)r;
3097  if ((weights!=NULL) && (ww!=NULL)) { delete ww; ww=NULL; }
3098  if ((r->weights!=NULL) && (r->weights[0]!=NULL))
3099  {
3100  ww=ivCopy(r->weights[0]);
3101  if (weights!=NULL) (*ww) += add_row_shift;
3102  atSet(res,omStrDup("isHomog"),ww,INTVEC_CMD);
3103  }
3104  else
3105  {
3106  if (weights!=NULL)
3107  {
3108  atSet(res,omStrDup("isHomog"),ivCopy(weights),INTVEC_CMD);
3109  }
3110  }
3111 
3112  // test the La Scala case' output
3113  assume( ((iiOp == LRES_CMD) || (iiOp == HRES_CMD)) == (r->syRing != NULL) );
3114  assume( (r->syRing != NULL) == (r->resPairs != NULL) );
3115 
3116  if(iiOp != HRES_CMD)
3117  assume( (r->minres != NULL) || (r->fullres != NULL) ); // is wrong for HRES_CMD...
3118  else
3119  assume( (r->orderedRes != NULL) || (r->res != NULL) ); // analog for hres...
3120 
3121  return FALSE;
3122 }
3124 {
3125  number n1; int i;
3126 
3127  if ((u->Typ() == BIGINT_CMD) ||
3128  ((u->Typ() == NUMBER_CMD) && rField_is_Q(currRing)))
3129  {
3130  n1 = (number)u->CopyD();
3131  }
3132  else if (u->Typ() == INT_CMD)
3133  {
3134  i = (int)(long)u->Data();
3135  n1 = n_Init(i, coeffs_BIGINT);
3136  }
3137  else
3138  {
3139  return TRUE;
3140  }
3141 
3142  i = (int)(long)v->Data();
3143 
3144  lists l = primeFactorisation(n1, i);
3145  n_Delete(&n1, coeffs_BIGINT);
3146  res->data = (char*)l;
3147  return FALSE;
3148 }
3150 {
3151  ring r;
3152  int i=rSum((ring)u->Data(),(ring)v->Data(),r);
3153  res->data = (char *)r;
3154  return (i==-1);
3155 }
3156 #define SIMPL_NORMALIZE 64
3157 #define SIMPL_LMDIV 32
3158 #define SIMPL_LMEQ 16
3159 #define SIMPL_MULT 8
3160 #define SIMPL_EQU 4
3161 #define SIMPL_NULL 2
3162 #define SIMPL_NORM 1
3164 {
3165  int sw = (int)(long)v->Data();
3166  // CopyD for IDEAL_CMD and MODUL_CMD are identical:
3167  ideal id = (ideal)u->CopyD(IDEAL_CMD);
3168  if (sw & SIMPL_LMDIV)
3169  {
3170  id_DelDiv(id,currRing);
3171  }
3172  if (sw & SIMPL_LMEQ)
3173  {
3175  }
3176  if (sw & SIMPL_MULT)
3177  {
3179  }
3180  else if(sw & SIMPL_EQU)
3181  {
3182  id_DelEquals(id,currRing);
3183  }
3184  if (sw & SIMPL_NULL)
3185  {
3186  idSkipZeroes(id);
3187  }
3188  if (sw & SIMPL_NORM)
3189  {
3190  id_Norm(id,currRing);
3191  }
3192  if (sw & SIMPL_NORMALIZE)
3193  {
3194  id_Normalize(id,currRing);
3195  }
3196  res->data = (char * )id;
3197  return FALSE;
3198 }
3201 {
3202  intvec *v=NULL;
3203  int sw=(int)(long)dummy->Data();
3204  int fac_sw=sw;
3205  if (sw<0) fac_sw=1;
3207  ideal f=singclap_sqrfree((poly)(u->CopyD()), &v, fac_sw, currRing);
3208  if (f==NULL)
3209  return TRUE;
3210  switch(sw)
3211  {
3212  case 0:
3213  case 2:
3214  {
3216  l->Init(2);
3217  l->m[0].rtyp=IDEAL_CMD;
3218  l->m[0].data=(void *)f;
3219  l->m[1].rtyp=INTVEC_CMD;
3220  l->m[1].data=(void *)v;
3221  res->data=(void *)l;
3222  res->rtyp=LIST_CMD;
3223  return FALSE;
3224  }
3225  case 1:
3226  res->data=(void *)f;
3227  return FALSE;
3228  case 3:
3229  {
3230  poly p=f->m[0];
3231  int i=IDELEMS(f);
3232  f->m[0]=NULL;
3233  while(i>1)
3234  {
3235  i--;
3236  p=pMult(p,f->m[i]);
3237  f->m[i]=NULL;
3238  }
3239  res->data=(void *)p;
3240  res->rtyp=POLY_CMD;
3241  }
3242  return FALSE;
3243  }
3244  WerrorS("invalid switch");
3245  return FALSE;
3246 }
3248 {
3249  res->data = omStrDup(slStatus((si_link) u->Data(), (char *) v->Data()));
3250  return FALSE;
3251 }
3253 {
3254  res->data = (void *)(long)slStatusSsiL((lists) u->Data(), (int)(long) v->Data());
3255  //return (res->data== (void*)(long)-2);
3256  return FALSE;
3257 }
3259 {
3260  int sw = (int)(long)v->Data();
3261  // CopyD for POLY_CMD and VECTOR_CMD are identical:
3262  poly p = (poly)u->CopyD(POLY_CMD);
3263  if (sw & SIMPL_NORM)
3264  {
3265  pNorm(p);
3266  }
3267  if (sw & SIMPL_NORMALIZE)
3268  {
3270  }
3271  res->data = (char * )p;
3272  return FALSE;
3273 }
3275 {
3276  ideal result;
3277  intvec *w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
3278  tHomog hom=testHomog;
3279  ideal u_id=(ideal)(u->Data());
3280  if (w!=NULL)
3281  {
3282  if (!idTestHomModule(u_id,currRing->qideal,w))
3283  {
3284  WarnS("wrong weights:");w->show();PrintLn();
3285  w=NULL;
3286  }
3287  else
3288  {
3289  w=ivCopy(w);
3290  hom=isHomog;
3291  }
3292  }
3293  result=kStd(u_id,currRing->qideal,hom,&w,(intvec *)v->Data());
3295  res->data = (char *)result;
3296  setFlag(res,FLAG_STD);
3297  if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
3298  return FALSE;
3299 }
3301 {
3302  ideal result;
3303  assumeStdFlag(u);
3304  ideal i1=(ideal)(u->Data());
3305  int ii1=idElem(i1); /* size of i1 */
3306  ideal i0;
3307  int r=v->Typ();
3308  if ((/*v->Typ()*/r==POLY_CMD) ||(r==VECTOR_CMD))
3309  {
3310  poly p=(poly)v->Data();
3311  i0=idInit(1,i1->rank);
3312  i0->m[0]=p;
3313  i1=idSimpleAdd(i1,i0); //
3314  memset(i0->m,0,sizeof(poly)*IDELEMS(i0));
3315  idDelete(&i0);
3316  intvec *w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
3317  tHomog hom=testHomog;
3318 
3319  if (w!=NULL)
3320  {
3321  if (!idTestHomModule(i1,currRing->qideal,w))
3322  {
3323  // no warnung: this is legal, if i in std(i,p)
3324  // is homogeneous, but p not
3325  w=NULL;
3326  }
3327  else
3328  {
3329  w=ivCopy(w);
3330  hom=isHomog;
3331  }
3332  }
3333  BITSET save1;
3334  SI_SAVE_OPT1(save1);
3336  /* ii1 appears to be the position of the first element of il that
3337  does not belong to the old SB ideal */
3338  result=kStd(i1,currRing->qideal,hom,&w,NULL,0,ii1);
3339  SI_RESTORE_OPT1(save1);
3340  idDelete(&i1);
3342  if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
3343  res->data = (char *)result;
3344  }
3345  else /*IDEAL/MODULE*/
3346  {
3347  i0=(ideal)v->CopyD();
3348  i1=idSimpleAdd(i1,i0); //
3349  memset(i0->m,0,sizeof(poly)*IDELEMS(i0));
3350  idDelete(&i0);
3351  intvec *w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
3352  tHomog hom=testHomog;
3353 
3354  if (w!=NULL)
3355  {
3356  if (!idTestHomModule(i1,currRing->qideal,w))
3357  {
3358  // no warnung: this is legal, if i in std(i,p)
3359  // is homogeneous, but p not
3360  w=NULL;
3361  hom=isNotHomog;
3362  }
3363  else
3364  {
3365  w=ivCopy(w);
3366  hom=isHomog;
3367  }
3368  }
3369  BITSET save1;
3370  SI_SAVE_OPT1(save1);
3372  /* ii1 appears to be the position of the first element of i1 that
3373  does not belong to the old SB ideal */
3374  result=kStd(i1,currRing->qideal,hom,&w,NULL,0,ii1);
3375  SI_RESTORE_OPT1(save1);
3376  idDelete(&i1);
3378  if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
3379  res->data = (char *)result;
3380  }
3382  return FALSE;
3383 }
3385 {
3386  // see jjSYZYGY
3387  intvec *w=NULL;
3388  ideal I=(ideal)u->Data();
3389  GbVariant alg=syGetAlgorithm((char*)v->Data(),currRing,I);
3390  res->data = (char *)idSyzygies(I,testHomog,&w,TRUE,FALSE,NULL,alg);
3391  if (w!=NULL) delete w;
3393  return FALSE;
3394 }
3396 {
3397  ideal A=(ideal)u->Data();
3398  ideal B=(ideal)v->Data();
3399  res->data = (char *)sm_Tensor(A,B,currRing);
3400  return FALSE;
3401 }
3403 {
3404  sleftv tmp_u,tmp_v,tmp_res;
3408  tmp_res.Init();
3409  tmp_res.rtyp=SMATRIX_CMD;
3410  BOOLEAN bo=jjTENSOR(&tmp_res,&tmp_u,&tmp_v);
3411  if (!bo)
3412  {
3415  }
3416  tmp_u.CleanUp();
3417  tmp_v.CleanUp();
3418  tmp_res.CleanUp();
3419  return bo;
3420 }
3422 {
3423  idhdl h=(idhdl)u->data;
3424  int i=(int)(long)v->Data();
3425  if ((0<i) && (i<=IDRING(h)->N))
3426  res->data=omStrDup(IDRING(h)->names[i-1]);
3427  else
3428  {
3429  Werror("var number %d out of range 1..%d",i,IDRING(h)->N);
3430  return TRUE;
3431  }
3432  return FALSE;
3433 }
3435 {
3436 // input: u: a list with links of type
3437 // ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
3438 // v: timeout for select in milliseconds
3439 // or 0 for polling
3440 // returns: ERROR (via Werror): timeout negative
3441 // -1: the read state of all links is eof
3442 // 0: timeout (or polling): none ready
3443 // i>0: (at least) L[i] is ready
3444  lists Lforks = (lists)u->Data();
3445  int t = (int)(long)v->Data();
3446  if(t < 0)
3447  {
3448  WerrorS("negative timeout"); return TRUE;
3449  }
3450  int i = slStatusSsiL(Lforks, t*1000);
3451  if(i == -2) /* error */
3452  {
3453  return TRUE;
3454  }
3455  res->data = (void*)(long)i;
3456  return FALSE;
3457 }
3459 {
3460 // input: u: a list with links of type
3461 // ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
3462 // v: timeout for select in milliseconds
3463 // or 0 for polling
3464 // returns: ERROR (via Werror): timeout negative
3465 // -1: the read state of all links is eof
3466 // 0: timeout (or polling): none ready
3467 // 1: all links are ready
3468 // (caution: at least one is ready, but some maybe dead)
3469  lists Lforks = (lists)u->CopyD();
3470  int timeout = 1000*(int)(long)v->Data();
3471  if(timeout < 0)
3472  {
3473  WerrorS("negative timeout"); return TRUE;
3474  }
3475  int t = getRTimer()/TIMER_RESOLUTION; // in seconds
3476  int i;
3477  int ret = -1;
3478  for(unsigned nfinished = 0; nfinished < ((unsigned)Lforks->nr)+1; nfinished++)
3479  {
3480  i = slStatusSsiL(Lforks, timeout);
3481  if(i > 0) /* Lforks[i] is ready */
3482  {
3483  ret = 1;
3484  Lforks->m[i-1].CleanUp();
3485  Lforks->m[i-1].rtyp=DEF_CMD;
3486  Lforks->m[i-1].data=NULL;
3487  timeout = si_max(0,timeout - 1000*(getRTimer()/TIMER_RESOLUTION - t));
3488  }
3489  else /* terminate the for loop */
3490  {
3491  if(i == -2) /* error */
3492  {
3493  return TRUE;
3494  }
3495  if(i == 0) /* timeout */
3496  {
3497  ret = 0;
3498  }
3499  break;
3500  }
3501  }
3502  Lforks->Clean();
3503  res->data = (void*)(long)ret;
3504  return FALSE;
3505 }
3507 {
3508  res->data = (char *)mp_Wedge((matrix)u->Data(),(int)(long)v->Data(),currRing);
3509  return FALSE;
3510 }
3511 #define jjWRONG2 (proc2)jjWRONG
3512 #define jjWRONG3 (proc3)jjWRONG
3514 {
3515  return TRUE;
3516 }
3517 
3518 /*=================== operations with 1 arg.: static proc =================*/
3519 /* must be ordered: first operations for chars (infix ops),
3520  * then alphabetically */
3521 
3523 {
3524  res->data = (char *)u->CopyD();
3525  return FALSE;
3526 }
3528 {
3529  return FALSE;
3530 }
3531 //static BOOLEAN jjPLUSPLUS(leftv res, leftv u)
3532 //{
3533 // res->data = (char *)((int)(long)u->Data()+1);
3534 // return FALSE;
3535 //}
3536 //static BOOLEAN jjMINUSMINUS(leftv res, leftv u)
3537 //{
3538 // res->data = (char *)((int)(long)u->Data()-1);
3539 // return FALSE;
3540 //}
3542 {
3543  if (IDTYP((idhdl)u->data)==INT_CMD)
3544  {
3545  int i=IDINT((idhdl)u->data);
3546  if (iiOp==PLUSPLUS) i++;
3547  else i--;
3548  IDDATA((idhdl)u->data)=(char *)(long)i;
3549  return FALSE;
3550  }
3551  return TRUE;
3552 }
3554 {
3555  number n=(number)u->CopyD(BIGINT_CMD);
3556  n=n_InpNeg(n,coeffs_BIGINT);
3557  res->data = (char *)n;
3558  return FALSE;
3559 }
3561 {
3562  res->data = (char *)(-(long)u->Data());
3563  return FALSE;
3564 }
3566 {
3567  number n=(number)u->CopyD(NUMBER_CMD);
3568  n=nInpNeg(n);
3569  res->data = (char *)n;
3570  return FALSE;
3571 }
3573 {
3574  res->data = (char *)pNeg((poly)u->CopyD(POLY_CMD));
3575  return FALSE;
3576 }
3578 {
3579  poly m1=pISet(-1);
3580  res->data = (char *)mp_MultP((matrix)u->CopyD(MATRIX_CMD),m1,currRing);
3581  return FALSE;
3582 }
3584 {
3585  intvec *iv=(intvec *)u->CopyD(INTVEC_CMD);
3586  (*iv)*=(-1);
3587  res->data = (char *)iv;
3588  return FALSE;
3589 }
3591 {
3592  bigintmat *bim=(bigintmat *)u->CopyD(BIGINTMAT_CMD);
3593  (*bim)*=(-1);
3594  res->data = (char *)bim;
3595  return FALSE;
3596 }
3597 // dummy for python_module.so and similiar
3599 {
3600  if (u->rtyp==IDHDL) rSetHdl((idhdl)u->data);
3601  else
3602  {
3603  ring r=(ring)u->Data();
3604  idhdl h=rFindHdl(r,NULL);
3605  if (h==NULL)
3606  {
3607  char name_buffer[100];
3608  static int ending=1000000;
3609  ending++;
3610  sprintf(name_buffer, "PYTHON_RING_VAR%d",ending);
3611  h=enterid(name_buffer,0,RING_CMD,&IDROOT);
3612  IDRING(h)=r;
3613  r->ref++;
3614  }
3615  rSetHdl(h);
3616  }
3617  return FALSE;
3618 }
3620 {
3621  return jjPROC(res,u,NULL);
3622 }
3624 {
3625  //matrix m=(matrix)v->Data();
3626  //lists l=mpBareiss(m,FALSE);
3627  intvec *iv;
3628  ideal m;
3629  sm_CallBareiss((ideal)v->Data(),0,0,m,&iv, currRing);
3631  l->Init(2);
3632  l->m[0].rtyp=MODUL_CMD;
3633  l->m[1].rtyp=INTVEC_CMD;
3634  l->m[0].data=(void *)m;
3635  l->m[1].data=(void *)iv;
3636  res->data = (char *)l;
3637  return FALSE;
3638 }
3639 //static BOOLEAN jjBAREISS_IM(leftv res, leftv v)
3640 //{
3641 // intvec *m=(intvec *)v->CopyD(INTMAT_CMD);
3642 // ivTriangMat(m);
3643 // res->data = (char *)m;
3644 // return FALSE;
3645 //}
3647 {
3648  bigintmat *b=(bigintmat*)v->CopyD(BIGINTMAT_CMD);
3649  b->hnf();
3650  res->data=(char*)b;
3651  return FALSE;
3652 }
3654 {
3655  BOOLEAN bo=FALSE;
3656  number n=(number)u->CopyD();
3658  if (nMap!=NULL)
3659  res->data=nMap(n,coeffs_BIGINT,currRing->cf);
3660  else
3661  {
3662  Werror("cannot convert bigint to cring %s", nCoeffName(currRing->cf));
3663  bo=TRUE;
3664  }
3665  n_Delete(&n,coeffs_BIGINT);
3666  return bo;
3667 }
3669 {
3670  bigintmat *b=(bigintmat*)u->Data();
3671  res->data=(void *)bim2iv(b);
3672  return FALSE;
3673 }
3675 {
3676  sleftv tmp;
3677  BOOLEAN bo=jjBI2N(&tmp,u);
3678  if (!bo)
3679  {
3680  number n=(number) tmp.data;
3681  if (nIsZero(n)) { res->data=NULL;nDelete(&n); }
3682  else
3683  {
3684  res->data=(void *)pNSet(n);
3685  }
3686  }
3687  return bo;
3688 }
3690 {
3691  return iiExprArithM(res,u,iiOp);
3692 }
3694 {
3695  res->data = (char *)(long)rChar((ring)v->Data());
3696  return FALSE;
3697 }
3699 {
3700  res->data = (char *)(long)MATCOLS((matrix)(v->Data()));
3701  return FALSE;
3702 }
3704 {
3705  res->data = (char *)(long)((bigintmat*)(v->Data()))->cols();
3706  return FALSE;
3707 }
3709 {
3710  res->data = (char *)(long)((intvec*)(v->Data()))->cols();
3711  return FALSE;
3712 }
3714 {
3715  // CopyD for POLY_CMD and VECTOR_CMD are identical:
3716  poly p=(poly)v->CopyD(POLY_CMD);
3717  if (p!=NULL) p_Cleardenom(p, currRing);
3718  res->data = (char *)p;
3719  return FALSE;
3720 }
3722 {
3723  res->data = (char *)(long)n_Size((number)v->Data(),coeffs_BIGINT);
3724  return FALSE;
3725 }
3727 {
3728  bigintmat* aa= (bigintmat *)v->Data();
3729  res->data = (char *)(long)(aa->rows()*aa->cols());
3730  return FALSE;
3731 }
3733 {
3734  res->data = (char *)(long)nSize((number)v->Data());
3735  return FALSE;
3736 }
3738 {
3739  lists l=(lists)v->Data();
3740  res->data = (char *)(long)(lSize(l)+1);
3741  return FALSE;
3742 }
3744 {
3745  matrix m=(matrix)v->Data();
3746  res->data = (char *)(long)(MATROWS(m)*MATCOLS(m));
3747  return FALSE;
3748 }
3750 {
3751  res->data = (char *)(long)((intvec*)(v->Data()))->length();
3752  return FALSE;
3753 }
3755 {
3756  ring r=(ring)v->Data();
3757  int elems=-1;
3758  if (rField_is_Zp(r)) elems=r->cf->ch;
3759  else if (rField_is_GF(r)) elems=r->cf->m_nfCharQ;
3760  else if (rField_is_Zp_a(r) && (r->cf->type==n_algExt))
3761  {
3762  extern int ipower ( int b, int n ); /* factory/cf_util */
3763  elems=ipower(r->cf->ch,r->cf->extRing->pFDeg(r->cf->extRing->qideal->m[0],r->cf->extRing));
3764  }
3765  res->data = (char *)(long)elems;
3766  return FALSE;
3767 }
3769 {
3770  int dummy;
3771  poly p=(poly)v->Data();
3772  if (p!=NULL) res->data = (char *)currRing->pLDeg(p,&dummy,currRing);
3773  else res->data=(char *)-1;
3774  return FALSE;
3775 }
3777 {
3778  ideal I=(ideal)u->Data();
3779  int d=-1;
3780  int dummy;
3781  int i;
3782  for(i=IDELEMS(I)-1;i>=0;i--)
3783  if (I->m[i]!=NULL) d=si_max(d,(int)currRing->pLDeg(I->m[i],&dummy,currRing));
3784  res->data = (char *)(long)d;
3785  return FALSE;
3786 }
3788 {
3789  SPrintStart();
3790 #ifdef HAVE_RINGS
3791  if (rField_is_Z(currRing))
3792  {
3793  PrintS("// NOTE: computation of degree is being performed for\n");
3794  PrintS("// generic fibre, that is, over Q\n");
3795  }
3796 #endif
3797  assumeStdFlag(v);
3798  intvec *module_w=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
3799  scDegree((ideal)v->Data(),module_w,currRing->qideal);
3800  char *s=SPrintEnd();
3801  int l=strlen(s)-1;
3802  s[l]='\0';
3803  res->data=(void*)s;
3804  return FALSE;
3805 }
3807 {
3808  if ((v->rtyp==IDHDL)
3809  && ((myynest==IDLEV((idhdl)v->data))||(0==IDLEV((idhdl)v->data))))
3810  {
3811  res->data=(void *)(long)(IDLEV((idhdl)v->data)+1);
3812  }
3813  else if (v->rtyp!=0) res->data=(void *)(-1);
3814  return FALSE;
3815 }
3816 
3817 /// Return the denominator of the input number
3818 /// NOTE: the input number is normalized as a side effect
3820 {
3821  number n = reinterpret_cast<number>(v->Data());
3822  res->data = reinterpret_cast<void*>(n_GetDenom(n, currRing->cf));
3823  return FALSE;
3824 }
3825 
3826 /// Return the numerator of the input number
3827 /// NOTE: the input number is normalized as a side effect
3829 {
3830  number n = reinterpret_cast<number>(v->Data());
3831  res->data = reinterpret_cast<void*>(n_GetNumerator(n, currRing->cf));
3832  return FALSE;
3833 }
3834 
3836 {
3837  matrix m=(matrix)v->Data();
3838  poly p;
3839  if (sm_CheckDet((ideal)m,m->cols(),TRUE, currRing))
3840  {
3842  p=sm_CallDet(I, currRing);
3843  idDelete(&I);
3844  }
3845  else
3847  res ->data = (char *)p;
3848  return FALSE;
3849 }
3851 {
3852  bigintmat * m=(bigintmat*)v->Data();
3853  int i,j;
3854  i=m->rows();j=m->cols();
3855  if(i==j)
3856  res->data = (char *)(long)singclap_det_bi(m,coeffs_BIGINT);
3857  else
3858  {
3859  Werror("det of %d x %d bigintmat",i,j);
3860  return TRUE;
3861  }
3862  return FALSE;
3863 }
3864 #ifdef SINGULAR_4_2
3865 static BOOLEAN jjDET_N2(leftv res, leftv v)
3866 {
3867  bigintmat * m=(bigintmat*)v->Data();
3868  number2 r=(number2)omAlloc0(sizeof(*r));
3869  int i,j;
3870  i=m->rows();j=m->cols();
3871  if(i==j)
3872  {
3873  r->n=m->det();
3874  r->cf=m->basecoeffs();
3875  }
3876  else
3877  {
3878  omFreeSize(r,sizeof(*r));
3879  Werror("det of %d x %d cmatrix",i,j);
3880  return TRUE;
3881  }
3882  res->data=(void*)r;
3883  return FALSE;
3884 }
3885 #endif
3887 {
3888  intvec * m=(intvec*)v->Data();
3889  int i,j;
3890  i=m->rows();j=m->cols();
3891  if(i==j)
3892  res->data = (char *)(long)singclap_det_i(m,currRing);
3893  else
3894  {
3895  Werror("det of %d x %d intmat",i,j);
3896  return TRUE;
3897  }
3898  return FALSE;
3899 }
3901 {
3902  ideal I=(ideal)v->Data();
3903  poly p;
3904  if (IDELEMS(I)<1) return TRUE;
3905  if (sm_CheckDet(I,IDELEMS(I),FALSE, currRing))
3906  {
3909  idDelete((ideal *)&m);
3910  }
3911  else
3912  p=sm_CallDet(I, currRing);
3913  res->data = (char *)p;
3914  return FALSE;
3915 }
3917 {
3918  assumeStdFlag(v);
3920  {
3921  Warn("dim(%s) may be wrong because the mixed monomial ordering",v->Name());
3922  }
3923 #ifdef HAVE_RINGS
3924  if (rField_is_Ring(currRing))
3925  {
3926  ideal vid = (ideal)v->Data();
3927  int i = idPosConstant(vid);
3928  if ((i != -1) && (n_IsUnit(pGetCoeff(vid->m[i]),currRing->cf)))
3929  { /* ideal v contains unit; dim = -1 */
3930  res->data = (char *)-1L;
3931  return FALSE;
3932  }
3933  ideal vv = id_Head(vid,currRing);
3934  idSkipZeroes(vv);
3935  int j = idPosConstant(vv);
3936  long d;
3937  if(j == -1)
3938  {
3939  d = (long)scDimInt(vv, currRing->qideal);
3940  if(rField_is_Z(currRing))
3941  d++;
3942  }
3943  else
3944  {
3945  if(n_IsUnit(pGetCoeff(vv->m[j]),currRing->cf))
3946  d = -1;
3947  else
3948  d = (long)scDimInt(vv, currRing->qideal);
3949  }
3950  //Anne's Idea for std(4,2x) = 0 bug
3951  long dcurr = d;
3952  for(unsigned ii=0;ii<(unsigned)IDELEMS(vv);ii++)
3953  {
3954  if(vv->m[ii] != NULL && !n_IsUnit(pGetCoeff(vv->m[ii]),currRing->cf))
3955  {
3956  ideal vc = idCopy(vv);
3957  poly c = pInit();
3958  pSetCoeff0(c,nCopy(pGetCoeff(vv->m[ii])));
3959  idInsertPoly(vc,c);
3960  idSkipZeroes(vc);
3961  for(unsigned jj = 0;jj<(unsigned)IDELEMS(vc)-1;jj++)
3962  {
3963  if((vc->m[jj]!=NULL)
3964  && (n_DivBy(pGetCoeff(vc->m[jj]),pGetCoeff(c),currRing->cf)))
3965  {
3966  pDelete(&vc->m[jj]);
3967  }
3968  }
3969  idSkipZeroes(vc);
3970  j = idPosConstant(vc);
3971  if (j != -1) pDelete(&vc->m[j]);
3972  dcurr = (long)scDimInt(vc, currRing->qideal);
3973  // the following assumes the ground rings to be either zero- or one-dimensional
3974  if((j==-1) && rField_is_Z(currRing))
3975  {
3976  // should also be activated for other euclidean domains as groundfield
3977  dcurr++;
3978  }
3979  idDelete(&vc);
3980  }
3981  if(dcurr > d)
3982  d = dcurr;
3983  }
3984  res->data = (char *)d;
3985  idDelete(&vv);
3986  return FALSE;
3987  }
3988 #endif
3989  res->data = (char *)(long)scDimInt((ideal)(v->Data()),currRing->qideal);
3990  return FALSE;
3991 }
3993 {
3994  si_link l = (si_link)v->Data();
3995  if (slDump(l))
3996  {
3997  const char *s;
3998  if ((l!=NULL)&&(l->name!=NULL)) s=l->name;
3999  else s=sNoName_fe;
4000  Werror("cannot dump to `%s`",s);
4001  return TRUE;
4002  }
4003  else
4004  return FALSE;
4005 }
4007 {
4008  res->data = (char *)pOne();
4009  int co=(int)(long)v->Data();
4010  if (co>0)
4011  {
4012  pSetComp((poly)res->data,co);
4013  pSetm((poly)res->data);
4014  }
4015  else WerrorS("argument of gen must be positive");
4016  return (co<=0);
4017 }
4019 {
4020  char * d = (char *)v->Data();
4021  char * s = (char *)omAlloc(strlen(d) + 13);
4022  strcpy( s, (char *)d);
4023  strcat( s, "\n;RETURN();\n");
4025  return yyparse();
4026 }
4028 {
4030  if (currRing->cf->convSingNFactoryN!=ndConvSingNFactoryN) /* conversion to factory*/
4031  {
4032  ideal_list p,h;
4033  h=kStdfac((ideal)v->Data(),NULL,testHomog,NULL);
4034  if (h==NULL)
4035  {
4036  L->Init(1);
4037  L->m[0].data=(char *)idInit(1);
4038  L->m[0].rtyp=IDEAL_CMD;
4039  }
4040  else
4041  {
4042  p=h;
4043  int l=0;
4044  while (p!=NULL) { p=p->next;l++; }
4045  L->Init(l);
4046  l=0;
4047  while(h!=NULL)
4048  {
4049  L->m[l].data=(char *)h->d;
4050  L->m[l].rtyp=IDEAL_CMD;
4051  p=h->next;
4052  omFreeSize(h,sizeof(*h));
4053  h=p;
4054  l++;
4055  }
4056  }
4057  }
4058  else
4059  {
4060  WarnS("no factorization implemented");
4061  L->Init(1);
4062  iiExprArith1(&(L->m[0]),v,STD_CMD);
4063  }
4064  res->data=(void *)L;
4065  return FALSE;
4066 }
4068 {
4069  intvec *v=NULL;
4071  ideal f=singclap_factorize((poly)(u->CopyD()), &v, 0,currRing);
4072  if (f==NULL) return TRUE;
4073  ivTest(v);
4075  l->Init(2);
4076  l->m[0].rtyp=IDEAL_CMD;
4077  l->m[0].data=(void *)f;
4078  l->m[1].rtyp=INTVEC_CMD;
4079  l->m[1].data=(void *)v;
4080  res->data=(void *)l;
4081  return FALSE;
4082 }
4084 {
4085  si_link l = (si_link)v->Data();
4086  if (slGetDump(l))
4087  {
4088  const char *s;
4089  if ((l!=NULL)&&(l->name!=NULL)) s=l->name;
4090  else s=sNoName_fe;
4091  Werror("cannot get dump from `%s`",s);
4092  return TRUE;
4093  }
4094  else
4095  return FALSE;
4096 }
4098 {
4099  assumeStdFlag(v);
4100  ideal I=(ideal)v->Data();
4101  res->data=(void *)iiHighCorner(I,0);
4102  return FALSE;
4103 }
4105 {
4106  assumeStdFlag(v);
4107  intvec *w=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
4108  BOOLEAN delete_w=FALSE;
4109  ideal I=(ideal)v->Data();
4110  int i;
4111  poly p=NULL,po=NULL;
4112  int rk=id_RankFreeModule(I,currRing);
4113  if (w==NULL)
4114  {
4115  w = new intvec(rk);
4116  delete_w=TRUE;
4117  }
4118  for(i=rk;i>0;i--)
4119  {
4120  p=iiHighCorner(I,i);
4121  if (p==NULL)
4122  {
4123  WerrorS("module must be zero-dimensional");
4124  if (delete_w) delete w;
4125  return TRUE;
4126  }
4127  if (po==NULL)
4128  {
4129  po=p;
4130  }
4131  else
4132  {
4133  // now po!=NULL, p!=NULL
4134  int d=(currRing->pFDeg(po,currRing)-(*w)[pGetComp(po)-1] - currRing->pFDeg(p,currRing)+(*w)[i-1]);
4135  if (d==0)
4136  d=pLmCmp(po,p);
4137  if (d > 0)
4138  {
4139  pDelete(&p);
4140  }
4141  else // (d < 0)
4142  {
4143  pDelete(&po); po=p;
4144  }
4145  }
4146  }
4147  if (delete_w) delete w;
4148  res->data=(void *)po;
4149  return FALSE;
4150 }
4152 {
4153 #ifdef HAVE_RINGS
4154  if (rField_is_Z(currRing))
4155  {
4156  PrintS("// NOTE: computation of Hilbert series etc. is being\n");
4157  PrintS("// performed for generic fibre, that is, over Q\n");
4158  }
4159 #endif
4160  assumeStdFlag(v);
4161  intvec *module_w=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
4162  //scHilbertPoly((ideal)v->Data(),currRing->qideal);
4163  hLookSeries((ideal)v->Data(),module_w,currRing->qideal);
4164  return FALSE;
4165 }
4167 {
4168 #ifdef HAVE_RINGS
4169  if (rField_is_Z(currRing))
4170  {
4171  PrintS("// NOTE: computation of Hilbert series etc. is being\n");
4172  PrintS("// performed for generic fibre, that is, over Q\n");
4173  }
4174 #endif
4175  res->data=(void *)hSecondSeries((intvec *)v->Data());
4176  return FALSE;
4177 }
4179 {
4180  intvec *w=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
4181  ideal v_id=(ideal)v->Data();
4182  if (w==NULL)
4183  {
4184  res->data=(void *)(long)idHomModule(v_id,currRing->qideal,&w);
4185  if (res->data!=NULL)
4186  {
4187  if (v->rtyp==IDHDL)
4188  {
4189  char *s_isHomog=omStrDup("isHomog");
4190  if (v->e==NULL)
4191  atSet((idhdl)(v->data),s_isHomog,w,INTVEC_CMD);
4192  else
4193  atSet((idhdl)(v->LData()),s_isHomog,w,INTVEC_CMD);
4194  }
4195  else if (w!=NULL) delete w;
4196  } // if res->data==NULL then w==NULL
4197  }
4198  else
4199  {
4200  res->data=(void *)(long)idTestHomModule(v_id,currRing->qideal,w);
4201  if((res->data==NULL) && (v->rtyp==IDHDL))
4202  {
4203  if (v->e==NULL)
4204  atKill((idhdl)(v->data),"isHomog");
4205  else
4206  atKill((idhdl)(v->LData()),"isHomog");
4207  }
4208  }
4209  return FALSE;
4210 }
4212 {
4213  res->data = (char *)idMaxIdeal((int)(long)v->Data());
4214  setFlag(res,FLAG_STD);
4215  return FALSE;
4216 }
4218 {
4219  matrix mat=(matrix)v->CopyD(MATRIX_CMD);
4220  IDELEMS((ideal)mat)=MATCOLS(mat)*MATROWS(mat);
4221  if (IDELEMS((ideal)mat)==0)
4222  {
4223  idDelete((ideal *)&mat);
4224  mat=(matrix)idInit(1,1);
4225  }
4226  else
4227  {
4228  MATROWS(mat)=1;
4229  mat->rank=1;
4230  idTest((ideal)mat);
4231  }
4232  res->data=(char *)mat;
4233  return FALSE;
4234 }
4236 {
4237  map m=(map)v->CopyD(MAP_CMD);
4238  omFree((ADDRESS)m->preimage);
4239  m->preimage=NULL;
4240  ideal I=(ideal)m;
4241  I->rank=1;
4242  res->data=(char *)I;
4243  return FALSE;
4244 }
4246 {
4247  if (currRing!=NULL)
4248  {
4249  ring q=(ring)v->Data();
4250  if (rSamePolyRep(currRing, q))
4251  {
4252  if (q->qideal==NULL)
4253  res->data=(char *)idInit(1,1);
4254  else
4255  res->data=(char *)idCopy(q->qideal);
4256  return FALSE;
4257  }
4258  }
4259  WerrorS("can only get ideal from identical qring");
4260  return TRUE;
4261 }
4263 {
4264  intvec *iv = (intvec *)v->CopyD(INTMAT_CMD);
4265  iv->makeVector();
4266  res->data = iv;
4267  return FALSE;
4268 }
4270 {
4271  res->data = (char *)n_ImPart((number)v->Data(),currRing->cf);
4272  return FALSE;
4273 }
4275 {
4276  assumeStdFlag(v);
4277  res->data=(void *)scIndIntvec((ideal)(v->Data()),currRing->qideal);
4278  return FALSE;
4279 }
4281 {
4282  ideal result=kInterRed((ideal)(v->Data()), currRing->qideal);
4283 #ifdef HAVE_RINGS
4285  WarnS("interred: this command is experimental over the integers");
4286 #endif
4287  if (TEST_OPT_PROT) { PrintLn(); mflush(); }
4288  res->data = result;
4289  return FALSE;
4290 }
4292 {
4293  res->data = (char *)(long)pVar((poly)v->Data());
4294  return FALSE;
4295 }
4297 {
4298  res->data = (char *)(long)(r_IsRingVar((char *)v->Data(), currRing->names,
4299  currRing->N)+1);
4300  return FALSE;
4301 }
4303 {
4304  res->data = (char *)0;
4305  return FALSE;
4306 }
4308 {
4309  ideal i=idInit(currRing->N,1);
4310  int k;
4311  poly p=(poly)(v->Data());
4312  for (k=currRing->N;k>0;k--)
4313  {
4314  i->m[k-1]=pDiff(p,k);
4315  }
4316  res->data = (char *)i;
4317  return FALSE;
4318 }
4320 {
4321  if (!nCoeff_is_transExt(currRing->cf))
4322  {
4323  WerrorS("differentiation not defined in the coefficient ring");
4324  return TRUE;
4325  }
4326  number n = (number) u->Data();
4327  number k = (number) v->Data();
4328  res->data = ntDiff(n,k,currRing->cf);
4329  return FALSE;
4330 }
4331 /*2
4332  * compute Jacobi matrix of a module/matrix
4333  * Jacobi(M) := ( diff(Mt,var(1))|, ... ,| diff(Mt,var(currRing->N)) ),
4334  * where Mt := transpose(M)
4335  * Note that this is consistent with the current conventions for jacob in Singular,
4336  * whereas M2 computes its transposed.
4337  */
4339 {
4340  ideal id = (ideal)a->Data();
4341  id = id_Transp(id,currRing);
4342  int W = IDELEMS(id);
4343 
4344  ideal result = idInit(W * currRing->N, id->rank);
4345  poly *p = result->m;
4346 
4347  for( int v = 1; v <= currRing->N; v++ )
4348  {
4349  poly* q = id->m;
4350  for( int i = 0; i < W; i++, p++, q++ )
4351  *p = pDiff( *q, v );
4352  }
4353  idDelete(&id);
4354 
4355  res->data = (char *)result;
4356  return FALSE;
4357 }
4358 
4359 
4361 {
4362  assumeStdFlag(v);
4363  res->data = (char *)scKBase(-1,(ideal)(v->Data()),currRing->qideal);
4364  return FALSE;
4365 }
4367 {
4368  res->data=(char *)syConvList((lists)v->Data());
4369  if (res->data != NULL)
4370  return FALSE;
4371  else
4372  return TRUE;
4373 }
4375 {
4376  poly p=(poly)v->Data();
4377  if (p==NULL)
4378  {
4379  res->data=(char *)nInit(0);
4380  }
4381  else
4382  {
4383  res->data=(char *)nCopy(pGetCoeff(p));
4384  }
4385  return FALSE;
4386 }
4388 {
4389  poly p=(poly)v->Data();
4390  int s=currRing->N;
4391  if (v->Typ()==VECTOR_CMD) s++;
4392  intvec *iv=new intvec(s);
4393  if (p!=NULL)
4394  {
4395  for(int i = currRing->N;i;i--)
4396  {
4397  (*iv)[i-1]=pGetExp(p,i);
4398  }
4399  if (s!=currRing->N)
4400  (*iv)[currRing->N]=pGetComp(p);
4401  }
4402  res->data=(char *)iv;
4403  return FALSE;
4404 }
4406 {
4407  poly p=(poly)v->Data();
4408  if (p == NULL)
4409  {
4410  res->data = (char*) NULL;
4411  }
4412  else
4413  {
4414  poly lm = pLmInit(p);
4415  pSetCoeff0(lm, nInit(1));
4416  res->data = (char*) lm;
4417  }
4418  return FALSE;
4419 }
4420 static BOOLEAN jjLOAD1(leftv /*res*/, leftv v)
4421 {
4422  return jjLOAD((char*)v->Data(),FALSE);
4423 }
4425 {
4426  lists l=(lists)v->Data();
4427  long mm=(long)atGet(v,"maxExp",INT_CMD);
4428  if (mm==0) mm=0x7fff;
4429  int isLetterplace=(int)(long)atGet(v,"isLetterplaceRing",INT_CMD);
4430  ring r=rCompose(l,TRUE,mm,isLetterplace);
4431  if (isLetterplace)
4432  {
4433  r->ShortOut=FALSE;
4434  r->CanShortOut=FALSE;
4435  r->isLPring=TRUE;
4436  }
4437  res->data=(char *)r;
4438  return (r==NULL);
4439 }
4441 {
4442  /* call method jjPFAC2 with second argument = 0 (meaning that no
4443  valid bound for the prime factors has been given) */
4444  sleftv tmp;
4445  memset(&tmp, 0, sizeof(tmp));
4446  tmp.rtyp = INT_CMD;
4447  return jjPFAC2(res, v, &tmp);
4448 }
4450 {
4451  /* computes the LU-decomposition of a matrix M;
4452  i.e., M = P * L * U, where
4453  - P is a row permutation matrix,
4454  - L is in lower triangular form,
4455  - U is in upper row echelon form
4456  Then, we also have P * M = L * U.
4457  A list [P, L, U] is returned. */
4458  matrix mat = (const matrix)v->Data();
4459  if (!idIsConstant((ideal)mat))
4460  {
4461  WerrorS("matrix must be constant");
4462  return TRUE;
4463  }
4464  matrix pMat;
4465  matrix lMat;
4466  matrix uMat;
4467 
4468  luDecomp(mat, pMat, lMat, uMat);
4469 
4471  ll->Init(3);
4472  ll->m[0].rtyp=MATRIX_CMD; ll->m[0].data=(void *)pMat;
4473  ll->m[1].rtyp=MATRIX_CMD; ll->m[1].data=(void *)lMat;
4474  ll->m[2].rtyp=MATRIX_CMD; ll->m[2].data=(void *)uMat;
4475  res->data=(char*)ll;
4476 
4477  return FALSE;
4478 }
4480 {
4481  // clean out "_":
4483  memset(&sLastPrinted,0,sizeof(sleftv));
4484  // collect all info:
4485  omUpdateInfo();
4486  switch(((int)(long)v->Data()))
4487  {
4488  case 0:
4489  res->data=(char *)n_Init(om_Info.UsedBytes,coeffs_BIGINT);
4490  break;
4491  case 1:
4492  res->data = (char *)n_Init(om_Info.CurrentBytesSystem,coeffs_BIGINT);
4493  break;
4494  case 2:
4495  res->data = (char *)n_Init(om_Info.MaxBytesSystem,coeffs_BIGINT);
4496  break;
4497  default:
4498  omPrintStats(stdout);
4499  omPrintInfo(stdout);
4500  omPrintBinStats(stdout);
4501  res->data = (char *)0;
4502  res->rtyp = NONE;
4503  }
4504  return FALSE;
4505  res->data = (char *)0;
4506  return FALSE;
4507 }
4508 //static BOOLEAN jjMONITOR1(leftv res, leftv v)
4509 //{
4510 // return jjMONITOR2(res,v,NULL);
4511 //}
4513 {
4514  int t=v->Typ();
4515  ideal r,m;
4516  r=kMin_std((ideal)v->Data(),currRing->qideal,testHomog,NULL,m);
4518  l->Init(2);
4519  l->m[0].rtyp=t;
4520  l->m[0].data=(char *)r;
4521  setFlag(&(l->m[0]),FLAG_STD);
4522  l->m[1].rtyp=t;
4523  l->m[1].data=(char *)m;
4524  res->data=(char *)l;
4525  return FALSE;
4526 }
4528 {
4529  assumeStdFlag(v);
4530  res->data = (char *)(long)scMultInt((ideal)(v->Data()),currRing->qideal);
4531  return FALSE;
4532 }
4534 {
4535  intvec *weights=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
4536 
4537  syStrategy tmp=(syStrategy)v->Data();
4538  tmp = syMinimize(tmp); // enrich itself!
4539 
4540  res->data=(char *)tmp;
4541 
4542  if (weights!=NULL)
4543  atSet(res, omStrDup("isHomog"),ivCopy(weights),INTVEC_CMD);
4544 
4545  return FALSE;
4546 }
4548 {
4549  number n,i; i=(number)v->Data();
4551  if (nMap!=NULL)
4552  n=nMap(i,currRing->cf,coeffs_BIGINT);
4553  else goto err;
4554  res->data=(void *)n;
4555  return FALSE;
4556 err:
4557  WerrorS("cannot convert to bigint"); return TRUE;
4558 }
4560 {
4561  if ((v->rtyp==IDHDL)||(v->rtyp==ALIAS_CMD))
4562  res->data=omStrDup(v->name);
4563  else if (v->name==NULL)
4564  res->data=omStrDup("");
4565  else
4566  {
4567  res->data = (char *)v->name;
4568  v->name=NULL;
4569  }
4570  return FALSE;
4571 }
4573 {
4574  res->data=ipNameList(((ring)v->Data())->idroot);
4575  return FALSE;
4576 }
4578 {
4579  res->data=ipNameListLev((IDROOT),(int)(long)v->Data());
4580  return FALSE;
4581 }
4583 {
4584  res->data=(char*)(long)((long)v->Data()==0 ? 1 : 0);
4585  return FALSE;
4586 }
4588 {
4589  res->data = (char *)(long)(((ring)(v->Data()))->N);
4590  return FALSE;
4591 }
4593 {
4594  si_link l=(si_link)v->Data();
4595  if (iiOp==OPEN_CMD) return slOpen(l, SI_LINK_OPEN,v);
4596  else { slPrepClose(l); return slClose(l);}
4597 }
4599 {
4600  poly p=(poly)v->Data();
4601  res->data=(char *)( p==NULL ? -1 : currRing->pFDeg(p,currRing) );
4602  return FALSE;
4603 }
4605 {
4606  int i=(int)(long)v->Data();
4607  int p=0;
4608  p=rPar(currRing);
4609  if ((0<i) && (i<=p))
4610  {
4611  res->data=(char *)n_Param(i,currRing);
4612  }
4613  else
4614  {
4615  Werror("par number %d out of range 1..%d",i,p);
4616  return TRUE;
4617  }
4618  return FALSE;
4619 }
4621 {
4622  number nn=(number)v->Data();
4623  res->data = (char *)(long)n_ParDeg(nn, currRing->cf);
4624  return FALSE;
4625 }
4627 {
4628  if (currRing==NULL)
4629  {
4630  WerrorS("no ring active");
4631  return TRUE;
4632  }
4633  int i=(int)(long)v->Data();
4634  int p=0;
4635  if ((0<i) && (rParameter(currRing)!=NULL) && (i<=(p=rPar(currRing))))
4636  res->data=omStrDup(rParameter(currRing)[i-1]);
4637  else
4638  {
4639  Werror("par number %d out of range 1..%d",i,p);
4640  return TRUE;
4641  }
4642  return FALSE;
4643 }
4645 {
4646  poly p=(poly)v->Data();
4647  if (p==NULL) { res->data=(char *)n_Init(0,coeffs_BIGINT); return FALSE; }
4648  if ((pNext(p)!=NULL)|| (!pIsConstant(p)))
4649  {
4650  WerrorS("poly must be constant");
4651  return TRUE;
4652  }
4653  number i=pGetCoeff(p);
4654  number n;
4656  if (nMap!=NULL)
4657  n=nMap(i,currRing->cf,coeffs_BIGINT);
4658  else goto err;
4659  res->data=(void *)n;
4660  return FALSE;
4661 err:
4662  WerrorS("cannot convert to bigint"); return TRUE;
4663 }
4665 {
4666  poly p=(poly)v->Data();
4667  if (p==NULL) { /*res->data=(char *)0;*/ return FALSE; }
4668  if ((pNext(p)!=NULL)|| (!pIsConstant(p)))
4669  {
4670  WerrorS("poly must be constant");
4671  return TRUE;
4672  }
4673  res->data = (char *)(long)iin_Int(pGetCoeff(p),currRing->cf);
4674  return FALSE;
4675 }
4677 {
4678  map mapping=(map)v->Data();
4679  syMake(res,omStrDup(mapping->preimage));
4680  return FALSE;
4681 }
4683 {
4684  int i = IsPrime((int)(long)(v->Data()));
4685  res->data = (char *)(long)(i > 1 ? i : 2);
4686  return FALSE;
4687 }
4689 {
4690  intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
4691  ideal v_id=(ideal)v->Data();
4692  if (w!=NULL)
4693  {
4694  if (!idTestHomModule(v_id,currRing->qideal,w))
4695  {
4696  WarnS("wrong weights");
4697  w=NULL;
4698  // and continue at the non-homog case below
4699  }
4700  else
4701  {
4702  w=ivCopy(w);
4703  intvec **ww=&w;
4704  res->data = (char *)idMinEmbedding(v_id,FALSE,ww);
4705  atSet(res,omStrDup("isHomog"),*ww,INTVEC_CMD);
4706  return FALSE;
4707  }
4708  }
4709  res->data = (char *)idMinEmbedding(v_id);
4710  return FALSE;
4711 }
4713 {
4714  number n;
4715  poly p;
4716  if (((p=(poly)v->Data())!=NULL)
4717  && (pIsConstant(p)))
4718  {
4719  n=nCopy(pGetCoeff(p));
4720  }
4721  else
4722  {
4723  n=nInit(0);
4724  }
4725  res->data = (char *)n;
4726  return FALSE;
4727 }
4729 {
4730  char *s= (char *)v->Data();
4731  // try system keywords
4732  for(unsigned i=0; i<sArithBase.nCmdUsed; i++)
4733  {
4734  //Print("test %d, >>%s<<, tab:>>%s<<\n",i,s,sArithBase.sCmds[i].name);
4735  if (strcmp(s, sArithBase.sCmds[i].name) == 0)
4736  {
4737  res->data = (char *)1;
4738  return FALSE;
4739  }
4740  }
4741  // try blackbox names
4742  int id;
4743  blackboxIsCmd(s,id);
4744  if (id>0)
4745  {
4746  res->data = (char *)1;
4747  }
4748  return FALSE;
4749 }
4751 {
4752  matrix m =(matrix)v->Data();
4753  int rank = luRank(m, 0);
4754  res->data =(char *)(long)rank;
4755  return FALSE;
4756 }
4758 {
4759  return jjREAD2(res,v,NULL);
4760 }
4762 {
4763  res->data = (char *)(long)iiRegularity((lists)v->Data());
4764  return FALSE;
4765 }
4767 {
4768  res->data = (char *)n_RePart((number)v->Data(),currRing->cf);
4769  return FALSE;
4770 }
4772 {
4773  ring r=(ring)v->Data();
4774  if (r!=NULL)
4775  {
4776  res->data = (char *)rDecompose((ring)v->Data());
4777  if (res->data!=NULL)
4778  {
4779  long mm=r->bitmask/2;
4780  if (mm>MAX_INT_VAL) mm=MAX_INT_VAL;
4781  atSet(res,omStrDup("maxExp"),(void*)mm,INT_CMD);
4782  return FALSE;
4783  }
4784  }
4785  return TRUE;
4786 }
4788 {
4789  coeffs r=(coeffs)v->Data();
4790  if (r!=NULL)
4791  return rDecompose_CF(res,r);
4792  return TRUE;
4793 }
4795 {
4796  ring r=(ring)v->Data();
4797  if (r!=NULL)
4798  res->data = (char *)rDecompose_list_cf((ring)v->Data());
4799  return (r==NULL)||(res->data==NULL);
4800 }
4802 {
4803  ideal i = (ideal)v->Data();
4804  res->data = (char *)i->rank;
4805  return FALSE;
4806 }
4808 {
4809  res->data = (char *)(long)((bigintmat*)(v->Data()))->rows();
4810  return FALSE;
4811 }
4813 {
4814  res->data = (char *)(long)((intvec*)(v->Data()))->rows();
4815  return FALSE;
4816 }
4818 {
4819  res->data = (char *)(long)rPar(((ring)v->Data()));
4820  return FALSE;
4821 }
4823 {
4824  const bool bIsSCA = rIsSCA(currRing);
4825 
4826  if ((currRing->qideal!=NULL) && !bIsSCA)
4827  {
4828  WerrorS("qring not supported by slimgb at the moment");
4829  return TRUE;
4830  }
4832  {
4833  WerrorS("ordering must be global for slimgb");
4834  return TRUE;
4835  }
4837  WarnS("groebner base computations with inexact coefficients can not be trusted due to rounding errors");
4838  intvec *w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
4839  // tHomog hom=testHomog;
4840  ideal u_id=(ideal)u->Data();
4841  if (w!=NULL)
4842  {
4843  if (!idTestHomModule(u_id,currRing->qideal,w))
4844  {
4845  WarnS("wrong weights");
4846  w=NULL;
4847  }
4848  else
4849  {
4850  w=ivCopy(w);
4851  // hom=isHomog;
4852  }
4853  }
4854 
4855  assume(u_id->rank>=id_RankFreeModule(u_id, currRing));
4856  res->data=(char *)t_rep_gb(currRing,
4857  u_id,u_id->rank);
4858  //res->data=(char *)t_rep_gb(currRing, u_id);
4859 
4861  if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
4862  return FALSE;
4863 }
4865 {
4866  ideal result;
4867  ideal v_id=(ideal)v->Data();
4868  intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
4869  tHomog hom=testHomog;
4870  if (w!=NULL)
4871  {
4872  if (!idTestHomModule(v_id,currRing->qideal,w))
4873  {
4874  WarnS("wrong weights");
4875  w=NULL;
4876  }
4877  else
4878  {
4879  hom=isHomog;
4880  w=ivCopy(w);
4881  }
4882  }
4883  result=kSba(v_id,currRing->qideal,hom,&w,1,0);
4885  res->data = (char *)result;
4887  if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
4888  return FALSE;
4889 }
4891 {
4892  ideal result;
4893  ideal v_id=(ideal)v->Data();
4894  intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
4895  tHomog hom=testHomog;
4896  if (w!=NULL)
4897  {
4898  if (!idTestHomModule(v_id,currRing->qideal,w))
4899  {
4900  WarnS("wrong weights");
4901  w=NULL;
4902  }
4903  else
4904  {
4905  hom=isHomog;
4906  w=ivCopy(w);
4907  }
4908  }
4909  result=kSba(v_id,currRing->qideal,hom,&w,(int)(long)u->Data(),0);
4911  res->data = (char *)result;
4913  if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
4914  return FALSE;
4915 }
4917 {
4918  ideal result;
4919  ideal v_id=(ideal)v->Data();
4920  intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
4921  tHomog hom=testHomog;
4922  if (w!=NULL)
4923  {
4924  if (!idTestHomModule(v_id,currRing->qideal,w))
4925  {
4926  WarnS("wrong weights");
4927  w=NULL;
4928  }
4929  else
4930  {
4931  hom=isHomog;
4932  w=ivCopy(w);
4933  }
4934  }
4935  result=kSba(v_id,currRing->qideal,hom,&w,(int)(long)u->Data(),(int)(long)t->Data());
4937  res->data = (char *)result;
4939  if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
4940  return FALSE;
4941 }
4943 {
4945  WarnS("groebner base computations with inexact coefficients can not be trusted due to rounding errors");
4946  ideal result;
4947  ideal v_id=(ideal)v->Data();
4948  intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
4949  tHomog hom=testHomog;
4950  if (w!=NULL)
4951  {
4952  if (!idTestHomModule(v_id,currRing->qideal,w))
4953  {
4954  WarnS("wrong weights");
4955  w=NULL;
4956  }
4957  else
4958  {
4959  hom=isHomog;
4960  w=ivCopy(w);
4961  }
4962  }
4963  result=kStd(v_id,currRing->qideal,hom,&w);
4965  res->data = (char *)result;
4967  if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
4968  return FALSE;
4969 }
4971 {
4972  res->data = (char *)idSort((ideal)v->Data());
4973  return FALSE;
4974 }
4976 {
4978  intvec *v=NULL;
4979  ideal f=singclap_sqrfree((poly)(u->CopyD()), &v, 0, currRing);
4980  if (f==NULL) return TRUE;
4981  ivTest(v);
4983  l->Init(2);
4984  l->m[0].rtyp=IDEAL_CMD;
4985  l->m[0].data=(void *)f;
4986  l->m[1].rtyp=INTVEC_CMD;
4987  l->m[1].data=(void *)v;
4988  res->data=(void *)l;
4989  return FALSE;
4990 }
4991 #if 1
4993 {
4994  intvec *w=NULL;
4995  res->data = (char *)idSyzygies((ideal)v->Data(),testHomog,&w);
4996  if (w!=NULL) delete w;
4998  return FALSE;
4999 }
5000 #else
5001 // activate, if idSyz handle module weights correctly !
5002 static BOOLEAN jjSYZYGY(leftv res, leftv v)
5003 {
5004  intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
5005  ideal v_id=(ideal)v->Data();
5006  tHomog hom=testHomog;
5007  int add_row_shift=0;
5008  if (w!=NULL)
5009  {
5010  w=ivCopy(w);
5011  add_row_shift=w->min_in();
5012  (*w)-=add_row_shift;
5013  if (idTestHomModule(v_id,currRing->qideal,w))
5014  hom=isHomog;
5015  else
5016  {
5017  //WarnS("wrong weights");
5018  delete w; w=NULL;
5019  hom=testHomog;
5020  }
5021  }
5022  res->data = (char *)idSyzygies(v_id,hom,&w);
5023  if (w!=NULL)
5024  {
5025  atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
5026  }
5027  return FALSE;
5028 }
5029 #endif
5031 {
5032  res->data = (char *)(long)ivTrace((intvec*)(v->Data()));
5033  return FALSE;
5034 }
5036 {
5037  res->data = (char *)(((bigintmat*)(v->Data()))->transpose());
5038  return FALSE;
5039 }
5041 {
5042  res->data = (char *)ivTranp((intvec*)(v->Data()));
5043  return FALSE;
5044 }
5045 #ifdef HAVE_PLURAL
5047 {
5048  ring r = (ring)a->Data();
5049  //if (rIsPluralRing(r))
5050  if (r->OrdSgn==1)
5051  {
5052  res->data = rOpposite(r);
5053  }
5054  else
5055  {
5056  WarnS("opposite only for global orderings");
5057  res->data = rCopy(r);
5058  }
5059  return FALSE;
5060 }
5062 {
5063  ring r = (ring)a->Data();
5064  if (rIsPluralRing(r))
5065  {
5066  ring s = rEnvelope(r);
5067  res->data = s;
5068  }
5069  else res->data = rCopy(r);
5070  return FALSE;
5071 }
5073 {
5074  if (rIsPluralRing(currRing)) res->data=(ideal)twostd((ideal)a->Data());
5075  else res->data=(ideal)a->CopyD();
5076  setFlag(res,FLAG_STD);
5078  return FALSE;
5079 }
5080 #endif
5081 
5083 {
5084  int t=(int)(long)v->data;
5085  switch (t)
5086  {
5087  case CRING_CMD:
5088  case INT_CMD:
5089  case POLY_CMD:
5090  case VECTOR_CMD:
5091  case STRING_CMD:
5092  case INTVEC_CMD:
5093  case IDEAL_CMD:
5094  case MATRIX_CMD:
5095  case MODUL_CMD:
5096  case MAP_CMD:
5097  case PROC_CMD:
5098  case RING_CMD:
5099  case SMATRIX_CMD:
5100  //case QRING_CMD:
5101  case INTMAT_CMD:
5102  case BIGINTMAT_CMD:
5103  case NUMBER_CMD:
5104  #ifdef SINGULAR_4_2
5105  case CNUMBER_CMD:
5106  #endif
5107  case BIGINT_CMD:
5108  case BUCKET_CMD:
5109  case LIST_CMD:
5110  case PACKAGE_CMD:
5111  case LINK_CMD:
5112  case RESOLUTION_CMD:
5113  res->data=omStrDup(Tok2Cmdname(t)); break;
5114  case DEF_CMD:
5115  case NONE: res->data=omStrDup("none"); break;
5116  default:
5117  {
5118  if (t>MAX_TOK)
5119  res->data=omStrDup(getBlackboxName(t));
5120  else
5121  res->data=omStrDup("?unknown type?");
5122  break;
5123  }
5124  }
5125  return FALSE;
5126 }
5128 {
5129  res->data=(char *)(long)pIsUnivariate((poly)v->Data());
5130  return FALSE;
5131 }
5133 {
5134  int i=(int)(long)v->Data();
5135  if ((0<i) && (i<=currRing->N))
5136  {
5137  poly p=pOne();
5138  pSetExp(p,i,1);
5139  pSetm(p);
5140  res->data=(char *)p;
5141  }
5142  else
5143  {
5144  Werror("var number %d out of range 1..%d",i,currRing->N);
5145  return TRUE;
5146  }
5147  return FALSE;
5148 }
5150 {
5151  if (currRing==NULL)
5152  {
5153  WerrorS("no ring active");
5154  return TRUE;
5155  }
5156  int i=(int)(long)v->Data();
5157  if ((0<i) && (i<=currRing->N))
5158  res->data=omStrDup(currRing->names[i-1]);
5159  else
5160  {
5161  Werror("var number %d out of range 1..%d",i,currRing->N);
5162  return TRUE;
5163  }
5164  return FALSE;
5165 }
5167 {
5168  assumeStdFlag(v);
5169  res->data = (char *)(long)scMult0Int((ideal)v->Data(),currRing->qideal);
5170  return FALSE;
5171 }
5173 {
5174 // input: u: a list with links of type
5175 // ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
5176 // returns: -1: the read state of all links is eof
5177 // i>0: (at least) u[i] is ready
5178  lists Lforks = (lists)u->Data();
5179  int i = slStatusSsiL(Lforks, -1);
5180  if(i == -2) /* error */
5181  {
5182  return TRUE;
5183  }
5184  res->data = (void*)(long)i;
5185  return FALSE;
5186 }
5188 {
5189 // input: u: a list with links of type
5190 // ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
5191 // returns: -1: the read state of all links is eof
5192 // 1: all links are ready
5193 // (caution: at least one is ready, but some maybe dead)
5194  lists Lforks = (lists)u->CopyD();
5195  int i;
5196  int j = -1;
5197  for(int nfinished = 0; nfinished < Lforks->nr+1; nfinished++)
5198  {
5199  i = slStatusSsiL(Lforks, -1);
5200  if(i == -2) /* error */
5201  {
5202  return TRUE;
5203  }
5204  if(i == -1)
5205  {
5206  break;
5207  }
5208  j = 1;
5209  Lforks->m[i-1].CleanUp();
5210  Lforks->m[i-1].rtyp=DEF_CMD;
5211  Lforks->m[i-1].data=NULL;
5212  }
5213  res->data = (void*)(long)j;
5214  Lforks->Clean();
5215  return FALSE;
5216 }
5217 
5218 BOOLEAN jjLOAD(const char *s, BOOLEAN autoexport)
5219 {
5220  char libnamebuf[1024];
5222 
5223 #ifdef HAVE_DYNAMIC_LOADING
5224  extern BOOLEAN load_modules(const char *newlib, char *fullpath, BOOLEAN autoexport);
5225 #endif /* HAVE_DYNAMIC_LOADING */
5226  switch(LT)
5227  {
5228  default:
5229  case LT_NONE:
5230  Werror("%s: unknown type", s);
5231  break;
5232  case LT_NOTFOUND:
5233  Werror("cannot open %s", s);
5234  break;
5235 
5236  case LT_SINGULAR:
5237  {
5238  char *plib = iiConvName(s);
5239  idhdl pl = IDROOT->get(plib,0);
5240  if (pl==NULL)
5241  {
5242  pl = enterid( plib,0, PACKAGE_CMD, &(basePack->idroot), TRUE );
5243  IDPACKAGE(pl)->language = LANG_SINGULAR;
5244  IDPACKAGE(pl)->libname=omStrDup(s);
5245  }
5246  else if (IDTYP(pl)!=PACKAGE_CMD)
5247  {
5248  Werror("can not create package `%s`",plib);
5249  omFree(plib);
5250  return TRUE;
5251  }
5252  else /* package */
5253  {
5254  package pa=IDPACKAGE(pl);
5255  if ((pa->language==LANG_C)
5256  || (pa->language==LANG_MIX))
5257  {
5258  Werror("can not create package `%s` - binaries exists",plib);
5259  omfree(plib);
5260  return TRUE;
5261  }
5262  }
5263  omFree(plib);
5264  package savepack=currPack;
5265  currPack=IDPACKAGE(pl);
5266  IDPACKAGE(pl)->loaded=TRUE;
5267  char libnamebuf[1024];
5268  FILE * fp = feFopen( s, "r", libnamebuf, TRUE );
5269  BOOLEAN bo=iiLoadLIB(fp, libnamebuf, s, pl, autoexport, TRUE);
5270  currPack=savepack;
5271  IDPACKAGE(pl)->loaded=(!bo);
5272  return bo;
5273  }
5274  case LT_BUILTIN:
5275  SModulFunc_t iiGetBuiltinModInit(const char*);
5276  return load_builtin(s,autoexport, iiGetBuiltinModInit(s));
5277  case LT_MACH_O:
5278  case LT_ELF:
5279  case LT_HPUX:
5280 #ifdef HAVE_DYNAMIC_LOADING
5281  return load_modules(s, libnamebuf, autoexport);
5282 #else /* HAVE_DYNAMIC_LOADING */
5283  WerrorS("Dynamic modules are not supported by this version of Singular");
5284  break;
5285 #endif /* HAVE_DYNAMIC_LOADING */
5286  }
5287  return TRUE;
5288 }
5289 static int WerrorS_dummy_cnt=0;
5290 static void WerrorS_dummy(const char *)
5291 {
5293 }
5294 BOOLEAN jjLOAD_TRY(const char *s)
5295 {
5296  void (*WerrorS_save)(const char *s) = WerrorS_callback;
5299  BOOLEAN bo=jjLOAD(s,TRUE);
5300  if (TEST_OPT_PROT && (bo || (WerrorS_dummy_cnt>0)))
5301  Print("loading of >%s< failed\n",s);
5302  WerrorS_callback=WerrorS_save;
5303  errorreported=0;
5304  return FALSE;
5305 }
5306 
5308 {
5309  res->data = (char *)strlen((char *)v->Data());
5310  return FALSE;
5311 }
5313 {
5314  res->data = (char *)(long)pLength((poly)v->Data());
5315  return FALSE;
5316 }
5318 {
5319  res->data = (char *)(long)idElem((ideal)v->Data());
5320  return FALSE;
5321 }
5323 {
5324  res->data = (char *)id_FreeModule((int)(long)v->Data(), currRing);
5325  return FALSE;
5326 }
5328 {
5329  res->data = (char *)id_Vec2Ideal((poly)v->Data(), currRing);
5330  return FALSE;
5331 }
5333 {
5334  res->data = rCharStr((ring)v->Data());
5335  return FALSE;
5336 }
5338 {
5339  res->data = (char *)pHead((poly)v->Data());
5340  return FALSE;
5341 }
5343 {
5344  res->data = (char *)id_Head((ideal)v->Data(),currRing);
5345  setFlag(res,FLAG_STD);
5346  return FALSE;
5347 }
5349 {
5350  res->data = (char *)idMinBase((ideal)v->Data());
5351  return FALSE;
5352 }
5353 #if 0 // unused
5354 static BOOLEAN jjsyMinBase(leftv res, leftv v)
5355 {
5356  res->data = (char *)syMinBase((ideal)v->Data());
5357  return FALSE;
5358 }
5359 #endif
5361 {
5362  res->data = (char *)pMaxComp((poly)v->Data());
5363  return FALSE;
5364 }
5366 {
5367  res->data = (char *)mp_Trace((matrix)v->Data(),currRing);
5368  return FALSE;
5369 }
5371 {
5372  res->data = (char *)mp_Transp((matrix)v->Data(),currRing);
5373  return FALSE;
5374 }
5376 {
5377  res->data = rOrdStr((ring)v->Data());
5378  return FALSE;
5379 }
5381 {
5382  res->data = rVarStr((ring)v->Data());
5383  return FALSE;
5384 }
5386 {
5387  res->data = rParStr((ring)v->Data());
5388  return FALSE;
5389 }
5391 {
5392  res->data=(char *)(long)sySize((syStrategy)v->Data());
5393  return FALSE;
5394 }
5396 {
5397  res->data = (char *)(long)syDim((syStrategy)v->Data());
5398  return FALSE;
5399 }
5401 {
5402  res->data = (char *)id_Transp((ideal)v->Data(),currRing);
5403  return FALSE;
5404 }
5406 {
5407  number n=(number)u->CopyD(); // n_Int may call n_Normalize
5408  res->data=(char *)(long)iin_Int(n,currRing->cf);
5409  n_Delete(&n,currRing->cf);
5410  return FALSE;
5411 }
5413 {
5414  number n=(number)u->Data();
5415  res->data=(char *)(long)iin_Int(n,coeffs_BIGINT );
5416  return FALSE;
5417 }
5418 /*=================== operations with 3 args.: static proc =================*/
5419 /* must be ordered: first operations for chars (infix ops),
5420  * then alphabetically */
5422 {
5423  char *s= (char *)u->Data();
5424  int r = (int)(long)v->Data();
5425  int c = (int)(long)w->Data();
5426  int l = strlen(s);
5427 
5428  if ( (r<1) || (r>l) || (c<0) )
5429  {
5430  Werror("wrong range[%d,%d] in string %s",r,c,u->Fullname());
5431  return TRUE;
5432  }
5433  res->data = (char *)omAlloc((long)(c+1));
5434  sprintf((char *)res->data,"%-*.*s",c,c,s+r-1);
5435  return FALSE;
5436 }
5438 {
5439  intvec *iv = (intvec *)u->Data();
5440  int r = (int)(long)v->Data();
5441  int c = (int)(long)w->Data();
5442  if ((r<1)||(r>iv->rows())||(c<1)||(c>iv->cols()))
5443  {
5444  Werror("wrong range[%d,%d] in intmat %s(%d x %d)",
5445  r,c,u->Fullname(),iv->rows(),iv->cols());
5446  return TRUE;
5447  }
5448  res->data=u->data; u->data=NULL;
5449  res->rtyp=u->rtyp; u->rtyp=0;
5450  res->name=u->name; u->name=NULL;
5451  Subexpr e=jjMakeSub(v);
5452  e->next=jjMakeSub(w);
5453  if (u->e==NULL) res->e=e;
5454  else
5455  {
5456  Subexpr h=u->e;
5457  while (h->next!=NULL) h=h->next;
5458  h->next=e;
5459  res->e=u->e;
5460  u->e=NULL;
5461  }
5462  return FALSE;
5463 }
5465 {
5466  bigintmat *bim = (bigintmat *)u->Data();
5467  int r = (int)(long)v->Data();
5468  int c = (int)(long)w->Data();
5469  if ((r<1)||(r>bim->rows())||(c<1)||(c>bim->cols()))
5470  {
5471  Werror("wrong range[%d,%d] in bigintmat %s(%d x %d)",
5472  r,c,u->Fullname(),bim->rows(),bim->cols());
5473  return TRUE;
5474  }
5475  res->data=u->data; u->data=NULL;
5476  res->rtyp=u->rtyp; u->rtyp=0;
5477  res->name=u->name; u->name=NULL;
5478  Subexpr e=jjMakeSub(v);
5479  e->next=jjMakeSub(w);
5480  if (u->e==NULL)
5481  res->e=e;
5482  else
5483  {
5484  Subexpr h=u->e;
5485  while (h->next!=NULL) h=h->next;
5486  h->next=e;
5487  res->e=u->e;
5488  u->e=NULL;
5489  }
5490  return FALSE;
5491 }
5493 {
5494  matrix m= (matrix)u->Data();
5495  int r = (int)(long)v->Data();
5496  int c = (int)(long)w->Data();
5497  //Print("gen. elem %d, %d\n",r,c);
5498  if ((r<1)||(r>MATROWS(m))||(c<1)||(c>MATCOLS(m)))
5499  {
5500  Werror("wrong range[%d,%d] in matrix %s(%d x %d)",r,c,u->Fullname(),
5501  MATROWS(m),MATCOLS(m));
5502  return TRUE;
5503  }
5504  res->data=u->data; u->data=NULL;
5505  res->rtyp=u->rtyp; u->rtyp=0;
5506  res->name=u->name; u->name=NULL;
5507  Subexpr e=jjMakeSub(v);
5508  e->next=jjMakeSub(w);
5509  if (u->e==NULL)
5510  res->e=e;
5511  else
5512  {
5513  Subexpr h=u->e;
5514  while (h->next!=NULL) h=h->next;
5515  h->next=e;
5516  res->e=u->e;
5517  u->e=NULL;
5518  }
5519  return FALSE;
5520 }
5522 {
5523  ideal m= (ideal)u->Data();
5524  int r = (int)(long)v->Data();
5525  int c = (int)(long)w->Data();
5526  //Print("gen. elem %d, %d\n",r,c);
5527  if ((r<1)||(r>m->rank)||(c<1)||(c>IDELEMS(m)))
5528  {
5529  Werror("wrong range[%d,%d] in matrix %s(%d x %d)",r,c,u->Fullname(),
5530  (int)m->rank,IDELEMS(m));
5531  return TRUE;
5532  }
5533  res->data=u->data; u->data=NULL;
5534  res->rtyp=u->rtyp; u->rtyp=0;
5535  res->name=u->name; u->name=NULL;
5536  Subexpr e=jjMakeSub(v);
5537  e->next=jjMakeSub(w);
5538  if (u->e==NULL)
5539  res->e=e;
5540  else
5541  {
5542  Subexpr h=u->e;
5543  while (h->next!=NULL) h=h->next;
5544  h->next=e;
5545  res->e=u->e;
5546  u->e=NULL;
5547  }
5548  return FALSE;
5549 }
5551 {
5552  sleftv t;
5553  sleftv ut;
5554  leftv p=NULL;
5555  intvec *iv=(intvec *)w->Data();
5556  int l;
5557  BOOLEAN nok;
5558 
5559  if ((u->rtyp!=IDHDL)||(u->e!=NULL))
5560  {
5561  WerrorS("cannot build expression lists from unnamed objects");
5562  return TRUE;
5563  }
5564  memcpy(&ut,u,sizeof(ut));
5565  memset(&t,0,sizeof(t));
5566  t.rtyp=INT_CMD;
5567  for (l=0;l< iv->length(); l++)
5568  {
5569  t.data=(char *)(long)((*iv)[l]);
5570  if (p==NULL)
5571  {
5572  p=res;
5573  }
5574  else
5575  {
5576  p->next=(leftv)omAlloc0Bin(sleftv_bin);
5577  p=p->next;
5578  }
5579  memcpy(u,&ut,sizeof(ut));
5580  if (u->Typ() == MATRIX_CMD)
5581  nok=jjBRACK_Ma(p,u,v,&t);
5582  else if (u->Typ() == BIGINTMAT_CMD)
5583  nok=jjBRACK_Bim(p,u,v,&t);
5584  else /* INTMAT_CMD */
5585  nok=jjBRACK_Im(p,u,v,&t);
5586  if (nok)
5587  {
5588  while (res->next!=NULL)
5589  {
5590  p=res->next->next;
5591  omFreeBin((ADDRESS)res->next, sleftv_bin);
5592  // res->e aufraeumen !!!!
5593  res->next=p;
5594  }
5595  return TRUE;
5596  }
5597  }
5598  return FALSE;
5599 }
5601 {
5602  sleftv t;
5603  sleftv ut;
5604  leftv p=NULL;
5605  intvec *iv=(intvec *)v->Data();
5606  int l;
5607  BOOLEAN nok;
5608 
5609  if ((u->rtyp!=IDHDL)||(u->e!=NULL))
5610  {
5611  WerrorS("cannot build expression lists from unnamed objects");
5612  return TRUE;
5613  }
5614  memcpy(&ut,u,sizeof(ut));
5615  memset(&t,0,sizeof(t));
5616  t.rtyp=INT_CMD;
5617  for (l=0;l< iv->length(); l++)
5618  {
5619  t.data=(char *)(long)((*iv)[l]);
5620  if (p==NULL)
5621  {
5622  p=res;
5623  }
5624  else
5625  {
5626  p->next=(leftv)omAlloc0Bin(sleftv_bin);
5627  p=p->next;
5628  }
5629  memcpy(u,&ut,sizeof(ut));
5630  if (u->Typ() == MATRIX_CMD)
5631  nok=jjBRACK_Ma(p,u,&t,w);
5632  else if (u->Typ() == BIGINTMAT_CMD)
5633  nok=jjBRACK_Bim(p,u,&t,w);
5634  else /* INTMAT_CMD */
5635  nok=jjBRACK_Im(p,u,&t,w);
5636  if (nok)
5637  {
5638  while (res->next!=NULL)
5639  {
5640  p=res->next->next;
5641  omFreeBin((ADDRESS)res->next, sleftv_bin);
5642  // res->e aufraeumen !!
5643  res->next=p;
5644  }
5645  return TRUE;
5646  }
5647  }
5648  return FALSE;
5649 }
5651 {
5652  sleftv t1,t2,ut;
5653  leftv p=NULL;
5654  intvec *vv=(intvec *)v->Data();
5655  intvec *wv=(intvec *)w->Data();
5656  int vl;
5657  int wl;
5658  BOOLEAN nok;
5659 
5660  if ((u->rtyp!=IDHDL)||(u->e!=NULL))
5661  {
5662  WerrorS("cannot build expression lists from unnamed objects");
5663  return TRUE;
5664  }
5665  memcpy(&ut,u,sizeof(ut));
5666  memset(&t1,0,sizeof(sleftv));
5667  memset(&t2,0,sizeof(sleftv));
5668  t1.rtyp=INT_CMD;
5669  t2.rtyp=INT_CMD;
5670  for (vl=0;vl< vv->length(); vl++)
5671  {
5672  t1.data=(char *)(long)((*vv)[vl]);
5673  for (wl=0;wl< wv->length(); wl++)
5674  {
5675  t2.data=(char *)(long)((*wv)[wl]);
5676  if (p==NULL)
5677  {
5678  p=res;
5679  }
5680  else
5681  {
5682  p->next=(leftv)omAlloc0Bin(sleftv_bin);
5683  p=p->next;
5684  }
5685  memcpy(u,&ut,sizeof(ut));
5686  if (u->Typ() == MATRIX_CMD)
5687  nok=jjBRACK_Ma(p,u,&t1,&t2);
5688  else if (u->Typ() == BIGINTMAT_CMD)
5689  nok=jjBRACK_Bim(p,u,&t1,&t2);
5690  else /* INTMAT_CMD */
5691  nok=jjBRACK_Im(p,u,&t1,&t2);
5692  if (nok)
5693  {
5694  res->CleanUp();
5695  return TRUE;
5696  }
5697  }
5698  }
5699  return FALSE;
5700 }
5702 {
5704  memcpy(v->next,w,sizeof(sleftv));
5705  memset(w,0,sizeof(sleftv));
5706  return jjPROC(res,u,v);
5707 }
5709 {
5710  u->next=(leftv)omAlloc(sizeof(sleftv));
5711  memcpy(u->next,v,sizeof(sleftv));
5712  memset(v,0,sizeof(sleftv));
5713  u->next->next=(leftv)omAlloc(sizeof(sleftv));
5714  memcpy(u->next->next,w,sizeof(sleftv));
5715  memset(w,0,sizeof(sleftv));
5716  BOOLEAN bo=iiExprArithM(res,u,'[');
5717  u->next=NULL;
5718  return bo;
5719 }
5721 {
5722  intvec *iv;
5723  ideal m;
5725  int k=(int)(long)w->Data();
5726  if (k>=0)
5727  {
5728  sm_CallBareiss((ideal)u->Data(),(int)(long)v->Data(),(int)(long)w->Data(),m,&iv, currRing);
5729  l->Init(2);
5730  l->m[0].rtyp=MODUL_CMD;
5731  l->m[1].rtyp=INTVEC_CMD;
5732  l->m[0].data=(void *)m;
5733  l->m[1].data=(void *)iv;
5734  }
5735  else
5736  {
5737  m=sm_CallSolv((ideal)u->Data(), currRing);
5738  l->Init(1);
5739  l->m[0].rtyp=IDEAL_CMD;
5740  l->m[0].data=(void *)m;
5741  }
5742  res->data = (char *)l;
5743  return FALSE;
5744 }
5746 {
5747  if ((w->rtyp!=IDHDL)||(w->e!=NULL))
5748  {
5749  WerrorS("3rd argument must be a name of a matrix");
5750  return TRUE;
5751  }
5752  ideal i=(ideal)u->Data();
5753  int rank=(int)i->rank;
5754  BOOLEAN r=jjCOEFFS_Id(res,u,v);
5755  if (r) return TRUE;
5756  mp_Monomials((matrix)res->data, rank, pVar((poly)v->Data()),(matrix)w->Data(),currRing);
5757  return FALSE;
5758 }
5760 {
5761  res->data=(void*)idCoeffOfKBase((ideal)(u->Data()),
5762  (ideal)(v->Data()),(poly)(w->Data()));
5763  return FALSE;
5764 }
5766 {
5767  if ((w->rtyp!=IDHDL)||(w->e!=NULL))
5768  {
5769  WerrorS("3rd argument must be a name of a matrix");
5770  return TRUE;
5771  }
5772  // CopyD for POLY_CMD and VECTOR_CMD are identical:
5773  poly p=(poly)u->CopyD(POLY_CMD);
5774  ideal i=idInit(1,1);
5775  i->m[0]=p;
5776  sleftv t;
5777  memset(&t,0,sizeof(t));
5778  t.data=(char *)i;
5779  t.rtyp=IDEAL_CMD;
5780  int rank=1;
5781  if (u->Typ()==VECTOR_CMD)
5782  {
5783  i->rank=rank=pMaxComp(p);
5784  t.rtyp=MODUL_CMD;
5785  }
5786  BOOLEAN r=jjCOEFFS_Id(res,&t,v);
5787  t.CleanUp();
5788  if (r) return TRUE;
5789  mp_Monomials((matrix)res->data, rank, pVar((poly)v->Data()),(matrix)w->Data(),currRing);
5790  return FALSE;
5791 }
5793 {
5794  ideal I=(ideal)u->Data();
5795  GbVariant alg=syGetAlgorithm((char*)w->Data(),currRing,I);
5796  res->data=(char *)idElimination(I,(poly)v->Data(),NULL,alg);
5797  //setFlag(res,FLAG_STD);
5798  return v->next!=NULL; //do not allow next like in eliminate(I,a(1..4))
5799 }
5801 {
5802  res->data=(char *)idElimination((ideal)u->Data(),(poly)v->Data(),
5803  (intvec *)w->Data());
5804  //setFlag(res,FLAG_STD);
5805  return FALSE;
5806 }
5808 {
5809  /*4
5810  * look for the substring what in the string where
5811  * starting at position n
5812  * return the position of the first char of what in where
5813  * or 0
5814  */
5815  int n=(int)(long)w->Data();
5816  char *where=(char *)u->Data();
5817  char *what=(char *)v->Data();
5818  char *found;
5819  if ((1>n)||(n>(int)strlen(where)))
5820  {
5821  Werror("start position %d out of range",n);
5822  return TRUE;
5823  }
5824  found = strchr(where+n-1,*what);
5825  if (*(what+1)!='\0')
5826  {
5827  while((found !=NULL) && (strncmp(found+1,what+1,strlen(what+1))!=0))
5828  {
5829  found=strchr(found+1,*what);
5830  }
5831  }
5832  if (found != NULL)
5833  {
5834  res->data=(char *)((found-where)+1);
5835  }
5836  return FALSE;
5837 }
5839 {
5840  if ((int)(long)w->Data()==0)
5841  res->data=(char *)walkProc(u,v);
5842  else
5843  res->data=(char *)fractalWalkProc(u,v);
5844  setFlag( res, FLAG_STD );
5845  return FALSE;
5846 }
5848 {
5849  intvec *wdegree=(intvec*)w->Data();
5850  if (wdegree->length()!=currRing->N)
5851  {
5852  Werror("weight vector must have size %d, not %d",
5853  currRing->N,wdegree->length());
5854  return TRUE;
5855  }
5856 #ifdef HAVE_RINGS
5857  if (rField_is_Z(currRing))
5858  {
5859  PrintS("// NOTE: computation of Hilbert series etc. is being\n");
5860  PrintS("// performed for generic fibre, that is, over Q\n");
5861  }
5862 #endif
5863  assumeStdFlag(u);
5864  intvec *module_w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
5865  intvec *iv=hFirstSeries((ideal)u->Data(),module_w,currRing->qideal,wdegree);
5866  if (errorreported) return TRUE;
5867 
5868  switch((int)(long)v->Data())
5869  {
5870  case 1:
5871  res->data=(void *)iv;
5872  return FALSE;
5873  case 2:
5874  res->data=(void *)hSecondSeries(iv);
5875  delete iv;
5876  return FALSE;
5877  }
5878  delete iv;
5880  return TRUE;
5881 }
5883 {
5884  PrintS("TODO\n");
5885  int i=pVar((poly)v->Data());
5886  if (i==0)
5887  {
5888  WerrorS("ringvar expected");
5889  return TRUE;
5890  }
5891  poly p=pOne(); pSetExp(p,i,1); pSetm(p);
5892  int d=pWTotaldegree(p);
5893  pLmDelete(p);
5894  if (d==1)
5895  res->data = (char *)id_Homogen((ideal)u->Data(), i, currRing);
5896  else
5897  WerrorS("variable must have weight 1");
5898  return (d!=1);
5899 }
5901 {
5902  PrintS("TODO\n");
5903  int i=pVar((poly)v->Data());
5904  if (i==0)
5905  {
5906  WerrorS("ringvar expected");
5907  return TRUE;
5908  }
5909  poly p=pOne(); pSetExp(p,i,1); pSetm(p);
5910  int d=pWTotaldegree(p);
5911  pLmDelete(p);
5912  if (d==1)
5913  res->data = (char *)p_Homogen((poly)u->Data(), i, currRing);
5914  else
5915  WerrorS("variable must have weight 1");
5916  return (d!=1);
5917 }
5919 {
5920  intvec* im= new intvec((int)(long)v->Data(),(int)(long)w->Data(), 0);
5921  intvec* arg = (intvec*) u->Data();
5922  int i, n = si_min(im->cols()*im->rows(), arg->cols()*arg->rows());
5923 
5924  for (i=0; i<n; i++)
5925  {
5926  (*im)[i] = (*arg)[i];
5927  }
5928 
5929  res->data = (char *)im;
5930  return FALSE;
5931 }
5933 {
5934  ideal I1=(ideal)u->Data();
5935  ideal I2=(ideal)v->Data();
5936  ideal I3=(ideal)w->Data();
5937  resolvente r=(resolvente)omAlloc0(3*sizeof(ideal));
5938  r[0]=I1;
5939  r[1]=I2;
5940  r[2]=I3;
5941  res->data=(char *)idMultSect(r,3);
5942  omFreeSize((ADDRESS)r,3*sizeof(ideal));
5943  return FALSE;
5944 }
5946 {
5947  ideal I=(ideal)u->Data();
5948  GbVariant alg=syGetAlgorithm((char*)w->Data(),currRing,I);
5949  res->data=(char *)idSect(I,(ideal)v->Data(),alg);
5951  return FALSE;
5952 }
5954 {
5955  short *iw=iv2array((intvec *)w->Data(),currRing);
5956  res->data = (char *)ppJetW((poly)u->Data(),(int)(long)v->Data(),iw);
5957  omFreeSize( (ADDRESS)iw, (rVar(currRing)+1)*sizeof(short) );
5958  return FALSE;
5959 }
5961 {
5962  if (!pIsUnit((poly)v->Data()))
5963  {
5964  WerrorS("2nd argument must be a unit");
5965  return TRUE;
5966  }
5967  res->data = (char *)p_Series((int)(long)w->Data(),(poly)u->CopyD(),(poly)v->CopyD(),NULL,currRing);
5968  return FALSE;
5969 }
5971 {
5972  res->data = (char *)id_JetW((ideal)u->Data(),(int)(long)v->Data(),
5973  (intvec *)w->Data(),currRing);
5974  return FALSE;
5975 }
5977 {
5978  if (!mp_IsDiagUnit((matrix)v->Data(), currRing))
5979  {
5980  WerrorS("2nd argument must be a diagonal matrix of units");
5981  return TRUE;
5982  }
5983  res->data = (char *)idSeries((int)(long)w->Data(),(ideal)u->CopyD(),
5984  (matrix)v->CopyD());
5985  return FALSE;
5986 }
5988 {
5989  /* Here's the use pattern for the minor command:
5990  minor ( matrix_expression m, int_expression minorSize,
5991  optional ideal_expression IasSB, optional int_expression k,
5992  optional string_expression algorithm,
5993  optional int_expression cachedMinors,
5994  optional int_expression cachedMonomials )
5995  This method here assumes that there are at least two arguments.
5996  - If IasSB is present, it must be a std basis. All minors will be
5997  reduced w.r.t. IasSB.
5998  - If k is absent, all non-zero minors will be computed.
5999  If k is present and k > 0, the first k non-zero minors will be
6000  computed.
6001  If k is present and k < 0, the first |k| minors (some of which
6002  may be zero) will be computed.
6003  If k is present and k = 0, an error is reported.
6004  - If algorithm is absent, all the following arguments must be absent too.
6005  In this case, a heuristic picks the best-suited algorithm (among
6006  Bareiss, Laplace, and Laplace with caching).
6007  If algorithm is present, it must be one of "Bareiss", "bareiss",
6008  "Laplace", "laplace", "Cache", "cache". In the cases "Cache" and
6009  "cache" two more arguments may be given, determining how many entries
6010  the cache may have at most, and how many cached monomials there are at
6011  most. (Cached monomials are counted over all cached polynomials.)
6012  If these two additional arguments are not provided, 200 and 100000
6013  will be used as defaults.
6014  */
6015  matrix m;
6016  leftv u=v->next;
6017  v->next=NULL;
6018  int v_typ=v->Typ();
6019  if (v_typ==MATRIX_CMD)
6020  {
6021  m = (const matrix)v->Data();
6022  }
6023  else
6024  {
6025  if (v_typ==0)
6026  {
6027  Werror("`%s` is undefined",v->Fullname());
6028  return TRUE;
6029  }
6030  // try to convert to MATRIX:
6031  int ii=iiTestConvert(v_typ,MATRIX_CMD);
6032  BOOLEAN bo;
6033  sleftv tmp;
6034  if (ii>0) bo=iiConvert(v_typ,MATRIX_CMD,ii,v,&tmp);
6035  else bo=TRUE;
6036  if (bo)
6037  {
6038  Werror("cannot convert %s to matrix",Tok2Cmdname(v_typ));
6039  return TRUE;
6040  }
6041  m=(matrix)tmp.data;
6042  }
6043  const int mk = (const int)(long)u->Data();
6044  bool noIdeal = true; bool noK = true; bool noAlgorithm = true;
6045  bool noCacheMinors = true; bool noCacheMonomials = true;
6046  ideal IasSB; int k; char* algorithm; int cacheMinors; int cacheMonomials;
6047 
6048  /* here come the different cases of correct argument sets */
6049  if ((u->next != NULL) && (u->next->Typ() == IDEAL_CMD))
6050  {
6051  IasSB = (ideal)u->next->Data();
6052  noIdeal = false;
6053  if ((u->next->next != NULL) && (u->next->next->Typ() == INT_CMD))
6054  {
6055  k = (int)(long)u->next->next->Data();
6056  noK = false;
6057  assume(k != 0);
6058  if ((u->next->next->next != NULL) &&
6059  (u->next->next->next->Typ() == STRING_CMD))
6060  {
6061  algorithm = (char*)u->next->next->next->Data();
6062  noAlgorithm = false;
6063  if ((u->next->next->next->next != NULL) &&
6064  (u->next->next->next->next->Typ() == INT_CMD))
6065  {
6066  cacheMinors = (int)(long)u->next->next->next->next->Data();
6067  noCacheMinors = false;
6068  if ((u->next->next->next->next->next != NULL) &&
6069  (u->next->next->next->next->next->Typ() == INT_CMD))
6070  {
6071  cacheMonomials =
6072  (int)(long)u->next->next->next->next->next->Data();
6073  noCacheMonomials = false;
6074  }
6075  }
6076  }
6077  }
6078  }
6079  else if ((u->next != NULL) && (u->next->Typ() == INT_CMD))
6080  {
6081  k = (int)(long)u->next->Data();
6082  noK = false;
6083  assume(k != 0);
6084  if ((u->next->next != NULL) && (u->next->next->Typ() == STRING_CMD))
6085  {
6086  algorithm = (char*)u->next->next->Data();
6087  noAlgorithm = false;
6088  if ((u->next->next->next != NULL) &&
6089  (u->next->next->next->Typ() == INT_CMD))
6090  {
6091  cacheMinors = (int)(long)u->next->next->next->Data();
6092  noCacheMinors = false;
6093  if ((u->next->next->next->next != NULL) &&
6094  (u->next->next->next->next->Typ() == INT_CMD))
6095  {
6096  cacheMonomials = (int)(long)u->next->next->next->next->Data();
6097  noCacheMonomials = false;
6098  }
6099  }
6100  }
6101  }
6102  else if ((u->next != NULL) && (u->next->Typ() == STRING_CMD))
6103  {
6104  algorithm = (char*)u->next->Data();
6105  noAlgorithm = false;
6106  if ((u->next->next != NULL) && (u->next->next->Typ() == INT_CMD))
6107  {
6108  cacheMinors = (int)(long)u->next->next->Data();
6109  noCacheMinors = false;
6110  if ((u->next->next->next != NULL) &&
6111  (u->next->next->next->Typ() == INT_CMD))
6112  {
6113  cacheMonomials = (int)(long)u->next->next->next->Data();
6114  noCacheMonomials = false;
6115  }
6116  }
6117  }
6118 
6119  /* upper case conversion for the algorithm if present */
6120  if (!noAlgorithm)
6121  {
6122  if (strcmp(algorithm, "bareiss") == 0)
6123  algorithm = (char*)"Bareiss";
6124  if (strcmp(algorithm, "laplace") == 0)
6125  algorithm = (char*)"Laplace";
6126  if (strcmp(algorithm, "cache") == 0)
6127  algorithm = (char*)"Cache";
6128  }
6129 
6130  v->next=u;
6131  /* here come some tests */
6132  if (!noIdeal)
6133  {
6134  assumeStdFlag(u->next);
6135  }
6136  if ((!noK) && (k == 0))
6137  {
6138  WerrorS("Provided number of minors to be computed is zero.");
6139  return TRUE;
6140  }
6141  if ((!noAlgorithm) && (strcmp(algorithm, "Bareiss") != 0)
6142  && (strcmp(algorithm, "Laplace") != 0)
6143  && (strcmp(algorithm, "Cache") != 0))
6144  {
6145  WerrorS("Expected as algorithm one of 'B/bareiss', 'L/laplace', or 'C/cache'.");
6146  return TRUE;
6147  }
6148  if ((!noAlgorithm) && (strcmp(algorithm, "Bareiss") == 0)
6149  && (!rField_is_Domain(currRing)))
6150  {
6151  Werror("Bareiss algorithm not defined over coefficient rings %s",
6152  "with zero divisors.");
6153  return TRUE;
6154  }
6155  res->rtyp=IDEAL_CMD;
6156  if ((mk < 1) || (mk > m->rows()) || (mk > m->cols()))
6157  {
6158  ideal I=idInit(1,1);
6159  if (mk<1) I->m[0]=p_One(currRing);
6160  //Werror("invalid size of minors: %d (matrix is (%d x %d))", mk,
6161  // m->rows(), m->cols());
6162  res->data=(void*)I;
6163  return FALSE;
6164  }
6165  if ((!noAlgorithm) && (strcmp(algorithm, "Cache") == 0)
6166  && (noCacheMinors || noCacheMonomials))
6167  {
6168  cacheMinors = 200;
6169  cacheMonomials = 100000;
6170  }
6171 
6172  /* here come the actual procedure calls */
6173  if (noAlgorithm)
6174  res->data = getMinorIdealHeuristic(m, mk, (noK ? 0 : k),
6175  (noIdeal ? 0 : IasSB), false);
6176  else if (strcmp(algorithm, "Cache") == 0)
6177  res->data = getMinorIdealCache(m, mk, (noK ? 0 : k),
6178  (noIdeal ? 0 : IasSB), 3, cacheMinors,
6179  cacheMonomials, false);
6180  else
6181  res->data = getMinorIdeal(m, mk, (noK ? 0 : k), algorithm,
6182  (noIdeal ? 0 : IasSB), false);
6183  if (v_typ!=MATRIX_CMD) idDelete((ideal *)&m);
6184  return FALSE;
6185 }
6187 {
6188  // u: the name of the new type
6189  // v: the parent type
6190  // w: the elements
6191  newstruct_desc d=newstructChildFromString((const char *)v->Data(),
6192  (const char *)w->Data());
6193  if (d!=NULL) newstruct_setup((const char *)u->Data(),d);
6194  return (d==NULL);
6195 }
6197 {
6198  // handles preimage(r,phi,i) and kernel(r,phi)
6199  idhdl h;
6200  ring rr;
6201  map mapping;
6202  BOOLEAN kernel_cmd= (iiOp==KERNEL_CMD);
6203 
6204  if ((v->name==NULL) || (!kernel_cmd && (w->name==NULL)))
6205  {
6206  WerrorS("2nd/3rd arguments must have names");
6207  return TRUE;
6208  }
6209  rr=(ring)u->Data();
6210  const char *ring_name=u->Name();
6211  if ((h=rr->idroot->get(v->name,myynest))!=NULL)
6212  {
6213  if (h->typ==MAP_CMD)
6214  {
6215  mapping=IDMAP(h);
6216  idhdl preim_ring=IDROOT->get(mapping->preimage,myynest);
6217  if ((preim_ring==NULL)
6218  || (IDRING(preim_ring)!=currRing))
6219  {
6220  Werror("preimage ring `%s` is not the basering",mapping->preimage);
6221  return TRUE;
6222  }
6223  }
6224  else if (h->typ==IDEAL_CMD)
6225  {
6226  mapping=IDMAP(h);
6227  }
6228  else
6229  {
6230  Werror("`%s` is no map nor ideal",IDID(h));
6231  return TRUE;
6232  }
6233  }
6234  else
6235  {
6236  Werror("`%s` is not defined in `%s`",v->name,ring_name);
6237  return TRUE;
6238  }
6239  ideal image;
6240  if (kernel_cmd) image=idInit(1,1);
6241  else
6242  {
6243  if ((h=rr->idroot->get(w->name,myynest))!=NULL)
6244  {
6245  if (h->typ==IDEAL_CMD)
6246  {
6247  image=IDIDEAL(h);
6248  }
6249  else
6250  {
6251  Werror("`%s` is no ideal",IDID(h));
6252  return TRUE;
6253  }
6254  }
6255  else
6256  {
6257  Werror("`%s` is not defined in `%s`",w->name,ring_name);
6258  return TRUE;
6259  }
6260  }
6261  if (((currRing->qideal!=NULL) && (rHasLocalOrMixedOrdering(currRing)))
6262  || ((rr->qideal!=NULL) && (rHasLocalOrMixedOrdering(rr))))
6263  {
6264  WarnS("preimage in local qring may be wrong: use Ring::preimageLoc instead");
6265  }
6266  res->data=(char *)maGetPreimage(rr,mapping,image,currRing);
6267  if (kernel_cmd) idDelete(&image);
6268  return (res->data==NULL/* is of type ideal, should not be NULL*/);
6269 }
6271 {
6272  int di, k;
6273  int i=(int)(long)u->Data();
6274  int r=(int)(long)v->Data();
6275  int c=(int)(long)w->Data();
6276  if ((r<=0) || (c<=0)) return TRUE;
6277  intvec *iv = new intvec(r, c, 0);
6278  if (iv->rows()==0)
6279  {
6280  delete iv;
6281  return TRUE;
6282  }
6283  if (i!=0)
6284  {
6285  if (i<0) i = -i;
6286  di = 2 * i + 1;
6287  for (k=0; k<iv->length(); k++)
6288  {
6289  (*iv)[k] = ((siRand() % di) - i);
6290  }
6291  }
6292  res->data = (char *)iv;
6293  return FALSE;
6294 }
6295 #ifdef SINGULAR_4_2
6296 static BOOLEAN jjRANDOM_CF(leftv res, leftv u, leftv v, leftv w)
6297 // <coeff>, par1, par2 -> number2
6298 {
6299  coeffs cf=(coeffs)u->Data();
6300  if ((cf==NULL) ||(cf->cfRandom==NULL))
6301  {
6302  Werror("no random function defined for coeff %d",cf->type);
6303  return TRUE;
6304  }
6305  else
6306  {
6307  number n= n_Random(siRand,(number)v->Data(),(number)w->Data(),cf);
6308  number2 nn=(number2)omAlloc(sizeof(*nn));
6309  nn->cf=cf;
6310  nn->n=n;
6311  res->data=nn;
6312  return FALSE;
6313  }
6314  return TRUE;
6315 }
6316 #endif
6318  int &ringvar, poly &monomexpr)
6319 {
6320  monomexpr=(poly)w->Data();
6321  poly p=(poly)v->Data();
6322 #if 0
6323  if (pLength(monomexpr)>1)
6324  {
6325  Werror("`%s` substitutes a ringvar only by a term",
6327  return TRUE;
6328  }
6329 #endif
6330  if ((ringvar=pVar(p))==0)
6331  {
6332  if ((p!=NULL) && (currRing->cf->extRing!=NULL))
6333  {
6334  number n = pGetCoeff(p);
6335  ringvar= -n_IsParam(n, currRing);
6336  }
6337  if(ringvar==0)
6338  {
6339  WerrorS("ringvar/par expected");
6340  return TRUE;
6341  }
6342  }
6343  return FALSE;
6344 }
6346 {
6347  // generic conversion from polyBucket to poly:
6348  // force this to be the first try everytime
6349  poly p; int l;
6350  sBucket_pt bu=(sBucket_pt)w->CopyD();
6351  sBucketDestroyAdd(bu,&p,&l);
6352  sleftv tmpw;
6353  tmpw.Init();
6354  tmpw.rtyp=POLY_CMD;
6355  tmpw.data=p;
6356  return iiExprArith3(res, iiOp, u, v, &tmpw);
6357 }
6359 {
6360  int ringvar;
6361  poly monomexpr;
6362  BOOLEAN nok=jjSUBST_Test(v,w,ringvar,monomexpr);
6363  if (nok) return TRUE;
6364  poly p=(poly)u->Data();
6365  if (ringvar>0)
6366  {
6367  if ((monomexpr!=NULL) && (p!=NULL) && (pTotaldegree(p)!=0) &&
6368  ((unsigned long)pTotaldegree(monomexpr) > (currRing->bitmask / (unsigned long)pTotaldegree(p)/2)))
6369  {
6370  Warn("possible OVERFLOW in subst, max exponent is %ld, substituting deg %d by deg %d",currRing->bitmask/2, pTotaldegree(monomexpr), pTotaldegree(p));
6371  //return TRUE;
6372  }
6373  if ((monomexpr==NULL)||(pNext(monomexpr)==NULL))
6374  res->data = pSubst((poly)u->CopyD(res->rtyp),ringvar,monomexpr);
6375  else
6376  res->data= pSubstPoly(p,ringvar,monomexpr);
6377  }
6378  else
6379  {
6380  res->data=pSubstPar(p,-ringvar,monomexpr);
6381  }
6382  return FALSE;
6383 }
6385 {
6386  int ringvar;
6387  poly monomexpr;
6388  BOOLEAN nok=jjSUBST_Test(v,w,ringvar,monomexpr);
6389  if (nok) return TRUE;
6390  ideal id=(ideal)u->Data();
6391  if (ringvar>0)
6392  {
6393  BOOLEAN overflow=FALSE;
6394  if (monomexpr!=NULL)
6395  {
6396  long deg_monexp=pTotaldegree(monomexpr);
6397  for(int i=IDELEMS(id)-1;i>=0;i--)
6398  {
6399  poly p=id->m[i];
6400  if ((p!=NULL) && (pTotaldegree(p)!=0) &&
6401  ((unsigned long)deg_monexp > (currRing->bitmask / (unsigned long)pTotaldegree(p)/2)))
6402  {
6403  overflow=TRUE;
6404  break;
6405  }
6406  }
6407  }
6408  if (overflow)
6409  Warn("possible OVERFLOW in subst, max exponent is %ld",currRing->bitmask/2);
6410  if ((monomexpr==NULL)||(pNext(monomexpr)==NULL))
6411  {
6412  if (res->rtyp==MATRIX_CMD) id=(ideal)mp_Copy((matrix)id,currRing);
6413  else id=id_Copy(id,currRing);
6414  res->data = id_Subst(id, ringvar, monomexpr, currRing);
6415  }
6416  else
6417  res->data = idSubstPoly(id,ringvar,monomexpr);
6418  }
6419  else
6420  {
6421  res->data = idSubstPar(id,-ringvar,monomexpr);
6422  }
6423  return FALSE;
6424 }
6425 // we do not want to have jjSUBST_Id_X inlined:
6427  int input_type);
6429 {
6430  return jjSUBST_Id_X(res,u,v,w,INT_CMD);
6431 }
6433 {
6434  return jjSUBST_Id_X(res,u,v,w,NUMBER_CMD);
6435 }
6436 static BOOLEAN jjSUBST_Id_X(leftv res, leftv u, leftv v,leftv w, int input_type)
6437 {
6438  sleftv tmp;
6439  memset(&tmp,0,sizeof(tmp));
6440  // do not check the result, conversion from int/number to poly works always
6441  iiConvert(input_type,POLY_CMD,iiTestConvert(input_type,POLY_CMD),w,&tmp);
6442  BOOLEAN b=jjSUBST_Id(res,u,v,&tmp);
6443  tmp.CleanUp();
6444  return b;
6445 }
6447 {
6448  int mi=(int)(long)v->Data();
6449  int ni=(int)(long)w->Data();
6450  if ((mi<1)||(ni<1))
6451  {
6452  Werror("converting ideal to matrix: dimensions must be positive(%dx%d)",mi,ni);
6453  return TRUE;
6454  }
6455  matrix m=mpNew(mi,ni);
6456  ideal I=(ideal)u->CopyD(IDEAL_CMD);
6457  int i=si_min(IDELEMS(I),mi*ni);
6458  //for(i=i-1;i>=0;i--)
6459  //{
6460  // m->m[i]=I->m[i];
6461  // I->m[i]=NULL;
6462  //}
6463  memcpy(m->m,I->m,i*sizeof(poly));
6464  memset(I->m,0,i*sizeof(poly));
6465  id_Delete(&I,currRing);
6466  res->data = (char *)m;
6467  return FALSE;
6468 }
6470 {
6471  int mi=(int)(long)v->Data();
6472  int ni=(int)(long)w->Data();
6473  if ((mi<0)||(ni<1))
6474  {
6475  Werror("converting module to matrix: dimensions must be positive(%dx%d)",mi,ni);
6476  return TRUE;
6477  }
6478  res->data = (char *)id_Module2formatedMatrix((ideal)u->CopyD(MODUL_CMD),
6479  mi,ni,currRing);
6480  return FALSE;
6481 }
6483 {
6484  int mi=(int)(long)v->Data();
6485  int ni=(int)(long)w->Data();
6486  if ((mi<1)||(ni<1))
6487  {
6488  Werror("converting matrix to matrix: dimensions must be positive(%dx%d)",mi,ni);
6489  return TRUE;
6490  }
6491  matrix m=mpNew(mi,ni);
6492  matrix I=(matrix)u->CopyD(MATRIX_CMD);
6493  int r=si_min(MATROWS(I),mi);
6494  int c=si_min(MATCOLS(I),ni);
6495  int i,j;
6496  for(i=r;i>0;i--)
6497  {
6498  for(j=c;j>0;j--)
6499  {
6500  MATELEM(m,i,j)=MATELEM(I,i,j);
6501  MATELEM(I,i,j)=NULL;
6502  }
6503  }
6504  id_Delete((ideal *)&I,currRing);
6505  res->data = (char *)m;
6506  return FALSE;
6507 }
6509 {
6510  int mi=(int)(long)v->Data();
6511  int ni=(int)(long)w->Data();
6512  if ((mi<0)||(ni<1))
6513  {
6514  Werror("converting to smatrix: dimensions must be positive(%dx%d)",mi,ni);
6515  return TRUE;
6516  }
6517  res->data = (char *)id_ResizeModule((ideal)u->CopyD(),
6518  mi,ni,currRing);
6519  return FALSE;
6520 }
6522 {
6523  if (w->rtyp!=IDHDL) return TRUE;
6524  int ul= IDELEMS((ideal)u->Data());
6525  int vl= IDELEMS((ideal)v->Data());
6526  ideal m
6527  = idLift((ideal)u->Data(),(ideal)v->Data(),NULL,FALSE,hasFlag(u,FLAG_STD),
6528  FALSE, (matrix *)(&(IDMATRIX((idhdl)(w->data)))));
6529  if (m==NULL) return TRUE;
6530  res->data = (char *)id_Module2formatedMatrix(m,ul,vl,currRing);
6531  return FALSE;
6532 }
6534 {
6535  if ((v->rtyp!=IDHDL)||(v->e!=NULL)) return TRUE;
6536  if ((w->rtyp!=IDHDL)||(w->e!=NULL)) return TRUE;
6537  idhdl hv=(idhdl)v->data;
6538  idhdl hw=(idhdl)w->data;
6539  // CopyD for IDEAL_CMD and MODUL_CMD are identical:
6540  res->data = (char *)idLiftStd((ideal)u->Data(),
6541  &(hv->data.umatrix),testHomog,
6542  &(hw->data.uideal));
6543  setFlag(res,FLAG_STD); v->flag=0; w->flag=0;
6544  return FALSE;
6545 }
6547 {
6548  assumeStdFlag(v);
6549  if (!idIsZeroDim((ideal)v->Data()))
6550  {
6551  Werror("`%s` must be 0-dimensional",v->Name());
6552  return TRUE;
6553  }
6554  res->data = (char *)redNF((ideal)v->CopyD(),(poly)u->CopyD(),
6555  (poly)w->CopyD());
6556  return FALSE;
6557 }
6559 {
6560  assumeStdFlag(v);
6561  if (!idIsZeroDim((ideal)v->Data()))
6562  {
6563  Werror("`%s` must be 0-dimensional",v->Name());
6564  return TRUE;
6565  }
6566  res->data = (char *)redNF((ideal)v->CopyD(),(ideal)u->CopyD(),
6567  (matrix)w->CopyD());
6568  return FALSE;
6569 }
6571 {
6572  assumeStdFlag(v);
6573  res->data = (char *)kNF((ideal)v->Data(),currRing->qideal,(poly)u->Data(),
6574  0,(int)(long)w->Data());
6575  return FALSE;
6576 }
6578 {
6579  assumeStdFlag(v);
6580  res->data = (char *)kNF((ideal)v->Data(),currRing->qideal,(ideal)u->Data(),
6581  0,(int)(long)w->Data());
6582  return FALSE;
6583 }
6584 #ifdef OLD_RES
6586 {
6587  int maxl=(int)v->Data();
6588  ideal u_id=(ideal)u->Data();
6589  int l=0;
6590  resolvente r;
6591  intvec **weights=NULL;
6592  int wmaxl=maxl;
6593  maxl--;
6594  if ((maxl==-1) && (iiOp!=MRES_CMD))
6595  maxl = currRing->N-1;
6596  if ((iiOp == RES_CMD) || (iiOp == MRES_CMD))
6597  {
6598  intvec * iv=(intvec*)atGet(u,"isHomog",INTVEC_CMD);
6599  if (iv!=NULL)
6600  {
6601  l=1;
6602  if (!idTestHomModule(u_id,currRing->qideal,iv))
6603  {
6604  WarnS("wrong weights");
6605  iv=NULL;
6606  }
6607  else
6608  {
6609  weights = (intvec**)omAlloc0Bin(char_ptr_bin);
6610  weights[0] = ivCopy(iv);
6611  }
6612  }
6613  r=syResolvente(u_id,maxl,&l, &weights, iiOp==MRES_CMD);
6614  }
6615  else
6616  r=sySchreyerResolvente((ideal)u->Data(),maxl+1,&l);
6617  if (r==NULL) return TRUE;
6618  int t3=u->Typ();
6619  iiMakeResolv(r,l,wmaxl,w->name,t3,weights);
6620  return FALSE;
6621 }
6622 #endif
6624 {
6625  res->data=(void *)rInit(u,v,w);
6626  return (res->data==NULL);
6627 }
6629 {
6630  int yes;
6631  jjSTATUS2(res, u, v);
6632  yes = (strcmp((char *) res->data, (char *) w->Data()) == 0);
6633  omFree((ADDRESS) res->data);
6634  res->data = (void *)(long)yes;
6635  return FALSE;
6636 }
6638 {
6639  intvec *vw=(intvec *)w->Data(); // weights of vars
6640  if (vw->length()!=currRing->N)
6641  {
6642  Werror("%d weights for %d variables",vw->length(),currRing->N);
6643  return TRUE;
6644  }
6645  ideal result;
6646  intvec *ww=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
6647  tHomog hom=testHomog;
6648  ideal u_id=(ideal)(u->Data());
6649  if (ww!=NULL)
6650  {
6651  if (!idTestHomModule(u_id,currRing->qideal,ww))
6652  {
6653  WarnS("wrong weights");
6654  ww=NULL;
6655  }
6656  else
6657  {
6658  ww=ivCopy(ww);
6659  hom=isHomog;
6660  }
6661  }
6662  result=kStd(u_id,
6663  currRing->qideal,
6664  hom,
6665  &ww, // module weights
6666  (intvec *)v->Data(), // hilbert series
6667  0,0, // syzComp, newIdeal
6668  vw); // weights of vars
6670  res->data = (char *)result;
6671  setFlag(res,FLAG_STD);
6672  if (ww!=NULL) atSet(res,omStrDup("isHomog"),ww,INTVEC_CMD);
6673  return FALSE;
6674 }
6675 
6676 /*=================== operations with many arg.: static proc =================*/
6677 /* must be ordered: first operations for chars (infix ops),
6678  * then alphabetically */
6680 {
6681 #ifdef HAVE_SDB
6682  sdb_show_bp();
6683 #endif
6684  return FALSE;
6685 }
6687 {
6688 #ifdef HAVE_SDB
6689  if(v->Typ()==PROC_CMD)
6690  {
6691  int lineno=0;
6692  if((v->next!=NULL) && (v->next->Typ()==INT_CMD))
6693  {
6694  lineno=(int)(long)v->next->Data();
6695  }
6696  return sdb_set_breakpoint(v->Name(),lineno);
6697  }
6698  return TRUE;
6699 #else
6700  return FALSE;
6701 #endif
6702 }
6704 {
6705  return iiExprArith1(res,v,iiOp);
6706 }
6708 {
6709  leftv v=u->next;
6710  u->next=NULL;
6711  BOOLEAN b=iiExprArith2(res,u,iiOp,v, (iiOp > 255));
6712  u->next=v;
6713  return b;
6714 }
6716 {
6717  leftv v = u->next;
6718  leftv w = v->next;
6719  u->next = NULL;
6720  v->next = NULL;
6721  BOOLEAN b = iiExprArith3(res, iiOp, u, v, w);
6722  u->next = v;
6723  v->next = w;
6724  return b;
6725 }
6726 
6728 {
6729  const short t[]={4,VECTOR_CMD,POLY_CMD,MATRIX_CMD,MATRIX_CMD};
6730  if (iiCheckTypes(v,t,1))
6731  {
6732  idhdl c=(idhdl)v->next->next->data;
6733  if (v->next->next->next->rtyp!=IDHDL) return TRUE;
6734  idhdl m=(idhdl)v->next->next->next->data;
6735  idDelete((ideal *)&(c->data.uideal));
6736  idDelete((ideal *)&(m->data.uideal));
6737  mp_Coef2((poly)v->Data(),(poly)v->next->Data(),
6738  (matrix *)&(c->data.umatrix),(matrix *)&(m->data.umatrix),currRing);
6739  return FALSE;
6740  }
6741  return TRUE;
6742 }
6743 
6745 { // may have 3 or 4 arguments
6746  leftv v1=v;
6747  leftv v2=v1->next;
6748  leftv v3=v2->next;
6749  leftv v4=v3->next;
6750  assumeStdFlag(v2);
6751 
6752  int i1=iiTestConvert(v1->Typ(),MODUL_CMD);
6753  int i2=iiTestConvert(v2->Typ(),MODUL_CMD);
6754 
6755  if((i1==0)||(i2==0)
6756  ||(v3->Typ()!=INT_CMD)||((v4!=NULL)&&(v4->Typ()!=INTVEC_CMD)))
6757  {
6758  WarnS("<module>,<module>,<int>[,<intvec>] expected!");
6759  return TRUE;
6760  }
6761 
6762  sleftv w1,w2;
6763  iiConvert(v1->Typ(),MODUL_CMD,i1,v1,&w1);
6764  iiConvert(v2->Typ(),MODUL_CMD,i2,v2,&w2);
6765  ideal P=(ideal)w1.Data();
6766  ideal Q=(ideal)w2.Data();
6767 
6768  int n=(int)(long)v3->Data();
6769  short *w=NULL;
6770  if(v4!=NULL)
6771  {
6772  w = iv2array((intvec *)v4->Data(),currRing);
6773  short * w0 = w + 1;
6774  int i = currRing->N;
6775  while( (i > 0) && ((*w0) > 0) )
6776  {
6777  w0++;
6778  i--;
6779  }
6780  if(i>0)
6781  WarnS("not all weights are positive!");
6782  }
6783 
6784  matrix T;
6785  ideal R;
6786  idLiftW(P,Q,n,T,R,w);
6787 
6788  w1.CleanUp();
6789  w2.CleanUp();
6790  if(w!=NULL)
6791  omFreeSize( (ADDRESS)w, (rVar(currRing)+1)*sizeof(short) );
6792 
6794  L->Init(2);
6795  L->m[1].rtyp=v1->Typ();
6796  if(v1->Typ()==POLY_CMD||v1->Typ()==VECTOR_CMD)
6797  {
6798  if(v1->Typ()==POLY_CMD)
6799  p_Shift(&R->m[0],-1,currRing);
6800  L->m[1].data=(void *)R->m[0];
6801  R->m[0]=NULL;
6802  idDelete(&R);
6803  }
6804  else if(v1->Typ()==IDEAL_CMD||v1->Typ()==MATRIX_CMD)
6805  L->m[1].data=(void *)id_Module2Matrix(R,currRing);
6806  else
6807  {
6808  L->m[1].rtyp=MODUL_CMD;
6809  L->m[1].data=(void *)R;
6810  }
6811  L->m[0].rtyp=MATRIX_CMD;
6812  L->m[0].data=(char *)T;
6813 
6814  res->data=L;
6815  res->rtyp=LIST_CMD;
6816 
6817  return FALSE;
6818 }
6819 
6820 //BOOLEAN jjDISPATCH(leftv res, leftv v)
6821 //{
6822 // WerrorS("`dispatch`: not implemented");
6823 // return TRUE;
6824 //}
6825 
6826 //static BOOLEAN jjEXPORTTO_M(leftv res, leftv u)
6827 //{
6828 // int l=u->listLength();
6829 // if (l<2) return TRUE;
6830 // BOOLEAN b;
6831 // leftv v=u->next;
6832 // leftv zz=v;
6833 // leftv z=zz;
6834 // u->next=NULL;
6835 // do
6836 // {
6837 // leftv z=z->next;
6838 // b=iiExprArith2(res,u,iiOp,z, (iiOp > 255));
6839 // if (b) break;
6840 // } while (z!=NULL);
6841 // u->next=zz;
6842 // return b;
6843 //}
6845 {
6846  int s=1;
6847  leftv h=v;
6848  if (h!=NULL) s=exprlist_length(h);
6849  ideal id=idInit(s,1);
6850  int rank=1;
6851  int i=0;
6852  poly p;
6853  int dest_type=POLY_CMD;
6854  if (iiOp==MODUL_CMD) dest_type=VECTOR_CMD;
6855  while (h!=NULL)
6856  {
6857  // use standard type conversions to poly/vector
6858  int ri;
6859  int ht=h->Typ();
6860  if (ht==dest_type)
6861  {
6862  p=(poly)h->CopyD();
6863  if (p!=NULL) rank=si_max(rank,(int)pMaxComp(p));
6864  }
6865  else if ((ri=iiTestConvert(ht,dest_type,dConvertTypes))!=0)
6866  {
6867  sleftv tmp;
6868  leftv hnext=h->next;
6869  h->next=NULL;
6870  iiConvert(ht,dest_type,ri,h,&tmp,dConvertTypes);
6871  h->next=hnext;
6872  p=(poly)tmp.data;
6873  if (p!=NULL) rank=si_max(rank,(int)pMaxComp(p));
6874  }
6875  else
6876  {
6877  idDelete(&id);
6878  return TRUE;
6879  }
6880  id->m[i]=p;
6881  i++;
6882  h=h->next;
6883  }
6884  id->rank=rank;
6885  res->data=(char *)id;
6886  return FALSE;
6887 }
6889 {
6890  ring r=(ring)u->Data();
6891  leftv v=u->next;
6892  leftv perm_var_l=v->next;
6893  leftv perm_par_l=v->next->next;
6894  if ((perm_var_l->Typ()!=INTVEC_CMD)
6895  ||((perm_par_l!=NULL)&&(perm_par_l->Typ()!=INTVEC_CMD))
6896  ||(u->Typ()!=RING_CMD))
6897  {
6898  WerrorS("fetch(<ring>,<name>[,<intvec>[,<intvec>])");
6899  return TRUE;
6900  }
6901  intvec *perm_var_v=(intvec*)perm_var_l->Data();
6902  intvec *perm_par_v=NULL;
6903  if (perm_par_l!=NULL)
6904  perm_par_v=(intvec*)perm_par_l->Data();
6905  idhdl w;
6906  nMapFunc nMap;
6907 
6908  if ((w=r->idroot->get(v->Name(),myynest))!=NULL)
6909  {
6910  int *perm=NULL;
6911  int *par_perm=NULL;
6912  int par_perm_size=0;
6913  BOOLEAN bo;
6914  if ((nMap=n_SetMap(r->cf,currRing->cf))==NULL)
6915  {
6916  // Allow imap/fetch to be make an exception only for:
6917  if (nCoeff_is_Extension(r->cf) && // Q(a..) -> Q(a..) || Q || Zp || Zp(a)
6918  ((n_SetMap(r->cf->extRing->cf,currRing->cf)!=NULL)
6919  || (nCoeff_is_Extension(currRing->cf) && (n_SetMap(r->cf->extRing->cf,currRing->cf->extRing->cf)!=NULL))))
6920  {
6921  par_perm_size=rPar(r);
6922  }
6923  else
6924  {
6925  goto err_fetch;
6926  }
6927  }
6928  else
6929  par_perm_size=rPar(r);
6930  perm=(int *)omAlloc0((rVar(r)+1)*sizeof(int));
6931  if (par_perm_size!=0)
6932  par_perm=(int *)omAlloc0(par_perm_size*sizeof(int));
6933  int i;
6934  if (perm_par_l==NULL)
6935  {
6936  if (par_perm_size!=0)
6937  for(i=si_min(rPar(r),rPar(currRing))-1;i>=0;i--) par_perm[i]=-(i+1);
6938  }
6939  else
6940  {
6941  if (par_perm_size==0) WarnS("source ring has no parameters");
6942  else
6943  {
6944  for(i=rPar(r)-1;i>=0;i--)
6945  {
6946  if (i<perm_par_v->length()) par_perm[i]=(*perm_par_v)[i];
6947  if ((par_perm[i]<-rPar(currRing))
6948  || (par_perm[i]>rVar(currRing)))
6949  {
6950  Warn("invalid entry for par %d: %d\n",i,par_perm[i]);
6951  par_perm[i]=0;
6952  }
6953  }
6954  }
6955  }
6956  for(i=rVar(r)-1;i>=0;i--)
6957  {
6958  if (i<perm_var_v->length()) perm[i+1]=(*perm_var_v)[i];
6959  if ((perm[i]<-rPar(currRing))
6960  || (perm[i]>rVar(currRing)))
6961  {
6962  Warn("invalid entry for var %d: %d\n",i,perm[i]);
6963  perm[i]=0;
6964  }
6965  }
6966  if (BVERBOSE(V_IMAP))
6967  {
6968  for(i=1;i<=si_min(rVar(r),rVar(currRing));i++)
6969  {
6970  if (perm[i]>0)
6971  Print("// var nr %d: %s -> var %s\n",i,r->names[i-1],currRing->names[perm[i]-1]);
6972  else if (perm[i]<0)
6973  Print("// var nr %d: %s -> par %s\n",i,r->names[i-1],rParameter(currRing)[-perm[i]-1]);
6974  }
6975  for(i=1;i<=si_min(rPar(r),rPar(currRing));i++) // possibly empty loop
6976  {
6977  if (par_perm[i-1]<0)
6978  Print("// par nr %d: %s -> par %s\n",
6979  i,rParameter(r)[i-1],rParameter(currRing)[-par_perm[i-1]-1]);
6980  else if (par_perm[i-1]>0)
6981  Print("// par nr %d: %s -> var %s\n",
6982  i,rParameter(r)[i-1],currRing->names[par_perm[i-1]-1]);
6983  }
6984  }
6985  if (IDTYP(w)==ALIAS_CMD) w=(idhdl)IDDATA(w);
6986  sleftv tmpW;
6987  memset(&tmpW,0,sizeof(sleftv));
6988  tmpW.rtyp=IDTYP(w);
6989  tmpW.data=IDDATA(w);
6990  if ((bo=maApplyFetch(IMAP_CMD,NULL,res,&tmpW, r,
6991  perm,par_perm,par_perm_size,nMap)))
6992  {
6993  Werror("cannot map %s of type %s(%d)",v->name, Tok2Cmdname(w->typ),w->typ);
6994  }
6995  if (perm!=NULL)
6996  omFreeSize((ADDRESS)perm,(rVar(r)+1)*sizeof(int));
6997  if (par_perm!=NULL)
6998  omFreeSize((ADDRESS)par_perm,par_perm_size*sizeof(int));
6999  return bo;
7000  }
7001  else
7002  {
7003  Werror("identifier %s not found in %s",v->Fullname(),u->Fullname());
7004  }
7005  return TRUE;
7006 err_fetch:
7007  char *s1=nCoeffString(r->cf);
7008  char *s2=nCoeffString(currRing->cf);
7009  Werror("no identity map from %s (%s -> %s)",u->Fullname(),s1,s2);
7010  omFree(s2);omFree(s1);
7011  return TRUE;
7012 }
7014 {
7015  leftv h=v;
7016  int l=v->listLength();
7017  resolvente r=(resolvente)omAlloc0(l*sizeof(ideal));
7018  BOOLEAN *copied=(BOOLEAN *)omAlloc0(l*sizeof(BOOLEAN));
7019  int t=0;
7020  // try to convert to IDEAL_CMD
7021  while (h!=NULL)
7022  {
7023  if (iiTestConvert(h->Typ(),IDEAL_CMD)!=0)
7024  {
7025  t=IDEAL_CMD;
7026  }
7027  else break;
7028  h=h->next;
7029  }
7030  // if failure, try MODUL_CMD
7031  if (t==0)
7032  {
7033  h=v;
7034  while (h!=NULL)
7035  {
7036  if (iiTestConvert(h->Typ(),MODUL_CMD)!=0)
7037  {
7038  t=MODUL_CMD;
7039  }
7040  else break;
7041  h=h->next;
7042  }
7043  }
7044  // check for success in converting
7045  if (t==0)
7046  {
7047  WerrorS("cannot convert to ideal or module");
7048  return TRUE;
7049  }
7050  // call idMultSect
7051  h=v;
7052  int i=0;
7053  sleftv tmp;
7054  while (h!=NULL)
7055  {
7056  if (h->Typ()==t)
7057  {
7058  r[i]=(ideal)h->Data(); /*no copy*/
7059  h=h->next;
7060  }
7061  else if(iiConvert(h->Typ(),t,iiTestConvert(h->Typ(),t),h,&tmp))
7062  {
7063  omFreeSize((ADDRESS)copied,l*sizeof(BOOLEAN));
7064  omFreeSize((ADDRESS)r,l*sizeof(ideal));
7065  Werror("cannot convert arg. %d to %s",i+1,Tok2Cmdname(t));
7066  return TRUE;
7067  }
7068  else
7069  {
7070  r[i]=(ideal)tmp.Data(); /*now it's a copy*/
7071  copied[i]=TRUE;
7072  h=tmp.next;
7073  }
7074  i++;
7075  }
7076  res->rtyp=t;
7077  res->data=(char *)idMultSect(r,i);
7078  while(i>0)
7079  {
7080  i--;
7081  if (copied[i]) idDelete(&(r[i]));
7082  }
7083  omFreeSize((ADDRESS)copied,l*sizeof(BOOLEAN));
7084  omFreeSize((ADDRESS)r,l*sizeof(ideal));
7085  return FALSE;
7086 }
7088 {
7089  /* computation of the inverse of a quadratic matrix A
7090  using the L-U-decomposition of A;
7091  There are two valid parametrisations:
7092  1) exactly one argument which is just the matrix A,
7093  2) exactly three arguments P, L, U which already
7094  realise the L-U-decomposition of A, that is,
7095  P * A = L * U, and P, L, and U satisfy the
7096  properties decribed in method 'jjLU_DECOMP';
7097  see there;
7098  If A is invertible, the list [1, A^(-1)] is returned,
7099  otherwise the list [0] is returned. Thus, the user may
7100  inspect the first entry of the returned list to see
7101  whether A is invertible. */
7102  matrix iMat; int invertible;
7103  const short t1[]={1,MATRIX_CMD};
7104  const short t2[]={3,MATRIX_CMD,MATRIX_CMD,MATRIX_CMD};
7105  if (iiCheckTypes(v,t1))
7106  {
7107  matrix aMat = (matrix)v->Data();
7108  int rr = aMat->rows();
7109  int cc = aMat->cols();
7110  if (rr != cc)
7111  {
7112  Werror("given matrix (%d x %d) is not quadratic, hence not invertible", rr, cc);
7113  return TRUE;
7114  }
7115  if (!idIsConstant((ideal)aMat))
7116  {
7117  WerrorS("matrix must be constant");
7118  return TRUE;
7119  }
7120  invertible = luInverse(aMat, iMat);
7121  }
7122  else if (iiCheckTypes(v,t2))
7123  {
7124  matrix pMat = (matrix)v->Data();
7125  matrix lMat = (matrix)v->next->Data();
7126  matrix uMat = (matrix)v->next->next->Data();
7127  int rr = uMat->rows();
7128  int cc = uMat->cols();
7129  if (rr != cc)
7130  {
7131  Werror("third matrix (%d x %d) is not quadratic, hence not invertible",
7132  rr, cc);
7133  return TRUE;
7134  }
7135  if (!idIsConstant((ideal)pMat)
7136  || (!idIsConstant((ideal)lMat))
7137  || (!idIsConstant((ideal)uMat))
7138  )
7139  {
7140  WerrorS("matricesx must be constant");
7141  return TRUE;
7142  }
7143  invertible = luInverseFromLUDecomp(pMat, lMat, uMat, iMat);
7144  }
7145  else
7146  {
7147  Werror("expected either one or three matrices");
7148  return TRUE;
7149  }
7150 
7151  /* build the return structure; a list with either one or two entries */
7153  if (invertible)
7154  {
7155  ll->Init(2);
7156  ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)invertible;
7157  ll->m[1].rtyp=MATRIX_CMD; ll->m[1].data=(void *)iMat;
7158  }
7159  else
7160  {
7161  ll->Init(1);
7162  ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)invertible;
7163  }
7164 
7165  res->data=(char*)ll;
7166  return FALSE;
7167 }
7169 {
7170  /* for solving a linear equation system A * x = b, via the
7171  given LU-decomposition of the matrix A;
7172  There is one valid parametrisation:
7173  1) exactly four arguments P, L, U, b;
7174  P, L, and U realise the L-U-decomposition of A, that is,
7175  P * A = L * U, and P, L, and U satisfy the
7176  properties decribed in method 'jjLU_DECOMP';
7177  see there;
7178  b is the right-hand side vector of the equation system;
7179  The method will return a list of either 1 entry or three entries:
7180  1) [0] if there is no solution to the system;
7181  2) [1, x, H] if there is at least one solution;
7182  x is any solution of the given linear system,
7183  H is the matrix with column vectors spanning the homogeneous
7184  solution space.
7185  The method produces an error if matrix and vector sizes do not fit. */
7186  const short t[]={4,MATRIX_CMD,MATRIX_CMD,MATRIX_CMD,MATRIX_CMD};
7187  if (!iiCheckTypes(v,t))
7188  {
7189  WerrorS("expected exactly three matrices and one vector as input");
7190  return TRUE;
7191  }
7192  matrix pMat = (matrix)v->Data();
7193  matrix lMat = (matrix)v->next->Data();
7194  matrix uMat = (matrix)v->next->next->Data();
7195  matrix bVec = (matrix)v->next->next->next->Data();
7196  matrix xVec; int solvable; matrix homogSolSpace;
7197  if (pMat->rows() != pMat->cols())
7198  {
7199  Werror("first matrix (%d x %d) is not quadratic",
7200  pMat->rows(), pMat->cols());
7201  return TRUE;
7202  }
7203  if (lMat->rows() != lMat->cols())
7204  {
7205  Werror("second matrix (%d x %d) is not quadratic",
7206  lMat->rows(), lMat->cols());
7207  return TRUE;
7208  }
7209  if (lMat->rows() != uMat->rows())
7210  {
7211  Werror("second matrix (%d x %d) and third matrix (%d x %d) do not fit",
7212  lMat->rows(), lMat->cols(), uMat->rows(), uMat->cols());
7213  return TRUE;
7214  }
7215  if (uMat->rows() != bVec->rows())
7216  {
7217  Werror("third matrix (%d x %d) and vector (%d x 1) do not fit",
7218  uMat->rows(), uMat->cols(), bVec->rows());
7219  return TRUE;
7220  }
7221  if (!idIsConstant((ideal)pMat)
7222  ||(!idIsConstant((ideal)lMat))
7223  ||(!idIsConstant((ideal)uMat))
7224  )
7225  {
7226  WerrorS("matrices must be constant");
7227  return TRUE;
7228  }
7229  solvable = luSolveViaLUDecomp(pMat, lMat, uMat, bVec, xVec, homogSolSpace);
7230 
7231  /* build the return structure; a list with either one or three entries */
7233  if (solvable)
7234  {
7235  ll->Init(3);
7236  ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)solvable;
7237  ll->m[1].rtyp=MATRIX_CMD; ll->m[1].data=(void *)xVec;
7238  ll->m[2].rtyp=MATRIX_CMD; ll->m[2].data=(void *)homogSolSpace;
7239  }
7240  else
7241  {
7242  ll->Init(1);
7243  ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)solvable;
7244  }
7245 
7246  res->data=(char*)ll;
7247  return FALSE;
7248 }
7250 {
7251  int i=0;
7252  leftv h=v;
7253  if (h!=NULL) i=exprlist_length(h);
7254  intvec *iv=new intvec(i);
7255  i=0;
7256  while (h!=NULL)
7257  {
7258  if(h->Typ()==INT_CMD)
7259  {
7260  (*iv)[i]=(int)(long)h->Data();
7261  }
7262  else if (h->Typ()==INTVEC_CMD)
7263  {
7264  intvec *ivv=(intvec*)h->Data();
7265  for(int j=0;j<ivv->length();j++,i++)
7266  {
7267  (*iv)[i]=(*ivv)[j];
7268  }
7269  i--;
7270  }
7271  else
7272  {
7273  delete iv;
7274  return TRUE;
7275  }
7276  i++;
7277  h=h->next;
7278  }
7279  res->data=(char *)iv;
7280  return FALSE;
7281 }
7283 {
7284  const short t1[]={4,POLY_CMD,POLY_CMD,POLY_CMD,INTVEC_CMD};
7285  const short t2[]={4,VECTOR_CMD,POLY_CMD,POLY_CMD,INTVEC_CMD};
7286  const short t3[]={4,IDEAL_CMD,MATRIX_CMD,INT_CMD,INTVEC_CMD};
7287  const short t4[]={4,MODUL_CMD,MATRIX_CMD,INT_CMD,INTVEC_CMD};
7288  leftv u1=u;
7289  leftv u2=u1->next;
7290  leftv u3=u2->next;
7291  leftv u4=u3->next;
7292  if (iiCheckTypes(u,t1)||iiCheckTypes(u,t2))
7293  {
7294  if(!pIsUnit((poly)u2->Data()))
7295  {
7296  WerrorS("2nd argument must be a unit");
7297  return TRUE;
7298  }
7299  res->rtyp=u1->Typ();
7300  res->data=(char*)pSeries((int)(long)u3->Data(),pCopy((poly)u1->Data()),
7301  pCopy((poly)u2->Data()),(intvec*)u4->Data());
7302  return FALSE;
7303  }
7304  else
7305  if (iiCheckTypes(u,t3)||iiCheckTypes(u,t4))
7306  {
7307  if(!mp_IsDiagUnit((matrix)u2->Data(), currRing))
7308  {
7309  WerrorS("2nd argument must be a diagonal matrix of units");
7310  return TRUE;
7311  }
7312  res->rtyp=u1->Typ();
7313  res->data=(char*)idSeries(
7314  (int)(long)u3->Data(),
7315  idCopy((ideal)u1->Data()),
7316  mp_Copy((matrix)u2->Data(), currRing),
7317  (intvec*)u4->Data()
7318  );
7319  return FALSE;
7320  }
7321  else
7322  {
7323  Werror("%s(`poly`,`poly`,`int`,`intvec`) exppected",
7324  Tok2Cmdname(iiOp));
7325  return TRUE;
7326  }
7327 }
7328 #if 0
7329 static BOOLEAN jjBRACKET_PL(leftv res, leftv u)
7330 {
7331  int ut=u->Typ();
7332  leftv v=u->next; u->next=NULL;
7333  leftv w=v->next; v->next=NULL;
7334  if ((ut!=CRING_CMD)&&(ut!=RING_CMD))
7335  {
7336  BOOLEAN bo=TRUE;
7337  if (w==NULL)
7338  {
7339  bo=iiExprArith2(res,u,'[',v);
7340  }
7341  else if (w->next==NULL)
7342  {
7343  bo=iiExprArith3(res,'[',u,v,w);
7344  }
7345  v->next=w;
7346  u->next=v;
7347  return bo;
7348  }
7349  v->next=w;
7350  u->next=v;
7351  #ifdef SINGULAR_4_1
7352  // construct new rings:
7353  while (u!=NULL)
7354  {
7355  Print("name: %s,\n",u->Name());
7356  u=u->next;
7357  }
7358  #else
7359  memset(res,0,sizeof(sleftv));
7360  res->rtyp=NONE;
7361  return TRUE;
7362  #endif
7363 }
7364 #endif
7366 {
7367  if ((yyInRingConstruction)
7368  && ((strcmp(u->Name(),"real")==0) || (strcmp(u->Name(),"complex")==0)))
7369  {
7370  memcpy(res,u,sizeof(sleftv));
7371  memset(u,0,sizeof(sleftv));
7372  return FALSE;
7373  }
7374  leftv v=u->next;
7375  BOOLEAN b;
7376  if(v==NULL) // p()
7377  b=iiExprArith1(res,u,iiOp);
7378  else if ((v->next==NULL) // p(1)
7379  || (u->Typ()!=UNKNOWN)) // p(1,2), p proc or map
7380  {
7381  u->next=NULL;
7382  b=iiExprArith2(res,u,iiOp,v);
7383  u->next=v;
7384  }
7385  else // p(1,2), p undefined
7386  {
7387  if (v->Typ()!=INT_CMD)
7388  {
7389  Werror("`int` expected while building `%s(`",u->name);
7390  return TRUE;
7391  }
7392  int l=u->listLength();
7393  char * nn = (char *)omAlloc(strlen(u->name) + 12*l);
7394  sprintf(nn,"%s(%d",u->name,(int)(long)v->Data());
7395  char *s=nn;
7396  do
7397  {
7398  while (*s!='\0') s++;
7399  v=v->next;
7400  if (v->Typ()!=INT_CMD)
7401  {
7402  Werror("`int` expected while building `%s`",nn);
7403  omFree((ADDRESS)nn);
7404  return TRUE;
7405  }
7406  sprintf(s,",%d",(int)(long)v->Data());
7407  } while (v->next!=NULL);
7408  while (*s!='\0') s++;
7409  nn=strcat(nn,")");
7410  char *n=omStrDup(nn);
7411  omFree((ADDRESS)nn);
7412  syMake(res,n);
7413  b=FALSE;
7414  }
7415  return b;
7416 }
7418 {
7419  const short t1[]={4,IDEAL_CMD,IDEAL_CMD,MATRIX_CMD,STRING_CMD};
7420  const short t2[]={4,MODUL_CMD,MODUL_CMD,MATRIX_CMD,STRING_CMD};
7421  leftv u=U;
7422  leftv v=u->next;
7423  leftv w=v->next;
7424  leftv u4=w->next;
7425  if (w->rtyp!=IDHDL) return TRUE;
7426  if (iiCheckTypes(U,t1)||iiCheckTypes(U,t2))
7427  {
7428  // see jjLIFT3
7429  ideal I=(ideal)u->Data();
7430  int ul= IDELEMS(I /*(ideal)u->Data()*/);
7431  int vl= IDELEMS((ideal)v->Data());
7432  GbVariant alg=syGetAlgorithm((char*)u4->Data(),currRing,I);
7433  ideal m
7434  = idLift(I,(ideal)v->Data(),NULL,FALSE,hasFlag(u,FLAG_STD),
7435  FALSE, (matrix *)(&(IDMATRIX((idhdl)(w->data)))),alg);
7436  if (m==NULL) return TRUE;
7437  res->data = (char *)id_Module2formatedMatrix(m,ul,vl,currRing);
7438  return FALSE;
7439  }
7440  else
7441  {
7442  Werror("%s(`ideal`,`ideal`,`matrix`,`string`)\n"
7443  "or (`module`,`module`,`matrix`,`string`)expected",
7444  Tok2Cmdname(iiOp));
7445  return TRUE;
7446  }
7447 }
7449 {
7450  const short t1[]={4,IDEAL_CMD,IDEAL_CMD,MATRIX_CMD,STRING_CMD};
7451  const short t2[]={4,MODUL_CMD,MODUL_CMD,MATRIX_CMD,STRING_CMD};
7452  leftv u=U;
7453  leftv v=u->next;
7454  leftv w=v->next;
7455  leftv u4=w->next;
7456  if (v->rtyp!=IDHDL) return TRUE;
7457  if (w->rtyp!=IDHDL) return TRUE;
7458  if (iiCheckTypes(U,t1)||iiCheckTypes(U,t2))
7459  {
7460  // see jjLIFTSTD3
7461  ideal I=(ideal)u->Data();
7462  idhdl hv=(idhdl)v->data;
7463  idhdl hw=(idhdl)w->data;
7464  GbVariant alg=syGetAlgorithm((char*)u4->Data(),currRing,I);
7465  // CopyD for IDEAL_CMD and MODUL_CMD are identical:
7466  res->data = (char *)idLiftStd((ideal)u->Data(),
7467  &(hv->data.umatrix),testHomog,
7468  &(hw->data.uideal),alg);
7469  setFlag(res,FLAG_STD); v->flag=0; w->flag=0;
7470  return FALSE;
7471  }
7472  else
7473  {
7474  Werror("%s(`ideal`,`ideal`,`matrix`,`string`)\n"
7475  "or (`module`,`module`,`matrix`,`string`)expected",
7476  Tok2Cmdname(iiOp));
7477  return TRUE;
7478  }
7479 }
7481 {
7482  int sl=0;
7483  if (v!=NULL) sl = v->listLength();
7484  lists L;
7485  if((sl==1)&&(v->Typ()==RESOLUTION_CMD))
7486  {
7487  int add_row_shift = 0;
7488  intvec *weights=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
7489  if (weights!=NULL) add_row_shift=weights->min_in();
7490  L=syConvRes((syStrategy)v->Data(),FALSE,add_row_shift);
7491  }
7492  else
7493  {
7495  leftv h=NULL;
7496  int i;
7497  int rt;
7498 
7499  L->Init(sl);
7500  for (i=0;i<sl;i++)
7501  {
7502  if (h!=NULL)
7503  { /* e.g. not in the first step:
7504  * h is the pointer to the old sleftv,
7505  * v is the pointer to the next sleftv
7506  * (in this moment) */
7507  h->next=v;
7508  }
7509  h=v;
7510  v=v->next;
7511  h->next=NULL;
7512  rt=h->Typ();
7513  if (rt==0)
7514  {
7515  L->Clean();
7516  Werror("`%s` is undefined",h->Fullname());
7517  return TRUE;
7518  }
7519  if (rt==RING_CMD)
7520  {
7521  L->m[i].rtyp=rt; L->m[i].data=h->Data();
7522  ((ring)L->m[i].data)->ref++;
7523  }
7524  else
7525  L->m[i].Copy(h);
7526  }
7527  }
7528  res->data=(char *)L;
7529  return FALSE;
7530 }
7532 {
7533  res->data=(void *)ipNameList(IDROOT);
7534  return FALSE;
7535 }
7537 {
7538  if(v==NULL)
7539  {
7540  res->data=(char *)showOption();
7541  return FALSE;
7542  }
7543  res->rtyp=NONE;
7544  return setOption(res,v);
7545 }
7547 {
7548  leftv u1=u;
7549  leftv u2=u1->next;
7550  leftv u3=u2->next;
7551  leftv u4=u3->next;
7552  int u1t=u1->Typ(); if (u1t==BUCKET_CMD) u1t=POLY_CMD;
7553  int u2t=u2->Typ(); if (u2t==BUCKET_CMD) u2t=POLY_CMD;
7554  if((u3->Typ()==INT_CMD)&&(u4->Typ()==INTVEC_CMD))
7555  {
7556  int save_d=Kstd1_deg;
7557  Kstd1_deg=(int)(long)u3->Data();
7558  kModW=(intvec *)u4->Data();
7559  BITSET save2;
7560  SI_SAVE_OPT2(save2);
7562  u2->next=NULL;
7563  BOOLEAN r=jjCALL2ARG(res,u);
7564  kModW=NULL;
7565  Kstd1_deg=save_d;
7566  SI_RESTORE_OPT2(save2);
7567  u->next->next=u3;
7568  return r;
7569  }
7570  else
7571  if((u1t==IDEAL_CMD)&&(u2t==MATRIX_CMD)&&(u3->Typ()==IDEAL_CMD)&&
7572  (u4->Typ()==INT_CMD))
7573  {
7574  assumeStdFlag(u3);
7575  if(!mp_IsDiagUnit((matrix)u2->Data(), currRing))
7576  {
7577  WerrorS("2nd argument must be a diagonal matrix of units");
7578  return TRUE;
7579  }
7580  res->rtyp=IDEAL_CMD;
7581  res->data=(char*)redNF(
7582  idCopy((ideal)u3->Data()),
7583  idCopy((ideal)u1->Data()),
7584  mp_Copy((matrix)u2->Data(), currRing),
7585  (int)(long)u4->Data()
7586  );
7587  return FALSE;
7588  }
7589  else
7590  if((u1t==POLY_CMD)&&(u2t==POLY_CMD)&&(u3->Typ()==IDEAL_CMD)&&
7591  (u4->Typ()==INT_CMD))
7592  {
7593  poly u1p;
7594  if (u1->Typ()==BUCKET_CMD) u1p=sBucketPeek((sBucket_pt)u1->Data());
7595  else u1p=(poly)u1->Data();
7596  poly u2p;
7597  if (u2->Typ()==BUCKET_CMD) u2p=sBucketPeek((sBucket_pt)u2->Data());
7598  else u2p=(poly)u2->Data();
7599  assumeStdFlag(u3);
7600  if(!pIsUnit(u2p))
7601  {
7602  WerrorS("2nd argument must be a unit");
7603  return TRUE;
7604  }
7605  res->rtyp=POLY_CMD;
7606  res->data=(char*)redNF((ideal)u3->CopyD(),pCopy(u1p),
7607  pCopy(u2p),(int)(long)u4->Data());
7608  return FALSE;
7609  }
7610  else
7611  {
7612  Werror("%s(`poly`,`ideal`,`int`,`intvec`) expected",Tok2Cmdname(iiOp));
7613  Werror("%s(`ideal`,`matrix`,`ideal`,`int`) expected",Tok2Cmdname(iiOp));
7614  Werror("%s(`poly`,`poly`,`ideal`,`int`) expected",Tok2Cmdname(iiOp));
7615  return TRUE;
7616  }
7617 }
7619 {
7620  leftv u1=u;
7621  leftv u2=u1->next;
7622  leftv u3=u2->next;
7623  leftv u4=u3->next;
7624  leftv u5=u4->next;
7625  if((u1->Typ()==IDEAL_CMD)&&(u2->Typ()==MATRIX_CMD)&&(u3->Typ()==IDEAL_CMD)&&
7626  (u4->Typ()==INT_CMD)&&(u5->Typ()==INTVEC_CMD))
7627  {
7628  assumeStdFlag(u3);
7629  if(!mp_IsDiagUnit((matrix)u2->Data(), currRing))
7630  {
7631  WerrorS("2nd argument must be a diagonal matrix of units");
7632  return TRUE;
7633  }
7634  res->rtyp=IDEAL_CMD;
7635  res->data=(char*)redNF(
7636  idCopy((ideal)u3->Data()),
7637  idCopy((ideal)u1->Data()),
7638  mp_Copy((matrix)u2->Data(),currRing),
7639  (int)(long)u4->Data(),
7640  (intvec*)u5->Data()
7641  );
7642  return FALSE;
7643  }
7644  else
7645  if((u1->Typ()==POLY_CMD)&&(u2->Typ()==POLY_CMD)&&(u3->Typ()==IDEAL_CMD)&&
7646  (u4->Typ()==INT_CMD)&&(u5->Typ()==INTVEC_CMD))
7647  {
7648  assumeStdFlag(u3);
7649  if(!pIsUnit((poly)u2->Data()))
7650  {
7651  WerrorS("2nd argument must be a unit");
7652  return TRUE;
7653  }
7654  res->rtyp=POLY_CMD;
7655  res->data=(char*)redNF(idCopy((ideal)u3->Data()),pCopy((poly)u1->Data()),
7656  pCopy((poly)u2->Data()),
7657  (int)(long)u4->Data(),(intvec*)u5->Data());
7658  return FALSE;
7659  }
7660  else
7661  {
7662  Werror("%s(`ideal`,`ideal`,`matrix`,`int`,`intvec`) exppected",
7663  Tok2Cmdname(iiOp));
7664  return TRUE;
7665  }
7666 }
7668 {
7669  unsigned i=1;
7670  unsigned nCount = (sArithBase.nCmdUsed-1)/3;
7671  if((3*nCount)<sArithBase.nCmdUsed) nCount++;
7672  //Print("CMDS: %d/%d\n", sArithBase.nCmdUsed,
7673  // sArithBase.nCmdAllocated);
7674  for(i=0; i<nCount; i++)
7675  {
7676  Print("%-20s",sArithBase.sCmds[i+1].name);
7677  if(i+1+nCount<sArithBase.nCmdUsed)
7678  Print("%-20s",sArithBase.sCmds[i+1+nCount].name);
7679  if(i+1+2*nCount<sArithBase.nCmdUsed)
7680  Print("%-20s",sArithBase.sCmds[i+1+2*nCount].name);
7681  //if ((i%3)==1) PrintLn();
7682  PrintLn();
7683  }
7684  PrintLn();
7686  return FALSE;
7687 }
7689 {
7690  if (v == NULL)
7691  {
7692  res->data = omStrDup("");
7693  return FALSE;
7694  }
7695  int n = v->listLength();
7696  if (n == 1)
7697  {
7698  res->data = v->String();
7699  return FALSE;
7700  }
7701 
7702  char** slist = (char**) omAlloc(n*sizeof(char*));
7703  int i, j;
7704 
7705  for (i=0, j=0; i<n; i++, v = v ->next)
7706  {
7707  slist[i] = v->String();
7708  assume(slist[i] != NULL);
7709  j+=strlen(slist[i]);
7710  }
7711  char* s = (char*) omAlloc((j+1)*sizeof(char));
7712  *s='\0';
7713  for (i=0;i<n;i++)
7714  {
7715  strcat(s, slist[i]);
7716  omFree(slist[i]);
7717  }
7718  omFreeSize(slist, n*sizeof(char*));
7719  res->data = s;
7720  return FALSE;
7721 }
7723 {
7724  do
7725  {
7726  if (v->Typ()!=INT_CMD)
7727  return TRUE;
7728  test_cmd((int)(long)v->Data());
7729  v=v->next;
7730  }
7731  while (v!=NULL);
7732  return FALSE;
7733 }
7734 
7735 #if defined(__alpha) && !defined(linux)
7736 extern "C"
7737 {
7738  void usleep(unsigned long usec);
7739 };
7740 #endif
7742 {
7743  /* compute two factors of h(x,y) modulo x^(d+1) in K[[x]][y],
7744  see a detailed documentation in /kernel/linear_algebra/linearAlgebra.h
7745 
7746  valid argument lists:
7747  - (poly h, int d),
7748  - (poly h, int d, poly f0, poly g0), optional: factors of h(0,y),
7749  - (poly h, int d, int xIndex, int yIndex), optional: indices of vars x & y
7750  in list of ring vars,
7751  - (poly h, int d, poly f0, poly g0, int xIndex, int yIndec),
7752  optional: all 4 optional args
7753  (The defaults are xIndex = 1, yIndex = 2, f0 and g0 polynomials as found
7754  by singclap_factorize and h(0, y)
7755  has exactly two distinct monic factors [possibly with exponent > 1].)
7756  result:
7757  - list with the two factors f and g such that
7758  h(x,y) = f(x,y)*g(x,y) mod x^(d+1) */
7759 
7760  poly h = NULL;
7761  int d = 1;
7762  poly f0 = NULL;
7763  poly g0 = NULL;
7764  int xIndex = 1; /* default index if none provided */
7765  int yIndex = 2; /* default index if none provided */
7766 
7767  leftv u = v; int factorsGiven = 0;
7768  if ((u == NULL) || (u->Typ() != POLY_CMD))
7769  {
7770  WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
7771  return TRUE;
7772  }
7773  else h = (poly)u->Data();
7774  u = u->next;
7775  if ((u == NULL) || (u->Typ() != INT_CMD))
7776  {
7777  WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
7778  return TRUE;
7779  }
7780  else d = (int)(long)u->Data();
7781  u = u->next;
7782  if ((u != NULL) && (u->Typ() == POLY_CMD))
7783  {
7784  if ((u->next == NULL) || (u->next->Typ() != POLY_CMD))
7785  {
7786  WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
7787  return TRUE;
7788  }
7789  else
7790  {
7791  f0 = (poly)u->Data();
7792  g0 = (poly)u->next->Data();
7793  factorsGiven = 1;
7794  u = u->next->next;
7795  }
7796  }
7797  if ((u != NULL) && (u->Typ() == INT_CMD))
7798  {
7799  if ((u->next == NULL) || (u->next->Typ() != INT_CMD))
7800  {
7801  WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
7802  return TRUE;
7803  }
7804  else
7805  {
7806  xIndex = (int)(long)u->Data();
7807  yIndex = (int)(long)u->next->Data();
7808  u = u->next->next;
7809  }
7810  }
7811  if (u != NULL)
7812  {
7813  WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
7814  return TRUE;
7815  }
7816 
7817  /* checks for provided arguments */
7818  if (pIsConstant(h) || (factorsGiven && (pIsConstant(f0) || pIsConstant(g0))))
7819  {
7820  WerrorS("expected non-constant polynomial argument(s)");
7821  return TRUE;
7822  }
7823  int n = rVar(currRing);
7824  if ((xIndex < 1) || (n < xIndex))
7825  {
7826  Werror("index for variable x (%d) out of range [1..%d]", xIndex, n);
7827  return TRUE;
7828  }
7829  if ((yIndex < 1) || (n < yIndex))
7830  {
7831  Werror("index for variable y (%d) out of range [1..%d]", yIndex, n);
7832  return TRUE;
7833  }
7834  if (xIndex == yIndex)
7835  {
7836  WerrorS("expected distinct indices for variables x and y");
7837  return TRUE;
7838  }
7839 
7840  /* computation of f0 and g0 if missing */
7841  if (factorsGiven == 0)
7842  {
7843  poly h0 = pSubst(pCopy(h), xIndex, NULL);
7844  intvec* v = NULL;
7845  ideal i = singclap_factorize(h0, &v, 0,currRing);
7846 
7847  ivTest(v);
7848 
7849  if (i == NULL) return TRUE;
7850 
7851  idTest(i);
7852 
7853  if ((v->rows() != 3) || ((*v)[0] =! 1) || (!nIsOne(pGetCoeff(i->m[0]))))
7854  {
7855  WerrorS("expected h(0,y) to have exactly two distinct monic factors");
7856  return TRUE;
7857  }
7858  f0 = pPower(pCopy(i->m[1]), (*v)[1]);
7859  g0 = pPower(pCopy(i->m[2]), (*v)[2]);
7860  idDelete(&i);
7861  }
7862 
7863  poly f; poly g;
7864  henselFactors(xIndex, yIndex, h, f0, g0, d, f, g);
7866  L->Init(2);
7867  L->m[0].rtyp = POLY_CMD; L->m[0].data=(void*)f;
7868  L->m[1].rtyp = POLY_CMD; L->m[1].data=(void*)g;
7869  res->rtyp = LIST_CMD;
7870  res->data = (char*)L;
7871  return FALSE;
7872 }
7874 {
7875  if ((v->Typ() != LINK_CMD) ||
7876  (v->next->Typ() != STRING_CMD) ||
7877  (v->next->next->Typ() != STRING_CMD) ||
7878  (v->next->next->next->Typ() != INT_CMD))
7879  return TRUE;
7880  jjSTATUS3(res, v, v->next, v->next->next);
7881 #if defined(HAVE_USLEEP)
7882  if (((long) res->data) == 0L)
7883  {
7884  int i_s = (int)(long) v->next->next->next->Data();
7885  if (i_s > 0)
7886  {
7887  usleep((int)(long) v->next->next->next->Data());
7888  jjSTATUS3(res, v, v->next, v->next->next);
7889  }
7890  }
7891 #elif defined(HAVE_SLEEP)
7892  if (((int) res->data) == 0)
7893  {
7894  int i_s = (int) v->next->next->next->Data();
7895  if (i_s > 0)
7896  {
7897  si_sleep((is - 1)/1000000 + 1);
7898  jjSTATUS3(res, v, v->next, v->next->next);
7899  }
7900  }
7901 #endif
7902  return FALSE;
7903 }
7905 {
7906  leftv v = u->next; // number of args > 0
7907  if (v==NULL) return TRUE;
7908  leftv w = v->next;
7909  if (w==NULL) return TRUE;
7910  leftv rest = w->next;;
7911 
7912  u->next = NULL;
7913  v->next = NULL;
7914  w->next = NULL;
7915  BOOLEAN b = iiExprArith3(res, iiOp, u, v, w);
7916  if ((rest!=NULL) && (!b))
7917  {
7918  sleftv tmp_res;
7919  leftv tmp_next=res->next;
7920  res->next=rest;
7921  memset(&tmp_res,0,sizeof(tmp_res));
7922  b = iiExprArithM(&tmp_res,res,iiOp);
7923  memcpy(res,&tmp_res,sizeof(tmp_res));
7924  res->next=tmp_next;
7925  }
7926  u->next = v;
7927  v->next = w;
7928  // rest was w->next, but is already cleaned
7929  return b;
7930 }
7931 static BOOLEAN jjQRDS(leftv res, leftv INPUT)
7932 {
7933  if ((INPUT->Typ() != MATRIX_CMD) ||
7934  (INPUT->next->Typ() != NUMBER_CMD) ||
7935  (INPUT->next->next->Typ() != NUMBER_CMD) ||
7936  (INPUT->next->next->next->Typ() != NUMBER_CMD))
7937  {
7938  WerrorS("expected (matrix, number, number, number) as arguments");
7939  return TRUE;
7940  }
7941  leftv u = INPUT; leftv v = u->next; leftv w = v->next; leftv x = w->next;
7942  res->data = (char *)qrDoubleShift((matrix)(u->Data()),
7943  (number)(v->Data()),
7944  (number)(w->Data()),
7945  (number)(x->Data()));
7946  return FALSE;
7947 }
7949 { ideal result;
7950  leftv u = INPUT; /* an ideal, weighted homogeneous and standard */
7951  leftv v = u->next; /* one additional polynomial or ideal */
7952  leftv h = v->next; /* Hilbert vector */
7953  leftv w = h->next; /* weight vector */
7954  assumeStdFlag(u);
7955  ideal i1=(ideal)(u->Data());
7956  ideal i0;
7957  if (((u->Typ()!=IDEAL_CMD)&&(u->Typ()!=MODUL_CMD))
7958  || (h->Typ()!=INTVEC_CMD)
7959  || (w->Typ()!=INTVEC_CMD))
7960  {
7961  WerrorS("expected `std(`ideal/module`,`poly/vector`,`intvec`,`intvec`)");
7962  return TRUE;
7963  }
7964  intvec *vw=(intvec *)w->Data(); // weights of vars
7965  /* merging std_hilb_w and std_1 */
7966  if (vw->length()!=currRing->N)
7967  {
7968  Werror("%d weights for %d variables",vw->length(),currRing->N);
7969  return TRUE;
7970  }
7971  int r=v->Typ();
7972  BOOLEAN cleanup_i0=FALSE;
7973  if ((r==POLY_CMD) ||(r==VECTOR_CMD))
7974  {
7975  i0=idInit(1,i1->rank);
7976  i0->m[0]=(poly)v->Data();
7977  cleanup_i0=TRUE;
7978  }
7979  else if (r==IDEAL_CMD)/* IDEAL */
7980  {
7981  i0=(ideal)v->Data();
7982  }
7983  else
7984  {
7985  WerrorS("expected `std(`ideal/module`,`poly/vector`,`intvec`,`intvec`)");
7986  return TRUE;
7987  }
7988  int ii0=idElem(i0);
7989  i1 = idSimpleAdd(i1,i0);
7990  if (cleanup_i0)
7991  {
7992  memset(i0->m,0,sizeof(poly)*IDELEMS(i0));
7993  idDelete(&i0);
7994  }
7995  intvec *ww=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
7996  tHomog hom=testHomog;
7997  /* u_id from jjSTD_W is now i1 as in jjSTD_1 */
7998  if (ww!=NULL)
7999  {
8000  if (!idTestHomModule(i1,currRing->qideal,ww))
8001  {
8002  WarnS("wrong weights");
8003  ww=NULL;
8004  }
8005  else
8006  {
8007  ww=ivCopy(ww);
8008  hom=isHomog;
8009  }
8010  }
8011  BITSET save1;
8012  SI_SAVE_OPT1(save1);
8014  result=kStd(i1,
8015  currRing->qideal,
8016  hom,
8017  &ww, // module weights
8018  (intvec *)h->Data(), // hilbert series
8019  0, // syzComp, whatever it is...
8020  IDELEMS(i1)-ii0, // new ideal
8021  vw); // weights of vars
8022  SI_RESTORE_OPT1(save1);
8023  idDelete(&i1);
8025  res->data = (char *)result;
8027  if (ww!=NULL) atSet(res,omStrDup("isHomog"),ww,INTVEC_CMD);
8028  return FALSE;
8029 }
8030 
8032 {
8033  //Print("construct ring\n");
8034  if (a->Typ()!=CRING_CMD)
8035  {
8036  WerrorS("expected `cring` [ `id` ... ]");
8037  return TRUE;
8038  }
8039  assume(a->next!=NULL);
8040  leftv names=a->next;
8041  int N=names->listLength();
8042  char **n=(char**)omAlloc0(N*sizeof(char*));
8043  for(int i=0; i<N;i++,names=names->next)
8044  {
8045  n[i]=(char *)names->Name();
8046  }
8047  coeffs cf=(coeffs)a->CopyD();
8048  res->data=rDefault(cf,N,n, ringorder_dp);
8049  omFreeSize(n,N*sizeof(char*));
8050  return FALSE;
8051 }
8052 
8053 static Subexpr jjMakeSub(leftv e)
8054 {
8055  assume( e->Typ()==INT_CMD );
8056  Subexpr r=(Subexpr)omAlloc0Bin(sSubexpr_bin);
8057  r->start =(int)(long)e->Data();
8058  return r;
8059 }
8061 {
8062  int c=(int)(long)u->Data();
8063  switch(c)
8064  {
8065  case 0:{
8066  PrintS("delete all variables\n");
8067  killlocals(0);
8068  WerrorS("restarting...");
8069  break;
8070  };
8071  default: WerrorS("not implemented");
8072  }
8073  return FALSE;
8074 }
8075 #define D(A) (A)
8076 #define NULL_VAL NULL
8077 #define IPARITH
8078 #include "table.h"
8079 
8080 #include "iparith.inc"
8081 
8082 /*=================== operations with 2 args. ============================*/
8083 /* must be ordered: first operations for chars (infix ops),
8084  * then alphabetically */
8085 
8087  BOOLEAN proccall,
8088  const struct sValCmd2* dA2,
8089  int at, int bt,
8090  const struct sConvertTypes *dConvertTypes)
8091 {
8092  memset(res,0,sizeof(sleftv));
8093  BOOLEAN call_failed=FALSE;
8094 
8095  if (!errorreported)
8096  {
8097  int i=0;
8098  iiOp=op;
8099  while (dA2[i].cmd==op)
8100  {
8101  if ((at==dA2[i].arg1)
8102  && (bt==dA2[i].arg2))
8103  {
8104  res->rtyp=dA2[i].res;
8105  if (currRing!=NULL)
8106  {
8107  if (check_valid(dA2[i].valid_for,op)) break;
8108  }
8109  else
8110  {
8111  if (RingDependend(dA2[i].res))
8112  {
8113  WerrorS("no ring active");
8114  break;
8115  }
8116  }
8117  if (traceit&TRACE_CALL)
8118  Print("call %s(%s,%s)\n",iiTwoOps(op),Tok2Cmdname(at),Tok2Cmdname(bt));
8119  if ((call_failed=dA2[i].p(res,a,b)))
8120  {
8121  break;// leave loop, goto error handling
8122  }
8123  a->CleanUp();
8124  b->CleanUp();
8125  //Print("op: %d,result typ:%d\n",op,res->rtyp);
8126  return FALSE;
8127  }
8128  i++;
8129  }
8130  // implicite type conversion ----------------------------------------------
8131  if (dA2[i].cmd!=op)
8132  {
8133  int ai,bi;
8136  BOOLEAN failed=FALSE;
8137  i=0; /*iiTabIndex(dArithTab2,JJTAB2LEN,op);*/
8138  //Print("op: %c, type: %s %s\n",op,Tok2Cmdname(at),Tok2Cmdname(bt));
8139  while (dA2[i].cmd==op)
8140  {
8141  //Print("test %s %s\n",Tok2Cmdname(dA2[i].arg1),Tok2Cmdname(dA2[i].arg2));
8142  if ((dA2[i].valid_for & NO_CONVERSION)==0)
8143  {
8144  if ((ai=iiTestConvert(at,dA2[i].arg1,dConvertTypes))!=0)
8145  {
8146  if ((bi=iiTestConvert(bt,dA2[i].arg2,dConvertTypes))!=0)
8147  {
8148  res->rtyp=dA2[i].res;
8149  if (currRing!=NULL)
8150  {
8151  if (check_valid(dA2[i].valid_for,op)) break;
8152  }
8153  else
8154  {
8155  if (RingDependend(dA2[i].res))
8156  {
8157  WerrorS("no ring active");
8158  break;
8159  }
8160  }
8161  if (traceit&TRACE_CALL)
8162  Print("call %s(%s,%s)\n",iiTwoOps(op),
8163  Tok2Cmdname(dA2[i].arg1),Tok2Cmdname(dA2[i].arg2));
8164  failed= ((iiConvert(at,dA2[i].arg1,ai,a,an))
8165  || (iiConvert(bt,dA2[i].arg2,bi,b,bn))
8166  || (call_failed=dA2[i].p(res,an,bn)));
8167  // everything done, clean up temp. variables
8168  if (failed)
8169  {
8170  // leave loop, goto error handling
8171  break;
8172  }
8173  else
8174  {
8175  // everything ok, clean up and return
8176  an->CleanUp();
8177  bn->CleanUp();
8180  return FALSE;
8181  }
8182  }
8183  }
8184  }
8185  i++;
8186  }
8187  an->CleanUp();
8188  bn->CleanUp();
8191  }
8192  // error handling ---------------------------------------------------
8193  const char *s=NULL;
8194  if (!errorreported)
8195  {
8196  if ((at==0) && (a->Fullname()!=sNoName_fe))
8197  {
8198  s=a->Fullname();
8199  }
8200  else if ((bt==0) && (b->Fullname()!=sNoName_fe))
8201  {
8202  s=b->Fullname();
8203  }
8204  if (s!=NULL)
8205  Werror("`%s` is not defined",s);
8206  else
8207  {
8208  i=0; /*iiTabIndex(dArithTab2,JJTAB2LEN,op);*/
8209  s = iiTwoOps(op);
8210  if (proccall)
8211  {
8212  Werror("%s(`%s`,`%s`) failed"
8213  ,s,Tok2Cmdname(at),Tok2Cmdname(bt));
8214  }
8215  else
8216  {
8217  Werror("`%s` %s `%s` failed"
8218  ,Tok2Cmdname(at),s,Tok2Cmdname(bt));
8219  }
8220  if ((!call_failed) && BVERBOSE(V_SHOW_USE))
8221  {
8222  while (dA2[i].cmd==op)
8223  {
8224  if(((at==dA2[i].arg1)||(bt==dA2[i].arg2))
8225  && (dA2[i].res!=0)
8226  && (dA2[i].p!=jjWRONG2))
8227  {
8228  if (proccall)
8229  Werror("expected %s(`%s`,`%s`)"
8230  ,s,Tok2Cmdname(dA2[i].arg1),Tok2Cmdname(dA2[i].arg2));
8231  else
8232  Werror("expected `%s` %s `%s`"
8233  ,Tok2Cmdname(dA2[i].arg1),s,Tok2Cmdname(dA2[i].arg2));
8234  }
8235  i++;
8236  }
8237  }
8238  }
8239  }
8240  a->CleanUp();
8241  b->CleanUp();
8242  res->rtyp = UNKNOWN;
8243  }
8244  return TRUE;
8245 }
8247  const struct sValCmd2* dA2,
8248  int at,
8249  const struct sConvertTypes *dConvertTypes)
8250 {
8251  leftv b=a->next;
8252  a->next=NULL;
8253  int bt=b->Typ();
8254  BOOLEAN bo=iiExprArith2TabIntern(res,a,op,b,TRUE,dA2,at,bt,dConvertTypes);
8255  a->next=b;
8256  a->CleanUp(); // to clean up the chain, content already done in iiExprArith2TabIntern
8257  return bo;
8258 }
8260 {
8261  memset(res,0,sizeof(sleftv));
8262 
8263  if (!errorreported)
8264  {
8265 #ifdef SIQ
8266  if (siq>0)
8267  {
8268  //Print("siq:%d\n",siq);
8270  memcpy(&d->arg1,a,sizeof(sleftv));
8271  a->Init();
8272  memcpy(&d->arg2,b,sizeof(sleftv));
8273  b->Init();
8274  d->argc=2;
8275  d->op=op;
8276  res->data=(char *)d;
8277  res->rtyp=COMMAND;
8278  return FALSE;
8279  }
8280 #endif
8281  int at=a->Typ();
8282  int bt=b->Typ();
8283  // handling bb-objects ----------------------------------------------------
8284  if (at>MAX_TOK)
8285  {
8286  blackbox *bb=getBlackboxStuff(at);
8287  if (bb!=NULL)
8288  {
8289  if (!bb->blackbox_Op2(op,res,a,b)) return FALSE;
8290  //else: no op defined, try the default
8291  }
8292  else
8293  return TRUE;
8294  }
8295  else if ((bt>MAX_TOK)&&(op!='('))
8296  {
8297  blackbox *bb=getBlackboxStuff(bt);
8298  if (bb!=NULL)
8299  {
8300  if(!bb->blackbox_Op2(op,res,a,b)) return FALSE;
8301  // else: no op defined
8302  }
8303  else
8304  return TRUE;
8305  }
8306  int i=iiTabIndex(dArithTab2,JJTAB2LEN,op);
8307  return iiExprArith2TabIntern(res,a,op,b,proccall,dArith2+i,at,bt,dConvertTypes);
8308  }
8309  a->CleanUp();
8310  b->CleanUp();
8311  return TRUE;
8312 }
8313 
8314 /*==================== operations with 1 arg. ===============================*/
8315 /* must be ordered: first operations for chars (infix ops),
8316  * then alphabetically */
8317 
8318 BOOLEAN iiExprArith1Tab(leftv res, leftv a, int op, const struct sValCmd1* dA1, int at, const struct sConvertTypes *dConvertTypes)
8319 {
8320  memset(res,0,sizeof(sleftv));
8321  BOOLEAN call_failed=FALSE;
8322 
8323  if (!errorreported)
8324  {
8325  BOOLEAN failed=FALSE;
8326  iiOp=op;
8327  int i = 0;
8328  while (dA1[i].cmd==op)
8329  {
8330  if (at==dA1[i].arg)
8331  {
8332  if (currRing!=NULL)
8333  {
8334  if (check_valid(dA1[i].valid_for,op)) break;
8335  }
8336  else
8337  {
8338  if (RingDependend(dA1[i].res))
8339  {
8340  WerrorS("no ring active");
8341  break;
8342  }
8343  }
8344  if (traceit&TRACE_CALL)
8345  Print("call %s(%s)\n",iiTwoOps(op),Tok2Cmdname(at));
8346  res->rtyp=dA1[i].res;
8347  if ((call_failed=dA1[i].p(res,a)))
8348  {
8349  break;// leave loop, goto error handling
8350  }
8351  if (a->Next()!=NULL)
8352  {
8353  res->next=(leftv)omAllocBin(sleftv_bin);
8354  failed=iiExprArith1(res->next,a->next,op);
8355  }
8356  a->CleanUp();
8357  return failed;
8358  }
8359  i++;
8360  }
8361  // implicite type conversion --------------------------------------------
8362  if (dA1[i].cmd!=op)
8363  {
8365  i=0;
8366  //Print("fuer %c , typ: %s\n",op,Tok2Cmdname(at));
8367  while (dA1[i].cmd==op)
8368  {
8369  int ai;
8370  //Print("test %s\n",Tok2Cmdname(dA1[i].arg));
8371  if ((dA1[i].valid_for & NO_CONVERSION)==0)
8372  {
8373  if ((ai=iiTestConvert(at,dA1[i].arg,dConvertTypes))!=0)
8374  {
8375  if (currRing!=NULL)
8376  {
8377  if (check_valid(dA1[i].valid_for,op)) break;
8378  }
8379  else
8380  {
8381  if (RingDependend(dA1[i].res))
8382  {
8383  WerrorS("no ring active");
8384  break;
8385  }
8386  }
8387  if (traceit&TRACE_CALL)
8388  Print("call %s(%s)\n",iiTwoOps(op),Tok2Cmdname(dA1[i].arg));
8389  res->rtyp=dA1[i].res;
8390  failed= ((iiConvert(at,dA1[i].arg,ai,a,an,dConvertTypes))
8391  || (call_failed=dA1[i].p(res,an)));
8392  // everything done, clean up temp. variables
8393  if (failed)
8394  {
8395  // leave loop, goto error handling
8396  break;
8397  }
8398  else
8399  {
8400  if (an->Next() != NULL)
8401  {
8402  res->next = (leftv)omAllocBin(sleftv_bin);
8403  failed=iiExprArith1(res->next,an->next,op);
8404  }
8405  // everything ok, clean up and return
8406  an->CleanUp();
8408  return failed;
8409  }
8410  }
8411  }
8412  i++;
8413  }
8414  an->CleanUp();
8416  }
8417  // error handling
8418  if (!errorreported)
8419  {
8420  if ((at==0) && (a->Fullname()!=sNoName_fe))
8421  {
8422  Werror("`%s` is not defined",a->Fullname());
8423  }
8424  else
8425  {
8426  i=0;
8427  const char *s = iiTwoOps(op);
8428  Werror("%s(`%s`) failed"
8429  ,s,Tok2Cmdname(at));
8430  if ((!call_failed) && BVERBOSE(V_SHOW_USE))
8431  {
8432  while (dA1[i].cmd==op)
8433  {
8434  if ((dA1[i].res!=0)
8435  && (dA1[i].p!=jjWRONG))
8436  Werror("expected %s(`%s`)"
8437  ,s,Tok2Cmdname(dA1[i].arg));
8438  i++;
8439  }
8440  }
8441  }
8442  }
8443  res->rtyp = UNKNOWN;
8444  }
8445  a->CleanUp();
8446  return TRUE;
8447 }
8449 {
8450  memset(res,0,sizeof(sleftv));
8451 
8452  if (!errorreported)
8453  {
8454 #ifdef SIQ
8455  if (siq>0)
8456  {
8457  //Print("siq:%d\n",siq);
8459  memcpy(&d->arg1,a,sizeof(sleftv));
8460  a->Init();
8461  d->op=op;
8462  d->argc=1;
8463  res->data=(char *)d;
8464  res->rtyp=COMMAND;
8465  return FALSE;
8466  }
8467 #endif
8468  int at=a->Typ();
8469  // handling bb-objects ----------------------------------------------------
8470  if(op>MAX_TOK) // explicit type conversion to bb
8471  {
8472  blackbox *bb=getBlackboxStuff(op);
8473  if (bb!=NULL)
8474  {
8475  res->rtyp=op;
8476  res->data=bb->blackbox_Init(bb);
8477  if(!bb->blackbox_Assign(res,a)) return FALSE;
8478  }
8479  else
8480  return TRUE;
8481  }
8482  else if (at>MAX_TOK) // argument is of bb-type
8483  {
8484  blackbox *bb=getBlackboxStuff(at);
8485  if (bb!=NULL)
8486  {
8487  if(!bb->blackbox_Op1(op,res,a)) return FALSE;
8488  // else: no op defined
8489  }
8490  else
8491  return TRUE;
8492  }
8493  if (errorreported) return TRUE;
8494 
8495  iiOp=op;
8496  int i=iiTabIndex(dArithTab1,JJTAB1LEN,op);
8497  return iiExprArith1Tab(res,a,op, dArith1+i,at,dConvertTypes);
8498  }
8499  a->CleanUp();
8500  return TRUE;
8501 }
8502 
8503 /*=================== operations with 3 args. ============================*/
8504 /* must be ordered: first operations for chars (infix ops),
8505  * then alphabetically */
8506 
8508  const struct sValCmd3* dA3, int at, int bt, int ct,
8509  const struct sConvertTypes *dConvertTypes)
8510 {
8511  memset(res,0,sizeof(sleftv));
8512  BOOLEAN call_failed=FALSE;
8513 
8514  assume(dA3[0].cmd==op);
8515 
8516  if (!errorreported)
8517  {
8518  int i=0;
8519  iiOp=op;
8520  while (dA3[i].cmd==op)
8521  {
8522  if ((at==dA3[i].arg1)
8523  && (bt==dA3[i].arg2)
8524  && (ct==dA3[i].arg3))
8525  {
8526  res->rtyp=dA3[i].res;
8527  if (currRing!=NULL)
8528  {
8529  if (check_valid(dA3[i].valid_for,op)) break;
8530  }
8531  if (traceit&TRACE_CALL)
8532  Print("call %s(%s,%s,%s)\n",
8533  iiTwoOps(op),Tok2Cmdname(at),Tok2Cmdname(bt),Tok2Cmdname(ct));
8534  if ((call_failed=dA3[i].p(res,a,b,c)))
8535  {
8536  break;// leave loop, goto error handling
8537  }
8538  a->CleanUp();
8539  b->CleanUp();
8540  c->CleanUp();
8541  return FALSE;
8542  }
8543  i++;
8544  }
8545  // implicite type conversion ----------------------------------------------
8546  if (dA3[i].cmd!=op)
8547  {
8548  int ai,bi,ci;
8552  BOOLEAN failed=FALSE;
8553  i=0;
8554  //while ((dA3[i].cmd!=op)&&(dA3[i].cmd!=0)) i++;
8555  while (dA3[i].cmd==op)
8556  {
8557  if ((dA3[i].valid_for & NO_CONVERSION)==0)
8558  {
8559  if ((ai=iiTestConvert(at,dA3[i].arg1,dConvertTypes))!=0)
8560  {
8561  if ((bi=iiTestConvert(bt,dA3[i].arg2,dConvertTypes))!=0)
8562  {
8563  if ((ci=iiTestConvert(ct,dA3[i].arg3,dConvertTypes))!=0)
8564  {
8565  res->rtyp=dA3[i].res;
8566  if (currRing!=NULL)
8567  {
8568  if (check_valid(dA3[i].valid_for,op)) break;
8569  }
8570  if (traceit&TRACE_CALL)
8571  Print("call %s(%s,%s,%s)\n",
8572  iiTwoOps(op),Tok2Cmdname(dA3[i].arg1),
8573  Tok2Cmdname(dA3[i].arg2),Tok2Cmdname(dA3[i].arg3));
8574  failed= ((iiConvert(at,dA3[i].arg1,ai,a,an,dConvertTypes))
8575  || (iiConvert(bt,dA3[i].arg2,bi,b,bn,dConvertTypes))
8576  || (iiConvert(ct,dA3[i].arg3,ci,c,cn,dConvertTypes))
8577  || (call_failed=dA3[i].p(res,an,bn,cn)));
8578  // everything done, clean up temp. variables
8579  if (failed)
8580  {
8581  // leave loop, goto error handling
8582  break;
8583  }
8584  else
8585  {
8586  // everything ok, clean up and return
8587  an->CleanUp();
8588  bn->CleanUp();
8589  cn->CleanUp();
8593  //Print("op: %d,result typ:%d\n",op,res->rtyp);
8594  return FALSE;
8595  }
8596  }
8597  }
8598  }
8599  }
8600  i++;
8601  }
8602  an->CleanUp();
8603  bn->CleanUp();
8604  cn->CleanUp();
8608  }
8609  // error handling ---------------------------------------------------
8610  if (!errorreported)
8611  {
8612  const char *s=NULL;
8613  if ((at==0) && (a->Fullname()!=sNoName_fe))
8614  {
8615  s=a->Fullname();
8616  }
8617  else if ((bt==0) && (b->Fullname()!=sNoName_fe))
8618  {
8619  s=b->Fullname();
8620  }
8621  else if ((ct==0) && (c->Fullname()!=sNoName_fe))
8622  {
8623  s=c->Fullname();
8624  }
8625  if (s!=NULL)
8626  Werror("`%s` is not defined",s);
8627  else
8628  {
8629  i=0;
8630  //while ((dA3[i].cmd!=op)&&(dA3[i].cmd!=0)) i++;
8631  const char *s = iiTwoOps(op);
8632  Werror("%s(`%s`,`%s`,`%s`) failed"
8633  ,s,Tok2Cmdname(at),Tok2Cmdname(bt),Tok2Cmdname(ct));
8634  if ((!call_failed) && BVERBOSE(V_SHOW_USE))
8635  {
8636  while (dA3[i].cmd==op)
8637  {
8638  if(((at==dA3[i].arg1)
8639  ||(bt==dA3[i].arg2)
8640  ||(ct==dA3[i].arg3))
8641  && (dA3[i].res!=0))
8642  {
8643  Werror("expected %s(`%s`,`%s`,`%s`)"
8644  ,s,Tok2Cmdname(dA3[i].arg1)
8645  ,Tok2Cmdname(dA3[i].arg2)
8646  ,Tok2Cmdname(dA3[i].arg3));
8647  }
8648  i++;
8649  }
8650  }
8651  }
8652  }
8653  res->rtyp = UNKNOWN;
8654  }
8655  a->CleanUp();
8656  b->CleanUp();
8657  c->CleanUp();
8658  //Print("op: %d,result typ:%d\n",op,res->rtyp);
8659  return TRUE;
8660 }
8662 {
8663  memset(res,0,sizeof(sleftv));
8664 
8665  if (!errorreported)
8666  {
8667 #ifdef SIQ
8668  if (siq>0)
8669  {
8670  //Print("siq:%d\n",siq);
8672  memcpy(&d->arg1,a,sizeof(sleftv));
8673  a->Init();
8674  memcpy(&d->arg2,b,sizeof(sleftv));
8675  b->Init();
8676  memcpy(&d->arg3,c,sizeof(sleftv));
8677  c->Init();
8678  d->op=op;
8679  d->argc=3;
8680  res->data=(char *)d;
8681  res->rtyp=COMMAND;
8682  return FALSE;
8683  }
8684 #endif
8685  int at=a->Typ();
8686  // handling bb-objects ----------------------------------------------
8687  if (at>MAX_TOK)
8688  {
8689  blackbox *bb=getBlackboxStuff(at);
8690  if (bb!=NULL)
8691  {
8692  if(!bb->blackbox_Op3(op,res,a,b,c)) return FALSE;
8693  // else: no op defined
8694  }
8695  else
8696  return TRUE;
8697  if (errorreported) return TRUE;
8698  }
8699  int bt=b->Typ();
8700  int ct=c->Typ();
8701 
8702  iiOp=op;
8703  int i=0;
8704  while ((dArith3[i].cmd!=op)&&(dArith3[i].cmd!=0)) i++;
8705  return iiExprArith3TabIntern(res,op,a,b,c,dArith3+i,at,bt,ct,dConvertTypes);
8706  }
8707  a->CleanUp();
8708  b->CleanUp();
8709  c->CleanUp();
8710  //Print("op: %d,result typ:%d\n",op,res->rtyp);
8711  return TRUE;
8712 }
8714  const struct sValCmd3* dA3,
8715  int at,
8716  const struct sConvertTypes *dConvertTypes)
8717 {
8718  leftv b=a->next;
8719  a->next=NULL;
8720  int bt=b->Typ();
8721  leftv c=b->next;
8722  b->next=NULL;
8723  int ct=c->Typ();
8724  BOOLEAN bo=iiExprArith3TabIntern(res,op,a,b,c,dA3,at,bt,ct,dConvertTypes);
8725  b->next=c;
8726  a->next=b;
8727  a->CleanUp(); // to cleanup the chain, content already done
8728  return bo;
8729 }
8730 /*==================== operations with many arg. ===============================*/
8731 /* must be ordered: first operations for chars (infix ops),
8732  * then alphabetically */
8733 
8734 #if 0 // unused
8735 static BOOLEAN jjANY2LIST(leftv res, leftv v, int cnt)
8736 {
8737  // cnt = 0: all
8738  // cnt = 1: only first one
8739  leftv next;
8740  BOOLEAN failed = TRUE;
8741  if(v==NULL) return failed;
8742  res->rtyp = LIST_CMD;
8743  if(cnt) v->next = NULL;
8744  next = v->next; // saving next-pointer
8745  failed = jjLIST_PL(res, v);
8746  v->next = next; // writeback next-pointer
8747  return failed;
8748 }
8749 #endif
8750 
8752 {
8753  memset(res,0,sizeof(sleftv));
8754 
8755  if (!errorreported)
8756  {
8757 #ifdef SIQ
8758  if (siq>0)
8759  {
8760  //Print("siq:%d\n",siq);
8762  d->op=op;
8763  res->data=(char *)d;
8764  if (a!=NULL)
8765  {
8766  d->argc=a->listLength();
8767  // else : d->argc=0;
8768  memcpy(&d->arg1,a,sizeof(sleftv));
8769  switch(d->argc)
8770  {
8771  case 3:
8772  memcpy(&d->arg3,a->next->next,sizeof(sleftv));
8773  a->next->next->Init();
8774  /* no break */
8775  case 2:
8776  memcpy(&d->arg2,a->next,sizeof(sleftv));
8777  a->next->Init();
8778  a->next->next=d->arg2.next;
8779  d->arg2.next=NULL;
8780  /* no break */
8781  case 1:
8782  a->Init();
8783  a->next=d->arg1.next;
8784  d->arg1.next=NULL;
8785  }
8786  if (d->argc>3) a->next=NULL;
8787  a->name=NULL;
8788  a->rtyp=0;
8789  a->data=NULL;
8790  a->e=NULL;
8791  a->attribute=NULL;
8792  a->CleanUp();
8793  }
8794  res->rtyp=COMMAND;
8795  return FALSE;
8796  }
8797 #endif
8798  if ((a!=NULL) && (a->Typ()>MAX_TOK))
8799  {
8800  blackbox *bb=getBlackboxStuff(a->Typ());
8801  if (bb!=NULL)
8802  {
8803  if(!bb->blackbox_OpM(op,res,a)) return FALSE;
8804  // else: no op defined
8805  }
8806  else
8807  return TRUE;
8808  if (errorreported) return TRUE;
8809  }
8810  int args=0;
8811  if (a!=NULL) args=a->listLength();
8812 
8813  iiOp=op;
8814  int i=0;
8815  while ((dArithM[i].cmd!=op)&&(dArithM[i].cmd!=0)) i++;
8816  while (dArithM[i].cmd==op)
8817  {
8818  if ((args==dArithM[i].number_of_args)
8819  || (dArithM[i].number_of_args==-1)
8820  || ((dArithM[i].number_of_args==-2)&&(args>0)))
8821  {
8822  res->rtyp=dArithM[i].res;
8823  if (currRing!=NULL)
8824  {
8825  if (check_valid(dArithM[i].valid_for,op)) break;
8826  }
8827  if (traceit&TRACE_CALL)
8828  Print("call %s(... (%d args))\n", iiTwoOps(op),args);
8829  if (dArithM[i].p(res,a))
8830  {
8831  break;// leave loop, goto error handling
8832  }
8833  if (a!=NULL) a->CleanUp();
8834  //Print("op: %d,result typ:%d\n",op,res->rtyp);
8835  return FALSE;
8836  }
8837  i++;
8838  }
8839  // error handling
8840  if (!errorreported)
8841  {
8842  if ((args>0) && (a->rtyp==0) && (a->Name()!=sNoName_fe))
8843  {
8844  Werror("`%s` is not defined",a->Fullname());
8845  }
8846  else
8847  {
8848  const char *s = iiTwoOps(op);
8849  Werror("%s(...) failed",s);
8850  }
8851  }
8852  res->rtyp = UNKNOWN;
8853  }
8854  if (a!=NULL) a->CleanUp();
8855  //Print("op: %d,result typ:%d\n",op,res->rtyp);
8856  return TRUE;
8857 }
8858 
8859 /*=================== general utilities ============================*/
8860 int IsCmd(const char *n, int & tok)
8861 {
8862  int i;
8863  int an=1;
8864  int en=sArithBase.nLastIdentifier;
8865 
8866  loop
8867  //for(an=0; an<sArithBase.nCmdUsed; )
8868  {
8869  if(an>=en-1)
8870  {
8871  if (strcmp(n, sArithBase.sCmds[an].name) == 0)
8872  {
8873  i=an;
8874  break;
8875  }
8876  else if ((an!=en) && (strcmp(n, sArithBase.sCmds[en].name) == 0))
8877  {
8878  i=en;
8879  break;
8880  }
8881  else
8882  {
8883  // -- blackbox extensions:
8884  // return 0;
8885  return blackboxIsCmd(n,tok);
8886  }
8887  }
8888  i=(an+en)/2;
8889  if (*n < *(sArithBase.sCmds[i].name))
8890  {
8891  en=i-1;
8892  }
8893  else if (*n > *(sArithBase.sCmds[i].name))
8894  {
8895  an=i+1;
8896  }
8897  else
8898  {
8899  int v=strcmp(n,sArithBase.sCmds[i].name);
8900  if(v<0)
8901  {
8902  en=i-1;
8903  }
8904  else if(v>0)
8905  {
8906  an=i+1;
8907  }
8908  else /*v==0*/
8909  {
8910  break;
8911  }
8912  }
8913  }
8915  tok=sArithBase.sCmds[i].tokval;
8916  if(sArithBase.sCmds[i].alias==2)
8917  {
8918  Warn("outdated identifier `%s` used - please change your code",
8919  sArithBase.sCmds[i].name);
8920  sArithBase.sCmds[i].alias=1;
8921  }
8922  #if 0
8923  if (currRingHdl==NULL)
8924  {
8925  #ifdef SIQ
8926  if (siq<=0)
8927  {
8928  #endif
8929  if ((tok>=BEGIN_RING) && (tok<=END_RING))
8930  {
8931  WerrorS("no ring active");
8932  return 0;
8933  }
8934  #ifdef SIQ
8935  }
8936  #endif
8937  }
8938  #endif
8939  if (!expected_parms)
8940  {
8941  switch (tok)
8942  {
8943  case IDEAL_CMD:
8944  case INT_CMD:
8945  case INTVEC_CMD:
8946  case MAP_CMD:
8947  case MATRIX_CMD:
8948  case MODUL_CMD:
8949  case POLY_CMD:
8950  case PROC_CMD:
8951  case RING_CMD:
8952  case STRING_CMD:
8953  cmdtok = tok;
8954  break;
8955  }
8956  }
8957  return sArithBase.sCmds[i].toktype;
8958 }
8959 static int iiTabIndex(const jjValCmdTab dArithTab, const int len, const int op)
8960 {
8961  // user defined types are not in the pre-computed table:
8962  if (op>MAX_TOK) return 0;
8963 
8964  int a=0;
8965  int e=len;
8966  int p=len/2;
8967  do
8968  {
8969  if (op==dArithTab[p].cmd) return dArithTab[p].start;
8970  if (op<dArithTab[p].cmd) e=p-1;
8971  else a = p+1;
8972  p=a+(e-a)/2;
8973  }
8974  while ( a <= e);
8975 
8976  // catch missing a cmd:
8977  // may be missing as a op for blackbox, if the first operand is "undef" instead of bb
8978  // Print("op %d (%c) unknown",op,op);
8979  return 0;
8980 }
8981 
8982 typedef char si_char_2[2];
8984 const char * Tok2Cmdname(int tok)
8985 {
8986  if (tok <= 0)
8987  {
8988  return sArithBase.sCmds[0].name;
8989  }
8990  if (tok==ANY_TYPE) return "any_type";
8991  if (tok==COMMAND) return "command";
8992  if (tok==NONE) return "nothing";
8993  if (tok < 128)
8994  {
8995  Tok2Cmdname_buf[1]=(char)tok;
8996  return Tok2Cmdname_buf;
8997  }
8998  //if (tok==IFBREAK) return "if_break";
8999  //if (tok==VECTOR_FROM_POLYS) return "vector_from_polys";
9000  //if (tok==ORDER_VECTOR) return "ordering";
9001  //if (tok==REF_VAR) return "ref";
9002  //if (tok==OBJECT) return "object";
9003  //if (tok==PRINT_EXPR) return "print_expr";
9004  if (tok==IDHDL) return "identifier";
9005  if (tok>MAX_TOK) return getBlackboxName(tok);
9006  unsigned i;
9007  for(i=0; i<sArithBase.nCmdUsed; i++)
9008  //while (sArithBase.sCmds[i].tokval!=0)
9009  {
9010  if ((sArithBase.sCmds[i].tokval == tok)&&
9011  (sArithBase.sCmds[i].alias==0))
9012  {
9013  return sArithBase.sCmds[i].name;
9014  }
9015  }
9016  // try gain for alias/old names:
9017  for(i=0; i<sArithBase.nCmdUsed; i++)
9018  {
9019  if (sArithBase.sCmds[i].tokval == tok)
9020  {
9021  return sArithBase.sCmds[i].name;
9022  }
9023  }
9024  return sArithBase.sCmds[0].name;
9025 }
9026 
9027 
9028 /*---------------------------------------------------------------------*/
9029 /**
9030  * @brief compares to entry of cmdsname-list
9031 
9032  @param[in] a
9033  @param[in] b
9034 
9035  @return <ReturnValue>
9036 **/
9037 /*---------------------------------------------------------------------*/
9038 static int _gentable_sort_cmds( const void *a, const void *b )
9039 {
9040  cmdnames *pCmdL = (cmdnames*)a;
9041  cmdnames *pCmdR = (cmdnames*)b;
9042 
9043  if(a==NULL || b==NULL) return 0;
9044 
9045  /* empty entries goes to the end of the list for later reuse */
9046  if(pCmdL->name==NULL) return 1;
9047  if(pCmdR->name==NULL) return -1;
9048 
9049  /* $INVALID$ must come first */
9050  if(strcmp(pCmdL->name, "$INVALID$")==0) return -1;
9051  if(strcmp(pCmdR->name, "$INVALID$")==0) return 1;
9052 
9053  /* tokval=-1 are reserved names at the end */
9054  if (pCmdL->tokval==-1)
9055  {
9056  if (pCmdR->tokval==-1)
9057  return strcmp(pCmdL->name, pCmdR->name);
9058  /* pCmdL->tokval==-1, pCmdL goes at the end */
9059  return 1;
9060  }
9061  /* pCmdR->tokval==-1, pCmdR goes at the end */
9062  if(pCmdR->tokval==-1) return -1;
9063 
9064  return strcmp(pCmdL->name, pCmdR->name);
9065 }
9066 
9067 /*---------------------------------------------------------------------*/
9068 /**
9069  * @brief initialisation of arithmetic structured data
9070 
9071  @retval 0 on success
9072 
9073 **/
9074 /*---------------------------------------------------------------------*/
9076 {
9077  //printf("iiInitArithmetic()\n");
9078  memset(&sArithBase, 0, sizeof(sArithBase));
9079  iiInitCmdName();
9080  /* fix last-identifier */
9081 #if 0
9082  /* we expect that gentable allready did every thing */
9085  if(sArithBase.sCmds[sArithBase.nLastIdentifier].tokval>=0) break;
9086  }
9087 #endif
9088  //Print("L=%d\n", sArithBase.nLastIdentifier);
9089 
9090  //iiArithAddCmd(szName, nAlias, nTokval, nToktype);
9091  //iiArithAddCmd("mygcd", 1, GCD_CMD, CMD_2);
9092 
9093  //iiArithAddCmd("Top", 0,-1,0);
9094 
9095 
9096  //for(i=0; i<sArithBase.nCmdUsed; i++) {
9097  // printf("CMD[%03d] %s, %d, %d, %d\n", i,
9098  // sArithBase.sCmds[i].name,
9099  // sArithBase.sCmds[i].alias,
9100  // sArithBase.sCmds[i].tokval,
9101  // sArithBase.sCmds[i].toktype);
9102  //}
9103  //iiArithRemoveCmd("Top");
9104  //iiArithAddCmd("mygcd", 2, GCD_CMD, CMD_2);
9105  //iiArithRemoveCmd("mygcd");
9106  //iiArithAddCmd("kkk", 1, 1234, CMD_1);
9107  return 0;
9108 }
9109 
9110 int iiArithFindCmd(const char *szName)
9111 {
9112  int an=0;
9113  int i = 0,v = 0;
9114  int en=sArithBase.nLastIdentifier;
9115 
9116  loop
9117  //for(an=0; an<sArithBase.nCmdUsed; )
9118  {
9119  if(an>=en-1)
9120  {
9121  if (strcmp(szName, sArithBase.sCmds[an].name) == 0)
9122  {
9123  //Print("RET-an=%d %s\n", an, sArithBase.sCmds[an].name);
9124  return an;
9125  }
9126  else if (strcmp(szName, sArithBase.sCmds[en].name) == 0)
9127  {
9128  //Print("RET-en=%d %s\n", en, sArithBase.sCmds[en].name);
9129  return en;
9130  }
9131  else
9132  {
9133  //Print("RET- 1\n");
9134  return -1;
9135  }
9136  }
9137  i=(an+en)/2;
9138  if (*szName < *(sArithBase.sCmds[i].name))
9139  {
9140  en=i-1;
9141  }
9142  else if (*szName > *(sArithBase.sCmds[i].name))
9143  {
9144  an=i+1;
9145  }
9146  else
9147  {
9148  v=strcmp(szName,sArithBase.sCmds[i].name);
9149  if(v<0)
9150  {
9151  en=i-1;
9152  }
9153  else if(v>0)
9154  {
9155  an=i+1;
9156  }
9157  else /*v==0*/
9158  {
9159  //Print("RET-i=%d %s\n", i, sArithBase.sCmds[i].name);
9160  return i;
9161  }
9162  }
9163  }
9164  //if(i>=0 && i<sArithBase.nCmdUsed)
9165  // return i;
9166  //PrintS("RET-2\n");
9167  return -2;
9168 }
9169 
9170 char *iiArithGetCmd( int nPos )
9171 {
9172  if(nPos<0) return NULL;
9173  if(nPos<(int)sArithBase.nCmdUsed)
9174  return sArithBase.sCmds[nPos].name;
9175  return NULL;
9176 }
9177 
9178 int iiArithRemoveCmd(const char *szName)
9179 {
9180  int nIndex;
9181  if(szName==NULL) return -1;
9182 
9183  nIndex = iiArithFindCmd(szName);
9184  if(nIndex<0 || nIndex>=(int)sArithBase.nCmdUsed)
9185  {
9186  Print("'%s' not found (%d)\n", szName, nIndex);
9187  return -1;
9188  }
9189  omFree(sArithBase.sCmds[nIndex].name);
9190  sArithBase.sCmds[nIndex].name=NULL;
9191  qsort(sArithBase.sCmds, sArithBase.nCmdUsed, sizeof(cmdnames),
9192  (&_gentable_sort_cmds));
9193  sArithBase.nCmdUsed--;
9194 
9195  /* fix last-identifier */
9198  {
9199  if(sArithBase.sCmds[sArithBase.nLastIdentifier].tokval>=0) break;
9200  }
9201  //Print("L=%d\n", sArithBase.nLastIdentifier);
9202  return 0;
9203 }
9204 
9206  const char *szName,
9207  short nAlias,
9208  short nTokval,
9209  short nToktype,
9210  short nPos
9211  )
9212 {
9213  //printf("AddCmd(%s, %d, %d, %d, %d)\n", szName, nAlias,
9214  // nTokval, nToktype, nPos);
9215  if(nPos>=0)
9216  {
9217  // no checks: we rely on a correct generated code in iparith.inc
9218  assume((unsigned)nPos < sArithBase.nCmdAllocated);
9219  assume(szName!=NULL);
9220  sArithBase.sCmds[nPos].name = omStrDup(szName);
9221  sArithBase.sCmds[nPos].alias = nAlias;
9222  sArithBase.sCmds[nPos].tokval = nTokval;
9223  sArithBase.sCmds[nPos].toktype = nToktype;
9224  sArithBase.nCmdUsed++;
9225  //if(nTokval>0) sArithBase.nLastIdentifier++;
9226  }
9227  else
9228  {
9229  if(szName==NULL) return -1;
9230  int nIndex = iiArithFindCmd(szName);
9231  if(nIndex>=0)
9232  {
9233  Print("'%s' already exists at %d\n", szName, nIndex);
9234  return -1;
9235  }
9236 
9238  {
9239  /* needs to create new slots */
9240  unsigned long nSize = (sArithBase.nCmdAllocated+1)*sizeof(cmdnames);
9241  sArithBase.sCmds = (cmdnames *)omRealloc(sArithBase.sCmds, nSize);
9242  if(sArithBase.sCmds==NULL) return -1;
9244  }
9245  /* still free slots available */
9246  sArithBase.sCmds[sArithBase.nCmdUsed].name = omStrDup(szName);
9247  sArithBase.sCmds[sArithBase.nCmdUsed].alias = nAlias;
9248  sArithBase.sCmds[sArithBase.nCmdUsed].tokval = nTokval;
9249  sArithBase.sCmds[sArithBase.nCmdUsed].toktype = nToktype;
9250  sArithBase.nCmdUsed++;
9251 
9252  qsort(sArithBase.sCmds, sArithBase.nCmdUsed, sizeof(cmdnames),
9253  (&_gentable_sort_cmds));
9256  {
9257  if(sArithBase.sCmds[sArithBase.nLastIdentifier].tokval>=0) break;
9258  }
9259  //Print("L=%d\n", sArithBase.nLastIdentifier);
9260  }
9261  return 0;
9262 }
9263 
9264 static BOOLEAN check_valid(const int p, const int op)
9265 {
9266  #ifdef HAVE_PLURAL
9267  if (rIsPluralRing(currRing))
9268  {
9269  if ((p & NC_MASK)==NO_NC)
9270  {
9271  WerrorS("not implemented for non-commutative rings");
9272  return TRUE;
9273  }
9274  else if ((p & NC_MASK)==COMM_PLURAL)
9275  {
9276  Warn("assume commutative subalgebra for cmd `%s` in >>%s<<",Tok2Cmdname(op),my_yylinebuf);
9277  return FALSE;
9278  }
9279  /* else, ALLOW_PLURAL */
9280  }
9281  else if (currRing->isLPring)
9282  {
9283  if ((p & ALLOW_LP)==0)
9284  {
9285  Werror("`%s` not implemented for letterplace rings in >>%s<<",Tok2Cmdname(op),my_yylinebuf);
9286  return TRUE;
9287  }
9288  }
9289  #endif
9290 #ifdef HAVE_RINGS
9291  if (rField_is_Ring(currRing))
9292  {
9293  if ((p & RING_MASK)==0 /*NO_RING*/)
9294  {
9295  WerrorS("not implemented for rings with rings as coeffients");
9296  return TRUE;
9297  }
9298  /* else ALLOW_RING */
9299  else if (((p & ZERODIVISOR_MASK)==NO_ZERODIVISOR)
9300  &&(!rField_is_Domain(currRing)))
9301  {
9302  WerrorS("domain required as coeffients");
9303  return TRUE;
9304  }
9305  /* else ALLOW_ZERODIVISOR */
9306  else if(((p & WARN_RING)==WARN_RING)&&(myynest==0))
9307  {
9308  WarnS("considering the image in Q[...]");
9309  }
9310  }
9311 #endif
9312  return FALSE;
9313 }
9314 // --------------------------------------------------------------------
9316 {
9317  if ((currRing!=NULL)
9319  && (!rField_is_Z(currRing)))
9320  {
9321  WerrorS("not implemented for rings with rings as coeffients (except ZZ)");
9322  return TRUE;
9323  }
9324  coeffs cf;
9325  lists c=(lists)u->CopyD(); // list of ideal or bigint/int
9326  int rl=c->nr+1;
9327  int return_type=c->m[0].Typ();
9328  if ((return_type!=IDEAL_CMD)
9329  && (return_type!=MODUL_CMD)
9330  && (return_type!=MATRIX_CMD)
9331  && (return_type!=POLY_CMD))
9332  {
9333  if((return_type==BIGINT_CMD)
9334  ||(return_type==INT_CMD))
9335  return_type=BIGINT_CMD;
9336  else if (return_type==LIST_CMD)
9337  {
9338  // create a tmp list of the correct size
9339  lists res_l=(lists)omAllocBin(slists_bin);
9340  res_l->Init(rl /*c->nr+1*/);
9341  BOOLEAN bo=FALSE;
9342  int tab_pos=iiTabIndex(dArithTab2,JJTAB2LEN,CHINREM_CMD);
9343  for (unsigned i=0;i<=(unsigned)c->nr;i++)
9344  {
9345  sleftv tmp;
9346  tmp.Copy(v);
9347  bo=iiExprArith2TabIntern(&res_l->m[i],&c->m[i],CHINREM_CMD,&tmp,TRUE,dArith2+tab_pos,c->m[i].rtyp,tmp.rtyp,dConvertTypes);
9348  if (bo) { Werror("chinrem failed for list entry %d",i+1); break;}
9349  }
9350  c->Clean();
9351  res->data=res_l;
9352  res->rtyp=LIST_CMD;
9353  return bo;
9354  }
9355  else
9356  {
9357  c->Clean();
9358  WerrorS("poly/ideal/module/matrix/list expected");
9359  return TRUE;
9360  }
9361  }
9362  if (return_type==BIGINT_CMD)
9363  cf=coeffs_BIGINT;
9364  else
9365  {
9366  cf=currRing->cf;
9367  if (nCoeff_is_Extension(cf) && (cf->extRing!=NULL))
9368  cf=cf->extRing->cf;
9369  }
9370  lists pl=NULL;
9371  intvec *p=NULL;
9372  if (v->Typ()==LIST_CMD) pl=(lists)v->Data();
9373  else p=(intvec*)v->Data();
9374  ideal result;
9375  ideal *x=(ideal *)omAlloc(rl*sizeof(ideal));
9376  number *xx=NULL;
9378  int i;
9379  if (return_type!=BIGINT_CMD)
9380  {
9381  for(i=rl-1;i>=0;i--)
9382  {
9383  if (c->m[i].Typ()!=return_type)
9384  {
9385  Werror("%s expected at pos %d",Tok2Cmdname(return_type),i+1);
9386  omFree(x); // delete c
9387  return TRUE;
9388  }
9389  if (return_type==POLY_CMD)
9390  {
9391  x[i]=idInit(1,1);
9392  x[i]->m[0]=(poly)c->m[i].CopyD();
9393  }
9394  else
9395  {
9396  x[i]=(ideal)c->m[i].CopyD();
9397  }
9398  //c->m[i].Init();
9399  }
9400  }
9401  else
9402  {
9403  if (nMap==NULL)
9404  {
9405  Werror("not implemented: map bigint -> %s", nCoeffName(cf));
9406  return TRUE;
9407  }
9408  xx=(number *)omAlloc(rl*sizeof(number));
9409  for(i=rl-1;i>=0;i--)
9410  {
9411  if (c->m[i].Typ()==INT_CMD)
9412  {
9413  xx[i]=n_Init(((int)(long)c->m[i].Data()),cf);
9414  }
9415  else if (c->m[i].Typ()==BIGINT_CMD)
9416  {
9417  xx[i]=nMap((number)c->m[i].Data(),coeffs_BIGINT,cf);
9418  }
9419  else
9420  {
9421  Werror("bigint expected at pos %d",i+1);
9422  omFree(x); // delete c
9423  omFree(xx); // delete c
9424  return TRUE;
9425  }
9426  }
9427  }
9428  number *q=(number *)omAlloc(rl*sizeof(number));
9429  if (p!=NULL)
9430  {
9431  for(i=rl-1;i>=0;i--)
9432  {
9433  q[i]=n_Init((*p)[i], cf);
9434  }
9435  }
9436  else
9437  {
9438  for(i=rl-1;i>=0;i--)
9439  {
9440  if (pl->m[i].Typ()==INT_CMD)
9441  {
9442  q[i]=n_Init((int)(long)pl->m[i].Data(),cf);
9443  }
9444  else if (pl->m[i].Typ()==BIGINT_CMD)
9445  {
9446  q[i]=nMap((number)(pl->m[i].Data()),coeffs_BIGINT,cf);
9447  }
9448  else
9449  {
9450  Werror("bigint expected at pos %d",i+1);
9451  for(i++;i<rl;i++)
9452  {
9453  n_Delete(&(q[i]),cf);
9454  }
9455  omFree(x); // delete c
9456  omFree(q); // delete pl
9457  if (xx!=NULL) omFree(xx); // delete c
9458  return TRUE;
9459  }
9460  }
9461  }
9462  if (return_type==BIGINT_CMD)
9463  {
9464  CFArray i_v(rl);
9465  number n=n_ChineseRemainderSym(xx,q,rl,TRUE,i_v,coeffs_BIGINT);
9466  res->data=(char *)n;
9467  }
9468  else
9469  {
9470  result=id_ChineseRemainder(x,q,rl,currRing); // deletes also x
9471  c->Clean();
9472  if ((return_type==POLY_CMD) &&(result!=NULL))
9473  {
9474  res->data=(char *)result->m[0];
9475  result->m[0]=NULL;
9476  idDelete(&result);
9477  }
9478  else
9479  res->data=(char *)result;
9480  }
9481  for(i=rl-1;i>=0;i--)
9482  {
9483  n_Delete(&(q[i]),cf);
9484  }
9485  omFree(q);
9486  res->rtyp=return_type;
9487  return result==NULL;
9488 }
9490 {
9491  lists c=(lists)u->CopyD();
9492  lists res_l=(lists)omAllocBin(slists_bin);
9493  res_l->Init(c->nr+1);
9494  BOOLEAN bo=FALSE;
9495  int tab_pos=iiTabIndex(dArithTab2,JJTAB2LEN,FAREY_CMD);
9496  for (unsigned i=0;i<=(unsigned)c->nr;i++)
9497  {
9498  sleftv tmp;
9499  tmp.Copy(v);
9500  bo=iiExprArith2TabIntern(&res_l->m[i],&c->m[i],FAREY_CMD,&tmp,TRUE,dArith2+tab_pos,c->m[i].rtyp,tmp.rtyp,dConvertTypes);
9501  if (bo) { Werror("farey failed for list entry %d",i+1); break;}
9502  }
9503  c->Clean();
9504  res->data=res_l;
9505  return bo;
9506 }
9507 // --------------------------------------------------------------------
9508 static int jjCOMPARE_ALL(const void * aa, const void * bb)
9509 {
9510  leftv a=(leftv)aa;
9511  int at=a->Typ();
9512  leftv b=(leftv)bb;
9513  int bt=b->Typ();;
9514  if (at < bt) return -1;
9515  if (at > bt) return 1;
9516  int tab_pos=iiTabIndex(dArithTab2,JJTAB2LEN,'<');
9517  sleftv tmp;
9518  memset(&tmp,0,sizeof(sleftv));
9519  iiOp='<';
9520  BOOLEAN bo=iiExprArith2TabIntern(&tmp,a,'<',b,FALSE,dArith2+tab_pos,at,bt,dConvertTypes);
9521  if (bo)
9522  {
9523  Werror(" no `<` for %s",Tok2Cmdname(at));
9524  unsigned long ad=(unsigned long)a->Data();
9525  unsigned long bd=(unsigned long)b->Data();
9526  if (ad<bd) return -1;
9527  else if (ad==bd) return 0;
9528  else return 1;
9529  }
9530  else if (tmp.data==NULL) /* not < */
9531  {
9532  iiOp=EQUAL_EQUAL;
9533  tab_pos=iiTabIndex(dArithTab2,JJTAB2LEN,EQUAL_EQUAL);
9534  bo=iiExprArith2TabIntern(&tmp,a,EQUAL_EQUAL,b,FALSE,dArith2+tab_pos,at,bt,dConvertTypes);
9535  if (bo)
9536  {
9537  Werror(" no `==` for %s",Tok2Cmdname(at));
9538  unsigned long ad=(unsigned long)a->Data();
9539  unsigned long bd=(unsigned long)b->Data();
9540  if (ad<bd) return -1;
9541  else if (ad==bd) return 0;
9542  else return 1;
9543  }
9544  else if (tmp.data==NULL) /* not <,== */ return 1;
9545  else return 0;
9546  }
9547  else return -1;
9548 }
9550 {
9551  lists l=(lists)arg->Data();
9552  if (l->nr>0)
9553  {
9554  qsort(l->m,l->nr+1,sizeof(sleftv),jjCOMPARE_ALL);
9555  }
9556  return FALSE;
9557 }
9559 {
9560  lists l=(lists)arg->Data();
9561  if (l->nr>0)
9562  {
9563  qsort(l->m,l->nr+1,sizeof(sleftv),jjCOMPARE_ALL);
9564  int i, j, len;
9565  len=l->nr;
9566  i=0;
9567  while(i<len)
9568  {
9569  if(jjCOMPARE_ALL(&(l->m[i]),&(l->m[i+1]))==0)
9570  {
9571  l->m[i].CleanUp();
9572  for(j=i; j<len;j++) l->m[j]=l->m[j+1];
9573  memset(&(l->m[len]),0,sizeof(sleftv));
9574  l->m[len].rtyp=DEF_CMD;
9575  len--;
9576  }
9577  else
9578  i++;
9579  }
9580  //Print("new len:%d\n",len);
9581  }
9582  return FALSE;
9583 }
ideal getMinorIdealCache(const matrix mat, const int minorSize, const int k, const ideal iSB, const int cacheStrategy, const int cacheN, const int cacheW, const bool allDifferent)
Returns the specified set of minors (= subdeterminantes) of the given matrix.
ideal getMinorIdeal(const matrix mat, const int minorSize, const int k, const char *algorithm, const ideal iSB, const bool allDifferent)
Returns the specified set of minors (= subdeterminantes) of the given matrix.
ideal getMinorIdealHeuristic(const matrix mat, const int minorSize, const int k, const ideal iSB, const bool allDifferent)
Returns the specified set of minors (= subdeterminantes) of the given matrix.
void * atGet(idhdl root, const char *name, int t, void *defaultReturnValue)
Definition: attrib.cc:131
void atSet(idhdl root, char *name, void *data, int typ)
Definition: attrib.cc:152
#define atKill(H, A)
Definition: attrib.h:49
static int ABS(int v)
Definition: auxiliary.h:110
long int64
Definition: auxiliary.h:66
static int si_max(const int a, const int b)
Definition: auxiliary.h:138
int BOOLEAN
Definition: auxiliary.h:85
#define TRUE
Definition: auxiliary.h:98
#define FALSE
Definition: auxiliary.h:94
void * ADDRESS
Definition: auxiliary.h:133
static int si_min(const int a, const int b)
Definition: auxiliary.h:139
bigintmat * bimSub(bigintmat *a, bigintmat *b)
Definition: bigintmat.cc:218
bigintmat * bimMult(bigintmat *a, bigintmat *b)
Definition: bigintmat.cc:255
intvec * bim2iv(bigintmat *b)
Definition: bigintmat.cc:341
bigintmat * bimAdd(bigintmat *a, bigintmat *b)
Matrix-Add/-Sub/-Mult so oder mit operator+/-/* ? @Note: NULL as a result means an error (non-compati...
Definition: bigintmat.cc:182
blackbox * getBlackboxStuff(const int t)
return the structure to the type given by t
Definition: blackbox.cc:16
const char * getBlackboxName(const int t)
return the name to the type given by t (r/o)
Definition: blackbox.cc:186
int blackboxIsCmd(const char *n, int &tok)
used by scanner: returns ROOT_DECL for known types (and the type number in tok)
Definition: blackbox.cc:192
void printBlackboxTypes()
list all defined type (for debugging)
Definition: blackbox.cc:209
CanonicalForm pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition: cf_gcd.cc:248
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:49
int l
Definition: cfEzgcd.cc:93
int m
Definition: cfEzgcd.cc:121
int i
Definition: cfEzgcd.cc:125
int k
Definition: cfEzgcd.cc:92
Variable x
Definition: cfModGcd.cc:4023
int p
Definition: cfModGcd.cc:4019
g
Definition: cfModGcd.cc:4031
CanonicalForm fp
Definition: cfModGcd.cc:4043
CanonicalForm cf
Definition: cfModGcd.cc:4024
CanonicalForm b
Definition: cfModGcd.cc:4044
CanonicalForm map(const CanonicalForm &primElem, const Variable &alpha, const CanonicalForm &F, const Variable &beta)
map from to such that is mapped onto
Definition: cf_map_ext.cc:400
int ipower(int b, int m)
int ipower ( int b, int m )
Definition: cf_util.cc:25
FILE * f
Definition: checklibs.c:9
poly singclap_pmod(poly f, poly g, const ring r)
Definition: clapsing.cc:604
ideal singclap_factorize(poly f, intvec **v, int with_exps, const ring r)
Definition: clapsing.cc:838
poly singclap_pdivide(poly f, poly g, const ring r)
Definition: clapsing.cc:557
BOOLEAN singclap_extgcd(poly f, poly g, poly &res, poly &pa, poly &pb, const ring r)
Definition: clapsing.cc:422
poly singclap_det(const matrix m, const ring s)
Definition: clapsing.cc:1635
number singclap_det_bi(bigintmat *m, const coeffs cf)
Definition: clapsing.cc:1676
int singclap_det_i(intvec *m, const ring)
Definition: clapsing.cc:1658
ideal singclap_sqrfree(poly f, intvec **v, int with_exps, const ring r)
Definition: clapsing.cc:1216
char name() const
Definition: variable.cc:122
Variable next() const
Definition: factory.h:137
Matrices of numbers.
Definition: bigintmat.h:52
int cols() const
Definition: bigintmat.h:145
int rows() const
Definition: bigintmat.h:146
int compare(const bigintmat *op) const
Definition: bigintmat.cc:362
Definition: idrec.h:35
utypes data
Definition: idrec.h:40
int typ
Definition: idrec.h:43
short ref
Definition: idrec.h:46
const char * id
Definition: idrec.h:39
Definition: intvec.h:21
void makeVector()
Definition: intvec.h:100
intvec * delete_pos(int p)
Definition: intvec.cc:824
void show(int mat=0, int spaces=0) const
Definition: intvec.cc:149
int min_in()
Definition: intvec.h:119
int length() const
Definition: intvec.h:92
int compare(const intvec *o) const
Definition: intvec.cc:206
int cols() const
Definition: intvec.h:93
int rows() const
Definition: intvec.h:94
long rank
Definition: matpol.h:19
int & rows()
Definition: matpol.h:23
int & cols()
Definition: matpol.h:24
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
void * CopyD(int t)
Definition: subexpr.cc:745
int Typ()
Definition: subexpr.cc:1039
const char * name
Definition: subexpr.h:87
package req_packhdl
Definition: subexpr.h:106
int rtyp
Definition: subexpr.h:91
void * Data()
Definition: subexpr.cc:1182
void Init()
Definition: subexpr.h:107
leftv next
Definition: subexpr.h:86
int listLength()
Definition: subexpr.cc:57
void Copy(leftv e)
Definition: subexpr.cc:720
const char * Fullname()
Definition: subexpr.h:125
void * data
Definition: subexpr.h:88
leftv Next()
Definition: subexpr.h:136
void CleanUp(ring r=currRing)
Definition: subexpr.cc:354
BITSET flag
Definition: subexpr.h:90
Subexpr e
Definition: subexpr.h:105
const char * Name()
Definition: subexpr.h:120
attr attribute
Definition: subexpr.h:89
Definition: lists.h:23
sleftv * m
Definition: lists.h:45
void Clean(ring r=currRing)
Definition: lists.h:25
INLINE_THIS void Init(int l=0)
int nr
Definition: lists.h:43
Coefficient rings, fields and other domains suitable for Singular polynomials.
static FORCE_INLINE int n_ParDeg(number n, const coeffs r)
Definition: coeffs.h:792
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
Definition: coeffs.h:636
static FORCE_INLINE number n_Param(const int iParameter, const coeffs r)
return the (iParameter^th) parameter as a NEW number NOTE: parameter numbering: 1....
Definition: coeffs.h:805
static FORCE_INLINE long n_Int(number &n, const coeffs r)
conversion of n to an int; 0 if not possible in Z/pZ: the representing int lying in (-p/2 ....
Definition: coeffs.h:547
static FORCE_INLINE char * nCoeffString(const coeffs cf)
TODO: make it a virtual method of coeffs, together with: Decompose & Compose, rParameter & rPar.
Definition: coeffs.h:981
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of 'a' and 'b', i.e., a+b
Definition: coeffs.h:656
static FORCE_INLINE number n_GetDenom(number &n, const coeffs r)
return the denominator of n (if elements of r are by nature not fractional, result is 1)
Definition: coeffs.h:603
static FORCE_INLINE BOOLEAN nCoeff_is_Extension(const coeffs r)
Definition: coeffs.h:868
static FORCE_INLINE number n_Random(siRandProc p, number p1, number p2, const coeffs cf)
Definition: coeffs.h:988
static FORCE_INLINE char * nCoeffName(const coeffs cf)
Definition: coeffs.h:985
@ n_algExt
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic
Definition: coeffs.h:36
static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
in Z: return the gcd of 'a' and 'b' in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ,...
Definition: coeffs.h:686
static FORCE_INLINE BOOLEAN n_IsUnit(number n, const coeffs r)
TRUE iff n has a multiplicative inverse in the given coeff field/ring r.
Definition: coeffs.h:515
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff 'n' is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2),...
Definition: coeffs.h:494
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
Definition: coeffs.h:721
static FORCE_INLINE number n_InpNeg(number n, const coeffs r)
in-place negation of n MUST BE USED: n = n_InpNeg(n) (no copy is returned)
Definition: coeffs.h:557
static FORCE_INLINE void n_Power(number a, int b, number *res, const coeffs r)
fill res with the power a^b
Definition: coeffs.h:632
static FORCE_INLINE number n_Farey(number a, number b, const coeffs r)
Definition: coeffs.h:789
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of 'a' and 'b', i.e., a/b; raises an error if 'b' is not invertible in r exceptio...
Definition: coeffs.h:615
static FORCE_INLINE number n_RePart(number i, const coeffs cf)
Definition: coeffs.h:812
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition: coeffs.h:464
static FORCE_INLINE int n_Size(number n, const coeffs r)
return a non-negative measure for the complexity of n; return 0 only when n represents zero; (used fo...
Definition: coeffs.h:570
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of 'a' and 'b', i.e., a-b
Definition: coeffs.h:669
static FORCE_INLINE number n_ChineseRemainderSym(number *a, number *b, int rl, BOOLEAN sym, CFArray &inv_cache, const coeffs r)
Definition: coeffs.h:786
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
static FORCE_INLINE number n_ExtGcd(number a, number b, number *s, number *t, const coeffs r)
beware that ExtGCD is only relevant for a few chosen coeff. domains and may perform something unexpec...
Definition: coeffs.h:693
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:538
static FORCE_INLINE number n_IntMod(number a, number b, const coeffs r)
for r a field, return n_Init(0,r) always: n_Div(a,b,r)*b+n_IntMod(a,b,r)==a n_IntMod(a,...
Definition: coeffs.h:628
static FORCE_INLINE BOOLEAN n_DivBy(number a, number b, const coeffs r)
test whether 'a' is divisible 'b'; for r encoding a field: TRUE iff 'b' does not represent zero in Z:...
Definition: coeffs.h:775
static FORCE_INLINE BOOLEAN n_Equal(number a, number b, const coeffs r)
TRUE iff 'a' and 'b' represent the same number; they may have different representations.
Definition: coeffs.h:460
static FORCE_INLINE number n_GetNumerator(number &n, const coeffs r)
return the numerator of n (if elements of r are by nature not fractional, result is n)
Definition: coeffs.h:608
static FORCE_INLINE number n_SubringGcd(number a, number b, const coeffs r)
Definition: coeffs.h:688
static FORCE_INLINE number n_ImPart(number i, const coeffs cf)
Definition: coeffs.h:815
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition: coeffs.h:578
static FORCE_INLINE BOOLEAN nCoeff_is_transExt(const coeffs r)
TRUE iff r represents a transcendental extension field.
Definition: coeffs.h:940
#define Print
Definition: emacs.cc:80
#define Warn
Definition: emacs.cc:77
#define WarnS
Definition: emacs.cc:78
return result
Definition: facAbsBiFact.cc:76
const CanonicalForm int s
Definition: facAbsFact.cc:55
CanonicalForm res
Definition: facAbsFact.cc:64
const CanonicalForm & w
Definition: facAbsFact.cc:55
b *CanonicalForm B
Definition: facBivar.cc:52
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
bool found
Definition: facFactorize.cc:56
int j
Definition: facHensel.cc:105
void(* WerrorS_callback)(const char *s)
Definition: feFopen.cc:21
void WerrorS(const char *s)
Definition: feFopen.cc:24
FILE * feFopen(const char *path, const char *mode, char *where, short useWerror, short path_only)
Definition: feFopen.cc:47
short errorreported
Definition: feFopen.cc:23
int myynest
Definition: febase.cc:41
char my_yylinebuf[80]
Definition: febase.cc:43
void monitor(void *F, int mode)
Definition: febase.cc:67
void newBuffer(char *s, feBufferTypes t, procinfo *pi, int lineno)
Definition: fevoices.cc:157
const char sNoName_fe[]
Definition: fevoices.cc:56
@ BT_execute
Definition: fevoices.h:23
int iiTestConvert(int inputType, int outputType)
Definition: gentable.cc:301
int RingDependend(int t)
Definition: gentable.cc:28
const char * iiTwoOps(int t)
Definition: gentable.cc:261
@ PLUSPLUS
Definition: grammar.cc:274
@ END_RING
Definition: grammar.cc:310
@ IDEAL_CMD
Definition: grammar.cc:284
@ MATRIX_CMD
Definition: grammar.cc:286
@ BUCKET_CMD
Definition: grammar.cc:283
@ BIGINTMAT_CMD
Definition: grammar.cc:278
@ IMAP_CMD
Definition: grammar.cc:298
@ GE
Definition: grammar.cc:269
@ EQUAL_EQUAL
Definition: grammar.cc:268
@ MAP_CMD
Definition: grammar.cc:285
@ PROC_CMD
Definition: grammar.cc:280
@ LE
Definition: grammar.cc:270
@ BEGIN_RING
Definition: grammar.cc:282
@ INTMAT_CMD
Definition: grammar.cc:279
@ MODUL_CMD
Definition: grammar.cc:287
@ SMATRIX_CMD
Definition: grammar.cc:291
@ VECTOR_CMD
Definition: grammar.cc:292
@ RESOLUTION_CMD
Definition: grammar.cc:290
@ NOTEQUAL
Definition: grammar.cc:273
@ NUMBER_CMD
Definition: grammar.cc:288
@ POLY_CMD
Definition: grammar.cc:289
@ RING_CMD
Definition: grammar.cc:281
@ FETCH_CMD
Definition: grammar.cc:295
int yyparse(void)
Definition: grammar.cc:2111
int inerror
Definition: grammar.cc:175
BOOLEAN yyInRingConstruction
Definition: grammar.cc:172
int scMult0Int(ideal S, ideal Q, const ring tailRing)
Definition: hdegree.cc:919
ideal scKBase(int deg, ideal s, ideal Q, intvec *mv)
Definition: hdegree.cc:1353
intvec * scIndIntvec(ideal S, ideal Q)
Definition: hdegree.cc:212
int scMultInt(ideal S, ideal Q)
Definition: hdegree.cc:799
void scDegree(ideal S, intvec *modulweight, ideal Q)
Definition: hdegree.cc:822
int scDimInt(ideal S, ideal Q)
Definition: hdegree.cc:72
void hLookSeries(ideal S, intvec *modulweight, ideal Q, intvec *wdegree, ring tailRing)
Definition: hilb.cc:1419
intvec * hSecondSeries(intvec *hseries1)
Definition: hilb.cc:1346
intvec * hFirstSeries(ideal S, intvec *modulweight, ideal Q, intvec *wdegree, ring tailRing)
Definition: hilb.cc:1336
GbVariant syGetAlgorithm(char *n, const ring r, const ideal)
Definition: ideals.cc:3030
matrix idCoeffOfKBase(ideal arg, ideal kbase, poly how)
Definition: ideals.cc:2499
ideal idSyzygies(ideal h1, tHomog h, intvec **w, BOOLEAN setSyzComp, BOOLEAN setRegularity, int *deg, GbVariant alg)
Definition: ideals.cc:730
matrix idDiff(matrix i, int k)
Definition: ideals.cc:2169
ideal idLiftStd(ideal h1, matrix *ma, tHomog hi, ideal *syz, GbVariant alg)
Definition: ideals.cc:925
BOOLEAN idTestHomModule(ideal m, ideal Q, intvec *w)
Definition: ideals.cc:2100
ideal idQuot(ideal h1, ideal h2, BOOLEAN h1IsStb, BOOLEAN resultIsIdeal)
Definition: ideals.cc:1479
ideal idSeries(int n, ideal M, matrix U, intvec *w)
Definition: ideals.cc:2152
matrix idDiffOp(ideal I, ideal J, BOOLEAN multiply)
Definition: ideals.cc:2182
ideal idElimination(ideal h1, poly delVar, intvec *hilb, GbVariant alg)
Definition: ideals.cc:1574
ideal idMinBase(ideal h1)
Definition: ideals.cc:49
ideal idSect(ideal h1, ideal h2, GbVariant alg)
Definition: ideals.cc:201
ideal idMultSect(resolvente arg, int length, GbVariant alg)
Definition: ideals.cc:421
ideal idLift(ideal mod, ideal submod, ideal *rest, BOOLEAN goodShape, BOOLEAN isSB, BOOLEAN divide, matrix *unit, GbVariant alg)
Definition: ideals.cc:1113
ideal id_Farey(ideal x, number N, const ring r)
Definition: ideals.cc:2726
void idLiftW(ideal P, ideal Q, int n, matrix &T, ideal &R, short *w)
Definition: ideals.cc:1309
ideal idMinEmbedding(ideal arg, BOOLEAN inPlace, intvec **w)
Definition: ideals.cc:2565
ideal idModulo(ideal h2, ideal h1, tHomog hom, intvec **w)
Definition: ideals.cc:2254
GbVariant
Definition: ideals.h:119
#define idDelete(H)
delete an ideal
Definition: ideals.h:29
#define idSimpleAdd(A, B)
Definition: ideals.h:42
#define idIsConstant(I)
Definition: ideals.h:40
BOOLEAN idInsertPoly(ideal h1, poly h2)
insert h2 into h1 (if h2 is not the zero polynomial) return TRUE iff h2 was indeed inserted
ideal id_Copy(ideal h1, const ring r)
copy an ideal
static BOOLEAN idIsZeroDim(ideal i)
Definition: ideals.h:178
static BOOLEAN idHomModule(ideal m, ideal Q, intvec **w)
Definition: ideals.h:96
static intvec * idSort(ideal id, BOOLEAN nolex=TRUE)
Definition: ideals.h:186
#define idTest(id)
Definition: ideals.h:47
static BOOLEAN idHomIdeal(ideal id, ideal Q=NULL)
Definition: ideals.h:91
static ideal idMult(ideal h1, ideal h2)
hh := h1 * h2
Definition: ideals.h:84
ideal idCopy(ideal A)
Definition: ideals.h:60
ideal idAdd(ideal h1, ideal h2)
h1 + h2
Definition: ideals.h:68
#define idMaxIdeal(D)
initialise the maximal ideal (at 0)
Definition: ideals.h:33
ideal * resolvente
Definition: ideals.h:18
#define idPosConstant(I)
index of generator with leading term in ground ring (if any); otherwise -1
Definition: ideals.h:37
ideal interpolation(const std::vector< ideal > &L, intvec *v)
static BOOLEAN length(leftv result, leftv arg)
Definition: interval.cc:263
int ivTrace(intvec *o)
Definition: intvec.cc:321
intvec * ivSub(intvec *a, intvec *b)
Definition: intvec.cc:279
intvec * ivTranp(intvec *o)
Definition: intvec.cc:309
intvec * ivMult(intvec *a, intvec *b)
Definition: intvec.cc:331
intvec * ivAdd(intvec *a, intvec *b)
Definition: intvec.cc:249
#define ivTest(v)
Definition: intvec.h:156
#define IMATELEM(M, I, J)
Definition: intvec.h:83
intvec * ivCopy(const intvec *o)
Definition: intvec.h:133
static BOOLEAN jjUMINUS_MA(leftv res, leftv u)
Definition: iparith.cc:3577
static BOOLEAN jjOP_BIM_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:247
static BOOLEAN jjRANK1(leftv res, leftv v)
Definition: iparith.cc:4750
#define COMM_PLURAL
Definition: iparith.cc:104
static BOOLEAN jjINDEX_V_IV(leftv res, leftv u, leftv v)
Definition: iparith.cc:1522
static BOOLEAN jjIMPART(leftv res, leftv v)
Definition: iparith.cc:4269
static BOOLEAN jjIm2Iv(leftv res, leftv v)
Definition: iparith.cc:4262
#define SIMPL_EQU
Definition: iparith.cc:3160
static BOOLEAN jjQUOT(leftv res, leftv u, leftv v)
Definition: iparith.cc:2939
static BOOLEAN jjUMINUS_IV(leftv res, leftv u)
Definition: iparith.cc:3583
static BOOLEAN jjOPPOSITE(leftv res, leftv a)
Definition: iparith.cc:5046
static int _gentable_sort_cmds(const void *a, const void *b)
compares to entry of cmdsname-list
Definition: iparith.cc:9038
BOOLEAN jjWAITALL1(leftv res, leftv u)
Definition: iparith.cc:5187
static BOOLEAN jjRESTART(leftv, leftv u)
Definition: iparith.cc:8060
static BOOLEAN jjidHead(leftv res, leftv v)
Definition: iparith.cc:5342
static BOOLEAN jjHILBERT(leftv, leftv v)
Definition: iparith.cc:4151
static BOOLEAN jjTIMES_MA_P1(leftv res, leftv u, leftv v)
Definition: iparith.cc:1100
static BOOLEAN jjLEADMONOM(leftv res, leftv v)
Definition: iparith.cc:4405
static BOOLEAN jjOP_IV_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:283
static BOOLEAN jjstrlen(leftv res, leftv v)
Definition: iparith.cc:5307
static BOOLEAN jjBRACK_Bim(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5464
static BOOLEAN jjEXTGCD_P(leftv res, leftv u, leftv v)
Definition: iparith.cc:2056
static BOOLEAN jjDET_BI(leftv res, leftv v)
Definition: iparith.cc:3850
BOOLEAN jjWAIT1ST1(leftv res, leftv u)
Definition: iparith.cc:5172
BOOLEAN jjLOAD(const char *s, BOOLEAN autoexport)
load lib/module given in v
Definition: iparith.cc:5218
static BOOLEAN jjMATRIX_Mo(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6469
static BOOLEAN jjP2I(leftv res, leftv v)
Definition: iparith.cc:4664
static BOOLEAN jjIS_RINGVAR_P(leftv res, leftv v)
Definition: iparith.cc:4291
static BOOLEAN jjDOTDOT(leftv res, leftv u, leftv v)
Definition: iparith.cc:336
static BOOLEAN jjFWALK3(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5838
static BOOLEAN jjREPART(leftv res, leftv v)
Definition: iparith.cc:4766
static BOOLEAN jjTIMES_MA_BI2(leftv res, leftv u, leftv v)
Definition: iparith.cc:1096
static BOOLEAN jjMAP(leftv res, leftv u, leftv v)
Definition: iparith.cc:1654
static BOOLEAN jjGT_BI(leftv res, leftv u, leftv v)
Definition: iparith.cc:1190
static BOOLEAN jjN2BI(leftv res, leftv v)
Definition: iparith.cc:4547
short start
Definition: iparith.cc:126
static BOOLEAN jjCHAR(leftv res, leftv v)
Definition: iparith.cc:3693
static BOOLEAN jjOP_I_IM(leftv res, leftv u, leftv v)
Definition: iparith.cc:319
static BOOLEAN jjBRACK_Ma_IV_I(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5600
static BOOLEAN jjROWS_IV(leftv res, leftv v)
Definition: iparith.cc:4812
static BOOLEAN jjLIFTSTD(leftv res, leftv u, leftv v)
Definition: iparith.cc:2552
static BOOLEAN jjNULL(leftv, leftv)
Definition: iparith.cc:3527
static BOOLEAN jjNEWSTRUCT2(leftv, leftv u, leftv v)
Definition: iparith.cc:2736
#define NO_ZERODIVISOR
Definition: iparith.cc:107
static BOOLEAN jjMONITOR2(leftv res, leftv u, leftv v)
Definition: iparith.cc:2671
static BOOLEAN jjDIM(leftv res, leftv v)
Definition: iparith.cc:3916
static si_char_2 Tok2Cmdname_buf
Definition: iparith.cc:8983
static BOOLEAN jjCOUNT_BIM(leftv res, leftv v)
Definition: iparith.cc:3726
static BOOLEAN jjBRACKET(leftv res, leftv a, leftv b)
Definition: iparith.cc:2847
static BOOLEAN jjCOLS_IV(leftv res, leftv v)
Definition: iparith.cc:3708
static BOOLEAN jjNAMES_I(leftv res, leftv v)
Definition: iparith.cc:4577
char * name
Definition: iparith.cc:133
static BOOLEAN jjMULT(leftv res, leftv v)
Definition: iparith.cc:4527
static BOOLEAN jjPARDEG(leftv res, leftv v)
Definition: iparith.cc:4620
static BOOLEAN jjDENOMINATOR(leftv res, leftv v)
Return the denominator of the input number NOTE: the input number is normalized as a side effect.
Definition: iparith.cc:3819
static BOOLEAN jjRANDOM(leftv res, leftv u, leftv v)
Definition: iparith.cc:2947
static BOOLEAN jjIDEAL_Ma(leftv res, leftv v)
Definition: iparith.cc:4217
static BOOLEAN jjDIVISION(leftv res, leftv u, leftv v)
Definition: iparith.cc:1940
static BOOLEAN jjOP_I_IV(leftv res, leftv u, leftv v)
Definition: iparith.cc:300
static BOOLEAN jjmpTransp(leftv res, leftv v)
Definition: iparith.cc:5370
static BOOLEAN jjOPTION_PL(leftv res, leftv v)
Definition: iparith.cc:7536
static BOOLEAN jjEQUAL_BI(leftv res, leftv u, leftv v)
Definition: iparith.cc:1321
static BOOLEAN jjDET_S(leftv res, leftv v)
Definition: iparith.cc:3900
static BOOLEAN jjL2R(leftv res, leftv v)
Definition: iparith.cc:4366
static BOOLEAN jjREDUCE5(leftv res, leftv u)
Definition: iparith.cc:7618
static BOOLEAN jjrCharStr(leftv res, leftv v)
Definition: iparith.cc:5332
static BOOLEAN jjSUBST_Id_I(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6428
static BOOLEAN jjMINUS_B_P(leftv res, leftv u, leftv v)
Definition: iparith.cc:909
static BOOLEAN jjHILBERT_IV(leftv res, leftv v)
Definition: iparith.cc:4166
int iiArithFindCmd(const char *szName)
Definition: iparith.cc:9110
int cmdtok
Definition: grammar.cc:174
BOOLEAN expected_parms
Definition: grammar.cc:173
static BOOLEAN jjIDEAL_R(leftv res, leftv v)
Definition: iparith.cc:4245
static BOOLEAN jjINDEPSET(leftv res, leftv v)
Definition: iparith.cc:4274
static BOOLEAN jjTYPEOF(leftv res, leftv v)
Definition: iparith.cc:5082
static BOOLEAN jjLU_SOLVE(leftv res, leftv v)
Definition: iparith.cc:7168
static BOOLEAN jjFACSTD(leftv res, leftv v)
Definition: iparith.cc:4027
static BOOLEAN jjMEMORY(leftv res, leftv v)
Definition: iparith.cc:4479
static BOOLEAN jjidTransp(leftv res, leftv v)
Definition: iparith.cc:5400
static BOOLEAN jjLIFT(leftv res, leftv u, leftv v)
Definition: iparith.cc:2542
static BOOLEAN jjUMINUS_BIM(leftv res, leftv u)
Definition: iparith.cc:3590
static BOOLEAN jjSUBST_Bu(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6345
static BOOLEAN jjTIMES_MA_N2(leftv res, leftv u, leftv v)
Definition: iparith.cc:1128
static BOOLEAN jjDIM_R(leftv res, leftv v)
Definition: iparith.cc:5395
BOOLEAN jjSORTLIST(leftv, leftv arg)
Definition: iparith.cc:9549
static BOOLEAN jjDUMP(leftv, leftv v)
Definition: iparith.cc:3992
static BOOLEAN jjpMaxComp(leftv res, leftv v)
Definition: iparith.cc:5360
static BOOLEAN jjREDUCE3_ID(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6577
static BOOLEAN jjELIMIN_HILB(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5800
static int jjCOMPARE_ALL(const void *aa, const void *bb)
Definition: iparith.cc:9508
static BOOLEAN jjNAMEOF(leftv res, leftv v)
Definition: iparith.cc:4559
static BOOLEAN jjPlural_mat_poly(leftv res, leftv a, leftv b)
Definition: iparith.cc:2807
static BOOLEAN jjTIMES_SM(leftv res, leftv u, leftv v)
Definition: iparith.cc:1157
static BOOLEAN jjMOD_BI(leftv res, leftv u, leftv v)
Definition: iparith.cc:2626
BOOLEAN jjUNIQLIST(leftv, leftv arg)
Definition: iparith.cc:9558
static BOOLEAN jjTIMES_MA_I2(leftv res, leftv u, leftv v)
Definition: iparith.cc:1138
static BOOLEAN jjSTATUS2L(leftv res, leftv u, leftv v)
Definition: iparith.cc:3252
BOOLEAN(* proc3)(leftv, leftv, leftv, leftv)
Definition: iparith.cc:160
static BOOLEAN jjGT_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:1197
static BOOLEAN jjPRIME(leftv res, leftv v)
Definition: iparith.cc:4682
static BOOLEAN jjPFAC2(leftv res, leftv u, leftv v)
Definition: iparith.cc:3123
static BOOLEAN jjidVec2Ideal(leftv res, leftv v)
Definition: iparith.cc:5327
static BOOLEAN jjJACOB_P(leftv res, leftv v)
Definition: iparith.cc:4307
static BOOLEAN jjSQR_FREE(leftv res, leftv u)
Definition: iparith.cc:4975
static BOOLEAN jjSTD_HILB_W(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6637
static BOOLEAN jjEQUAL_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:1327
static BOOLEAN jjTIMES_MA_P2(leftv res, leftv u, leftv v)
Definition: iparith.cc:1110
static BOOLEAN jjSBA_1(leftv res, leftv v, leftv u)
Definition: iparith.cc:4890
#define SIMPL_NORM
Definition: iparith.cc:3162
static BOOLEAN jjCOEFFS3_P(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5765
static BOOLEAN jjCALL1MANY(leftv res, leftv u)
Definition: iparith.cc:3689
static BOOLEAN jjPLUS_MA(leftv res, leftv u, leftv v)
Definition: iparith.cc:824
short tokval
Definition: gentable.cc:63
static BOOLEAN jjWRONG(leftv, leftv)
Definition: iparith.cc:3513
static BOOLEAN jjMINUS_V(leftv res, leftv u, leftv v)
Definition: iparith.cc:904
static BOOLEAN jjINTERRED(leftv res, leftv v)
Definition: iparith.cc:4280
static BOOLEAN jjJACOB_M(leftv res, leftv a)
Definition: iparith.cc:4338
static BOOLEAN jjJET_ID_IV(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5970
static BOOLEAN jjTIMES_ID(leftv res, leftv u, leftv v)
Definition: iparith.cc:1054
static BOOLEAN jjBAREISS(leftv res, leftv v)
Definition: iparith.cc:3623
static BOOLEAN jjREAD(leftv res, leftv v)
Definition: iparith.cc:4757
static BOOLEAN jjLT_N(leftv res, leftv u, leftv v)
Definition: iparith.cc:1229
static BOOLEAN jjMINUS_MA(leftv res, leftv u, leftv v)
Definition: iparith.cc:952
static BOOLEAN jjFactModD_M(leftv res, leftv v)
Definition: iparith.cc:7741
static BOOLEAN jjMATRIX_Id(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6446
static BOOLEAN jjEXTGCD_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:2027
static BOOLEAN jjIS_RINGVAR_S(leftv res, leftv v)
Definition: iparith.cc:4296
static BOOLEAN jjDelete_ID(leftv res, leftv u, leftv v)
Definition: iparith.cc:1868
static BOOLEAN jjLE_N(leftv res, leftv u, leftv v)
Definition: iparith.cc:1216
static BOOLEAN jjSUBST_P(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6358
static BOOLEAN jjROWS_BIM(leftv res, leftv v)
Definition: iparith.cc:4807
static BOOLEAN jjCOMPARE_S(leftv res, leftv u, leftv v)
Definition: iparith.cc:480
#define SIMPL_LMEQ
Definition: iparith.cc:3158
int iiInitArithmetic()
initialisation of arithmetic structured data
Definition: iparith.cc:9075
static BOOLEAN jjOR_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:1383
static BOOLEAN jjTIMES_MA_I1(leftv res, leftv u, leftv v)
Definition: iparith.cc:1132
static BOOLEAN jjBAREISS3(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5720
static BOOLEAN jjRESERVED0(leftv, leftv)
Definition: iparith.cc:7667
static BOOLEAN jjTIMES_MA_N1(leftv res, leftv u, leftv v)
Definition: iparith.cc:1120
static BOOLEAN jjLIFT_4(leftv res, leftv U)
Definition: iparith.cc:7417
static BOOLEAN jjSLIM_GB(leftv res, leftv u)
Definition: iparith.cc:4822
static BOOLEAN jjMSTD(leftv res, leftv v)
Definition: iparith.cc:4512
short cmd
Definition: iparith.cc:125
static BOOLEAN jjBREAK1(leftv, leftv v)
Definition: iparith.cc:6686
const char * Tok2Cmdname(int tok)
Definition: iparith.cc:8984
static BOOLEAN jjJET_ID_M(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5976
static BOOLEAN jjMINUS_BIM(leftv res, leftv u, leftv v)
Definition: iparith.cc:942
static BOOLEAN jjnInt(leftv res, leftv u)
Definition: iparith.cc:5405
static BOOLEAN jjSQR_FREE2(leftv res, leftv u, leftv dummy)
Definition: iparith.cc:3200
static BOOLEAN jjCOEFFS3_Id(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5745
static BOOLEAN jjREGULARITY(leftv res, leftv v)
Definition: iparith.cc:4761
static BOOLEAN jjMINUS_N(leftv res, leftv u, leftv v)
Definition: iparith.cc:899
static BOOLEAN jjBREAK0(leftv, leftv)
Definition: iparith.cc:6679
static BOOLEAN jjTRACE_IV(leftv res, leftv v)
Definition: iparith.cc:5030
BOOLEAN iiExprArith2(leftv res, leftv a, int op, leftv b, BOOLEAN proccall)
Definition: iparith.cc:8259
static SArithBase sArithBase
Base entry for arithmetic.
Definition: iparith.cc:197
static BOOLEAN jjMONOM(leftv res, leftv v)
Definition: iparith.cc:2712
static BOOLEAN jjSort_Id(leftv res, leftv v)
Definition: iparith.cc:4970
static BOOLEAN jjCOEF_M(leftv, leftv v)
Definition: iparith.cc:6727
static BOOLEAN jjidMinBase(leftv res, leftv v)
Definition: iparith.cc:5348
static BOOLEAN jjDEG_IV(leftv res, leftv u, leftv v)
Definition: iparith.cc:1847
static BOOLEAN jjRING_2(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5708
static BOOLEAN jjMINUS_IV(leftv res, leftv u, leftv v)
Definition: iparith.cc:932
static BOOLEAN jjPREIMAGE_R(leftv res, leftv v)
Definition: iparith.cc:4676
static BOOLEAN jjHOMOG_P(leftv res, leftv u, leftv v)
Definition: iparith.cc:2408
static BOOLEAN jjBRACK_Im(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5437
static BOOLEAN jjMATRIX_Ma(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6482
static BOOLEAN jjidMaxIdeal(leftv res, leftv v)
Definition: iparith.cc:4211
char * iiArithGetCmd(int nPos)
Definition: iparith.cc:9170
static BOOLEAN jjMINOR_M(leftv res, leftv v)
Definition: iparith.cc:5987
static BOOLEAN jjCOUNT_BI(leftv res, leftv v)
Definition: iparith.cc:3721
static BOOLEAN jjPROC3(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5701
static BOOLEAN jjCOLS_BIM(leftv res, leftv v)
Definition: iparith.cc:3703
static BOOLEAN jjREDUCE3_CP(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6546
struct sValCmd3 * psValCmd3
Definition: iparith.cc:185
static BOOLEAN jjBRACK_Ma_I_IV(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5550
static BOOLEAN jjLE_BI(leftv res, leftv u, leftv v)
Definition: iparith.cc:1207
static BOOLEAN jjPLUS_B_P(leftv res, leftv u, leftv v)
Definition: iparith.cc:795
static BOOLEAN jjPlural_mat_mat(leftv res, leftv a, leftv b)
Definition: iparith.cc:2827
static BOOLEAN jjIDEAL_Map(leftv res, leftv v)
Definition: iparith.cc:4235
static BOOLEAN jjPARSTR2(leftv res, leftv u, leftv v)
Definition: iparith.cc:2750
BOOLEAN(* proc2)(leftv, leftv, leftv)
Definition: iparith.cc:149
static BOOLEAN jjKoszul(leftv res, leftv u, leftv v)
Definition: iparith.cc:2530
static BOOLEAN jjTIMES_N(leftv res, leftv u, leftv v)
Definition: iparith.cc:997
static BOOLEAN jjINTERSECT_PL(leftv res, leftv v)
Definition: iparith.cc:7013
static BOOLEAN jjTIMES_MA(leftv res, leftv u, leftv v)
Definition: iparith.cc:1142
static BOOLEAN jjTIMES_IV(leftv res, leftv u, leftv v)
Definition: iparith.cc:1062
#define NO_CONVERSION
Definition: iparith.cc:118
static BOOLEAN jjPLUS_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:755
static BOOLEAN jjINTERSEC3S(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5945
static BOOLEAN jjRES3(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6585
static BOOLEAN jjJET_P_IV(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5953
static BOOLEAN jjREDUCE_ID(leftv res, leftv u, leftv v)
Definition: iparith.cc:2988
static BOOLEAN jjCOEF(leftv res, leftv u, leftv v)
Definition: iparith.cc:1792
BOOLEAN iiExprArith3Tab(leftv res, leftv a, int op, const struct sValCmd3 *dA3, int at, const struct sConvertTypes *dConvertTypes)
apply an operation 'op' to arguments a, a->next and a->next->next return TRUE on failure
Definition: iparith.cc:8713
static BOOLEAN jjOP_REST(leftv res, leftv u, leftv v)
Definition: iparith.cc:507
static BOOLEAN jjEXECUTE(leftv, leftv v)
Definition: iparith.cc:4018
static BOOLEAN jjDEG_M_IV(leftv res, leftv u, leftv v)
Definition: iparith.cc:1836
static BOOLEAN jjSTATUS3(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6628
static BOOLEAN jjLEADEXP(leftv res, leftv v)
Definition: iparith.cc:4387
static BOOLEAN jjDEG_M(leftv res, leftv u)
Definition: iparith.cc:3776
static BOOLEAN jjPLUS_IV(leftv res, leftv u, leftv v)
Definition: iparith.cc:804
static BOOLEAN jjDIFF_COEF(leftv res, leftv u, leftv v)
Definition: iparith.cc:4319
int iiArithRemoveCmd(char *szName)
static BOOLEAN jjGE_N(leftv res, leftv u, leftv v)
Definition: iparith.cc:1184
static BOOLEAN jjEQUAL_SM(leftv res, leftv u, leftv v)
Definition: iparith.cc:1339
static BOOLEAN jjINTERPOLATION(leftv res, leftv l, leftv v)
Definition: iparith.cc:2480
static BOOLEAN jjSIMPL_ID(leftv res, leftv u, leftv v)
Definition: iparith.cc:3163
static BOOLEAN jjRING3(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6623
static BOOLEAN jjREDUCE_P(leftv res, leftv u, leftv v)
Definition: iparith.cc:2980
static BOOLEAN jjDIV_Ma(leftv res, leftv u, leftv v)
Definition: iparith.cc:1291
static BOOLEAN jjFRES3(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:2288
static BOOLEAN jjMODULO(leftv res, leftv u, leftv v)
Definition: iparith.cc:2577
static BOOLEAN jjCOMPARE_IV(leftv res, leftv u, leftv v)
Definition: iparith.cc:342
static BOOLEAN jjREAD2(leftv res, leftv u, leftv v)
Definition: iparith.cc:2964
static BOOLEAN jjREDUCE3_P(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6570
static BOOLEAN jjPAR1(leftv res, leftv v)
Definition: iparith.cc:4604
static BOOLEAN jjnlInt(leftv res, leftv u)
Definition: iparith.cc:5412
cmdnames * sCmds
array of existing commands
Definition: iparith.cc:182
static BOOLEAN jjFAREY_ID(leftv res, leftv u, leftv v)
Definition: iparith.cc:2153
static BOOLEAN jjPLUS_ID(leftv res, leftv u, leftv v)
Definition: iparith.cc:873
static BOOLEAN jjGCD_N(leftv res, leftv u, leftv v)
Definition: iparith.cc:2357
static BOOLEAN jjELIMIN(leftv res, leftv u, leftv v)
Definition: iparith.cc:1981
static BOOLEAN jjPLUSPLUS(leftv, leftv u)
Definition: iparith.cc:3541
static Subexpr jjMakeSub(leftv e)
Definition: iparith.cc:8053
static BOOLEAN jjCHINREM_BI(leftv res, leftv u, leftv v)
Definition: iparith.cc:1681
static BOOLEAN jjROWS(leftv res, leftv v)
Definition: iparith.cc:4801
static BOOLEAN jjJET_ID(leftv res, leftv u, leftv v)
Definition: iparith.cc:2508
static BOOLEAN iiExprArith2TabIntern(leftv res, leftv a, int op, leftv b, BOOLEAN proccall, const struct sValCmd2 *dA2, int at, int bt, const struct sConvertTypes *dConvertTypes)
Definition: iparith.cc:8086
int IsCmd(const char *n, int &tok)
Definition: iparith.cc:8860
static BOOLEAN jjSBA(leftv res, leftv v)
Definition: iparith.cc:4864
static BOOLEAN jjOP_IM_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:304
static BOOLEAN jjJanetBasis(leftv res, leftv v)
Definition: iparith.cc:2498
static BOOLEAN jjKBASE(leftv res, leftv v)
Definition: iparith.cc:4360
static BOOLEAN jjTENSOR(leftv res, leftv u, leftv v)
Definition: iparith.cc:3395
static BOOLEAN jjmpTrace(leftv res, leftv v)
Definition: iparith.cc:5365
static BOOLEAN jjRING_PL(leftv res, leftv a)
Definition: iparith.cc:8031
static BOOLEAN jjREDUCE4(leftv res, leftv u)
Definition: iparith.cc:7546
static BOOLEAN jjFWALK(leftv res, leftv u, leftv v)
Definition: iparith.cc:2330
static BOOLEAN jjTEST(leftv, leftv v)
Definition: iparith.cc:7722
static BOOLEAN jjDIFF_ID_ID(leftv res, leftv u, leftv v)
Definition: iparith.cc:1897
static BOOLEAN jjSYZ_2(leftv res, leftv u, leftv v)
Definition: iparith.cc:3384
static BOOLEAN jjPRUNE(leftv res, leftv v)
Definition: iparith.cc:4688
static BOOLEAN jjDIVISION4(leftv res, leftv v)
Definition: iparith.cc:6744
unsigned nLastIdentifier
valid indentifieres are slot 1..nLastIdentifier
Definition: iparith.cc:189
static BOOLEAN jjDEFINED(leftv res, leftv v)
Definition: iparith.cc:3806
static BOOLEAN jjRING_1(leftv res, leftv u, leftv v)
Definition: iparith.cc:1672
static BOOLEAN jjVDIM(leftv res, leftv v)
Definition: iparith.cc:5166
static BOOLEAN jjOP_I_BIM(leftv res, leftv u, leftv v)
Definition: iparith.cc:262
static BOOLEAN jjCOUNT_N(leftv res, leftv v)
Definition: iparith.cc:3732
static BOOLEAN jjHILBERT2(leftv res, leftv u, leftv v)
Definition: iparith.cc:2380
static BOOLEAN jjFIND2(leftv res, leftv u, leftv v)
Definition: iparith.cc:2270
static BOOLEAN jjCOEF_Id(leftv res, leftv u, leftv v)
Definition: iparith.cc:1799
static BOOLEAN jjP2N(leftv res, leftv v)
Definition: iparith.cc:4712
static BOOLEAN jjE(leftv res, leftv v)
Definition: iparith.cc:4006
static BOOLEAN jjPOWER_ID(leftv res, leftv u, leftv v)
Definition: iparith.cc:625
static BOOLEAN jjTIMES_MA_BI1(leftv res, leftv u, leftv v)
Definition: iparith.cc:1086
BOOLEAN iiExprArith1(leftv res, leftv a, int op)
Definition: iparith.cc:8448
static BOOLEAN jjSTD_HILB_WP(leftv res, leftv INPUT)
Definition: iparith.cc:7948
static BOOLEAN jjLISTRING(leftv res, leftv v)
Definition: iparith.cc:4424
static BOOLEAN jjCOEFFS2_KB(leftv res, leftv u, leftv v)
Definition: iparith.cc:1817
#define SIMPL_NULL
Definition: iparith.cc:3161
#define ALLOW_LP
Definition: iparith.cc:109
#define RING_MASK
Definition: iparith.cc:96
static BOOLEAN jjELIMIN_ALG(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5792
static BOOLEAN jjVAR1(leftv res, leftv v)
Definition: iparith.cc:5132
static BOOLEAN jjLEADCOEF(leftv res, leftv v)
Definition: iparith.cc:4374
static BOOLEAN jjVARSTR2(leftv res, leftv u, leftv v)
Definition: iparith.cc:3421
static BOOLEAN jjPLUS_N(leftv res, leftv u, leftv v)
Definition: iparith.cc:772
static BOOLEAN jjSUBST_Id_X(leftv res, leftv u, leftv v, leftv w, int input_type)
Definition: iparith.cc:6436
static BOOLEAN jjUMINUS_BI(leftv res, leftv u)
Definition: iparith.cc:3553
int iiArithAddCmd(const char *szName, short nAlias, short nTokval, short nToktype, short nPos=-1)
Definition: iparith.cc:9205
static BOOLEAN jjpLength(leftv res, leftv v)
Definition: iparith.cc:5312
static BOOLEAN jjJET_P_P(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5960
static BOOLEAN jjLT_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:1224
static BOOLEAN jjIS_RINGVAR0(leftv res, leftv)
Definition: iparith.cc:4302
static BOOLEAN jjEXTGCD_BI(leftv res, leftv u, leftv v)
Definition: iparith.cc:2013
static BOOLEAN jjBI2P(leftv res, leftv u)
Definition: iparith.cc:3674
static BOOLEAN jjTWOSTD(leftv res, leftv a)
Definition: iparith.cc:5072
static BOOLEAN jjGCD_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:2336
static BOOLEAN jjCONTRACT(leftv res, leftv u, leftv v)
Definition: iparith.cc:1831
short toktype
Definition: gentable.cc:64
static BOOLEAN jjFAC_P(leftv res, leftv u)
Definition: iparith.cc:4067
static BOOLEAN jjREDUCE3_CID(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6558
static BOOLEAN jjFAREY_LI(leftv res, leftv u, leftv v)
Definition: iparith.cc:9489
static BOOLEAN jjTRANSP_BIM(leftv res, leftv v)
Definition: iparith.cc:5035
static BOOLEAN jjCOUNT_RES(leftv res, leftv v)
Definition: iparith.cc:5390
#define ii_div_by_0
Definition: iparith.cc:216
static BOOLEAN jjDelete_IV(leftv res, leftv u, leftv v)
Definition: iparith.cc:1861
static BOOLEAN jjGE_BI(leftv res, leftv u, leftv v)
Definition: iparith.cc:1172
static BOOLEAN jjrOrdStr(leftv res, leftv v)
Definition: iparith.cc:5375
static BOOLEAN jjKERNEL(leftv res, leftv u, leftv v)
Definition: iparith.cc:2526
static BOOLEAN jjINTERSECT3(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5932
static BOOLEAN jjBRACK_Ma(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5492
sValCmdTab jjValCmdTab[]
Definition: iparith.cc:129
static BOOLEAN jjMOD_N(leftv res, leftv u, leftv v)
Definition: iparith.cc:2637
static BOOLEAN jjLOAD_E(leftv, leftv v, leftv u)
Definition: iparith.cc:2566
poly pHeadProc(poly p)
Definition: iparith.cc:228
static BOOLEAN jjNEWSTRUCT3(leftv, leftv u, leftv v, leftv w)
Definition: iparith.cc:6186
static BOOLEAN jjHOMOG_P_W(leftv res, leftv u, leftv v, leftv)
Definition: iparith.cc:5900
static BOOLEAN jjpHead(leftv res, leftv v)
Definition: iparith.cc:5337
static BOOLEAN jjSUBST_Id(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6384
static BOOLEAN jjEQUAL_R(leftv res, leftv u, leftv v)
Definition: iparith.cc:1345
static BOOLEAN jjCOUNT_L(leftv res, leftv v)
Definition: iparith.cc:3737
struct sValCmdM * psValCmdM
Definition: iparith.cc:186
static BOOLEAN jjDET_I(leftv res, leftv v)
Definition: iparith.cc:3886
static BOOLEAN jjCOUNT_RG(leftv res, leftv v)
Definition: iparith.cc:3754
static BOOLEAN jjSMATRIX_Mo(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6508
static BOOLEAN jjINTERSECT(leftv res, leftv u, leftv v)
Definition: iparith.cc:2474
static BOOLEAN jjrVarStr(leftv res, leftv v)
Definition: iparith.cc:5380
static BOOLEAN jjOP_BI_BIM(leftv res, leftv u, leftv v)
Definition: iparith.cc:279
static BOOLEAN jjDIFF_P(leftv res, leftv u, leftv v)
Definition: iparith.cc:1875
static BOOLEAN check_valid(const int p, const int op)
Definition: iparith.cc:9264
static BOOLEAN jjSTRING_PL(leftv res, leftv v)
Definition: iparith.cc:7688
static BOOLEAN jjMINUS_B(leftv res, leftv u, leftv v)
Definition: iparith.cc:919
static BOOLEAN jjLIFTSTD_4(leftv res, leftv U)
Definition: iparith.cc:7448
static BOOLEAN jjRSUM(leftv res, leftv u, leftv v)
Definition: iparith.cc:3149
static BOOLEAN jjINDEX_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:1388
static BOOLEAN jjPOWER_BI(leftv res, leftv u, leftv v)
Definition: iparith.cc:569
static BOOLEAN jjMONITOR1(leftv res, leftv v)
Definition: iparith.cc:2667
static BOOLEAN jjKLAMMER_IV(leftv res, leftv u, leftv v)
Definition: iparith.cc:1571
static BOOLEAN jjFETCH(leftv res, leftv u, leftv v)
Definition: iparith.cc:2168
static BOOLEAN jjCALL3ARG(leftv res, leftv u)
Definition: iparith.cc:6715
static BOOLEAN jjSTD_1(leftv res, leftv u, leftv v)
Definition: iparith.cc:3300
static BOOLEAN jjUMINUS_N(leftv res, leftv u)
Definition: iparith.cc:3565
static BOOLEAN jjNUMERATOR(leftv res, leftv v)
Return the numerator of the input number NOTE: the input number is normalized as a side effect.
Definition: iparith.cc:3828
static BOOLEAN jjORD(leftv res, leftv v)
Definition: iparith.cc:4598
static BOOLEAN jjTIMES_P(leftv res, leftv u, leftv v)
Definition: iparith.cc:1007
static BOOLEAN jjUMINUS_I(leftv res, leftv u)
Definition: iparith.cc:3560
static BOOLEAN jjPREIMAGE(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6196
static BOOLEAN jjBRACK_Ma_IV_IV(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5650
static BOOLEAN jjPLUS_SM(leftv res, leftv u, leftv v)
Definition: iparith.cc:836
BOOLEAN jjLOAD_TRY(const char *s)
Definition: iparith.cc:5294
static BOOLEAN jjLIFT3(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6521
static BOOLEAN jjENVELOPE(leftv res, leftv a)
Definition: iparith.cc:5061
static BOOLEAN jjSetRing(leftv, leftv u)
Definition: iparith.cc:3598
static BOOLEAN jjMINUS_BI(leftv res, leftv u, leftv v)
Definition: iparith.cc:894
static BOOLEAN jjTIMES_BI(leftv res, leftv u, leftv v)
Definition: iparith.cc:990
static BOOLEAN jjFACSTD2(leftv res, leftv v, leftv w)
Definition: iparith.cc:2120
static BOOLEAN jjINTVEC_PL(leftv res, leftv v)
Definition: iparith.cc:7249
static BOOLEAN jjEXPORTTO(leftv, leftv u, leftv v)
Definition: iparith.cc:2001
static BOOLEAN jjPlural_num_poly(leftv res, leftv a, leftv b)
Definition: iparith.cc:2767
static BOOLEAN jjDIV_P(leftv res, leftv u, leftv v)
Definition: iparith.cc:1282
static BOOLEAN jjKBASE2(leftv res, leftv u, leftv v)
Definition: iparith.cc:2513
#define WARN_RING
Definition: iparith.cc:116
static BOOLEAN jjPOWER_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:523
#define SIMPL_MULT
Definition: iparith.cc:3159
static BOOLEAN jjRES(leftv res, leftv u, leftv v)
Definition: iparith.cc:2997
static int iin_Int(number &n, coeffs cf)
Definition: iparith.cc:221
static BOOLEAN jjPLUS_P_MA(leftv res, leftv u, leftv v)
Definition: iparith.cc:859
static BOOLEAN jjMINRES_R(leftv res, leftv v)
Definition: iparith.cc:4533
static BOOLEAN jjCOLS(leftv res, leftv v)
Definition: iparith.cc:3698
static BOOLEAN jjPLUS_BIM(leftv res, leftv u, leftv v)
Definition: iparith.cc:814
#define NC_MASK
Definition: iparith.cc:90
static BOOLEAN jjP2BI(leftv res, leftv v)
Definition: iparith.cc:4644
static void WerrorS_dummy(const char *)
Definition: iparith.cc:5290
static BOOLEAN jjGE_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:1179
static BOOLEAN jjTRANSP_IV(leftv res, leftv v)
Definition: iparith.cc:5040
static BOOLEAN jjGT_N(leftv res, leftv u, leftv v)
Definition: iparith.cc:1202
static BOOLEAN jjUNIVARIATE(leftv res, leftv v)
Definition: iparith.cc:5127
static BOOLEAN jjHOMOG_ID_W(leftv res, leftv u, leftv v, leftv)
Definition: iparith.cc:5882
static BOOLEAN jjWEDGE(leftv res, leftv u, leftv v)
Definition: iparith.cc:3506
static BOOLEAN jjCOMPARE_P(leftv res, leftv u, leftv v)
Definition: iparith.cc:453
static BOOLEAN jjFIND3(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5807
static BOOLEAN jjLU_INVERSE(leftv res, leftv v)
Definition: iparith.cc:7087
static BOOLEAN jjBAREISS_BIM(leftv res, leftv v)
Definition: iparith.cc:3646
#define jjWRONG2
Definition: iparith.cc:3511
static BOOLEAN jjPLUS_MA_P(leftv res, leftv u, leftv v)
Definition: iparith.cc:848
static BOOLEAN jjSIMPL_P(leftv res, leftv u, leftv v)
Definition: iparith.cc:3258
static BOOLEAN jjPFAC1(leftv res, leftv v)
Definition: iparith.cc:4440
static BOOLEAN jjQRDS(leftv res, leftv INPUT)
Definition: iparith.cc:7931
static BOOLEAN jjELIMIN_IV(leftv res, leftv u, leftv v)
Definition: iparith.cc:1987
static int WerrorS_dummy_cnt
Definition: iparith.cc:5289
static BOOLEAN jjCONTENT(leftv res, leftv v)
Definition: iparith.cc:3713
int singclap_factorize_retry
Definition: iparith.cc:3199
static BOOLEAN jjDIFF_ID(leftv res, leftv u, leftv v)
Definition: iparith.cc:1886
static BOOLEAN jjSTD(leftv res, leftv v)
Definition: iparith.cc:4942
static BOOLEAN jjTIMES_BIM(leftv res, leftv u, leftv v)
Definition: iparith.cc:1074
static BOOLEAN jjLIFTSTD3(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6533
static BOOLEAN jjTIMES_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:978
static BOOLEAN jjDIV_N(leftv res, leftv u, leftv v)
Definition: iparith.cc:1269
static BOOLEAN jjINTMAT3(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5918
static BOOLEAN jjCOUNT_IV(leftv res, leftv v)
Definition: iparith.cc:3749
static BOOLEAN jjFRES(leftv res, leftv u, leftv v)
Definition: iparith.cc:2320
unsigned nCmdAllocated
number of commands-slots allocated
Definition: iparith.cc:188
static BOOLEAN jjDUMMY(leftv res, leftv u)
Definition: iparith.cc:3522
static BOOLEAN jjKLAMMER(leftv res, leftv u, leftv v)
Definition: iparith.cc:1558
BOOLEAN iiExprArith2Tab(leftv res, leftv a, int op, const struct sValCmd2 *dA2, int at, const struct sConvertTypes *dConvertTypes)
apply an operation 'op' to arguments a and a->next return TRUE on failure
Definition: iparith.cc:8246
static BOOLEAN jjBI2N(leftv res, leftv u)
Definition: iparith.cc:3653
short alias
Definition: gentable.cc:62
BOOLEAN iiExprArithM(leftv res, leftv a, int op)
Definition: iparith.cc:8751
static BOOLEAN jjCOMPARE_MA(leftv res, leftv u, leftv v)
Definition: iparith.cc:425
BOOLEAN iiExprArith3(leftv res, int op, leftv a, leftv b, leftv c)
Definition: iparith.cc:8661
static BOOLEAN jjGETDUMP(leftv, leftv v)
Definition: iparith.cc:4083
static BOOLEAN jjidFreeModule(leftv res, leftv v)
Definition: iparith.cc:5322
static BOOLEAN jjFAREY_BI(leftv res, leftv u, leftv v)
Definition: iparith.cc:2142
static BOOLEAN jjCOMPARE_IV_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:398
static BOOLEAN jjRANDOM_Im(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6270
static BOOLEAN jjRESERVEDNAME(leftv res, leftv v)
Definition: iparith.cc:4728
struct sValCmd1 * psValCmd1
Definition: iparith.cc:183
static BOOLEAN jjDIVMOD_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:1233
static BOOLEAN jjLE_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:1211
static BOOLEAN jjTENSOR_Ma(leftv res, leftv u, leftv v)
Definition: iparith.cc:3402
static BOOLEAN jjCOEFFS3_KB(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5759
static BOOLEAN iiExprArith3TabIntern(leftv res, int op, leftv a, leftv b, leftv c, const struct sValCmd3 *dA3, int at, int bt, int ct, const struct sConvertTypes *dConvertTypes)
Definition: iparith.cc:8507
BOOLEAN jjPROC(leftv res, leftv u, leftv v)
Definition: iparith.cc:1618
static BOOLEAN jjPLUS_BI(leftv res, leftv u, leftv v)
Definition: iparith.cc:767
static BOOLEAN jjHILBERT3(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5847
static BOOLEAN jjSTD_HILB(leftv res, leftv u, leftv v)
Definition: iparith.cc:3274
static BOOLEAN jjAND_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:1378
static BOOLEAN jjINDEX_P_IV(leftv res, leftv u, leftv v)
Definition: iparith.cc:1486
static BOOLEAN jjRPAR(leftv res, leftv v)
Definition: iparith.cc:4817
static BOOLEAN jjJanetBasis2(leftv res, leftv u, leftv v)
Definition: iparith.cc:2492
static BOOLEAN jjLOAD1(leftv, leftv v)
Definition: iparith.cc:4420
static BOOLEAN jjCOLON(leftv res, leftv u, leftv v)
Definition: iparith.cc:323
static BOOLEAN jjCOLCOL(leftv res, leftv u, leftv v)
Definition: iparith.cc:693
static BOOLEAN jjFAC_P2(leftv res, leftv u, leftv dummy)
Definition: iparith.cc:2073
static BOOLEAN jjHOMOG_ID(leftv res, leftv u, leftv v)
Definition: iparith.cc:2425
static BOOLEAN jjrParStr(leftv res, leftv v)
Definition: iparith.cc:5385
struct sValCmd2 * psValCmd2
Definition: iparith.cc:184
static BOOLEAN jjDEG(leftv res, leftv v)
Definition: iparith.cc:3768
static BOOLEAN jjFETCH_M(leftv res, leftv u)
Definition: iparith.cc:6888
static BOOLEAN jjINDEX_V(leftv res, leftv u, leftv v)
Definition: iparith.cc:1515
static BOOLEAN jjRINGLIST(leftv res, leftv v)
Definition: iparith.cc:4771
static BOOLEAN jjidElem(leftv res, leftv v)
Definition: iparith.cc:5317
static BOOLEAN jjDIM2(leftv res, leftv v, leftv w)
Definition: iparith.cc:1902
static BOOLEAN jjOP_BIM_BI(leftv res, leftv u, leftv v)
Definition: iparith.cc:266
static BOOLEAN jjGCD_BI(leftv res, leftv u, leftv v)
Definition: iparith.cc:2350
static BOOLEAN jjBI2IM(leftv res, leftv u)
Definition: iparith.cc:3668
static BOOLEAN jjRANK2(leftv res, leftv u, leftv v)
Definition: iparith.cc:2955
static BOOLEAN jjDEGREE(leftv res, leftv v)
Definition: iparith.cc:3787
static BOOLEAN jjINDEPSET2(leftv res, leftv u, leftv v)
Definition: iparith.cc:2467
static BOOLEAN jjWAITALL2(leftv res, leftv u, leftv v)
Definition: iparith.cc:3458
static BOOLEAN jjOpenClose(leftv, leftv v)
Definition: iparith.cc:4592
static BOOLEAN jjBRACK_S(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5421
static BOOLEAN jjUMINUS_P(leftv res, leftv u)
Definition: iparith.cc:3572
static BOOLEAN jjMINUS_SM(leftv res, leftv u, leftv v)
Definition: iparith.cc:965
static BOOLEAN jjHIGHCORNER_M(leftv res, leftv v)
Definition: iparith.cc:4104
static BOOLEAN jjNAMES(leftv res, leftv v)
Definition: iparith.cc:4572
static BOOLEAN jjINDEX_P(leftv res, leftv u, leftv v)
Definition: iparith.cc:1446
static BOOLEAN jjHIGHCORNER(leftv res, leftv v)
Definition: iparith.cc:4097
static BOOLEAN jjEQUAL_Ma(leftv res, leftv u, leftv v)
Definition: iparith.cc:1333
static BOOLEAN jjNAMES0(leftv res, leftv)
Definition: iparith.cc:7531
#define SIMPL_NORMALIZE
Definition: iparith.cc:3156
static BOOLEAN jjLOAD2(leftv, leftv, leftv v)
Definition: iparith.cc:2562
static BOOLEAN jjALIGN_M(leftv res, leftv u, leftv v)
Definition: iparith.cc:1778
static BOOLEAN jjWAIT1ST2(leftv res, leftv u, leftv v)
Definition: iparith.cc:3434
static BOOLEAN jjDIV_BI(leftv res, leftv u, leftv v)
Definition: iparith.cc:1256
static BOOLEAN jjCOMPARE_BIM(leftv res, leftv u, leftv v)
Definition: iparith.cc:370
static BOOLEAN jjEQUAL_N(leftv res, leftv u, leftv v)
Definition: iparith.cc:1351
static BOOLEAN jjCOEFFS_Id(leftv res, leftv u, leftv v)
Definition: iparith.cc:1806
static BOOLEAN jjPROC1(leftv res, leftv u)
Definition: iparith.cc:3619
static BOOLEAN jjNOT(leftv res, leftv v)
Definition: iparith.cc:4582
static BOOLEAN jjPARSTR1(leftv res, leftv v)
Definition: iparith.cc:4626
static BOOLEAN jjSUBST_Id_N(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6432
static BOOLEAN jjJET4(leftv res, leftv u)
Definition: iparith.cc:7282
static BOOLEAN jjOPPOSE(leftv res, leftv a, leftv b)
Definition: iparith.cc:2866
static BOOLEAN jjMOD_P(leftv res, leftv u, leftv v)
Definition: iparith.cc:2648
BOOLEAN iiExprArith1Tab(leftv res, leftv a, int op, const struct sValCmd1 *dA1, int at, const struct sConvertTypes *dConvertTypes)
apply an operation 'op' to an argument a return TRUE on failure
Definition: iparith.cc:8318
static BOOLEAN jjPLUS_B(leftv res, leftv u, leftv v)
Definition: iparith.cc:782
static BOOLEAN jjGCD_P(leftv res, leftv u, leftv v)
Definition: iparith.cc:2374
static BOOLEAN jjHOMOG1(leftv res, leftv v)
Definition: iparith.cc:4178
static BOOLEAN jjDET(leftv res, leftv v)
Definition: iparith.cc:3835
static void jjEQUAL_REST(leftv res, leftv u, leftv v)
Definition: iparith.cc:1365
static BOOLEAN jjCOUNT_M(leftv res, leftv v)
Definition: iparith.cc:3743
static BOOLEAN jjPLUS_V(leftv res, leftv u, leftv v)
Definition: iparith.cc:777
#define SIMPL_LMDIV
Definition: iparith.cc:3157
int iiTokType(int op)
Definition: iparith.cc:233
static BOOLEAN jjKoszul_Id(leftv res, leftv u, leftv v)
Definition: iparith.cc:2534
static BOOLEAN jjKLAMMER_rest(leftv res, leftv u, leftv v)
Definition: iparith.cc:1599
static BOOLEAN jjCHINREM_ID(leftv res, leftv u, leftv v)
Definition: iparith.cc:9315
static BOOLEAN jjPLUS_S(leftv res, leftv u, leftv v)
Definition: iparith.cc:863
static BOOLEAN jjHOMOG1_W(leftv res, leftv v, leftv u)
Definition: iparith.cc:2447
static BOOLEAN jjSBA_2(leftv res, leftv v, leftv u, leftv t)
Definition: iparith.cc:4916
static BOOLEAN jjINDEX_IV(leftv res, leftv u, leftv v)
Definition: iparith.cc:1410
char si_char_2[2]
Definition: iparith.cc:8982
unsigned nCmdUsed
number of commands used
Definition: iparith.cc:187
static BOOLEAN jjRING_LIST(leftv res, leftv v)
Definition: iparith.cc:4794
static BOOLEAN jjBRACK_SM(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5521
static BOOLEAN jjSUBST_Test(leftv v, leftv w, int &ringvar, poly &monomexpr)
Definition: iparith.cc:6317
static BOOLEAN jjMINUS_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:878
static BOOLEAN jjJET_P(leftv res, leftv u, leftv v)
Definition: iparith.cc:2503
static BOOLEAN jjVARSTR1(leftv res, leftv v)
Definition: iparith.cc:5149
static BOOLEAN jjSTATUS_M(leftv res, leftv v)
Definition: iparith.cc:7873
static BOOLEAN jjCALL1ARG(leftv res, leftv v)
Definition: iparith.cc:6703
static BOOLEAN jjLT_BI(leftv res, leftv u, leftv v)
Definition: iparith.cc:1220
static BOOLEAN jjPOWER_P(leftv res, leftv u, leftv v)
Definition: iparith.cc:603
#define NO_NC
Definition: iparith.cc:103
BOOLEAN jjLIST_PL(leftv res, leftv v)
Definition: iparith.cc:7480
static BOOLEAN jjPLUSMINUS_Gen(leftv res, leftv u, leftv v)
Definition: iparith.cc:631
static BOOLEAN jjCALL2ARG(leftv res, leftv u)
Definition: iparith.cc:6707
static BOOLEAN jjINDEX_PBu(leftv res, leftv u, leftv v)
Definition: iparith.cc:1463
static int iiTabIndex(const jjValCmdTab dArithTab, const int len, const int op)
Definition: iparith.cc:8959
static BOOLEAN jjSYZYGY(leftv res, leftv v)
Definition: iparith.cc:4992
static BOOLEAN jjPOWER_N(leftv res, leftv u, leftv v)
Definition: iparith.cc:585
static BOOLEAN jjKLAMMER_PL(leftv res, leftv u)
Definition: iparith.cc:7365
static BOOLEAN jjSUBST_M(leftv res, leftv u)
Definition: iparith.cc:7904
#define ZERODIVISOR_MASK
Definition: iparith.cc:97
static BOOLEAN jjEQUAL_P(leftv res, leftv u, leftv v)
Definition: iparith.cc:1357
static BOOLEAN jjLU_DECOMP(leftv res, leftv v)
Definition: iparith.cc:4449
static BOOLEAN jjPlural_num_mat(leftv res, leftv a, leftv b)
Definition: iparith.cc:2787
static BOOLEAN jjIDEAL_PL(leftv res, leftv v)
Definition: iparith.cc:6844
static BOOLEAN jjNVARS(leftv res, leftv v)
Definition: iparith.cc:4587
static BOOLEAN jjERROR(leftv, leftv u)
Definition: iparith.cc:2006
static BOOLEAN jjSTATUS2(leftv res, leftv u, leftv v)
Definition: iparith.cc:3247
static BOOLEAN jjALIGN_V(leftv res, leftv u, leftv v)
Definition: iparith.cc:1768
int iiOp
Definition: iparith.cc:218
static BOOLEAN jjRINGLIST_C(leftv res, leftv v)
Definition: iparith.cc:4787
BOOLEAN iiConvert(int inputType, int outputType, int index, leftv input, leftv output, const struct sConvertTypes *dConvertTypes)
Definition: ipconv.cc:436
omBin sip_command_bin
Definition: ipid.cc:47
lists ipNameListLev(idhdl root, int lev)
Definition: ipid.cc:569
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition: ipid.cc:267
coeffs coeffs_BIGINT
Definition: ipid.cc:52
package basePack
Definition: ipid.cc:60
idhdl currRingHdl
Definition: ipid.cc:61
package currPack
Definition: ipid.cc:59
lists ipNameList(idhdl root)
Definition: ipid.cc:546
#define IDMAP(a)
Definition: ipid.h:130
#define IDMATRIX(a)
Definition: ipid.h:129
ip_command * command
Definition: ipid.h:22
#define IDDATA(a)
Definition: ipid.h:121
#define hasFlag(A, F)
Definition: ipid.h:107
#define setFlag(A, F)
Definition: ipid.h:108
#define IDIDEAL(a)
Definition: ipid.h:128
omBin sleftv_bin
Definition: subexpr.cc:47
#define IDID(a)
Definition: ipid.h:117
#define IDROOT
Definition: ipid.h:18
#define IDINT(a)
Definition: ipid.h:120
#define FLAG_TWOSTD
Definition: ipid.h:105
BOOLEAN load_builtin(const char *newlib, BOOLEAN autoexport, SModulFunc_t init)
Definition: iplib.cc:1197
#define IDPACKAGE(a)
Definition: ipid.h:134
#define IDLEV(a)
Definition: ipid.h:116
int(* SModulFunc_t)(SModulFunctions *)
Definition: ipid.h:80
#define IDRING(a)
Definition: ipid.h:122
#define IDTYP(a)
Definition: ipid.h:114
#define FLAG_STD
Definition: ipid.h:104
BOOLEAN iiLoadLIB(FILE *fp, const char *libnamebuf, const char *newlib, idhdl pl, BOOLEAN autoexport, BOOLEAN tellerror)
Definition: iplib.cc:915
char * iiConvName(const char *libname)
Definition: iplib.cc:1331
sleftv iiRETURNEXPR
Definition: iplib.cc:455
BOOLEAN iiTryLoadLib(leftv v, const char *id)
Definition: iplib.cc:764
BOOLEAN load_modules(const char *newlib, char *fullname, BOOLEAN autoexport)
Definition: iplib.cc:1091
BOOLEAN iiMake_proc(idhdl pn, package pack, leftv sl)
Definition: iplib.cc:485
SModulFunc_t iiGetBuiltinModInit(const char *libname)
Definition: iplib.cc:751
lists rDecompose(const ring r)
Definition: ipshell.cc:2058
lists rDecompose_list_cf(const ring r)
Definition: ipshell.cc:1927
BOOLEAN iiCheckTypes(leftv args, const short *type_list, int report)
check a list of arguemys against a given field of types return TRUE if the types match return FALSE (...
Definition: ipshell.cc:6546
ring rInit(leftv pn, leftv rv, leftv ord)
Definition: ipshell.cc:5574
leftv iiMap(map theMap, const char *what)
Definition: ipshell.cc:612
int iiRegularity(lists L)
Definition: ipshell.cc:961
BOOLEAN rDecompose_CF(leftv res, const coeffs C)
Definition: ipshell.cc:1856
void iiMakeResolv(resolvente r, int length, int rlen, char *name, int typ0, intvec **weights)
Definition: ipshell.cc:771
void killlocals(int v)
Definition: ipshell.cc:383
int exprlist_length(leftv v)
Definition: ipshell.cc:549
BOOLEAN mpKoszul(leftv res, leftv c, leftv b, leftv id)
Definition: ipshell.cc:3062
poly iiHighCorner(ideal I, int ak)
Definition: ipshell.cc:1517
lists scIndIndset(ideal S, BOOLEAN all, ideal Q)
Definition: ipshell.cc:1027
idhdl rFindHdl(ring r, idhdl n)
Definition: ipshell.cc:1612
syStrategy syConvList(lists li)
Definition: ipshell.cc:3225
void test_cmd(int i)
Definition: ipshell.cc:511
ring rCompose(const lists L, const BOOLEAN check_comp, const long bitmask, const int isLetterplace)
Definition: ipshell.cc:2760
const char * lastreserved
Definition: ipshell.cc:80
lists syConvRes(syStrategy syzstr, BOOLEAN toDel, int add_row_shift)
Definition: ipshell.cc:3153
void rSetHdl(idhdl h)
Definition: ipshell.cc:5081
BOOLEAN iiExport(leftv v, int toLev)
Definition: ipshell.cc:1419
const struct sValCmd1 dArith1[]
Definition: table.h:37
short arg
Definition: gentable.cc:83
short res
Definition: gentable.cc:73
proc3 p
Definition: iparith.cc:163
short arg1
Definition: gentable.cc:74
proc1 p
Definition: iparith.cc:142
const struct sValCmd2 dArith2[]
Definition: table.h:316
short number_of_args
Definition: gentable.cc:101
short valid_for
Definition: gentable.cc:102
BOOLEAN setOption(leftv res, leftv v)
Definition: misc_ip.cc:586
short cmd
Definition: gentable.cc:89
short cmd
Definition: gentable.cc:72
short valid_for
Definition: gentable.cc:94
short cmd
Definition: gentable.cc:81
short valid_for
Definition: gentable.cc:76
short res
Definition: gentable.cc:100
short res
Definition: gentable.cc:90
short arg1
Definition: gentable.cc:91
proc1 p
Definition: iparith.cc:173
short arg2
Definition: gentable.cc:92
BOOLEAN(* proc1)(leftv, leftv)
Definition: ipshell.h:121
const struct sValCmdM dArithM[]
Definition: table.h:885
short valid_for
Definition: gentable.cc:84
short arg3
Definition: gentable.cc:93
proc2 p
Definition: iparith.cc:152
short res
Definition: gentable.cc:82
short arg2
Definition: gentable.cc:75
const struct sValCmd3 dArith3[]
Definition: table.h:763
short cmd
Definition: gentable.cc:99
static Poly * h
Definition: janet.cc:972
static jList * T
Definition: janet.cc:31
ListNode * next
Definition: janet.h:31
ideal kMin_std(ideal F, ideal Q, tHomog h, intvec **w, ideal &M, intvec *hilb, int syzComp, int reduced)
Definition: kstd1.cc:2673
intvec * kHomW
Definition: kstd1.cc:2062
ideal kInterRed(ideal F, ideal Q)
Definition: kstd1.cc:3380
intvec * kModW
Definition: kstd1.cc:2062
long kHomModDeg(poly p, ring r)
Definition: kstd1.cc:2074
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition: kstd1.cc:2822
ideal kSba(ideal F, ideal Q, tHomog h, intvec **w, int sbaOrder, int arri, intvec *hilb, int syzComp, int newIdeal, intvec *vw)
Definition: kstd1.cc:2268
ideal kStd(ideal F, ideal Q, tHomog h, intvec **w, intvec *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
Definition: kstd1.cc:2087
int Kstd1_deg
Definition: kstd1.h:47
poly redNF(poly h, int &max_ind, int nonorm, kStrategy strat)
Definition: kstd2.cc:1589
ideal_list kStdfac(ideal F, ideal Q, tHomog h, intvec **w, ideal D)
Definition: kstdfac.cc:807
char * showOption()
Definition: misc_ip.cc:728
char libnamebuf[1024]
Definition: libparse.cc:1096
if(yy_init)
Definition: libparse.cc:1418
idhdl h0
Definition: libparse.cc:1141
static bool rIsSCA(const ring r)
Definition: nc.h:190
ideal idOppose(ring Rop_src, ideal I, const ring Rop_dst)
opposes a module I from Rop to currRing(dst)
Definition: old.gring.cc:3407
poly pOppose(ring Rop_src, poly p, const ring Rop_dst)
opposes a vector p from Rop to currRing (dst!)
Definition: old.gring.cc:3368
BOOLEAN rIsLikeOpposite(ring rBase, ring rCandidate)
checks whether rings rBase and rCandidate could be opposite to each other returns TRUE if it is so
Definition: old.gring.cc:3341
BOOLEAN nc_CallPlural(matrix cc, matrix dd, poly cn, poly dn, ring r, bool bSetupQuotient, bool bCopyInput, bool bBeQuiet, ring curr, bool dummy_ring=false)
returns TRUE if there were errors analyze inputs, check them for consistency detects nc_type,...
Definition: old.gring.cc:2682
poly nc_p_Bracket_qq(poly p, const poly q, const ring r)
returns [p,q], destroys p
Definition: old.gring.cc:2243
int luRank(const matrix aMat, const bool isRowEchelon, const ring R)
Computes the rank of a given (m x n)-matrix.
bool luInverseFromLUDecomp(const matrix pMat, const matrix lMat, const matrix uMat, matrix &iMat, const ring R)
This code computes the inverse by inverting lMat and uMat, and then performing two matrix multiplicat...
void henselFactors(const int xIndex, const int yIndex, const poly h, const poly f0, const poly g0, const int d, poly &f, poly &g)
Computes a factorization of a polynomial h(x, y) in K[[x]][y] up to a certain degree in x,...
bool luInverse(const matrix aMat, matrix &iMat, const ring R)
This code first computes the LU-decomposition of aMat, and then calls the method for inverting a matr...
void luDecomp(const matrix aMat, matrix &pMat, matrix &lMat, matrix &uMat, const ring R)
LU-decomposition of a given (m x n)-matrix.
bool luSolveViaLUDecomp(const matrix pMat, const matrix lMat, const matrix uMat, const matrix bVec, matrix &xVec, matrix &H)
Solves the linear system A * x = b, where A is an (m x n)-matrix which is given by its LU-decompositi...
lists qrDoubleShift(const matrix A, const number tol1, const number tol2, const number tol3, const ring r=currRing)
Computes all eigenvalues of a given real quadratic matrix with multiplicites.
omBin slists_bin
Definition: lists.cc:23
int lSize(lists L)
Definition: lists.cc:25
BOOLEAN jjANY2LIST(leftv res, leftv v, int cnt)
LINLINE void nlDelete(number *a, const coeffs r)
Definition: longrat.cc:2498
LINLINE number nlInit(long i, const coeffs r)
Definition: longrat.cc:2438
void maFindPerm(char const *const *const preim_names, int preim_n, char const *const *const preim_par, int preim_p, char const *const *const names, int n, char const *const *const par, int nop, int *perm, int *par_perm, n_coeffType ch)
Definition: maps.cc:165
poly pSubstPoly(poly p, int var, poly image)
Definition: maps_ip.cc:402
ideal idSubstPoly(ideal id, int n, poly e)
Definition: maps_ip.cc:418
BOOLEAN maApplyFetch(int what, map theMap, leftv res, leftv w, ring preimage_r, int *perm, int *par_perm, int P, nMapFunc nMap)
Definition: maps_ip.cc:46
ideal idSubstPar(ideal id, int n, poly e)
Definition: maps_ip.cc:385
poly pSubstPar(poly p, int par, poly image)
Definition: maps_ip.cc:265
BOOLEAN mp_IsDiagUnit(matrix U, const ring R)
Definition: matpol.cc:819
matrix mp_Wedge(matrix a, int ar, const ring R)
Definition: matpol.cc:1754
matrix mp_Transp(matrix a, const ring R)
Definition: matpol.cc:257
ideal sm_Tensor(ideal A, ideal B, const ring r)
Definition: matpol.cc:1834
ideal sm_Add(ideal a, ideal b, const ring R)
Definition: matpol.cc:1874
matrix mp_CoeffProc(poly f, poly vars, const ring R)
Definition: matpol.cc:402
matrix pMultMp(poly p, matrix a, const ring R)
Definition: matpol.cc:165
void mp_Monomials(matrix c, int r, int var, matrix m, const ring R)
Definition: matpol.cc:365
matrix mp_CoeffProcId(ideal I, poly vars, const ring R)
Definition: matpol.cc:479
ideal sm_Sub(ideal a, ideal b, const ring R)
Definition: matpol.cc:1884
ideal sm_Mult(ideal a, ideal b, const ring R)
Definition: matpol.cc:1894
matrix mp_Sub(matrix a, matrix b, const ring R)
Definition: matpol.cc:196
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:37
int mp_Compare(matrix a, matrix b, const ring R)
Definition: matpol.cc:646
BOOLEAN sm_Equal(ideal a, ideal b, const ring R)
Definition: matpol.cc:2006
matrix mp_Mult(matrix a, matrix b, const ring R)
Definition: matpol.cc:213
BOOLEAN mp_Equal(matrix a, matrix b, const ring R)
Definition: matpol.cc:665
matrix mp_MultI(matrix a, int f, const ring R)
c = f*a
Definition: matpol.cc:135
matrix mp_Coeffs(ideal I, int var, const ring R)
corresponds to Maple's coeffs: var has to be the number of a variable
Definition: matpol.cc:316
void mp_Coef2(poly v, poly mon, matrix *c, matrix *m, const ring R)
corresponds to Macauley's coef: the exponent vector of vars has to contain the variables,...
Definition: matpol.cc:584
matrix mp_MultP(matrix a, poly p, const ring R)
multiply a matrix 'a' by a poly 'p', destroy the args
Definition: matpol.cc:148
matrix mp_Copy(matrix a, const ring r)
copies matrix a (from ring r to r)
Definition: matpol.cc:64
matrix mp_Add(matrix a, matrix b, const ring R)
Definition: matpol.cc:179
matrix mp_InitP(int r, int c, poly p, const ring R)
make it a p * unit matrix
Definition: matpol.cc:113
poly mp_Trace(matrix a, const ring R)
Definition: matpol.cc:278
#define MATELEM(mat, i, j)
Definition: matpol.h:28
ip_smatrix * matrix
Definition: matpol.h:31
#define MATROWS(i)
Definition: matpol.h:26
#define MATCOLS(i)
Definition: matpol.h:27
lists primeFactorisation(const number n, const int pBound)
Factorises a given bigint number n into its prime factors less than or equal to a given bound,...
Definition: misc_ip.cc:372
This file provides miscellaneous functionality.
#define TIMER_RESOLUTION
Definition: mod2.h:34
#define assume(x)
Definition: mod2.h:390
lib_types type_of_LIB(const char *newlib, char *libnamebuf)
Definition: mod_lib.cc:22
lib_types
Definition: mod_raw.h:16
@ LT_MACH_O
Definition: mod_raw.h:16
@ LT_HPUX
Definition: mod_raw.h:16
@ LT_SINGULAR
Definition: mod_raw.h:16
@ LT_BUILTIN
Definition: mod_raw.h:16
@ LT_ELF
Definition: mod_raw.h:16
@ LT_NONE
Definition: mod_raw.h:16
@ LT_NOTFOUND
Definition: mod_raw.h:16
#define pIter(p)
Definition: monomials.h:38
#define pNext(p)
Definition: monomials.h:37
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition: monomials.h:45
#define pSetCoeff0(p, n)
Definition: monomials.h:60
slists * lists
Definition: mpr_numeric.h:146
const int MAX_INT_VAL
Definition: mylimits.h:12
The main handler for Singular numbers which are suitable for Singular polynomials.
Definition: ap.h:40
ideal twostd(ideal I)
Compute two-sided GB:
Definition: nc.cc:18
void newstruct_setup(const char *n, newstruct_desc d)
Definition: newstruct.cc:701
newstruct_desc newstructChildFromString(const char *parent, const char *s)
Definition: newstruct.cc:812
newstruct_desc newstructFromString(const char *s)
Definition: newstruct.cc:805
CanonicalForm ndConvSingNFactoryN(number, BOOLEAN, const coeffs)
Definition: numbers.cc:273
#define nDiv(a, b)
Definition: numbers.h:33
#define nDelete(n)
Definition: numbers.h:17
#define nInpNeg(n)
Definition: numbers.h:22
#define nIsZero(n)
Definition: numbers.h:20
#define nEqual(n1, n2)
Definition: numbers.h:21
#define nSub(n1, n2)
Definition: numbers.h:23
#define nCopy(n)
Definition: numbers.h:16
#define nGreater(a, b)
Definition: numbers.h:29
#define nAdd(n1, n2)
Definition: numbers.h:19
#define nSize(n)
Definition: numbers.h:40
#define nInvers(a)
Definition: numbers.h:34
#define nIsOne(n)
Definition: numbers.h:26
#define nNormalize(n)
Definition: numbers.h:31
#define nInit(i)
Definition: numbers.h:25
#define nMult(n1, n2)
Definition: numbers.h:18
#define nPower(a, b, res)
Definition: numbers.h:39
#define omStrDup(s)
Definition: omAllocDecl.h:263
#define omfree(addr)
Definition: omAllocDecl.h:237
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
#define omRealloc(addr, size)
Definition: omAllocDecl.h:225
#define omFree(addr)
Definition: omAllocDecl.h:261
#define omAlloc0(size)
Definition: omAllocDecl.h:211
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
void omPrintBinStats(FILE *fd)
Definition: omBin.c:692
#define NULL
Definition: omList.c:10
void omPrintStats(FILE *fd)
Definition: omStats.c:115
void omPrintInfo(FILE *fd)
Definition: omStats.c:129
void omUpdateInfo()
Definition: omStats.c:24
omInfo_t om_Info
Definition: omStats.c:13
unsigned si_opt_2
Definition: options.c:6
unsigned si_opt_1
Definition: options.c:5
#define SI_SAVE_OPT2(A)
Definition: options.h:23
#define BVERBOSE(a)
Definition: options.h:35
#define OPT_SB_1
Definition: options.h:94
#define SI_SAVE_OPT1(A)
Definition: options.h:22
#define SI_RESTORE_OPT1(A)
Definition: options.h:25
#define SI_RESTORE_OPT2(A)
Definition: options.h:26
#define Sy_bit(x)
Definition: options.h:32
#define TEST_OPT_DEGBOUND
Definition: options.h:112
#define TEST_OPT_RETURN_SB
Definition: options.h:111
#define TEST_OPT_PROT
Definition: options.h:102
#define V_IMAP
Definition: options.h:53
#define V_DEG_STOP
Definition: options.h:71
#define V_SHOW_USE
Definition: options.h:52
static int index(p_Length length, p_Ord ord)
Definition: p_Procs_Impl.h:592
void pRestoreDegProcs(ring r, pFDegProc old_FDeg, pLDegProc old_lDeg)
Definition: p_polys.cc:3600
poly p_Homogen(poly p, int varnum, const ring r)
Definition: p_polys.cc:3208
void p_Shift(poly *p, int i, const ring r)
shifts components of the vector p by i
Definition: p_polys.cc:4604
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3723
int p_Compare(const poly a, const poly b, const ring R)
Definition: p_polys.cc:4804
poly p_Series(int n, poly p, poly u, intvec *w, const ring R)
Definition: p_polys.cc:4396
poly p_Cleardenom(poly p, const ring r)
Definition: p_polys.cc:2782
long p_DegW(poly p, const short *w, const ring R)
Definition: p_polys.cc:682
poly p_Vec2Poly(poly v, int k, const ring r)
Definition: p_polys.cc:3522
poly p_One(const ring r)
Definition: p_polys.cc:1305
void pSetDegProcs(ring r, pFDegProc new_FDeg, pLDegProc new_lDeg)
Definition: p_polys.cc:3588
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1044
static long p_MinComp(poly p, ring lmRing, ring tailRing)
Definition: p_polys.h:314
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:858
static unsigned pLength(poly a)
Definition: p_polys.h:193
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1444
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
void rChangeCurrRing(ring r)
Definition: polys.cc:15
poly p_Divide(poly p, poly q, const ring r)
polynomial division, ignoring the rest via singclap_pdivide resp. idLift destroyes a,...
Definition: polys.cc:31
poly singclap_gcd(poly f, poly g, const ring r)
polynomial gcd via singclap_gcd_r resp. idSyzygies destroys f and g
Definition: polys.cc:165
Compatiblity layer for legacy polynomial operations (over currRing)
#define pAdd(p, q)
Definition: polys.h:198
static long pTotaldegree(poly p)
Definition: polys.h:276
#define pDelete(p_ptr)
Definition: polys.h:181
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL
Definition: polys.h:67
#define pSetm(p)
Definition: polys.h:265
#define pIsConstant(p)
like above, except that Comp might be != 0
Definition: polys.h:233
#define pSplit(p, r)
Definition: polys.h:259
#define pNeg(p)
Definition: polys.h:193
#define pGetComp(p)
Component.
Definition: polys.h:37
#define pDiff(a, b)
Definition: polys.h:290
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
Definition: polys.h:31
#define pNSet(n)
Definition: polys.h:307
#define pVar(m)
Definition: polys.h:375
#define pJet(p, m)
Definition: polys.h:362
#define pSub(a, b)
Definition: polys.h:281
#define ppJetW(p, m, iv)
Definition: polys.h:363
#define pDivideM(a, b)
Definition: polys.h:288
#define pMaxComp(p)
Definition: polys.h:293
#define pLmInit(p)
like pInit, except that expvector is initialized to that of p, p must be != NULL
Definition: polys.h:64
#define pIsUnit(p)
return true if the Lm is a constant <>0
Definition: polys.h:235
#define pPower(p, q)
Definition: polys.h:199
#define pSetComp(p, v)
Definition: polys.h:38
#define pLmDelete(p)
assume p != NULL, deletes Lm(p)->coef and Lm(p)
Definition: polys.h:76
#define pMult(p, q)
Definition: polys.h:202
static void pLmFree(poly p)
frees the space of the monomial m, assumes m != NULL coef is not freed, m is not advanced
Definition: polys.h:70
#define pSubst(p, n, e)
Definition: polys.h:360
#define pSeries(n, p, u, w)
Definition: polys.h:366
#define pGetExp(p, i)
Exponent.
Definition: polys.h:41
void pNorm(poly p, const ring R=currRing)
Definition: polys.h:357
#define pNormalize(p)
Definition: polys.h:311
#define pInit()
allocates a new monomial and initializes everything to 0
Definition: polys.h:61
#define pEqualPolys(p1, p2)
Definition: polys.h:394
#define pSetExp(p, i, v)
Definition: polys.h:42
#define pLmCmp(p, q)
returns 0|1|-1 if p=q|p>q|p<q w.r.t monomial ordering
Definition: polys.h:105
#define pCopy(p)
return a copy of the poly
Definition: polys.h:180
#define pLmFreeAndNext(p)
assumes p != NULL, deletes p, returns pNext(p)
Definition: polys.h:74
#define pOne()
Definition: polys.h:309
#define pIsUnivariate(p)
Definition: polys.h:244
#define pISet(i)
Definition: polys.h:306
#define pWTotaldegree(p)
Definition: polys.h:277
ideal maGetPreimage(ring theImageRing, map theMap, ideal id, const ring dst_r)
Definition: preimage.cc:61
int IsPrime(int p)
Definition: prime.cc:61
void SPrintStart()
Definition: reporter.cc:246
char * SPrintEnd()
Definition: reporter.cc:273
const char feNotImplemented[]
Definition: reporter.cc:54
void PrintS(const char *s)
Definition: reporter.cc:284
void PrintLn()
Definition: reporter.cc:310
void Werror(const char *fmt,...)
Definition: reporter.cc:189
int traceit
Definition: febase.cc:42
#define TRACE_CALL
Definition: reporter.h:43
#define SI_PROT_O
Definition: reporter.h:53
#define SI_PROT_I
Definition: reporter.h:52
#define mflush()
Definition: reporter.h:57
int rSum(ring r1, ring r2, ring &sum)
Definition: ring.cc:1321
char * rVarStr(ring r)
Definition: ring.cc:596
int r_IsRingVar(const char *n, char **names, int N)
Definition: ring.cc:213
int rChar(ring r)
Definition: ring.cc:686
char * rOrdStr(ring r)
Definition: ring.cc:511
char * rCharStr(const ring r)
TODO: make it a virtual method of coeffs, together with: Decompose & Compose, rParameter & rPar.
Definition: ring.cc:620
BOOLEAN rSamePolyRep(ring r1, ring r2)
returns TRUE, if r1 and r2 represents the monomials in the same way FALSE, otherwise this is an analo...
Definition: ring.cc:1683
ring rOpposite(ring src)
Definition: ring.cc:5194
ring rDefault(const coeffs cf, int N, char **n, int ord_size, rRingOrder_t *ord, int *block0, int *block1, int **wvhdl, unsigned long bitmask)
Definition: ring.cc:103
char * rParStr(ring r)
Definition: ring.cc:622
ring rEnvelope(ring R)
Definition: ring.cc:5524
int n_IsParam(const number m, const ring r)
TODO: rewrite somehow...
Definition: ring.cc:5649
ring rCopy(ring r)
Definition: ring.cc:1620
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:475
static BOOLEAN rField_is_Zp_a(const ring r)
Definition: ring.h:520
static BOOLEAN rField_is_Z(const ring r)
Definition: ring.h:500
static BOOLEAN rField_is_Zp(const ring r)
Definition: ring.h:491
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:398
long(* pFDegProc)(poly p, ring r)
Definition: ring.h:39
static char const ** rParameter(const ring r)
(r->cf->parameter)
Definition: ring.h:615
static BOOLEAN rField_is_Domain(const ring r)
Definition: ring.h:478
long(* pLDegProc)(poly p, int *length, ring r)
Definition: ring.h:38
static int rPar(const ring r)
(r->cf->P)
Definition: ring.h:589
@ ringorder_lp
Definition: ring.h:78
@ ringorder_dp
Definition: ring.h:79
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:497
static BOOLEAN rField_is_numeric(const ring r)
Definition: ring.h:506
BOOLEAN rHasMixedOrdering(const ring r)
Definition: ring.h:752
static BOOLEAN rField_is_GF(const ring r)
Definition: ring.h:512
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:582
BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition: ring.h:751
idrec * idhdl
Definition: ring.h:22
void sBucket_Add_p(sBucket_pt bucket, poly p, int length)
adds poly p to bucket destroys p!
Definition: sbuckets.cc:205
void sBucketCanonicalize(sBucket_pt bucket)
Definition: sbuckets.cc:401
sBucket_pt sBucketCreate(const ring r)
Definition: sbuckets.cc:98
poly sBucketPeek(sBucket_pt b)
Definition: sbuckets.cc:455
sBucket * sBucket_pt
Definition: sbuckets.h:16
void sBucketDestroyAdd(sBucket_pt bucket, poly *p, int *length)
Definition: sbuckets.h:68
BOOLEAN sdb_set_breakpoint(const char *pp, int given_lineno)
Definition: sdb.cc:65
void sdb_show_bp()
Definition: sdb.cc:58
ideal id_Vec2Ideal(poly vec, const ring R)
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:37
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
void id_Norm(ideal id, const ring r)
ideal id = (id[i]), result is leadcoeff(id[i]) = 1
void id_Normalize(ideal I, const ring r)
normialize all polys in id
ideal id_Transp(ideal a, const ring rRing)
transpose a module
ideal id_FreeModule(int i, const ring r)
the free module of rank i
ideal id_Homogen(ideal h, int varnum, const ring r)
ideal id_Power(ideal given, int exp, const ring r)
matrix id_Module2Matrix(ideal mod, const ring R)
int idElem(const ideal F)
count non-zero elements
ideal id_Head(ideal h, const ring r)
returns the ideals of initial terms
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
void id_DelDiv(ideal id, const ring r)
delete id[j], if LT(j) == coeff*mon*LT(i) and vice versa, i.e., delete id[i], if LT(i) == coeff*mon*L...
void id_DelMultiples(ideal id, const ring r)
ideal id = (id[i]), c any unit if id[i] = c*id[j] then id[j] is deleted for j > i
matrix id_Module2formatedMatrix(ideal mod, int rows, int cols, const ring R)
ideal id_Matrix2Module(matrix mat, const ring R)
converts mat to module, destroys mat
ideal id_ResizeModule(ideal mod, int rows, int cols, const ring R)
ideal id_Delete_Pos(const ideal I, const int p, const ring r)
void id_DelEquals(ideal id, const ring r)
ideal id = (id[i]) if id[i] = id[j] then id[j] is deleted for j > i
ideal id_Jet(const ideal i, int d, const ring R)
void id_DelLmEquals(ideal id, const ring r)
Delete id[j], if Lm(j) == Lm(i) and both LC(j), LC(i) are units and j > i.
ideal id_JetW(const ideal i, int d, intvec *iv, const ring R)
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
void id_Shift(ideal M, int s, const ring r)
ideal id_ChineseRemainder(ideal *xx, number *q, int rl, const ring r)
ideal id_Subst(ideal id, int n, poly e, const ring r)
#define IDELEMS(i)
Definition: simpleideals.h:24
int siRand()
Definition: sirandom.c:41
#define R
Definition: sirandom.c:26
#define A
Definition: sirandom.c:23
#define M
Definition: sirandom.c:24
#define Q
Definition: sirandom.c:25
poly sm_CallDet(ideal I, const ring R)
Definition: sparsmat.cc:357
BOOLEAN sm_CheckDet(ideal I, int d, BOOLEAN sw, const ring r)
Definition: sparsmat.cc:306
void sm_CallBareiss(ideal I, int x, int y, ideal &M, intvec **iv, const ring R)
Definition: sparsmat.cc:402
ideal sm_CallSolv(ideal I, const ring R)
Definition: sparsmat.cc:2371
omBin char_ptr_bin
Definition: ring.cc:45
sleftv * leftv
Definition: structs.h:60
tHomog
Definition: structs.h:38
@ isHomog
Definition: structs.h:40
@ testHomog
Definition: structs.h:41
@ isNotHomog
Definition: structs.h:39
#define BITSET
Definition: structs.h:18
#define loop
Definition: structs.h:78
void syMake(leftv v, const char *id, package pa)
Definition: subexpr.cc:1584
sleftv sLastPrinted
Definition: subexpr.cc:52
BOOLEAN siq
Definition: subexpr.cc:54
omBin sSubexpr_bin
Definition: subexpr.cc:46
BOOLEAN assumeStdFlag(leftv h)
Definition: subexpr.cc:1558
@ LANG_SINGULAR
Definition: subexpr.h:22
@ LANG_MIX
Definition: subexpr.h:22
@ LANG_C
Definition: subexpr.h:22
@ LANG_TOP
Definition: subexpr.h:22
resolvente syResolvente(ideal arg, int maxlength, int *length, intvec ***weights, BOOLEAN minim)
Definition: syz.cc:390
syStrategy syResolution(ideal arg, int maxlength, intvec *w, BOOLEAN minim)
Definition: syz.cc:614
ideal syMinBase(ideal arg)
Definition: syz.cc:1005
syStrategy syHilb(ideal arg, int *length)
Definition: syz2.cc:952
resolvente sySchreyerResolvente(ideal arg, int maxlength, int *length, BOOLEAN isMonomial=FALSE, BOOLEAN notReplace=FALSE)
Definition: syz0.cc:856
syStrategy sySchreyer(ideal arg, int maxlength)
Definition: syz0.cc:1019
ring syRing
Definition: syz.h:56
int syDim(syStrategy syzstr)
Definition: syz1.cc:1850
syStrategy syMinimize(syStrategy syzstr)
Definition: syz1.cc:2395
resolvente minres
Definition: syz.h:58
syStrategy syKosz(ideal arg, int *length)
Definition: syz3.cc:1764
int sySize(syStrategy syzstr)
Definition: syz1.cc:1830
short list_length
Definition: syz.h:62
resolvente res
Definition: syz.h:47
resolvente fullres
Definition: syz.h:57
intvec ** weights
Definition: syz.h:45
ssyStrategy * syStrategy
Definition: syz.h:35
resolvente orderedRes
Definition: syz.h:48
SRes resPairs
Definition: syz.h:49
syStrategy syFrank(const ideal arg, const int length, const char *method, const bool use_cache=true, const bool use_tensor_trick=false)
Definition: syz4.cc:823
syStrategy syLaScala3(ideal arg, int *length)
Definition: syz1.cc:2434
const struct sConvertTypes dConvertTypes[]
Definition: table.h:1251
ideal t_rep_gb(const ring r, ideal arg_I, int syz_comp, BOOLEAN F4_mode)
Definition: tgb.cc:3520
int getRTimer()
Definition: timer.cc:172
#define IDHDL
Definition: tok.h:31
@ NCALGEBRA_CMD
Definition: tok.h:137
@ ALIAS_CMD
Definition: tok.h:34
@ BIGINT_CMD
Definition: tok.h:38
@ CRING_CMD
Definition: tok.h:56
@ LIST_CMD
Definition: tok.h:118
@ INTVEC_CMD
Definition: tok.h:101
@ PACKAGE_CMD
Definition: tok.h:149
@ DEF_CMD
Definition: tok.h:58
@ LRES_CMD
Definition: tok.h:120
@ SUBST_CMD
Definition: tok.h:184
@ HRES_CMD
Definition: tok.h:91
@ KRES_CMD
Definition: tok.h:109
@ OPEN_CMD
Definition: tok.h:144
@ CNUMBER_CMD
Definition: tok.h:47
@ LINK_CMD
Definition: tok.h:117
@ STD_CMD
Definition: tok.h:182
@ CHINREM_CMD
Definition: tok.h:45
@ MRES_CMD
Definition: tok.h:131
@ STRING_CMD
Definition: tok.h:183
@ SRES_CMD
Definition: tok.h:180
@ INTDIV_CMD
Definition: tok.h:97
@ INT_CMD
Definition: tok.h:96
@ KERNEL_CMD
Definition: tok.h:107
@ FAREY_CMD
Definition: tok.h:77
@ MAX_TOK
Definition: tok.h:216
@ RES_CMD
Definition: tok.h:167
#define NONE
Definition: tok.h:219
#define COMMAND
Definition: tok.h:29
#define UNKNOWN
Definition: tok.h:220
#define ANY_TYPE
Definition: tok.h:30
number ntDiff(number a, number d, const coeffs cf)
Definition: transext.cc:898
ideal fractalWalkProc(leftv first, leftv second)
Definition: walk_ip.cc:161
ideal walkProc(leftv first, leftv second)
Definition: walk_ip.cc:55
short * iv2array(intvec *iv, const ring R)
Definition: weight.cc:206
BOOLEAN jjStdJanetBasis(leftv res, leftv v, int flag)
flag: 0: JB, 1: SB
Definition: wrapper.cc:50