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 
9 
10 #include <kernel/mod2.h>
11 
12 #include <omalloc/omalloc.h>
13 
14 #include <factory/factory.h>
15 
16 #include <coeffs/bigintmat.h>
17 #include <coeffs/coeffs.h>
18 #include <coeffs/numbers.h>
19 
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/prCopy.h>
27 #include <polys/matpol.h>
28 #include <polys/monomials/maps.h>
29 #include <polys/coeffrings.h>
30 #include <polys/sparsmat.h>
31 #include <polys/weight.h>
33 #include <polys/clapsing.h>
34 
37 
41 
42 #include <kernel/spectrum/GMPrat.h>
44 #include <kernel/oswrapper/timer.h>
45 #include <kernel/fglm/fglm.h>
46 
48 #include <kernel/GBEngine/syz.h>
49 #include <kernel/GBEngine/kstd1.h>
50 #include <kernel/GBEngine/units.h>
51 #include <kernel/GBEngine/tgb.h>
52 
53 #include <kernel/preimage.h>
54 #include <kernel/polys.h>
55 #include <kernel/ideals.h>
56 
57 #include <Singular/mod_lib.h>
58 #include <Singular/fevoices.h>
59 #include <Singular/tok.h>
60 #include <Singular/ipid.h>
61 #include <Singular/sdb.h>
62 #include <Singular/subexpr.h>
63 #include <Singular/lists.h>
64 #include <Singular/maps_ip.h>
65 
66 #include <Singular/ipconv.h>
67 #include <Singular/ipprint.h>
68 #include <Singular/attrib.h>
69 #include <Singular/links/silink.h>
70 #include <Singular/misc_ip.h>
72 
73 #ifdef SINGULAR_4_1
74 #include <Singular/number2.h>
75 #endif
76 
77 # include <Singular/fglm.h>
78 
79 #include <Singular/blackbox.h>
80 #include <Singular/newstruct.h>
81 #include <Singular/ipshell.h>
82 //#include <kernel/mpr_inout.h>
83 #include <reporter/si_signals.h>
84 
85 #include <Singular/number2.h>
86 
87 
88 #include <stdlib.h>
89 #include <string.h>
90 #include <ctype.h>
91 #include <stdio.h>
92 #include <time.h>
93 #include <unistd.h>
94 #include <vector>
95 
96 lists rDecompose(const ring r);
97 ring rCompose(const lists L, const BOOLEAN check_comp=TRUE);
98 
99 
100 // defaults for all commands: NO_PLURAL | NO_RING | ALLOW_ZERODIVISOR
101 
102 #ifdef HAVE_PLURAL
103  #include <kernel/GBEngine/ratgring.h>
104  #include <kernel/GBEngine/nc.h>
105  #include <polys/nc/nc.h>
106  #include <polys/nc/sca.h>
107  #define PLURAL_MASK 3
108 #else /* HAVE_PLURAL */
109  #define PLURAL_MASK 0
110 #endif /* HAVE_PLURAL */
111 
112 #ifdef HAVE_RINGS
113  #define RING_MASK 4
114  #define ZERODIVISOR_MASK 8
115 #else
116  #define RING_MASK 0
117  #define ZERODIVISOR_MASK 0
118 #endif
119 #define ALLOW_PLURAL 1
120 #define NO_PLURAL 0
121 #define COMM_PLURAL 2
122 #define ALLOW_RING 4
123 #define NO_RING 0
124 #define NO_ZERODIVISOR 8
125 #define ALLOW_ZERODIVISOR 0
126 
127 // bit 4 for warning, if used at toplevel
128 #define WARN_RING 16
129 
130 static BOOLEAN check_valid(const int p, const int op);
131 
132 #ifdef SINGULAR_4_1
133 // helper routine to catch all library/test parts which need to be changed
134 // shall go away after the transition
135 static void iiReWrite(const char *s)
136 {
137  Print("please rewrite the use of >>%s<< in >>%s<<\n"
138  "%s is depreciated or changed in Singular 4-1\n",s,my_yylinebuf,s);
139 }
140 #endif
141 
142 /*=============== types =====================*/
144 {
145  short cmd;
146  short start;
147 };
148 
150 
151 struct _scmdnames
152 {
153  char *name;
154  short alias;
155  short tokval;
156  short toktype;
157 };
158 typedef struct _scmdnames cmdnames;
159 
160 
161 typedef char * (*Proc1)(char *);
162 struct sValCmd1
163 {
165  short cmd;
166  short res;
167  short arg;
168  short valid_for;
169 };
170 
172 struct sValCmd2
173 {
175  short cmd;
176  short res;
177  short arg1;
178  short arg2;
179  short valid_for;
180 };
181 
183 struct sValCmd3
184 {
186  short cmd;
187  short res;
188  short arg1;
189  short arg2;
190  short arg3;
191  short valid_for;
192 };
193 struct sValCmdM
194 {
196  short cmd;
197  short res;
198  short number_of_args; /* -1: any, -2: any >0, .. */
199  short valid_for;
200 };
201 
202 typedef struct
203 {
204  cmdnames *sCmds; /**< array of existing commands */
209  int nCmdUsed; /**< number of commands used */
210  int nCmdAllocated; /**< number of commands-slots allocated */
211  int nLastIdentifier; /**< valid indentifieres are slot 1..nLastIdentifier */
212 } SArithBase;
213 
214 /*---------------------------------------------------------------------*
215  * File scope Variables (Variables share by several functions in
216  * the same file )
217  *
218  *---------------------------------------------------------------------*/
219 static SArithBase sArithBase; /**< Base entry for arithmetic */
220 
221 /*---------------------------------------------------------------------*
222  * Extern Functions declarations
223  *
224  *---------------------------------------------------------------------*/
225 static int _gentable_sort_cmds(const void *a, const void *b);
226 extern int iiArithRemoveCmd(char *szName);
227 extern int iiArithAddCmd(const char *szName, short nAlias, short nTokval,
228  short nToktype, short nPos=-1);
229 
230 /*============= proc =======================*/
231 static int iiTabIndex(const jjValCmdTab dArithTab, const int len, const int op);
232 static Subexpr jjMakeSub(leftv e);
233 
234 /*============= vars ======================*/
235 extern int cmdtok;
236 extern BOOLEAN expected_parms;
237 
238 #define ii_div_by_0 "div. by 0"
239 
240 int iiOp; /* the current operation*/
241 
242 /*=================== simple helpers =================*/
243 static int iin_Int(number &n,coeffs cf)
244 {
245  long l=n_Int(n,cf);
246  int i=(int)l;
247  if ((long)i==l) return l;
248  return 0;
249 }
251 {
252  return pHead(p);
253 }
254 
255 int iiTokType(int op)
256 {
257  for (int i=0;i<sArithBase.nCmdUsed;i++)
258  {
259  if (sArithBase.sCmds[i].tokval==op)
260  return sArithBase.sCmds[i].toktype;
261  }
262  return 0;
263 }
264 
265 /*=================== operations with 2 args.: static proc =================*/
266 /* must be ordered: first operations for chars (infix ops),
267  * then alphabetically */
268 
270 {
271  bigintmat* aa= (bigintmat *)u->Data();
272  int bb = (int)(long)(v->Data());
273  if (errorreported) return TRUE;
274  bigintmat *cc=NULL;
275  switch (iiOp)
276  {
277  case '+': cc=bimAdd(aa,bb); break;
278  case '-': cc=bimSub(aa,bb); break;
279  case '*': cc=bimMult(aa,bb); break;
280  }
281  res->data=(char *)cc;
282  return cc==NULL;
283 }
285 {
286  return jjOP_BIM_I(res, v, u);
287 }
289 {
290  bigintmat* aa= (bigintmat *)u->Data();
291  number bb = (number)(v->Data());
292  if (errorreported) return TRUE;
293  bigintmat *cc=NULL;
294  switch (iiOp)
295  {
296  case '*': cc=bimMult(aa,bb,coeffs_BIGINT); break;
297  }
298  res->data=(char *)cc;
299  return cc==NULL;
300 }
302 {
303  return jjOP_BIM_BI(res, v, u);
304 }
306 {
307  intvec* aa= (intvec *)u->CopyD(INTVEC_CMD);
308  int bb = (int)(long)(v->Data());
309  if (errorreported) return TRUE;
310  switch (iiOp)
311  {
312  case '+': (*aa) += bb; break;
313  case '-': (*aa) -= bb; break;
314  case '*': (*aa) *= bb; break;
315  case '/':
316  case INTDIV_CMD: (*aa) /= bb; break;
317  case '%': (*aa) %= bb; break;
318  }
319  res->data=(char *)aa;
320  return FALSE;
321 }
323 {
324  return jjOP_IV_I(res,v,u);
325 }
327 {
328  intvec* aa= (intvec *)u->CopyD(INTVEC_CMD);
329  int bb = (int)(long)(v->Data());
330  int i=si_min(aa->rows(),aa->cols());
331  switch (iiOp)
332  {
333  case '+': for (;i>0;i--) IMATELEM(*aa,i,i) += bb;
334  break;
335  case '-': for (;i>0;i--) IMATELEM(*aa,i,i) -= bb;
336  break;
337  }
338  res->data=(char *)aa;
339  return FALSE;
340 }
342 {
343  return jjOP_IM_I(res,v,u);
344 }
346 {
347  int l=(int)(long)v->Data();
348  if (l>=0)
349  {
350  int d=(int)(long)u->Data();
351  intvec *vv=new intvec(l);
352  int i;
353  for(i=l-1;i>=0;i--) { (*vv)[i]=d; }
354  res->data=(char *)vv;
355  }
356  return (l<0);
357 }
359 {
360  res->data=(char *)new intvec((int)(long)u->Data(),(int)(long)v->Data());
361  return FALSE;
362 }
363 static void jjEQUAL_REST(leftv res,leftv u,leftv v);
365 {
366  intvec* a = (intvec * )(u->Data());
367  intvec* b = (intvec * )(v->Data());
368  int r=a->compare(b);
369  switch (iiOp)
370  {
371  case '<':
372  res->data = (char *) (r<0);
373  break;
374  case '>':
375  res->data = (char *) (r>0);
376  break;
377  case LE:
378  res->data = (char *) (r<=0);
379  break;
380  case GE:
381  res->data = (char *) (r>=0);
382  break;
383  case EQUAL_EQUAL:
384  case NOTEQUAL: /* negation handled by jjEQUAL_REST */
385  res->data = (char *) (r==0);
386  break;
387  }
388  jjEQUAL_REST(res,u,v);
389  if(r==-2) { WerrorS("size incompatible"); return TRUE; }
390  return FALSE;
391 }
393 {
394  bigintmat* a = (bigintmat * )(u->Data());
395  bigintmat* b = (bigintmat * )(v->Data());
396  int r=a->compare(b);
397  switch (iiOp)
398  {
399  case '<':
400  res->data = (char *) (r<0);
401  break;
402  case '>':
403  res->data = (char *) (r>0);
404  break;
405  case LE:
406  res->data = (char *) (r<=0);
407  break;
408  case GE:
409  res->data = (char *) (r>=0);
410  break;
411  case EQUAL_EQUAL:
412  case NOTEQUAL: /* negation handled by jjEQUAL_REST */
413  res->data = (char *) (r==0);
414  break;
415  }
416  jjEQUAL_REST(res,u,v);
417  if(r==-2) { WerrorS("size incompatible"); return TRUE; }
418  return FALSE;
419 }
421 {
422  intvec* a = (intvec * )(u->Data());
423  int b = (int)(long)(v->Data());
424  int r=a->compare(b);
425  switch (iiOp)
426  {
427  case '<':
428  res->data = (char *) (r<0);
429  break;
430  case '>':
431  res->data = (char *) (r>0);
432  break;
433  case LE:
434  res->data = (char *) (r<=0);
435  break;
436  case GE:
437  res->data = (char *) (r>=0);
438  break;
439  case EQUAL_EQUAL:
440  case NOTEQUAL: /* negation handled by jjEQUAL_REST */
441  res->data = (char *) (r==0);
442  break;
443  }
444  jjEQUAL_REST(res,u,v);
445  return FALSE;
446 }
448 {
449  poly p=(poly)u->Data();
450  poly q=(poly)v->Data();
451  int r=pCmp(p,q);
452  if (r==0)
453  {
454  number h=nSub(pGetCoeff(p),pGetCoeff(q));
455  /* compare lead coeffs */
456  r = -1+nIsZero(h)+2*nGreaterZero(h); /* -1: <, 0:==, 1: > */
457  nDelete(&h);
458  }
459  else if (p==NULL)
460  {
461  if (q==NULL)
462  {
463  /* compare 0, 0 */
464  r=0;
465  }
466  else if(pIsConstant(q))
467  {
468  /* compare 0, const */
469  r = 1-2*nGreaterZero(pGetCoeff(q)); /* -1: <, 1: > */
470  }
471  }
472  else if (q==NULL)
473  {
474  if (pIsConstant(p))
475  {
476  /* compare const, 0 */
477  r = -1+2*nGreaterZero(pGetCoeff(p)); /* -1: <, 1: > */
478  }
479  }
480  switch (iiOp)
481  {
482  case '<':
483  res->data = (char *) (r < 0);
484  break;
485  case '>':
486  res->data = (char *) (r > 0);
487  break;
488  case LE:
489  res->data = (char *) (r <= 0);
490  break;
491  case GE:
492  res->data = (char *) (r >= 0);
493  break;
494  //case EQUAL_EQUAL:
495  //case NOTEQUAL: /* negation handled by jjEQUAL_REST */
496  // res->data = (char *) (r == 0);
497  // break;
498  }
499  jjEQUAL_REST(res,u,v);
500  return FALSE;
501 }
503 {
504  char* a = (char * )(u->Data());
505  char* b = (char * )(v->Data());
506  int result = strcmp(a,b);
507  switch (iiOp)
508  {
509  case '<':
510  res->data = (char *) (result < 0);
511  break;
512  case '>':
513  res->data = (char *) (result > 0);
514  break;
515  case LE:
516  res->data = (char *) (result <= 0);
517  break;
518  case GE:
519  res->data = (char *) (result >= 0);
520  break;
521  case EQUAL_EQUAL:
522  case NOTEQUAL: /* negation handled by jjEQUAL_REST */
523  res->data = (char *) (result == 0);
524  break;
525  }
526  jjEQUAL_REST(res,u,v);
527  return FALSE;
528 }
529 static BOOLEAN jjOP_REST(leftv res, leftv u, leftv v)
530 {
531  if (u->Next()!=NULL)
532  {
533  u=u->next;
534  res->next = (leftv)omAllocBin(sleftv_bin);
535  return iiExprArith2(res->next,u,iiOp,v);
536  }
537  else if (v->Next()!=NULL)
538  {
539  v=v->next;
540  res->next = (leftv)omAllocBin(sleftv_bin);
541  return iiExprArith2(res->next,u,iiOp,v);
542  }
543  return FALSE;
544 }
545 static BOOLEAN jjPOWER_I(leftv res, leftv u, leftv v)
546 {
547  int b=(int)(long)u->Data();
548  int e=(int)(long)v->Data();
549  int rc = 1;
550  BOOLEAN overflow=FALSE;
551  if (e >= 0)
552  {
553  if (b==0)
554  {
555  rc=(e==0);
556  }
557  else if ((e==0)||(b==1))
558  {
559  rc= 1;
560  }
561  else if (b== -1)
562  {
563  if (e&1) rc= -1;
564  else rc= 1;
565  }
566  else
567  {
568  int oldrc;
569  while ((e--)!=0)
570  {
571  oldrc=rc;
572  rc *= b;
573  if (!overflow)
574  {
575  if(rc/b!=oldrc) overflow=TRUE;
576  }
577  }
578  if (overflow)
579  WarnS("int overflow(^), result may be wrong");
580  }
581  res->data = (char *)((long)rc);
582  if (u!=NULL) return jjOP_REST(res,u,v);
583  return FALSE;
584  }
585  else
586  {
587  WerrorS("exponent must be non-negative");
588  return TRUE;
589  }
590 }
591 static BOOLEAN jjPOWER_BI(leftv res, leftv u, leftv v)
592 {
593  int e=(int)(long)v->Data();
594  number n=(number)u->Data();
595  if (e>=0)
596  {
597  n_Power(n,e,(number*)&res->data,coeffs_BIGINT);
598  }
599  else
600  {
601  WerrorS("exponent must be non-negative");
602  return TRUE;
603  }
604  if (u!=NULL) return jjOP_REST(res,u,v);
605  return FALSE;
606 }
607 static BOOLEAN jjPOWER_N(leftv res, leftv u, leftv v)
608 {
609  int e=(int)(long)v->Data();
610  number n=(number)u->Data();
611  int d=0;
612  if (e<0)
613  {
614  n=nInvers(n);
615  e=-e;
616  d=1;
617  }
618  number r;
619  nPower(n,e,(number*)&r);
620  res->data=(char*)r;
621  if (d) nDelete(&n);
622  if (u!=NULL) return jjOP_REST(res,u,v);
623  return FALSE;
624 }
625 static BOOLEAN jjPOWER_P(leftv res, leftv u, leftv v)
626 {
627  int v_i=(int)(long)v->Data();
628  if (v_i<0)
629  {
630  WerrorS("exponent must be non-negative");
631  return TRUE;
632  }
633  poly u_p=(poly)u->CopyD(POLY_CMD);
634  if ((u_p!=NULL)
635  && ((v_i!=0) &&
636  ((long)pTotaldegree(u_p) > (signed long)currRing->bitmask / (signed long)v_i/2)))
637  {
638  Werror("OVERFLOW in power(d=%ld, e=%d, max=%ld)",
639  pTotaldegree(u_p),v_i,currRing->bitmask/2);
640  pDelete(&u_p);
641  return TRUE;
642  }
643  res->data = (char *)pPower(u_p,v_i);
644  if (u!=NULL) return jjOP_REST(res,u,v);
645  return errorreported; /* pPower may set errorreported via Werror */
646 }
647 static BOOLEAN jjPOWER_ID(leftv res, leftv u, leftv v)
648 {
649  res->data = (char *)id_Power((ideal)(u->Data()),(int)(long)(v->Data()), currRing);
650  if (u!=NULL) return jjOP_REST(res,u,v);
651  return FALSE;
652 }
654 {
655  u=u->next;
656  v=v->next;
657  if (u==NULL)
658  {
659  if (v==NULL) return FALSE; /* u==NULL, v==NULL */
660  if (iiOp=='-') /* u==NULL, v<>NULL, iiOp=='-'*/
661  {
662  do
663  {
664  if (res->next==NULL)
665  res->next = (leftv)omAlloc0Bin(sleftv_bin);
666  leftv tmp_v=v->next;
667  v->next=NULL;
668  BOOLEAN b=iiExprArith1(res->next,v,'-');
669  v->next=tmp_v;
670  if (b)
671  return TRUE;
672  v=tmp_v;
673  res=res->next;
674  } while (v!=NULL);
675  return FALSE;
676  }
677  loop /* u==NULL, v<>NULL, iiOp=='+' */
678  {
679  res->next = (leftv)omAlloc0Bin(sleftv_bin);
680  res=res->next;
681  res->data = v->CopyD();
682  res->rtyp = v->Typ();
683  v=v->next;
684  if (v==NULL) return FALSE;
685  }
686  }
687  if (v!=NULL) /* u<>NULL, v<>NULL */
688  {
689  do
690  {
691  res->next = (leftv)omAlloc0Bin(sleftv_bin);
692  leftv tmp_u=u->next; u->next=NULL;
693  leftv tmp_v=v->next; v->next=NULL;
694  BOOLEAN b=iiExprArith2(res->next,u,iiOp,v);
695  u->next=tmp_u;
696  v->next=tmp_v;
697  if (b)
698  return TRUE;
699  u=tmp_u;
700  v=tmp_v;
701  res=res->next;
702  } while ((u!=NULL) && (v!=NULL));
703  return FALSE;
704  }
705  loop /* u<>NULL, v==NULL */
706  {
707  res->next = (leftv)omAlloc0Bin(sleftv_bin);
708  res=res->next;
709  res->data = u->CopyD();
710  res->rtyp = u->Typ();
711  u=u->next;
712  if (u==NULL) return FALSE;
713  }
714 }
715 static BOOLEAN jjCOLCOL(leftv res, leftv u, leftv v)
716 {
717  idhdl packhdl;
718  switch(u->Typ())
719  {
720  case 0:
721  {
722  int name_err=0;
723  if(isupper(u->name[0]))
724  {
725  const char *c=u->name+1;
726  while((*c!='\0')&&(islower(*c)||(isdigit(*c)))) c++;
727  if (*c!='\0')
728  name_err=1;
729  else
730  {
731  Print("%s of type 'ANY'. Trying load.\n", u->name);
732  if(iiTryLoadLib(u, u->name))
733  {
734  Werror("'%s' no such package", u->name);
735  return TRUE;
736  }
737  syMake(u,u->name,NULL);
738  }
739  }
740  else name_err=1;
741  if(name_err)
742  { Werror("'%s' is an invalid package name",u->name);return TRUE;}
743  // and now, after the loading: use next case !!! no break !!!
744  }
745  case PACKAGE_CMD:
746  packhdl = (idhdl)u->data;
747  if((!IDPACKAGE(packhdl)->loaded)
748  && (IDPACKAGE(packhdl)->language > LANG_TOP))
749  {
750  Werror("'%s' not loaded", u->name);
751  return TRUE;
752  }
753  if(v->rtyp == IDHDL)
754  {
755  v->name = omStrDup(v->name);
756  }
757  else if (v->rtyp!=0)
758  {
759  WerrorS("reserved name with ::");
760  return TRUE;
761  }
762  v->req_packhdl=IDPACKAGE(packhdl);
763  syMake(v, v->name, packhdl);
764  memcpy(res, v, sizeof(sleftv));
765  memset(v, 0, sizeof(sleftv));
766  break;
767  case DEF_CMD:
768  break;
769  default:
770  WerrorS("<package>::<id> expected");
771  return TRUE;
772  }
773  return FALSE;
774 }
775 static BOOLEAN jjPLUS_I(leftv res, leftv u, leftv v)
776 {
777  unsigned int a=(unsigned int)(unsigned long)u->Data();
778  unsigned int b=(unsigned int)(unsigned long)v->Data();
779  unsigned int c=a+b;
780  res->data = (char *)((long)c);
781  if (((Sy_bit(31)&a)==(Sy_bit(31)&b))&&((Sy_bit(31)&a)!=(Sy_bit(31)&c)))
782  {
783  WarnS("int overflow(+), result may be wrong");
784  }
785  return jjPLUSMINUS_Gen(res,u,v);
786 }
787 static BOOLEAN jjPLUS_BI(leftv res, leftv u, leftv v)
788 {
789  res->data = (char *)(n_Add((number)u->Data(), (number)v->Data(),coeffs_BIGINT));
790  return jjPLUSMINUS_Gen(res,u,v);
791 }
792 static BOOLEAN jjPLUS_N(leftv res, leftv u, leftv v)
793 {
794  res->data = (char *)(nAdd((number)u->Data(), (number)v->Data()));
795  return jjPLUSMINUS_Gen(res,u,v);
796 }
797 static BOOLEAN jjPLUS_P(leftv res, leftv u, leftv v)
798 {
799  res->data = (char *)(pAdd((poly)u->CopyD(POLY_CMD) , (poly)v->CopyD(POLY_CMD)));
800  return jjPLUSMINUS_Gen(res,u,v);
801 }
802 static BOOLEAN jjPLUS_IV(leftv res, leftv u, leftv v)
803 {
804  res->data = (char *)ivAdd((intvec*)(u->Data()), (intvec*)(v->Data()));
805  if (res->data==NULL)
806  {
807  WerrorS("intmat size not compatible");
808  return TRUE;
809  }
810  return jjPLUSMINUS_Gen(res,u,v);
811 }
812 static BOOLEAN jjPLUS_BIM(leftv res, leftv u, leftv v)
813 {
814  res->data = (char *)bimAdd((bigintmat*)(u->Data()), (bigintmat*)(v->Data()));
815  if (res->data==NULL)
816  {
817  WerrorS("bigintmat/cmatrix not compatible");
818  return TRUE;
819  }
820  return jjPLUSMINUS_Gen(res,u,v);
821 }
822 static BOOLEAN jjPLUS_MA(leftv res, leftv u, leftv v)
823 {
824  matrix A=(matrix)u->Data(); matrix B=(matrix)v->Data();
825  res->data = (char *)(mp_Add(A , B, currRing));
826  if (res->data==NULL)
827  {
828  Werror("matrix size not compatible(%dx%d, %dx%d)",
829  MATROWS(A),MATCOLS(A),MATROWS(B),MATCOLS(B));
830  return TRUE;
831  }
832  return jjPLUSMINUS_Gen(res,u,v);
833 }
835 {
836  matrix m=(matrix)u->Data();
838  if (iiOp=='+')
839  res->data = (char *)mp_Add(m , p,currRing);
840  else
841  res->data = (char *)mp_Sub(m , p,currRing);
842  idDelete((ideal *)&p);
843  return jjPLUSMINUS_Gen(res,u,v);
844 }
846 {
847  return jjPLUS_MA_P(res,v,u);
848 }
849 static BOOLEAN jjPLUS_S(leftv res, leftv u, leftv v)
850 {
851  char* a = (char * )(u->Data());
852  char* b = (char * )(v->Data());
853  char* r = (char * )omAlloc(strlen(a) + strlen(b) + 1);
854  strcpy(r,a);
855  strcat(r,b);
856  res->data=r;
857  return jjPLUSMINUS_Gen(res,u,v);
858 }
859 static BOOLEAN jjPLUS_ID(leftv res, leftv u, leftv v)
860 {
861  res->data = (char *)idAdd((ideal)u->Data(),(ideal)v->Data());
862  return jjPLUSMINUS_Gen(res,u,v);
863 }
864 static BOOLEAN jjMINUS_I(leftv res, leftv u, leftv v)
865 {
866  void *ap=u->Data(); void *bp=v->Data();
867  int aa=(int)(long)ap;
868  int bb=(int)(long)bp;
869  int cc=aa-bb;
870  unsigned int a=(unsigned int)(unsigned long)ap;
871  unsigned int b=(unsigned int)(unsigned long)bp;
872  unsigned int c=a-b;
873  if (((Sy_bit(31)&a)!=(Sy_bit(31)&b))&&((Sy_bit(31)&a)!=(Sy_bit(31)&c)))
874  {
875  WarnS("int overflow(-), result may be wrong");
876  }
877  res->data = (char *)((long)cc);
878  return jjPLUSMINUS_Gen(res,u,v);
879 }
880 static BOOLEAN jjMINUS_BI(leftv res, leftv u, leftv v)
881 {
882  res->data = (char *)(n_Sub((number)u->Data(), (number)v->Data(),coeffs_BIGINT));
883  return jjPLUSMINUS_Gen(res,u,v);
884 }
885 static BOOLEAN jjMINUS_N(leftv res, leftv u, leftv v)
886 {
887  res->data = (char *)(nSub((number)u->Data(), (number)v->Data()));
888  return jjPLUSMINUS_Gen(res,u,v);
889 }
890 static BOOLEAN jjMINUS_P(leftv res, leftv u, leftv v)
891 {
892  res->data = (char *)(pSub((poly)u->CopyD(POLY_CMD) , (poly)v->CopyD(POLY_CMD)));
893  return jjPLUSMINUS_Gen(res,u,v);
894 }
895 static BOOLEAN jjMINUS_IV(leftv res, leftv u, leftv v)
896 {
897  res->data = (char *)ivSub((intvec*)(u->Data()), (intvec*)(v->Data()));
898  if (res->data==NULL)
899  {
900  WerrorS("intmat size not compatible");
901  return TRUE;
902  }
903  return jjPLUSMINUS_Gen(res,u,v);
904 }
906 {
907  res->data = (char *)bimSub((bigintmat*)(u->Data()), (bigintmat*)(v->Data()));
908  if (res->data==NULL)
909  {
910  WerrorS("bigintmat/cmatrix not compatible");
911  return TRUE;
912  }
913  return jjPLUSMINUS_Gen(res,u,v);
914 }
915 static BOOLEAN jjMINUS_MA(leftv res, leftv u, leftv v)
916 {
917  matrix A=(matrix)u->Data(); matrix B=(matrix)v->Data();
918  res->data = (char *)(mp_Sub(A , B, currRing));
919  if (res->data==NULL)
920  {
921  Werror("matrix size not compatible(%dx%d, %dx%d)",
922  MATROWS(A),MATCOLS(A),MATROWS(B),MATCOLS(B));
923  return TRUE;
924  }
925  return jjPLUSMINUS_Gen(res,u,v);
926  return FALSE;
927 }
928 static BOOLEAN jjTIMES_I(leftv res, leftv u, leftv v)
929 {
930  int a=(int)(long)u->Data();
931  int b=(int)(long)v->Data();
932  int64 c=(int64)a * (int64)b;
933  if ((c>INT_MAX)||(c<INT_MIN))
934  WarnS("int overflow(*), result may be wrong");
935  res->data = (char *)((long)((int)c));
936  if ((u->Next()!=NULL) || (v->Next()!=NULL))
937  return jjOP_REST(res,u,v);
938  return FALSE;
939 }
940 static BOOLEAN jjTIMES_BI(leftv res, leftv u, leftv v)
941 {
942  res->data = (char *)(n_Mult( (number)u->Data(), (number)v->Data(),coeffs_BIGINT));
943  if ((v->next!=NULL) || (u->next!=NULL))
944  return jjOP_REST(res,u,v);
945  return FALSE;
946 }
947 static BOOLEAN jjTIMES_N(leftv res, leftv u, leftv v)
948 {
949  res->data = (char *)(nMult( (number)u->Data(), (number)v->Data()));
950  number n=(number)res->data;
951  nNormalize(n);
952  res->data=(char *)n;
953  if ((v->next!=NULL) || (u->next!=NULL))
954  return jjOP_REST(res,u,v);
955  return FALSE;
956 }
957 static BOOLEAN jjTIMES_P(leftv res, leftv u, leftv v)
958 {
959  poly a;
960  poly b;
961  if (v->next==NULL)
962  {
963  a=(poly)u->CopyD(POLY_CMD); // works also for VECTOR_CMD
964  if (u->next==NULL)
965  {
966  b=(poly)v->CopyD(POLY_CMD); // works also for VECTOR_CMD
967  if ((a!=NULL) && (b!=NULL)
968  && ((long)pTotaldegree(a)>si_max((long)rVar(currRing),(long)currRing->bitmask/2)-(long)pTotaldegree(b)))
969  {
970  Warn("possible OVERFLOW in mult(d=%ld, d=%ld, max=%ld)",
971  pTotaldegree(a),pTotaldegree(b),currRing->bitmask/2);
972  }
973  res->data = (char *)(pMult( a, b));
974  pNormalize((poly)res->data);
975  return FALSE;
976  }
977  // u->next exists: copy v
978  b=pCopy((poly)v->Data());
979  if ((a!=NULL) && (b!=NULL)
980  && (pTotaldegree(a)+pTotaldegree(b)>si_max((long)rVar(currRing),(long)currRing->bitmask/2)))
981  {
982  Warn("possible OVERFLOW in mult(d=%ld, d=%ld, max=%ld)",
983  pTotaldegree(a),pTotaldegree(b),currRing->bitmask/2);
984  }
985  res->data = (char *)(pMult( a, b));
986  pNormalize((poly)res->data);
987  return jjOP_REST(res,u,v);
988  }
989  // v->next exists: copy u
990  a=pCopy((poly)u->Data());
991  b=(poly)v->CopyD(POLY_CMD); // works also for VECTOR_CMD
992  if ((a!=NULL) && (b!=NULL)
993  && ((unsigned long)(pTotaldegree(a)+pTotaldegree(b))>=currRing->bitmask/2))
994  {
995  pDelete(&a);
996  pDelete(&b);
997  WerrorS("OVERFLOW");
998  return TRUE;
999  }
1000  res->data = (char *)(pMult( a, b));
1001  pNormalize((poly)res->data);
1002  return jjOP_REST(res,u,v);
1003 }
1005 {
1006  res->data = (char *)idMult((ideal)u->Data(),(ideal)v->Data());
1007  id_Normalize((ideal)res->data,currRing);
1008  if ((v->next!=NULL) || (u->next!=NULL))
1009  return jjOP_REST(res,u,v);
1010  return FALSE;
1011 }
1013 {
1014  res->data = (char *)ivMult((intvec*)(u->Data()), (intvec*)(v->Data()));
1015  if (res->data==NULL)
1016  {
1017  WerrorS("intmat size not compatible");
1018  return TRUE;
1019  }
1020  if ((v->next!=NULL) || (u->next!=NULL))
1021  return jjOP_REST(res,u,v);
1022  return FALSE;
1023 }
1025 {
1026  res->data = (char *)bimMult((bigintmat*)(u->Data()), (bigintmat*)(v->Data()));
1027  if (res->data==NULL)
1028  {
1029  WerrorS("bigintmat/cmatrix not compatible");
1030  return TRUE;
1031  }
1032  if ((v->next!=NULL) || (u->next!=NULL))
1033  return jjOP_REST(res,u,v);
1034  return FALSE;
1035 }
1037 {
1039  if (nMap==NULL) return TRUE;
1040  number n=nMap((number)v->Data(),coeffs_BIGINT,currRing->cf);
1041  poly p=pNSet(n);
1042  ideal I= (ideal)mp_MultP((matrix)u->CopyD(MATRIX_CMD),p,currRing);
1043  res->data = (char *)I;
1044  return FALSE;
1045 }
1047 {
1048  return jjTIMES_MA_BI1(res,v,u);
1049 }
1051 {
1052  poly p=(poly)v->CopyD(POLY_CMD);
1053  int r=pMaxComp(p);/* recompute the rank for the case ideal*vector*/
1054  ideal I= (ideal)mp_MultP((matrix)u->CopyD(MATRIX_CMD),p,currRing);
1055  if (r>0) I->rank=r;
1057  res->data = (char *)I;
1058  return FALSE;
1059 }
1061 {
1062  poly p=(poly)u->CopyD(POLY_CMD);
1063  int r=pMaxComp(p);/* recompute the rank for the case ideal*vector*/
1064  ideal I= (ideal)pMultMp(p,(matrix)v->CopyD(MATRIX_CMD),currRing);
1065  if (r>0) I->rank=r;
1067  res->data = (char *)I;
1068  return FALSE;
1069 }
1071 {
1072  number n=(number)v->CopyD(NUMBER_CMD);
1073  poly p=pNSet(n);
1074  res->data = (char *)mp_MultP((matrix)u->CopyD(MATRIX_CMD),p,currRing);
1075  id_Normalize((ideal)res->data,currRing);
1076  return FALSE;
1077 }
1079 {
1080  return jjTIMES_MA_N1(res,v,u);
1081 }
1083 {
1084  res->data = (char *)mp_MultI((matrix)u->CopyD(MATRIX_CMD),(int)(long)v->Data(),currRing);
1085  id_Normalize((ideal)res->data,currRing);
1086  return FALSE;
1087 }
1089 {
1090  return jjTIMES_MA_I1(res,v,u);
1091 }
1093 {
1094  matrix A=(matrix)u->Data(); matrix B=(matrix)v->Data();
1095  res->data = (char *)mp_Mult(A,B,currRing);
1096  if (res->data==NULL)
1097  {
1098  Werror("matrix size not compatible(%dx%d, %dx%d) in *",
1099  MATROWS(A),MATCOLS(A),MATROWS(B),MATCOLS(B));
1100  return TRUE;
1101  }
1102  id_Normalize((ideal)res->data,currRing);
1103  if ((v->next!=NULL) || (u->next!=NULL))
1104  return jjOP_REST(res,u,v);
1105  return FALSE;
1106 }
1107 static BOOLEAN jjGE_BI(leftv res, leftv u, leftv v)
1108 {
1109  number h=n_Sub((number)u->Data(),(number)v->Data(),coeffs_BIGINT);
1110  res->data = (char *) (n_GreaterZero(h,coeffs_BIGINT)||(n_IsZero(h,coeffs_BIGINT)));
1111  n_Delete(&h,coeffs_BIGINT);
1112  return FALSE;
1113 }
1114 static BOOLEAN jjGE_I(leftv res, leftv u, leftv v)
1115 {
1116  res->data = (char *)(long)((int)((long)u->Data()) >= (int)((long)v->Data()));
1117  return FALSE;
1118 }
1119 static BOOLEAN jjGE_N(leftv res, leftv u, leftv v)
1120 {
1121  res->data = (char *)(long) (nGreater((number)u->Data(),(number)v->Data())
1122  || nEqual((number)u->Data(),(number)v->Data()));
1123  return FALSE;
1124 }
1125 static BOOLEAN jjGT_BI(leftv res, leftv u, leftv v)
1126 {
1127  number h=n_Sub((number)u->Data(),(number)v->Data(),coeffs_BIGINT);
1128  res->data = (char *)(long) (n_GreaterZero(h,coeffs_BIGINT)&&(!n_IsZero(h,coeffs_BIGINT)));
1129  n_Delete(&h,coeffs_BIGINT);
1130  return FALSE;
1131 }
1132 static BOOLEAN jjGT_I(leftv res, leftv u, leftv v)
1133 {
1134  res->data = (char *)(long)((int)((long)u->Data()) > (int)((long)v->Data()));
1135  return FALSE;
1136 }
1137 static BOOLEAN jjGT_N(leftv res, leftv u, leftv v)
1138 {
1139  res->data = (char *)(long)(nGreater((number)u->Data(),(number)v->Data()));
1140  return FALSE;
1141 }
1142 static BOOLEAN jjLE_BI(leftv res, leftv u, leftv v)
1143 {
1144  return jjGE_BI(res,v,u);
1145 }
1146 static BOOLEAN jjLE_I(leftv res, leftv u, leftv v)
1147 {
1148  res->data = (char *)(long)((int)((long)u->Data()) <= (int)((long)v->Data()));
1149  return FALSE;
1150 }
1151 static BOOLEAN jjLE_N(leftv res, leftv u, leftv v)
1152 {
1153  return jjGE_N(res,v,u);
1154 }
1155 static BOOLEAN jjLT_BI(leftv res, leftv u, leftv v)
1156 {
1157  return jjGT_BI(res,v,u);
1158 }
1159 static BOOLEAN jjLT_I(leftv res, leftv u, leftv v)
1160 {
1161  res->data = (char *)(long)((int)((long)u->Data()) < (int)((long)v->Data()));
1162  return FALSE;
1163 }
1164 static BOOLEAN jjLT_N(leftv res, leftv u, leftv v)
1165 {
1166  return jjGT_N(res,v,u);
1167 }
1169 {
1170  if (iiOp=='/') Warn("int division with `/`: use `div` instead in line >>%s<<",my_yylinebuf);
1171  int a= (int)(long)u->Data();
1172  int b= (int)(long)v->Data();
1173  if (b==0)
1174  {
1176  return TRUE;
1177  }
1178  int c=a%b;
1179  int r=0;
1180  switch (iiOp)
1181  {
1182  case '%':
1183  r=c; break;
1184  case '/':
1185  case INTDIV_CMD:
1186  r=((a-c) /b); break;
1187  }
1188  res->data=(void *)((long)r);
1189  return FALSE;
1190 }
1191 static BOOLEAN jjDIV_BI(leftv res, leftv u, leftv v)
1192 {
1193  number q=(number)v->Data();
1194  if (n_IsZero(q,coeffs_BIGINT))
1195  {
1197  return TRUE;
1198  }
1199  q = n_Div((number)u->Data(),q,coeffs_BIGINT);
1201  res->data = (char *)q;
1202  return FALSE;
1203 }
1204 static BOOLEAN jjDIV_N(leftv res, leftv u, leftv v)
1205 {
1206  number q=(number)v->Data();
1207  if (nIsZero(q))
1208  {
1210  return TRUE;
1211  }
1212  q = nDiv((number)u->Data(),q);
1213  nNormalize(q);
1214  res->data = (char *)q;
1215  return FALSE;
1216 }
1217 static BOOLEAN jjDIV_P(leftv res, leftv u, leftv v)
1218 {
1219  poly q=(poly)v->Data();
1220  if (q==NULL)
1221  {
1223  return TRUE;
1224  }
1225  poly p=(poly)(u->Data());
1226  if (p==NULL)
1227  {
1228  res->data=NULL;
1229  return FALSE;
1230  }
1231  if ((pNext(q)!=NULL) && (!rField_is_Ring(currRing)))
1232  { /* This means that q != 0 consists of at least two terms.
1233  Moreover, currRing is over a field. */
1234  if(pGetComp(p)==0)
1235  {
1236  res->data=(void*)(singclap_pdivide(p /*(poly)(u->Data())*/ ,
1237  q /*(poly)(v->Data())*/ ,currRing));
1238  }
1239  else
1240  {
1241  int comps=pMaxComp(p);
1242  ideal I=idInit(comps,1);
1243  p=pCopy(p);
1244  poly h;
1245  int i;
1246  // conversion to a list of polys:
1247  while (p!=NULL)
1248  {
1249  i=pGetComp(p)-1;
1250  h=pNext(p);
1251  pNext(p)=NULL;
1252  pSetComp(p,0);
1253  I->m[i]=pAdd(I->m[i],p);
1254  p=h;
1255  }
1256  // division and conversion to vector:
1257  h=NULL;
1258  p=NULL;
1259  for(i=comps-1;i>=0;i--)
1260  {
1261  if (I->m[i]!=NULL)
1262  {
1263  h=singclap_pdivide(I->m[i],q,currRing);
1264  pSetCompP(h,i+1);
1265  p=pAdd(p,h);
1266  }
1267  }
1268  idDelete(&I);
1269  res->data=(void *)p;
1270  }
1271  }
1272  else
1273  { /* This means that q != 0 consists of just one term,
1274  or that currRing is over a coefficient ring. */
1275 #ifdef HAVE_RINGS
1276  if (!rField_is_Domain(currRing))
1277  {
1278  WerrorS("division only defined over coefficient domains");
1279  return TRUE;
1280  }
1281  if (pNext(q)!=NULL)
1282  {
1283  WerrorS("division over a coefficient domain only implemented for terms");
1284  return TRUE;
1285  }
1286 #endif
1287  res->data = (char *)pDivideM(pCopy(p),pHead(q));
1288  }
1289  pNormalize((poly)res->data);
1290  return FALSE;
1291 }
1292 static BOOLEAN jjDIV_Ma(leftv res, leftv u, leftv v)
1293 {
1294  poly q=(poly)v->Data();
1295  if (q==NULL)
1296  {
1298  return TRUE;
1299  }
1300  matrix m=(matrix)(u->Data());
1301  int r=m->rows();
1302  int c=m->cols();
1303  matrix mm=mpNew(r,c);
1304  int i,j;
1305  for(i=r;i>0;i--)
1306  {
1307  for(j=c;j>0;j--)
1308  {
1309  if (pNext(q)!=NULL)
1310  {
1311  MATELEM(mm,i,j) = singclap_pdivide( MATELEM(m,i,j) ,
1312  q /*(poly)(v->Data())*/, currRing );
1313  }
1314  else
1315  MATELEM(mm,i,j) = pDivideM(pCopy(MATELEM(m,i,j)),pHead(q));
1316  }
1317  }
1318  id_Normalize((ideal)mm,currRing);
1319  res->data=(char *)mm;
1320  return FALSE;
1321 }
1323 {
1324  res->data = (char *)((long)n_Equal((number)u->Data(),(number)v->Data(),coeffs_BIGINT));
1325  jjEQUAL_REST(res,u,v);
1326  return FALSE;
1327 }
1328 static BOOLEAN jjEQUAL_I(leftv res, leftv u, leftv v)
1329 {
1330  res->data = (char *)((int)((long)u->Data()) == (int)((long)v->Data()));
1331  jjEQUAL_REST(res,u,v);
1332  return FALSE;
1333 }
1335 {
1336  res->data = (char *)((long)mp_Equal((matrix)u->Data(),(matrix)v->Data(),currRing));
1337  jjEQUAL_REST(res,u,v);
1338  return FALSE;
1339 }
1340 static BOOLEAN jjEQUAL_N(leftv res, leftv u, leftv v)
1341 {
1342  res->data = (char *)((long)nEqual((number)u->Data(),(number)v->Data()));
1343  jjEQUAL_REST(res,u,v);
1344  return FALSE;
1345 }
1346 static BOOLEAN jjEQUAL_P(leftv res, leftv u, leftv v)
1347 {
1348  poly p=(poly)u->Data();
1349  poly q=(poly)v->Data();
1350  res->data = (char *) ((long)pEqualPolys(p,q));
1351  jjEQUAL_REST(res,u,v);
1352  return FALSE;
1353 }
1354 static void jjEQUAL_REST(leftv res,leftv u,leftv v)
1355 {
1356  if ((res->data) && (u->next!=NULL) && (v->next!=NULL))
1357  {
1358  int save_iiOp=iiOp;
1359  if (iiOp==NOTEQUAL)
1360  iiExprArith2(res,u->next,EQUAL_EQUAL,v->next);
1361  else
1362  iiExprArith2(res,u->next,iiOp,v->next);
1363  iiOp=save_iiOp;
1364  }
1365  if (iiOp==NOTEQUAL) res->data=(char *)(!(long)res->data);
1366 }
1367 static BOOLEAN jjAND_I(leftv res, leftv u, leftv v)
1368 {
1369  res->data = (char *)((long)u->Data() && (long)v->Data());
1370  return FALSE;
1371 }
1372 static BOOLEAN jjOR_I(leftv res, leftv u, leftv v)
1373 {
1374  res->data = (char *)((long)u->Data() || (long)v->Data());
1375  return FALSE;
1376 }
1377 static BOOLEAN jjINDEX_I(leftv res, leftv u, leftv v)
1378 {
1379  res->rtyp=u->rtyp; u->rtyp=0;
1380  res->data=u->data; u->data=NULL;
1381  res->name=u->name; u->name=NULL;
1382  res->e=u->e; u->e=NULL;
1383  if (res->e==NULL) res->e=jjMakeSub(v);
1384  else
1385  {
1386  Subexpr sh=res->e;
1387  while (sh->next != NULL) sh=sh->next;
1388  sh->next=jjMakeSub(v);
1389  }
1390  if (u->next!=NULL)
1391  {
1393  BOOLEAN bo=iiExprArith2(rn,u->next,iiOp,v);
1394  res->next=rn;
1395  return bo;
1396  }
1397  return FALSE;
1398 }
1400 {
1401  if ((u->rtyp!=IDHDL)||(u->e!=NULL))
1402  {
1403  WerrorS("indexed object must have a name");
1404  return TRUE;
1405  }
1406  intvec * iv=(intvec *)v->Data();
1407  leftv p=NULL;
1408  int i;
1409  sleftv t;
1410  memset(&t,0,sizeof(t));
1411  t.rtyp=INT_CMD;
1412  for (i=0;i<iv->length(); i++)
1413  {
1414  t.data=(char *)((long)(*iv)[i]);
1415  if (p==NULL)
1416  {
1417  p=res;
1418  }
1419  else
1420  {
1422  p=p->next;
1423  }
1424  p->rtyp=IDHDL;
1425  p->data=u->data;
1426  p->name=u->name;
1427  p->flag=u->flag;
1428  p->e=jjMakeSub(&t);
1429  }
1430  u->rtyp=0;
1431  u->data=NULL;
1432  u->name=NULL;
1433  return FALSE;
1434 }
1435 static BOOLEAN jjINDEX_P(leftv res, leftv u, leftv v)
1436 {
1437  poly p=(poly)u->Data();
1438  int i=(int)(long)v->Data();
1439  int j=0;
1440  while (p!=NULL)
1441  {
1442  j++;
1443  if (j==i)
1444  {
1445  res->data=(char *)pHead(p);
1446  return FALSE;
1447  }
1448  pIter(p);
1449  }
1450  return FALSE;
1451 }
1453 {
1454  poly p=(poly)u->Data();
1455  poly r=NULL;
1456  intvec *iv=(intvec *)v->CopyD(INTVEC_CMD);
1457  int i;
1458  int sum=0;
1459  for(i=iv->length()-1;i>=0;i--)
1460  sum+=(*iv)[i];
1461  int j=0;
1462  while ((p!=NULL) && (sum>0))
1463  {
1464  j++;
1465  for(i=iv->length()-1;i>=0;i--)
1466  {
1467  if (j==(*iv)[i])
1468  {
1469  r=pAdd(r,pHead(p));
1470  sum-=j;
1471  (*iv)[i]=0;
1472  break;
1473  }
1474  }
1475  pIter(p);
1476  }
1477  delete iv;
1478  res->data=(char *)r;
1479  return FALSE;
1480 }
1481 static BOOLEAN jjINDEX_V(leftv res, leftv u, leftv v)
1482 {
1483  poly p=(poly)u->CopyD(VECTOR_CMD);
1484  poly r=p; // pointer to the beginning of component i
1485  poly o=NULL;
1486  int i=(int)(long)v->Data();
1487  while (p!=NULL)
1488  {
1489  if (pGetComp(p)!=i)
1490  {
1491  if (r==p) r=pNext(p);
1492  if (o!=NULL)
1493  {
1494  if (pNext(o)!=NULL) pLmDelete(&pNext(o));
1495  p=pNext(o);
1496  }
1497  else
1498  pLmDelete(&p);
1499  }
1500  else
1501  {
1502  pSetComp(p, 0);
1503  p_SetmComp(p, currRing);
1504  o=p;
1505  p=pNext(o);
1506  }
1507  }
1508  res->data=(char *)r;
1509  return FALSE;
1510 }
1512 {
1513  poly p=(poly)u->CopyD(VECTOR_CMD);
1514  if (p!=NULL)
1515  {
1516  poly r=pOne();
1517  poly hp=r;
1518  intvec *iv=(intvec *)v->Data();
1519  int i;
1520  loop
1521  {
1522  for(i=0;i<iv->length();i++)
1523  {
1524  if (((int)pGetComp(p))==(*iv)[i])
1525  {
1526  poly h;
1527  pSplit(p,&h);
1528  pNext(hp)=p;
1529  p=h;
1530  pIter(hp);
1531  break;
1532  }
1533  }
1534  if (p==NULL) break;
1535  if (i==iv->length())
1536  {
1537  pLmDelete(&p);
1538  if (p==NULL) break;
1539  }
1540  }
1541  pLmDelete(&r);
1542  res->data=(char *)r;
1543  }
1544  return FALSE;
1545 }
1546 static BOOLEAN jjKLAMMER_rest(leftv res, leftv u, leftv v);
1547 static BOOLEAN jjKLAMMER(leftv res, leftv u, leftv v)
1548 {
1549  if(u->name==NULL) return TRUE;
1550  char * nn = (char *)omAlloc(strlen(u->name) + 14);
1551  sprintf(nn,"%s(%d)",u->name,(int)(long)v->Data());
1552  omFree((ADDRESS)u->name);
1553  u->name=NULL;
1554  char *n=omStrDup(nn);
1555  omFree((ADDRESS)nn);
1556  syMake(res,n);
1557  if (u->next!=NULL) return jjKLAMMER_rest(res,u->next,v);
1558  return FALSE;
1559 }
1561 {
1562  intvec * iv=(intvec *)v->Data();
1563  leftv p=NULL;
1564  int i;
1565  long slen = strlen(u->name) + 14;
1566  char *n = (char*) omAlloc(slen);
1567 
1568  for (i=0;i<iv->length(); i++)
1569  {
1570  if (p==NULL)
1571  {
1572  p=res;
1573  }
1574  else
1575  {
1577  p=p->next;
1578  }
1579  sprintf(n,"%s(%d)",u->name,(*iv)[i]);
1580  syMake(p,omStrDup(n));
1581  }
1582  omFree((ADDRESS)u->name);
1583  u->name = NULL;
1584  omFreeSize(n, slen);
1585  if (u->next!=NULL) return jjKLAMMER_rest(res,u->next,v);
1586  return FALSE;
1587 }
1589 {
1591  memset(tmp,0,sizeof(sleftv));
1592  BOOLEAN b;
1593  if (v->Typ()==INTVEC_CMD)
1594  b=jjKLAMMER_IV(tmp,u,v);
1595  else
1596  b=jjKLAMMER(tmp,u,v);
1597  if (b)
1598  {
1599  omFreeBin(tmp,sleftv_bin);
1600  return TRUE;
1601  }
1602  leftv h=res;
1603  while (h->next!=NULL) h=h->next;
1604  h->next=tmp;
1605  return FALSE;
1606 }
1608 {
1609  void *d;
1610  Subexpr e;
1611  int typ;
1612  BOOLEAN t=FALSE;
1613  idhdl tmp_proc=NULL;
1614  if ((u->rtyp!=IDHDL)||(u->e!=NULL))
1615  {
1616  tmp_proc=(idhdl)omAlloc0(sizeof(idrec));
1617  tmp_proc->id="_auto";
1618  tmp_proc->typ=PROC_CMD;
1619  tmp_proc->data.pinf=(procinfo *)u->Data();
1620  tmp_proc->ref=1;
1621  d=u->data; u->data=(void *)tmp_proc;
1622  e=u->e; u->e=NULL;
1623  t=TRUE;
1624  typ=u->rtyp; u->rtyp=IDHDL;
1625  }
1626  BOOLEAN sl;
1627  if (u->req_packhdl==currPack)
1628  sl = iiMake_proc((idhdl)u->data,NULL,v);
1629  else
1630  sl = iiMake_proc((idhdl)u->data,u->req_packhdl,v);
1631  if (t)
1632  {
1633  u->rtyp=typ;
1634  u->data=d;
1635  u->e=e;
1636  omFreeSize(tmp_proc,sizeof(idrec));
1637  }
1638  if (sl) return TRUE;
1639  memcpy(res,&iiRETURNEXPR,sizeof(sleftv));
1640  iiRETURNEXPR.Init();
1641  return FALSE;
1642 }
1643 static BOOLEAN jjMAP(leftv res, leftv u, leftv v)
1644 {
1645  //Print("try to map %s with %s\n",$3.Name(),$1.Name());
1646  leftv sl=NULL;
1647  if ((v->e==NULL)&&(v->name!=NULL))
1648  {
1649  map m=(map)u->Data();
1650  sl=iiMap(m,v->name);
1651  }
1652  else
1653  {
1654  Werror("%s(<name>) expected",u->Name());
1655  }
1656  if (sl==NULL) return TRUE;
1657  memcpy(res,sl,sizeof(sleftv));
1659  return FALSE;
1660 }
1662 {
1663  intvec *c=(intvec*)u->Data();
1664  intvec* p=(intvec*)v->Data();
1665  int rl=p->length();
1666  number *x=(number *)omAlloc(rl*sizeof(number));
1667  number *q=(number *)omAlloc(rl*sizeof(number));
1668  int i;
1669  for(i=rl-1;i>=0;i--)
1670  {
1671  q[i]=n_Init((*p)[i], coeffs_BIGINT);
1672  x[i]=n_Init((*c)[i], coeffs_BIGINT);
1673  }
1674  CFArray iv(rl);
1675  number n=n_ChineseRemainderSym(x,q,rl,FALSE,iv,coeffs_BIGINT);
1676  for(i=rl-1;i>=0;i--)
1677  {
1678  n_Delete(&(q[i]),coeffs_BIGINT);
1679  n_Delete(&(x[i]),coeffs_BIGINT);
1680  }
1681  omFree(x); omFree(q);
1682  res->data=(char *)n;
1683  return FALSE;
1684 }
1685 #if 0
1686 static BOOLEAN jjCHINREM_P(leftv res, leftv u, leftv v)
1687 {
1688  lists c=(lists)u->CopyD(); // list of poly
1689  intvec* p=(intvec*)v->Data();
1690  int rl=p->length();
1691  poly r=NULL,h, result=NULL;
1692  number *x=(number *)omAlloc(rl*sizeof(number));
1693  number *q=(number *)omAlloc(rl*sizeof(number));
1694  int i;
1695  for(i=rl-1;i>=0;i--)
1696  {
1697  q[i]=nlInit((*p)[i]);
1698  }
1699  loop
1700  {
1701  for(i=rl-1;i>=0;i--)
1702  {
1703  if (c->m[i].Typ()!=POLY_CMD)
1704  {
1705  Werror("poly expected at pos %d",i+1);
1706  for(i=rl-1;i>=0;i--)
1707  {
1708  nlDelete(&(q[i]),currRing);
1709  }
1710  omFree(x); omFree(q); // delete c
1711  return TRUE;
1712  }
1713  h=((poly)c->m[i].Data());
1714  if (r==NULL) r=h;
1715  else if (pLmCmp(r,h)==-1) r=h;
1716  }
1717  if (r==NULL) break;
1718  for(i=rl-1;i>=0;i--)
1719  {
1720  h=((poly)c->m[i].Data());
1721  if (pLmCmp(r,h)==0)
1722  {
1723  x[i]=pGetCoeff(h);
1724  h=pLmFreeAndNext(h);
1725  c->m[i].data=(char*)h;
1726  }
1727  else
1728  x[i]=nlInit(0);
1729  }
1730  number n=n_ChineseRemainder(x,q,rl,currRing->cf);
1731  for(i=rl-1;i>=0;i--)
1732  {
1733  nlDelete(&(x[i]),currRing);
1734  }
1735  h=pHead(r);
1736  pSetCoeff(h,n);
1737  result=pAdd(result,h);
1738  }
1739  for(i=rl-1;i>=0;i--)
1740  {
1741  nlDelete(&(q[i]),currRing);
1742  }
1743  omFree(x); omFree(q);
1744  res->data=(char *)result;
1745  return FALSE;
1746 }
1747 #endif
1748 static BOOLEAN jjALIGN_V(leftv res, leftv u, leftv v)
1749 {
1750  poly p=(poly)u->CopyD();
1751  int s=(int)(long)v->Data();
1752  if (s+p_MinComp(p,currRing)<=0)
1753  { p_Delete(&p,currRing);return TRUE;}
1754  p_Shift(&p,s,currRing);
1755  res->data=p;
1756  return FALSE;
1757 }
1758 static BOOLEAN jjALIGN_M(leftv res, leftv u, leftv v)
1759 {
1760  ideal M=(ideal)u->CopyD();
1761  int s=(int)(long)v->Data();
1762  for(int i=IDELEMS(M)-1; i>=0;i--)
1763  {
1764  if (s+p_MinComp(M->m[i],currRing)<=0)
1765  { id_Delete(&M,currRing);return TRUE;}
1766  }
1767  id_Shift(M,s,currRing);
1768  res->data=M;
1769  return FALSE;
1770 }
1772 {
1773  coeffs cf;
1774  lists c=(lists)u->CopyD(); // list of ideal or bigint/int
1775  lists pl=NULL;
1776  intvec *p=NULL;
1777  if (v->Typ()==LIST_CMD) pl=(lists)v->Data();
1778  else p=(intvec*)v->Data();
1779  int rl=c->nr+1;
1780  ideal result;
1781  ideal *x=(ideal *)omAlloc(rl*sizeof(ideal));
1782  number *xx=NULL;
1783  int i;
1784  int return_type=c->m[0].Typ();
1785  if ((return_type!=IDEAL_CMD)
1786  && (return_type!=MODUL_CMD)
1787  && (return_type!=MATRIX_CMD)
1788  && (return_type!=POLY_CMD))
1789  {
1790  if((return_type!=BIGINT_CMD)&&(return_type!=INT_CMD))
1791  {
1792  WerrorS("poly/ideal/module/matrix expected");
1793  omFree(x); // delete c
1794  return TRUE;
1795  }
1796  else
1797  return_type=BIGINT_CMD;
1798  }
1799  if (return_type==BIGINT_CMD)
1800  cf=coeffs_BIGINT;
1801  else
1802  {
1803  cf=currRing->cf;
1804  if (nCoeff_is_Extension(cf) && (cf->extRing!=NULL))
1805  cf=cf->extRing->cf;
1806  }
1807  nMapFunc nMap=n_SetMap(coeffs_BIGINT,cf);
1808  if (return_type!=BIGINT_CMD)
1809  {
1810  for(i=rl-1;i>=0;i--)
1811  {
1812  if (c->m[i].Typ()!=return_type)
1813  {
1814  Werror("%s expected at pos %d",Tok2Cmdname(return_type),i+1);
1815  omFree(x); // delete c
1816  return TRUE;
1817  }
1818  if (return_type==POLY_CMD)
1819  {
1820  x[i]=idInit(1,1);
1821  x[i]->m[0]=(poly)c->m[i].CopyD();
1822  }
1823  else
1824  {
1825  x[i]=(ideal)c->m[i].CopyD();
1826  }
1827  //c->m[i].Init();
1828  }
1829  }
1830  else
1831  {
1832  if (nMap==NULL)
1833  {
1834  Werror("not implemented: map bigint -> %s", nCoeffString(cf));
1835  return TRUE;
1836  }
1837  xx=(number *)omAlloc(rl*sizeof(number));
1838  for(i=rl-1;i>=0;i--)
1839  {
1840  if (c->m[i].Typ()==INT_CMD)
1841  {
1842  xx[i]=n_Init(((int)(long)c->m[i].Data()),cf);
1843  }
1844  else if (c->m[i].Typ()==BIGINT_CMD)
1845  {
1846  xx[i]=nMap((number)c->m[i].Data(),coeffs_BIGINT,cf);
1847  }
1848  else
1849  {
1850  Werror("bigint expected at pos %d",i+1);
1851  omFree(x); // delete c
1852  omFree(xx); // delete c
1853  return TRUE;
1854  }
1855  }
1856  }
1857  number *q=(number *)omAlloc(rl*sizeof(number));
1858  if (p!=NULL)
1859  {
1860  for(i=rl-1;i>=0;i--)
1861  {
1862  q[i]=n_Init((*p)[i], cf);
1863  }
1864  }
1865  else
1866  {
1867  for(i=rl-1;i>=0;i--)
1868  {
1869  if (pl->m[i].Typ()==INT_CMD)
1870  {
1871  q[i]=n_Init((int)(long)pl->m[i].Data(),cf);
1872  }
1873  else if (pl->m[i].Typ()==BIGINT_CMD)
1874  {
1875  q[i]=nMap((number)(pl->m[i].Data()),coeffs_BIGINT,cf);
1876  }
1877  else
1878  {
1879  Werror("bigint expected at pos %d",i+1);
1880  for(i++;i<rl;i++)
1881  {
1882  n_Delete(&(q[i]),cf);
1883  }
1884  omFree(x); // delete c
1885  omFree(q); // delete pl
1886  if (xx!=NULL) omFree(xx); // delete c
1887  return TRUE;
1888  }
1889  }
1890  }
1891  if (return_type==BIGINT_CMD)
1892  {
1893  CFArray i_v(rl);
1894  number n=n_ChineseRemainderSym(xx,q,rl,TRUE,i_v,coeffs_BIGINT);
1895  res->data=(char *)n;
1896  }
1897  else
1898  {
1899  result=id_ChineseRemainder(x,q,rl,currRing);
1900  // deletes also x
1901  c->Clean();
1902  if ((return_type==POLY_CMD) &&(result!=NULL))
1903  {
1904  res->data=(char *)result->m[0];
1905  result->m[0]=NULL;
1906  idDelete(&result);
1907  }
1908  else
1909  res->data=(char *)result;
1910  }
1911  for(i=rl-1;i>=0;i--)
1912  {
1913  n_Delete(&(q[i]),cf);
1914  }
1915  omFree(q);
1916  res->rtyp=return_type;
1917  return result==NULL;
1918 }
1919 static BOOLEAN jjCOEF(leftv res, leftv u, leftv v)
1920 {
1921  poly p=(poly)v->Data();
1922  if ((p==NULL)||(pNext(p)!=NULL)) return TRUE;
1923  res->data=(char *)mp_CoeffProc((poly)u->Data(),p /*(poly)v->Data()*/,currRing);
1924  return FALSE;
1925 }
1927 {
1928  int i=pVar((poly)v->Data());
1929  if (i==0)
1930  {
1931  WerrorS("ringvar expected");
1932  return TRUE;
1933  }
1934  res->data=(char *)mp_Coeffs((ideal)u->CopyD(),i,currRing);
1935  return FALSE;
1936 }
1938 {
1939  poly p = pInit();
1940  int i;
1941  for (i=1; i<=currRing->N; i++)
1942  {
1943  pSetExp(p, i, 1);
1944  }
1945  pSetm(p);
1946  res->data = (void*)idCoeffOfKBase((ideal)(u->Data()),
1947  (ideal)(v->Data()), p);
1948  pDelete(&p);
1949  return FALSE;
1950 }
1952 {
1953  res->data=(char *)idDiffOp((ideal)u->Data(),(ideal)v->Data(),FALSE);
1954  return FALSE;
1955 }
1957 {
1958  short *iv=iv2array((intvec *)v->Data(),currRing);
1959  ideal I=(ideal)u->Data();
1960  int d=-1;
1961  int i;
1962  for(i=IDELEMS(I);i>=0;i--) d=si_max(d,(int)p_DegW(I->m[i],iv,currRing));
1963  omFreeSize( (ADDRESS)iv, (rVar(currRing)+1)*sizeof(short) );
1964  res->data = (char *)((long)d);
1965  return FALSE;
1966 }
1967 static BOOLEAN jjDEG_IV(leftv res, leftv u, leftv v)
1968 {
1969  poly p=(poly)u->Data();
1970  if (p!=NULL)
1971  {
1972  short *iv=iv2array((intvec *)v->Data(),currRing);
1973  const long d = p_DegW(p,iv,currRing);
1974  omFreeSize( (ADDRESS)iv, (rVar(currRing)+1)*sizeof(short) );
1975  res->data = (char *)(d);
1976  }
1977  else
1978  res->data=(char *)(long)(-1);
1979  return FALSE;
1980 }
1981 static BOOLEAN jjDIFF_P(leftv res, leftv u, leftv v)
1982 {
1983  int i=pVar((poly)v->Data());
1984  if (i==0)
1985  {
1986  WerrorS("ringvar expected");
1987  return TRUE;
1988  }
1989  res->data=(char *)pDiff((poly)(u->Data()),i);
1990  return FALSE;
1991 }
1992 static BOOLEAN jjDIFF_ID(leftv res, leftv u, leftv v)
1993 {
1994  int i=pVar((poly)v->Data());
1995  if (i==0)
1996  {
1997  WerrorS("ringvar expected");
1998  return TRUE;
1999  }
2000  res->data=(char *)idDiff((matrix)(u->Data()),i);
2001  return FALSE;
2002 }
2004 {
2005  res->data=(char *)idDiffOp((ideal)u->Data(),(ideal)v->Data());
2006  return FALSE;
2007 }
2008 static BOOLEAN jjDIM2(leftv res, leftv v, leftv w)
2009 {
2010  assumeStdFlag(v);
2011 #ifdef HAVE_RINGS
2012  if (rField_is_Ring(currRing))
2013  {
2014  //ring origR = currRing;
2015  //ring tempR = rCopy(origR);
2016  //coeffs new_cf=nInitChar(n_Q,NULL);
2017  //nKillChar(tempR->cf);
2018  //tempR->cf=new_cf;
2019  //rComplete(tempR);
2020  ideal vid = (ideal)v->Data();
2021  int i = idPosConstant(vid);
2022  if ((i != -1) && (n_IsUnit(pGetCoeff(vid->m[i]),currRing->cf)))
2023  { /* ideal v contains unit; dim = -1 */
2024  res->data = (char *)-1;
2025  return FALSE;
2026  }
2027  //rChangeCurrRing(tempR);
2028  //ideal vv = idrCopyR(vid, origR, currRing);
2029  ideal vv = id_Copy(vid, currRing);
2030  //ideal ww = idrCopyR((ideal)w->Data(), origR, currRing);
2031  ideal ww = id_Copy((ideal)w->Data(), currRing);
2032  /* drop degree zero generator from vv (if any) */
2033  if (i != -1) pDelete(&vv->m[i]);
2034  long d = (long)scDimInt(vv, ww);
2035  if (rField_is_Ring_Z(currRing) && (i == -1)) d++;
2036  res->data = (char *)d;
2037  idDelete(&vv); idDelete(&ww);
2038  //rChangeCurrRing(origR);
2039  //rDelete(tempR);
2040  return FALSE;
2041  }
2042 #endif
2043  if(currRing->qideal==NULL)
2044  res->data = (char *)((long)scDimInt((ideal)(v->Data()),(ideal)w->Data()));
2045  else
2046  {
2047  ideal q=idSimpleAdd(currRing->qideal,(ideal)w->Data());
2048  res->data = (char *)((long)scDimInt((ideal)(v->Data()),q));
2049  idDelete(&q);
2050  }
2051  return FALSE;
2052 }
2054 {
2055  ideal vi=(ideal)v->Data();
2056  int vl= IDELEMS(vi);
2057  ideal ui=(ideal)u->Data();
2058  int ul= IDELEMS(ui);
2059  ideal R; matrix U;
2060  ideal m = idLift(vi,ui,&R, FALSE,hasFlag(v,FLAG_STD),TRUE,&U);
2061  if (m==NULL) return TRUE;
2062  // now make sure that all matices have the corect size:
2064  int i;
2065  if (MATCOLS(U) != ul)
2066  {
2067  int mul=si_min(ul,MATCOLS(U));
2068  matrix UU=mpNew(ul,ul);
2069  int j;
2070  for(i=mul;i>0;i--)
2071  {
2072  for(j=mul;j>0;j--)
2073  {
2074  MATELEM(UU,i,j)=MATELEM(U,i,j);
2075  MATELEM(U,i,j)=NULL;
2076  }
2077  }
2078  idDelete((ideal *)&U);
2079  U=UU;
2080  }
2081  // make sure that U is a diagonal matrix of units
2082  for(i=ul;i>0;i--)
2083  {
2084  if(MATELEM(U,i,i)==NULL) MATELEM(U,i,i)=pOne();
2085  }
2087  L->Init(3);
2088  L->m[0].rtyp=MATRIX_CMD; L->m[0].data=(void *)T;
2089  L->m[1].rtyp=u->Typ(); L->m[1].data=(void *)R;
2090  L->m[2].rtyp=MATRIX_CMD; L->m[2].data=(void *)U;
2091  res->data=(char *)L;
2092  return FALSE;
2093 }
2094 static BOOLEAN jjELIMIN(leftv res, leftv u, leftv v)
2095 {
2096  res->data=(char *)idElimination((ideal)u->Data(),(poly)v->Data());
2097  //setFlag(res,FLAG_STD);
2098  return v->next!=NULL; //do not allow next like in eliminate(I,a(1..4))
2099 }
2101 {
2102  poly p=pOne();
2103  intvec *iv=(intvec*)v->Data();
2104  for(int i=iv->length()-1; i>=0; i--)
2105  {
2106  pSetExp(p,(*iv)[i],1);
2107  }
2108  pSetm(p);
2109  res->data=(char *)idElimination((ideal)u->Data(),p);
2110  pLmDelete(&p);
2111  //setFlag(res,FLAG_STD);
2112  return FALSE;
2113 }
2115 {
2116  //Print("exportto %s -> %s\n",v->Name(),u->Name() );
2117  return iiExport(v,0,IDPACKAGE((idhdl)u->data));
2118 }
2120 {
2121  WerrorS((char *)u->Data());
2122  extern int inerror;
2123  inerror=3;
2124  return TRUE;
2125 }
2127 {
2128  number uu=(number)u->Data();number vv=(number)v->Data();
2130  number a,b;
2131  number p0=n_ExtGcd(uu,vv,&a,&b,coeffs_BIGINT);
2132  L->Init(3);
2133  L->m[0].rtyp=BIGINT_CMD; L->m[0].data=(void *)p0;
2134  L->m[1].rtyp=BIGINT_CMD; L->m[1].data=(void *)a;
2135  L->m[2].rtyp=BIGINT_CMD; L->m[2].data=(void *)b;
2136  res->rtyp=LIST_CMD;
2137  res->data=(char *)L;
2138  return FALSE;
2139 }
2141 {
2142  int uu=(int)(long)u->Data();int vv=(int)(long)v->Data();
2143  int p0=ABS(uu),p1=ABS(vv);
2144  int f0 = 1, f1 = 0, g0 = 0, g1 = 1, q, r;
2145 
2146  while ( p1!=0 )
2147  {
2148  q=p0 / p1;
2149  r=p0 % p1;
2150  p0 = p1; p1 = r;
2151  r = g0 - g1 * q;
2152  g0 = g1; g1 = r;
2153  r = f0 - f1 * q;
2154  f0 = f1; f1 = r;
2155  }
2156  int a = f0;
2157  int b = g0;
2158  if ( uu /*(int)(long)u->Data()*/ < 0 ) a=-a;
2159  if ( vv /*(int)(long)v->Data()*/ < 0 ) b=-b;
2161  L->Init(3);
2162  L->m[0].rtyp=INT_CMD; L->m[0].data=(void *)(long)p0;
2163  L->m[1].rtyp=INT_CMD; L->m[1].data=(void *)(long)a;
2164  L->m[2].rtyp=INT_CMD; L->m[2].data=(void *)(long)b;
2165  res->rtyp=LIST_CMD;
2166  res->data=(char *)L;
2167  return FALSE;
2168 }
2170 {
2171  poly r,pa,pb;
2172  BOOLEAN ret=singclap_extgcd((poly)u->Data(),(poly)v->Data(),r,pa,pb,currRing);
2173  if (ret) return TRUE;
2175  L->Init(3);
2176  res->data=(char *)L;
2177  L->m[0].data=(void *)r;
2178  L->m[0].rtyp=POLY_CMD;
2179  L->m[1].data=(void *)pa;
2180  L->m[1].rtyp=POLY_CMD;
2181  L->m[2].data=(void *)pb;
2182  L->m[2].rtyp=POLY_CMD;
2183  return FALSE;
2184 }
2185 extern int singclap_factorize_retry;
2186 static BOOLEAN jjFAC_P2(leftv res, leftv u,leftv dummy)
2187 {
2188  intvec *v=NULL;
2189  int sw=(int)(long)dummy->Data();
2190  int fac_sw=sw;
2191  if ((sw<0)||(sw>2)) fac_sw=1;
2193  ideal f=singclap_factorize((poly)(u->CopyD()), &v, fac_sw,currRing);
2194  if (f==NULL)
2195  return TRUE;
2196  switch(sw)
2197  {
2198  case 0:
2199  case 2:
2200  {
2202  l->Init(2);
2203  l->m[0].rtyp=IDEAL_CMD;
2204  l->m[0].data=(void *)f;
2205  l->m[1].rtyp=INTVEC_CMD;
2206  l->m[1].data=(void *)v;
2207  res->data=(void *)l;
2208  res->rtyp=LIST_CMD;
2209  return FALSE;
2210  }
2211  case 1:
2212  res->data=(void *)f;
2213  return FALSE;
2214  case 3:
2215  {
2216  poly p=f->m[0];
2217  int i=IDELEMS(f);
2218  f->m[0]=NULL;
2219  while(i>1)
2220  {
2221  i--;
2222  p=pMult(p,f->m[i]);
2223  f->m[i]=NULL;
2224  }
2225  res->data=(void *)p;
2226  res->rtyp=POLY_CMD;
2227  }
2228  return FALSE;
2229  }
2230  WerrorS("invalid switch");
2231  return TRUE;
2232 }
2234 {
2235  ideal_list p,h;
2236  h=kStdfac((ideal)v->Data(),NULL,testHomog,NULL,(ideal)w->Data());
2237  p=h;
2238  int l=0;
2239  while (p!=NULL) { p=p->next;l++; }
2241  L->Init(l);
2242  l=0;
2243  while(h!=NULL)
2244  {
2245  L->m[l].data=(char *)h->d;
2246  L->m[l].rtyp=IDEAL_CMD;
2247  p=h->next;
2248  omFreeSize(h,sizeof(*h));
2249  h=p;
2250  l++;
2251  }
2252  res->data=(void *)L;
2253  return FALSE;
2254 }
2256 {
2257  if (rField_is_Q(currRing))
2258  {
2259  number uu=(number)u->Data();
2260  number vv=(number)v->Data();
2261  res->data=(char *)n_Farey(uu,vv,currRing->cf);
2262  return FALSE;
2263  }
2264  else return TRUE;
2265 }
2267 {
2268  ideal uu=(ideal)u->Data();
2269  number vv=(number)v->Data();
2270  res->data=(void*)id_Farey(uu,vv,currRing);
2271  res->rtyp=u->Typ();
2272  return FALSE;
2273 }
2274 static BOOLEAN jjFETCH(leftv res, leftv u, leftv v)
2275 {
2276  ring r=(ring)u->Data();
2277  idhdl w;
2278  int op=iiOp;
2279  nMapFunc nMap;
2280 
2281  if ((w=r->idroot->get(v->Name(),myynest))!=NULL)
2282  {
2283  int *perm=NULL;
2284  int *par_perm=NULL;
2285  int par_perm_size=0;
2286  BOOLEAN bo;
2287  if ((nMap=n_SetMap(r->cf,currRing->cf))==NULL)
2288  {
2289  // Allow imap/fetch to be make an exception only for:
2290  if ( (rField_is_Q_a(r) && // Q(a..) -> Q(a..) || Q || Zp || Zp(a)
2293  ||
2294  (rField_is_Zp_a(r) && // Zp(a..) -> Zp(a..) || Zp
2295  (rField_is_Zp(currRing, r->cf->ch) ||
2296  rField_is_Zp_a(currRing, r->cf->ch))) )
2297  {
2298  par_perm_size=rPar(r);
2299  }
2300  else
2301  {
2302  goto err_fetch;
2303  }
2304  }
2305  if ((iiOp!=FETCH_CMD) || (r->N!=currRing->N) || (rPar(r)!=rPar(currRing)))
2306  {
2307  perm=(int *)omAlloc0((r->N+1)*sizeof(int));
2308  if (par_perm_size!=0)
2309  par_perm=(int *)omAlloc0(par_perm_size*sizeof(int));
2310  op=IMAP_CMD;
2311  if (iiOp==IMAP_CMD)
2312  {
2313  int r_par=0;
2314  char ** r_par_names=NULL;
2315  if (r->cf->extRing!=NULL)
2316  {
2317  r_par=r->cf->extRing->N;
2318  r_par_names=r->cf->extRing->names;
2319  }
2320  int c_par=0;
2321  char ** c_par_names=NULL;
2322  if (currRing->cf->extRing!=NULL)
2323  {
2324  c_par=currRing->cf->extRing->N;
2325  c_par_names=currRing->cf->extRing->names;
2326  }
2327  maFindPerm(r->names, r->N, r_par_names, r_par,
2328  currRing->names,currRing->N,c_par_names, c_par,
2329  perm,par_perm, currRing->cf->type);
2330  }
2331  else
2332  {
2333  int i;
2334  if (par_perm_size!=0)
2335  for(i=si_min(rPar(r),rPar(currRing))-1;i>=0;i--) par_perm[i]=-(i+1);
2336  for(i=si_min(r->N,currRing->N);i>0;i--) perm[i]=i;
2337  }
2338  }
2339  if ((iiOp==FETCH_CMD) &&(BVERBOSE(V_IMAP)))
2340  {
2341  int i;
2342  for(i=0;i<si_min(r->N,currRing->N);i++)
2343  {
2344  Print("// var nr %d: %s -> %s\n",i,r->names[i],currRing->names[i]);
2345  }
2346  for(i=0;i<si_min(rPar(r),rPar(currRing));i++) // possibly empty loop
2347  {
2348  Print("// par nr %d: %s -> %s\n",
2349  i,rParameter(r)[i],rParameter(currRing)[i]);
2350  }
2351  }
2352  if (IDTYP(w)==ALIAS_CMD) w=(idhdl)IDDATA(w);
2353  sleftv tmpW;
2354  memset(&tmpW,0,sizeof(sleftv));
2355  tmpW.rtyp=IDTYP(w);
2356  tmpW.data=IDDATA(w);
2357  if ((bo=maApplyFetch(op,NULL,res,&tmpW, r,
2358  perm,par_perm,par_perm_size,nMap)))
2359  {
2360  Werror("cannot map %s of type %s(%d)",v->name, Tok2Cmdname(w->typ),w->typ);
2361  }
2362  if (perm!=NULL)
2363  omFreeSize((ADDRESS)perm,(r->N+1)*sizeof(int));
2364  if (par_perm!=NULL)
2365  omFreeSize((ADDRESS)par_perm,par_perm_size*sizeof(int));
2366  return bo;
2367  }
2368  else
2369  {
2370  Werror("identifier %s not found in %s",v->Fullname(),u->Fullname());
2371  }
2372  return TRUE;
2373 err_fetch:
2374  Werror("no identity map from %s (%s -> %s)",u->Fullname(),
2375  nCoeffString(r->cf),
2376  nCoeffString(currRing->cf));
2377  return TRUE;
2378 }
2379 static BOOLEAN jjFIND2(leftv res, leftv u, leftv v)
2380 {
2381  /*4
2382  * look for the substring what in the string where
2383  * return the position of the first char of what in where
2384  * or 0
2385  */
2386  char *where=(char *)u->Data();
2387  char *what=(char *)v->Data();
2388  char *found = strstr(where,what);
2389  if (found != NULL)
2390  {
2391  res->data=(char *)((found-where)+1);
2392  }
2393  /*else res->data=NULL;*/
2394  return FALSE;
2395 }
2396 static BOOLEAN jjFWALK(leftv res, leftv u, leftv v)
2397 {
2398  res->data=(char *)fractalWalkProc(u,v);
2399  setFlag( res, FLAG_STD );
2400  return FALSE;
2401 }
2402 static BOOLEAN jjGCD_I(leftv res, leftv u, leftv v)
2403 {
2404  int uu=(int)(long)u->Data();int vv=(int)(long)v->Data();
2405  int p0=ABS(uu),p1=ABS(vv);
2406  int r;
2407  while ( p1!=0 )
2408  {
2409  r=p0 % p1;
2410  p0 = p1; p1 = r;
2411  }
2412  res->rtyp=INT_CMD;
2413  res->data=(char *)(long)p0;
2414  return FALSE;
2415 }
2416 static BOOLEAN jjGCD_BI(leftv res, leftv u, leftv v)
2417 {
2418  number n1 = (number) u->Data();
2419  number n2 = (number) v->Data();
2420  res->data = n_Gcd(n1,n2,coeffs_BIGINT);
2421  return FALSE;
2422 }
2423 static BOOLEAN jjGCD_N(leftv res, leftv u, leftv v)
2424 {
2425  number a=(number) u->Data();
2426  number b=(number) v->Data();
2427  if (nIsZero(a))
2428  {
2429  if (nIsZero(b)) res->data=(char *)nInit(1);
2430  else res->data=(char *)nCopy(b);
2431  }
2432  else
2433  {
2434  if (nIsZero(b)) res->data=(char *)nCopy(a);
2435  //else res->data=(char *)n_Gcd(a, b, currRing->cf);
2436  else res->data=(char *)n_SubringGcd(a, b, currRing->cf);
2437  }
2438  return FALSE;
2439 }
2440 static BOOLEAN jjGCD_P(leftv res, leftv u, leftv v)
2441 {
2442  res->data=(void *)singclap_gcd((poly)(u->CopyD(POLY_CMD)),
2443  (poly)(v->CopyD(POLY_CMD)),currRing);
2444  return FALSE;
2445 }
2447 {
2448 #ifdef HAVE_RINGS
2450  {
2451  ring origR = currRing;
2452  ring tempR = rCopy(origR);
2453  coeffs new_cf=nInitChar(n_Q,NULL);
2454  nKillChar(tempR->cf);
2455  tempR->cf=new_cf;
2456  rComplete(tempR);
2457  ideal uid = (ideal)u->Data();
2458  rChangeCurrRing(tempR);
2459  ideal uu = idrCopyR(uid, origR, currRing);
2460  sleftv uuAsLeftv; memset(&uuAsLeftv, 0, sizeof(uuAsLeftv));
2461  uuAsLeftv.rtyp = IDEAL_CMD;
2462  uuAsLeftv.data = uu; uuAsLeftv.next = NULL;
2463  if (hasFlag(u, FLAG_STD)) setFlag(&uuAsLeftv,FLAG_STD);
2464  assumeStdFlag(&uuAsLeftv);
2465  Print("// NOTE: computation of Hilbert series etc. is being\n");
2466  Print("// performed for generic fibre, that is, over Q\n");
2467  intvec *module_w=(intvec*)atGet(&uuAsLeftv,"isHomog",INTVEC_CMD);
2468  intvec *iv=hFirstSeries(uu,module_w,currRing->qideal);
2469  int returnWithTrue = 1;
2470  switch((int)(long)v->Data())
2471  {
2472  case 1:
2473  res->data=(void *)iv;
2474  returnWithTrue = 0;
2475  case 2:
2476  res->data=(void *)hSecondSeries(iv);
2477  delete iv;
2478  returnWithTrue = 0;
2479  }
2480  if (returnWithTrue)
2481  {
2483  delete iv;
2484  }
2485  idDelete(&uu);
2486  rChangeCurrRing(origR);
2487  rDelete(tempR);
2488  if (returnWithTrue) return TRUE; else return FALSE;
2489  }
2490 #endif
2491  assumeStdFlag(u);
2492  intvec *module_w=(intvec*)atGet(u,"isHomog",INTVEC_CMD);
2493  intvec *iv=hFirstSeries((ideal)u->Data(),module_w,currRing->qideal);
2494  switch((int)(long)v->Data())
2495  {
2496  case 1:
2497  res->data=(void *)iv;
2498  return FALSE;
2499  case 2:
2500  res->data=(void *)hSecondSeries(iv);
2501  delete iv;
2502  return FALSE;
2503  }
2505  delete iv;
2506  return TRUE;
2507 }
2508 static BOOLEAN jjHOMOG_P(leftv res, leftv u, leftv v)
2509 {
2510  int i=pVar((poly)v->Data());
2511  if (i==0)
2512  {
2513  WerrorS("ringvar expected");
2514  return TRUE;
2515  }
2516  poly p=pOne(); pSetExp(p,i,1); pSetm(p);
2517  int d=pWTotaldegree(p);
2518  pLmDelete(p);
2519  if (d==1)
2520  res->data = (char *)p_Homogen((poly)u->Data(), i, currRing);
2521  else
2522  WerrorS("variable must have weight 1");
2523  return (d!=1);
2524 }
2526 {
2527  int i=pVar((poly)v->Data());
2528  if (i==0)
2529  {
2530  WerrorS("ringvar expected");
2531  return TRUE;
2532  }
2533  pFDegProc deg;
2534  if (currRing->pLexOrder && (currRing->order[0]==ringorder_lp))
2535  deg=p_Totaldegree;
2536  else
2537  deg=currRing->pFDeg;
2538  poly p=pOne(); pSetExp(p,i,1); pSetm(p);
2539  int d=deg(p,currRing);
2540  pLmDelete(p);
2541  if (d==1)
2542  res->data = (char *)id_Homogen((ideal)u->Data(), i, currRing);
2543  else
2544  WerrorS("variable must have weight 1");
2545  return (d!=1);
2546 }
2548 {
2549  intvec *w=new intvec(rVar(currRing));
2550  intvec *vw=(intvec*)u->Data();
2551  ideal v_id=(ideal)v->Data();
2552  pFDegProc save_FDeg=currRing->pFDeg;
2553  pLDegProc save_LDeg=currRing->pLDeg;
2554  BOOLEAN save_pLexOrder=currRing->pLexOrder;
2555  currRing->pLexOrder=FALSE;
2556  kHomW=vw;
2557  kModW=w;
2559  res->data=(void *)(long)idHomModule(v_id,currRing->qideal,&w);
2560  currRing->pLexOrder=save_pLexOrder;
2561  kHomW=NULL;
2562  kModW=NULL;
2563  pRestoreDegProcs(currRing,save_FDeg,save_LDeg);
2564  if (w!=NULL) delete w;
2565  return FALSE;
2566 }
2568 {
2569  assumeStdFlag(u);
2570  res->data=(void *)scIndIndset((ideal)(u->Data()),(int)(long)(v->Data()),
2571  currRing->qideal);
2572  return FALSE;
2573 }
2575 {
2576  res->data=(char *)idSect((ideal)u->Data(),(ideal)v->Data());
2578  return FALSE;
2579 }
2581 {
2582  const lists L = (lists)l->Data();
2583  const int n = L->nr; assume (n >= 0);
2584  std::vector<ideal> V(n + 1);
2585 
2586  for(int i = n; i >= 0; i--) V[i] = (ideal)(L->m[i].Data());
2587 
2588  res->data=interpolation(V, (intvec*)v->Data());
2589  setFlag(res,FLAG_STD);
2590  return errorreported;
2591 }
2593 {
2594  extern BOOLEAN jjStdJanetBasis(leftv res, leftv v,int flag);
2595  return jjStdJanetBasis(res,u,(int)(long)v->Data());
2596 }
2597 
2599 {
2600  extern BOOLEAN jjStdJanetBasis(leftv res, leftv v,int flag);
2601  return jjStdJanetBasis(res,v,0);
2602 }
2603 static BOOLEAN jjJET_P(leftv res, leftv u, leftv v)
2604 {
2605  res->data = (char *)pJet((poly)u->CopyD(), (int)(long)v->Data());
2606  return FALSE;
2607 }
2608 static BOOLEAN jjJET_ID(leftv res, leftv u, leftv v)
2609 {
2610  res->data = (char *)id_Jet((ideal)u->Data(),(int)(long)v->Data(),currRing);
2611  return FALSE;
2612 }
2613 static BOOLEAN jjKBASE2(leftv res, leftv u, leftv v)
2614 {
2615  assumeStdFlag(u);
2616  intvec *w_u=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
2617  res->data = (char *)scKBase((int)(long)v->Data(),
2618  (ideal)(u->Data()),currRing->qideal, w_u);
2619  if (w_u!=NULL)
2620  {
2621  atSet(res,omStrDup("isHomog"),ivCopy(w_u),INTVEC_CMD);
2622  }
2623  return FALSE;
2624 }
2625 static BOOLEAN jjPREIMAGE(leftv res, leftv u, leftv v, leftv w);
2626 static BOOLEAN jjKERNEL(leftv res, leftv u, leftv v)
2627 {
2628  return jjPREIMAGE(res,u,v,NULL);
2629 }
2630 static BOOLEAN jjKoszul(leftv res, leftv u, leftv v)
2631 {
2632  return mpKoszul(res, u,v,NULL);
2633 }
2635 {
2636  sleftv h;
2637  memset(&h,0,sizeof(sleftv));
2638  h.rtyp=INT_CMD;
2639  h.data=(void *)(long)IDELEMS((ideal)v->Data());
2640  return mpKoszul(res, u, &h, v);
2641 }
2642 static BOOLEAN jjLIFT(leftv res, leftv u, leftv v)
2643 {
2644  int ul= IDELEMS((ideal)u->Data());
2645  int vl= IDELEMS((ideal)v->Data());
2646  ideal m = idLift((ideal)u->Data(),(ideal)v->Data(),NULL,FALSE,
2647  hasFlag(u,FLAG_STD));
2648  if (m==NULL) return TRUE;
2649  res->data = (char *)id_Module2formatedMatrix(m,ul,vl,currRing);
2650  return FALSE;
2651 }
2652 static BOOLEAN jjLIFTSTD(leftv res, leftv u, leftv v)
2653 {
2654  if ((v->rtyp!=IDHDL)||(v->e!=NULL)) return TRUE;
2655  idhdl h=(idhdl)v->data;
2656  // CopyD for IDEAL_CMD and MODUL_CMD are identical:
2657  res->data = (char *)idLiftStd((ideal)u->Data(),
2658  &(h->data.umatrix),testHomog);
2659  setFlag(res,FLAG_STD); v->flag=0;
2660  return FALSE;
2661 }
2662 static BOOLEAN jjLOAD2(leftv /*res*/, leftv, leftv v)
2663 {
2664  return jjLOAD((char*)v->Data(),TRUE);
2665 }
2666 static BOOLEAN jjLOAD_E(leftv /*res*/, leftv v, leftv u)
2667 {
2668  char * s=(char *)u->Data();
2669  if(strcmp(s, "with")==0)
2670  return jjLOAD((char*)v->Data(), TRUE);
2671  if (strcmp(s,"try")==0)
2672  return jjLOAD_TRY((char*)v->Data());
2673  WerrorS("invalid second argument");
2674  WerrorS("load(\"libname\" [,option]);");
2675  return TRUE;
2676 }
2677 static BOOLEAN jjMODULO(leftv res, leftv u, leftv v)
2678 {
2679  intvec *w_u=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
2680  tHomog hom=testHomog;
2681  if (w_u!=NULL)
2682  {
2683  w_u=ivCopy(w_u);
2684  hom=isHomog;
2685  }
2686  intvec *w_v=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
2687  if (w_v!=NULL)
2688  {
2689  w_v=ivCopy(w_v);
2690  hom=isHomog;
2691  }
2692  if ((w_u!=NULL) && (w_v==NULL))
2693  w_v=ivCopy(w_u);
2694  if ((w_v!=NULL) && (w_u==NULL))
2695  w_u=ivCopy(w_v);
2696  ideal u_id=(ideal)u->Data();
2697  ideal v_id=(ideal)v->Data();
2698  if (w_u!=NULL)
2699  {
2700  if ((*w_u).compare((w_v))!=0)
2701  {
2702  WarnS("incompatible weights");
2703  delete w_u; w_u=NULL;
2704  hom=testHomog;
2705  }
2706  else
2707  {
2708  if ((!idTestHomModule(u_id,currRing->qideal,w_v))
2709  || (!idTestHomModule(v_id,currRing->qideal,w_v)))
2710  {
2711  WarnS("wrong weights");
2712  delete w_u; w_u=NULL;
2713  hom=testHomog;
2714  }
2715  }
2716  }
2717  res->data = (char *)idModulo(u_id,v_id ,hom,&w_u);
2718  if (w_u!=NULL)
2719  {
2720  atSet(res,omStrDup("isHomog"),w_u,INTVEC_CMD);
2721  }
2722  delete w_v;
2723  //if (TEST_OPT_RETURN_SB) setFlag(res,FLAG_STD);
2724  return FALSE;
2725 }
2726 static BOOLEAN jjMOD_BI(leftv res, leftv u, leftv v)
2727 {
2728  number q=(number)v->Data();
2729  if (n_IsZero(q,coeffs_BIGINT))
2730  {
2732  return TRUE;
2733  }
2734  res->data =(char *) n_IntMod((number)u->Data(),q,coeffs_BIGINT);
2735  return FALSE;
2736 }
2737 static BOOLEAN jjMOD_N(leftv res, leftv u, leftv v)
2738 {
2739  number q=(number)v->Data();
2740  if (nIsZero(q))
2741  {
2743  return TRUE;
2744  }
2745  res->data =(char *) n_IntMod((number)u->Data(),q,currRing->cf);
2746  return FALSE;
2747 }
2748 static BOOLEAN jjMONITOR2(leftv res, leftv u,leftv v);
2750 {
2751  return jjMONITOR2(res,v,NULL);
2752 }
2754 {
2755 #if 0
2756  char *opt=(char *)v->Data();
2757  int mode=0;
2758  while(*opt!='\0')
2759  {
2760  if (*opt=='i') mode |= SI_PROT_I;
2761  else if (*opt=='o') mode |= SI_PROT_O;
2762  opt++;
2763  }
2764  monitor((char *)(u->Data()),mode);
2765 #else
2766  si_link l=(si_link)u->Data();
2767  if (slOpen(l,SI_LINK_WRITE,u)) return TRUE;
2768  if(strcmp(l->m->type,"ASCII")!=0)
2769  {
2770  Werror("ASCII link required, not `%s`",l->m->type);
2771  slClose(l);
2772  return TRUE;
2773  }
2774  SI_LINK_SET_CLOSE_P(l); // febase handles the FILE*
2775  if ( l->name[0]!='\0') // "" is the stop condition
2776  {
2777  const char *opt;
2778  int mode=0;
2779  if (v==NULL) opt=(const char*)"i";
2780  else opt=(const char *)v->Data();
2781  while(*opt!='\0')
2782  {
2783  if (*opt=='i') mode |= SI_PROT_I;
2784  else if (*opt=='o') mode |= SI_PROT_O;
2785  opt++;
2786  }
2787  monitor((FILE *)l->data,mode);
2788  }
2789  else
2790  monitor(NULL,0);
2791  return FALSE;
2792 #endif
2793 }
2794 static BOOLEAN jjMONOM(leftv res, leftv v)
2795 {
2796  intvec *iv=(intvec *)v->Data();
2797  poly p=pOne();
2798  int i,e;
2799  BOOLEAN err=FALSE;
2800  for(i=si_min(currRing->N,iv->length()); i>0; i--)
2801  {
2802  e=(*iv)[i-1];
2803  if (e>=0) pSetExp(p,i,e);
2804  else err=TRUE;
2805  }
2806  if (iv->length()==(currRing->N+1))
2807  {
2808  res->rtyp=VECTOR_CMD;
2809  e=(*iv)[currRing->N];
2810  if (e>=0) pSetComp(p,e);
2811  else err=TRUE;
2812  }
2813  pSetm(p);
2814  res->data=(char*)p;
2815  if(err) { pDelete(&p); WerrorS("no negative exponent allowed"); }
2816  return err;
2817 }
2819 {
2820  // u: the name of the new type
2821  // v: the elements
2822  newstruct_desc d=newstructFromString((const char *)v->Data());
2823  if (d!=NULL) newstruct_setup((const char *)u->Data(),d);
2824  return d==NULL;
2825 }
2826 static BOOLEAN jjPARSTR2(leftv res, leftv u, leftv v)
2827 {
2828  idhdl h=(idhdl)u->data;
2829  int i=(int)(long)v->Data();
2830  int p=0;
2831  if ((0<i)
2832  && (rParameter(IDRING(h))!=NULL)
2833  && (i<=(p=rPar(IDRING(h)))))
2834  res->data=omStrDup(rParameter(IDRING(h))[i-1]);
2835  else
2836  {
2837  Werror("par number %d out of range 1..%d",i,p);
2838  return TRUE;
2839  }
2840  return FALSE;
2841 }
2842 #ifdef HAVE_PLURAL
2844 {
2845  if( currRing->qideal != NULL )
2846  {
2847  WerrorS("basering must NOT be a qring!");
2848  return TRUE;
2849  }
2850 
2851  if (iiOp==NCALGEBRA_CMD)
2852  {
2853  return nc_CallPlural(NULL,NULL,(poly)a->Data(),(poly)b->Data(),currRing,false,true,false,currRing);
2854  }
2855  else
2856  {
2857  ring r=rCopy(currRing);
2858  BOOLEAN result=nc_CallPlural(NULL,NULL,(poly)a->Data(),(poly)b->Data(),r,false,true,false,currRing);
2859  res->data=r;
2860  if (r->qideal!=NULL) res->rtyp=QRING_CMD;
2861  return result;
2862  }
2863 }
2865 {
2866  if( currRing->qideal != NULL )
2867  {
2868  WerrorS("basering must NOT be a qring!");
2869  return TRUE;
2870  }
2871 
2872  if (iiOp==NCALGEBRA_CMD)
2873  {
2874  return nc_CallPlural(NULL,(matrix)b->Data(),(poly)a->Data(),NULL,currRing,false,true,false,currRing);
2875  }
2876  else
2877  {
2878  ring r=rCopy(currRing);
2879  BOOLEAN result=nc_CallPlural(NULL,(matrix)b->Data(),(poly)a->Data(),NULL,r,false,true,false,currRing);
2880  res->data=r;
2881  if (r->qideal!=NULL) res->rtyp=QRING_CMD;
2882  return result;
2883  }
2884 }
2886 {
2887  if( currRing->qideal != NULL )
2888  {
2889  WerrorS("basering must NOT be a qring!");
2890  return TRUE;
2891  }
2892 
2893  if (iiOp==NCALGEBRA_CMD)
2894  {
2895  return nc_CallPlural((matrix)a->Data(),NULL,NULL,(poly)b->Data(),currRing,false,true,false,currRing);
2896  }
2897  else
2898  {
2899  ring r=rCopy(currRing);
2900  BOOLEAN result=nc_CallPlural((matrix)a->Data(),NULL,NULL,(poly)b->Data(),r,false,true,false,currRing);
2901  res->data=r;
2902  if (r->qideal!=NULL) res->rtyp=QRING_CMD;
2903  return result;
2904  }
2905 }
2907 {
2908  if( currRing->qideal != NULL )
2909  {
2910  WerrorS("basering must NOT be a qring!");
2911  return TRUE;
2912  }
2913 
2914  if (iiOp==NCALGEBRA_CMD)
2915  {
2916  return nc_CallPlural((matrix)a->Data(),(matrix)b->Data(),NULL,NULL,currRing,false,true,false,currRing);
2917  }
2918  else
2919  {
2920  ring r=rCopy(currRing);
2921  BOOLEAN result=nc_CallPlural((matrix)a->Data(),(matrix)b->Data(),NULL,NULL,r,false,true,false,currRing);
2922  res->data=r;
2923  if (r->qideal!=NULL) res->rtyp=QRING_CMD;
2924  return result;
2925  }
2926 }
2928 {
2929  res->data=NULL;
2930 
2931  if (rIsPluralRing(currRing))
2932  {
2933  const poly q = (poly)b->Data();
2934 
2935  if( q != NULL )
2936  {
2937  if( (poly)a->Data() != NULL )
2938  {
2939  poly p = (poly)a->CopyD(POLY_CMD); // p = copy!
2940  res->data = nc_p_Bracket_qq(p,q, currRing); // p will be destroyed!
2941  }
2942  }
2943  }
2944  return FALSE;
2945 }
2947 {
2948  /* number, poly, vector, ideal, module, matrix */
2949  ring r = (ring)a->Data();
2950  if (r == currRing)
2951  {
2952  res->data = b->Data();
2953  res->rtyp = b->rtyp;
2954  return FALSE;
2955  }
2956  if (!rIsLikeOpposite(currRing, r))
2957  {
2958  Werror("%s is not an opposite ring to current ring",a->Fullname());
2959  return TRUE;
2960  }
2961  idhdl w;
2962  if( ((w=r->idroot->get(b->Name(),myynest))!=NULL) && (b->e==NULL))
2963  {
2964  int argtype = IDTYP(w);
2965  switch (argtype)
2966  {
2967  case NUMBER_CMD:
2968  {
2969  /* since basefields are equal, we can apply nCopy */
2970  res->data = nCopy((number)IDDATA(w));
2971  res->rtyp = argtype;
2972  break;
2973  }
2974  case POLY_CMD:
2975  case VECTOR_CMD:
2976  {
2977  poly q = (poly)IDDATA(w);
2978  res->data = pOppose(r,q,currRing);
2979  res->rtyp = argtype;
2980  break;
2981  }
2982  case IDEAL_CMD:
2983  case MODUL_CMD:
2984  {
2985  ideal Q = (ideal)IDDATA(w);
2986  res->data = idOppose(r,Q,currRing);
2987  res->rtyp = argtype;
2988  break;
2989  }
2990  case MATRIX_CMD:
2991  {
2992  ring save = currRing;
2993  rChangeCurrRing(r);
2994  matrix m = (matrix)IDDATA(w);
2996  rChangeCurrRing(save);
2997  ideal S = idOppose(r,Q,currRing);
2998  id_Delete(&Q, r);
2999  res->data = id_Module2Matrix(S,currRing);
3000  res->rtyp = argtype;
3001  break;
3002  }
3003  default:
3004  {
3005  WerrorS("unsupported type in oppose");
3006  return TRUE;
3007  }
3008  }
3009  }
3010  else
3011  {
3012  Werror("identifier %s not found in %s",b->Fullname(),a->Fullname());
3013  return TRUE;
3014  }
3015  return FALSE;
3016 }
3017 #endif /* HAVE_PLURAL */
3018 
3019 static BOOLEAN jjQUOT(leftv res, leftv u, leftv v)
3020 {
3021  res->data = (char *)idQuot((ideal)u->Data(),(ideal)v->Data(),
3022  hasFlag(u,FLAG_STD),u->Typ()==v->Typ());
3023  id_DelMultiples((ideal)(res->data),currRing);
3025  return FALSE;
3026 }
3027 static BOOLEAN jjRANDOM(leftv res, leftv u, leftv v)
3028 {
3029  int i=(int)(long)u->Data();
3030  int j=(int)(long)v->Data();
3031  if (j-i <0) {WerrorS("invalid range for random"); return TRUE;}
3032  res->data =(char *)(long)((i > j) ? i : (siRand() % (j-i+1)) + i);
3033  return FALSE;
3034 }
3035 static BOOLEAN jjRANK2(leftv res, leftv u, leftv v)
3036 {
3037  matrix m =(matrix)u->Data();
3038  int isRowEchelon = (int)(long)v->Data();
3039  if (isRowEchelon != 1) isRowEchelon = 0;
3040  int rank = luRank(m, isRowEchelon);
3041  res->data =(char *)(long)rank;
3042  return FALSE;
3043 }
3044 static BOOLEAN jjREAD2(leftv res, leftv u, leftv v)
3045 {
3046  si_link l=(si_link)u->Data();
3047  leftv r=slRead(l,v);
3048  if (r==NULL)
3049  {
3050  const char *s;
3051  if ((l!=NULL)&&(l->name!=NULL)) s=l->name;
3052  else s=sNoName;
3053  Werror("cannot read from `%s`",s);
3054  return TRUE;
3055  }
3056  memcpy(res,r,sizeof(sleftv));
3058  return FALSE;
3059 }
3061 {
3062  ideal vi=(ideal)v->Data();
3063  if (currRing->qideal!=NULL || vi->ncols>1 || rIsPluralRing(currRing))
3064  assumeStdFlag(v);
3065  res->data = (char *)kNF(vi,currRing->qideal,(poly)u->Data());
3066  return FALSE;
3067 }
3069 {
3070  ideal ui=(ideal)u->Data();
3071  ideal vi=(ideal)v->Data();
3072  if (currRing->qideal!=NULL || vi->ncols>1 || rIsPluralRing(currRing))
3073  assumeStdFlag(v);
3074  res->data = (char *)kNF(vi,currRing->qideal,ui);
3075  return FALSE;
3076 }
3077 #if 0
3078 static BOOLEAN jjRES(leftv res, leftv u, leftv v)
3079 {
3080  int maxl=(int)(long)v->Data();
3081  if (maxl<0)
3082  {
3083  WerrorS("length for res must not be negative");
3084  return TRUE;
3085  }
3086  int l=0;
3087  //resolvente r;
3088  syStrategy r;
3089  intvec *weights=NULL;
3090  int wmaxl=maxl;
3091  ideal u_id=(ideal)u->Data();
3092 
3093  maxl--;
3094  if (/*(*/ maxl==-1 /*)*/) /*&& (iiOp!=MRES_CMD)*/
3095  {
3096  maxl = currRing->N-1+2*(iiOp==MRES_CMD);
3097  if (currRing->qideal!=NULL)
3098  {
3099  Warn(
3100  "full resolution in a qring may be infinite, setting max length to %d",
3101  maxl+1);
3102  }
3103  }
3104  weights=(intvec*)atGet(u,"isHomog",INTVEC_CMD);
3105  if (weights!=NULL)
3106  {
3107  if (!idTestHomModule(u_id,currRing->qideal,weights))
3108  {
3109  WarnS("wrong weights given:");weights->show();PrintLn();
3110  weights=NULL;
3111  }
3112  }
3113  intvec *ww=NULL;
3114  int add_row_shift=0;
3115  if (weights!=NULL)
3116  {
3117  ww=ivCopy(weights);
3118  add_row_shift = ww->min_in();
3119  (*ww) -= add_row_shift;
3120  }
3121  else
3122  idHomModule(u_id,currRing->qideal,&ww);
3123  weights=ww;
3124 
3125  if ((iiOp == RES_CMD) || (iiOp == MRES_CMD))
3126  {
3127  r=syResolution(u_id,maxl, ww, iiOp==MRES_CMD);
3128  }
3129  else if (iiOp==SRES_CMD)
3130  // r=sySchreyerResolvente(u_id,maxl+1,&l);
3131  r=sySchreyer(u_id,maxl+1);
3132  else if (iiOp == LRES_CMD)
3133  {
3134  int dummy;
3135  if((currRing->qideal!=NULL)||
3136  (!idHomIdeal (u_id,NULL)))
3137  {
3138  WerrorS
3139  ("`lres` not implemented for inhomogeneous input or qring");
3140  return TRUE;
3141  }
3142  r=syLaScala3(u_id,&dummy);
3143  }
3144  else if (iiOp == KRES_CMD)
3145  {
3146  int dummy;
3147  if((currRing->qideal!=NULL)||
3148  (!idHomIdeal (u_id,NULL)))
3149  {
3150  WerrorS
3151  ("`kres` not implemented for inhomogeneous input or qring");
3152  return TRUE;
3153  }
3154  r=syKosz(u_id,&dummy);
3155  }
3156  else
3157  {
3158  int dummy;
3159  if((currRing->qideal!=NULL)||
3160  (!idHomIdeal (u_id,NULL)))
3161  {
3162  WerrorS
3163  ("`hres` not implemented for inhomogeneous input or qring");
3164  return TRUE;
3165  }
3166  r=syHilb(u_id,&dummy);
3167  }
3168  if (r==NULL) return TRUE;
3169  //res->data=(void *)liMakeResolv(r,l,wmaxl,u->Typ(),weights);
3170  r->list_length=wmaxl;
3171  res->data=(void *)r;
3172  if ((r->weights!=NULL) && (r->weights[0]!=NULL))
3173  {
3174  intvec *w=ivCopy(r->weights[0]);
3175  if (weights!=NULL) (*w) += add_row_shift;
3176  atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
3177  w=NULL;
3178  }
3179  else
3180  {
3181 //#if 0
3182 // need to set weights for ALL components (sres)
3183  if (weights!=NULL)
3184  {
3185  atSet(res,omStrDup("isHomog"),ivCopy(weights),INTVEC_CMD);
3187  (r->weights)[0] = ivCopy(weights);
3188  }
3189 //#endif
3190  }
3191  if (ww!=NULL) { delete ww; ww=NULL; }
3192  return FALSE;
3193 }
3194 #else
3195 static BOOLEAN jjRES(leftv res, leftv u, leftv v)
3196 {
3197  int maxl=(int)(long)v->Data();
3198  if (maxl<0)
3199  {
3200  WerrorS("length for res must not be negative");
3201  return TRUE;
3202  }
3203  syStrategy r;
3204  intvec *weights=NULL;
3205  int wmaxl=maxl;
3206  ideal u_id=(ideal)u->Data();
3207 
3208  maxl--;
3209  if (/*(*/ maxl==-1 /*)*/) /*&& (iiOp!=MRES_CMD)*/
3210  {
3211  maxl = currRing->N-1+2*(iiOp==MRES_CMD);
3212  if (currRing->qideal!=NULL)
3213  {
3214  Warn(
3215  "full resolution in a qring may be infinite, setting max length to %d",
3216  maxl+1);
3217  }
3218  }
3219  weights=(intvec*)atGet(u,"isHomog",INTVEC_CMD);
3220  if (weights!=NULL)
3221  {
3222  if (!idTestHomModule(u_id,currRing->qideal,weights))
3223  {
3224  WarnS("wrong weights given:");weights->show();PrintLn();
3225  weights=NULL;
3226  }
3227  }
3228  intvec *ww=NULL;
3229  int add_row_shift=0;
3230  if (weights!=NULL)
3231  {
3232  ww=ivCopy(weights);
3233  add_row_shift = ww->min_in();
3234  (*ww) -= add_row_shift;
3235  }
3236  if ((iiOp == RES_CMD) || (iiOp == MRES_CMD))
3237  {
3238  r=syResolution(u_id,maxl, ww, iiOp==MRES_CMD);
3239  }
3240  else if (iiOp==SRES_CMD)
3241  // r=sySchreyerResolvente(u_id,maxl+1,&l);
3242  r=sySchreyer(u_id,maxl+1);
3243  else if (iiOp == LRES_CMD)
3244  {
3245  int dummy;
3246  if((currRing->qideal!=NULL)||
3247  (!idHomIdeal (u_id,NULL)))
3248  {
3249  WerrorS
3250  ("`lres` not implemented for inhomogeneous input or qring");
3251  return TRUE;
3252  }
3253  if(currRing->N == 1)
3254  WarnS("the current implementation of `lres` may not work in the case of a single variable");
3255  r=syLaScala3(u_id,&dummy);
3256  }
3257  else if (iiOp == KRES_CMD)
3258  {
3259  int dummy;
3260  if((currRing->qideal!=NULL)||
3261  (!idHomIdeal (u_id,NULL)))
3262  {
3263  WerrorS
3264  ("`kres` not implemented for inhomogeneous input or qring");
3265  return TRUE;
3266  }
3267  r=syKosz(u_id,&dummy);
3268  }
3269  else
3270  {
3271  int dummy;
3272  if((currRing->qideal!=NULL)||
3273  (!idHomIdeal (u_id,NULL)))
3274  {
3275  WerrorS
3276  ("`hres` not implemented for inhomogeneous input or qring");
3277  return TRUE;
3278  }
3279  ideal u_id_copy=idCopy(u_id);
3280  idSkipZeroes(u_id_copy);
3281  r=syHilb(u_id_copy,&dummy);
3282  idDelete(&u_id_copy);
3283  }
3284  if (r==NULL) return TRUE;
3285  //res->data=(void *)liMakeResolv(r,l,wmaxl,u->Typ(),weights);
3286  r->list_length=wmaxl;
3287  res->data=(void *)r;
3288  if ((weights!=NULL) && (ww!=NULL)) { delete ww; ww=NULL; }
3289  if ((r->weights!=NULL) && (r->weights[0]!=NULL))
3290  {
3291  ww=ivCopy(r->weights[0]);
3292  if (weights!=NULL) (*ww) += add_row_shift;
3293  atSet(res,omStrDup("isHomog"),ww,INTVEC_CMD);
3294  }
3295  else
3296  {
3297  if (weights!=NULL)
3298  {
3299  atSet(res,omStrDup("isHomog"),ivCopy(weights),INTVEC_CMD);
3300  }
3301  }
3302 
3303  // test the La Scala case' output
3304  assume( ((iiOp == LRES_CMD) || (iiOp == HRES_CMD)) == (r->syRing != NULL) );
3305  assume( (r->syRing != NULL) == (r->resPairs != NULL) );
3306 
3307  if(iiOp != HRES_CMD)
3308  assume( (r->minres != NULL) || (r->fullres != NULL) ); // is wrong for HRES_CMD...
3309  else
3310  assume( (r->orderedRes != NULL) || (r->res != NULL) ); // analog for hres...
3311 
3312  return FALSE;
3313 }
3314 #endif
3315 static BOOLEAN jjPFAC2(leftv res, leftv u, leftv v)
3316 {
3317  number n1; int i;
3318 
3319  if ((u->Typ() == BIGINT_CMD) ||
3320  ((u->Typ() == NUMBER_CMD) && rField_is_Q(currRing)))
3321  {
3322  n1 = (number)u->CopyD();
3323  }
3324  else if (u->Typ() == INT_CMD)
3325  {
3326  i = (int)(long)u->Data();
3327  n1 = n_Init(i, coeffs_BIGINT);
3328  }
3329  else
3330  {
3331  return TRUE;
3332  }
3333 
3334  i = (int)(long)v->Data();
3335 
3336  lists l = primeFactorisation(n1, i);
3337  n_Delete(&n1, coeffs_BIGINT);
3338  res->data = (char*)l;
3339  return FALSE;
3340 }
3341 static BOOLEAN jjRSUM(leftv res, leftv u, leftv v)
3342 {
3343  ring r;
3344  int i=rSum((ring)u->Data(),(ring)v->Data(),r);
3345  res->data = (char *)r;
3346  return (i==-1);
3347 }
3348 #define SIMPL_LMDIV 32
3349 #define SIMPL_LMEQ 16
3350 #define SIMPL_MULT 8
3351 #define SIMPL_EQU 4
3352 #define SIMPL_NULL 2
3353 #define SIMPL_NORM 1
3355 {
3356  int sw = (int)(long)v->Data();
3357  // CopyD for IDEAL_CMD and MODUL_CMD are identical:
3358  ideal id = (ideal)u->CopyD(IDEAL_CMD);
3359  if (sw & SIMPL_LMDIV)
3360  {
3361  id_DelDiv(id,currRing);
3362  }
3363  if (sw & SIMPL_LMEQ)
3364  {
3366  }
3367  if (sw & SIMPL_MULT)
3368  {
3370  }
3371  else if(sw & SIMPL_EQU)
3372  {
3373  id_DelEquals(id,currRing);
3374  }
3375  if (sw & SIMPL_NULL)
3376  {
3377  idSkipZeroes(id);
3378  }
3379  if (sw & SIMPL_NORM)
3380  {
3381  id_Norm(id,currRing);
3382  }
3383  res->data = (char * )id;
3384  return FALSE;
3385 }
3387 static BOOLEAN jjSQR_FREE2(leftv res, leftv u, leftv dummy)
3388 {
3389  intvec *v=NULL;
3390  int sw=(int)(long)dummy->Data();
3391  int fac_sw=sw;
3392  if (sw<0) fac_sw=1;
3394  ideal f=singclap_sqrfree((poly)(u->CopyD()), &v, fac_sw, currRing);
3395  if (f==NULL)
3396  return TRUE;
3397  switch(sw)
3398  {
3399  case 0:
3400  case 2:
3401  {
3403  l->Init(2);
3404  l->m[0].rtyp=IDEAL_CMD;
3405  l->m[0].data=(void *)f;
3406  l->m[1].rtyp=INTVEC_CMD;
3407  l->m[1].data=(void *)v;
3408  res->data=(void *)l;
3409  res->rtyp=LIST_CMD;
3410  return FALSE;
3411  }
3412  case 1:
3413  res->data=(void *)f;
3414  return FALSE;
3415  case 3:
3416  {
3417  poly p=f->m[0];
3418  int i=IDELEMS(f);
3419  f->m[0]=NULL;
3420  while(i>1)
3421  {
3422  i--;
3423  p=pMult(p,f->m[i]);
3424  f->m[i]=NULL;
3425  }
3426  res->data=(void *)p;
3427  res->rtyp=POLY_CMD;
3428  }
3429  return FALSE;
3430  }
3431  WerrorS("invalid switch");
3432  return FALSE;
3433 }
3434 static BOOLEAN jjSTATUS2(leftv res, leftv u, leftv v)
3435 {
3436  res->data = omStrDup(slStatus((si_link) u->Data(), (char *) v->Data()));
3437  return FALSE;
3438 }
3440 {
3441  res->data = (void *)(long)slStatusSsiL((lists) u->Data(), (int)(long) v->Data());
3442  //return (res->data== (void*)(long)-2);
3443  return FALSE;
3444 }
3445 static BOOLEAN jjSIMPL_P(leftv res, leftv u, leftv v)
3446 {
3447  int sw = (int)(long)v->Data();
3448  // CopyD for POLY_CMD and VECTOR_CMD are identical:
3449  poly p = (poly)u->CopyD(POLY_CMD);
3450  if (sw & SIMPL_NORM)
3451  {
3452  pNorm(p);
3453  }
3454  res->data = (char * )p;
3455  return FALSE;
3456 }
3458 {
3459  ideal result;
3460  intvec *w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
3461  tHomog hom=testHomog;
3462  ideal u_id=(ideal)(u->Data());
3463  if (w!=NULL)
3464  {
3465  if (!idTestHomModule(u_id,currRing->qideal,w))
3466  {
3467  WarnS("wrong weights:");w->show();PrintLn();
3468  w=NULL;
3469  }
3470  else
3471  {
3472  w=ivCopy(w);
3473  hom=isHomog;
3474  }
3475  }
3476  result=kStd(u_id,currRing->qideal,hom,&w,(intvec *)v->Data());
3477  idSkipZeroes(result);
3478  res->data = (char *)result;
3479  setFlag(res,FLAG_STD);
3480  if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
3481  return FALSE;
3482 }
3483 static BOOLEAN jjSTD_1(leftv res, leftv u, leftv v)
3484 {
3485  ideal result;
3486  assumeStdFlag(u);
3487  ideal i1=(ideal)(u->Data());
3488  ideal i0;
3489  int r=v->Typ();
3490  if ((/*v->Typ()*/r==POLY_CMD) ||(r==VECTOR_CMD))
3491  {
3492  i0=idInit(1,i1->rank); // TODO: rank is wrong (if v is a vector!)
3493  i0->m[0]=(poly)v->Data();
3494  int ii0=idElem(i0); /* size of i0 */
3495  i1=idSimpleAdd(i1,i0); //
3496  memset(i0->m,0,sizeof(poly)*IDELEMS(i0));
3497  idDelete(&i0);
3498  intvec *w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
3499  tHomog hom=testHomog;
3500 
3501  if (w!=NULL)
3502  {
3503  if (!idTestHomModule(i1,currRing->qideal,w))
3504  {
3505  // no warnung: this is legal, if i in std(i,p)
3506  // is homogeneous, but p not
3507  w=NULL;
3508  }
3509  else
3510  {
3511  w=ivCopy(w);
3512  hom=isHomog;
3513  }
3514  }
3515  BITSET save1;
3516  SI_SAVE_OPT1(save1);
3518  /* ii0 appears to be the position of the first element of il that
3519  does not belong to the old SB ideal */
3520  result=kStd(i1,currRing->qideal,hom,&w,NULL,0,ii0);
3521  SI_RESTORE_OPT1(save1);
3522  idDelete(&i1);
3523  idSkipZeroes(result);
3524  if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
3525  res->data = (char *)result;
3526  }
3527  else /*IDEAL/MODULE*/
3528  {
3529  i0=(ideal)v->CopyD();
3530  int ii0=idElem(i0); /* size of i0 */
3531  i1=idSimpleAdd(i1,i0); //
3532  memset(i0->m,0,sizeof(poly)*IDELEMS(i0));
3533  idDelete(&i0);
3534  intvec *w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
3535  tHomog hom=testHomog;
3536 
3537  if (w!=NULL)
3538  {
3539  if (!idTestHomModule(i1,currRing->qideal,w))
3540  {
3541  // no warnung: this is legal, if i in std(i,p)
3542  // is homogeneous, but p not
3543  w=NULL;
3544  }
3545  else
3546  {
3547  w=ivCopy(w);
3548  hom=isHomog;
3549  }
3550  }
3551  if (ii0*4 >= 3*IDELEMS(i1)) // MAGIC: add few poly to large SB: 3/4
3552  {
3553  BITSET save1;
3554  SI_SAVE_OPT1(save1);
3556  /* ii0 appears to be the position of the first element of il that
3557  does not belong to the old SB ideal */
3558  result=kStd(i1,currRing->qideal,hom,&w,NULL,0,ii0);
3559  SI_RESTORE_OPT1(save1);
3560  }
3561  else
3562  {
3563  result=kStd(i1,currRing->qideal,hom,&w);
3564  }
3565  idDelete(&i1);
3566  idSkipZeroes(result);
3567  if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
3568  res->data = (char *)result;
3569  }
3571  return FALSE;
3572 }
3573 static BOOLEAN jjVARSTR2(leftv res, leftv u, leftv v)
3574 {
3575  idhdl h=(idhdl)u->data;
3576  int i=(int)(long)v->Data();
3577  if ((0<i) && (i<=IDRING(h)->N))
3578  res->data=omStrDup(IDRING(h)->names[i-1]);
3579  else
3580  {
3581  Werror("var number %d out of range 1..%d",i,IDRING(h)->N);
3582  return TRUE;
3583  }
3584  return FALSE;
3585 }
3587 {
3588 // input: u: a list with links of type
3589 // ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
3590 // v: timeout for select in milliseconds
3591 // or 0 for polling
3592 // returns: ERROR (via Werror): timeout negative
3593 // -1: the read state of all links is eof
3594 // 0: timeout (or polling): none ready
3595 // i>0: (at least) L[i] is ready
3596  lists Lforks = (lists)u->Data();
3597  int t = (int)(long)v->Data();
3598  if(t < 0)
3599  {
3600  WerrorS("negative timeout"); return TRUE;
3601  }
3602  int i = slStatusSsiL(Lforks, t*1000);
3603  if(i == -2) /* error */
3604  {
3605  return TRUE;
3606  }
3607  res->data = (void*)(long)i;
3608  return FALSE;
3609 }
3611 {
3612 // input: u: a list with links of type
3613 // ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
3614 // v: timeout for select in milliseconds
3615 // or 0 for polling
3616 // returns: ERROR (via Werror): timeout negative
3617 // -1: the read state of all links is eof
3618 // 0: timeout (or polling): none ready
3619 // 1: all links are ready
3620 // (caution: at least one is ready, but some maybe dead)
3621  lists Lforks = (lists)u->CopyD();
3622  int timeout = 1000*(int)(long)v->Data();
3623  if(timeout < 0)
3624  {
3625  WerrorS("negative timeout"); return TRUE;
3626  }
3627  int t = getRTimer()/TIMER_RESOLUTION; // in seconds
3628  int i;
3629  int ret = -1;
3630  for(int nfinished = 0; nfinished < Lforks->nr+1; nfinished++)
3631  {
3632  i = slStatusSsiL(Lforks, timeout);
3633  if(i > 0) /* Lforks[i] is ready */
3634  {
3635  ret = 1;
3636  Lforks->m[i-1].CleanUp();
3637  Lforks->m[i-1].rtyp=DEF_CMD;
3638  Lforks->m[i-1].data=NULL;
3639  timeout = si_max(0,timeout - 1000*(getRTimer()/TIMER_RESOLUTION - t));
3640  }
3641  else /* terminate the for loop */
3642  {
3643  if(i == -2) /* error */
3644  {
3645  return TRUE;
3646  }
3647  if(i == 0) /* timeout */
3648  {
3649  ret = 0;
3650  }
3651  break;
3652  }
3653  }
3654  Lforks->Clean();
3655  res->data = (void*)(long)ret;
3656  return FALSE;
3657 }
3658 static BOOLEAN jjWEDGE(leftv res, leftv u, leftv v)
3659 {
3660  res->data = (char *)mp_Wedge((matrix)u->Data(),(int)(long)v->Data(),currRing);
3661  return FALSE;
3662 }
3663 #define jjWRONG2 (proc2)jjWRONG
3664 #define jjWRONG3 (proc3)jjWRONG
3666 {
3667  return TRUE;
3668 }
3669 
3670 /*=================== operations with 1 arg.: static proc =================*/
3671 /* must be ordered: first operations for chars (infix ops),
3672  * then alphabetically */
3673 
3674 static BOOLEAN jjDUMMY(leftv res, leftv u)
3675 {
3676  res->data = (char *)u->CopyD();
3677  return FALSE;
3678 }
3680 {
3681  return FALSE;
3682 }
3683 //static BOOLEAN jjPLUSPLUS(leftv res, leftv u)
3684 //{
3685 // res->data = (char *)((int)(long)u->Data()+1);
3686 // return FALSE;
3687 //}
3688 //static BOOLEAN jjMINUSMINUS(leftv res, leftv u)
3689 //{
3690 // res->data = (char *)((int)(long)u->Data()-1);
3691 // return FALSE;
3692 //}
3694 {
3695  if (IDTYP((idhdl)u->data)==INT_CMD)
3696  {
3697  int i=IDINT((idhdl)u->data);
3698  if (iiOp==PLUSPLUS) i++;
3699  else i--;
3700  IDDATA((idhdl)u->data)=(char *)(long)i;
3701  return FALSE;
3702  }
3703  return TRUE;
3704 }
3706 {
3707  number n=(number)u->CopyD(BIGINT_CMD);
3708  n=n_InpNeg(n,coeffs_BIGINT);
3709  res->data = (char *)n;
3710  return FALSE;
3711 }
3713 {
3714  res->data = (char *)(-(long)u->Data());
3715  return FALSE;
3716 }
3718 {
3719  number n=(number)u->CopyD(NUMBER_CMD);
3720  n=nInpNeg(n);
3721  res->data = (char *)n;
3722  return FALSE;
3723 }
3725 {
3726  res->data = (char *)pNeg((poly)u->CopyD(POLY_CMD));
3727  return FALSE;
3728 }
3730 {
3731  poly m1=pISet(-1);
3732  res->data = (char *)mp_MultP((matrix)u->CopyD(MATRIX_CMD),m1,currRing);
3733  return FALSE;
3734 }
3736 {
3737  intvec *iv=(intvec *)u->CopyD(INTVEC_CMD);
3738  (*iv)*=(-1);
3739  res->data = (char *)iv;
3740  return FALSE;
3741 }
3743 {
3744  bigintmat *bim=(bigintmat *)u->CopyD(BIGINTMAT_CMD);
3745  (*bim)*=(-1);
3746  res->data = (char *)bim;
3747  return FALSE;
3748 }
3749 static BOOLEAN jjPROC1(leftv res, leftv u)
3750 {
3751  return jjPROC(res,u,NULL);
3752 }
3754 {
3755  //matrix m=(matrix)v->Data();
3756  //lists l=mpBareiss(m,FALSE);
3757  intvec *iv;
3758  ideal m;
3759  sm_CallBareiss((ideal)v->Data(),0,0,m,&iv, currRing);
3761  l->Init(2);
3762  l->m[0].rtyp=MODUL_CMD;
3763  l->m[1].rtyp=INTVEC_CMD;
3764  l->m[0].data=(void *)m;
3765  l->m[1].data=(void *)iv;
3766  res->data = (char *)l;
3767  return FALSE;
3768 }
3769 //static BOOLEAN jjBAREISS_IM(leftv res, leftv v)
3770 //{
3771 // intvec *m=(intvec *)v->CopyD(INTMAT_CMD);
3772 // ivTriangMat(m);
3773 // res->data = (char *)m;
3774 // return FALSE;
3775 //}
3776 static BOOLEAN jjBI2N(leftv res, leftv u)
3777 {
3778  BOOLEAN bo=FALSE;
3779  number n=(number)u->CopyD();
3781  if (nMap!=NULL)
3782  res->data=nMap(n,coeffs_BIGINT,currRing->cf);
3783  else
3784  {
3785  Werror("cannot convert bigint to cring %s", nCoeffString(currRing->cf));
3786  bo=TRUE;
3787  }
3788  n_Delete(&n,coeffs_BIGINT);
3789  return bo;
3790 }
3791 static BOOLEAN jjBI2IM(leftv res, leftv u)
3792 {
3793  bigintmat *b=(bigintmat*)u->Data();
3794  res->data=(void *)bim2iv(b);
3795  return FALSE;
3796 }
3797 static BOOLEAN jjBI2P(leftv res, leftv u)
3798 {
3799  sleftv tmp;
3800  BOOLEAN bo=jjBI2N(&tmp,u);
3801  if (!bo)
3802  {
3803  number n=(number) tmp.data;
3804  if (nIsZero(n)) { res->data=NULL;nDelete(&n); }
3805  else
3806  {
3807  res->data=(void *)pNSet(n);
3808  }
3809  }
3810  return bo;
3811 }
3813 {
3814  return iiExprArithM(res,u,iiOp);
3815 }
3816 static BOOLEAN jjCHAR(leftv res, leftv v)
3817 {
3818  res->data = (char *)(long)rChar((ring)v->Data());
3819  return FALSE;
3820 }
3821 static BOOLEAN jjCOLS(leftv res, leftv v)
3822 {
3823  res->data = (char *)(long)MATCOLS((matrix)(v->Data()));
3824  return FALSE;
3825 }
3827 {
3828  res->data = (char *)(long)((bigintmat*)(v->Data()))->cols();
3829  return FALSE;
3830 }
3832 {
3833  res->data = (char *)(long)((intvec*)(v->Data()))->cols();
3834  return FALSE;
3835 }
3837 {
3838  // CopyD for POLY_CMD and VECTOR_CMD are identical:
3839  poly p=(poly)v->CopyD(POLY_CMD);
3840  if (p!=NULL) p_Cleardenom(p, currRing);
3841  res->data = (char *)p;
3842  return FALSE;
3843 }
3845 {
3846  res->data = (char *)(long)n_Size((number)v->Data(),coeffs_BIGINT);
3847  return FALSE;
3848 }
3850 {
3851  res->data = (char *)(long)nSize((number)v->Data());
3852  return FALSE;
3853 }
3855 {
3856  lists l=(lists)v->Data();
3857  res->data = (char *)(long)(lSize(l)+1);
3858  return FALSE;
3859 }
3861 {
3862  matrix m=(matrix)v->Data();
3863  res->data = (char *)(long)(MATROWS(m)*MATCOLS(m));
3864  return FALSE;
3865 }
3867 {
3868  res->data = (char *)(long)((intvec*)(v->Data()))->length();
3869  return FALSE;
3870 }
3872 {
3873  ring r=(ring)v->Data();
3874  int elems=-1;
3875  if (rField_is_Zp(r)||rField_is_GF(r)) elems=r->cf->ch;
3876  else if (rField_is_Zp_a(r) && (r->cf->type==n_algExt))
3877  {
3878  extern int ipower ( int b, int n ); /* factory/cf_util */
3879  elems=ipower(r->cf->ch,r->cf->extRing->pFDeg(r->cf->extRing->qideal->m[0],r->cf->extRing));
3880  }
3881  res->data = (char *)(long)elems;
3882  return FALSE;
3883 }
3884 static BOOLEAN jjDEG(leftv res, leftv v)
3885 {
3886  int dummy;
3887  poly p=(poly)v->Data();
3888  if (p!=NULL) res->data = (char *)currRing->pLDeg(p,&dummy,currRing);
3889  else res->data=(char *)-1;
3890  return FALSE;
3891 }
3892 static BOOLEAN jjDEG_M(leftv res, leftv u)
3893 {
3894  ideal I=(ideal)u->Data();
3895  int d=-1;
3896  int dummy;
3897  int i;
3898  for(i=IDELEMS(I)-1;i>=0;i--)
3899  if (I->m[i]!=NULL) d=si_max(d,(int)currRing->pLDeg(I->m[i],&dummy,currRing));
3900  res->data = (char *)(long)d;
3901  return FALSE;
3902 }
3903 static BOOLEAN jjDEGREE(leftv res, leftv v)
3904 {
3905  SPrintStart();
3906 #ifdef HAVE_RINGS
3908  {
3909  ring origR = currRing;
3910  ring tempR = rCopy(origR);
3911  coeffs new_cf=nInitChar(n_Q,NULL);
3912  nKillChar(tempR->cf);
3913  tempR->cf=new_cf;
3914  rComplete(tempR);
3915  ideal vid = (ideal)v->Data();
3916  rChangeCurrRing(tempR);
3917  ideal vv = idrCopyR(vid, origR, currRing);
3918  sleftv vvAsLeftv; memset(&vvAsLeftv, 0, sizeof(vvAsLeftv));
3919  vvAsLeftv.rtyp = IDEAL_CMD;
3920  vvAsLeftv.data = vv; vvAsLeftv.next = NULL;
3921  if (hasFlag(v, FLAG_STD)) setFlag(&vvAsLeftv,FLAG_STD);
3922  assumeStdFlag(&vvAsLeftv);
3923  Print("// NOTE: computation of degree is being performed for\n");
3924  Print("// generic fibre, that is, over Q\n");
3925  intvec *module_w=(intvec*)atGet(&vvAsLeftv,"isHomog",INTVEC_CMD);
3926  scDegree(vv,module_w,currRing->qideal);
3927  idDelete(&vv);
3928  rChangeCurrRing(origR);
3929  rDelete(tempR);
3930  }
3931 #endif
3932  assumeStdFlag(v);
3933  intvec *module_w=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
3934  scDegree((ideal)v->Data(),module_w,currRing->qideal);
3935  char *s=SPrintEnd();
3936  int l=strlen(s)-1;
3937  s[l]='\0';
3938  res->data=(void*)s;
3939  return FALSE;
3940 }
3942 {
3943  if ((v->rtyp==IDHDL)
3944  && ((myynest==IDLEV((idhdl)v->data))||(0==IDLEV((idhdl)v->data))))
3945  {
3946  res->data=(void *)(long)(IDLEV((idhdl)v->data)+1);
3947  }
3948  else if (v->rtyp!=0) res->data=(void *)(-1);
3949  return FALSE;
3950 }
3951 
3952 /// Return the denominator of the input number
3953 /// NOTE: the input number is normalized as a side effect
3955 {
3956  number n = reinterpret_cast<number>(v->Data());
3957  res->data = reinterpret_cast<void*>(n_GetDenom(n, currRing));
3958  return FALSE;
3959 }
3960 
3961 /// Return the numerator of the input number
3962 /// NOTE: the input number is normalized as a side effect
3964 {
3965  number n = reinterpret_cast<number>(v->Data());
3966  res->data = reinterpret_cast<void*>(n_GetNumerator(n, currRing));
3967  return FALSE;
3968 }
3969 
3970 static BOOLEAN jjDET(leftv res, leftv v)
3971 {
3972  matrix m=(matrix)v->Data();
3973  poly p;
3974  if (sm_CheckDet((ideal)m,m->cols(),TRUE, currRing))
3975  {
3977  p=sm_CallDet(I, currRing);
3978  idDelete(&I);
3979  }
3980  else
3981  p=singclap_det(m,currRing);
3982  res ->data = (char *)p;
3983  return FALSE;
3984 }
3985 static BOOLEAN jjDET_BI(leftv res, leftv v)
3986 {
3987  bigintmat * m=(bigintmat*)v->Data();
3988  int i,j;
3989  i=m->rows();j=m->cols();
3990  if(i==j)
3991  res->data = (char *)(long)singclap_det_bi(m,coeffs_BIGINT);
3992  else
3993  {
3994  Werror("det of %d x %d bigintmat",i,j);
3995  return TRUE;
3996  }
3997  return FALSE;
3998 }
3999 static BOOLEAN jjDET_I(leftv res, leftv v)
4000 {
4001  intvec * m=(intvec*)v->Data();
4002  int i,j;
4003  i=m->rows();j=m->cols();
4004  if(i==j)
4005  res->data = (char *)(long)singclap_det_i(m,currRing);
4006  else
4007  {
4008  Werror("det of %d x %d intmat",i,j);
4009  return TRUE;
4010  }
4011  return FALSE;
4012 }
4013 static BOOLEAN jjDET_S(leftv res, leftv v)
4014 {
4015  ideal I=(ideal)v->Data();
4016  poly p;
4017  if (IDELEMS(I)<1) return TRUE;
4018  if (sm_CheckDet(I,IDELEMS(I),FALSE, currRing))
4019  {
4021  p=singclap_det(m,currRing);
4022  idDelete((ideal *)&m);
4023  }
4024  else
4025  p=sm_CallDet(I, currRing);
4026  res->data = (char *)p;
4027  return FALSE;
4028 }
4029 static BOOLEAN jjDIM(leftv res, leftv v)
4030 {
4031  assumeStdFlag(v);
4032 #ifdef HAVE_RINGS
4033  if (rField_is_Ring(currRing))
4034  {
4035  //ring origR = currRing;
4036  //ring tempR = rCopy(origR);
4037  //coeffs new_cf=nInitChar(n_Q,NULL);
4038  //nKillChar(tempR->cf);
4039  //tempR->cf=new_cf;
4040  //rComplete(tempR);
4041  ideal vid = (ideal)v->Data();
4042  int i = idPosConstant(vid);
4043  if ((i != -1) && (n_IsUnit(pGetCoeff(vid->m[i]),currRing->cf)))
4044  { /* ideal v contains unit; dim = -1 */
4045  res->data = (char *)-1;
4046  return FALSE;
4047  }
4048  //rChangeCurrRing(tempR);
4049  //ideal vv = idrCopyR(vid, origR, currRing);
4050  ideal vv = id_Head(vid,currRing);
4051  /* drop degree zero generator from vv (if any) */
4052  if (i != -1) pDelete(&vv->m[i]);
4053  long d = (long)scDimInt(vv, currRing->qideal);
4054  if (rField_is_Ring_Z(currRing) && (i == -1)) d++;
4055  res->data = (char *)d;
4056  idDelete(&vv);
4057  //rChangeCurrRing(origR);
4058  //rDelete(tempR);
4059  return FALSE;
4060  }
4061 #endif
4062  res->data = (char *)(long)scDimInt((ideal)(v->Data()),currRing->qideal);
4063  return FALSE;
4064 }
4066 {
4067  si_link l = (si_link)v->Data();
4068  if (slDump(l))
4069  {
4070  const char *s;
4071  if ((l!=NULL)&&(l->name!=NULL)) s=l->name;
4072  else s=sNoName;
4073  Werror("cannot dump to `%s`",s);
4074  return TRUE;
4075  }
4076  else
4077  return FALSE;
4078 }
4079 static BOOLEAN jjE(leftv res, leftv v)
4080 {
4081  res->data = (char *)pOne();
4082  int co=(int)(long)v->Data();
4083  if (co>0)
4084  {
4085  pSetComp((poly)res->data,co);
4086  pSetm((poly)res->data);
4087  }
4088  else WerrorS("argument of gen must be positive");
4089  return (co<=0);
4090 }
4092 {
4093  char * d = (char *)v->Data();
4094  char * s = (char *)omAlloc(strlen(d) + 13);
4095  strcpy( s, (char *)d);
4096  strcat( s, "\n;RETURN();\n");
4097  newBuffer(s,BT_execute);
4098  return yyparse();
4099 }
4100 static BOOLEAN jjFACSTD(leftv res, leftv v)
4101 {
4103  if (currRing->cf->convSingNFactoryN!=NULL) /* conversion to factory*/
4104  {
4105  ideal_list p,h;
4106  h=kStdfac((ideal)v->Data(),NULL,testHomog,NULL);
4107  if (h==NULL)
4108  {
4109  L->Init(1);
4110  L->m[0].data=(char *)idInit(1);
4111  L->m[0].rtyp=IDEAL_CMD;
4112  }
4113  else
4114  {
4115  p=h;
4116  int l=0;
4117  while (p!=NULL) { p=p->next;l++; }
4118  L->Init(l);
4119  l=0;
4120  while(h!=NULL)
4121  {
4122  L->m[l].data=(char *)h->d;
4123  L->m[l].rtyp=IDEAL_CMD;
4124  p=h->next;
4125  omFreeSize(h,sizeof(*h));
4126  h=p;
4127  l++;
4128  }
4129  }
4130  }
4131  else
4132  {
4133  WarnS("no factorization implemented");
4134  L->Init(1);
4135  iiExprArith1(&(L->m[0]),v,STD_CMD);
4136  }
4137  res->data=(void *)L;
4138  return FALSE;
4139 }
4140 static BOOLEAN jjFAC_P(leftv res, leftv u)
4141 {
4142  intvec *v=NULL;
4144  ideal f=singclap_factorize((poly)(u->CopyD()), &v, 0,currRing);
4145  if (f==NULL) return TRUE;
4146  ivTest(v);
4148  l->Init(2);
4149  l->m[0].rtyp=IDEAL_CMD;
4150  l->m[0].data=(void *)f;
4151  l->m[1].rtyp=INTVEC_CMD;
4152  l->m[1].data=(void *)v;
4153  res->data=(void *)l;
4154  return FALSE;
4155 }
4157 {
4158  si_link l = (si_link)v->Data();
4159  if (slGetDump(l))
4160  {
4161  const char *s;
4162  if ((l!=NULL)&&(l->name!=NULL)) s=l->name;
4163  else s=sNoName;
4164  Werror("cannot get dump from `%s`",s);
4165  return TRUE;
4166  }
4167  else
4168  return FALSE;
4169 }
4171 {
4172  assumeStdFlag(v);
4173  ideal I=(ideal)v->Data();
4174  res->data=(void *)iiHighCorner(I,0);
4175  return FALSE;
4176 }
4178 {
4179  assumeStdFlag(v);
4180  intvec *w=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
4181  BOOLEAN delete_w=FALSE;
4182  ideal I=(ideal)v->Data();
4183  int i;
4184  poly p=NULL,po=NULL;
4185  int rk=id_RankFreeModule(I,currRing);
4186  if (w==NULL)
4187  {
4188  w = new intvec(rk);
4189  delete_w=TRUE;
4190  }
4191  for(i=rk;i>0;i--)
4192  {
4193  p=iiHighCorner(I,i);
4194  if (p==NULL)
4195  {
4196  WerrorS("module must be zero-dimensional");
4197  if (delete_w) delete w;
4198  return TRUE;
4199  }
4200  if (po==NULL)
4201  {
4202  po=p;
4203  }
4204  else
4205  {
4206  // now po!=NULL, p!=NULL
4207  int d=(currRing->pFDeg(po,currRing)-(*w)[pGetComp(po)-1] - currRing->pFDeg(p,currRing)+(*w)[i-1]);
4208  if (d==0)
4209  d=pLmCmp(po,p);
4210  if (d > 0)
4211  {
4212  pDelete(&p);
4213  }
4214  else // (d < 0)
4215  {
4216  pDelete(&po); po=p;
4217  }
4218  }
4219  }
4220  if (delete_w) delete w;
4221  res->data=(void *)po;
4222  return FALSE;
4223 }
4225 {
4226 #ifdef HAVE_RINGS
4228  {
4229  ring origR = currRing;
4230  ring tempR = rCopy(origR);
4231  coeffs new_cf=nInitChar(n_Q,NULL);
4232  nKillChar(tempR->cf);
4233  tempR->cf=new_cf;
4234  rComplete(tempR);
4235  ideal vid = (ideal)v->Data();
4236  rChangeCurrRing(tempR);
4237  ideal vv = idrCopyR(vid, origR, currRing);
4238  sleftv vvAsLeftv; memset(&vvAsLeftv, 0, sizeof(vvAsLeftv));
4239  vvAsLeftv.rtyp = IDEAL_CMD;
4240  vvAsLeftv.data = vv; vvAsLeftv.next = NULL;
4241  if (hasFlag(v, FLAG_STD)) setFlag(&vvAsLeftv,FLAG_STD);
4242  assumeStdFlag(&vvAsLeftv);
4243  Print("// NOTE: computation of Hilbert series etc. is being\n");
4244  Print("// performed for generic fibre, that is, over Q\n");
4245  intvec *module_w=(intvec*)atGet(&vvAsLeftv,"isHomog",INTVEC_CMD);
4246  //scHilbertPoly(vv,currRing->qideal);
4247  hLookSeries(vv,module_w,currRing->qideal);
4248  idDelete(&vv);
4249  rChangeCurrRing(origR);
4250  rDelete(tempR);
4251  return FALSE;
4252  }
4253 #endif
4254  assumeStdFlag(v);
4255  intvec *module_w=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
4256  //scHilbertPoly((ideal)v->Data(),currRing->qideal);
4257  hLookSeries((ideal)v->Data(),module_w,currRing->qideal);
4258  return FALSE;
4259 }
4261 {
4262 #ifdef HAVE_RINGS
4264  {
4265  Print("// NOTE: computation of Hilbert series etc. is being\n");
4266  Print("// performed for generic fibre, that is, over Q\n");
4267  }
4268 #endif
4269  res->data=(void *)hSecondSeries((intvec *)v->Data());
4270  return FALSE;
4271 }
4272 static BOOLEAN jjHOMOG1(leftv res, leftv v)
4273 {
4274  intvec *w=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
4275  ideal v_id=(ideal)v->Data();
4276  if (w==NULL)
4277  {
4278  res->data=(void *)(long)idHomModule(v_id,currRing->qideal,&w);
4279  if (res->data!=NULL)
4280  {
4281  if (v->rtyp==IDHDL)
4282  {
4283  char *s_isHomog=omStrDup("isHomog");
4284  if (v->e==NULL)
4285  atSet((idhdl)(v->data),s_isHomog,w,INTVEC_CMD);
4286  else
4287  atSet((idhdl)(v->LData()),s_isHomog,w,INTVEC_CMD);
4288  }
4289  else if (w!=NULL) delete w;
4290  } // if res->data==NULL then w==NULL
4291  }
4292  else
4293  {
4294  res->data=(void *)(long)idTestHomModule(v_id,currRing->qideal,w);
4295  if((res->data==NULL) && (v->rtyp==IDHDL))
4296  {
4297  if (v->e==NULL)
4298  atKill((idhdl)(v->data),"isHomog");
4299  else
4300  atKill((idhdl)(v->LData()),"isHomog");
4301  }
4302  }
4303  return FALSE;
4304 }
4306 {
4307  res->data = (char *)idMaxIdeal((int)(long)v->Data());
4308  setFlag(res,FLAG_STD);
4309  return FALSE;
4310 }
4312 {
4313  matrix mat=(matrix)v->CopyD(MATRIX_CMD);
4314  IDELEMS((ideal)mat)=MATCOLS(mat)*MATROWS(mat);
4315  if (IDELEMS((ideal)mat)==0)
4316  {
4317  idDelete((ideal *)&mat);
4318  mat=(matrix)idInit(1,1);
4319  }
4320  else
4321  {
4322  MATROWS(mat)=1;
4323  mat->rank=1;
4324  idTest((ideal)mat);
4325  }
4326  res->data=(char *)mat;
4327  return FALSE;
4328 }
4330 {
4331  map m=(map)v->CopyD(MAP_CMD);
4332  omFree((ADDRESS)m->preimage);
4333  m->preimage=NULL;
4334  ideal I=(ideal)m;
4335  I->rank=1;
4336  res->data=(char *)I;
4337  return FALSE;
4338 }
4340 {
4341  if (currRing!=NULL)
4342  {
4343  ring q=(ring)v->Data();
4344  if (rSamePolyRep(currRing, q))
4345  {
4346  if (q->qideal==NULL)
4347  res->data=(char *)idInit(1,1);
4348  else
4349  res->data=(char *)idCopy(q->qideal);
4350  return FALSE;
4351  }
4352  }
4353  WerrorS("can only get ideal from identical qring");
4354  return TRUE;
4355 }
4356 static BOOLEAN jjIm2Iv(leftv res, leftv v)
4357 {
4358  intvec *iv = (intvec *)v->CopyD(INTMAT_CMD);
4359  iv->makeVector();
4360  res->data = iv;
4361  return FALSE;
4362 }
4363 static BOOLEAN jjIMPART(leftv res, leftv v)
4364 {
4365  res->data = (char *)n_ImPart((number)v->Data(),currRing->cf);
4366  return FALSE;
4367 }
4369 {
4370  assumeStdFlag(v);
4371  res->data=(void *)scIndIntvec((ideal)(v->Data()),currRing->qideal);
4372  return FALSE;
4373 }
4375 {
4376  ideal result=kInterRed((ideal)(v->Data()), currRing->qideal);
4377  #ifdef HAVE_RINGS
4379  Warn("interred: this command is experimental over the integers");
4380  #endif
4381  if (TEST_OPT_PROT) { PrintLn(); mflush(); }
4382  res->data = result;
4383  return FALSE;
4384 }
4386 {
4387  res->data = (char *)(long)pVar((poly)v->Data());
4388  return FALSE;
4389 }
4391 {
4392  res->data = (char *)(long)(r_IsRingVar((char *)v->Data(), currRing->names,
4393  currRing->N)+1);
4394  return FALSE;
4395 }
4397 {
4398  res->data = (char *)0;
4399  return FALSE;
4400 }
4402 {
4403  ideal i=idInit(currRing->N,1);
4404  int k;
4405  poly p=(poly)(v->Data());
4406  for (k=currRing->N;k>0;k--)
4407  {
4408  i->m[k-1]=pDiff(p,k);
4409  }
4410  res->data = (char *)i;
4411  return FALSE;
4412 }
4414 {
4415  if (!nCoeff_is_transExt(currRing->cf))
4416  {
4417  WerrorS("differentiation not defined in the coefficient ring");
4418  return TRUE;
4419  }
4420  number n = (number) u->Data();
4421  number k = (number) v->Data();
4422  res->data = ntDiff(n,k,currRing->cf);
4423  return FALSE;
4424 }
4425 /*2
4426  * compute Jacobi matrix of a module/matrix
4427  * Jacobi(M) := ( diff(Mt,var(1))|, ... ,| diff(Mt,var(currRing->N)) ),
4428  * where Mt := transpose(M)
4429  * Note that this is consistent with the current conventions for jacob in Singular,
4430  * whereas M2 computes its transposed.
4431  */
4433 {
4434  ideal id = (ideal)a->Data();
4435  id = id_Transp(id,currRing);
4436  int W = IDELEMS(id);
4437 
4438  ideal result = idInit(W * currRing->N, id->rank);
4439  poly *p = result->m;
4440 
4441  for( int v = 1; v <= currRing->N; v++ )
4442  {
4443  poly* q = id->m;
4444  for( int i = 0; i < W; i++, p++, q++ )
4445  *p = pDiff( *q, v );
4446  }
4447  idDelete(&id);
4448 
4449  res->data = (char *)result;
4450  return FALSE;
4451 }
4452 
4453 
4454 static BOOLEAN jjKBASE(leftv res, leftv v)
4455 {
4456  assumeStdFlag(v);
4457  res->data = (char *)scKBase(-1,(ideal)(v->Data()),currRing->qideal);
4458  return FALSE;
4459 }
4460 static BOOLEAN jjL2R(leftv res, leftv v)
4461 {
4462  res->data=(char *)syConvList((lists)v->Data(),FALSE);
4463  if (res->data != NULL)
4464  return FALSE;
4465  else
4466  return TRUE;
4467 }
4469 {
4470  poly p=(poly)v->Data();
4471  if (p==NULL)
4472  {
4473  res->data=(char *)nInit(0);
4474  }
4475  else
4476  {
4477  res->data=(char *)nCopy(pGetCoeff(p));
4478  }
4479  return FALSE;
4480 }
4482 {
4483  poly p=(poly)v->Data();
4484  int s=currRing->N;
4485  if (v->Typ()==VECTOR_CMD) s++;
4486  intvec *iv=new intvec(s);
4487  if (p!=NULL)
4488  {
4489  for(int i = currRing->N;i;i--)
4490  {
4491  (*iv)[i-1]=pGetExp(p,i);
4492  }
4493  if (s!=currRing->N)
4494  (*iv)[currRing->N]=pGetComp(p);
4495  }
4496  res->data=(char *)iv;
4497  return FALSE;
4498 }
4500 {
4501  poly p=(poly)v->Data();
4502  if (p == NULL)
4503  {
4504  res->data = (char*) NULL;
4505  }
4506  else
4507  {
4508  poly lm = pLmInit(p);
4509  pSetCoeff(lm, nInit(1));
4510  res->data = (char*) lm;
4511  }
4512  return FALSE;
4513 }
4514 static BOOLEAN jjLOAD1(leftv /*res*/, leftv v)
4515 {
4516  return jjLOAD((char*)v->Data(),FALSE);
4517 }
4519 {
4520  ring r=rCompose((lists)v->Data());
4521  if (r==NULL) return TRUE;
4522  if (r->qideal!=NULL) res->rtyp=QRING_CMD;
4523  res->data=(char *)r;
4524  return FALSE;
4525 }
4526 static BOOLEAN jjPFAC1(leftv res, leftv v)
4527 {
4528  /* call method jjPFAC2 with second argument = 0 (meaning that no
4529  valid bound for the prime factors has been given) */
4530  sleftv tmp;
4531  memset(&tmp, 0, sizeof(tmp));
4532  tmp.rtyp = INT_CMD;
4533  return jjPFAC2(res, v, &tmp);
4534 }
4536 {
4537  /* computes the LU-decomposition of a matrix M;
4538  i.e., M = P * L * U, where
4539  - P is a row permutation matrix,
4540  - L is in lower triangular form,
4541  - U is in upper row echelon form
4542  Then, we also have P * M = L * U.
4543  A list [P, L, U] is returned. */
4544  matrix mat = (const matrix)v->Data();
4545  if (!idIsConstant((ideal)mat))
4546  {
4547  WerrorS("matrix must be constant");
4548  return TRUE;
4549  }
4550  matrix pMat;
4551  matrix lMat;
4552  matrix uMat;
4553 
4554  luDecomp(mat, pMat, lMat, uMat);
4555 
4557  ll->Init(3);
4558  ll->m[0].rtyp=MATRIX_CMD; ll->m[0].data=(void *)pMat;
4559  ll->m[1].rtyp=MATRIX_CMD; ll->m[1].data=(void *)lMat;
4560  ll->m[2].rtyp=MATRIX_CMD; ll->m[2].data=(void *)uMat;
4561  res->data=(char*)ll;
4562 
4563  return FALSE;
4564 }
4565 static BOOLEAN jjMEMORY(leftv res, leftv v)
4566 {
4567  omUpdateInfo();
4568  switch(((int)(long)v->Data()))
4569  {
4570  case 0:
4571  res->data=(char *)n_Init(om_Info.UsedBytes,coeffs_BIGINT);
4572  break;
4573  case 1:
4574  res->data = (char *)n_Init(om_Info.CurrentBytesSystem,coeffs_BIGINT);
4575  break;
4576  case 2:
4577  res->data = (char *)n_Init(om_Info.MaxBytesSystem,coeffs_BIGINT);
4578  break;
4579  default:
4580  omPrintStats(stdout);
4581  omPrintInfo(stdout);
4582  omPrintBinStats(stdout);
4583  res->data = (char *)0;
4584  res->rtyp = NONE;
4585  }
4586  return FALSE;
4587  res->data = (char *)0;
4588  return FALSE;
4589 }
4590 //static BOOLEAN jjMONITOR1(leftv res, leftv v)
4591 //{
4592 // return jjMONITOR2(res,v,NULL);
4593 //}
4594 static BOOLEAN jjMSTD(leftv res, leftv v)
4595 {
4596  int t=v->Typ();
4597  ideal r,m;
4598  r=kMin_std((ideal)v->Data(),currRing->qideal,testHomog,NULL,m);
4600  l->Init(2);
4601  l->m[0].rtyp=t;
4602  l->m[0].data=(char *)r;
4603  setFlag(&(l->m[0]),FLAG_STD);
4604  l->m[1].rtyp=t;
4605  l->m[1].data=(char *)m;
4606  res->data=(char *)l;
4607  return FALSE;
4608 }
4609 static BOOLEAN jjMULT(leftv res, leftv v)
4610 {
4611  assumeStdFlag(v);
4612  res->data = (char *)(long)scMultInt((ideal)(v->Data()),currRing->qideal);
4613  return FALSE;
4614 }
4616 {
4617  intvec *weights=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
4618 
4619  syStrategy tmp=(syStrategy)v->Data();
4620  tmp = syMinimize(tmp); // enrich itself!
4621 
4622  res->data=(char *)tmp;
4623 
4624  if (weights!=NULL)
4625  atSet(res, omStrDup("isHomog"),ivCopy(weights),INTVEC_CMD);
4626 
4627  return FALSE;
4628 }
4629 static BOOLEAN jjN2BI(leftv res, leftv v)
4630 {
4631  number n,i; i=(number)v->Data();
4633  if (nMap!=NULL)
4634  n=nMap(i,currRing->cf,coeffs_BIGINT);
4635  else goto err;
4636  res->data=(void *)n;
4637  return FALSE;
4638 err:
4639  WerrorS("cannot convert to bigint"); return TRUE;
4640 }
4641 static BOOLEAN jjNAMEOF(leftv res, leftv v)
4642 {
4643  res->data = (char *)v->name;
4644  if (res->data==NULL) res->data=omStrDup("");
4645  v->name=NULL;
4646  return FALSE;
4647 }
4648 static BOOLEAN jjNAMES(leftv res, leftv v)
4649 {
4650  res->data=ipNameList(((ring)v->Data())->idroot);
4651  return FALSE;
4652 }
4654 {
4655  res->data=ipNameListLev((IDROOT),(int)(long)v->Data());
4656  return FALSE;
4657 }
4658 static BOOLEAN jjNOT(leftv res, leftv v)
4659 {
4660  res->data=(char*)(long)((long)v->Data()==0 ? 1 : 0);
4661  return FALSE;
4662 }
4663 static BOOLEAN jjNVARS(leftv res, leftv v)
4664 {
4665  res->data = (char *)(long)(((ring)(v->Data()))->N);
4666  return FALSE;
4667 }
4669 {
4670  si_link l=(si_link)v->Data();
4671  if (iiOp==OPEN_CMD) return slOpen(l, SI_LINK_OPEN,v);
4672  else return slClose(l);
4673 }
4674 static BOOLEAN jjORD(leftv res, leftv v)
4675 {
4676  poly p=(poly)v->Data();
4677  res->data=(char *)( p==NULL ? -1 : currRing->pFDeg(p,currRing) );
4678  return FALSE;
4679 }
4680 static BOOLEAN jjPAR1(leftv res, leftv v)
4681 {
4682  int i=(int)(long)v->Data();
4683  int p=0;
4684  p=rPar(currRing);
4685  if ((0<i) && (i<=p))
4686  {
4687  res->data=(char *)n_Param(i,currRing);
4688  }
4689  else
4690  {
4691  Werror("par number %d out of range 1..%d",i,p);
4692  return TRUE;
4693  }
4694  return FALSE;
4695 }
4696 static BOOLEAN jjPARDEG(leftv res, leftv v)
4697 {
4698  number nn=(number)v->Data();
4699  res->data = (char *)(long)n_ParDeg(nn, currRing);
4700  return FALSE;
4701 }
4703 {
4704  if (currRing==NULL)
4705  {
4706  WerrorS("no ring active");
4707  return TRUE;
4708  }
4709  int i=(int)(long)v->Data();
4710  int p=0;
4711  if ((0<i) && (rParameter(currRing)!=NULL) && (i<=(p=rPar(currRing))))
4712  res->data=omStrDup(rParameter(currRing)[i-1]);
4713  else
4714  {
4715  Werror("par number %d out of range 1..%d",i,p);
4716  return TRUE;
4717  }
4718  return FALSE;
4719 }
4720 static BOOLEAN jjP2BI(leftv res, leftv v)
4721 {
4722  poly p=(poly)v->Data();
4723  if (p==NULL) { res->data=(char *)n_Init(0,coeffs_BIGINT); return FALSE; }
4724  if ((pNext(p)!=NULL)|| (!pIsConstant(p)))
4725  {
4726  WerrorS("poly must be constant");
4727  return TRUE;
4728  }
4729  number i=pGetCoeff(p);
4730  number n;
4732  if (nMap!=NULL)
4733  n=nMap(i,currRing->cf,coeffs_BIGINT);
4734  else goto err;
4735  res->data=(void *)n;
4736  return FALSE;
4737 err:
4738  WerrorS("cannot convert to bigint"); return TRUE;
4739 }
4740 static BOOLEAN jjP2I(leftv res, leftv v)
4741 {
4742  poly p=(poly)v->Data();
4743  if (p==NULL) { /*res->data=(char *)0;*/ return FALSE; }
4744  if ((pNext(p)!=NULL)|| (!pIsConstant(p)))
4745  {
4746  WerrorS("poly must be constant");
4747  return TRUE;
4748  }
4749  res->data = (char *)(long)iin_Int(pGetCoeff(p),currRing->cf);
4750  return FALSE;
4751 }
4753 {
4754  map mapping=(map)v->Data();
4755  syMake(res,omStrDup(mapping->preimage));
4756  return FALSE;
4757 }
4758 static BOOLEAN jjPRIME(leftv res, leftv v)
4759 {
4760  int i = IsPrime((int)(long)(v->Data()));
4761  res->data = (char *)(long)(i > 1 ? i : 2);
4762  return FALSE;
4763 }
4764 static BOOLEAN jjPRUNE(leftv res, leftv v)
4765 {
4766  intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
4767  ideal v_id=(ideal)v->Data();
4768  if (w!=NULL)
4769  {
4770  if (!idTestHomModule(v_id,currRing->qideal,w))
4771  {
4772  WarnS("wrong weights");
4773  w=NULL;
4774  // and continue at the non-homog case below
4775  }
4776  else
4777  {
4778  w=ivCopy(w);
4779  intvec **ww=&w;
4780  res->data = (char *)idMinEmbedding(v_id,FALSE,ww);
4781  atSet(res,omStrDup("isHomog"),*ww,INTVEC_CMD);
4782  return FALSE;
4783  }
4784  }
4785  res->data = (char *)idMinEmbedding(v_id);
4786  return FALSE;
4787 }
4788 static BOOLEAN jjP2N(leftv res, leftv v)
4789 {
4790  number n;
4791  poly p;
4792  if (((p=(poly)v->Data())!=NULL)
4793  && (pIsConstant(p)))
4794  {
4795  n=nCopy(pGetCoeff(p));
4796  }
4797  else
4798  {
4799  n=nInit(0);
4800  }
4801  res->data = (char *)n;
4802  return FALSE;
4803 }
4805 {
4806  char *s= (char *)v->Data();
4807  int i = 1;
4808  for(i=0; i<sArithBase.nCmdUsed; i++)
4809  {
4810  //Print("test %d, >>%s<<, tab:>>%s<<\n",i,s,sArithBase.sCmds[i].name);
4811  if (strcmp(s, sArithBase.sCmds[i].name) == 0)
4812  {
4813  res->data = (char *)1;
4814  return FALSE;
4815  }
4816  }
4817  //res->data = (char *)0;
4818  return FALSE;
4819 }
4820 static BOOLEAN jjRANK1(leftv res, leftv v)
4821 {
4822  matrix m =(matrix)v->Data();
4823  int rank = luRank(m, 0);
4824  res->data =(char *)(long)rank;
4825  return FALSE;
4826 }
4827 static BOOLEAN jjREAD(leftv res, leftv v)
4828 {
4829  return jjREAD2(res,v,NULL);
4830 }
4832 {
4833  res->data = (char *)(long)iiRegularity((lists)v->Data());
4834  return FALSE;
4835 }
4836 static BOOLEAN jjREPART(leftv res, leftv v)
4837 {
4838  res->data = (char *)n_RePart((number)v->Data(),currRing->cf);
4839  return FALSE;
4840 }
4842 {
4843  ring r=(ring)v->Data();
4844  if (r!=NULL)
4845  res->data = (char *)rDecompose((ring)v->Data());
4846  return (r==NULL)||(res->data==NULL);
4847 }
4848 #ifdef SINGULAR_4_1
4850 {
4851  coeffs r=(coeffs)v->Data();
4852  if (r!=NULL)
4853  return rDecompose_CF(res,r);
4854  return TRUE;
4855 }
4856 #endif
4857 static BOOLEAN jjROWS(leftv res, leftv v)
4858 {
4859  ideal i = (ideal)v->Data();
4860  res->data = (char *)i->rank;
4861  return FALSE;
4862 }
4864 {
4865  res->data = (char *)(long)((bigintmat*)(v->Data()))->rows();
4866  return FALSE;
4867 }
4869 {
4870  res->data = (char *)(long)((intvec*)(v->Data()))->rows();
4871  return FALSE;
4872 }
4873 static BOOLEAN jjRPAR(leftv res, leftv v)
4874 {
4875  res->data = (char *)(long)rPar(((ring)v->Data()));
4876  return FALSE;
4877 }
4879 {
4880 #ifdef HAVE_PLURAL
4881  const bool bIsSCA = rIsSCA(currRing);
4882 #else
4883  const bool bIsSCA = false;
4884 #endif
4885 
4886  if ((currRing->qideal!=NULL) && !bIsSCA)
4887  {
4888  WerrorS("qring not supported by slimgb at the moment");
4889  return TRUE;
4890  }
4892  {
4893  WerrorS("ordering must be global for slimgb");
4894  return TRUE;
4895  }
4896  intvec *w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
4897  // tHomog hom=testHomog;
4898  ideal u_id=(ideal)u->Data();
4899  if (w!=NULL)
4900  {
4901  if (!idTestHomModule(u_id,currRing->qideal,w))
4902  {
4903  WarnS("wrong weights");
4904  w=NULL;
4905  }
4906  else
4907  {
4908  w=ivCopy(w);
4909  // hom=isHomog;
4910  }
4911  }
4912 
4913  assume(u_id->rank>=id_RankFreeModule(u_id, currRing));
4914  res->data=(char *)t_rep_gb(currRing,
4915  u_id,u_id->rank);
4916  //res->data=(char *)t_rep_gb(currRing, u_id);
4917 
4919  if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
4920  return FALSE;
4921 }
4922 static BOOLEAN jjSBA(leftv res, leftv v)
4923 {
4924  ideal result;
4925  ideal v_id=(ideal)v->Data();
4926  intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
4927  tHomog hom=testHomog;
4928  if (w!=NULL)
4929  {
4930  if (!idTestHomModule(v_id,currRing->qideal,w))
4931  {
4932  WarnS("wrong weights");
4933  w=NULL;
4934  }
4935  else
4936  {
4937  hom=isHomog;
4938  w=ivCopy(w);
4939  }
4940  }
4941  result=kSba(v_id,currRing->qideal,hom,&w,1,0);
4942  idSkipZeroes(result);
4943  res->data = (char *)result;
4945  if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
4946  return FALSE;
4947 }
4948 static BOOLEAN jjSBA_1(leftv res, leftv v, leftv u)
4949 {
4950  ideal result;
4951  ideal v_id=(ideal)v->Data();
4952  intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
4953  tHomog hom=testHomog;
4954  if (w!=NULL)
4955  {
4956  if (!idTestHomModule(v_id,currRing->qideal,w))
4957  {
4958  WarnS("wrong weights");
4959  w=NULL;
4960  }
4961  else
4962  {
4963  hom=isHomog;
4964  w=ivCopy(w);
4965  }
4966  }
4967  result=kSba(v_id,currRing->qideal,hom,&w,(int)(long)u->Data(),0);
4968  idSkipZeroes(result);
4969  res->data = (char *)result;
4971  if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
4972  return FALSE;
4973 }
4974 static BOOLEAN jjSBA_2(leftv res, leftv v, leftv u, leftv t)
4975 {
4976  ideal result;
4977  ideal v_id=(ideal)v->Data();
4978  intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
4979  tHomog hom=testHomog;
4980  if (w!=NULL)
4981  {
4982  if (!idTestHomModule(v_id,currRing->qideal,w))
4983  {
4984  WarnS("wrong weights");
4985  w=NULL;
4986  }
4987  else
4988  {
4989  hom=isHomog;
4990  w=ivCopy(w);
4991  }
4992  }
4993  result=kSba(v_id,currRing->qideal,hom,&w,(int)(long)u->Data(),(int)(long)t->Data());
4994  idSkipZeroes(result);
4995  res->data = (char *)result;
4997  if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
4998  return FALSE;
4999 }
5000 static BOOLEAN jjSTD(leftv res, leftv v)
5001 {
5002  ideal result;
5003  ideal v_id=(ideal)v->Data();
5004  intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
5005  tHomog hom=testHomog;
5006  if (w!=NULL)
5007  {
5008  if (!idTestHomModule(v_id,currRing->qideal,w))
5009  {
5010  WarnS("wrong weights");
5011  w=NULL;
5012  }
5013  else
5014  {
5015  hom=isHomog;
5016  w=ivCopy(w);
5017  }
5018  }
5019  result=kStd(v_id,currRing->qideal,hom,&w);
5020  idSkipZeroes(result);
5021  res->data = (char *)result;
5023  if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
5024  return FALSE;
5025 }
5027 {
5028  res->data = (char *)idSort((ideal)v->Data());
5029  return FALSE;
5030 }
5032 {
5034  intvec *v=NULL;
5035  ideal f=singclap_sqrfree((poly)(u->CopyD()), &v, 0, currRing);
5036  if (f==NULL) return TRUE;
5037  ivTest(v);
5039  l->Init(2);
5040  l->m[0].rtyp=IDEAL_CMD;
5041  l->m[0].data=(void *)f;
5042  l->m[1].rtyp=INTVEC_CMD;
5043  l->m[1].data=(void *)v;
5044  res->data=(void *)l;
5045  return FALSE;
5046 }
5047 #if 1
5048 static BOOLEAN jjSYZYGY(leftv res, leftv v)
5049 {
5050  intvec *w=NULL;
5051  res->data = (char *)idSyzygies((ideal)v->Data(),testHomog,&w);
5052  if (w!=NULL) delete w;
5054  return FALSE;
5055 }
5056 #else
5057 // activate, if idSyz handle module weights correctly !
5058 static BOOLEAN jjSYZYGY(leftv res, leftv v)
5059 {
5060  intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
5061  ideal v_id=(ideal)v->Data();
5062  tHomog hom=testHomog;
5063  int add_row_shift=0;
5064  if (w!=NULL)
5065  {
5066  w=ivCopy(w);
5067  add_row_shift=w->min_in();
5068  (*w)-=add_row_shift;
5069  if (idTestHomModule(v_id,currRing->qideal,w))
5070  hom=isHomog;
5071  else
5072  {
5073  //WarnS("wrong weights");
5074  delete w; w=NULL;
5075  hom=testHomog;
5076  }
5077  }
5078  res->data = (char *)idSyzygies(v_id,hom,&w);
5079  if (w!=NULL)
5080  {
5081  atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
5082  }
5083  return FALSE;
5084 }
5085 #endif
5087 {
5088  res->data = (char *)(long)ivTrace((intvec*)(v->Data()));
5089  return FALSE;
5090 }
5092 {
5093  res->data = (char *)(((bigintmat*)(v->Data()))->transpose());
5094  return FALSE;
5095 }
5097 {
5098  res->data = (char *)ivTranp((intvec*)(v->Data()));
5099  return FALSE;
5100 }
5101 #ifdef HAVE_PLURAL
5103 {
5104  ring r = (ring)a->Data();
5105  //if (rIsPluralRing(r))
5106  if (r->OrdSgn==1)
5107  {
5108  res->data = rOpposite(r);
5109  }
5110  else
5111  {
5112  WarnS("opposite only for global orderings");
5113  res->data = rCopy(r);
5114  }
5115  return FALSE;
5116 }
5118 {
5119  ring r = (ring)a->Data();
5120  if (rIsPluralRing(r))
5121  {
5122  // ideal i;
5123 // if (a->rtyp == QRING_CMD)
5124 // {
5125 // i = r->qideal;
5126 // r->qideal = NULL;
5127 // }
5128  ring s = rEnvelope(r);
5129 // if (a->rtyp == QRING_CMD)
5130 // {
5131 // ideal is = idOppose(r,i); /* twostd? */
5132 // is = idAdd(is,i);
5133 // s->qideal = i;
5134 // }
5135  res->data = s;
5136  }
5137  else res->data = rCopy(r);
5138  return FALSE;
5139 }
5141 {
5142  if (rIsPluralRing(currRing)) res->data=(ideal)twostd((ideal)a->Data());
5143  else res->data=(ideal)a->CopyD();
5144  setFlag(res,FLAG_STD);
5145  setFlag(res,FLAG_TWOSTD);
5146  return FALSE;
5147 }
5148 #endif
5149 
5150 static BOOLEAN jjTYPEOF(leftv res, leftv v)
5151 {
5152  int t=(int)(long)v->data;
5153  switch (t)
5154  {
5155  #ifdef SINGULAR_4_1
5156  case CRING_CMD:
5157  #endif
5158  case INT_CMD:
5159  case POLY_CMD:
5160  case VECTOR_CMD:
5161  case STRING_CMD:
5162  case INTVEC_CMD:
5163  case IDEAL_CMD:
5164  case MATRIX_CMD:
5165  case MODUL_CMD:
5166  case MAP_CMD:
5167  case PROC_CMD:
5168  case RING_CMD:
5169  case QRING_CMD:
5170  case INTMAT_CMD:
5171  case BIGINTMAT_CMD:
5172  case NUMBER_CMD:
5173  #ifdef SINGULAR_4_1
5174  case CNUMBER_CMD:
5175  #endif
5176  case BIGINT_CMD:
5177  case LIST_CMD:
5178  case PACKAGE_CMD:
5179  case LINK_CMD:
5180  case RESOLUTION_CMD:
5181  res->data=omStrDup(Tok2Cmdname(t)); break;
5182  case DEF_CMD:
5183  case NONE: res->data=omStrDup("none"); break;
5184  default:
5185  {
5186  if (t>MAX_TOK)
5187  res->data=omStrDup(getBlackboxName(t));
5188  else
5189  res->data=omStrDup("?unknown type?");
5190  break;
5191  }
5192  }
5193  return FALSE;
5194 }
5196 {
5197  res->data=(char *)(long)pIsUnivariate((poly)v->Data());
5198  return FALSE;
5199 }
5200 static BOOLEAN jjVAR1(leftv res, leftv v)
5201 {
5202  int i=(int)(long)v->Data();
5203  if ((0<i) && (i<=currRing->N))
5204  {
5205  poly p=pOne();
5206  pSetExp(p,i,1);
5207  pSetm(p);
5208  res->data=(char *)p;
5209  }
5210  else
5211  {
5212  Werror("var number %d out of range 1..%d",i,currRing->N);
5213  return TRUE;
5214  }
5215  return FALSE;
5216 }
5218 {
5219  if (currRing==NULL)
5220  {
5221  WerrorS("no ring active");
5222  return TRUE;
5223  }
5224  int i=(int)(long)v->Data();
5225  if ((0<i) && (i<=currRing->N))
5226  res->data=omStrDup(currRing->names[i-1]);
5227  else
5228  {
5229  Werror("var number %d out of range 1..%d",i,currRing->N);
5230  return TRUE;
5231  }
5232  return FALSE;
5233 }
5234 static BOOLEAN jjVDIM(leftv res, leftv v)
5235 {
5236  assumeStdFlag(v);
5237  res->data = (char *)(long)scMult0Int((ideal)v->Data(),currRing->qideal);
5238  return FALSE;
5239 }
5241 {
5242 // input: u: a list with links of type
5243 // ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
5244 // returns: -1: the read state of all links is eof
5245 // i>0: (at least) u[i] is ready
5246  lists Lforks = (lists)u->Data();
5247  int i = slStatusSsiL(Lforks, -1);
5248  if(i == -2) /* error */
5249  {
5250  return TRUE;
5251  }
5252  res->data = (void*)(long)i;
5253  return FALSE;
5254 }
5256 {
5257 // input: u: a list with links of type
5258 // ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
5259 // returns: -1: the read state of all links is eof
5260 // 1: all links are ready
5261 // (caution: at least one is ready, but some maybe dead)
5262  lists Lforks = (lists)u->CopyD();
5263  int i;
5264  int j = -1;
5265  for(int nfinished = 0; nfinished < Lforks->nr+1; nfinished++)
5266  {
5267  i = slStatusSsiL(Lforks, -1);
5268  if(i == -2) /* error */
5269  {
5270  return TRUE;
5271  }
5272  if(i == -1)
5273  {
5274  break;
5275  }
5276  j = 1;
5277  Lforks->m[i-1].CleanUp();
5278  Lforks->m[i-1].rtyp=DEF_CMD;
5279  Lforks->m[i-1].data=NULL;
5280  }
5281  res->data = (void*)(long)j;
5282  Lforks->Clean();
5283  return FALSE;
5284 }
5285 
5286 BOOLEAN jjLOAD(const char *s, BOOLEAN autoexport)
5287 {
5288  char libnamebuf[256];
5289  lib_types LT = type_of_LIB(s, libnamebuf);
5290 
5291 #ifdef HAVE_DYNAMIC_LOADING
5292  extern BOOLEAN load_modules(const char *newlib, char *fullpath, BOOLEAN autoexport);
5293 #endif /* HAVE_DYNAMIC_LOADING */
5294  switch(LT)
5295  {
5296  default:
5297  case LT_NONE:
5298  Werror("%s: unknown type", s);
5299  break;
5300  case LT_NOTFOUND:
5301  Werror("cannot open %s", s);
5302  break;
5303 
5304  case LT_SINGULAR:
5305  {
5306  char *plib = iiConvName(s);
5307  idhdl pl = IDROOT->get(plib,0);
5308  if (pl==NULL)
5309  {
5310  pl = enterid( plib,0, PACKAGE_CMD, &(basePack->idroot), TRUE );
5311  IDPACKAGE(pl)->language = LANG_SINGULAR;
5312  IDPACKAGE(pl)->libname=omStrDup(plib);
5313  }
5314  else if (IDTYP(pl)!=PACKAGE_CMD)
5315  {
5316  Werror("can not create package `%s`",plib);
5317  omFree(plib);
5318  return TRUE;
5319  }
5320  package savepack=currPack;
5321  currPack=IDPACKAGE(pl);
5322  IDPACKAGE(pl)->loaded=TRUE;
5323  char libnamebuf[256];
5324  FILE * fp = feFopen( s, "r", libnamebuf, TRUE );
5325  BOOLEAN bo=iiLoadLIB(fp, libnamebuf, s, pl, autoexport, TRUE);
5326  currPack=savepack;
5327  IDPACKAGE(pl)->loaded=(!bo);
5328  return bo;
5329  }
5330  case LT_BUILTIN:
5331  SModulFunc_t iiGetBuiltinModInit(const char*);
5332  return load_builtin(s,autoexport, iiGetBuiltinModInit(s));
5333  case LT_MACH_O:
5334  case LT_ELF:
5335  case LT_HPUX:
5336 #ifdef HAVE_DYNAMIC_LOADING
5337  return load_modules(s, libnamebuf, autoexport);
5338 #else /* HAVE_DYNAMIC_LOADING */
5339  WerrorS("Dynamic modules are not supported by this version of Singular");
5340  break;
5341 #endif /* HAVE_DYNAMIC_LOADING */
5342  }
5343  return TRUE;
5344 }
5345 static int WerrorS_dummy_cnt=0;
5346 static void WerrorS_dummy(const char *)
5347 {
5348  WerrorS_dummy_cnt++;
5349 }
5350 BOOLEAN jjLOAD_TRY(const char *s)
5351 {
5352  void (*WerrorS_save)(const char *s) = WerrorS_callback;
5354  WerrorS_dummy_cnt=0;
5355  BOOLEAN bo=jjLOAD(s,TRUE);
5356  if (TEST_OPT_PROT && (bo || (WerrorS_dummy_cnt>0)))
5357  Print("loading of >%s< failed\n",s);
5358  WerrorS_callback=WerrorS_save;
5359  errorreported=0;
5360  return FALSE;
5361 }
5362 
5363 static BOOLEAN jjstrlen(leftv res, leftv v)
5364 {
5365  res->data = (char *)strlen((char *)v->Data());
5366  return FALSE;
5367 }
5369 {
5370  res->data = (char *)(long)pLength((poly)v->Data());
5371  return FALSE;
5372 }
5373 static BOOLEAN jjidElem(leftv res, leftv v)
5374 {
5375  res->data = (char *)(long)idElem((ideal)v->Data());
5376  return FALSE;
5377 }
5379 {
5380  res->data = (char *)id_FreeModule((int)(long)v->Data(), currRing);
5381  return FALSE;
5382 }
5384 {
5385  res->data = (char *)id_Vec2Ideal((poly)v->Data(), currRing);
5386  return FALSE;
5387 }
5389 {
5390 #ifdef SINGULAR_4_1
5391  iiReWrite("charstr");
5392 #endif
5393  res->data = rCharStr((ring)v->Data());
5394  return FALSE;
5395 }
5396 static BOOLEAN jjpHead(leftv res, leftv v)
5397 {
5398  res->data = (char *)pHead((poly)v->Data());
5399  return FALSE;
5400 }
5401 static BOOLEAN jjidHead(leftv res, leftv v)
5402 {
5403  res->data = (char *)id_Head((ideal)v->Data(),currRing);
5404  setFlag(res,FLAG_STD);
5405  return FALSE;
5406 }
5408 {
5409  res->data = (char *)idMinBase((ideal)v->Data());
5410  return FALSE;
5411 }
5413 {
5414  res->data = (char *)syMinBase((ideal)v->Data());
5415  return FALSE;
5416 }
5418 {
5419  res->data = (char *)pMaxComp((poly)v->Data());
5420  return FALSE;
5421 }
5423 {
5424  res->data = (char *)mp_Trace((matrix)v->Data(),currRing);
5425  return FALSE;
5426 }
5428 {
5429  res->data = (char *)mp_Transp((matrix)v->Data(),currRing);
5430  return FALSE;
5431 }
5433 {
5434 #ifdef SINGULAR_4_1
5435  iiReWrite("ordstr");
5436 #endif
5437  res->data = rOrdStr((ring)v->Data());
5438  return FALSE;
5439 }
5441 {
5442 #ifdef SINGULAR_4_1
5443  iiReWrite("varstr");
5444 #endif
5445  res->data = rVarStr((ring)v->Data());
5446  return FALSE;
5447 }
5449 {
5450 #ifdef SINGULAR_4_1
5451  iiReWrite("varstr");
5452 #endif
5453  res->data = rParStr((ring)v->Data());
5454  return FALSE;
5455 }
5457 {
5458  res->data=(char *)(long)sySize((syStrategy)v->Data());
5459  return FALSE;
5460 }
5461 static BOOLEAN jjDIM_R(leftv res, leftv v)
5462 {
5463  res->data = (char *)(long)syDim((syStrategy)v->Data());
5464  return FALSE;
5465 }
5467 {
5468  res->data = (char *)id_Transp((ideal)v->Data(),currRing);
5469  return FALSE;
5470 }
5471 static BOOLEAN jjnInt(leftv res, leftv u)
5472 {
5473  number n=(number)u->CopyD(); // n_Int may call n_Normalize
5474  res->data=(char *)(long)iin_Int(n,currRing->cf);
5475  n_Delete(&n,currRing->cf);
5476  return FALSE;
5477 }
5478 static BOOLEAN jjnlInt(leftv res, leftv u)
5479 {
5480  number n=(number)u->Data();
5481  res->data=(char *)(long)iin_Int(n,coeffs_BIGINT );
5482  return FALSE;
5483 }
5484 /*=================== operations with 3 args.: static proc =================*/
5485 /* must be ordered: first operations for chars (infix ops),
5486  * then alphabetically */
5488 {
5489  char *s= (char *)u->Data();
5490  int r = (int)(long)v->Data();
5491  int c = (int)(long)w->Data();
5492  int l = strlen(s);
5493 
5494  if ( (r<1) || (r>l) || (c<0) )
5495  {
5496  Werror("wrong range[%d,%d] in string %s",r,c,u->Fullname());
5497  return TRUE;
5498  }
5499  res->data = (char *)omAlloc((long)(c+1));
5500  sprintf((char *)res->data,"%-*.*s",c,c,s+r-1);
5501  return FALSE;
5502 }
5504 {
5505  intvec *iv = (intvec *)u->Data();
5506  int r = (int)(long)v->Data();
5507  int c = (int)(long)w->Data();
5508  if ((r<1)||(r>iv->rows())||(c<1)||(c>iv->cols()))
5509  {
5510  Werror("wrong range[%d,%d] in intmat %s(%d x %d)",
5511  r,c,u->Fullname(),iv->rows(),iv->cols());
5512  return TRUE;
5513  }
5514  res->data=u->data; u->data=NULL;
5515  res->rtyp=u->rtyp; u->rtyp=0;
5516  res->name=u->name; u->name=NULL;
5517  Subexpr e=jjMakeSub(v);
5518  e->next=jjMakeSub(w);
5519  if (u->e==NULL) res->e=e;
5520  else
5521  {
5522  Subexpr h=u->e;
5523  while (h->next!=NULL) h=h->next;
5524  h->next=e;
5525  res->e=u->e;
5526  u->e=NULL;
5527  }
5528  return FALSE;
5529 }
5531 {
5532  bigintmat *bim = (bigintmat *)u->Data();
5533  int r = (int)(long)v->Data();
5534  int c = (int)(long)w->Data();
5535  if ((r<1)||(r>bim->rows())||(c<1)||(c>bim->cols()))
5536  {
5537  Werror("wrong range[%d,%d] in bigintmat %s(%d x %d)",
5538  r,c,u->Fullname(),bim->rows(),bim->cols());
5539  return TRUE;
5540  }
5541  res->data=u->data; u->data=NULL;
5542  res->rtyp=u->rtyp; u->rtyp=0;
5543  res->name=u->name; u->name=NULL;
5544  Subexpr e=jjMakeSub(v);
5545  e->next=jjMakeSub(w);
5546  if (u->e==NULL)
5547  res->e=e;
5548  else
5549  {
5550  Subexpr h=u->e;
5551  while (h->next!=NULL) h=h->next;
5552  h->next=e;
5553  res->e=u->e;
5554  u->e=NULL;
5555  }
5556  return FALSE;
5557 }
5559 {
5560  matrix m= (matrix)u->Data();
5561  int r = (int)(long)v->Data();
5562  int c = (int)(long)w->Data();
5563  //Print("gen. elem %d, %d\n",r,c);
5564  if ((r<1)||(r>MATROWS(m))||(c<1)||(c>MATCOLS(m)))
5565  {
5566  Werror("wrong range[%d,%d] in matrix %s(%d x %d)",r,c,u->Fullname(),
5567  MATROWS(m),MATCOLS(m));
5568  return TRUE;
5569  }
5570  res->data=u->data; u->data=NULL;
5571  res->rtyp=u->rtyp; u->rtyp=0;
5572  res->name=u->name; u->name=NULL;
5573  Subexpr e=jjMakeSub(v);
5574  e->next=jjMakeSub(w);
5575  if (u->e==NULL)
5576  res->e=e;
5577  else
5578  {
5579  Subexpr h=u->e;
5580  while (h->next!=NULL) h=h->next;
5581  h->next=e;
5582  res->e=u->e;
5583  u->e=NULL;
5584  }
5585  return FALSE;
5586 }
5588 {
5589  sleftv t;
5590  sleftv ut;
5591  leftv p=NULL;
5592  intvec *iv=(intvec *)w->Data();
5593  int l;
5594  BOOLEAN nok;
5595 
5596  if ((u->rtyp!=IDHDL)||(u->e!=NULL))
5597  {
5598  WerrorS("cannot build expression lists from unnamed objects");
5599  return TRUE;
5600  }
5601  memcpy(&ut,u,sizeof(ut));
5602  memset(&t,0,sizeof(t));
5603  t.rtyp=INT_CMD;
5604  for (l=0;l< iv->length(); l++)
5605  {
5606  t.data=(char *)(long)((*iv)[l]);
5607  if (p==NULL)
5608  {
5609  p=res;
5610  }
5611  else
5612  {
5614  p=p->next;
5615  }
5616  memcpy(u,&ut,sizeof(ut));
5617  if (u->Typ() == MATRIX_CMD)
5618  nok=jjBRACK_Ma(p,u,v,&t);
5619  else if (u->Typ() == BIGINTMAT_CMD)
5620  nok=jjBRACK_Bim(p,u,v,&t);
5621  else /* INTMAT_CMD */
5622  nok=jjBRACK_Im(p,u,v,&t);
5623  if (nok)
5624  {
5625  while (res->next!=NULL)
5626  {
5627  p=res->next->next;
5628  omFreeBin((ADDRESS)res->next, sleftv_bin);
5629  // res->e aufraeumen !!!!
5630  res->next=p;
5631  }
5632  return TRUE;
5633  }
5634  }
5635  return FALSE;
5636 }
5638 {
5639  sleftv t;
5640  sleftv ut;
5641  leftv p=NULL;
5642  intvec *iv=(intvec *)v->Data();
5643  int l;
5644  BOOLEAN nok;
5645 
5646  if ((u->rtyp!=IDHDL)||(u->e!=NULL))
5647  {
5648  WerrorS("cannot build expression lists from unnamed objects");
5649  return TRUE;
5650  }
5651  memcpy(&ut,u,sizeof(ut));
5652  memset(&t,0,sizeof(t));
5653  t.rtyp=INT_CMD;
5654  for (l=0;l< iv->length(); l++)
5655  {
5656  t.data=(char *)(long)((*iv)[l]);
5657  if (p==NULL)
5658  {
5659  p=res;
5660  }
5661  else
5662  {
5664  p=p->next;
5665  }
5666  memcpy(u,&ut,sizeof(ut));
5667  if (u->Typ() == MATRIX_CMD)
5668  nok=jjBRACK_Ma(p,u,&t,w);
5669  else if (u->Typ() == BIGINTMAT_CMD)
5670  nok=jjBRACK_Bim(p,u,&t,w);
5671  else /* INTMAT_CMD */
5672  nok=jjBRACK_Im(p,u,&t,w);
5673  if (nok)
5674  {
5675  while (res->next!=NULL)
5676  {
5677  p=res->next->next;
5678  omFreeBin((ADDRESS)res->next, sleftv_bin);
5679  // res->e aufraeumen !!
5680  res->next=p;
5681  }
5682  return TRUE;
5683  }
5684  }
5685  return FALSE;
5686 }
5688 {
5689  sleftv t1,t2,ut;
5690  leftv p=NULL;
5691  intvec *vv=(intvec *)v->Data();
5692  intvec *wv=(intvec *)w->Data();
5693  int vl;
5694  int wl;
5695  BOOLEAN nok;
5696 
5697  if ((u->rtyp!=IDHDL)||(u->e!=NULL))
5698  {
5699  WerrorS("cannot build expression lists from unnamed objects");
5700  return TRUE;
5701  }
5702  memcpy(&ut,u,sizeof(ut));
5703  memset(&t1,0,sizeof(sleftv));
5704  memset(&t2,0,sizeof(sleftv));
5705  t1.rtyp=INT_CMD;
5706  t2.rtyp=INT_CMD;
5707  for (vl=0;vl< vv->length(); vl++)
5708  {
5709  t1.data=(char *)(long)((*vv)[vl]);
5710  for (wl=0;wl< wv->length(); wl++)
5711  {
5712  t2.data=(char *)(long)((*wv)[wl]);
5713  if (p==NULL)
5714  {
5715  p=res;
5716  }
5717  else
5718  {
5720  p=p->next;
5721  }
5722  memcpy(u,&ut,sizeof(ut));
5723  if (u->Typ() == MATRIX_CMD)
5724  nok=jjBRACK_Ma(p,u,&t1,&t2);
5725  else if (u->Typ() == BIGINTMAT_CMD)
5726  nok=jjBRACK_Bim(p,u,&t1,&t2);
5727  else /* INTMAT_CMD */
5728  nok=jjBRACK_Im(p,u,&t1,&t2);
5729  if (nok)
5730  {
5731  res->CleanUp();
5732  return TRUE;
5733  }
5734  }
5735  }
5736  return FALSE;
5737 }
5738 static BOOLEAN jjPROC3(leftv res, leftv u, leftv v, leftv w)
5739 {
5741  memcpy(v->next,w,sizeof(sleftv));
5742  memset(w,0,sizeof(sleftv));
5743  return jjPROC(res,u,v);
5744 }
5745 static BOOLEAN jjBAREISS3(leftv res, leftv u, leftv v, leftv w)
5746 {
5747  intvec *iv;
5748  ideal m;
5750  int k=(int)(long)w->Data();
5751  if (k>=0)
5752  {
5753  sm_CallBareiss((ideal)u->Data(),(int)(long)v->Data(),(int)(long)w->Data(),m,&iv, currRing);
5754  l->Init(2);
5755  l->m[0].rtyp=MODUL_CMD;
5756  l->m[1].rtyp=INTVEC_CMD;
5757  l->m[0].data=(void *)m;
5758  l->m[1].data=(void *)iv;
5759  }
5760  else
5761  {
5762  m=sm_CallSolv((ideal)u->Data(), currRing);
5763  l->Init(1);
5764  l->m[0].rtyp=IDEAL_CMD;
5765  l->m[0].data=(void *)m;
5766  }
5767  res->data = (char *)l;
5768  return FALSE;
5769 }
5771 {
5772  if ((w->rtyp!=IDHDL)||(w->e!=NULL))
5773  {
5774  WerrorS("3rd argument must be a name of a matrix");
5775  return TRUE;
5776  }
5777  ideal i=(ideal)u->Data();
5778  int rank=(int)i->rank;
5779  BOOLEAN r=jjCOEFFS_Id(res,u,v);
5780  if (r) return TRUE;
5781  mp_Monomials((matrix)res->data, rank, pVar((poly)v->Data()),(matrix)w->Data(),currRing);
5782  return FALSE;
5783 }
5785 {
5786  res->data=(void*)idCoeffOfKBase((ideal)(u->Data()),
5787  (ideal)(v->Data()),(poly)(w->Data()));
5788  return FALSE;
5789 }
5791 {
5792  if ((w->rtyp!=IDHDL)||(w->e!=NULL))
5793  {
5794  WerrorS("3rd argument must be a name of a matrix");
5795  return TRUE;
5796  }
5797  // CopyD for POLY_CMD and VECTOR_CMD are identical:
5798  poly p=(poly)u->CopyD(POLY_CMD);
5799  ideal i=idInit(1,1);
5800  i->m[0]=p;
5801  sleftv t;
5802  memset(&t,0,sizeof(t));
5803  t.data=(char *)i;
5804  t.rtyp=IDEAL_CMD;
5805  int rank=1;
5806  if (u->Typ()==VECTOR_CMD)
5807  {
5808  i->rank=rank=pMaxComp(p);
5809  t.rtyp=MODUL_CMD;
5810  }
5811  BOOLEAN r=jjCOEFFS_Id(res,&t,v);
5812  t.CleanUp();
5813  if (r) return TRUE;
5814  mp_Monomials((matrix)res->data, rank, pVar((poly)v->Data()),(matrix)w->Data(),currRing);
5815  return FALSE;
5816 }
5818 {
5819  res->data=(char *)idElimination((ideal)u->Data(),(poly)v->Data(),
5820  (intvec *)w->Data());
5821  //setFlag(res,FLAG_STD);
5822  return FALSE;
5823 }
5824 static BOOLEAN jjFIND3(leftv res, leftv u, leftv v, leftv w)
5825 {
5826  /*4
5827  * look for the substring what in the string where
5828  * starting at position n
5829  * return the position of the first char of what in where
5830  * or 0
5831  */
5832  int n=(int)(long)w->Data();
5833  char *where=(char *)u->Data();
5834  char *what=(char *)v->Data();
5835  char *found;
5836  if ((1>n)||(n>(int)strlen(where)))
5837  {
5838  Werror("start position %d out of range",n);
5839  return TRUE;
5840  }
5841  found = strchr(where+n-1,*what);
5842  if (*(what+1)!='\0')
5843  {
5844  while((found !=NULL) && (strncmp(found+1,what+1,strlen(what+1))!=0))
5845  {
5846  found=strchr(found+1,*what);
5847  }
5848  }
5849  if (found != NULL)
5850  {
5851  res->data=(char *)((found-where)+1);
5852  }
5853  return FALSE;
5854 }
5855 static BOOLEAN jjFWALK3(leftv res, leftv u, leftv v, leftv w)
5856 {
5857  if ((int)(long)w->Data()==0)
5858  res->data=(char *)walkProc(u,v);
5859  else
5860  res->data=(char *)fractalWalkProc(u,v);
5861  setFlag( res, FLAG_STD );
5862  return FALSE;
5863 }
5864 static BOOLEAN jjHILBERT3(leftv res, leftv u, leftv v, leftv w)
5865 {
5866  intvec *wdegree=(intvec*)w->Data();
5867  if (wdegree->length()!=currRing->N)
5868  {
5869  Werror("weight vector must have size %d, not %d",
5870  currRing->N,wdegree->length());
5871  return TRUE;
5872  }
5873 #ifdef HAVE_RINGS
5875  {
5876  ring origR = currRing;
5877  ring tempR = rCopy(origR);
5878  coeffs new_cf=nInitChar(n_Q,NULL);
5879  nKillChar(tempR->cf);
5880  tempR->cf=new_cf;
5881  rComplete(tempR);
5882  ideal uid = (ideal)u->Data();
5883  rChangeCurrRing(tempR);
5884  ideal uu = idrCopyR(uid, origR, currRing);
5885  sleftv uuAsLeftv; memset(&uuAsLeftv, 0, sizeof(uuAsLeftv));
5886  uuAsLeftv.rtyp = IDEAL_CMD;
5887  uuAsLeftv.data = uu; uuAsLeftv.next = NULL;
5888  if (hasFlag(u, FLAG_STD)) setFlag(&uuAsLeftv,FLAG_STD);
5889  assumeStdFlag(&uuAsLeftv);
5890  Print("// NOTE: computation of Hilbert series etc. is being\n");
5891  Print("// performed for generic fibre, that is, over Q\n");
5892  intvec *module_w=(intvec*)atGet(&uuAsLeftv,"isHomog",INTVEC_CMD);
5893  intvec *iv=hFirstSeries(uu,module_w,currRing->qideal,wdegree);
5894  int returnWithTrue = 1;
5895  switch((int)(long)v->Data())
5896  {
5897  case 1:
5898  res->data=(void *)iv;
5899  returnWithTrue = 0;
5900  case 2:
5901  res->data=(void *)hSecondSeries(iv);
5902  delete iv;
5903  returnWithTrue = 0;
5904  }
5905  if (returnWithTrue)
5906  {
5908  delete iv;
5909  }
5910  idDelete(&uu);
5911  rChangeCurrRing(origR);
5912  rDelete(tempR);
5913  if (returnWithTrue) return TRUE; else return FALSE;
5914  }
5915 #endif
5916  assumeStdFlag(u);
5917  intvec *module_w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
5918  intvec *iv=hFirstSeries((ideal)u->Data(),module_w,currRing->qideal,wdegree);
5919  switch((int)(long)v->Data())
5920  {
5921  case 1:
5922  res->data=(void *)iv;
5923  return FALSE;
5924  case 2:
5925  res->data=(void *)hSecondSeries(iv);
5926  delete iv;
5927  return FALSE;
5928  }
5930  delete iv;
5931  return TRUE;
5932 }
5933 static BOOLEAN jjHOMOG_ID_W(leftv res, leftv u, leftv v, leftv /*w*/)
5934 {
5935  PrintS("TODO\n");
5936  int i=pVar((poly)v->Data());
5937  if (i==0)
5938  {
5939  WerrorS("ringvar expected");
5940  return TRUE;
5941  }
5942  poly p=pOne(); pSetExp(p,i,1); pSetm(p);
5943  int d=pWTotaldegree(p);
5944  pLmDelete(p);
5945  if (d==1)
5946  res->data = (char *)id_Homogen((ideal)u->Data(), i, currRing);
5947  else
5948  WerrorS("variable must have weight 1");
5949  return (d!=1);
5950 }
5951 static BOOLEAN jjHOMOG_P_W(leftv res, leftv u, leftv v,leftv /*w*/)
5952 {
5953  PrintS("TODO\n");
5954  int i=pVar((poly)v->Data());
5955  if (i==0)
5956  {
5957  WerrorS("ringvar expected");
5958  return TRUE;
5959  }
5960  poly p=pOne(); pSetExp(p,i,1); pSetm(p);
5961  int d=pWTotaldegree(p);
5962  pLmDelete(p);
5963  if (d==1)
5964  res->data = (char *)p_Homogen((poly)u->Data(), i, currRing);
5965  else
5966  WerrorS("variable must have weight 1");
5967  return (d!=1);
5968 }
5970 {
5971  intvec* im= new intvec((int)(long)v->Data(),(int)(long)w->Data(), 0);
5972  intvec* arg = (intvec*) u->Data();
5973  int i, n = si_min(im->cols()*im->rows(), arg->cols()*arg->rows());
5974 
5975  for (i=0; i<n; i++)
5976  {
5977  (*im)[i] = (*arg)[i];
5978  }
5979 
5980  res->data = (char *)im;
5981  return FALSE;
5982 }
5983 static BOOLEAN jjJET_P_IV(leftv res, leftv u, leftv v, leftv w)
5984 {
5985  short *iw=iv2array((intvec *)w->Data(),currRing);
5986  res->data = (char *)ppJetW((poly)u->Data(),(int)(long)v->Data(),iw);
5987  omFreeSize( (ADDRESS)iw, (rVar(currRing)+1)*sizeof(short) );
5988  return FALSE;
5989 }
5990 static BOOLEAN jjJET_P_P(leftv res, leftv u, leftv v, leftv w)
5991 {
5992  if (!pIsUnit((poly)v->Data()))
5993  {
5994  WerrorS("2nd argument must be a unit");
5995  return TRUE;
5996  }
5997  res->data = (char *)p_Series((int)(long)w->Data(),(poly)u->CopyD(),(poly)v->CopyD(),NULL,currRing);
5998  return FALSE;
5999 }
6001 {
6002  res->data = (char *)id_JetW((ideal)u->Data(),(int)(long)v->Data(),
6003  (intvec *)w->Data(),currRing);
6004  return FALSE;
6005 }
6006 static BOOLEAN jjJET_ID_M(leftv res, leftv u, leftv v, leftv w)
6007 {
6008  if (!mp_IsDiagUnit((matrix)v->Data(), currRing))
6009  {
6010  WerrorS("2nd argument must be a diagonal matrix of units");
6011  return TRUE;
6012  }
6013  res->data = (char *)idSeries((int)(long)w->Data(),(ideal)u->CopyD(),
6014  (matrix)v->CopyD());
6015  return FALSE;
6016 }
6018 {
6019  /* true for fields and Z, false otherwise */
6020  if (rField_is_Ring_PtoM(currRing)) return FALSE;
6021  if (rField_is_Ring_2toM(currRing)) return FALSE;
6022  if (rField_is_Ring_ModN(currRing)) return FALSE;
6023  return TRUE;
6024 }
6026 {
6027  /* Here's the use pattern for the minor command:
6028  minor ( matrix_expression m, int_expression minorSize,
6029  optional ideal_expression IasSB, optional int_expression k,
6030  optional string_expression algorithm,
6031  optional int_expression cachedMinors,
6032  optional int_expression cachedMonomials )
6033  This method here assumes that there are at least two arguments.
6034  - If IasSB is present, it must be a std basis. All minors will be
6035  reduced w.r.t. IasSB.
6036  - If k is absent, all non-zero minors will be computed.
6037  If k is present and k > 0, the first k non-zero minors will be
6038  computed.
6039  If k is present and k < 0, the first |k| minors (some of which
6040  may be zero) will be computed.
6041  If k is present and k = 0, an error is reported.
6042  - If algorithm is absent, all the following arguments must be absent too.
6043  In this case, a heuristic picks the best-suited algorithm (among
6044  Bareiss, Laplace, and Laplace with caching).
6045  If algorithm is present, it must be one of "Bareiss", "bareiss",
6046  "Laplace", "laplace", "Cache", "cache". In the cases "Cache" and
6047  "cache" two more arguments may be given, determining how many entries
6048  the cache may have at most, and how many cached monomials there are at
6049  most. (Cached monomials are counted over all cached polynomials.)
6050  If these two additional arguments are not provided, 200 and 100000
6051  will be used as defaults.
6052  */
6053  matrix m;
6054  leftv u=v->next;
6055  v->next=NULL;
6056  int v_typ=v->Typ();
6057  if (v_typ==MATRIX_CMD)
6058  {
6059  m = (const matrix)v->Data();
6060  }
6061  else
6062  {
6063  if (v_typ==0)
6064  {
6065  Werror("`%s` is undefined",v->Fullname());
6066  return TRUE;
6067  }
6068  // try to convert to MATRIX:
6069  int ii=iiTestConvert(v_typ,MATRIX_CMD);
6070  BOOLEAN bo;
6071  sleftv tmp;
6072  if (ii>0) bo=iiConvert(v_typ,MATRIX_CMD,ii,v,&tmp);
6073  else bo=TRUE;
6074  if (bo)
6075  {
6076  Werror("cannot convert %s to matrix",Tok2Cmdname(v_typ));
6077  return TRUE;
6078  }
6079  m=(matrix)tmp.data;
6080  }
6081  const int mk = (const int)(long)u->Data();
6082  bool noIdeal = true; bool noK = true; bool noAlgorithm = true;
6083  bool noCacheMinors = true; bool noCacheMonomials = true;
6084  ideal IasSB; int k; char* algorithm; int cacheMinors; int cacheMonomials;
6085 
6086  /* here come the different cases of correct argument sets */
6087  if ((u->next != NULL) && (u->next->Typ() == IDEAL_CMD))
6088  {
6089  IasSB = (ideal)u->next->Data();
6090  noIdeal = false;
6091  if ((u->next->next != NULL) && (u->next->next->Typ() == INT_CMD))
6092  {
6093  k = (int)(long)u->next->next->Data();
6094  noK = false;
6095  assume(k != 0);
6096  if ((u->next->next->next != NULL) &&
6097  (u->next->next->next->Typ() == STRING_CMD))
6098  {
6099  algorithm = (char*)u->next->next->next->Data();
6100  noAlgorithm = false;
6101  if ((u->next->next->next->next != NULL) &&
6102  (u->next->next->next->next->Typ() == INT_CMD))
6103  {
6104  cacheMinors = (int)(long)u->next->next->next->next->Data();
6105  noCacheMinors = false;
6106  if ((u->next->next->next->next->next != NULL) &&
6107  (u->next->next->next->next->next->Typ() == INT_CMD))
6108  {
6109  cacheMonomials =
6110  (int)(long)u->next->next->next->next->next->Data();
6111  noCacheMonomials = false;
6112  }
6113  }
6114  }
6115  }
6116  }
6117  else if ((u->next != NULL) && (u->next->Typ() == INT_CMD))
6118  {
6119  k = (int)(long)u->next->Data();
6120  noK = false;
6121  assume(k != 0);
6122  if ((u->next->next != NULL) && (u->next->next->Typ() == STRING_CMD))
6123  {
6124  algorithm = (char*)u->next->next->Data();
6125  noAlgorithm = false;
6126  if ((u->next->next->next != NULL) &&
6127  (u->next->next->next->Typ() == INT_CMD))
6128  {
6129  cacheMinors = (int)(long)u->next->next->next->Data();
6130  noCacheMinors = false;
6131  if ((u->next->next->next->next != NULL) &&
6132  (u->next->next->next->next->Typ() == INT_CMD))
6133  {
6134  cacheMonomials = (int)(long)u->next->next->next->next->Data();
6135  noCacheMonomials = false;
6136  }
6137  }
6138  }
6139  }
6140  else if ((u->next != NULL) && (u->next->Typ() == STRING_CMD))
6141  {
6142  algorithm = (char*)u->next->Data();
6143  noAlgorithm = false;
6144  if ((u->next->next != NULL) && (u->next->next->Typ() == INT_CMD))
6145  {
6146  cacheMinors = (int)(long)u->next->next->Data();
6147  noCacheMinors = false;
6148  if ((u->next->next->next != NULL) &&
6149  (u->next->next->next->Typ() == INT_CMD))
6150  {
6151  cacheMonomials = (int)(long)u->next->next->next->Data();
6152  noCacheMonomials = false;
6153  }
6154  }
6155  }
6156 
6157  /* upper case conversion for the algorithm if present */
6158  if (!noAlgorithm)
6159  {
6160  if (strcmp(algorithm, "bareiss") == 0)
6161  algorithm = (char*)"Bareiss";
6162  if (strcmp(algorithm, "laplace") == 0)
6163  algorithm = (char*)"Laplace";
6164  if (strcmp(algorithm, "cache") == 0)
6165  algorithm = (char*)"Cache";
6166  }
6167 
6168  v->next=u;
6169  /* here come some tests */
6170  if (!noIdeal)
6171  {
6172  assumeStdFlag(u->next);
6173  }
6174  if ((!noK) && (k == 0))
6175  {
6176  WerrorS("Provided number of minors to be computed is zero.");
6177  return TRUE;
6178  }
6179  if ((!noAlgorithm) && (strcmp(algorithm, "Bareiss") != 0)
6180  && (strcmp(algorithm, "Laplace") != 0)
6181  && (strcmp(algorithm, "Cache") != 0))
6182  {
6183  WerrorS("Expected as algorithm one of 'B/bareiss', 'L/laplace', or 'C/cache'.");
6184  return TRUE;
6185  }
6186  if ((!noAlgorithm) && (strcmp(algorithm, "Bareiss") == 0)
6188  {
6189  Werror("Bareiss algorithm not defined over coefficient rings %s",
6190  "with zero divisors.");
6191  return TRUE;
6192  }
6193  res->rtyp=IDEAL_CMD;
6194  if ((mk < 1) || (mk > m->rows()) || (mk > m->cols()))
6195  {
6196  ideal I=idInit(1,1);
6197  if (mk<1) I->m[0]=p_One(currRing);
6198  //Werror("invalid size of minors: %d (matrix is (%d x %d))", mk,
6199  // m->rows(), m->cols());
6200  res->data=(void*)I;
6201  return FALSE;
6202  }
6203  if ((!noAlgorithm) && (strcmp(algorithm, "Cache") == 0)
6204  && (noCacheMinors || noCacheMonomials))
6205  {
6206  cacheMinors = 200;
6207  cacheMonomials = 100000;
6208  }
6209 
6210  /* here come the actual procedure calls */
6211  if (noAlgorithm)
6212  res->data = getMinorIdealHeuristic(m, mk, (noK ? 0 : k),
6213  (noIdeal ? 0 : IasSB), false);
6214  else if (strcmp(algorithm, "Cache") == 0)
6215  res->data = getMinorIdealCache(m, mk, (noK ? 0 : k),
6216  (noIdeal ? 0 : IasSB), 3, cacheMinors,
6217  cacheMonomials, false);
6218  else
6219  res->data = getMinorIdeal(m, mk, (noK ? 0 : k), algorithm,
6220  (noIdeal ? 0 : IasSB), false);
6221  if (v_typ!=MATRIX_CMD) idDelete((ideal *)&m);
6222  return FALSE;
6223 }
6225 {
6226  // u: the name of the new type
6227  // v: the parent type
6228  // w: the elements
6229  newstruct_desc d=newstructChildFromString((const char *)v->Data(),
6230  (const char *)w->Data());
6231  if (d!=NULL) newstruct_setup((const char *)u->Data(),d);
6232  return (d==NULL);
6233 }
6234 static BOOLEAN jjPREIMAGE(leftv res, leftv u, leftv v, leftv w)
6235 {
6236  // handles preimage(r,phi,i) and kernel(r,phi)
6237  idhdl h;
6238  ring rr;
6239  map mapping;
6240  BOOLEAN kernel_cmd= (iiOp==KERNEL_CMD);
6241 
6242  if ((v->name==NULL) || (!kernel_cmd && (w->name==NULL)))
6243  {
6244  WerrorS("2nd/3rd arguments must have names");
6245  return TRUE;
6246  }
6247  rr=(ring)u->Data();
6248  const char *ring_name=u->Name();
6249  if ((h=rr->idroot->get(v->name,myynest))!=NULL)
6250  {
6251  if (h->typ==MAP_CMD)
6252  {
6253  mapping=IDMAP(h);
6254  idhdl preim_ring=IDROOT->get(mapping->preimage,myynest);
6255  if ((preim_ring==NULL)
6256  || (IDRING(preim_ring)!=currRing))
6257  {
6258  Werror("preimage ring `%s` is not the basering",mapping->preimage);
6259  return TRUE;
6260  }
6261  }
6262  else if (h->typ==IDEAL_CMD)
6263  {
6264  mapping=IDMAP(h);
6265  }
6266  else
6267  {
6268  Werror("`%s` is no map nor ideal",IDID(h));
6269  return TRUE;
6270  }
6271  }
6272  else
6273  {
6274  Werror("`%s` is not defined in `%s`",v->name,ring_name);
6275  return TRUE;
6276  }
6277  ideal image;
6278  if (kernel_cmd) image=idInit(1,1);
6279  else
6280  {
6281  if ((h=rr->idroot->get(w->name,myynest))!=NULL)
6282  {
6283  if (h->typ==IDEAL_CMD)
6284  {
6285  image=IDIDEAL(h);
6286  }
6287  else
6288  {
6289  Werror("`%s` is no ideal",IDID(h));
6290  return TRUE;
6291  }
6292  }
6293  else
6294  {
6295  Werror("`%s` is not defined in `%s`",w->name,ring_name);
6296  return TRUE;
6297  }
6298  }
6299  if (((currRing->qideal!=NULL) && (rHasLocalOrMixedOrdering_currRing()))
6300  || ((rr->qideal!=NULL) && (rHasLocalOrMixedOrdering(rr))))
6301  {
6302  WarnS("preimage in local qring may be wrong: use Ring::preimageLoc instead");
6303  }
6304  res->data=(char *)maGetPreimage(rr,mapping,image,currRing);
6305  if (kernel_cmd) idDelete(&image);
6306  return (res->data==NULL/* is of type ideal, should not be NULL*/);
6307 }
6309 {
6310  int di, k;
6311  int i=(int)(long)u->Data();
6312  int r=(int)(long)v->Data();
6313  int c=(int)(long)w->Data();
6314  if ((r<=0) || (c<=0)) return TRUE;
6315  intvec *iv = new intvec(r, c, 0);
6316  if (iv->rows()==0)
6317  {
6318  delete iv;
6319  return TRUE;
6320  }
6321  if (i!=0)
6322  {
6323  if (i<0) i = -i;
6324  di = 2 * i + 1;
6325  for (k=0; k<iv->length(); k++)
6326  {
6327  (*iv)[k] = ((siRand() % di) - i);
6328  }
6329  }
6330  res->data = (char *)iv;
6331  return FALSE;
6332 }
6333 #ifdef SINGULAR_4_1
6335 // <coeff>, par1, par2 -> number2
6336 {
6337  coeffs cf=(coeffs)w->Data();
6338  if ((cf==NULL) ||(cf->cfRandom==NULL))
6339  {
6340  Werror("no random function defined for coeff %d",cf->type);
6341  return TRUE;
6342  }
6343  else
6344  {
6345  number n= n_Random(siRand,(number)v->Data(),(number)w->Data(),cf);
6346  number2 nn=(number2)omAlloc(sizeof(*nn));
6347  nn->cf=cf;
6348  nn->n=n;
6349  res->data=nn;
6350  return FALSE;
6351  }
6352  return TRUE;
6353 }
6354 #endif
6356  int &ringvar, poly &monomexpr)
6357 {
6358  monomexpr=(poly)w->Data();
6359  poly p=(poly)v->Data();
6360 #if 0
6361  if (pLength(monomexpr)>1)
6362  {
6363  Werror("`%s` substitutes a ringvar only by a term",
6365  return TRUE;
6366  }
6367 #endif
6368  if ((ringvar=pVar(p))==0)
6369  {
6370  if ((p!=NULL) && (currRing->cf->extRing!=NULL))
6371  {
6372  number n = pGetCoeff(p);
6373  ringvar= -n_IsParam(n, currRing);
6374  }
6375  if(ringvar==0)
6376  {
6377  WerrorS("ringvar/par expected");
6378  return TRUE;
6379  }
6380  }
6381  return FALSE;
6382 }
6384 {
6385  int ringvar;
6386  poly monomexpr;
6387  BOOLEAN nok=jjSUBST_Test(v,w,ringvar,monomexpr);
6388  if (nok) return TRUE;
6389  poly p=(poly)u->Data();
6390  if (ringvar>0)
6391  {
6392  if ((monomexpr!=NULL) && (p!=NULL) && (pTotaldegree(p)!=0) &&
6393  ((unsigned long)pTotaldegree(monomexpr) > (currRing->bitmask / (unsigned long)pTotaldegree(p)/2)))
6394  {
6395  Warn("possible OVERFLOW in subst, max exponent is %ld, substituting deg %d by deg %d",currRing->bitmask/2, pTotaldegree(monomexpr), pTotaldegree(p));
6396  //return TRUE;
6397  }
6398  if ((monomexpr==NULL)||(pNext(monomexpr)==NULL))
6399  res->data = pSubst((poly)u->CopyD(res->rtyp),ringvar,monomexpr);
6400  else
6401  res->data= pSubstPoly(p,ringvar,monomexpr);
6402  }
6403  else
6404  {
6405  res->data=pSubstPar(p,-ringvar,monomexpr);
6406  }
6407  return FALSE;
6408 }
6410 {
6411  int ringvar;
6412  poly monomexpr;
6413  BOOLEAN nok=jjSUBST_Test(v,w,ringvar,monomexpr);
6414  if (nok) return TRUE;
6415  ideal id=(ideal)u->Data();
6416  if (ringvar>0)
6417  {
6418  BOOLEAN overflow=FALSE;
6419  if (monomexpr!=NULL)
6420  {
6421  long deg_monexp=pTotaldegree(monomexpr);
6422  for(int i=IDELEMS(id)-1;i>=0;i--)
6423  {
6424  poly p=id->m[i];
6425  if ((p!=NULL) && (pTotaldegree(p)!=0) &&
6426  ((unsigned long)deg_monexp > (currRing->bitmask / (unsigned long)pTotaldegree(p)/2)))
6427  {
6428  overflow=TRUE;
6429  break;
6430  }
6431  }
6432  }
6433  if (overflow)
6434  Warn("possible OVERFLOW in subst, max exponent is %ld",currRing->bitmask/2);
6435  if ((monomexpr==NULL)||(pNext(monomexpr)==NULL))
6436  {
6437  if (res->rtyp==MATRIX_CMD) id=(ideal)mp_Copy((matrix)id,currRing);
6438  else id=id_Copy(id,currRing);
6439  res->data = id_Subst(id, ringvar, monomexpr, currRing);
6440  }
6441  else
6442  res->data = idSubstPoly(id,ringvar,monomexpr);
6443  }
6444  else
6445  {
6446  res->data = idSubstPar(id,-ringvar,monomexpr);
6447  }
6448  return FALSE;
6449 }
6450 // we do not want to have jjSUBST_Id_X inlined:
6451 static BOOLEAN jjSUBST_Id_X(leftv res, leftv u, leftv v,leftv w,
6452  int input_type);
6454 {
6455  return jjSUBST_Id_X(res,u,v,w,INT_CMD);
6456 }
6458 {
6459  return jjSUBST_Id_X(res,u,v,w,NUMBER_CMD);
6460 }
6461 static BOOLEAN jjSUBST_Id_X(leftv res, leftv u, leftv v,leftv w, int input_type)
6462 {
6463  sleftv tmp;
6464  memset(&tmp,0,sizeof(tmp));
6465  // do not check the result, conversion from int/number to poly works always
6466  iiConvert(input_type,POLY_CMD,iiTestConvert(input_type,POLY_CMD),w,&tmp);
6467  BOOLEAN b=jjSUBST_Id(res,u,v,&tmp);
6468  tmp.CleanUp();
6469  return b;
6470 }
6472 {
6473  int mi=(int)(long)v->Data();
6474  int ni=(int)(long)w->Data();
6475  if ((mi<1)||(ni<1))
6476  {
6477  Werror("converting ideal to matrix: dimensions must be positive(%dx%d)",mi,ni);
6478  return TRUE;
6479  }
6480  matrix m=mpNew(mi,ni);
6481  ideal I=(ideal)u->CopyD(IDEAL_CMD);
6482  int i=si_min(IDELEMS(I),mi*ni);
6483  //for(i=i-1;i>=0;i--)
6484  //{
6485  // m->m[i]=I->m[i];
6486  // I->m[i]=NULL;
6487  //}
6488  memcpy(m->m,I->m,i*sizeof(poly));
6489  memset(I->m,0,i*sizeof(poly));
6490  id_Delete(&I,currRing);
6491  res->data = (char *)m;
6492  return FALSE;
6493 }
6495 {
6496  int mi=(int)(long)v->Data();
6497  int ni=(int)(long)w->Data();
6498  if ((mi<1)||(ni<1))
6499  {
6500  Werror("converting module to matrix: dimensions must be positive(%dx%d)",mi,ni);
6501  return TRUE;
6502  }
6503  res->data = (char *)id_Module2formatedMatrix((ideal)u->CopyD(MODUL_CMD),
6504  mi,ni,currRing);
6505  return FALSE;
6506 }
6508 {
6509  int mi=(int)(long)v->Data();
6510  int ni=(int)(long)w->Data();
6511  if ((mi<1)||(ni<1))
6512  {
6513  Werror("converting matrix to matrix: dimensions must be positive(%dx%d)",mi,ni);
6514  return TRUE;
6515  }
6516  matrix m=mpNew(mi,ni);
6517  matrix I=(matrix)u->CopyD(MATRIX_CMD);
6518  int r=si_min(MATROWS(I),mi);
6519  int c=si_min(MATCOLS(I),ni);
6520  int i,j;
6521  for(i=r;i>0;i--)
6522  {
6523  for(j=c;j>0;j--)
6524  {
6525  MATELEM(m,i,j)=MATELEM(I,i,j);
6526  MATELEM(I,i,j)=NULL;
6527  }
6528  }
6529  id_Delete((ideal *)&I,currRing);
6530  res->data = (char *)m;
6531  return FALSE;
6532 }
6533 static BOOLEAN jjLIFT3(leftv res, leftv u, leftv v, leftv w)
6534 {
6535  if (w->rtyp!=IDHDL) return TRUE;
6536  int ul= IDELEMS((ideal)u->Data());
6537  int vl= IDELEMS((ideal)v->Data());
6538  ideal m
6539  = idLift((ideal)u->Data(),(ideal)v->Data(),NULL,FALSE,hasFlag(u,FLAG_STD),
6540  FALSE, (matrix *)(&(IDMATRIX((idhdl)(w->data)))));
6541  if (m==NULL) return TRUE;
6542  res->data = (char *)id_Module2formatedMatrix(m,ul,vl,currRing);
6543  return FALSE;
6544 }
6545 static BOOLEAN jjLIFTSTD3(leftv res, leftv u, leftv v, leftv w)
6546 {
6547  if ((v->rtyp!=IDHDL)||(v->e!=NULL)) return TRUE;
6548  if ((w->rtyp!=IDHDL)||(w->e!=NULL)) return TRUE;
6549  idhdl hv=(idhdl)v->data;
6550  idhdl hw=(idhdl)w->data;
6551  // CopyD for IDEAL_CMD and MODUL_CMD are identical:
6552  res->data = (char *)idLiftStd((ideal)u->Data(),
6553  &(hv->data.umatrix),testHomog,
6554  &(hw->data.uideal));
6555  setFlag(res,FLAG_STD); v->flag=0; w->flag=0;
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(),(poly)u->CopyD(),
6567  (poly)w->CopyD());
6568  return FALSE;
6569 }
6571 {
6572  assumeStdFlag(v);
6573  if (!idIsZeroDim((ideal)v->Data()))
6574  {
6575  Werror("`%s` must be 0-dimensional",v->Name());
6576  return TRUE;
6577  }
6578  res->data = (char *)redNF((ideal)v->CopyD(),(ideal)u->CopyD(),
6579  (matrix)w->CopyD());
6580  return FALSE;
6581 }
6583 {
6584  assumeStdFlag(v);
6585  res->data = (char *)kNF((ideal)v->Data(),currRing->qideal,(poly)u->Data(),
6586  0,(int)(long)w->Data());
6587  return FALSE;
6588 }
6590 {
6591  assumeStdFlag(v);
6592  res->data = (char *)kNF((ideal)v->Data(),currRing->qideal,(ideal)u->Data(),
6593  0,(int)(long)w->Data());
6594  return FALSE;
6595 }
6596 #ifdef OLD_RES
6597 static BOOLEAN jjRES3(leftv res, leftv u, leftv v, leftv w)
6598 {
6599  int maxl=(int)v->Data();
6600  ideal u_id=(ideal)u->Data();
6601  int l=0;
6602  resolvente r;
6603  intvec **weights=NULL;
6604  int wmaxl=maxl;
6605  maxl--;
6606  if ((maxl==-1) && (iiOp!=MRES_CMD))
6607  maxl = currRing->N-1;
6608  if ((iiOp == RES_CMD) || (iiOp == MRES_CMD))
6609  {
6610  intvec * iv=(intvec*)atGet(u,"isHomog",INTVEC_CMD);
6611  if (iv!=NULL)
6612  {
6613  l=1;
6614  if (!idTestHomModule(u_id,currRing->qideal,iv))
6615  {
6616  WarnS("wrong weights");
6617  iv=NULL;
6618  }
6619  else
6620  {
6621  weights = (intvec**)omAlloc0Bin(char_ptr_bin);
6622  weights[0] = ivCopy(iv);
6623  }
6624  }
6625  r=syResolvente(u_id,maxl,&l, &weights, iiOp==MRES_CMD);
6626  }
6627  else
6628  r=sySchreyerResolvente((ideal)u->Data(),maxl+1,&l);
6629  if (r==NULL) return TRUE;
6630  int t3=u->Typ();
6631  iiMakeResolv(r,l,wmaxl,w->name,t3,weights);
6632  return FALSE;
6633 }
6634 #endif
6635 static BOOLEAN jjRING3(leftv res, leftv u, leftv v, leftv w)
6636 {
6637  res->data=(void *)rInit(u,v,w);
6638  return (res->data==NULL);
6639 }
6640 static BOOLEAN jjSTATUS3(leftv res, leftv u, leftv v, leftv w)
6641 {
6642  int yes;
6643  jjSTATUS2(res, u, v);
6644  yes = (strcmp((char *) res->data, (char *) w->Data()) == 0);
6645  omFree((ADDRESS) res->data);
6646  res->data = (void *)(long)yes;
6647  return FALSE;
6648 }
6650 {
6651  intvec *vw=(intvec *)w->Data(); // weights of vars
6652  if (vw->length()!=currRing->N)
6653  {
6654  Werror("%d weights for %d variables",vw->length(),currRing->N);
6655  return TRUE;
6656  }
6657  ideal result;
6658  intvec *ww=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
6659  tHomog hom=testHomog;
6660  ideal u_id=(ideal)(u->Data());
6661  if (ww!=NULL)
6662  {
6663  if (!idTestHomModule(u_id,currRing->qideal,ww))
6664  {
6665  WarnS("wrong weights");
6666  ww=NULL;
6667  }
6668  else
6669  {
6670  ww=ivCopy(ww);
6671  hom=isHomog;
6672  }
6673  }
6674  result=kStd(u_id,
6675  currRing->qideal,
6676  hom,
6677  &ww, // module weights
6678  (intvec *)v->Data(), // hilbert series
6679  0,0, // syzComp, newIdeal
6680  vw); // weights of vars
6681  idSkipZeroes(result);
6682  res->data = (char *)result;
6683  setFlag(res,FLAG_STD);
6684  if (ww!=NULL) atSet(res,omStrDup("isHomog"),ww,INTVEC_CMD);
6685  return FALSE;
6686 }
6687 
6688 /*=================== operations with many arg.: static proc =================*/
6689 /* must be ordered: first operations for chars (infix ops),
6690  * then alphabetically */
6692 {
6693 #ifdef HAVE_SDB
6694  sdb_show_bp();
6695 #endif
6696  return FALSE;
6697 }
6699 {
6700 #ifdef HAVE_SDB
6701  if(v->Typ()==PROC_CMD)
6702  {
6703  int lineno=0;
6704  if((v->next!=NULL) && (v->next->Typ()==INT_CMD))
6705  {
6706  lineno=(int)(long)v->next->Data();
6707  }
6708  return sdb_set_breakpoint(v->Name(),lineno);
6709  }
6710  return TRUE;
6711 #else
6712  return FALSE;
6713 #endif
6714 }
6716 {
6717  return iiExprArith1(res,v,iiOp);
6718 }
6720 {
6721  leftv v=u->next;
6722  u->next=NULL;
6723  BOOLEAN b=iiExprArith2(res,u,iiOp,v, (iiOp > 255));
6724  u->next=v;
6725  return b;
6726 }
6728 {
6729  leftv v = u->next;
6730  leftv w = v->next;
6731  u->next = NULL;
6732  v->next = NULL;
6733  BOOLEAN b = iiExprArith3(res, iiOp, u, v, w);
6734  u->next = v;
6735  v->next = w;
6736  return b;
6737 }
6738 
6740 {
6742  if (iiCheckTypes(v,t))
6743  return TRUE;
6744  idhdl c=(idhdl)v->next->next->data;
6745  if (v->next->next->next->rtyp!=IDHDL) return TRUE;
6746  idhdl m=(idhdl)v->next->next->next->data;
6747  idDelete((ideal *)&(c->data.uideal));
6748  idDelete((ideal *)&(m->data.uideal));
6749  mp_Coef2((poly)v->Data(),(poly)v->next->Data(),
6750  (matrix *)&(c->data.umatrix),(matrix *)&(m->data.umatrix),currRing);
6751  return FALSE;
6752 }
6753 
6755 { // may have 3 or 4 arguments
6756  leftv v1=v;
6757  leftv v2=v1->next;
6758  leftv v3=v2->next;
6759  leftv v4=v3->next;
6760  assumeStdFlag(v2);
6761 
6762  int i1=iiTestConvert(v1->Typ(),MODUL_CMD);
6763  int i2=iiTestConvert(v2->Typ(),MODUL_CMD);
6764 
6765  if((i1==0)||(i2==0)
6766  ||(v3->Typ()!=INT_CMD)||((v4!=NULL)&&(v4->Typ()!=INTVEC_CMD)))
6767  {
6768  WarnS("<module>,<module>,<int>[,<intvec>] expected!");
6769  return TRUE;
6770  }
6771 
6772  sleftv w1,w2;
6773  iiConvert(v1->Typ(),MODUL_CMD,i1,v1,&w1);
6774  iiConvert(v2->Typ(),MODUL_CMD,i2,v2,&w2);
6775  ideal P=(ideal)w1.Data();
6776  ideal Q=(ideal)w2.Data();
6777 
6778  int n=(int)(long)v3->Data();
6779  short *w=NULL;
6780  if(v4!=NULL)
6781  {
6782  w = iv2array((intvec *)v4->Data(),currRing);
6783  short * w0 = w + 1;
6784  int i = currRing->N;
6785  while( (i > 0) && ((*w0) > 0) )
6786  {
6787  w0++;
6788  i--;
6789  }
6790  if(i>0)
6791  WarnS("not all weights are positive!");
6792  }
6793 
6794  matrix T;
6795  ideal R;
6796  idLiftW(P,Q,n,T,R,w);
6797 
6798  w1.CleanUp();
6799  w2.CleanUp();
6800  if(w!=NULL)
6801  omFreeSize( (ADDRESS)w, (rVar(currRing)+1)*sizeof(short) );
6802 
6804  L->Init(2);
6805  L->m[1].rtyp=v1->Typ();
6806  if(v1->Typ()==POLY_CMD||v1->Typ()==VECTOR_CMD)
6807  {
6808  if(v1->Typ()==POLY_CMD)
6809  p_Shift(&R->m[0],-1,currRing);
6810  L->m[1].data=(void *)R->m[0];
6811  R->m[0]=NULL;
6812  idDelete(&R);
6813  }
6814  else if(v1->Typ()==IDEAL_CMD||v1->Typ()==MATRIX_CMD)
6815  L->m[1].data=(void *)id_Module2Matrix(R,currRing);
6816  else
6817  {
6818  L->m[1].rtyp=MODUL_CMD;
6819  L->m[1].data=(void *)R;
6820  }
6821  L->m[0].rtyp=MATRIX_CMD;
6822  L->m[0].data=(char *)T;
6823 
6824  res->data=L;
6825  res->rtyp=LIST_CMD;
6826 
6827  return FALSE;
6828 }
6829 
6830 //BOOLEAN jjDISPATCH(leftv res, leftv v)
6831 //{
6832 // WerrorS("`dispatch`: not implemented");
6833 // return TRUE;
6834 //}
6835 
6836 //static BOOLEAN jjEXPORTTO_M(leftv res, leftv u)
6837 //{
6838 // int l=u->listLength();
6839 // if (l<2) return TRUE;
6840 // BOOLEAN b;
6841 // leftv v=u->next;
6842 // leftv zz=v;
6843 // leftv z=zz;
6844 // u->next=NULL;
6845 // do
6846 // {
6847 // leftv z=z->next;
6848 // b=iiExprArith2(res,u,iiOp,z, (iiOp > 255));
6849 // if (b) break;
6850 // } while (z!=NULL);
6851 // u->next=zz;
6852 // return b;
6853 //}
6855 {
6856  int s=1;
6857  leftv h=v;
6858  if (h!=NULL) s=exprlist_length(h);
6859  ideal id=idInit(s,1);
6860  int rank=1;
6861  int i=0;
6862  poly p;
6863  while (h!=NULL)
6864  {
6865  switch(h->Typ())
6866  {
6867  case POLY_CMD:
6868  {
6869  p=(poly)h->CopyD(POLY_CMD);
6870  break;
6871  }
6872  case INT_CMD:
6873  {
6874  number n=nInit((int)(long)h->Data());
6875  if (!nIsZero(n))
6876  {
6877  p=pNSet(n);
6878  }
6879  else
6880  {
6881  p=NULL;
6882  nDelete(&n);
6883  }
6884  break;
6885  }
6886  case BIGINT_CMD:
6887  {
6888  number b=(number)h->Data();
6890  if (nMap==NULL) return TRUE;
6891  number n=nMap(b,coeffs_BIGINT,currRing->cf);
6892  if (!nIsZero(n))
6893  {
6894  p=pNSet(n);
6895  }
6896  else
6897  {
6898  p=NULL;
6899  nDelete(&n);
6900  }
6901  break;
6902  }
6903  case NUMBER_CMD:
6904  {
6905  number n=(number)h->CopyD(NUMBER_CMD);
6906  if (!nIsZero(n))
6907  {
6908  p=pNSet(n);
6909  }
6910  else
6911  {
6912  p=NULL;
6913  nDelete(&n);
6914  }
6915  break;
6916  }
6917  case VECTOR_CMD:
6918  {
6919  p=(poly)h->CopyD(VECTOR_CMD);
6920  if (iiOp!=MODUL_CMD)
6921  {
6922  idDelete(&id);
6923  pDelete(&p);
6924  return TRUE;
6925  }
6926  rank=si_max(rank,(int)pMaxComp(p));
6927  break;
6928  }
6929  default:
6930  {
6931  idDelete(&id);
6932  return TRUE;
6933  }
6934  }
6935  if ((iiOp==MODUL_CMD)&&(p!=NULL)&&(pGetComp(p)==0))
6936  {
6937  pSetCompP(p,1);
6938  }
6939  id->m[i]=p;
6940  i++;
6941  h=h->next;
6942  }
6943  id->rank=rank;
6944  res->data=(char *)id;
6945  return FALSE;
6946 }
6948 {
6949  ring r=(ring)u->Data();
6950  leftv v=u->next;
6951  leftv perm_var_l=v->next;
6952  leftv perm_par_l=v->next->next;
6953  if ((perm_var_l->Typ()!=INTVEC_CMD)
6954  ||((perm_par_l!=NULL)&&(perm_par_l->Typ()!=INTVEC_CMD))
6955  ||((u->Typ()!=RING_CMD)&&(u->Typ()!=QRING_CMD)))
6956  {
6957  WerrorS("fetch(<ring>,<name>[,<intvec>[,<intvec>])");
6958  return TRUE;
6959  }
6960  intvec *perm_var_v=(intvec*)perm_var_l->Data();
6961  intvec *perm_par_v=NULL;
6962  if (perm_par_l!=NULL)
6963  perm_par_v=(intvec*)perm_par_l->Data();
6964  idhdl w;
6965  nMapFunc nMap;
6966 
6967  if ((w=r->idroot->get(v->Name(),myynest))!=NULL)
6968  {
6969  int *perm=NULL;
6970  int *par_perm=NULL;
6971  int par_perm_size=0;
6972  BOOLEAN bo;
6973  if ((nMap=n_SetMap(r->cf,currRing->cf))==NULL)
6974  {
6975  // Allow imap/fetch to be make an exception only for:
6976  if ( (rField_is_Q_a(r) && // Q(a..) -> Q(a..) || Q || Zp || Zp(a)
6979  ||
6980  (rField_is_Zp_a(r) && // Zp(a..) -> Zp(a..) || Zp
6981  (rField_is_Zp(currRing, r->cf->ch) ||
6982  rField_is_Zp_a(currRing, r->cf->ch))) )
6983  {
6984  par_perm_size=rPar(r);
6985  }
6986  else
6987  {
6988  goto err_fetch;
6989  }
6990  }
6991  else
6992  par_perm_size=rPar(r);
6993  perm=(int *)omAlloc0((rVar(r)+1)*sizeof(int));
6994  if (par_perm_size!=0)
6995  par_perm=(int *)omAlloc0(par_perm_size*sizeof(int));
6996  int i;
6997  if (perm_par_l==NULL)
6998  {
6999  if (par_perm_size!=0)
7000  for(i=si_min(rPar(r),rPar(currRing))-1;i>=0;i--) par_perm[i]=-(i+1);
7001  }
7002  else
7003  {
7004  if (par_perm_size==0) WarnS("source ring has no parameters");
7005  else
7006  {
7007  for(i=rPar(r)-1;i>=0;i--)
7008  {
7009  if (i<perm_par_v->length()) par_perm[i]=(*perm_par_v)[i];
7010  if ((par_perm[i]<-rPar(currRing))
7011  || (par_perm[i]>rVar(currRing)))
7012  {
7013  Warn("invalid entry for par %d: %d\n",i,par_perm[i]);
7014  par_perm[i]=0;
7015  }
7016  }
7017  }
7018  }
7019  for(i=rVar(r)-1;i>=0;i--)
7020  {
7021  if (i<perm_var_v->length()) perm[i+1]=(*perm_var_v)[i];
7022  if ((perm[i]<-rPar(currRing))
7023  || (perm[i]>rVar(currRing)))
7024  {
7025  Warn("invalid entry for var %d: %d\n",i,perm[i]);
7026  perm[i]=0;
7027  }
7028  }
7029  if (BVERBOSE(V_IMAP))
7030  {
7031  for(i=1;i<=si_min(rVar(r),rVar(currRing));i++)
7032  {
7033  if (perm[i]>0)
7034  Print("// var nr %d: %s -> var %s\n",i,r->names[i-1],currRing->names[perm[i]-1]);
7035  else if (perm[i]<0)
7036  Print("// var nr %d: %s -> par %s\n",i,r->names[i-1],rParameter(currRing)[-perm[i]-1]);
7037  }
7038  for(i=1;i<=si_min(rPar(r),rPar(currRing));i++) // possibly empty loop
7039  {
7040  if (par_perm[i-1]<0)
7041  Print("// par nr %d: %s -> par %s\n",
7042  i,rParameter(r)[i-1],rParameter(currRing)[-par_perm[i-1]-1]);
7043  else if (par_perm[i-1]>0)
7044  Print("// par nr %d: %s -> var %s\n",
7045  i,rParameter(r)[i-1],currRing->names[par_perm[i-1]-1]);
7046  }
7047  }
7048  if (IDTYP(w)==ALIAS_CMD) w=(idhdl)IDDATA(w);
7049  sleftv tmpW;
7050  memset(&tmpW,0,sizeof(sleftv));
7051  tmpW.rtyp=IDTYP(w);
7052  tmpW.data=IDDATA(w);
7053  if ((bo=maApplyFetch(IMAP_CMD,NULL,res,&tmpW, r,
7054  perm,par_perm,par_perm_size,nMap)))
7055  {
7056  Werror("cannot map %s of type %s(%d)",v->name, Tok2Cmdname(w->typ),w->typ);
7057  }
7058  if (perm!=NULL)
7059  omFreeSize((ADDRESS)perm,(rVar(r)+1)*sizeof(int));
7060  if (par_perm!=NULL)
7061  omFreeSize((ADDRESS)par_perm,par_perm_size*sizeof(int));
7062  return bo;
7063  }
7064  else
7065  {
7066  Werror("identifier %s not found in %s",v->Fullname(),u->Fullname());
7067  }
7068  return TRUE;
7069 err_fetch:
7070  Werror("no identity map from %s (%s -> %s)",u->Fullname(),
7071  nCoeffString(r->cf),
7072  nCoeffString(currRing->cf));
7073  return TRUE;
7074 }
7076 {
7077  leftv h=v;
7078  int l=v->listLength();
7079  resolvente r=(resolvente)omAlloc0(l*sizeof(ideal));
7080  BOOLEAN *copied=(BOOLEAN *)omAlloc0(l*sizeof(BOOLEAN));
7081  int t=0;
7082  // try to convert to IDEAL_CMD
7083  while (h!=NULL)
7084  {
7085  if (iiTestConvert(h->Typ(),IDEAL_CMD)!=0)
7086  {
7087  t=IDEAL_CMD;
7088  }
7089  else break;
7090  h=h->next;
7091  }
7092  // if failure, try MODUL_CMD
7093  if (t==0)
7094  {
7095  h=v;
7096  while (h!=NULL)
7097  {
7098  if (iiTestConvert(h->Typ(),MODUL_CMD)!=0)
7099  {
7100  t=MODUL_CMD;
7101  }
7102  else break;
7103  h=h->next;
7104  }
7105  }
7106  // check for success in converting
7107  if (t==0)
7108  {
7109  WerrorS("cannot convert to ideal or module");
7110  return TRUE;
7111  }
7112  // call idMultSect
7113  h=v;
7114  int i=0;
7115  sleftv tmp;
7116  while (h!=NULL)
7117  {
7118  if (h->Typ()==t)
7119  {
7120  r[i]=(ideal)h->Data(); /*no copy*/
7121  h=h->next;
7122  }
7123  else if(iiConvert(h->Typ(),t,iiTestConvert(h->Typ(),t),h,&tmp))
7124  {
7125  omFreeSize((ADDRESS)copied,l*sizeof(BOOLEAN));
7126  omFreeSize((ADDRESS)r,l*sizeof(ideal));
7127  Werror("cannot convert arg. %d to %s",i+1,Tok2Cmdname(t));
7128  return TRUE;
7129  }
7130  else
7131  {
7132  r[i]=(ideal)tmp.Data(); /*now it's a copy*/
7133  copied[i]=TRUE;
7134  h=tmp.next;
7135  }
7136  i++;
7137  }
7138  res->rtyp=t;
7139  res->data=(char *)idMultSect(r,i);
7140  while(i>0)
7141  {
7142  i--;
7143  if (copied[i]) idDelete(&(r[i]));
7144  }
7145  omFreeSize((ADDRESS)copied,l*sizeof(BOOLEAN));
7146  omFreeSize((ADDRESS)r,l*sizeof(ideal));
7147  return FALSE;
7148 }
7150 {
7151  /* computation of the inverse of a quadratic matrix A
7152  using the L-U-decomposition of A;
7153  There are two valid parametrisations:
7154  1) exactly one argument which is just the matrix A,
7155  2) exactly three arguments P, L, U which already
7156  realise the L-U-decomposition of A, that is,
7157  P * A = L * U, and P, L, and U satisfy the
7158  properties decribed in method 'jjLU_DECOMP';
7159  see there;
7160  If A is invertible, the list [1, A^(-1)] is returned,
7161  otherwise the list [0] is returned. Thus, the user may
7162  inspect the first entry of the returned list to see
7163  whether A is invertible. */
7164  matrix iMat; int invertible;
7165  short t1[]={1,MATRIX_CMD};
7166  short t2[]={3,MATRIX_CMD,MATRIX_CMD,MATRIX_CMD};
7167  if (iiCheckTypes(v,t1))
7168  {
7169  matrix aMat = (matrix)v->Data();
7170  int rr = aMat->rows();
7171  int cc = aMat->cols();
7172  if (rr != cc)
7173  {
7174  Werror("given matrix (%d x %d) is not quadratic, hence not invertible", rr, cc);
7175  return TRUE;
7176  }
7177  if (!idIsConstant((ideal)aMat))
7178  {
7179  WerrorS("matrix must be constant");
7180  return TRUE;
7181  }
7182  invertible = luInverse(aMat, iMat);
7183  }
7184  else if (iiCheckTypes(v,t2))
7185  {
7186  matrix pMat = (matrix)v->Data();
7187  matrix lMat = (matrix)v->next->Data();
7188  matrix uMat = (matrix)v->next->next->Data();
7189  int rr = uMat->rows();
7190  int cc = uMat->cols();
7191  if (rr != cc)
7192  {
7193  Werror("third matrix (%d x %d) is not quadratic, hence not invertible",
7194  rr, cc);
7195  return TRUE;
7196  }
7197  if (!idIsConstant((ideal)pMat)
7198  || (!idIsConstant((ideal)lMat))
7199  || (!idIsConstant((ideal)uMat))
7200  )
7201  {
7202  WerrorS("matricesx must be constant");
7203  return TRUE;
7204  }
7205  invertible = luInverseFromLUDecomp(pMat, lMat, uMat, iMat);
7206  }
7207  else
7208  {
7209  Werror("expected either one or three matrices");
7210  return TRUE;
7211  }
7212 
7213  /* build the return structure; a list with either one or two entries */
7215  if (invertible)
7216  {
7217  ll->Init(2);
7218  ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)invertible;
7219  ll->m[1].rtyp=MATRIX_CMD; ll->m[1].data=(void *)iMat;
7220  }
7221  else
7222  {
7223  ll->Init(1);
7224  ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)invertible;
7225  }
7226 
7227  res->data=(char*)ll;
7228  return FALSE;
7229 }
7231 {
7232  /* for solving a linear equation system A * x = b, via the
7233  given LU-decomposition of the matrix A;
7234  There is one valid parametrisation:
7235  1) exactly four arguments P, L, U, b;
7236  P, L, and U realise the L-U-decomposition of A, that is,
7237  P * A = L * U, and P, L, and U satisfy the
7238  properties decribed in method 'jjLU_DECOMP';
7239  see there;
7240  b is the right-hand side vector of the equation system;
7241  The method will return a list of either 1 entry or three entries:
7242  1) [0] if there is no solution to the system;
7243  2) [1, x, H] if there is at least one solution;
7244  x is any solution of the given linear system,
7245  H is the matrix with column vectors spanning the homogeneous
7246  solution space.
7247  The method produces an error if matrix and vector sizes do not fit. */
7248  short t[]={4,MATRIX_CMD,MATRIX_CMD,MATRIX_CMD,MATRIX_CMD};
7249  if (!iiCheckTypes(v,t))
7250  {
7251  WerrorS("expected exactly three matrices and one vector as input");
7252  return TRUE;
7253  }
7254  matrix pMat = (matrix)v->Data();
7255  matrix lMat = (matrix)v->next->Data();
7256  matrix uMat = (matrix)v->next->next->Data();
7257  matrix bVec = (matrix)v->next->next->next->Data();
7258  matrix xVec; int solvable; matrix homogSolSpace;
7259  if (pMat->rows() != pMat->cols())
7260  {
7261  Werror("first matrix (%d x %d) is not quadratic",
7262  pMat->rows(), pMat->cols());
7263  return TRUE;
7264  }
7265  if (lMat->rows() != lMat->cols())
7266  {
7267  Werror("second matrix (%d x %d) is not quadratic",
7268  lMat->rows(), lMat->cols());
7269  return TRUE;
7270  }
7271  if (lMat->rows() != uMat->rows())
7272  {
7273  Werror("second matrix (%d x %d) and third matrix (%d x %d) do not fit",
7274  lMat->rows(), lMat->cols(), uMat->rows(), uMat->cols());
7275  return TRUE;
7276  }
7277  if (uMat->rows() != bVec->rows())
7278  {
7279  Werror("third matrix (%d x %d) and vector (%d x 1) do not fit",
7280  uMat->rows(), uMat->cols(), bVec->rows());
7281  return TRUE;
7282  }
7283  if (!idIsConstant((ideal)pMat)
7284  ||(!idIsConstant((ideal)lMat))
7285  ||(!idIsConstant((ideal)uMat))
7286  )
7287  {
7288  WerrorS("matrices must be constant");
7289  return TRUE;
7290  }
7291  solvable = luSolveViaLUDecomp(pMat, lMat, uMat, bVec, xVec, homogSolSpace);
7292 
7293  /* build the return structure; a list with either one or three entries */
7295  if (solvable)
7296  {
7297  ll->Init(3);
7298  ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)solvable;
7299  ll->m[1].rtyp=MATRIX_CMD; ll->m[1].data=(void *)xVec;
7300  ll->m[2].rtyp=MATRIX_CMD; ll->m[2].data=(void *)homogSolSpace;
7301  }
7302  else
7303  {
7304  ll->Init(1);
7305  ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)solvable;
7306  }
7307 
7308  res->data=(char*)ll;
7309  return FALSE;
7310 }
7312 {
7313  int i=0;
7314  leftv h=v;
7315  if (h!=NULL) i=exprlist_length(h);
7316  intvec *iv=new intvec(i);
7317  i=0;
7318  while (h!=NULL)
7319  {
7320  if(h->Typ()==INT_CMD)
7321  {
7322  (*iv)[i]=(int)(long)h->Data();
7323  }
7324  else if (h->Typ()==INTVEC_CMD)
7325  {
7326  intvec *ivv=(intvec*)h->Data();
7327  for(int j=0;j<ivv->length();j++,i++)
7328  {
7329  (*iv)[i]=(*ivv)[j];
7330  }
7331  i--;
7332  }
7333  else
7334  {
7335  delete iv;
7336  return TRUE;
7337  }
7338  i++;
7339  h=h->next;
7340  }
7341  res->data=(char *)iv;
7342  return FALSE;
7343 }
7344 static BOOLEAN jjJET4(leftv res, leftv u)
7345 {
7346  short t1[]={4,POLY_CMD,POLY_CMD,POLY_CMD,INTVEC_CMD};
7347  short t2[]={4,VECTOR_CMD,POLY_CMD,POLY_CMD,INTVEC_CMD};
7348  short t3[]={4,IDEAL_CMD,MATRIX_CMD,INT_CMD,INTVEC_CMD};
7349  short t4[]={4,MODUL_CMD,MATRIX_CMD,INT_CMD,INTVEC_CMD};
7350  leftv u1=u;
7351  leftv u2=u1->next;
7352  leftv u3=u2->next;
7353  leftv u4=u3->next;
7354  if (iiCheckTypes(u,t1)||iiCheckTypes(u,t2))
7355  {
7356  if(!pIsUnit((poly)u2->Data()))
7357  {
7358  WerrorS("2nd argument must be a unit");
7359  return TRUE;
7360  }
7361  res->rtyp=u1->Typ();
7362  res->data=(char*)pSeries((int)(long)u3->Data(),pCopy((poly)u1->Data()),
7363  pCopy((poly)u2->Data()),(intvec*)u4->Data());
7364  return FALSE;
7365  }
7366  else
7367  if (iiCheckTypes(u,t3)||iiCheckTypes(u,t4))
7368  {
7369  if(!mp_IsDiagUnit((matrix)u2->Data(), currRing))
7370  {
7371  WerrorS("2nd argument must be a diagonal matrix of units");
7372  return TRUE;
7373  }
7374  res->rtyp=u1->Typ();
7375  res->data=(char*)idSeries(
7376  (int)(long)u3->Data(),
7377  idCopy((ideal)u1->Data()),
7378  mp_Copy((matrix)u2->Data(), currRing),
7379  (intvec*)u4->Data()
7380  );
7381  return FALSE;
7382  }
7383  else
7384  {
7385  Werror("%s(`poly`,`poly`,`int`,`intvec`) exppected",
7386  Tok2Cmdname(iiOp));
7387  return TRUE;
7388  }
7389 }
7391 {
7392  if ((yyInRingConstruction)
7393  && ((strcmp(u->Name(),"real")==0) || (strcmp(u->Name(),"complex")==0)))
7394  {
7395  memcpy(res,u,sizeof(sleftv));
7396  memset(u,0,sizeof(sleftv));
7397  return FALSE;
7398  }
7399  leftv v=u->next;
7400  BOOLEAN b;
7401  if(v==NULL)
7402  b=iiExprArith1(res,u,iiOp);
7403  else
7404  {
7405  u->next=NULL;
7406  b=iiExprArith2(res,u,iiOp,v);
7407  u->next=v;
7408  }
7409  return b;
7410 }
7412 {
7413  int sl=0;
7414  if (v!=NULL) sl = v->listLength();
7415  lists L;
7416  if((sl==1)&&(v->Typ()==RESOLUTION_CMD))
7417  {
7418  int add_row_shift = 0;
7419  intvec *weights=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
7420  if (weights!=NULL) add_row_shift=weights->min_in();
7421  L=syConvRes((syStrategy)v->Data(),FALSE,add_row_shift);
7422  }
7423  else
7424  {
7426  leftv h=NULL;
7427  int i;
7428  int rt;
7429 
7430  L->Init(sl);
7431  for (i=0;i<sl;i++)
7432  {
7433  if (h!=NULL)
7434  { /* e.g. not in the first step:
7435  * h is the pointer to the old sleftv,
7436  * v is the pointer to the next sleftv
7437  * (in this moment) */
7438  h->next=v;
7439  }
7440  h=v;
7441  v=v->next;
7442  h->next=NULL;
7443  rt=h->Typ();
7444  if (rt==0)
7445  {
7446  L->Clean();
7447  Werror("`%s` is undefined",h->Fullname());
7448  return TRUE;
7449  }
7450  if ((rt==RING_CMD)||(rt==QRING_CMD))
7451  {
7452  L->m[i].rtyp=rt; L->m[i].data=h->Data();
7453  ((ring)L->m[i].data)->ref++;
7454  }
7455  else
7456  L->m[i].Copy(h);
7457  }
7458  }
7459  res->data=(char *)L;
7460  return FALSE;
7461 }
7463 {
7464  res->data=(void *)ipNameList(IDROOT);
7465  return FALSE;
7466 }
7468 {
7469  if(v==NULL)
7470  {
7471  res->data=(char *)showOption();
7472  return FALSE;
7473  }
7474  res->rtyp=NONE;
7475  return setOption(res,v);
7476 }
7478 {
7479  leftv u1=u;
7480  leftv u2=u1->next;
7481  leftv u3=u2->next;
7482  leftv u4=u3->next;
7483  if((u3->Typ()==INT_CMD)&&(u4->Typ()==INTVEC_CMD))
7484  {
7485  int save_d=Kstd1_deg;
7486  Kstd1_deg=(int)(long)u3->Data();
7487  kModW=(intvec *)u4->Data();
7488  BITSET save2;
7489  SI_SAVE_OPT2(save2);
7491  u2->next=NULL;
7492  BOOLEAN r=jjCALL2ARG(res,u);
7493  kModW=NULL;
7494  Kstd1_deg=save_d;
7495  SI_RESTORE_OPT2(save2);
7496  u->next->next=u3;
7497  return r;
7498  }
7499  else
7500  if((u1->Typ()==IDEAL_CMD)&&(u2->Typ()==MATRIX_CMD)&&(u3->Typ()==IDEAL_CMD)&&
7501  (u4->Typ()==INT_CMD))
7502  {
7503  assumeStdFlag(u3);
7504  if(!mp_IsDiagUnit((matrix)u2->Data(), currRing))
7505  {
7506  WerrorS("2nd argument must be a diagonal matrix of units");
7507  return TRUE;
7508  }
7509  res->rtyp=IDEAL_CMD;
7510  res->data=(char*)redNF(
7511  idCopy((ideal)u3->Data()),
7512  idCopy((ideal)u1->Data()),
7513  mp_Copy((matrix)u2->Data(), currRing),
7514  (int)(long)u4->Data()
7515  );
7516  return FALSE;
7517  }
7518  else
7519  if((u1->Typ()==POLY_CMD)&&(u2->Typ()==POLY_CMD)&&(u3->Typ()==IDEAL_CMD)&&
7520  (u4->Typ()==INT_CMD))
7521  {
7522  assumeStdFlag(u3);
7523  if(!pIsUnit((poly)u2->Data()))
7524  {
7525  WerrorS("2nd argument must be a unit");
7526  return TRUE;
7527  }
7528  res->rtyp=POLY_CMD;
7529  res->data=(char*)redNF(idCopy((ideal)u3->Data()),pCopy((poly)u1->Data()),
7530  pCopy((poly)u2->Data()),(int)(long)u4->Data());
7531  return FALSE;
7532  }
7533  else
7534  {
7535  Werror("%s(`poly`,`ideal`,`int`,`intvec`) expected",Tok2Cmdname(iiOp));
7536  return TRUE;
7537  }
7538 }
7540 {
7541  leftv u1=u;
7542  leftv u2=u1->next;
7543  leftv u3=u2->next;
7544  leftv u4=u3->next;
7545  leftv u5=u4->next;
7546  if((u1->Typ()==IDEAL_CMD)&&(u2->Typ()==MATRIX_CMD)&&(u3->Typ()==IDEAL_CMD)&&
7547  (u4->Typ()==INT_CMD)&&(u5->Typ()==INTVEC_CMD))
7548  {
7549  assumeStdFlag(u3);
7550  if(!mp_IsDiagUnit((matrix)u2->Data(), currRing))
7551  {
7552  WerrorS("2nd argument must be a diagonal matrix of units");
7553  return TRUE;
7554  }
7555  res->rtyp=IDEAL_CMD;
7556  res->data=(char*)redNF(
7557  idCopy((ideal)u3->Data()),
7558  idCopy((ideal)u1->Data()),
7559  mp_Copy((matrix)u2->Data(),currRing),
7560  (int)(long)u4->Data(),
7561  (intvec*)u5->Data()
7562  );
7563  return FALSE;
7564  }
7565  else
7566  if((u1->Typ()==POLY_CMD)&&(u2->Typ()==POLY_CMD)&&(u3->Typ()==IDEAL_CMD)&&
7567  (u4->Typ()==INT_CMD)&&(u5->Typ()==INTVEC_CMD))
7568  {
7569  assumeStdFlag(u3);
7570  if(!pIsUnit((poly)u2->Data()))
7571  {
7572  WerrorS("2nd argument must be a unit");
7573  return TRUE;
7574  }
7575  res->rtyp=POLY_CMD;
7576  res->data=(char*)redNF(idCopy((ideal)u3->Data()),pCopy((poly)u1->Data()),
7577  pCopy((poly)u2->Data()),
7578  (int)(long)u4->Data(),(intvec*)u5->Data());
7579  return FALSE;
7580  }
7581  else
7582  {
7583  Werror("%s(`ideal`,`ideal`,`matrix`,`int`,`intvec`) exppected",
7584  Tok2Cmdname(iiOp));
7585  return TRUE;
7586  }
7587 }
7589 {
7590  int i=1;
7591  int nCount = (sArithBase.nCmdUsed-1)/3;
7592  if((3*nCount)<sArithBase.nCmdUsed) nCount++;
7593  //Print("CMDS: %d/%d\n", sArithBase.nCmdUsed,
7594  // sArithBase.nCmdAllocated);
7595  for(i=0; i<nCount; i++)
7596  {
7597  Print("%-20s",sArithBase.sCmds[i+1].name);
7598  if(i+1+nCount<sArithBase.nCmdUsed)
7599  Print("%-20s",sArithBase.sCmds[i+1+nCount].name);
7600  if(i+1+2*nCount<sArithBase.nCmdUsed)
7601  Print("%-20s",sArithBase.sCmds[i+1+2*nCount].name);
7602  //if ((i%3)==1) PrintLn();
7603  PrintLn();
7604  }
7605  PrintLn();
7607  return FALSE;
7608 }
7610 {
7611  if (v == NULL)
7612  {
7613  res->data = omStrDup("");
7614  return FALSE;
7615  }
7616  int n = v->listLength();
7617  if (n == 1)
7618  {
7619  res->data = v->String();
7620  return FALSE;
7621  }
7622 
7623  char** slist = (char**) omAlloc(n*sizeof(char*));
7624  int i, j;
7625 
7626  for (i=0, j=0; i<n; i++, v = v ->next)
7627  {
7628  slist[i] = v->String();
7629  assume(slist[i] != NULL);
7630  j+=strlen(slist[i]);
7631  }
7632  char* s = (char*) omAlloc((j+1)*sizeof(char));
7633  *s='\0';
7634  for (i=0;i<n;i++)
7635  {
7636  strcat(s, slist[i]);
7637  omFree(slist[i]);
7638  }
7639  omFreeSize(slist, n*sizeof(char*));
7640  res->data = s;
7641  return FALSE;
7642 }
7644 {
7645  do
7646  {
7647  if (v->Typ()!=INT_CMD)
7648  return TRUE;
7649  test_cmd((int)(long)v->Data());
7650  v=v->next;
7651  }
7652  while (v!=NULL);
7653  return FALSE;
7654 }
7655 
7656 #if defined(__alpha) && !defined(linux)
7657 extern "C"
7658 {
7659  void usleep(unsigned long usec);
7660 };
7661 #endif
7663 {
7664  /* compute two factors of h(x,y) modulo x^(d+1) in K[[x]][y],
7665  see a detailed documentation in /kernel/linear_algebra/linearAlgebra.h
7666 
7667  valid argument lists:
7668  - (poly h, int d),
7669  - (poly h, int d, poly f0, poly g0), optional: factors of h(0,y),
7670  - (poly h, int d, int xIndex, int yIndex), optional: indices of vars x & y
7671  in list of ring vars,
7672  - (poly h, int d, poly f0, poly g0, int xIndex, int yIndec),
7673  optional: all 4 optional args
7674  (The defaults are xIndex = 1, yIndex = 2, f0 and g0 polynomials as found
7675  by singclap_factorize and h(0, y)
7676  has exactly two distinct monic factors [possibly with exponent > 1].)
7677  result:
7678  - list with the two factors f and g such that
7679  h(x,y) = f(x,y)*g(x,y) mod x^(d+1) */
7680 
7681  poly h = NULL;
7682  int d = 1;
7683  poly f0 = NULL;
7684  poly g0 = NULL;
7685  int xIndex = 1; /* default index if none provided */
7686  int yIndex = 2; /* default index if none provided */
7687 
7688  leftv u = v; int factorsGiven = 0;
7689  if ((u == NULL) || (u->Typ() != POLY_CMD))
7690  {
7691  WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
7692  return TRUE;
7693  }
7694  else h = (poly)u->Data();
7695  u = u->next;
7696  if ((u == NULL) || (u->Typ() != INT_CMD))
7697  {
7698  WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
7699  return TRUE;
7700  }
7701  else d = (int)(long)u->Data();
7702  u = u->next;
7703  if ((u != NULL) && (u->Typ() == POLY_CMD))
7704  {
7705  if ((u->next == NULL) || (u->next->Typ() != POLY_CMD))
7706  {
7707  WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
7708  return TRUE;
7709  }
7710  else
7711  {
7712  f0 = (poly)u->Data();
7713  g0 = (poly)u->next->Data();
7714  factorsGiven = 1;
7715  u = u->next->next;
7716  }
7717  }
7718  if ((u != NULL) && (u->Typ() == INT_CMD))
7719  {
7720  if ((u->next == NULL) || (u->next->Typ() != INT_CMD))
7721  {
7722  WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
7723  return TRUE;
7724  }
7725  else
7726  {
7727  xIndex = (int)(long)u->Data();
7728  yIndex = (int)(long)u->next->Data();
7729  u = u->next->next;
7730  }
7731  }
7732  if (u != NULL)
7733  {
7734  WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
7735  return TRUE;
7736  }
7737 
7738  /* checks for provided arguments */
7739  if (pIsConstant(h) || (factorsGiven && (pIsConstant(f0) || pIsConstant(g0))))
7740  {
7741  WerrorS("expected non-constant polynomial argument(s)");
7742  return TRUE;
7743  }
7744  int n = rVar(currRing);
7745  if ((xIndex < 1) || (n < xIndex))
7746  {
7747  Werror("index for variable x (%d) out of range [1..%d]", xIndex, n);
7748  return TRUE;
7749  }
7750  if ((yIndex < 1) || (n < yIndex))
7751  {
7752  Werror("index for variable y (%d) out of range [1..%d]", yIndex, n);
7753  return TRUE;
7754  }
7755  if (xIndex == yIndex)
7756  {
7757  WerrorS("expected distinct indices for variables x and y");
7758  return TRUE;
7759  }
7760 
7761  /* computation of f0 and g0 if missing */
7762  if (factorsGiven == 0)
7763  {
7764  poly h0 = pSubst(pCopy(h), xIndex, NULL);
7765  intvec* v = NULL;
7766  ideal i = singclap_factorize(h0, &v, 0,currRing);
7767 
7768  ivTest(v);
7769 
7770  if (i == NULL) return TRUE;
7771 
7772  idTest(i);
7773 
7774  if ((v->rows() != 3) || ((*v)[0] =! 1) || (!nIsOne(pGetCoeff(i->m[0]))))
7775  {
7776  WerrorS("expected h(0,y) to have exactly two distinct monic factors");
7777  return TRUE;
7778  }
7779  f0 = pPower(pCopy(i->m[1]), (*v)[1]);
7780  g0 = pPower(pCopy(i->m[2]), (*v)[2]);
7781  idDelete(&i);
7782  }
7783 
7784  poly f; poly g;
7785  henselFactors(xIndex, yIndex, h, f0, g0, d, f, g);
7787  L->Init(2);
7788  L->m[0].rtyp = POLY_CMD; L->m[0].data=(void*)f;
7789  L->m[1].rtyp = POLY_CMD; L->m[1].data=(void*)g;
7790  res->rtyp = LIST_CMD;
7791  res->data = (char*)L;
7792  return FALSE;
7793 }
7795 {
7796  if ((v->Typ() != LINK_CMD) ||
7797  (v->next->Typ() != STRING_CMD) ||
7798  (v->next->next->Typ() != STRING_CMD) ||
7799  (v->next->next->next->Typ() != INT_CMD))
7800  return TRUE;
7801  jjSTATUS3(res, v, v->next, v->next->next);
7802 #if defined(HAVE_USLEEP)
7803  if (((long) res->data) == 0L)
7804  {
7805  int i_s = (int)(long) v->next->next->next->Data();
7806  if (i_s > 0)
7807  {
7808  usleep((int)(long) v->next->next->next->Data());
7809  jjSTATUS3(res, v, v->next, v->next->next);
7810  }
7811  }
7812 #elif defined(HAVE_SLEEP)
7813  if (((int) res->data) == 0)
7814  {
7815  int i_s = (int) v->next->next->next->Data();
7816  if (i_s > 0)
7817  {
7818  si_sleep((is - 1)/1000000 + 1);
7819  jjSTATUS3(res, v, v->next, v->next->next);
7820  }
7821  }
7822 #endif
7823  return FALSE;
7824 }
7826 {
7827  leftv v = u->next; // number of args > 0
7828  if (v==NULL) return TRUE;
7829  leftv w = v->next;
7830  if (w==NULL) return TRUE;
7831  leftv rest = w->next;;
7832 
7833  u->next = NULL;
7834  v->next = NULL;
7835  w->next = NULL;
7836  BOOLEAN b = iiExprArith3(res, iiOp, u, v, w);
7837  if ((rest!=NULL) && (!b))
7838  {
7839  sleftv tmp_res;
7840  leftv tmp_next=res->next;
7841  res->next=rest;
7842  memset(&tmp_res,0,sizeof(tmp_res));
7843  b = iiExprArithM(&tmp_res,res,iiOp);
7844  memcpy(res,&tmp_res,sizeof(tmp_res));
7845  res->next=tmp_next;
7846  }
7847  u->next = v;
7848  v->next = w;
7849  // rest was w->next, but is already cleaned
7850  return b;
7851 }
7852 static BOOLEAN jjQRDS(leftv res, leftv INPUT)
7853 {
7854  if ((INPUT->Typ() != MATRIX_CMD) ||
7855  (INPUT->next->Typ() != NUMBER_CMD) ||
7856  (INPUT->next->next->Typ() != NUMBER_CMD) ||
7857  (INPUT->next->next->next->Typ() != NUMBER_CMD))
7858  {
7859  WerrorS("expected (matrix, number, number, number) as arguments");
7860  return TRUE;
7861  }
7862  leftv u = INPUT; leftv v = u->next; leftv w = v->next; leftv x = w->next;
7863  res->data = (char *)qrDoubleShift((matrix)(u->Data()),
7864  (number)(v->Data()),
7865  (number)(w->Data()),
7866  (number)(x->Data()));
7867  return FALSE;
7868 }
7869 static BOOLEAN jjSTD_HILB_WP(leftv res, leftv INPUT)
7870 { ideal result;
7871  leftv u = INPUT; /* an ideal, weighted homogeneous and standard */
7872  leftv v = u->next; /* one additional polynomial or ideal */
7873  leftv h = v->next; /* Hilbert vector */
7874  leftv w = h->next; /* weight vector */
7875  assumeStdFlag(u);
7876  ideal i1=(ideal)(u->Data());
7877  ideal i0;
7878  if (((u->Typ()!=IDEAL_CMD)&&(u->Typ()!=MODUL_CMD))
7879  || (h->Typ()!=INTVEC_CMD)
7880  || (w->Typ()!=INTVEC_CMD))
7881  {
7882  WerrorS("expected `std(`ideal/module`,`poly/vector`,`intvec`,`intvec`)");
7883  return TRUE;
7884  }
7885  intvec *vw=(intvec *)w->Data(); // weights of vars
7886  /* merging std_hilb_w and std_1 */
7887  if (vw->length()!=currRing->N)
7888  {
7889  Werror("%d weights for %d variables",vw->length(),currRing->N);
7890  return TRUE;
7891  }
7892  int r=v->Typ();
7893  BOOLEAN cleanup_i0=FALSE;
7894  if ((r==POLY_CMD) ||(r==VECTOR_CMD))
7895  {
7896  i0=idInit(1,i1->rank);
7897  i0->m[0]=(poly)v->Data();
7898  cleanup_i0=TRUE;
7899  }
7900  else if (r==IDEAL_CMD)/* IDEAL */
7901  {
7902  i0=(ideal)v->Data();
7903  }
7904  else
7905  {
7906  WerrorS("expected `std(`ideal/module`,`poly/vector`,`intvec`,`intvec`)");
7907  return TRUE;
7908  }
7909  int ii0=idElem(i0);
7910  i1 = idSimpleAdd(i1,i0);
7911  if (cleanup_i0)
7912  {
7913  memset(i0->m,0,sizeof(poly)*IDELEMS(i0));
7914  idDelete(&i0);
7915  }
7916  intvec *ww=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
7917  tHomog hom=testHomog;
7918  /* u_id from jjSTD_W is now i1 as in jjSTD_1 */
7919  if (ww!=NULL)
7920  {
7921  if (!idTestHomModule(i1,currRing->qideal,ww))
7922  {
7923  WarnS("wrong weights");
7924  ww=NULL;
7925  }
7926  else
7927  {
7928  ww=ivCopy(ww);
7929  hom=isHomog;
7930  }
7931  }
7932  BITSET save1;
7933  SI_SAVE_OPT1(save1);
7935  result=kStd(i1,
7936  currRing->qideal,
7937  hom,
7938  &ww, // module weights
7939  (intvec *)h->Data(), // hilbert series
7940  0, // syzComp, whatever it is...
7941  IDELEMS(i1)-ii0, // new ideal
7942  vw); // weights of vars
7943  SI_RESTORE_OPT1(save1);
7944  idDelete(&i1);
7945  idSkipZeroes(result);
7946  res->data = (char *)result;
7947  if (!TEST_OPT_DEGBOUND) setFlag(res,FLAG_STD);
7948  if (ww!=NULL) atSet(res,omStrDup("isHomog"),ww,INTVEC_CMD);
7949  return FALSE;
7950 }
7951 
7952 
7953 static Subexpr jjMakeSub(leftv e)
7954 {
7955  assume( e->Typ()==INT_CMD );
7956  Subexpr r=(Subexpr)omAlloc0Bin(sSubexpr_bin);
7957  r->start =(int)(long)e->Data();
7958  return r;
7959 }
7960 #define D(A) (A)
7961 #define NULL_VAL NULL
7962 #define IPARITH
7963 #include "table.h"
7964 
7965 #include "iparith.inc"
7966 
7967 /*=================== operations with 2 args. ============================*/
7968 /* must be ordered: first operations for chars (infix ops),
7969  * then alphabetically */
7970 
7972  BOOLEAN proccall,
7973  struct sValCmd2* dA2,
7974  int at, int bt,
7975  struct sConvertTypes *dConvertTypes)
7976 {
7977  memset(res,0,sizeof(sleftv));
7978  BOOLEAN call_failed=FALSE;
7979 
7980  if (!errorreported)
7981  {
7982  int i=0;
7983  iiOp=op;
7984  while (dA2[i].cmd==op)
7985  {
7986  if ((at==dA2[i].arg1)
7987  && (bt==dA2[i].arg2))
7988  {
7989  res->rtyp=dA2[i].res;
7990  if (currRing!=NULL)
7991  {
7992  if (check_valid(dA2[i].valid_for,op)) break;
7993  }
7994  else
7995  {
7996  if (RingDependend(dA2[i].res))
7997  {
7998  WerrorS("no ring active");
7999  break;
8000  }
8001  }
8002  if (traceit&TRACE_CALL)
8003  Print("call %s(%s,%s)\n",iiTwoOps(op),Tok2Cmdname(at),Tok2Cmdname(bt));
8004  if ((call_failed=dA2[i].p(res,a,b)))
8005  {
8006  break;// leave loop, goto error handling
8007  }
8008  a->CleanUp();
8009  b->CleanUp();
8010  //Print("op: %d,result typ:%d\n",op,res->rtyp);
8011  return FALSE;
8012  }
8013  i++;
8014  }
8015  // implicite type conversion ----------------------------------------------
8016  if (dA2[i].cmd!=op)
8017  {
8018  int ai,bi;
8021  BOOLEAN failed=FALSE;
8022  i=0; /*iiTabIndex(dArithTab2,JJTAB2LEN,op);*/
8023  //Print("op: %c, type: %s %s\n",op,Tok2Cmdname(at),Tok2Cmdname(bt));
8024  while (dA2[i].cmd==op)
8025  {
8026  //Print("test %s %s\n",Tok2Cmdname(dA2[i].arg1),Tok2Cmdname(dA2[i].arg2));
8027  if ((ai=iiTestConvert(at,dA2[i].arg1,dConvertTypes))!=0)
8028  {
8029  if ((bi=iiTestConvert(bt,dA2[i].arg2,dConvertTypes))!=0)
8030  {
8031  res->rtyp=dA2[i].res;
8032  if (currRing!=NULL)
8033  {
8034  if (check_valid(dA2[i].valid_for,op)) break;
8035  }
8036  else
8037  {
8038  if (RingDependend(dA2[i].res))
8039  {
8040  WerrorS("no ring active");
8041  break;
8042  }
8043  }
8044  if (traceit&TRACE_CALL)
8045  Print("call %s(%s,%s)\n",iiTwoOps(op),
8046  Tok2Cmdname(dA2[i].arg1),Tok2Cmdname(dA2[i].arg2));
8047  failed= ((iiConvert(at,dA2[i].arg1,ai,a,an))
8048  || (iiConvert(bt,dA2[i].arg2,bi,b,bn))
8049  || (call_failed=dA2[i].p(res,an,bn)));
8050  // everything done, clean up temp. variables
8051  if (failed)
8052  {
8053  // leave loop, goto error handling
8054  break;
8055  }
8056  else
8057  {
8058  // everything ok, clean up and return
8059  an->CleanUp();
8060  bn->CleanUp();
8063  a->CleanUp();
8064  b->CleanUp();
8065  return FALSE;
8066  }
8067  }
8068  }
8069  i++;
8070  }
8071  an->CleanUp();
8072  bn->CleanUp();
8075  }
8076  // error handling ---------------------------------------------------
8077  const char *s=NULL;
8078  if (!errorreported)
8079  {
8080  if ((at==0) && (a->Fullname()!=sNoName))
8081  {
8082  s=a->Fullname();
8083  }
8084  else if ((bt==0) && (b->Fullname()!=sNoName))
8085  {
8086  s=b->Fullname();
8087  }
8088  if (s!=NULL)
8089  Werror("`%s` is not defined",s);
8090  else
8091  {
8092  i=0; /*iiTabIndex(dArithTab2,JJTAB2LEN,op);*/
8093  s = iiTwoOps(op);
8094  if (proccall)
8095  {
8096  Werror("%s(`%s`,`%s`) failed"
8097  ,s,Tok2Cmdname(at),Tok2Cmdname(bt));
8098  }
8099  else
8100  {
8101  Werror("`%s` %s `%s` failed"
8102  ,Tok2Cmdname(at),s,Tok2Cmdname(bt));
8103  }
8104  if ((!call_failed) && BVERBOSE(V_SHOW_USE))
8105  {
8106  while (dA2[i].cmd==op)
8107  {
8108  if(((at==dA2[i].arg1)||(bt==dA2[i].arg2))
8109  && (dA2[i].res!=0)
8110  && (dA2[i].p!=jjWRONG2))
8111  {
8112  if (proccall)
8113  Werror("expected %s(`%s`,`%s`)"
8114  ,s,Tok2Cmdname(dA2[i].arg1),Tok2Cmdname(dA2[i].arg2));
8115  else
8116  Werror("expected `%s` %s `%s`"
8117  ,Tok2Cmdname(dA2[i].arg1),s,Tok2Cmdname(dA2[i].arg2));
8118  }
8119  i++;
8120  }
8121  }
8122  }
8123  }
8124  res->rtyp = UNKNOWN;
8125  }
8126  a->CleanUp();
8127  b->CleanUp();
8128  return TRUE;
8129 }
8131  struct sValCmd2* dA2,
8132  int at,
8133  struct sConvertTypes *dConvertTypes)
8134 {
8135  leftv b=a->next;
8136  a->next=NULL;
8137  int bt=b->Typ();
8138  BOOLEAN bo=iiExprArith2TabIntern(res,a,op,b,TRUE,dA2,at,bt,dConvertTypes);
8139  a->next=b;
8140  a->CleanUp();
8141  return bo;
8142 }
8143 BOOLEAN iiExprArith2(leftv res, leftv a, int op, leftv b, BOOLEAN proccall)
8144 {
8145  memset(res,0,sizeof(sleftv));
8146 
8147  if (!errorreported)
8148  {
8149 #ifdef SIQ
8150  if (siq>0)
8151  {
8152  //Print("siq:%d\n",siq);
8154  memcpy(&d->arg1,a,sizeof(sleftv));
8155  //a->Init();
8156  memcpy(&d->arg2,b,sizeof(sleftv));
8157  //b->Init();
8158  d->argc=2;
8159  d->op=op;
8160  res->data=(char *)d;
8161  res->rtyp=COMMAND;
8162  return FALSE;
8163  }
8164 #endif
8165  int at=a->Typ();
8166  int bt=b->Typ();
8167  // handling bb-objects ----------------------------------------------------
8168  if (at>MAX_TOK)
8169  {
8170  blackbox *bb=getBlackboxStuff(at);
8171  if (bb!=NULL)
8172  {
8173  if (!bb->blackbox_Op2(op,res,a,b)) return FALSE;
8174  if (errorreported) return TRUE;
8175  // else: no op defined
8176  }
8177  else return TRUE;
8178  }
8179  else if ((bt>MAX_TOK)&&(op!='('))
8180  {
8181  blackbox *bb=getBlackboxStuff(bt);
8182  if (bb!=NULL)
8183  {
8184  if(!bb->blackbox_Op2(op,res,a,b)) return FALSE;
8185  if (errorreported) return TRUE;
8186  // else: no op defined
8187  }
8188  else return TRUE;
8189  }
8190  int i=iiTabIndex(dArithTab2,JJTAB2LEN,op);
8191  return iiExprArith2TabIntern(res,a,op,b,proccall,dArith2+i,at,bt,dConvertTypes);
8192  }
8193  a->CleanUp();
8194  b->CleanUp();
8195  return TRUE;
8196 }
8197 
8198 /*==================== operations with 1 arg. ===============================*/
8199 /* must be ordered: first operations for chars (infix ops),
8200  * then alphabetically */
8201 
8202 BOOLEAN iiExprArith1Tab(leftv res, leftv a, int op, struct sValCmd1* dA1, int at, struct sConvertTypes *dConvertTypes)
8203 {
8204  memset(res,0,sizeof(sleftv));
8205  BOOLEAN call_failed=FALSE;
8206 
8207  if (!errorreported)
8208  {
8209  BOOLEAN failed=FALSE;
8210  iiOp=op;
8211  int i = 0;
8212  while (dA1[i].cmd==op)
8213  {
8214  if (at==dA1[i].arg)
8215  {
8216  if (currRing!=NULL)
8217  {
8218  if (check_valid(dA1[i].valid_for,op)) break;
8219  }
8220  else
8221  {
8222  if (RingDependend(dA1[i].res))
8223  {
8224  WerrorS("no ring active");
8225  break;
8226  }
8227  }
8228  if (traceit&TRACE_CALL)
8229  Print("call %s(%s)\n",iiTwoOps(op),Tok2Cmdname(at));
8230  res->rtyp=dA1[i].res;
8231  if ((call_failed=dA1[i].p(res,a)))
8232  {
8233  break;// leave loop, goto error handling
8234  }
8235  if (a->Next()!=NULL)
8236  {
8238  failed=iiExprArith1(res->next,a->next,op);
8239  }
8240  a->CleanUp();
8241  return failed;
8242  }
8243  i++;
8244  }
8245  // implicite type conversion --------------------------------------------
8246  if (dA1[i].cmd!=op)
8247  {
8249  i=0;
8250  //Print("fuer %c , typ: %s\n",op,Tok2Cmdname(at));
8251  while (dA1[i].cmd==op)
8252  {
8253  int ai;
8254  //Print("test %s\n",Tok2Cmdname(dA1[i].arg));
8255  if ((ai=iiTestConvert(at,dA1[i].arg,dConvertTypes))!=0)
8256  {
8257  if (currRing!=NULL)
8258  {
8259  if (check_valid(dA1[i].valid_for,op)) break;
8260  }
8261  else
8262  {
8263  if (RingDependend(dA1[i].res))
8264  {
8265  WerrorS("no ring active");
8266  break;
8267  }
8268  }
8269  if (traceit&TRACE_CALL)
8270  Print("call %s(%s)\n",iiTwoOps(op),Tok2Cmdname(dA1[i].arg));
8271  res->rtyp=dA1[i].res;
8272  failed= ((iiConvert(at,dA1[i].arg,ai,a,an,dConvertTypes))
8273  || (call_failed=dA1[i].p(res,an)));
8274  // everything done, clean up temp. variables
8275  if (failed)
8276  {
8277  // leave loop, goto error handling
8278  break;
8279  }
8280  else
8281  {
8282  if (an->Next() != NULL)
8283  {
8284  res->next = (leftv)omAllocBin(sleftv_bin);
8285  failed=iiExprArith1(res->next,an->next,op);
8286  }
8287  // everything ok, clean up and return
8288  an->CleanUp();
8290  a->CleanUp();
8291  return failed;
8292  }
8293  }
8294  i++;
8295  }
8296  an->CleanUp();
8298  }
8299  // error handling
8300  if (!errorreported)
8301  {
8302  if ((at==0) && (a->Fullname()!=sNoName))
8303  {
8304  Werror("`%s` is not defined",a->Fullname());
8305  }
8306  else
8307  {
8308  i=0;
8309  const char *s = iiTwoOps(op);
8310  Werror("%s(`%s`) failed"
8311  ,s,Tok2Cmdname(at));
8312  if ((!call_failed) && BVERBOSE(V_SHOW_USE))
8313  {
8314  while (dA1[i].cmd==op)
8315  {
8316  if ((dA1[i].res!=0)
8317  && (dA1[i].p!=jjWRONG))
8318  Werror("expected %s(`%s`)"
8319  ,s,Tok2Cmdname(dA1[i].arg));
8320  i++;
8321  }
8322  }
8323  }
8324  }
8325  res->rtyp = UNKNOWN;
8326  }
8327  a->CleanUp();
8328  return TRUE;
8329 }
8331 {
8332  memset(res,0,sizeof(sleftv));
8333 
8334  if (!errorreported)
8335  {
8336 #ifdef SIQ
8337  if (siq>0)
8338  {
8339  //Print("siq:%d\n",siq);
8341  memcpy(&d->arg1,a,sizeof(sleftv));
8342  //a->Init();
8343  d->op=op;
8344  d->argc=1;
8345  res->data=(char *)d;
8346  res->rtyp=COMMAND;
8347  return FALSE;
8348  }
8349 #endif
8350  int at=a->Typ();
8351  // handling bb-objects ----------------------------------------------------
8352  if(op>MAX_TOK) // explicit type conversion to bb
8353  {
8354  blackbox *bb=getBlackboxStuff(op);
8355  if (bb!=NULL)
8356  {
8357  res->rtyp=op;
8358  res->data=bb->blackbox_Init(bb);
8359  if(!bb->blackbox_Assign(res,a)) return FALSE;
8360  if (errorreported) return TRUE;
8361  }
8362  else return TRUE;
8363  }
8364  else if (at>MAX_TOK) // argument is of bb-type
8365  {
8366  blackbox *bb=getBlackboxStuff(at);
8367  if (bb!=NULL)
8368  {
8369  if(!bb->blackbox_Op1(op,res,a)) return FALSE;
8370  if (errorreported) return TRUE;
8371  // else: no op defined
8372  }
8373  else return TRUE;
8374  }
8375 
8376  iiOp=op;
8377  int i=iiTabIndex(dArithTab1,JJTAB1LEN,op);
8378  return iiExprArith1Tab(res,a,op, dArith1+i,at,dConvertTypes);
8379  }
8380  a->CleanUp();
8381  return TRUE;
8382 }
8383 
8384 /*=================== operations with 3 args. ============================*/
8385 /* must be ordered: first operations for chars (infix ops),
8386  * then alphabetically */
8387 
8389  struct sValCmd3* dA3, int at, int bt, int ct,
8390  struct sConvertTypes *dConvertTypes)
8391 {
8392  memset(res,0,sizeof(sleftv));
8393  BOOLEAN call_failed=FALSE;
8394 
8395  assume(dA3[0].cmd==op);
8396 
8397  if (!errorreported)
8398  {
8399  int i=0;
8400  iiOp=op;
8401  while (dA3[i].cmd==op)
8402  {
8403  if ((at==dA3[i].arg1)
8404  && (bt==dA3[i].arg2)
8405  && (ct==dA3[i].arg3))
8406  {
8407  res->rtyp=dA3[i].res;
8408  if (currRing!=NULL)
8409  {
8410  if (check_valid(dA3[i].valid_for,op)) break;
8411  }
8412  if (traceit&TRACE_CALL)
8413  Print("call %s(%s,%s,%s)\n",
8414  iiTwoOps(op),Tok2Cmdname(at),Tok2Cmdname(bt),Tok2Cmdname(ct));
8415  if ((call_failed=dA3[i].p(res,a,b,c)))
8416  {
8417  break;// leave loop, goto error handling
8418  }
8419  a->CleanUp();
8420  b->CleanUp();
8421  c->CleanUp();
8422  return FALSE;
8423  }
8424  i++;
8425  }
8426  // implicite type conversion ----------------------------------------------
8427  if (dA3[i].cmd!=op)
8428  {
8429  int ai,bi,ci;
8433  BOOLEAN failed=FALSE;
8434  i=0;
8435  //while ((dA3[i].cmd!=op)&&(dA3[i].cmd!=0)) i++;
8436  while (dA3[i].cmd==op)
8437  {
8438  if ((ai=iiTestConvert(at,dA3[i].arg1,dConvertTypes))!=0)
8439  {
8440  if ((bi=iiTestConvert(bt,dA3[i].arg2,dConvertTypes))!=0)
8441  {
8442  if ((ci=iiTestConvert(ct,dA3[i].arg3,dConvertTypes))!=0)
8443  {
8444  res->rtyp=dA3[i].res;
8445  if (currRing!=NULL)
8446  {
8447  if (check_valid(dA3[i].valid_for,op)) break;
8448  }
8449  if (traceit&TRACE_CALL)
8450  Print("call %s(%s,%s,%s)\n",
8451  iiTwoOps(op),Tok2Cmdname(dA3[i].arg1),
8452  Tok2Cmdname(dA3[i].arg2),Tok2Cmdname(dA3[i].arg3));
8453  failed= ((iiConvert(at,dA3[i].arg1,ai,a,an,dConvertTypes))
8454  || (iiConvert(bt,dA3[i].arg2,bi,b,bn,dConvertTypes))
8455  || (iiConvert(ct,dA3[i].arg3,ci,c,cn,dConvertTypes))
8456  || (call_failed=dA3[i].p(res,an,bn,cn)));
8457  // everything done, clean up temp. variables
8458  if (failed)
8459  {
8460  // leave loop, goto error handling
8461  break;
8462  }
8463  else
8464  {
8465  // everything ok, clean up and return
8466  an->CleanUp();
8467  bn->CleanUp();
8468  cn->CleanUp();
8472  a->CleanUp();
8473  b->CleanUp();
8474  c->CleanUp();
8475  //Print("op: %d,result typ:%d\n",op,res->rtyp);
8476  return FALSE;
8477  }
8478  }
8479  }
8480  }
8481  i++;
8482  }
8483  an->CleanUp();
8484  bn->CleanUp();
8485  cn->CleanUp();
8489  }
8490  // error handling ---------------------------------------------------
8491  if (!errorreported)
8492  {
8493  const char *s=NULL;
8494  if ((at==0) && (a->Fullname()!=sNoName))
8495  {
8496  s=a->Fullname();
8497  }
8498  else if ((bt==0) && (b->Fullname()!=sNoName))
8499  {
8500  s=b->Fullname();
8501  }
8502  else if ((ct==0) && (c->Fullname()!=sNoName))
8503  {
8504  s=c->Fullname();
8505  }
8506  if (s!=NULL)
8507  Werror("`%s` is not defined",s);
8508  else
8509  {
8510  i=0;
8511  //while ((dA3[i].cmd!=op)&&(dA3[i].cmd!=0)) i++;
8512  const char *s = iiTwoOps(op);
8513  Werror("%s(`%s`,`%s`,`%s`) failed"
8514  ,s,Tok2Cmdname(at),Tok2Cmdname(bt),Tok2Cmdname(ct));
8515  if ((!call_failed) && BVERBOSE(V_SHOW_USE))
8516  {
8517  while (dA3[i].cmd==op)
8518  {
8519  if(((at==dA3[i].arg1)
8520  ||(bt==dA3[i].arg2)
8521  ||(ct==dA3[i].arg3))
8522  && (dA3[i].res!=0))
8523  {
8524  Werror("expected %s(`%s`,`%s`,`%s`)"
8525  ,s,Tok2Cmdname(dA3[i].arg1)
8526  ,Tok2Cmdname(dA3[i].arg2)
8527  ,Tok2Cmdname(dA3[i].arg3));
8528  }
8529  i++;
8530  }
8531  }
8532  }
8533  }
8534  res->rtyp = UNKNOWN;
8535  }
8536  a->CleanUp();
8537  b->CleanUp();
8538  c->CleanUp();
8539  //Print("op: %d,result typ:%d\n",op,res->rtyp);
8540  return TRUE;
8541 }
8543 {
8544  memset(res,0,sizeof(sleftv));
8545 
8546  if (!errorreported)
8547  {
8548 #ifdef SIQ
8549  if (siq>0)
8550  {
8551  //Print("siq:%d\n",siq);
8553  memcpy(&d->arg1,a,sizeof(sleftv));
8554  //a->Init();
8555  memcpy(&d->arg2,b,sizeof(sleftv));
8556  //b->Init();
8557  memcpy(&d->arg3,c,sizeof(sleftv));
8558  //c->Init();
8559  d->op=op;
8560  d->argc=3;
8561  res->data=(char *)d;
8562  res->rtyp=COMMAND;
8563  return FALSE;
8564  }
8565 #endif
8566  int at=a->Typ();
8567  // handling bb-objects ----------------------------------------------
8568  if (at>MAX_TOK)
8569  {
8570  blackbox *bb=getBlackboxStuff(at);
8571  if (bb!=NULL)
8572  {
8573  if(!bb->blackbox_Op3(op,res,a,b,c)) return FALSE;
8574  if (errorreported) return TRUE;
8575  // else: no op defined
8576  }
8577  else return TRUE;
8578  if (errorreported) return TRUE;
8579  }
8580  int bt=b->Typ();
8581  int ct=c->Typ();
8582 
8583  iiOp=op;
8584  int i=0;
8585  while ((dArith3[i].cmd!=op)&&(dArith3[i].cmd!=0)) i++;
8586  return iiExprArith3TabIntern(res,op,a,b,c,dArith3+i,at,bt,ct,dConvertTypes);
8587  }
8588  a->CleanUp();
8589  b->CleanUp();
8590  c->CleanUp();
8591  //Print("op: %d,result typ:%d\n",op,res->rtyp);
8592  return TRUE;
8593 }
8595  struct sValCmd3* dA3,
8596  int at,
8597  struct sConvertTypes *dConvertTypes)
8598 {
8599  leftv b=a->next;
8600  a->next=NULL;
8601  int bt=b->Typ();
8602  leftv c=b->next;
8603  b->next=NULL;
8604  int ct=c->Typ();
8605  BOOLEAN bo=iiExprArith3TabIntern(res,op,a,b,c,dA3,at,bt,ct,dConvertTypes);
8606  b->next=c;
8607  a->next=b;
8608  a->CleanUp();
8609  return bo;
8610 }
8611 /*==================== operations with many arg. ===============================*/
8612 /* must be ordered: first operations for chars (infix ops),
8613  * then alphabetically */
8614 
8615 BOOLEAN jjANY2LIST(leftv res, leftv v, int cnt)
8616 {
8617  // cnt = 0: all
8618  // cnt = 1: only first one
8619  leftv next;
8620  BOOLEAN failed = TRUE;
8621  if(v==NULL) return failed;
8622  res->rtyp = LIST_CMD;
8623  if(cnt) v->next = NULL;
8624  next = v->next; // saving next-pointer
8625  failed = jjLIST_PL(res, v);
8626  v->next = next; // writeback next-pointer
8627  return failed;
8628 }
8629 
8631 {
8632  memset(res,0,sizeof(sleftv));
8633 
8634  if (!errorreported)
8635  {
8636 #ifdef SIQ
8637  if (siq>0)
8638  {
8639  //Print("siq:%d\n",siq);
8641  d->op=op;
8642  res->data=(char *)d;
8643  if (a!=NULL)
8644  {
8645  d->argc=a->listLength();
8646  // else : d->argc=0;
8647  memcpy(&d->arg1,a,sizeof(sleftv));
8648  switch(d->argc)
8649  {
8650  case 3:
8651  memcpy(&d->arg3,a->next->next,sizeof(sleftv));
8652  a->next->next->Init();
8653  /* no break */
8654  case 2:
8655  memcpy(&d->arg2,a->next,sizeof(sleftv));
8656  a->next->Init();
8657  a->next->next=d->arg2.next;
8658  d->arg2.next=NULL;
8659  /* no break */
8660  case 1:
8661  a->Init();
8662  a->next=d->arg1.next;
8663  d->arg1.next=NULL;
8664  }
8665  if (d->argc>3) a->next=NULL;
8666  a->name=NULL;
8667  a->rtyp=0;
8668  a->data=NULL;
8669  a->e=NULL;
8670  a->attribute=NULL;
8671  a->CleanUp();
8672  }
8673  res->rtyp=COMMAND;
8674  return FALSE;
8675  }
8676 #endif
8677  if ((a!=NULL) && (a->Typ()>MAX_TOK))
8678  {
8679  blackbox *bb=getBlackboxStuff(a->Typ());
8680  if (bb!=NULL)
8681  {
8682  if(!bb->blackbox_OpM(op,res,a)) return FALSE;
8683  if (errorreported) return TRUE;
8684  // else: no op defined
8685  }
8686  else return TRUE;
8687  }
8688  BOOLEAN failed=FALSE;
8689  int args=0;
8690  if (a!=NULL) args=a->listLength();
8691 
8692  iiOp=op;
8693  int i=0;
8694  while ((dArithM[i].cmd!=op)&&(dArithM[i].cmd!=0)) i++;
8695  while (dArithM[i].cmd==op)
8696  {
8697  if ((args==dArithM[i].number_of_args)
8698  || (dArithM[i].number_of_args==-1)
8699  || ((dArithM[i].number_of_args==-2)&&(args>0)))
8700  {
8701  res->rtyp=dArithM[i].res;
8702  if (currRing!=NULL)
8703  {
8704  if (check_valid(dArithM[i].valid_for,op)) break;
8705  }
8706  if (traceit&TRACE_CALL)
8707  Print("call %s(... (%d args))\n", iiTwoOps(op),args);
8708  if ((failed=dArithM[i].p(res,a))==TRUE)
8709  {
8710  break;// leave loop, goto error handling
8711  }
8712  if (a!=NULL) a->CleanUp();
8713  //Print("op: %d,result typ:%d\n",op,res->rtyp);
8714  return failed;
8715  }
8716  i++;
8717  }
8718  // error handling
8719  if (!errorreported)
8720  {
8721  if ((args>0) && (a->rtyp==0) && (a->Name()!=sNoName))
8722  {
8723  Werror("`%s` is not defined",a->Fullname());
8724  }
8725  else
8726  {
8727  const char *s = iiTwoOps(op);
8728  Werror("%s(...) failed",s);
8729  }
8730  }
8731  res->rtyp = UNKNOWN;
8732  }
8733  if (a!=NULL) a->CleanUp();
8734  //Print("op: %d,result typ:%d\n",op,res->rtyp);
8735  return TRUE;
8736 }
8737 
8738 /*=================== general utilities ============================*/
8739 int IsCmd(const char *n, int & tok)
8740 {
8741  int i;
8742  int an=1;
8743  int en=sArithBase.nLastIdentifier;
8744 
8745  loop
8746  //for(an=0; an<sArithBase.nCmdUsed; )
8747  {
8748  if(an>=en-1)
8749  {
8750  if (strcmp(n, sArithBase.sCmds[an].name) == 0)
8751  {
8752  i=an;
8753  break;
8754  }
8755  else if ((an!=en) && (strcmp(n, sArithBase.sCmds[en].name) == 0))
8756  {
8757  i=en;
8758  break;
8759  }
8760  else
8761  {
8762  // -- blackbox extensions:
8763  // return 0;
8764  return blackboxIsCmd(n,tok);
8765  }
8766  }
8767  i=(an+en)/2;
8768  if (*n < *(sArithBase.sCmds[i].name))
8769  {
8770  en=i-1;
8771  }
8772  else if (*n > *(sArithBase.sCmds[i].name))
8773  {
8774  an=i+1;
8775  }
8776  else
8777  {
8778  int v=strcmp(n,sArithBase.sCmds[i].name);
8779  if(v<0)
8780  {
8781  en=i-1;
8782  }
8783  else if(v>0)
8784  {
8785  an=i+1;
8786  }
8787  else /*v==0*/
8788  {
8789  break;
8790  }
8791  }
8792  }
8793  lastreserved=sArithBase.sCmds[i].name;
8794  tok=sArithBase.sCmds[i].tokval;
8795  if(sArithBase.sCmds[i].alias==2)
8796  {
8797  Warn("outdated identifier `%s` used - please change your code",
8798  sArithBase.sCmds[i].name);
8799  sArithBase.sCmds[i].alias=1;
8800  }
8801  #if 0
8802  if (currRingHdl==NULL)
8803  {
8804  #ifdef SIQ
8805  if (siq<=0)
8806  {
8807  #endif
8808  if ((tok>=BEGIN_RING) && (tok<=END_RING))
8809  {
8810  WerrorS("no ring active");
8811  return 0;
8812  }
8813  #ifdef SIQ
8814  }
8815  #endif
8816  }
8817  #endif
8818  if (!expected_parms)
8819  {
8820  switch (tok)
8821  {
8822  case IDEAL_CMD:
8823  case INT_CMD:
8824  case INTVEC_CMD:
8825  case MAP_CMD:
8826  case MATRIX_CMD:
8827  case MODUL_CMD:
8828  case POLY_CMD:
8829  case PROC_CMD:
8830  case RING_CMD:
8831  case STRING_CMD:
8832  cmdtok = tok;
8833  break;
8834  }
8835  }
8836  return sArithBase.sCmds[i].toktype;
8837 }
8838 static int iiTabIndex(const jjValCmdTab dArithTab, const int len, const int op)
8839 {
8840  // user defined types are not in the pre-computed table:
8841  if (op>MAX_TOK) return 0;
8842 
8843  int a=0;
8844  int e=len;
8845  int p=len/2;
8846  do
8847  {
8848  if (op==dArithTab[p].cmd) return dArithTab[p].start;
8849  if (op<dArithTab[p].cmd) e=p-1;
8850  else a = p+1;
8851  p=a+(e-a)/2;
8852  }
8853  while ( a <= e);
8854 
8855  // catch missing a cmd:
8856  // may be missing as a op for blackbox, if the first operand is "undef" instead of bb
8857  // Print("op %d (%c) unknown",op,op);
8858  return 0;
8859 }
8860 
8861 const char * Tok2Cmdname(int tok)
8862 {
8863  if (tok <= 0)
8864  {
8865  return sArithBase.sCmds[0].name;
8866  }
8867  if (tok==ANY_TYPE) return "any_type";
8868  if (tok==COMMAND) return "command";
8869  if (tok==NONE) return "nothing";
8870  //if (tok==IFBREAK) return "if_break";
8871  //if (tok==VECTOR_FROM_POLYS) return "vector_from_polys";
8872  //if (tok==ORDER_VECTOR) return "ordering";
8873  //if (tok==REF_VAR) return "ref";
8874  //if (tok==OBJECT) return "object";
8875  //if (tok==PRINT_EXPR) return "print_expr";
8876  if (tok==IDHDL) return "identifier";
8877  #ifdef SINGULAR_4_1
8878  if (tok==CRING_CMD) return "(c)ring";
8879  #endif
8880  if (tok==QRING_CMD) return "ring";
8881  if (tok>MAX_TOK) return getBlackboxName(tok);
8882  int i;
8883  for(i=0; i<sArithBase.nCmdUsed; i++)
8884  //while (sArithBase.sCmds[i].tokval!=0)
8885  {
8886  if ((sArithBase.sCmds[i].tokval == tok)&&
8887  (sArithBase.sCmds[i].alias==0))
8888  {
8889  return sArithBase.sCmds[i].name;
8890  }
8891  }
8892  // try gain for alias/old names:
8893  for(i=0; i<sArithBase.nCmdUsed; i++)
8894  {
8895  if (sArithBase.sCmds[i].tokval == tok)
8896  {
8897  return sArithBase.sCmds[i].name;
8898  }
8899  }
8900  return sArithBase.sCmds[0].name;
8901 }
8902 
8903 
8904 /*---------------------------------------------------------------------*/
8905 /**
8906  * @brief compares to entry of cmdsname-list
8907 
8908  @param[in] a
8909  @param[in] b
8910 
8911  @return <ReturnValue>
8912 **/
8913 /*---------------------------------------------------------------------*/
8914 static int _gentable_sort_cmds( const void *a, const void *b )
8915 {
8916  cmdnames *pCmdL = (cmdnames*)a;
8917  cmdnames *pCmdR = (cmdnames*)b;
8918 
8919  if(a==NULL || b==NULL) return 0;
8920 
8921  /* empty entries goes to the end of the list for later reuse */
8922  if(pCmdL->name==NULL) return 1;
8923  if(pCmdR->name==NULL) return -1;
8924 
8925  /* $INVALID$ must come first */
8926  if(strcmp(pCmdL->name, "$INVALID$")==0) return -1;
8927  if(strcmp(pCmdR->name, "$INVALID$")==0) return 1;
8928 
8929  /* tokval=-1 are reserved names at the end */
8930  if (pCmdL->tokval==-1)
8931  {
8932  if (pCmdR->tokval==-1)
8933  return strcmp(pCmdL->name, pCmdR->name);
8934  /* pCmdL->tokval==-1, pCmdL goes at the end */
8935  return 1;
8936  }
8937  /* pCmdR->tokval==-1, pCmdR goes at the end */
8938  if(pCmdR->tokval==-1) return -1;
8939 
8940  return strcmp(pCmdL->name, pCmdR->name);
8941 }
8942 
8943 /*---------------------------------------------------------------------*/
8944 /**
8945  * @brief initialisation of arithmetic structured data
8946 
8947  @retval 0 on success
8948 
8949 **/
8950 /*---------------------------------------------------------------------*/
8952 {
8953  //printf("iiInitArithmetic()\n");
8954  memset(&sArithBase, 0, sizeof(sArithBase));
8955  iiInitCmdName();
8956  /* fix last-identifier */
8957 #if 0
8958  /* we expect that gentable allready did every thing */
8959  for(sArithBase.nLastIdentifier=sArithBase.nCmdUsed-1;
8960  sArithBase.nLastIdentifier>0; sArithBase.nLastIdentifier--) {
8961  if(sArithBase.sCmds[sArithBase.nLastIdentifier].tokval>=0) break;
8962  }
8963 #endif
8964  //Print("L=%d\n", sArithBase.nLastIdentifier);
8965 
8966  //iiArithAddCmd(szName, nAlias, nTokval, nToktype);
8967  //iiArithAddCmd("mygcd", 1, GCD_CMD, CMD_2);
8968 
8969  //iiArithAddCmd("Top", 0,-1,0);
8970 
8971 
8972  //for(i=0; i<sArithBase.nCmdUsed; i++) {
8973  // printf("CMD[%03d] %s, %d, %d, %d\n", i,
8974  // sArithBase.sCmds[i].name,
8975  // sArithBase.sCmds[i].alias,
8976  // sArithBase.sCmds[i].tokval,
8977  // sArithBase.sCmds[i].toktype);
8978  //}
8979  //iiArithRemoveCmd("Top");
8980  //iiArithAddCmd("mygcd", 2, GCD_CMD, CMD_2);
8981  //iiArithRemoveCmd("mygcd");
8982  //iiArithAddCmd("kkk", 1, 1234, CMD_1);
8983  return 0;
8984 }
8985 
8986 int iiArithFindCmd(const char *szName)
8987 {
8988  int an=0;
8989  int i = 0,v = 0;
8990  int en=sArithBase.nLastIdentifier;
8991 
8992  loop
8993  //for(an=0; an<sArithBase.nCmdUsed; )
8994  {
8995  if(an>=en-1)
8996  {
8997  if (strcmp(szName, sArithBase.sCmds[an].name) == 0)
8998  {
8999  //Print("RET-an=%d %s\n", an, sArithBase.sCmds[an].name);
9000  return an;
9001  }
9002  else if (strcmp(szName, sArithBase.sCmds[en].name) == 0)
9003  {
9004  //Print("RET-en=%d %s\n", en, sArithBase.sCmds[en].name);
9005  return en;
9006  }
9007  else
9008  {
9009  //Print("RET- 1\n");
9010  return -1;
9011  }
9012  }
9013  i=(an+en)/2;
9014  if (*szName < *(sArithBase.sCmds[i].name))
9015  {
9016  en=i-1;
9017  }
9018  else if (*szName > *(sArithBase.sCmds[i].name))
9019  {
9020  an=i+1;
9021  }
9022  else
9023  {
9024  v=strcmp(szName,sArithBase.sCmds[i].name);
9025  if(v<0)
9026  {
9027  en=i-1;
9028  }
9029  else if(v>0)
9030  {
9031  an=i+1;
9032  }
9033  else /*v==0*/
9034  {
9035  //Print("RET-i=%d %s\n", i, sArithBase.sCmds[i].name);
9036  return i;
9037  }
9038  }
9039  }
9040  //if(i>=0 && i<sArithBase.nCmdUsed)
9041  // return i;
9042  //Print("RET-2\n");
9043  return -2;
9044 }
9045 
9046 char *iiArithGetCmd( int nPos )
9047 {
9048  if(nPos<0) return NULL;
9049  if(nPos<sArithBase.nCmdUsed)
9050  return sArithBase.sCmds[nPos].name;
9051  return NULL;
9052 }
9053 
9054 int iiArithRemoveCmd(const char *szName)
9055 {
9056  int nIndex;
9057  if(szName==NULL) return -1;
9058 
9059  nIndex = iiArithFindCmd(szName);
9060  if(nIndex<0 || nIndex>=sArithBase.nCmdUsed)
9061  {
9062  Print("'%s' not found (%d)\n", szName, nIndex);
9063  return -1;
9064  }
9065  omFree(sArithBase.sCmds[nIndex].name);
9066  sArithBase.sCmds[nIndex].name=NULL;
9067  qsort(sArithBase.sCmds, sArithBase.nCmdUsed, sizeof(cmdnames),
9068  (&_gentable_sort_cmds));
9069  sArithBase.nCmdUsed--;
9070 
9071  /* fix last-identifier */
9072  for(sArithBase.nLastIdentifier=sArithBase.nCmdUsed-1;
9073  sArithBase.nLastIdentifier>0; sArithBase.nLastIdentifier--)
9074  {
9075  if(sArithBase.sCmds[sArithBase.nLastIdentifier].tokval>=0) break;
9076  }
9077  //Print("L=%d\n", sArithBase.nLastIdentifier);
9078  return 0;
9079 }
9080 
9082  const char *szName,
9083  short nAlias,
9084  short nTokval,
9085  short nToktype,
9086  short nPos
9087  )
9088 {
9089  //printf("AddCmd(%s, %d, %d, %d, %d)\n", szName, nAlias,
9090  // nTokval, nToktype, nPos);
9091  if(nPos>=0)
9092  {
9093  // no checks: we rely on a correct generated code in iparith.inc
9094  assume(nPos < sArithBase.nCmdAllocated);
9095  assume(szName!=NULL);
9096  sArithBase.sCmds[nPos].name = omStrDup(szName);
9097  sArithBase.sCmds[nPos].alias = nAlias;
9098  sArithBase.sCmds[nPos].tokval = nTokval;
9099  sArithBase.sCmds[nPos].toktype = nToktype;
9100  sArithBase.nCmdUsed++;
9101  //if(nTokval>0) sArithBase.nLastIdentifier++;
9102  }
9103  else
9104  {
9105  if(szName==NULL) return -1;
9106  int nIndex = iiArithFindCmd(szName);
9107  if(nIndex>=0)
9108  {
9109  Print("'%s' already exists at %d\n", szName, nIndex);
9110  return -1;
9111  }
9112 
9113  if(sArithBase.nCmdUsed>=sArithBase.nCmdAllocated)
9114  {
9115  /* needs to create new slots */
9116  unsigned long nSize = (sArithBase.nCmdAllocated+1)*sizeof(cmdnames);
9117  sArithBase.sCmds = (cmdnames *)omRealloc(sArithBase.sCmds, nSize);
9118  if(sArithBase.sCmds==NULL) return -1;
9119  sArithBase.nCmdAllocated++;
9120  }
9121  /* still free slots available */
9122  sArithBase.sCmds[sArithBase.nCmdUsed].name = omStrDup(szName);
9123  sArithBase.sCmds[sArithBase.nCmdUsed].alias = nAlias;
9124  sArithBase.sCmds[sArithBase.nCmdUsed].tokval = nTokval;
9125  sArithBase.sCmds[sArithBase.nCmdUsed].toktype = nToktype;
9126  sArithBase.nCmdUsed++;
9127 
9128  qsort(sArithBase.sCmds, sArithBase.nCmdUsed, sizeof(cmdnames),
9129  (&_gentable_sort_cmds));
9130  for(sArithBase.nLastIdentifier=sArithBase.nCmdUsed-1;
9131  sArithBase.nLastIdentifier>0; sArithBase.nLastIdentifier--)
9132  {
9133  if(sArithBase.sCmds[sArithBase.nLastIdentifier].tokval>=0) break;
9134  }
9135  //Print("L=%d\n", sArithBase.nLastIdentifier);
9136  }
9137  return 0;
9138 }
9139 
9140 static BOOLEAN check_valid(const int p, const int op)
9141 {
9142  #ifdef HAVE_PLURAL
9143  if (rIsPluralRing(currRing))
9144  {
9145  if ((p & PLURAL_MASK)==0 /*NO_PLURAL*/)
9146  {
9147  WerrorS("not implemented for non-commutative rings");
9148  return TRUE;
9149  }
9150  else if ((p & PLURAL_MASK)==2 /*, COMM_PLURAL */)
9151  {
9152  Warn("assume commutative subalgebra for cmd `%s`",Tok2Cmdname(op));
9153  return FALSE;
9154  }
9155  /* else, ALLOW_PLURAL */
9156  }
9157  #endif
9158  #ifdef HAVE_RINGS
9159  if (rField_is_Ring(currRing))
9160  {
9161  if ((p & RING_MASK)==0 /*NO_RING*/)
9162  {
9163  WerrorS("not implemented for rings with rings as coeffients");
9164  return TRUE;
9165  }
9166  /* else ALLOW_RING */
9167  else if (((p & ZERODIVISOR_MASK)==NO_ZERODIVISOR)
9168  &&(!rField_is_Domain(currRing)))
9169  {
9170  WerrorS("domain required as coeffients");
9171  return TRUE;
9172  }
9173  /* else ALLOW_ZERODIVISOR */
9174  else if(((p & WARN_RING)==WARN_RING)&&(myynest==0))
9175  {
9176  WarnS("considering the image in Q[...]");
9177  }
9178  }
9179  #endif
9180  return FALSE;
9181 }
BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition: ring.h:753
static BOOLEAN jjINTMAT3(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5969
#define idPosConstant(I)
index of generator with leading term in ground ring (if any); otherwise -1
Definition: ideals.h:39
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of &#39;a&#39; and &#39;b&#39;, i.e., a-b
Definition: coeffs.h:668
int iiInitArithmetic()
initialisation of arithmetic structured data
Definition: iparith.cc:8951
int & rows()
Definition: matpol.h:24
matrix idDiff(matrix i, int k)
Definition: ideals.cc:1950
static BOOLEAN jjBREAK0(leftv, leftv)
Definition: iparith.cc:6691
static BOOLEAN jjPLUS_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:775
static BOOLEAN jjE(leftv res, leftv v)
Definition: iparith.cc:4079
static BOOLEAN jjPAR1(leftv res, leftv v)
Definition: iparith.cc:4680
#define pSubst(p, n, e)
Definition: polys.h:337
static BOOLEAN jjRANK2(leftv res, leftv u, leftv v)
Definition: iparith.cc:3035
static BOOLEAN jjIDEAL_PL(leftv res, leftv v)
Definition: iparith.cc:6854
intvec ** weights
Definition: syz.h:45
poly pOppose(ring Rop_src, poly p, const ring Rop_dst)
opposes a vector p from Rop to currRing (dst!)
Definition: old.gring.cc:3427
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
ideal singclap_sqrfree(poly f, intvec **v, int with_exps, const ring r)
Definition: clapsing.cc:1155
static void jjEQUAL_REST(leftv res, leftv u, leftv v)
Definition: iparith.cc:1354
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
static BOOLEAN jjDET_S(leftv res, leftv v)
Definition: iparith.cc:4013
BOOLEAN yyInRingConstruction
Definition: grammar.cc:173
ideal scKBase(int deg, ideal s, ideal Q, intvec *mv)
Definition: hdegree.cc:1352
#define SIMPL_LMDIV
Definition: iparith.cc:3348
static BOOLEAN jjPLUSMINUS_Gen(leftv res, leftv u, leftv v)
Definition: iparith.cc:653
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.
static BOOLEAN jjTIMES_ID(leftv res, leftv u, leftv v)
Definition: iparith.cc:1004
static FORCE_INLINE number n_IntMod(number a, number b, const coeffs r)
for r a field, return n_Init(0,r) otherwise: n_Div(a,b,r)*b+n_IntMod(a,b,r)==a
Definition: coeffs.h:627
matrix mp_CoeffProc(poly f, poly vars, const ring R)
Definition: matpol.cc:414
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:609
static BOOLEAN jjBI2IM(leftv res, leftv u)
Definition: iparith.cc:3791
int compare(const bigintmat *op) const
Definition: bigintmat.cc:362
static BOOLEAN jjOP_BI_BIM(leftv res, leftv u, leftv v)
Definition: iparith.cc:301
void id_Normalize(ideal I, const ring r)
normialize all polys in id
static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
in Z: return the gcd of &#39;a&#39; and &#39;b&#39; in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ...
Definition: coeffs.h:685
#define WARN_RING
Definition: iparith.cc:128
static BOOLEAN jjFAC_P(leftv res, leftv u)
Definition: iparith.cc:4140
#define idMaxIdeal(D)
initialise the maximal ideal (at 0)
Definition: ideals.h:35
const CanonicalForm int s
Definition: facAbsFact.cc:55
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...
unsigned si_opt_1
Definition: options.c:5
#define pVar(m)
Definition: polys.h:353
This file provides miscellaneous functionality.
ring rEnvelope(ring R)
Definition: ring.cc:5517
static BOOLEAN jjCALL2ARG(leftv res, leftv u)
Definition: iparith.cc:6719
resolvente syResolvente(ideal arg, int maxlength, int *length, intvec ***weights, BOOLEAN minim)
Definition: syz.cc:394
syStrategy syKosz(ideal arg, int *length)
Definition: syz3.cc:1765
int iiTestConvert(int inputType, int outputType)
Definition: gentable.cc:292
static BOOLEAN jjREPART(leftv res, leftv v)
Definition: iparith.cc:4836
ideal id_FreeModule(int i, const ring r)
the free module of rank i
sleftv * m
Definition: lists.h:45
static BOOLEAN jjRING3(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6635
static BOOLEAN jjRSUM(leftv res, leftv u, leftv v)
Definition: iparith.cc:3341
ideal id_Transp(ideal a, const ring rRing)
transpose a module
static BOOLEAN jjVAR1(leftv res, leftv v)
Definition: iparith.cc:5200
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...
poly nc_p_Bracket_qq(poly p, const poly q, const ring r)
returns [p,q], destroys p
Definition: old.gring.cc:2308
poly pSubstPoly(poly p, int var, poly image)
Definition: maps_ip.cc:365
void atSet(idhdl root, const char *name, void *data, int typ)
Definition: attrib.cc:156
Definition: tok.h:115
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
static BOOLEAN jjTEST(leftv, leftv v)
Definition: iparith.cc:7643
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition: kstd1.cc:2815
ideal id_Homogen(ideal h, int varnum, const ring r)
#define pSetm(p)
Definition: polys.h:241
char * rVarStr(ring r)
Definition: ring.cc:594
static int _gentable_sort_cmds(const void *a, const void *b)
compares to entry of cmdsname-list
Definition: iparith.cc:8914
ip_command * command
Definition: ipid.h:24
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:516
static BOOLEAN jjPARDEG(leftv res, leftv v)
Definition: iparith.cc:4696
number ntDiff(number a, number d, const coeffs cf)
Definition: transext.cc:814
static BOOLEAN jjTIMES_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:928
const poly a
Definition: syzextra.cc:212
Definition: tok.h:93
void syMake(leftv v, const char *id, idhdl packhdl)
Definition: subexpr.cc:1474
static BOOLEAN jjLOAD_E(leftv, leftv v, leftv u)
Definition: iparith.cc:2666
void PrintLn()
Definition: reporter.cc:327
static BOOLEAN jjJET_ID_M(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6006
#define ANY_TYPE
Definition: tok.h:34
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:3400
static BOOLEAN jjCOMPARE_S(leftv res, leftv u, leftv v)
Definition: iparith.cc:502
#define Print
Definition: emacs.cc:83
CanonicalForm fp
Definition: cfModGcd.cc:4043
static BOOLEAN jjnInt(leftv res, leftv u)
Definition: iparith.cc:5471
static BOOLEAN jjLIFT(leftv res, leftv u, leftv v)
Definition: iparith.cc:2642
void omPrintInfo(FILE *fd)
Definition: omStats.c:127
bigintmat * bimSub(bigintmat *a, bigintmat *b)
Definition: bigintmat.cc:216
static BOOLEAN jjPLUS_MA(leftv res, leftv u, leftv v)
Definition: iparith.cc:822
Definition: tok.h:85
#define TEST_OPT_DEGBOUND
Definition: options.h:108
static BOOLEAN jjKERNEL(leftv res, leftv u, leftv v)
Definition: iparith.cc:2626
static BOOLEAN jjCOMPARE_IV(leftv res, leftv u, leftv v)
Definition: iparith.cc:364
#define pAdd(p, q)
Definition: polys.h:174
static BOOLEAN jjPLUS_BIM(leftv res, leftv u, leftv v)
Definition: iparith.cc:812
static BOOLEAN jjSQR_FREE(leftv res, leftv u)
Definition: iparith.cc:5031
static BOOLEAN jjPFAC1(leftv res, leftv v)
Definition: iparith.cc:4526
static BOOLEAN jjTIMES_MA_BI2(leftv res, leftv u, leftv v)
Definition: iparith.cc:1046
static BOOLEAN jjKBASE2(leftv res, leftv u, leftv v)
Definition: iparith.cc:2613
static BOOLEAN jjHILBERT2(leftv res, leftv u, leftv v)
Definition: iparith.cc:2446
static BOOLEAN jjJET_P_IV(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5983
ideal id_Subst(ideal id, int n, poly e, const ring r)
#define SIMPL_MULT
Definition: iparith.cc:3350
ideal idSubstPar(ideal id, int n, poly e)
Definition: maps_ip.cc:348
static BOOLEAN jjMULT(leftv res, leftv v)
Definition: iparith.cc:4609
static BOOLEAN jjSUBST_Id_I(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6453
static BOOLEAN jjPlural_mat_mat(leftv res, leftv a, leftv b)
Definition: iparith.cc:2906
#define pNSet(n)
Definition: polys.h:284
static BOOLEAN jjPOWER_ID(leftv res, leftv u, leftv v)
Definition: iparith.cc:647
Subexpr e
Definition: subexpr.h:106
#define idDelete(H)
delete an ideal
Definition: ideals.h:31
static BOOLEAN rField_is_Zp_a(const ring r)
Definition: ring.h:478
BITSET flag
Definition: subexpr.h:91
static BOOLEAN jjFACSTD(leftv res, leftv v)
Definition: iparith.cc:4100
static BOOLEAN jjTRANSP_IV(leftv res, leftv v)
Definition: iparith.cc:5096
int nCmdAllocated
number of commands-slots allocated
Definition: iparith.cc:210
static BOOLEAN jjCALL3ARG(leftv res, leftv u)
Definition: iparith.cc:6727
static BOOLEAN jjN2BI(leftv res, leftv v)
Definition: iparith.cc:4629
Definition: lists.h:22
static BOOLEAN jjCOUNT_N(leftv res, leftv v)
Definition: iparith.cc:3849
#define nNormalize(n)
Definition: numbers.h:30
static BOOLEAN jjGETDUMP(leftv, leftv v)
Definition: iparith.cc:4156
static BOOLEAN jjINTVEC_PL(leftv res, leftv v)
Definition: iparith.cc:7311
static BOOLEAN jjP2BI(leftv res, leftv v)
Definition: iparith.cc:4720
ideal_list kStdfac(ideal F, ideal Q, tHomog h, intvec **w, ideal D)
Definition: kstdfac.cc:808
static BOOLEAN jjTIMES_MA_P2(leftv res, leftv u, leftv v)
Definition: iparith.cc:1060
void idLiftW(ideal P, ideal Q, int n, matrix &T, ideal &R, short *w)
Definition: ideals.cc:1130
ideal interpolation(const std::vector< ideal > &L, intvec *v)
#define TEST_OPT_PROT
Definition: options.h:98
intvec * scIndIntvec(ideal S, ideal Q)
Definition: hdegree.cc:212
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...
int ncols
Definition: matpol.h:22
#define pMaxComp(p)
Definition: polys.h:270
BOOLEAN mpKoszul(leftv res, leftv c, leftv b, leftv id)
Definition: ipshell.cc:2956
loop
Definition: myNF.cc:98
if(0 > strat->sl)
Definition: myNF.cc:73
#define IDID(a)
Definition: ipid.h:121
static BOOLEAN jjCOUNT_M(leftv res, leftv v)
Definition: iparith.cc:3860
BOOLEAN iiExprArith1(leftv res, leftv a, int op)
Definition: iparith.cc:8330
static BOOLEAN rField_is_Ring_PtoM(const ring r)
Definition: ring.h:431
static int WerrorS_dummy_cnt
Definition: iparith.cc:5345
#define pSetExp(p, i, v)
Definition: polys.h:42
static int si_min(const int a, const int b)
Definition: auxiliary.h:167
int getRTimer()
Definition: timer.cc:172
static BOOLEAN jjRANDOM(leftv res, leftv u, leftv v)
Definition: iparith.cc:3027
static BOOLEAN jjOP_REST(leftv res, leftv u, leftv v)
Definition: iparith.cc:529
#define FALSE
Definition: auxiliary.h:140
static BOOLEAN jjFAREY_BI(leftv res, leftv u, leftv v)
Definition: iparith.cc:2255
poly pHeadProc(poly p)
Definition: iparith.cc:250
matrix mp_InitP(int r, int c, poly p, const ring R)
make it a p * unit matrix
Definition: matpol.cc:124
ideal t_rep_gb(ring r, ideal arg_I, int syz_comp, BOOLEAN F4_mode)
Definition: tgb.cc:3558
Compatiblity layer for legacy polynomial operations (over currRing)
static BOOLEAN jjDIVMOD_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:1168
static BOOLEAN jjBRACK_Ma_I_IV(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5587
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:2418
poly p_Homogen(poly p, int varnum, const ring r)
Definition: p_polys.cc:3138
static BOOLEAN jjL2R(leftv res, leftv v)
Definition: iparith.cc:4460
static BOOLEAN jjOpenClose(leftv, leftv v)
Definition: iparith.cc:4668
Definition: tok.h:42
short res
Definition: gentable.cc:61
static BOOLEAN jjMEMORY(leftv res, leftv v)
Definition: iparith.cc:4565
return P p
Definition: myNF.cc:203
BOOLEAN jjWAIT1ST1(leftv res, leftv u)
Definition: iparith.cc:5240
int exprlist_length(leftv v)
Definition: ipshell.cc:559
ideal id_Copy(ideal h1, const ring r)
copy an ideal
short * iv2array(intvec *iv, const ring R)
Definition: weight.cc:208
Definition: mod_raw.h:16
Matrices of numbers.
Definition: bigintmat.h:51
f
Definition: cfModGcd.cc:4022
static int rPar(const ring r)
(r->cf->P)
Definition: ring.h:547
static BOOLEAN jjCOEFFS_Id(leftv res, leftv u, leftv v)
Definition: iparith.cc:1926
BOOLEAN iiExprArith3(leftv res, int op, leftv a, leftv b, leftv c)
Definition: iparith.cc:8542
static BOOLEAN jjCOLS(leftv res, leftv v)
Definition: iparith.cc:3821
static BOOLEAN rField_is_Ring_ModN(const ring r)
Definition: ring.h:428
matrix mp_Coeffs(ideal I, int var, const ring R)
corresponds to Maple&#39;s coeffs: var has to be the number of a variable
Definition: matpol.cc:327
#define nPower(a, b, res)
Definition: numbers.h:38
#define pLmCmp(p, q)
returns 0|1|-1 if p=q|p>q|p<q w.r.t monomial ordering
Definition: polys.h:105
static BOOLEAN jjKLAMMER_rest(leftv res, leftv u, leftv v)
Definition: iparith.cc:1588
lists syConvRes(syStrategy syzstr, BOOLEAN toDel, int add_row_shift)
Definition: ipshell.cc:3046
static BOOLEAN jjALIGN_M(leftv res, leftv u, leftv v)
Definition: iparith.cc:1758
static BOOLEAN jjHOMOG1(leftv res, leftv v)
Definition: iparith.cc:4272
static BOOLEAN jjCHINREM_BI(leftv res, leftv u, leftv v)
Definition: iparith.cc:1661
void omPrintBinStats(FILE *fd)
Definition: omBin.c:692
static BOOLEAN jjPLUS_MA_P(leftv res, leftv u, leftv v)
Definition: iparith.cc:834
char * rParStr(ring r)
Definition: ring.cc:620
poly sm_CallDet(ideal I, const ring R)
Definition: sparsmat.cc:359
BOOLEAN idTestHomModule(ideal m, ideal Q, intvec *w)
Definition: ideals.cc:1881
static BOOLEAN jjGCD_N(leftv res, leftv u, leftv v)
Definition: iparith.cc:2423
static BOOLEAN jjrVarStr(leftv res, leftv v)
Definition: iparith.cc:5440
static BOOLEAN jjPRIME(leftv res, leftv v)
Definition: iparith.cc:4758
static BOOLEAN jjMODULO(leftv res, leftv u, leftv v)
Definition: iparith.cc:2677
static BOOLEAN jjROWS(leftv res, leftv v)
Definition: iparith.cc:4857
ideal id_ChineseRemainder(ideal *xx, number *q, int rl, const ring r)
static BOOLEAN jjDET_BI(leftv res, leftv v)
Definition: iparith.cc:3985
static BOOLEAN jjDUMP(leftv, leftv v)
Definition: iparith.cc:4065
static BOOLEAN jjPLUS_S(leftv res, leftv u, leftv v)
Definition: iparith.cc:849
BOOLEAN iiTryLoadLib(leftv v, const char *id)
Definition: iplib.cc:751
static BOOLEAN jjBRACK_Bim(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5530
poly mp_Trace(matrix a, const ring R)
Definition: matpol.cc:289
static BOOLEAN jjCOEF(leftv res, leftv u, leftv v)
Definition: iparith.cc:1919
Definition: tok.h:170
static BOOLEAN jjREDUCE3_ID(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6589
static BOOLEAN jjTIMES_MA_I2(leftv res, leftv u, leftv v)
Definition: iparith.cc:1088
static BOOLEAN jjJACOB_M(leftv res, leftv a)
Definition: iparith.cc:4432
static BOOLEAN jjnlInt(leftv res, leftv u)
Definition: iparith.cc:5478
static BOOLEAN jjIS_RINGVAR0(leftv res, leftv)
Definition: iparith.cc:4396
sleftv iiRETURNEXPR
Definition: iplib.cc:527
static BOOLEAN jjINTERRED(leftv res, leftv v)
Definition: iparith.cc:4374
rational (GMP) numbers
Definition: coeffs.h:31
static BOOLEAN jjMINUS_BI(leftv res, leftv u, leftv v)
Definition: iparith.cc:880
static BOOLEAN jjSTD_1(leftv res, leftv u, leftv v)
Definition: iparith.cc:3483
static BOOLEAN jjDOTDOT(leftv res, leftv u, leftv v)
Definition: iparith.cc:358
void id_Norm(ideal id, const ring r)
ideal id = (id[i]), result is leadcoeff(id[i]) = 1
static BOOLEAN jjNULL(leftv, leftv)
Definition: iparith.cc:3679
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:539
#define pIsUnit(p)
return true if the Lm is a constant <>0
Definition: polys.h:211
static BOOLEAN jjCONTENT(leftv res, leftv v)
Definition: iparith.cc:3836
static BOOLEAN jjFAC_P2(leftv res, leftv u, leftv dummy)
Definition: iparith.cc:2186
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
static BOOLEAN jjREAD2(leftv res, leftv u, leftv v)
Definition: iparith.cc:3044
static BOOLEAN jjKLAMMER_IV(leftv res, leftv u, leftv v)
Definition: iparith.cc:1560
#define idSimpleAdd(A, B)
Definition: ideals.h:55
matrix idDiffOp(ideal I, ideal J, BOOLEAN multiply)
Definition: ideals.cc:1963
int singclap_det_i(intvec *m, const ring)
Definition: clapsing.cc:1602
static BOOLEAN jjpHead(leftv res, leftv v)
Definition: iparith.cc:5396
Definition: grammar.cc:271
static BOOLEAN jjCOLON(leftv res, leftv u, leftv v)
Definition: iparith.cc:345
static BOOLEAN jjPARSTR2(leftv res, leftv u, leftv v)
Definition: iparith.cc:2826
int rChar(ring r)
Definition: ring.cc:684
BOOLEAN iiExprArith1Tab(leftv res, leftv a, int op, struct sValCmd1 *dA1, int at, struct sConvertTypes *dConvertTypes)
apply an operation &#39;op&#39; to an argument a return TRUE on failure
Definition: iparith.cc:8202
static BOOLEAN jjBI2N(leftv res, leftv u)
Definition: iparith.cc:3776
static BOOLEAN jjUMINUS_MA(leftv res, leftv u)
Definition: iparith.cc:3729
static BOOLEAN jjSUBST_Id_N(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6457
#define IDROOT
Definition: ipid.h:20
static BOOLEAN jjDIV_P(leftv res, leftv u, leftv v)
Definition: iparith.cc:1217
ring rOpposite(ring src)
Definition: ring.cc:5189
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:540
BOOLEAN jjPROC(leftv res, leftv u, leftv v)
Definition: iparith.cc:1607
poly singclap_gcd(poly f, poly g, const ring r)
destroys f and g
Definition: clapsing.cc:287
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
void sdb_show_bp()
Definition: sdb.cc:58
#define pNeg(p)
Definition: polys.h:169
intvec * ivCopy(const intvec *o)
Definition: intvec.h:141
struct sValCmd1 * psValCmd1
Definition: iparith.cc:205
static BOOLEAN jjDEGREE(leftv res, leftv v)
Definition: iparith.cc:3903
bigintmat * bimAdd(bigintmat *a, bigintmat *b)
Matrix-Add/-Sub/-Mult so oder mit operator+/-/* ? : NULL as a result means an error (non-compatible m...
Definition: bigintmat.cc:180
BOOLEAN siq
Definition: subexpr.cc:58
static BOOLEAN jjINTERSECT_PL(leftv res, leftv v)
Definition: iparith.cc:7075
static BOOLEAN jjBREAK1(leftv, leftv v)
Definition: iparith.cc:6698
static BOOLEAN jjEXTGCD_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:2140
#define SIMPL_EQU
Definition: iparith.cc:3351
const char sNoName[]
Definition: subexpr.cc:56
int listLength()
Definition: subexpr.cc:61
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.
long int64
Definition: auxiliary.h:112
static BOOLEAN jjPlural_mat_poly(leftv res, leftv a, leftv b)
Definition: iparith.cc:2885
static BOOLEAN jjNEWSTRUCT3(leftv, leftv u, leftv v, leftv w)
Definition: iparith.cc:6224
static BOOLEAN jjTRACE_IV(leftv res, leftv v)
Definition: iparith.cc:5086
#define pLmDelete(p)
assume p != NULL, deletes Lm(p)->coef and Lm(p)
Definition: polys.h:76
resolvente res
Definition: syz.h:47
#define pCmp(p1, p2)
pCmp: args may be NULL returns: (p2==NULL ? 1 : (p1 == NULL ? -1 : p_LmCmp(p1, p2))) ...
Definition: polys.h:115
static BOOLEAN jjGT_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:1132
static BOOLEAN jjidFreeModule(leftv res, leftv v)
Definition: iparith.cc:5378
static BOOLEAN rField_is_Q_a(const ring r)
Definition: ring.h:488
static BOOLEAN jjINTERPOLATION(leftv res, leftv l, leftv v)
Definition: iparith.cc:2580
#define TRUE
Definition: auxiliary.h:144
struct sValCmd1 dArith1[]
Definition: table.h:19
#define nIsOne(n)
Definition: numbers.h:25
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.
lib_types type_of_LIB(const char *newlib, char *libnamebuf)
Definition: mod_lib.cc:24
static BOOLEAN jjMINUS_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:864
static BOOLEAN jjDUMMY(leftv res, leftv u)
Definition: iparith.cc:3674
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:2221
int length() const
Definition: intvec.h:86
syStrategy syResolution(ideal arg, int maxlength, intvec *w, BOOLEAN minim)
Definition: syz.cc:623
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:54
#define IDIDEAL(a)
Definition: ipid.h:132
ideal idMultSect(resolvente arg, int length)
Definition: ideals.cc:350
static BOOLEAN jjHILBERT_IV(leftv res, leftv v)
Definition: iparith.cc:4260
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1435
intvec * ivSub(intvec *a, intvec *b)
Definition: intvec.cc:306
int syDim(syStrategy syzstr)
Definition: syz1.cc:1860
#define pSplit(p, r)
Definition: polys.h:235
void Init()
Definition: subexpr.h:108
static BOOLEAN rField_is_Domain(const ring r)
Definition: ring.h:440
#define UNKNOWN
Definition: tok.h:174
int cmdtok
Definition: grammar.cc:175
static BOOLEAN jjEQUAL_BI(leftv res, leftv u, leftv v)
Definition: iparith.cc:1322
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition: coeffs.h:579
poly iiHighCorner(ideal I, int ak)
Definition: ipshell.cc:1488
void * ADDRESS
Definition: auxiliary.h:161
static BOOLEAN jjTIMES_MA_BI1(leftv res, leftv u, leftv v)
Definition: iparith.cc:1036
sleftv * leftv
Definition: structs.h:60
static BOOLEAN jjWEDGE(leftv res, leftv u, leftv v)
Definition: iparith.cc:3658
BOOLEAN iiExprArithM(leftv res, leftv a, int op)
Definition: iparith.cc:8630
poly singclap_det(const matrix m, const ring s)
Definition: clapsing.cc:1579
#define SI_SAVE_OPT1(A)
Definition: options.h:20
sValCmdTab jjValCmdTab[]
Definition: iparith.cc:149
static BOOLEAN jjPROC1(leftv res, leftv u)
Definition: iparith.cc:3749
intvec * ivTranp(intvec *o)
Definition: intvec.cc:336
#define PLURAL_MASK
Definition: iparith.cc:107
g
Definition: cfModGcd.cc:4031
static BOOLEAN jjDEG_M(leftv res, leftv u)
Definition: iparith.cc:3892
static BOOLEAN jjDIM_R(leftv res, leftv v)
Definition: iparith.cc:5461
void WerrorS(const char *s)
Definition: feFopen.cc:24
static BOOLEAN jjPROC3(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5738
void omPrintStats(FILE *fd)
Definition: omStats.c:114
int k
Definition: cfEzgcd.cc:93
static BOOLEAN jjJanetBasis2(leftv res, leftv u, leftv v)
Definition: iparith.cc:2592
static BOOLEAN jjOP_BIM_BI(leftv res, leftv u, leftv v)
Definition: iparith.cc:288
static BOOLEAN jjBRACK_Im(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5503
ideal idModulo(ideal h2, ideal h1, tHomog hom, intvec **w)
Definition: ideals.cc:2035
int min_in()
Definition: intvec.h:114
static BOOLEAN jjDIV_Ma(leftv res, leftv u, leftv v)
Definition: iparith.cc:1292
static intvec * idSort(ideal id, BOOLEAN nolex=TRUE)
Definition: ideals.h:181
static BOOLEAN jjNAMES0(leftv res, leftv)
Definition: iparith.cc:7462
static BOOLEAN rField_is_GF(const ring r)
Definition: ring.h:470
Definition: tok.h:98
static char const ** rParameter(const ring r)
(r->cf->parameter)
Definition: ring.h:573
int inerror
Definition: grammar.cc:176
static BOOLEAN jjTIMES_BI(leftv res, leftv u, leftv v)
Definition: iparith.cc:940
static BOOLEAN jjSTD(leftv res, leftv v)
Definition: iparith.cc:5000
static BOOLEAN jjJACOB_P(leftv res, leftv v)
Definition: iparith.cc:4401
static BOOLEAN jjpLength(leftv res, leftv v)
Definition: iparith.cc:5368
#define pLmFreeAndNext(p)
assumes p != NULL, deletes p, returns pNext(p)
Definition: polys.h:74
#define Q
Definition: sirandom.c:25
#define nEqual(n1, n2)
Definition: numbers.h:20
char * showOption()
Definition: misc_ip.cc:727
static BOOLEAN jjJET_P(leftv res, leftv u, leftv v)
Definition: iparith.cc:2603
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
static BOOLEAN jjGE_BI(leftv res, leftv u, leftv v)
Definition: iparith.cc:1107
int traceit
Definition: febase.cc:47
#define pEqualPolys(p1, p2)
Definition: polys.h:372
#define WarnS
Definition: emacs.cc:81
static FORCE_INLINE int n_ParDeg(number n, const coeffs r)
Definition: coeffs.h:788
BOOLEAN jjLOAD(const char *s, BOOLEAN autoexport)
load lib/module given in v
Definition: iparith.cc:5286
static BOOLEAN jjP2N(leftv res, leftv v)
Definition: iparith.cc:4788
ideal idMinEmbedding(ideal arg, BOOLEAN inPlace, intvec **w)
Definition: ideals.cc:2344
#define BITSET
Definition: structs.h:17
static BOOLEAN jjGCD_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:2402
poly singclap_pdivide(poly f, poly g, const ring r)
Definition: clapsing.cc:547
coeffs coeffs_BIGINT
Definition: ipid.cc:54
int Typ()
Definition: subexpr.cc:969
#define omAlloc(size)
Definition: omAllocDecl.h:210
static BOOLEAN jjOPPOSE(leftv res, leftv a, leftv b)
Definition: iparith.cc:2946
static bool rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:361
static BOOLEAN jjSUBST_Id(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6409
static BOOLEAN jjPRUNE(leftv res, leftv v)
Definition: iparith.cc:4764
static BOOLEAN jjOP_I_BIM(leftv res, leftv u, leftv v)
Definition: iparith.cc:284
ideal idQuot(ideal h1, ideal h2, BOOLEAN h1IsStb, BOOLEAN resultIsIdeal)
Definition: ideals.cc:1307
#define Sy_bit(x)
Definition: options.h:30
short res
Definition: gentable.cc:70
long(* pLDegProc)(poly p, int *length, ring r)
Definition: ring.h:45
static BOOLEAN jjINDEX_P_IV(leftv res, leftv u, leftv v)
Definition: iparith.cc:1452
static BOOLEAN jjsyMinBase(leftv res, leftv v)
Definition: iparith.cc:5412
const char * Name()
Definition: subexpr.h:121
#define pGetComp(p)
Component.
Definition: polys.h:37
static BOOLEAN jjPARSTR1(leftv res, leftv v)
Definition: iparith.cc:4702
static BOOLEAN jjHOMOG1_W(leftv res, leftv v, leftv u)
Definition: iparith.cc:2547
static BOOLEAN jjGE_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:1114
static int pLength(poly a)
Definition: p_polys.h:189
static int iiTabIndex(const jjValCmdTab dArithTab, const int len, const int op)
Definition: iparith.cc:8838
BOOLEAN iiExport(leftv v, int toLev)
Definition: ipshell.cc:1388
Definition: idrec.h:34
Definition: tok.h:91
newstruct_desc newstructFromString(const char *s)
Definition: newstruct.cc:795
static BOOLEAN jjWAIT1ST2(leftv res, leftv u, leftv v)
Definition: iparith.cc:3586
#define IDHDL
Definition: tok.h:35
ideal idOppose(ring Rop_src, ideal I, const ring Rop_dst)
opposes a module I from Rop to currRing(dst)
Definition: old.gring.cc:3466
poly redNF(poly h, int &max_ind, int nonorm, kStrategy strat)
Definition: kstd2.cc:1321
static BOOLEAN jjMAP(leftv res, leftv u, leftv v)
Definition: iparith.cc:1643
omBin char_ptr_bin
Definition: ring.cc:55
const char * Fullname()
Definition: subexpr.h:126
static BOOLEAN jjKoszul_Id(leftv res, leftv u, leftv v)
Definition: iparith.cc:2634
static BOOLEAN jjMINUS_N(leftv res, leftv u, leftv v)
Definition: iparith.cc:885
static BOOLEAN idIsZeroDim(ideal i)
Definition: ideals.h:173
#define ivTest(v)
Definition: intvec.h:165
idhdl get(const char *s, int lev)
Definition: ipid.cc:91
#define SI_PROT_I
Definition: reporter.h:50
ideal idMinBase(ideal h1)
Definition: ideals.cc:53
void monitor(void *F, int mode)
Definition: febase.cc:72
matrix idCoeffOfKBase(ideal arg, ideal kbase, poly how)
Definition: ideals.cc:2278
bool found
Definition: facFactorize.cc:56
static BOOLEAN jjTIMES_MA_I1(leftv res, leftv u, leftv v)
Definition: iparith.cc:1082
static BOOLEAN jjP2I(leftv res, leftv v)
Definition: iparith.cc:4740
ideal id_JetW(ideal i, int d, intvec *iv, const ring R)
static BOOLEAN jjMINOR_M(leftv res, leftv v)
Definition: iparith.cc:6025
static BOOLEAN jjEXPORTTO(leftv, leftv u, leftv v)
Definition: iparith.cc:2114
char * String(void *d=NULL, BOOLEAN typed=FALSE, int dim=1)
Called for conversion to string (used by string(..), write(..),..)
Definition: subexpr.cc:720
static void iiReWrite(const char *s)
Definition: iparith.cc:135
int iiRegularity(lists L)
Definition: ipshell.cc:953
static FORCE_INLINE number n_Random(siRandProc p, number p1, number p2, const coeffs cf)
Definition: coeffs.h:970
static BOOLEAN jjUMINUS_BI(leftv res, leftv u)
Definition: iparith.cc:3705
void * data
Definition: subexpr.h:89
static BOOLEAN jjTIMES_BIM(leftv res, leftv u, leftv v)
Definition: iparith.cc:1024
static BOOLEAN jjCOUNT_RES(leftv res, leftv v)
Definition: iparith.cc:5456
static BOOLEAN jjJanetBasis(leftv res, leftv v)
Definition: iparith.cc:2598
void printBlackboxTypes()
list all defined type (for debugging)
Definition: blackbox.cc:210
#define mflush()
Definition: reporter.h:55
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..n_NumberOfParameters(...)
Definition: coeffs.h:801
static BOOLEAN jjVARSTR2(leftv res, leftv u, leftv v)
Definition: iparith.cc:3573
static BOOLEAN jjLE_N(leftv res, leftv u, leftv v)
Definition: iparith.cc:1151
static BOOLEAN jjROWS_IV(leftv res, leftv v)
Definition: iparith.cc:4868
#define pIter(p)
Definition: monomials.h:44
int rSum(ring r1, ring r2, ring &sum)
Definition: ring.cc:1302
static BOOLEAN jjEQUAL_Ma(leftv res, leftv u, leftv v)
Definition: iparith.cc:1334
poly res
Definition: myNF.cc:322
static BOOLEAN jjBAREISS(leftv res, leftv v)
Definition: iparith.cc:3753
intvec * kHomW
Definition: kstd1.cc:2196
matrix mp_Transp(matrix a, const ring R)
Definition: matpol.cc:268
#define IDPACKAGE(a)
Definition: ipid.h:138
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of &#39;a&#39; and &#39;b&#39;, i.e., a*b
Definition: coeffs.h:635
static BOOLEAN jjWAITALL2(leftv res, leftv u, leftv v)
Definition: iparith.cc:3610
int myynest
Definition: febase.cc:46
int scMultInt(ideal S, ideal Q)
Definition: hdegree.cc:799
#define M
Definition: sirandom.c:24
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
#define pGetExp(p, i)
Exponent.
Definition: polys.h:41
static BOOLEAN jjBRACK_Ma_IV_IV(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5687
#define V_SHOW_USE
Definition: options.h:50
#define IDTYP(a)
Definition: ipid.h:118
static void WerrorS_dummy(const char *)
Definition: iparith.cc:5346
static BOOLEAN jjCOUNT_IV(leftv res, leftv v)
Definition: iparith.cc:3866
static BOOLEAN jjRES3(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6597
static BOOLEAN jjTIMES_MA_N1(leftv res, leftv u, leftv v)
Definition: iparith.cc:1070
static BOOLEAN jjRINGLIST_C(leftv res, leftv v)
Definition: iparith.cc:4849
static BOOLEAN jjSTATUS2L(leftv res, leftv u, leftv v)
Definition: iparith.cc:3439
static BOOLEAN check_valid(const int p, const int op)
Definition: iparith.cc:9140
static BOOLEAN jjPLUS_P(leftv res, leftv u, leftv v)
Definition: iparith.cc:797
char * iiArithGetCmd(int nPos)
Definition: iparith.cc:9046
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition: ipid.cc:259
static BOOLEAN jjrCharStr(leftv res, leftv v)
Definition: iparith.cc:5388
static BOOLEAN jjKoszul(leftv res, leftv u, leftv v)
Definition: iparith.cc:2630
poly * m
Definition: matpol.h:19
static BOOLEAN jjBRACKET(leftv res, leftv a, leftv b)
Definition: iparith.cc:2927
const char * Tok2Cmdname(int tok)
Definition: iparith.cc:8861
BOOLEAN iiMake_proc(idhdl pn, package pack, sleftv *sl)
Definition: iplib.cc:573
static BOOLEAN jjINDEX_P(leftv res, leftv u, leftv v)
Definition: iparith.cc:1435
int RingDependend(int t)
Definition: gentable.cc:23
Definition: tok.h:56
void luDecomp(const matrix aMat, matrix &pMat, matrix &lMat, matrix &uMat, const ring R)
LU-decomposition of a given (m x n)-matrix.
void id_Shift(ideal M, int s, const ring r)
long p_DegW(poly p, const short *w, const ring R)
Definition: p_polys.cc:689
char my_yylinebuf[80]
Definition: febase.cc:48
static BOOLEAN jjOP_BIM_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:269
int r_IsRingVar(const char *n, char **names, int N)
Definition: ring.cc:222
ideal idSect(ideal h1, ideal h2)
Definition: ideals.cc:211
static BOOLEAN jjREDUCE3_CID(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6570
static BOOLEAN jjIDEAL_Map(leftv res, leftv v)
Definition: iparith.cc:4329
static BOOLEAN jjSUBST_Test(leftv v, leftv w, int &ringvar, poly &monomexpr)
Definition: iparith.cc:6355
const ring r
Definition: syzextra.cc:208
static BOOLEAN jjIm2Iv(leftv res, leftv v)
Definition: iparith.cc:4356
static BOOLEAN jjSUBST_M(leftv res, leftv u)
Definition: iparith.cc:7825
static BOOLEAN jjLU_INVERSE(leftv res, leftv v)
Definition: iparith.cc:7149
static BOOLEAN jjHIGHCORNER_M(leftv res, leftv v)
Definition: iparith.cc:4177
BOOLEAN expected_parms
Definition: grammar.cc:174
static BOOLEAN jjINDEPSET2(leftv res, leftv u, leftv v)
Definition: iparith.cc:2567
intvec * bim2iv(bigintmat *b)
Definition: bigintmat.cc:341
Coefficient rings, fields and other domains suitable for Singular polynomials.
static BOOLEAN jjLT_BI(leftv res, leftv u, leftv v)
Definition: iparith.cc:1155
static BOOLEAN jjIMPART(leftv res, leftv v)
Definition: iparith.cc:4363
resolvente orderedRes
Definition: syz.h:48
static BOOLEAN jjLOAD1(leftv, leftv v)
Definition: iparith.cc:4514
ideal idSeries(int n, ideal M, matrix U, intvec *w)
Definition: ideals.cc:1933
intvec * kModW
Definition: kstd1.cc:2196
ideal idElimination(ideal h1, poly delVar, intvec *hilb)
Definition: ideals.cc:1400
#define FLAG_TWOSTD
Definition: ipid.h:109
static BOOLEAN jjSUBST_Id_X(leftv res, leftv u, leftv v, leftv w, int input_type)
Definition: iparith.cc:6461
static BOOLEAN jjREDUCE_ID(leftv res, leftv u, leftv v)
Definition: iparith.cc:3068
#define TIMER_RESOLUTION
Definition: mod2.h:40
BOOLEAN jjWAITALL1(leftv res, leftv u)
Definition: iparith.cc:5255
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 ...
Definition: intvec.h:16
#define pSub(a, b)
Definition: polys.h:258
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
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.
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:548
const char * iiTwoOps(int t)
Definition: gentable.cc:252
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:49
poly p_One(const ring r)
Definition: p_polys.cc:1318
short cmd
Definition: iparith.cc:145
static BOOLEAN jjUMINUS_I(leftv res, leftv u)
Definition: iparith.cc:3712
matrix mp_Wedge(matrix a, int ar, const ring R)
Definition: matpol.cc:1656
static BOOLEAN jjWRONG(leftv, leftv)
Definition: iparith.cc:3665
BOOLEAN rComplete(ring r, int force)
this needs to be called whenever a new ring is created: new fields in ring are created (like VarOffse...
Definition: ring.cc:3436
static BOOLEAN jjMATRIX_Ma(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6507
static BOOLEAN jjMSTD(leftv res, leftv v)
Definition: iparith.cc:4594
leftv Next()
Definition: subexpr.h:137
int iiArithRemoveCmd(char *szName)
int nrows
Definition: matpol.h:21
tHomog
Definition: structs.h:37
int j
Definition: myNF.cc:70
static BOOLEAN jjUMINUS_P(leftv res, leftv u)
Definition: iparith.cc:3724
static BOOLEAN jjCOEFFS2_KB(leftv res, leftv u, leftv v)
Definition: iparith.cc:1937
static BOOLEAN jjmpTrace(leftv res, leftv v)
Definition: iparith.cc:5422
lists ipNameListLev(idhdl root, int lev)
Definition: ipid.cc:550
static BOOLEAN jjALIGN_V(leftv res, leftv u, leftv v)
Definition: iparith.cc:1748
Definition: tok.h:58
bigintmat * bimMult(bigintmat *a, bigintmat *b)
Definition: bigintmat.cc:253
#define nGreaterZero(n)
Definition: numbers.h:27
const char * name
Definition: subexpr.h:88
void pSetDegProcs(ring r, pFDegProc new_FDeg, pLDegProc new_lDeg)
Definition: p_polys.cc:3481
static BOOLEAN jjKLAMMER(leftv res, leftv u, leftv v)
Definition: iparith.cc:1547
#define pSetCompP(a, i)
Definition: polys.h:274
#define omFree(addr)
Definition: omAllocDecl.h:261
static long pTotaldegree(poly p)
Definition: polys.h:253
static BOOLEAN jjHOMOG_P_W(leftv res, leftv u, leftv v, leftv)
Definition: iparith.cc:5951
BOOLEAN setOption(leftv res, leftv v)
Definition: misc_ip.cc:581
omInfo_t om_Info
Definition: omStats.c:13
static BOOLEAN jjDIFF_ID(leftv res, leftv u, leftv v)
Definition: iparith.cc:1992
int scMult0Int(ideal S, ideal Q, const ring tailRing)
Definition: hdegree.cc:919
#define assume(x)
Definition: mod2.h:405
poly pSubstPar(poly p, int par, poly image)
Definition: maps_ip.cc:228
The main handler for Singular numbers which are suitable for Singular polynomials.
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of &#39;a&#39; and &#39;b&#39;, i.e., a+b
Definition: coeffs.h:655
static BOOLEAN jjRPAR(leftv res, leftv v)
Definition: iparith.cc:4873
static BOOLEAN jjERROR(leftv, leftv u)
Definition: iparith.cc:2119
static BOOLEAN jjVDIM(leftv res, leftv v)
Definition: iparith.cc:5234
static BOOLEAN jjEQUAL_N(leftv res, leftv u, leftv v)
Definition: iparith.cc:1340
static BOOLEAN jjJET4(leftv res, leftv u)
Definition: iparith.cc:7344
void scDegree(ideal S, intvec *modulweight, ideal Q)
Definition: hdegree.cc:822
static BOOLEAN jjOP_IM_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:326
int nLastIdentifier
valid indentifieres are slot 1..nLastIdentifier
Definition: iparith.cc:211
#define nInpNeg(n)
Definition: numbers.h:21
static BOOLEAN jjLEADEXP(leftv res, leftv v)
Definition: iparith.cc:4481
int scDimInt(ideal S, ideal Q)
Definition: hdegree.cc:72
int compare(const intvec *o) const
Definition: intvec.cc:225
static BOOLEAN jjSLIM_GB(leftv res, leftv u)
Definition: iparith.cc:4878
matrix mp_MultI(matrix a, int f, const ring R)
c = f*a
Definition: matpol.cc:146
proc2 p
Definition: iparith.cc:174
#define pLmInit(p)
like pInit, except that expvector is initialized to that of p, p must be != NULL
Definition: polys.h:64
#define pDivideM(a, b)
Definition: polys.h:265
static BOOLEAN jjDIVISION4(leftv res, leftv v)
Definition: iparith.cc:6754
static BOOLEAN jjKBASE(leftv res, leftv v)
Definition: iparith.cc:4454
#define A
Definition: sirandom.c:23
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:72
#define nMult(n1, n2)
Definition: numbers.h:17
static FORCE_INLINE number n_ChineseRemainderSym(number *a, number *b, int rl, BOOLEAN sym, CFArray &inv_cache, const coeffs r)
Definition: coeffs.h:782
static BOOLEAN jjVARSTR1(leftv res, leftv v)
Definition: iparith.cc:5217
static BOOLEAN jjREDUCE5(leftv res, leftv u)
Definition: iparith.cc:7539
pNormalize(P.p)
static BOOLEAN jjELIMIN(leftv res, leftv u, leftv v)
Definition: iparith.cc:2094
static BOOLEAN jjSTD_HILB_W(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6649
const ring R
Definition: DebugPrint.cc:36
static BOOLEAN jjLIFT3(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6533
BOOLEAN sm_CheckDet(ideal I, int d, BOOLEAN sw, const ring r)
Definition: sparsmat.cc:308
static BOOLEAN jjMONOM(leftv res, leftv v)
Definition: iparith.cc:2794
const char feNotImplemented[]
Definition: reporter.cc:54
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
static BOOLEAN jjTIMES_N(leftv res, leftv u, leftv v)
Definition: iparith.cc:947
static BOOLEAN jjMOD_BI(leftv res, leftv u, leftv v)
Definition: iparith.cc:2726
static BOOLEAN jjBRACK_Ma_IV_I(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5637
long kHomModDeg(poly p, ring r)
Definition: kstd1.cc:2208
Definition: grammar.cc:270
struct sValCmd3 dArith3[]
Definition: table.h:706
static BOOLEAN jjPREIMAGE(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6234
void makeVector()
Definition: intvec.h:95
static BOOLEAN jjKLAMMER_PL(leftv res, leftv u)
Definition: iparith.cc:7390
omBin sSubexpr_bin
Definition: subexpr.cc:49
ideal kInterRed(ideal F, ideal Q)
Definition: kstd1.cc:3277
ideal id_Power(ideal given, int exp, const ring r)
#define SIMPL_NORM
Definition: iparith.cc:3353
BOOLEAN(* proc3)(leftv, leftv, leftv, leftv)
Definition: iparith.cc:182
static BOOLEAN jjSTATUS_M(leftv res, leftv v)
Definition: iparith.cc:7794
static BOOLEAN jjDEG_M_IV(leftv res, leftv u, leftv v)
Definition: iparith.cc:1956
ip_smatrix * matrix
static BOOLEAN jjDET(leftv res, leftv v)
Definition: iparith.cc:3970
BOOLEAN jjLOAD_TRY(const char *s)
Definition: iparith.cc:5350
static BOOLEAN jjSUBST_P(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6383
static BOOLEAN jjLIFTSTD(leftv res, leftv u, leftv v)
Definition: iparith.cc:2652
int nCmdUsed
number of commands used
Definition: iparith.cc:209
static BOOLEAN jjRES(leftv res, leftv u, leftv v)
Definition: iparith.cc:3195
static BOOLEAN jjINDEX_V_IV(leftv res, leftv u, leftv v)
Definition: iparith.cc:1511
static BOOLEAN jjSTRING_PL(leftv res, leftv v)
Definition: iparith.cc:7609
static BOOLEAN jjRANK1(leftv res, leftv v)
Definition: iparith.cc:4820
static BOOLEAN jjHOMOG_P(leftv res, leftv u, leftv v)
Definition: iparith.cc:2508
idhdl currRingHdl
Definition: ipid.cc:65
static BOOLEAN jjDIV_N(leftv res, leftv u, leftv v)
Definition: iparith.cc:1204
void Copy(leftv e)
Definition: subexpr.cc:657
#define setFlag(A, F)
Definition: ipid.h:112
static BOOLEAN jjEXTGCD_P(leftv res, leftv u, leftv v)
Definition: iparith.cc:2169
static BOOLEAN jjLEADCOEF(leftv res, leftv v)
Definition: iparith.cc:4468
#define pSetComp(p, v)
Definition: polys.h:38
static BOOLEAN jjSBA_2(leftv res, leftv v, leftv u, leftv t)
Definition: iparith.cc:4974
struct sValCmd2 * psValCmd2
Definition: iparith.cc:206
#define pJet(p, m)
Definition: polys.h:339
int m
Definition: cfEzgcd.cc:119
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:1681
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:558
short ref
Definition: idrec.h:46
#define pIsConstant(p)
like above, except that Comp might be != 0
Definition: polys.h:209
static BOOLEAN jjSBA(leftv res, leftv v)
Definition: iparith.cc:4922
static BOOLEAN jjREGULARITY(leftv res, leftv v)
Definition: iparith.cc:4831
BOOLEAN jjStdJanetBasis(leftv res, leftv v, int flag)
flag: 0: JB, 1: SB
Definition: wrapper.cc:52
#define nSub(n1, n2)
Definition: numbers.h:22
matrix pMultMp(poly p, matrix a, const ring R)
Definition: matpol.cc:176
static BOOLEAN jjDEFINED(leftv res, leftv v)
Definition: iparith.cc:3941
static BOOLEAN jjidVec2Ideal(leftv res, leftv v)
Definition: iparith.cc:5383
struct sValCmdM * psValCmdM
Definition: iparith.cc:208
static int si_max(const int a, const int b)
Definition: auxiliary.h:166
static BOOLEAN jjGE_N(leftv res, leftv u, leftv v)
Definition: iparith.cc:1119
static FORCE_INLINE BOOLEAN nCoeff_is_transExt(const coeffs r)
TRUE iff r represents a transcendental extension field.
Definition: coeffs.h:919
static BOOLEAN jjREDUCE_P(leftv res, leftv u, leftv v)
Definition: iparith.cc:3060
idrec * idhdl
Definition: ring.h:18
#define ZERODIVISOR_MASK
Definition: iparith.cc:114
FILE * feFopen(const char *path, const char *mode, char *where, short useWerror, short path_only)
Definition: feFopen.cc:47
static BOOLEAN jjMINUS_P(leftv res, leftv u, leftv v)
Definition: iparith.cc:890
BOOLEAN assumeStdFlag(leftv h)
Definition: subexpr.cc:1448
static BOOLEAN jjOP_I_IV(leftv res, leftv u, leftv v)
Definition: iparith.cc:322
static BOOLEAN jjFAREY_ID(leftv res, leftv u, leftv v)
Definition: iparith.cc:2266
static BOOLEAN jjRESERVED0(leftv, leftv)
Definition: iparith.cc:7588
omBin sleftv_bin
Definition: subexpr.cc:50
int i
Definition: cfEzgcd.cc:123
static BOOLEAN jjENVELOPE(leftv res, leftv a)
Definition: iparith.cc:5117
static BOOLEAN jjPFAC2(leftv res, leftv u, leftv v)
Definition: iparith.cc:3315
void PrintS(const char *s)
Definition: reporter.cc:294
static BOOLEAN jjDEG_IV(leftv res, leftv u, leftv v)
Definition: iparith.cc:1967
lib_types
Definition: mod_raw.h:16
static BOOLEAN jjRINGLIST(leftv res, leftv v)
Definition: iparith.cc:4841
lists ipNameList(idhdl root)
Definition: ipid.cc:527
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:461
static BOOLEAN jjCALL1ARG(leftv res, leftv v)
Definition: iparith.cc:6715
static BOOLEAN jjLOAD2(leftv, leftv, leftv v)
Definition: iparith.cc:2662
static BOOLEAN jjidTransp(leftv res, leftv v)
Definition: iparith.cc:5466
int iiArithAddCmd(const char *szName, short nAlias, short nTokval, short nToktype, short nPos=-1)
Definition: iparith.cc:9081
static long p_MinComp(poly p, ring lmRing, ring tailRing)
Definition: p_polys.h:302
BOOLEAN load_builtin(const char *newlib, BOOLEAN autoexport, SModulFunc_t init)
Definition: iplib.cc:1147
#define SIMPL_LMEQ
Definition: iparith.cc:3349
static BOOLEAN jjSTD_HILB(leftv res, leftv u, leftv v)
Definition: iparith.cc:3457
int IsPrime(int p)
Definition: prime.cc:61
#define SIMPL_NULL
Definition: iparith.cc:3352
static BOOLEAN jjidMinBase(leftv res, leftv v)
Definition: iparith.cc:5407
#define pOne()
Definition: polys.h:286
syStrategy sySchreyer(ideal arg, int maxlength)
Definition: syz0.cc:1024
BOOLEAN sdb_set_breakpoint(const char *pp, int given_lineno)
Definition: sdb.cc:65
static BOOLEAN jjBI2P(leftv res, leftv u)
Definition: iparith.cc:3797
int yyparse(void)
Definition: grammar.cc:2168
matrix id_Module2Matrix(ideal mod, const ring R)
resolvente sySchreyerResolvente(ideal arg, int maxlength, int *length, BOOLEAN isMonomial=FALSE, BOOLEAN notReplace=FALSE)
Definition: syz0.cc:861
static BOOLEAN jjDIM2(leftv res, leftv v, leftv w)
Definition: iparith.cc:2008
Definition: tok.h:88
static BOOLEAN jjPOWER_BI(leftv res, leftv u, leftv v)
Definition: iparith.cc:591
static BOOLEAN jjUMINUS_N(leftv res, leftv u)
Definition: iparith.cc:3717
int sySize(syStrategy syzstr)
Definition: syz1.cc:1840
static BOOLEAN jjDIVISION(leftv res, leftv u, leftv v)
Definition: iparith.cc:2053
static BOOLEAN jjFWALK(leftv res, leftv u, leftv v)
Definition: iparith.cc:2396
static BOOLEAN jjREDUCE3_CP(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6558
static BOOLEAN jjINTERSECT(leftv res, leftv u, leftv v)
Definition: iparith.cc:2574
struct sValCmd2 dArith2[]
Definition: table.h:290
static BOOLEAN jjREDUCE3_P(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6582
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL ...
Definition: polys.h:67
static BOOLEAN jjmpTransp(leftv res, leftv v)
Definition: iparith.cc:5427
static BOOLEAN jjTYPEOF(leftv res, leftv v)
Definition: iparith.cc:5150
static BOOLEAN jjINDEX_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:1377
#define IDELEMS(i)
Definition: simpleideals.h:24
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the zero element.
Definition: coeffs.h:465
static BOOLEAN jjFactModD_M(leftv res, leftv v)
Definition: iparith.cc:7662
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:720
lists scIndIndset(ideal S, BOOLEAN all, ideal Q)
Definition: ipshell.cc:1019
#define atKill(H, A)
Definition: attrib.h:44
int lSize(lists L)
Definition: lists.cc:25
void(* WerrorS_callback)(const char *s)
Definition: feFopen.cc:21
#define V_DEG_STOP
Definition: options.h:67
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
void iiMakeResolv(resolvente r, int length, int rlen, char *name, int typ0, intvec **weights)
Definition: ipshell.cc:772
static BOOLEAN jjPLUS_IV(leftv res, leftv u, leftv v)
Definition: iparith.cc:802
#define IDLEV(a)
Definition: ipid.h:120
char * SPrintEnd()
Definition: reporter.cc:283
resolvente fullres
Definition: syz.h:57
#define TRACE_CALL
Definition: reporter.h:41
#define nDelete(n)
Definition: numbers.h:16
#define IDMAP(a)
Definition: ipid.h:134
int cols() const
Definition: bigintmat.h:147
#define FLAG_STD
Definition: ipid.h:108
static BOOLEAN jjLISTRING(leftv res, leftv v)
Definition: iparith.cc:4518
static BOOLEAN jjOPTION_PL(leftv res, leftv v)
Definition: iparith.cc:7467
poly p_Series(int n, poly p, poly u, intvec *w, const ring R)
Definition: p_polys.cc:4247
BOOLEAN iiExprArith2Tab(leftv res, leftv a, int op, struct sValCmd2 *dA2, int at, struct sConvertTypes *dConvertTypes)
apply an operation &#39;op&#39; to arguments a and a->next return TRUE on failure
Definition: iparith.cc:8130
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:3954
static BOOLEAN jjRANDOM_CF(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6334
static BOOLEAN jjIS_RINGVAR_P(leftv res, leftv v)
Definition: iparith.cc:4385
ideal idCopy(ideal A)
Definition: ideals.h:73
static BOOLEAN jjrOrdStr(leftv res, leftv v)
Definition: iparith.cc:5432
static BOOLEAN jjNAMES(leftv res, leftv v)
Definition: iparith.cc:4648
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...
static BOOLEAN jjGCD_BI(leftv res, leftv u, leftv v)
Definition: iparith.cc:2416
short errorreported
Definition: feFopen.cc:23
leftv next
Definition: subexpr.h:87
static BOOLEAN jjBRACK_S(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5487
struct sValCmdM dArithM[]
Definition: table.h:816
struct sConvertTypes dConvertTypes[]
Definition: table.h:1170
void pRestoreDegProcs(ring r, pFDegProc old_FDeg, pLDegProc old_lDeg)
Definition: p_polys.cc:3493
#define rHasLocalOrMixedOrdering_currRing()
Definition: ring.h:760
static FORCE_INLINE number n_ImPart(number i, const coeffs cf)
Definition: coeffs.h:811
void test_cmd(int i)
Definition: ipshell.cc:521
void rChangeCurrRing(ring r)
Definition: polys.cc:14
static BOOLEAN jjFIND2(leftv res, leftv u, leftv v)
Definition: iparith.cc:2379
static BOOLEAN jjFETCH_M(leftv res, leftv u)
Definition: iparith.cc:6947
static BOOLEAN jjMOD_N(leftv res, leftv u, leftv v)
Definition: iparith.cc:2737
resolvente minres
Definition: syz.h:58
static BOOLEAN rField_is_Zp(const ring r)
Definition: ring.h:455
static FORCE_INLINE number n_Farey(number a, number b, const coeffs r)
Definition: coeffs.h:785
intvec * ivMult(intvec *a, intvec *b)
Definition: intvec.cc:358
ideal idSubstPoly(ideal id, int n, poly e)
Definition: maps_ip.cc:420
static BOOLEAN jjBAREISS3(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5745
static BOOLEAN jjSIMPL_P(leftv res, leftv u, leftv v)
Definition: iparith.cc:3445
#define BVERBOSE(a)
Definition: options.h:33
short start
Definition: iparith.cc:146
void p_Shift(poly *p, int i, const ring r)
shifts components of the vector p by i
Definition: p_polys.cc:4483
#define NO_ZERODIVISOR
Definition: iparith.cc:124
static BOOLEAN jjDIM(leftv res, leftv v)
Definition: iparith.cc:4029
INLINE_THIS void Init(int l=0)
Definition: lists.h:66
static BOOLEAN jjCOEFFS3_KB(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5784
BOOLEAN(* proc2)(leftv, leftv, leftv)
Definition: iparith.cc:171
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:48
#define TEST_OPT_RETURN_SB
Definition: options.h:107
#define nInvers(a)
Definition: numbers.h:33
Definition: tok.h:38
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:850
ideal idMult(ideal h1, ideal h2)
hh := h1 * h2
Definition: ideals.h:96
matrix mp_MultP(matrix a, poly p, const ring R)
multiply a matrix &#39;a&#39; by a poly &#39;p&#39;, destroy the args
Definition: matpol.cc:159
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
static BOOLEAN jjOP_IV_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:305
static BOOLEAN iiExprArith2TabIntern(leftv res, leftv a, int op, leftv b, BOOLEAN proccall, struct sValCmd2 *dA2, int at, int bt, struct sConvertTypes *dConvertTypes)
Definition: iparith.cc:7971
static BOOLEAN jjTIMES_MA_P1(leftv res, leftv u, leftv v)
Definition: iparith.cc:1050
static BOOLEAN jjINDEX_V(leftv res, leftv u, leftv v)
Definition: iparith.cc:1481
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:692
static BOOLEAN jjNEWSTRUCT2(leftv, leftv u, leftv v)
Definition: iparith.cc:2818
#define p_SetmComp
Definition: p_polys.h:233
#define SI_RESTORE_OPT2(A)
Definition: options.h:24
static BOOLEAN jjCOMPARE_P(leftv res, leftv u, leftv v)
Definition: iparith.cc:447
static BOOLEAN jjSQR_FREE2(leftv res, leftv u, leftv dummy)
Definition: iparith.cc:3387
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:38
static BOOLEAN jjGCD_P(leftv res, leftv u, leftv v)
Definition: iparith.cc:2440
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:2747
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
static BOOLEAN jjEXECUTE(leftv, leftv v)
Definition: iparith.cc:4091
#define pSeries(n, p, u, w)
Definition: polys.h:343
static BOOLEAN jjidMaxIdeal(leftv res, leftv v)
Definition: iparith.cc:4305
ring rCopy(ring r)
Definition: ring.cc:1618
matrix mp_Mult(matrix a, matrix b, const ring R)
Definition: matpol.cc:224
int singclap_factorize_retry
Definition: iparith.cc:3386
static BOOLEAN jjMINRES_R(leftv res, leftv v)
Definition: iparith.cc:4615
static BOOLEAN jjPlural_num_mat(leftv res, leftv a, leftv b)
Definition: iparith.cc:2864
static BOOLEAN iiExprArith3TabIntern(leftv res, int op, leftv a, leftv b, leftv c, struct sValCmd3 *dA3, int at, int bt, int ct, struct sConvertTypes *dConvertTypes)
Definition: iparith.cc:8388
static BOOLEAN jjCOEFFS3_P(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5790
void * atGet(idhdl root, const char *name, int t, void *defaultReturnValue)
Definition: attrib.cc:135
short res
Definition: gentable.cc:88
int nr
Definition: lists.h:43
#define nDiv(a, b)
Definition: numbers.h:32
int rows() const
Definition: bigintmat.h:148
void mp_Coef2(poly v, poly mon, matrix *c, matrix *m, const ring R)
corresponds to Macauley&#39;s coef: the exponent vector of vars has to contain the variables, eg &#39;xy&#39;; then the poly f is searched for monomials in x and y, these monimials are written to the first row of the matrix co. the second row of co contains the respective factors in f. Thus f = sum co[1,i]*co[2,i], i = 1..cols, rows equals 2.
Definition: matpol.cc:516
int & cols()
Definition: matpol.h:25
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 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:169
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:631
static BOOLEAN jjPLUS_N(leftv res, leftv u, leftv v)
Definition: iparith.cc:792
ideal id_Jet(ideal i, int d, const ring R)
CanonicalForm cf
Definition: cfModGcd.cc:4024
#define MATCOLS(i)
Definition: matpol.h:28
Definition: tok.h:95
static BOOLEAN jjJET_ID_IV(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6000
BOOLEAN jjLIST_PL(leftv res, leftv v)
Definition: iparith.cc:7411
static BOOLEAN jjTIMES_MA(leftv res, leftv u, leftv v)
Definition: iparith.cc:1092
void mp_Monomials(matrix c, int r, int var, matrix m, const ring R)
Definition: matpol.cc:377
#define nIsZero(n)
Definition: numbers.h:19
static BOOLEAN rField_is_Ring_2toM(const ring r)
Definition: ring.h:425
short res
Definition: gentable.cc:78
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:437
matrix mp_Add(matrix a, matrix b, const ring R)
Definition: matpol.cc:190
#define NULL
Definition: omList.c:10
BOOLEAN idHomIdeal(ideal id, ideal Q=NULL)
Definition: ideals.h:103
static BOOLEAN jjJET_ID(leftv res, leftv u, leftv v)
Definition: iparith.cc:2608
int ipower(int b, int m)
int ipower ( int b, int m )
Definition: cf_util.cc:25
int cols() const
Definition: intvec.h:87
matrix id_Module2formatedMatrix(ideal mod, int rows, int cols, const ring R)
slists * lists
Definition: mpr_numeric.h:146
ring rCompose(const lists L, const BOOLEAN check_comp=TRUE)
Definition: ipshell.cc:2409
static BOOLEAN jjHILBERT(leftv, leftv v)
Definition: iparith.cc:4224
ideal id_Farey(ideal x, number N, const ring r)
Definition: ideals.cc:2502
package req_packhdl
Definition: subexpr.h:107
ring syRing
Definition: syz.h:56
static BOOLEAN jjIS_RINGVAR_S(leftv res, leftv v)
Definition: iparith.cc:4390
SRes resPairs
Definition: syz.h:49
static BOOLEAN jjGT_N(leftv res, leftv u, leftv v)
Definition: iparith.cc:1137
omBin sip_command_bin
Definition: ipid.cc:49
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:332
static BOOLEAN jjLT_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:1159
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:448
lists rDecompose(const ring r)
Definition: ipshell.cc:1894
static BOOLEAN jjPOWER_P(leftv res, leftv u, leftv v)
Definition: iparith.cc:625
SModulFunc_t iiGetBuiltinModInit(const char *libname)
Definition: iplib.cc:738
static BOOLEAN jjQUOT(leftv res, leftv u, leftv v)
Definition: iparith.cc:3019
#define IDINT(a)
Definition: ipid.h:124
ideal sm_CallSolv(ideal I, const ring R)
Definition: sparsmat.cc:2372
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic ...
Definition: coeffs.h:35
#define pMult(p, q)
Definition: polys.h:178
static BOOLEAN jjCOEF_M(leftv, leftv v)
Definition: iparith.cc:6739
ideal walkProc(leftv first, leftv second)
Definition: walk_ip.cc:61
LINLINE void nlDelete(number *a, const coeffs r)
Definition: longrat.cc:2417
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of &#39;a&#39; and &#39;b&#39;, i.e., a/b; raises an error if &#39;b&#39; is not invertible in r exceptio...
Definition: coeffs.h:615
int rows() const
Definition: intvec.h:88
long(* pFDegProc)(poly p, ring r)
Definition: ring.h:46
intvec * hSecondSeries(intvec *hseries1)
Definition: hilb.cc:1307
#define jjWRONG2
Definition: iparith.cc:3663
ideal kMin_std(ideal F, ideal Q, tHomog h, intvec **w, ideal &M, intvec *hilb, int syzComp, int reduced)
Definition: kstd1.cc:2664
b *CanonicalForm B
Definition: facBivar.cc:51
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:6434
#define ABS(x)
Definition: auxiliary.h:157
int luRank(const matrix aMat, const bool isRowEchelon, const ring R)
Computes the rank of a given (m x n)-matrix.
static BOOLEAN jjPLUS_P_MA(leftv res, leftv u, leftv v)
Definition: iparith.cc:845
package basePack
Definition: ipid.cc:64
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 omUpdateInfo()
Definition: omStats.c:24
static BOOLEAN rField_is_Ring_Z(const ring r)
Definition: ring.h:434
static BOOLEAN jjCOUNT_RG(leftv res, leftv v)
Definition: iparith.cc:3871
static BOOLEAN jjUMINUS_IV(leftv res, leftv u)
Definition: iparith.cc:3735
void pNorm(poly p, const ring R=currRing)
Definition: polys.h:334
static BOOLEAN jjTIMES_IV(leftv res, leftv u, leftv v)
Definition: iparith.cc:1012
BOOLEAN iiConvert(int inputType, int outputType, int index, leftv input, leftv output, struct sConvertTypes *dConvertTypes)
Definition: ipconv.cc:358
#define hasFlag(A, F)
Definition: ipid.h:111
ideal idLiftStd(ideal h1, matrix *ma, tHomog hi, ideal *syz)
Definition: ideals.cc:748
static BOOLEAN jjMONITOR1(leftv res, leftv v)
Definition: iparith.cc:2749
static BOOLEAN jjMINUS_BIM(leftv res, leftv u, leftv v)
Definition: iparith.cc:905
static BOOLEAN jjQRDS(leftv res, leftv INPUT)
Definition: iparith.cc:7852
ideal fractalWalkProc(leftv first, leftv second)
Definition: walk_ip.cc:167
char * name
Definition: iparith.cc:153
#define pInit()
allocates a new monomial and initializes everything to 0
Definition: polys.h:61
#define IDRING(a)
Definition: ipid.h:126
static BOOLEAN jjPREIMAGE_R(leftv res, leftv v)
Definition: iparith.cc:4752
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:193
static BOOLEAN jjPLUS_BI(leftv res, leftv u, leftv v)
Definition: iparith.cc:787
ideal id_Head(ideal h, const ring r)
returns the ideals of initial terms
static BOOLEAN jjTIMES_MA_N2(leftv res, leftv u, leftv v)
Definition: iparith.cc:1078
Definition: tok.h:86
const CanonicalForm & w
Definition: facAbsFact.cc:55
#define pWTotaldegree(p)
Definition: polys.h:254
#define pDelete(p_ptr)
Definition: polys.h:157
package currPack
Definition: ipid.cc:63
static BOOLEAN jjNAMES_I(leftv res, leftv v)
Definition: iparith.cc:4653
static BOOLEAN jjEQUAL_P(leftv res, leftv u, leftv v)
Definition: iparith.cc:1346
proc3 p
Definition: iparith.cc:185
number singclap_det_bi(bigintmat *m, const coeffs cf)
Definition: clapsing.cc:1620
static BOOLEAN jjEXTGCD_BI(leftv res, leftv u, leftv v)
Definition: iparith.cc:2126
static BOOLEAN jjNAMEOF(leftv res, leftv v)
Definition: iparith.cc:4641
static BOOLEAN jjGT_BI(leftv res, leftv u, leftv v)
Definition: iparith.cc:1125
static BOOLEAN jjNVARS(leftv res, leftv v)
Definition: iparith.cc:4663
static BOOLEAN jjCOLCOL(leftv res, leftv u, leftv v)
Definition: iparith.cc:715
Variable x
Definition: cfModGcd.cc:4023
int rtyp
Definition: subexpr.h:92
BOOLEAN singclap_extgcd(poly f, poly g, poly &res, poly &pa, poly &pb, const ring r)
Definition: clapsing.cc:460
BOOLEAN mp_IsDiagUnit(matrix U, const ring R)
Definition: matpol.cc:721
#define nSize(n)
Definition: numbers.h:39
#define nCopy(n)
Definition: numbers.h:15
static SArithBase sArithBase
Base entry for arithmetic.
Definition: iparith.cc:219
int iiArithFindCmd(const char *szName)
Definition: iparith.cc:8986
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:604
static bool rIsSCA(const ring r)
Definition: nc.h:206
static BOOLEAN jjHOMOG_ID_W(leftv res, leftv u, leftv v, leftv)
Definition: iparith.cc:5933
static BOOLEAN jjUMINUS_BIM(leftv res, leftv u)
Definition: iparith.cc:3742
void CleanUp(ring r=currRing)
Definition: subexpr.cc:321
Definition: tok.h:81
static FORCE_INLINE number n_RePart(number i, const coeffs cf)
Definition: coeffs.h:808
int(* SModulFunc_t)(SModulFunctions *)
Definition: ipid.h:84
static BOOLEAN jjMONITOR2(leftv res, leftv u, leftv v)
Definition: iparith.cc:2753
static Subexpr jjMakeSub(leftv e)
Definition: iparith.cc:7953
void Clean(ring r=currRing)
Definition: lists.h:25
#define pNext(p)
Definition: monomials.h:43
static BOOLEAN jjLU_DECOMP(leftv res, leftv v)
Definition: iparith.cc:4535
static BOOLEAN jjFWALK3(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5855
void * Data()
Definition: subexpr.cc:1111
static BOOLEAN jjCOUNT_BI(leftv res, leftv v)
Definition: iparith.cc:3844
static BOOLEAN jjrParStr(leftv res, leftv v)
Definition: iparith.cc:5448
static BOOLEAN jjCOLS_BIM(leftv res, leftv v)
Definition: iparith.cc:3826
static FORCE_INLINE BOOLEAN n_Equal(number a, number b, const coeffs r)
TRUE iff &#39;a&#39; and &#39;b&#39; represent the same number; they may have different representations.
Definition: coeffs.h:461
static BOOLEAN jjLE_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:1146
ideal idrCopyR(ideal id, ring src_r, ring dest_r)
Definition: prCopy.cc:193
static BOOLEAN jjSYZYGY(leftv res, leftv v)
Definition: iparith.cc:5048
static BOOLEAN jjLIFTSTD3(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6545
void show(int mat=0, int spaces=0) const
Definition: intvec.cc:168
int typ
Definition: idrec.h:43
ideal idLift(ideal mod, ideal submod, ideal *rest, BOOLEAN goodShape, BOOLEAN isSB, BOOLEAN divide, matrix *unit)
Definition: ideals.cc:935
short list_length
Definition: syz.h:62
static BOOLEAN jjCHINREM_ID(leftv res, leftv u, leftv v)
Definition: iparith.cc:1771
Definition: tok.h:96
BOOLEAN mp_Equal(matrix a, matrix b, const ring R)
Definition: matpol.cc:579
static BOOLEAN jjDIFF_ID_ID(leftv res, leftv u, leftv v)
Definition: iparith.cc:2003
matrix mp_Copy(matrix a, const ring r)
copies matrix a (from ring r to r)
Definition: matpol.cc:75
static BOOLEAN jjDIFF_P(leftv res, leftv u, leftv v)
Definition: iparith.cc:1981
static BOOLEAN jjELIMIN_IV(leftv res, leftv u, leftv v)
Definition: iparith.cc:2100
ideal * resolvente
Definition: ideals.h:20
void newBuffer(char *s, feBufferTypes t, procinfo *pi, int lineno)
Definition: fevoices.cc:171
void SPrintStart()
Definition: reporter.cc:256
syStrategy syConvList(lists li, BOOLEAN toDel)
Definition: ipshell.cc:3119
void sm_CallBareiss(ideal I, int x, int y, ideal &M, intvec **iv, const ring R)
Definition: sparsmat.cc:404
static FORCE_INLINE number n_SubringGcd(number a, number b, const coeffs r)
Definition: coeffs.h:687
static BOOLEAN jjCALL1MANY(leftv res, leftv u)
Definition: iparith.cc:3812
const char * id
Definition: idrec.h:39
static BOOLEAN jjTIMES_P(leftv res, leftv u, leftv v)
Definition: iparith.cc:957
static BOOLEAN jjROWS_BIM(leftv res, leftv v)
Definition: iparith.cc:4863
attr attribute
Definition: subexpr.h:90
omBin slists_bin
Definition: lists.cc:23
static BOOLEAN jjLE_BI(leftv res, leftv u, leftv v)
Definition: iparith.cc:1142
ideal maGetPreimage(ring theImageRing, map theMap, ideal id, const ring dst_r)
Definition: preimage.cc:63
static BOOLEAN jjINDEX_IV(leftv res, leftv u, leftv v)
Definition: iparith.cc:1399
static BOOLEAN jjSBA_1(leftv res, leftv v, leftv u)
Definition: iparith.cc:4948
static BOOLEAN jjMINUS_IV(leftv res, leftv u, leftv v)
Definition: iparith.cc:895
static BOOLEAN jjPOWER_N(leftv res, leftv u, leftv v)
Definition: iparith.cc:607
cmdnames * sCmds
array of existing commands
Definition: iparith.cc:204
#define ii_div_by_0
Definition: iparith.cc:238
int idElem(const ideal F)
count non-zero elements
char libnamebuf[128]
Definition: libparse.cc:1096
#define pPower(p, q)
Definition: polys.h:175
static FORCE_INLINE BOOLEAN nCoeff_is_Extension(const coeffs r)
Definition: coeffs.h:844
static BOOLEAN jjMATRIX_Mo(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6494
LINLINE number nlInit(long i, const coeffs r)
Definition: longrat.cc:2357
static BOOLEAN jjidHead(leftv res, leftv v)
Definition: iparith.cc:5401
Definition: tok.h:126
void newstruct_setup(const char *n, newstruct_desc d)
Definition: newstruct.cc:692
static BOOLEAN jjOP_I_IM(leftv res, leftv u, leftv v)
Definition: iparith.cc:341
static BOOLEAN jjSort_Id(leftv res, leftv v)
Definition: iparith.cc:5026
static BOOLEAN jjJET_P_P(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5990
newstruct_desc newstructChildFromString(const char *parent, const char *s)
Definition: newstruct.cc:802
leftv iiMap(map theMap, const char *what)
Definition: ipshell.cc:622
int n_IsParam(const number m, const ring r)
TODO: rewrite somehow...
Definition: ring.cc:5642
static BOOLEAN jjPOWER_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:545
static BOOLEAN jjCOMPARE_IV_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:420
static BOOLEAN jjPLUSPLUS(leftv, leftv u)
Definition: iparith.cc:3693
ring rInit(sleftv *pn, sleftv *rv, sleftv *ord)
Definition: ipshell.cc:5461
BOOLEAN iiLoadLIB(FILE *fp, const char *libnamebuf, const char *newlib, idhdl pl, BOOLEAN autoexport, BOOLEAN tellerror)
Definition: iplib.cc:902
BOOLEAN iiExprArith3Tab(leftv res, leftv a, int op, struct sValCmd3 *dA3, int at, struct sConvertTypes *dConvertTypes)
apply an operation &#39;op&#39; to arguments a, a->next and a->next->next return TRUE on failure ...
Definition: iparith.cc:8594
#define pDiff(a, b)
Definition: polys.h:267
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
#define OPT_SB_1
Definition: options.h:90
char * rCharStr(const ring r)
TODO: make it a virtual method of coeffs, together with: Decompose & Compose, rParameter & rPar...
Definition: ring.cc:618
static BOOLEAN jjFACSTD2(leftv res, leftv v, leftv w)
Definition: iparith.cc:2233
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff &#39;n&#39; is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2), where m is the long representing n in C: TRUE iff (Im(n) != 0 and Im(n) >= 0) or (Im(n) == 0 and Re(n) >= 0) in K(a)/<p(a)>: TRUE iff (n != 0 and (LC(n) > 0 or deg(n) > 0)) in K(t_1, ..., t_n): TRUE iff (LC(numerator(n) is a constant and > 0) or (LC(numerator(n) is not a constant) in Z/2^kZ: TRUE iff 0 < n <= 2^(k-1) in Z/mZ: TRUE iff the internal mpz is greater than zero in Z: TRUE iff n > 0
Definition: coeffs.h:495
#define SI_PROT_O
Definition: reporter.h:51
const char * getBlackboxName(const int t)
return the name to the type given by t (r/o)
Definition: blackbox.cc:187
ideal singclap_factorize(poly f, intvec **v, int with_exps, const ring r)
Definition: clapsing.cc:784
ideal idAdd(ideal h1, ideal h2)
h1 + h2
Definition: ideals.h:81
#define pIsUnivariate(p)
Definition: polys.h:220
static BOOLEAN jjREDUCE4(leftv res, leftv u)
Definition: iparith.cc:7477
proc1 p
Definition: iparith.cc:195
static BOOLEAN jjUNIVARIATE(leftv res, leftv v)
Definition: iparith.cc:5195
#define MATROWS(i)
Definition: matpol.h:27
static BOOLEAN jjIDEAL_Ma(leftv res, leftv v)
Definition: iparith.cc:4311
static BOOLEAN jjSTATUS3(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6640
static BOOLEAN jjIDEAL_R(leftv res, leftv v)
Definition: iparith.cc:4339
intvec * hFirstSeries(ideal S, intvec *modulweight, ideal Q, intvec *wdegree, ring tailRing)
Definition: hilb.cc:1299
ideal id_Vec2Ideal(poly vec, const ring R)
matrix mp_Sub(matrix a, matrix b, const ring R)
Definition: matpol.cc:207
static BOOLEAN jjDEG(leftv res, leftv v)
Definition: iparith.cc:3884
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:963
kBucketDestroy & P
Definition: myNF.cc:191
int iiTokType(int op)
Definition: iparith.cc:255
void hLookSeries(ideal S, intvec *modulweight, ideal Q, intvec *wdegree, ring tailRing)
Definition: hilb.cc:1378
static BOOLEAN jjCOUNT_L(leftv res, leftv v)
Definition: iparith.cc:3854
static jList * T
Definition: janet.cc:37
polyrec * poly
Definition: hilb.h:10
static BOOLEAN jjMATRIX_Id(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6471
static int iin_Int(number &n, coeffs cf)
Definition: iparith.cc:243
#define IDDATA(a)
Definition: ipid.h:125
static BOOLEAN jjOR_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:1372
int Kstd1_deg
Definition: kutil.cc:228
static BOOLEAN jjMINUS_MA(leftv res, leftv u, leftv v)
Definition: iparith.cc:915
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
static BOOLEAN jjLU_SOLVE(leftv res, leftv v)
Definition: iparith.cc:7230
BOOLEAN rDecompose_CF(leftv res, const coeffs C)
Definition: ipshell.cc:1821
BOOLEAN(* proc1)(leftv, leftv)
Definition: ipshell.h:123
static BOOLEAN jjpMaxComp(leftv res, leftv v)
Definition: iparith.cc:5417
#define pISet(i)
Definition: polys.h:283
#define nInit(i)
Definition: numbers.h:24
char * iiConvName(const char *libname)
Definition: iplib.cc:1279
syStrategy syHilb(ideal arg, int *length)
Definition: syz2.cc:953
int iiOp
Definition: iparith.cc:240
unsigned si_opt_2
Definition: options.c:6
static BOOLEAN currRingIsOverIntegralDomain()
Definition: iparith.cc:6017
static BOOLEAN jjBRACK_Ma(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5558
static Poly * h
Definition: janet.cc:978
int BOOLEAN
Definition: auxiliary.h:131
static BOOLEAN jjPlural_num_poly(leftv res, leftv a, leftv b)
Definition: iparith.cc:2843
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:3963
ideal idSyzygies(ideal h1, tHomog h, intvec **w, BOOLEAN setSyzComp, BOOLEAN setRegularity, int *deg)
Definition: ideals.cc:557
static BOOLEAN jjNOT(leftv res, leftv v)
Definition: iparith.cc:4658
#define IMATELEM(M, I, J)
Definition: intvec.h:77
const poly b
Definition: syzextra.cc:213
BOOLEAN iiExprArith2(leftv res, leftv a, int op, leftv b, BOOLEAN proccall)
Definition: iparith.cc:8143
static BOOLEAN jjHOMOG_ID(leftv res, leftv u, leftv v)
Definition: iparith.cc:2525
#define omRealloc(addr, size)
Definition: omAllocDecl.h:225
poly p_Cleardenom(poly p, const ring r)
Definition: p_polys.cc:2682
#define NONE
Definition: tok.h:173
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
Definition: polys.h:31
static BOOLEAN jjRESERVEDNAME(leftv res, leftv v)
Definition: iparith.cc:4804
#define ppJetW(p, m, iv)
Definition: polys.h:340
#define SI_RESTORE_OPT1(A)
Definition: options.h:23
static BOOLEAN jjINDEPSET(leftv res, leftv v)
Definition: iparith.cc:4368
BOOLEAN load_modules(const char *newlib, char *fullname, BOOLEAN autoexport)
Definition: iplib.cc:1050
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:571
static BOOLEAN jjDET_I(leftv res, leftv v)
Definition: iparith.cc:3999
ideal id_Matrix2Module(matrix mat, const ring R)
static BOOLEAN jjTRANSP_BIM(leftv res, leftv v)
Definition: iparith.cc:5091
void nKillChar(coeffs r)
undo all initialisations
Definition: numbers.cc:488
static BOOLEAN jjOPPOSITE(leftv res, leftv a)
Definition: iparith.cc:5102
static BOOLEAN jjCONTRACT(leftv res, leftv u, leftv v)
Definition: iparith.cc:1951
static BOOLEAN jjHIGHCORNER(leftv res, leftv v)
Definition: iparith.cc:4170
proc1 p
Definition: iparith.cc:164
leftv LData()
Definition: subexpr.cc:1380
struct sValCmd3 * psValCmd3
Definition: iparith.cc:207
BOOLEAN idHomModule(ideal m, ideal Q, intvec **w)
Definition: ideals.h:108
char * rOrdStr(ring r)
Definition: ring.cc:522
void Werror(const char *fmt,...)
Definition: reporter.cc:199
static BOOLEAN jjAND_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:1367
#define nAdd(n1, n2)
Definition: numbers.h:18
syStrategy syLaScala3(ideal arg, int *length)
Definition: syz1.cc:2435
static BOOLEAN jjREAD(leftv res, leftv v)
Definition: iparith.cc:4827
int ivTrace(intvec *o)
Definition: intvec.cc:348
void * CopyD(int t)
Definition: subexpr.cc:676
static BOOLEAN jjCHAR(leftv res, leftv v)
Definition: iparith.cc:3816
const char * lastreserved
Definition: ipshell.cc:86
static BOOLEAN jjEQUAL_I(leftv res, leftv u, leftv v)
Definition: iparith.cc:1328
static BOOLEAN jjLEADMONOM(leftv res, leftv v)
Definition: iparith.cc:4499
int siRand()
Definition: sirandom.c:41
#define omAlloc0(size)
Definition: omAllocDecl.h:211
static BOOLEAN jjPLUS_ID(leftv res, leftv u, leftv v)
Definition: iparith.cc:859
idhdl h0
Definition: libparse.cc:1141
return result
Definition: facAbsBiFact.cc:76
int l
Definition: cfEzgcd.cc:94
static BOOLEAN jjSIMPL_ID(leftv res, leftv u, leftv v)
Definition: iparith.cc:3354
static BOOLEAN jjELIMIN_HILB(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5817
intvec * ivAdd(intvec *a, intvec *b)
Definition: intvec.cc:276
static BOOLEAN jjstrlen(leftv res, leftv v)
Definition: iparith.cc:5363
static BOOLEAN jjFETCH(leftv res, leftv u, leftv v)
Definition: iparith.cc:2274
ideal syMinBase(ideal arg)
Definition: syz.cc:1025
static BOOLEAN jjTWOSTD(leftv res, leftv a)
Definition: iparith.cc:5140
static BOOLEAN jjSTD_HILB_WP(leftv res, leftv INPUT)
Definition: iparith.cc:7869
static BOOLEAN jjDIFF_COEF(leftv res, leftv u, leftv v)
Definition: iparith.cc:4413
static BOOLEAN jjSTATUS2(leftv res, leftv u, leftv v)
Definition: iparith.cc:3434
static BOOLEAN jjORD(leftv res, leftv v)
Definition: iparith.cc:4674
long rank
Definition: matpol.h:20
static BOOLEAN jjFIND3(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5824
static BOOLEAN jjDIV_BI(leftv res, leftv u, leftv v)
Definition: iparith.cc:1191
BOOLEAN jjANY2LIST(leftv res, leftv v, int cnt)
Definition: iparith.cc:8615
static BOOLEAN jjCOLS_IV(leftv res, leftv v)
Definition: iparith.cc:3831
syStrategy syMinimize(syStrategy syzstr)
Definition: syz1.cc:2403
#define IDMATRIX(a)
Definition: ipid.h:133
#define nGreater(a, b)
Definition: numbers.h:28
#define pCopy(p)
return a copy of the poly
Definition: polys.h:156
#define COMMAND
Definition: tok.h:33
#define MATELEM(mat, i, j)
Definition: matpol.h:29
#define RING_MASK
Definition: iparith.cc:113
blackbox * getBlackboxStuff(const int t)
return the structure to the type given by t
Definition: blackbox.cc:20
#define V_IMAP
Definition: options.h:51
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:327
ssyStrategy * syStrategy
Definition: syz.h:35
#define idTest(id)
Definition: ideals.h:60
utypes data
Definition: idrec.h:40
static BOOLEAN jjCOMPARE_BIM(leftv res, leftv u, leftv v)
Definition: iparith.cc:392
#define SI_SAVE_OPT2(A)
Definition: options.h:21
int IsCmd(const char *n, int &tok)
Definition: iparith.cc:8739
static BOOLEAN jjHILBERT3(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5864
ListNode * next
Definition: janet.h:31
static BOOLEAN jjRANDOM_Im(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:6308
static BOOLEAN jjLT_N(leftv res, leftv u, leftv v)
Definition: iparith.cc:1164
static BOOLEAN jjidElem(leftv res, leftv v)
Definition: iparith.cc:5373
static BOOLEAN jjCOEFFS3_Id(leftv res, leftv u, leftv v, leftv w)
Definition: iparith.cc:5770
#define Warn
Definition: emacs.cc:80
ideal twostd(ideal I)
Compute two-sided GB:
Definition: nc.cc:22
#define omStrDup(s)
Definition: omAllocDecl.h:263
#define idIsConstant(I)
Definition: ideals.h:53