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