My Project
Loading...
Searching...
No Matches
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*/
8long all_farey=0L;
9long farey_cnt=0L;
10
11#include "kernel/mod2.h"
12
13#include "factory/factory.h"
14
15#include "coeffs/bigintmat.h"
16#include "coeffs/coeffs.h"
17#include "coeffs/numbers.h"
18
19#include "misc/options.h"
20#include "misc/intvec.h"
21#include "misc/sirandom.h"
22#include "misc/prime.h"
23
24#include "polys/matpol.h"
26#include "polys/sparsmat.h"
27#include "polys/weight.h"
29#include "polys/clapsing.h"
30#include "polys/flintconv.h"
31
34
38
40
44#include "kernel/fglm/fglm.h"
45
47#include "kernel/GBEngine/syz.h"
50#include "kernel/GBEngine/tgb.h"
51
52#include "kernel/preimage.h"
53#include "kernel/polys.h"
54#include "kernel/ideals.h"
55
56#include "Singular/mod_lib.h"
57#include "Singular/fevoices.h"
58#include "Singular/tok.h"
59#include "Singular/ipid.h"
60#include "Singular/sdb.h"
61#include "Singular/subexpr.h"
62#include "Singular/lists.h"
63#include "Singular/maps_ip.h"
64#include "Singular/feOpt.h"
65
66#include "Singular/ipconv.h"
67#include "Singular/ipprint.h"
68#include "Singular/attrib.h"
70#include "Singular/misc_ip.h"
72
73#include "Singular/number2.h"
74
75#include "Singular/fglm.h"
76
77#include "Singular/blackbox.h"
78#include "Singular/newstruct.h"
79#include "Singular/ipshell.h"
80//#include "kernel/mpr_inout.h"
81#include "reporter/si_signals.h"
82
83#include <ctype.h>
84
85// defaults for all commands: NO_NC | NO_RING | ALLOW_ZERODIVISOR
86
87#ifdef HAVE_PLURAL
89 #include "kernel/GBEngine/nc.h"
90 #include "polys/nc/nc.h"
91 #include "polys/nc/sca.h"
92 #define NC_MASK (3+64)
93#else /* HAVE_PLURAL */
94 #define NC_MASK 0
95#endif /* HAVE_PLURAL */
96
97#define RING_MASK 4
98#define ZERODIVISOR_MASK 8
99#define ALLOW_PLURAL 1
100#define NO_NC 0
101#define COMM_PLURAL 2
102#define ALLOW_RING 4
103#define NO_RING 0
104#define NO_ZERODIVISOR 8
105#define ALLOW_ZERODIVISOR 0
106#define ALLOW_LP 64
107#define NO_LRING 128
108#define ALLOW_NC ALLOW_LP|ALLOW_PLURAL
109
110#define ALLOW_ZZ (ALLOW_RING|NO_ZERODIVISOR)
111
112
113// bit 4 for warning, if used at toplevel
114#define WARN_RING 16
115// bit 5: do no try automatic conversions
116#define NO_CONVERSION 32
117
118static BOOLEAN check_valid(const int p, const int op);
119
120#define bit31 SIZEOF_LONG*8-1
121
122/*=============== types =====================*/
124{
125 short cmd;
126 short start;
127};
128
130
131struct _scmdnames
132{
133 char *name;
134 short alias;
135 short tokval;
136 short toktype;
137};
138typedef struct _scmdnames cmdnames;
139
140struct sValCmd1
141{
143 short cmd;
144 short res;
145 short arg;
146 short valid_for;
147};
148
150struct sValCmd2
151{
153 short cmd;
154 short res;
155 short arg1;
156 short arg2;
157 short valid_for;
158};
159
161struct sValCmd3
162{
164 short cmd;
165 short res;
166 short arg1;
167 short arg2;
168 short arg3;
169 short valid_for;
170};
171struct sValCmdM
172{
174 short cmd;
175 short res;
176 short number_of_args; /* -1: any, -2: any >0, .. */
177 short valid_for;
178};
179
180typedef struct
181{
182 cmdnames *sCmds; /**< array of existing commands */
187 unsigned nCmdUsed; /**< number of commands used */
188 unsigned nCmdAllocated; /**< number of commands-slots allocated */
189 unsigned nLastIdentifier; /**< valid identifiers are slot 1..nLastIdentifier */
190} SArithBase;
191
192/*---------------------------------------------------------------------*
193 * File scope Variables (Variables share by several functions in
194 * the same file )
195 *
196 *---------------------------------------------------------------------*/
197STATIC_VAR SArithBase sArithBase; /**< Base entry for arithmetic */
198
199/*---------------------------------------------------------------------*
200 * Extern Functions declarations
201 *
202 *---------------------------------------------------------------------*/
203static int _gentable_sort_cmds(const void *a, const void *b);
204extern int iiArithRemoveCmd(char *szName);
205extern int iiArithAddCmd(const char *szName, short nAlias, short nTokval,
206 short nToktype, short nPos=-1);
207
208/*============= proc =======================*/
209static int iiTabIndex(const jjValCmdTab dArithTab, const int len, const int op);
210static Subexpr jjMakeSub(leftv e);
211
212/*============= vars ======================*/
215
216#define ii_div_by_0 "div. by 0"
217
218VAR int iiOp; /* the current operation*/
219
220/*=================== simple helpers =================*/
221static int iin_Int(number &n,coeffs cf)
222{
223 long l=n_Int(n,cf);
224 int i=(int)l;
225 if ((long)i==l) return l;
226 return 0;
227}
228
229int iiTokType(int op)
230{
231 for (unsigned i=0;i<sArithBase.nCmdUsed;i++)
232 {
233 if (sArithBase.sCmds[i].tokval==op)
234 return sArithBase.sCmds[i].toktype;
235 }
236 return 0;
237}
238
239/*=================== operations with 2 args.: static proc =================*/
240/* must be ordered: first operations for chars (infix ops),
241 * then alphabetically */
242
244{
245 bigintmat* aa= (bigintmat *)u->Data();
246 long bb = (long)(v->Data());
247 if (errorreported) return TRUE;
248 bigintmat *cc=NULL;
249 switch (iiOp)
250 {
251 case '+': cc=bimAdd(aa,bb); break;
252 case '-': cc=bimSub(aa,bb); break;
253 case '*': cc=bimMult(aa,bb); break;
254 }
255 res->data=(char *)cc;
256 return cc==NULL;
257}
259{
260 return jjOP_BIM_I(res, v, u);
261}
263{
264 bigintmat* aa= (bigintmat *)u->Data();
265 number bb = (number)(v->Data());
266 if (errorreported) return TRUE;
267 bigintmat *cc=NULL;
268 switch (iiOp)
269 {
270 case '*': cc=bimMult(aa,bb,coeffs_BIGINT); break;
271 }
272 res->data=(char *)cc;
273 return cc==NULL;
274}
276{
277 return jjOP_BIM_BI(res, v, u);
278}
280{
281 intvec* aa= (intvec *)u->CopyD(INTVEC_CMD);
282 int bb = (int)(long)(v->Data());
283 if (errorreported) return TRUE;
284 switch (iiOp)
285 {
286 case '+': (*aa) += bb; break;
287 case '-': (*aa) -= bb; break;
288 case '*': (*aa) *= bb; break;
289 case '/':
290 case INTDIV_CMD: (*aa) /= bb; break;
291 case '%': (*aa) %= bb; break;
292 }
293 res->data=(char *)aa;
294 return FALSE;
295}
297{
298 return jjOP_IV_I(res,v,u);
299}
301{
302 intvec* aa= (intvec *)u->CopyD(INTVEC_CMD);
303 int bb = (int)(long)(v->Data());
304 int i=si_min(aa->rows(),aa->cols());
305 switch (iiOp)
306 {
307 case '+': for (;i>0;i--) IMATELEM(*aa,i,i) += bb;
308 break;
309 case '-': for (;i>0;i--) IMATELEM(*aa,i,i) -= bb;
310 break;
311 }
312 res->data=(char *)aa;
313 return FALSE;
314}
316{
317 return jjOP_IM_I(res,v,u);
318}
320{
321 int l=(int)(long)v->Data();
322 if (l>=0)
323 {
324 int d=(int)(long)u->Data();
325 intvec *vv=new intvec(l);
326 int i;
327 for(i=l-1;i>=0;i--) { (*vv)[i]=d; }
328 res->data=(char *)vv;
329 }
330 return (l<0);
331}
333{
334 res->data=(char *)new intvec((int)(long)u->Data(),(int)(long)v->Data());
335 return FALSE;
336}
337static void jjEQUAL_REST(leftv res,leftv u,leftv v);
339{
340 intvec* a = (intvec * )(u->Data());
341 intvec* b = (intvec * )(v->Data());
342 int r=a->compare(b);
343 switch (iiOp)
344 {
345 case '<':
346 res->data = (char *) (r<0);
347 break;
348 case '>':
349 res->data = (char *) (r>0);
350 break;
351 case LE:
352 res->data = (char *) (r<=0);
353 break;
354 case GE:
355 res->data = (char *) (r>=0);
356 break;
357 case EQUAL_EQUAL:
358 case NOTEQUAL: /* negation handled by jjEQUAL_REST */
359 res->data = (char *) (r==0);
360 break;
361 }
362 jjEQUAL_REST(res,u,v);
363 if(r==-2) { WerrorS("size incompatible"); return TRUE; }
364 return FALSE;
365}
367{
368 bigintmat* a = (bigintmat * )(u->Data());
369 bigintmat* b = (bigintmat * )(v->Data());
370 int r=a->compare(b);
371 switch (iiOp)
372 {
373 #if 0
374 case '<':
375 res->data = (char *) (r<0);
376 break;
377 case '>':
378 res->data = (char *) (r>0);
379 break;
380 case LE:
381 res->data = (char *) (r<=0);
382 break;
383 case GE:
384 res->data = (char *) (r>=0);
385 break;
386 #endif
387 case EQUAL_EQUAL:
388 case NOTEQUAL: /* negation handled by jjEQUAL_REST */
389 res->data = (char *) (r==0);
390 break;
391 }
392 jjEQUAL_REST(res,u,v);
393 if(r==-2) { WerrorS("size incompatible"); return TRUE; }
394 return FALSE;
395}
397{
398 intvec* a = (intvec * )(u->Data());
399 int b = (int)(long)(v->Data());
400 int r=a->compare(b);
401 switch (iiOp)
402 {
403 case '<':
404 res->data = (char *) (r<0);
405 break;
406 case '>':
407 res->data = (char *) (r>0);
408 break;
409 case LE:
410 res->data = (char *) (r<=0);
411 break;
412 case GE:
413 res->data = (char *) (r>=0);
414 break;
415 case EQUAL_EQUAL:
416 case NOTEQUAL: /* negation handled by jjEQUAL_REST */
417 res->data = (char *) (r==0);
418 break;
419 }
420 jjEQUAL_REST(res,u,v);
421 return FALSE;
422}
424{
425 //Print("in: >>%s<<\n",my_yylinebuf);
426 matrix a=(matrix)u->Data();
427 matrix b=(matrix)v->Data();
428 int r=mp_Compare(a,b,currRing);
429 switch (iiOp)
430 {
431 case '<':
432 res->data = (char *) (long)(r < 0);
433 break;
434 case '>':
435 res->data = (char *) (long)(r > 0);
436 break;
437 case LE:
438 res->data = (char *) (long)(r <= 0);
439 break;
440 case GE:
441 res->data = (char *) (long)(r >= 0);
442 break;
443 case EQUAL_EQUAL:
444 case NOTEQUAL: /* negation handled by jjEQUAL_REST */
445 res->data = (char *)(long) (r == 0);
446 break;
447 }
448 jjEQUAL_REST(res,u,v);
449 return FALSE;
450}
452{
453 poly p=(poly)u->Data();
454 poly q=(poly)v->Data();
455 int r=p_Compare(p,q,currRing);
456 switch (iiOp)
457 {
458 case '<':
459 res->data = (char *) (r < 0);
460 break;
461 case '>':
462 res->data = (char *) (r > 0);
463 break;
464 case LE:
465 res->data = (char *) (r <= 0);
466 break;
467 case GE:
468 res->data = (char *) (r >= 0);
469 break;
470 //case EQUAL_EQUAL:
471 //case NOTEQUAL: /* negation handled by jjEQUAL_REST */
472 // res->data = (char *) (r == 0);
473 // break;
474 }
475 jjEQUAL_REST(res,u,v);
476 return FALSE;
477}
479{
480 char* a = (char * )(u->Data());
481 char* b = (char * )(v->Data());
482 int result = strcmp(a,b);
483 switch (iiOp)
484 {
485 case '<':
486 res->data = (char *) (result < 0);
487 break;
488 case '>':
489 res->data = (char *) (result > 0);
490 break;
491 case LE:
492 res->data = (char *) (result <= 0);
493 break;
494 case GE:
495 res->data = (char *) (result >= 0);
496 break;
497 case EQUAL_EQUAL:
498 case NOTEQUAL: /* negation handled by jjEQUAL_REST */
499 res->data = (char *) (result == 0);
500 break;
501 }
502 jjEQUAL_REST(res,u,v);
503 return FALSE;
504}
506{
507 if (u->Next()!=NULL)
508 {
509 u=u->next;
510 res->next = (leftv)omAllocBin(sleftv_bin);
511 return iiExprArith2(res->next,u,iiOp,v);
512 }
513 else if (v->Next()!=NULL)
514 {
515 v=v->next;
516 res->next = (leftv)omAllocBin(sleftv_bin);
517 return iiExprArith2(res->next,u,iiOp,v);
518 }
519 return FALSE;
520}
522{
523 long b=(long)u->Data();
524 long e=(long)v->Data();
525 long rc = 1;
526 BOOLEAN overflow=FALSE;
527 if (e >= 0)
528 {
529 if (b==0)
530 {
531 rc=(e==0);
532 }
533 else if ((e==0)||(b==1))
534 {
535 rc= 1;
536 }
537 else if (b== -1)
538 {
539 if (e&1) rc= -1;
540 else rc= 1;
541 }
542 else
543 {
544 long oldrc;
545 while ((e--)!=0)
546 {
547 oldrc=rc;
548 rc *= b;
549 if (!overflow)
550 {
551 if(rc/b!=oldrc) overflow=TRUE;
552 }
553 }
554 if (overflow)
555 WarnS("int overflow(^), result may be wrong");
556 }
557 res->data = (char *)rc;
558 if (u!=NULL) return jjOP_REST(res,u,v);
559 return FALSE;
560 }
561 else
562 {
563 WerrorS("exponent must be non-negative");
564 return TRUE;
565 }
566}
568{
569 int e=(int)(long)v->Data();
570 number n=(number)u->Data();
571 if (e>=0)
572 {
573 n_Power(n,e,(number*)&res->data,coeffs_BIGINT);
574 }
575 else
576 {
577 WerrorS("exponent must be non-negative");
578 return TRUE;
579 }
580 if (u!=NULL) return jjOP_REST(res,u,v);
581 return FALSE;
582}
584{
585 int e=(int)(long)v->Data();
586 number n=(number)u->Data();
587 int d=0;
588 if (e<0)
589 {
590 n=nInvers(n);
591 e=-e;
592 d=1;
593 }
594 number r;
595 nPower(n,e,(number*)&r);
596 res->data=(char*)r;
597 if (d) nDelete(&n);
598 if (u!=NULL) return jjOP_REST(res,u,v);
599 return FALSE;
600}
602{
603 int v_i=(int)(long)v->Data();
604 if (v_i<0)
605 {
606 WerrorS("exponent must be non-negative");
607 return TRUE;
608 }
609 poly u_p=(poly)u->CopyD(POLY_CMD);
610 if ((u_p!=NULL)
611 && (!rIsLPRing(currRing))
612 && ((v_i!=0) &&
613 ((long)pTotaldegree(u_p) > (signed long)currRing->bitmask / (signed long)v_i/2)))
614 {
615 Werror("OVERFLOW in power(d=%ld, e=%d, max=%ld)",
616 pTotaldegree(u_p),v_i,currRing->bitmask/2);
617 pDelete(&u_p);
618 return TRUE;
619 }
620 res->data = (char *)pPower(u_p,v_i);
621 if (u!=NULL) return jjOP_REST(res,u,v);
622 return errorreported; /* pPower may set errorreported via Werror */
623}
625{
626 res->data = (char *)id_Power((ideal)(u->Data()),(int)(long)(v->Data()), currRing);
627 if (u!=NULL) return jjOP_REST(res,u,v);
628 return FALSE;
629}
631{
632 u=u->next;
633 v=v->next;
634 if (u==NULL)
635 {
636 if (v==NULL) return FALSE; /* u==NULL, v==NULL */
637 if (iiOp=='-') /* u==NULL, v<>NULL, iiOp=='-'*/
638 {
639 do
640 {
641 if (res->next==NULL)
643 leftv tmp_v=v->next;
644 v->next=NULL;
645 BOOLEAN b=iiExprArith1(res->next,v,'-');
646 v->next=tmp_v;
647 if (b)
648 return TRUE;
649 v=tmp_v;
650 res=res->next;
651 } while (v!=NULL);
652 return FALSE;
653 }
654 loop /* u==NULL, v<>NULL, iiOp=='+' */
655 {
657 res=res->next;
658 res->data = v->CopyD();
659 res->rtyp = v->Typ();
660 v=v->next;
661 if (v==NULL) return FALSE;
662 }
663 }
664 if (v!=NULL) /* u<>NULL, v<>NULL */
665 {
666 do
667 {
669 leftv tmp_u=u->next; u->next=NULL;
670 leftv tmp_v=v->next; v->next=NULL;
671 BOOLEAN b=iiExprArith2(res->next,u,iiOp,v);
672 u->next=tmp_u;
673 v->next=tmp_v;
674 if (b)
675 return TRUE;
676 u=tmp_u;
677 v=tmp_v;
678 res=res->next;
679 } while ((u!=NULL) && (v!=NULL));
680 return FALSE;
681 }
682 loop /* u<>NULL, v==NULL */
683 {
685 res=res->next;
686 res->data = u->CopyD();
687 res->rtyp = u->Typ();
688 u=u->next;
689 if (u==NULL) return FALSE;
690 }
691}
693{
694 switch(u->Typ())
695 {
696 case 0:
697 {
698 int name_err=0;
699 if(isupper(u->name[0]))
700 {
701 const char *c=u->name+1;
702 while((*c!='\0')&&(islower(*c)||(isdigit(*c))||(*c=='_'))) c++;
703 if (*c!='\0')
704 name_err=1;
705 else
706 {
707 Print("%s of type 'ANY'. Trying load.\n", u->name);
708 if(iiTryLoadLib(u, u->name))
709 {
710 Werror("'%s' no such package", u->name);
711 return TRUE;
712 }
713 syMake(u,u->name,NULL);
714 }
715 }
716 else name_err=1;
717 if(name_err)
718 { Werror("'%s' is an invalid package name",u->name);return TRUE;}
719 // and now, after the loading: use next case !!! no break !!!
720 }
721 case PACKAGE_CMD:
722 {
723 package pa=(package)u->Data();
724 if (u->rtyp==IDHDL) pa=IDPACKAGE((idhdl)u->data);
725 if((!pa->loaded)
726 && (pa->language > LANG_TOP))
727 {
728 Werror("'%s' not loaded", u->name);
729 return TRUE;
730 }
731 if(v->rtyp == IDHDL)
732 {
733 v->name = omStrDup(v->name);
734 }
735 else if (v->rtyp!=0)
736 {
737 WerrorS("reserved name with ::");
738 return TRUE;
739 }
740 v->req_packhdl=pa;
741 syMake(v, v->name, pa);
742 memcpy(res, v, sizeof(sleftv));
743 v->Init();
744 }
745 break;
746 case DEF_CMD:
747 break;
748 default:
749 WerrorS("<package>::<id> expected");
750 return TRUE;
751 }
752 return FALSE;
753}
755{
756 unsigned long a=(unsigned long)u->Data();
757 unsigned long b=(unsigned long)v->Data();
758 unsigned long c=a+b;
759 res->data = (char *)((long)c);
760 if (((Sy_bitL(bit31)&a)==(Sy_bitL(bit31)&b))&&((Sy_bitL(bit31)&a)!=(Sy_bitL(bit31)&c)))
761 {
762 WarnS("int overflow(+), result may be wrong");
763 }
764 return jjPLUSMINUS_Gen(res,u,v);
765}
767{
768 res->data = (char *)(n_Add((number)u->Data(), (number)v->Data(),coeffs_BIGINT));
769 return jjPLUSMINUS_Gen(res,u,v);
770}
772{
773 res->data = (char *)(nAdd((number)u->Data(), (number)v->Data()));
774 return jjPLUSMINUS_Gen(res,u,v);
775}
777{
778 res->data = (char *)(pAdd((poly)u->CopyD(POLY_CMD) , (poly)v->CopyD(POLY_CMD)));
779 return jjPLUSMINUS_Gen(res,u,v);
780}
782{
783 //res->data = (char *)(pAdd((poly)u->CopyD(POLY_CMD) , (poly)v->CopyD(POLY_CMD)));
785 poly p=(poly)u->CopyD(POLY_CMD);
786 int l=pLength(p);
788 p= (poly)v->CopyD(POLY_CMD);
789 l=pLength(p);
791 res->data=(void*)b;
792 return jjPLUSMINUS_Gen(res,u,v);
793}
795{
797 poly p= (poly)v->CopyD(POLY_CMD);
798 int l=pLength(p);
800 res->data=(void*)b;
801 return jjPLUSMINUS_Gen(res,u,v);
802}
804{
805 res->data = (char *)ivAdd((intvec*)(u->Data()), (intvec*)(v->Data()));
806 if (res->data==NULL)
807 {
808 WerrorS("intmat size not compatible");
809 return TRUE;
810 }
811 return jjPLUSMINUS_Gen(res,u,v);
812}
814{
815 res->data = (char *)bimAdd((bigintmat*)(u->Data()), (bigintmat*)(v->Data()));
816 if (res->data==NULL)
817 {
818 WerrorS("bigintmat/cmatrix not compatible");
819 return TRUE;
820 }
821 return jjPLUSMINUS_Gen(res,u,v);
822}
824{
825 matrix A=(matrix)u->Data(); matrix B=(matrix)v->Data();
826 res->data = (char *)(mp_Add(A , B, currRing));
827 if (res->data==NULL)
828 {
829 Werror("matrix size not compatible(%dx%d, %dx%d)",
831 return TRUE;
832 }
833 return jjPLUSMINUS_Gen(res,u,v);
834}
836{
837 ideal A=(ideal)u->Data(); ideal B=(ideal)v->Data();
838 res->data = (char *)(sm_Add(A , B, currRing));
839 if (res->data==NULL)
840 {
841 Werror("matrix size not compatible(%dx%d, %dx%d)",
842 (int)A->rank,IDELEMS(A),(int)B->rank,IDELEMS(B));
843 return TRUE;
844 }
845 return jjPLUSMINUS_Gen(res,u,v);
846}
848{
849 matrix m=(matrix)u->Data();
850 matrix p= mp_InitP(m->nrows,m->ncols,(poly)(v->CopyD(POLY_CMD)),currRing);
851 if (iiOp=='+')
852 res->data = (char *)mp_Add(m , p,currRing);
853 else
854 res->data = (char *)mp_Sub(m , p,currRing);
855 idDelete((ideal *)&p);
856 return jjPLUSMINUS_Gen(res,u,v);
857}
859{
860 return jjPLUS_MA_P(res,v,u);
861}
863{
864 char* a = (char * )(u->Data());
865 char* b = (char * )(v->Data());
866 char* r = (char * )omAlloc(strlen(a) + strlen(b) + 1);
867 strcpy(r,a);
868 strcat(r,b);
869 res->data=r;
870 return jjPLUSMINUS_Gen(res,u,v);
871}
873{
874 res->data = (char *)idAdd((ideal)u->Data(),(ideal)v->Data());
875 return jjPLUSMINUS_Gen(res,u,v);
876}
878{
879 void *ap=u->Data(); void *bp=v->Data();
880 long aa=(long)ap;
881 long bb=(long)bp;
882 long cc=aa-bb;
883 unsigned long a=(unsigned long)ap;
884 unsigned long b=(unsigned long)bp;
885 unsigned long c=a-b;
886 if (((Sy_bitL(bit31)&a)!=(Sy_bitL(bit31)&b))&&((Sy_bitL(bit31)&a)!=(Sy_bitL(bit31)&c)))
887 {
888 WarnS("int overflow(-), result may be wrong");
889 }
890 res->data = (char *)cc;
891 return jjPLUSMINUS_Gen(res,u,v);
892}
894{
895 res->data = (char *)(n_Sub((number)u->Data(), (number)v->Data(),coeffs_BIGINT));
896 return jjPLUSMINUS_Gen(res,u,v);
897}
899{
900 res->data = (char *)(nSub((number)u->Data(), (number)v->Data()));
901 return jjPLUSMINUS_Gen(res,u,v);
902}
904{
905 res->data = (char *)(pSub((poly)u->CopyD(POLY_CMD) , (poly)v->CopyD(POLY_CMD)));
906 return jjPLUSMINUS_Gen(res,u,v);
907}
909{
911 poly p= (poly)v->CopyD(POLY_CMD);
912 int l=pLength(p);
913 p=p_Neg(p,currRing);
915 res->data=(void*)b;
916 return jjPLUSMINUS_Gen(res,u,v);
917}
919{
921 poly p=(poly)u->CopyD(POLY_CMD);
922 int l=pLength(p);
924 p= (poly)v->CopyD(POLY_CMD);
925 p=p_Neg(p,currRing);
926 l=pLength(p);
928 res->data=(void*)b;
929 return jjPLUSMINUS_Gen(res,u,v);
930}
932{
933 res->data = (char *)ivSub((intvec*)(u->Data()), (intvec*)(v->Data()));
934 if (res->data==NULL)
935 {
936 WerrorS("intmat size not compatible");
937 return TRUE;
938 }
939 return jjPLUSMINUS_Gen(res,u,v);
940}
942{
943 res->data = (char *)bimSub((bigintmat*)(u->Data()), (bigintmat*)(v->Data()));
944 if (res->data==NULL)
945 {
946 WerrorS("bigintmat/cmatrix not compatible");
947 return TRUE;
948 }
949 return jjPLUSMINUS_Gen(res,u,v);
950}
952{
953 matrix A=(matrix)u->Data(); matrix B=(matrix)v->Data();
954 res->data = (char *)(mp_Sub(A , B, currRing));
955 if (res->data==NULL)
956 {
957 Werror("matrix size not compatible(%dx%d, %dx%d)",
959 return TRUE;
960 }
961 return jjPLUSMINUS_Gen(res,u,v);
962 return FALSE;
963}
965{
966 ideal A=(ideal)u->Data(); ideal B=(ideal)v->Data();
967 res->data = (char *)(sm_Sub(A , B, currRing));
968 if (res->data==NULL)
969 {
970 Werror("matrix size not compatible(%dx%d, %dx%d)",
971 (int)A->rank,IDELEMS(A),(int)B->rank,IDELEMS(B));
972 return TRUE;
973 }
974 return jjPLUSMINUS_Gen(res,u,v);
975 return FALSE;
976}
978{
979 long a=(long)u->Data();
980 long b=(long)v->Data();
981 long c=a * b;
982 if ((a!=0)&&(c/a!=b))
983 WarnS("int overflow(*), result may be wrong");
984 res->data = (char *)c;
985 if ((u->Next()!=NULL) || (v->Next()!=NULL))
986 return jjOP_REST(res,u,v);
987 return FALSE;
988}
990{
991 res->data = (char *)(n_Mult( (number)u->Data(), (number)v->Data(),coeffs_BIGINT));
992 if ((v->next!=NULL) || (u->next!=NULL))
993 return jjOP_REST(res,u,v);
994 return FALSE;
995}
997{
998 res->data = (char *)(nMult( (number)u->Data(), (number)v->Data()));
999 number n=(number)res->data;
1000 nNormalize(n);
1001 res->data=(char *)n;
1002 if ((v->next!=NULL) || (u->next!=NULL))
1003 return jjOP_REST(res,u,v);
1004 return FALSE;
1005}
1007{
1008 poly a;
1009 poly b;
1010 if (v->next==NULL)
1011 {
1012 if (u->next==NULL)
1013 {
1014 a=(poly)u->Data(); // works also for VECTOR_CMD
1015 b=(poly)v->Data(); // works also for VECTOR_CMD
1016 if (!rIsLPRing(currRing)
1017 && (a!=NULL) && (b!=NULL)
1018 && ((long)pTotaldegree(a)>si_max((long)rVar(currRing),(long)currRing->bitmask/2)-(long)pTotaldegree(b)))
1019 {
1020 Warn("possible OVERFLOW in mult(d=%ld, d=%ld, max=%ld)",
1021 pTotaldegree(a),pTotaldegree(b),currRing->bitmask/2);
1022 }
1023 res->data = (char *)(pp_Mult_qq( a, b, currRing));
1024 return FALSE;
1025 }
1026 // u->next exists: copy v
1027 a=(poly)u->CopyD(POLY_CMD); // works also for VECTOR_CMD
1028 b=pCopy((poly)v->Data());
1029 if (!rIsLPRing(currRing)
1030 && (a!=NULL) && (b!=NULL)
1031 && (pTotaldegree(a)+pTotaldegree(b)>si_max((long)rVar(currRing),(long)currRing->bitmask/2)))
1032 {
1033 Warn("possible OVERFLOW in mult(d=%ld, d=%ld, max=%ld)",
1034 pTotaldegree(a),pTotaldegree(b),currRing->bitmask/2);
1035 }
1036 res->data = (char *)(pMult( a, b));
1037 return jjOP_REST(res,u,v);
1038 }
1039 // v->next exists: copy u
1040 a=pCopy((poly)u->Data());
1041 b=(poly)v->CopyD(POLY_CMD); // works also for VECTOR_CMD
1042 if ((a!=NULL) && (b!=NULL)
1043 && ((unsigned long)(pTotaldegree(a)+pTotaldegree(b))>=currRing->bitmask/2))
1044 {
1045 pDelete(&a);
1046 pDelete(&b);
1047 WerrorS("OVERFLOW");
1048 return TRUE;
1049 }
1050 res->data = (char *)(pMult( a, b));
1051 return jjOP_REST(res,u,v);
1052}
1054{
1055 res->data = (char *)idMult((ideal)u->Data(),(ideal)v->Data());
1056 if ((v->next!=NULL) || (u->next!=NULL))
1057 return jjOP_REST(res,u,v);
1058 return FALSE;
1059}
1061{
1062 res->data = (char *)ivMult((intvec*)(u->Data()), (intvec*)(v->Data()));
1063 if (res->data==NULL)
1064 {
1065 WerrorS("intmat size not compatible");
1066 return TRUE;
1067 }
1068 if ((v->next!=NULL) || (u->next!=NULL))
1069 return jjOP_REST(res,u,v);
1070 return FALSE;
1071}
1073{
1074 res->data = (char *)bimMult((bigintmat*)(u->Data()), (bigintmat*)(v->Data()));
1075 if (res->data==NULL)
1076 {
1077 WerrorS("bigintmat/cmatrix not compatible");
1078 return TRUE;
1079 }
1080 if ((v->next!=NULL) || (u->next!=NULL))
1081 return jjOP_REST(res,u,v);
1082 return FALSE;
1083}
1085{
1087 if (nMap==NULL) return TRUE;
1088 number n=nMap((number)v->Data(),coeffs_BIGINT,currRing->cf);
1089 poly p=pNSet(n);
1090 ideal I= (ideal)mp_MultP((matrix)u->CopyD(MATRIX_CMD),p,currRing);
1091 res->data = (char *)I;
1092 return FALSE;
1093}
1095{
1096 return jjTIMES_MA_BI1(res,v,u);
1097}
1099{
1100 poly p=(poly)v->CopyD(POLY_CMD);
1101 int r=pMaxComp(p);/* recompute the rank for the case ideal*vector*/
1102 ideal I= (ideal)mp_MultP((matrix)u->CopyD(MATRIX_CMD),p,currRing);
1103 if (r>0) I->rank=r;
1104 res->data = (char *)I;
1105 return FALSE;
1106}
1108{
1109 poly p=(poly)u->CopyD(POLY_CMD);
1110 int r=pMaxComp(p);/* recompute the rank for the case ideal*vector*/
1111 ideal I= (ideal)pMultMp(p,(matrix)v->CopyD(MATRIX_CMD),currRing);
1112 if (r>0) I->rank=r;
1113 res->data = (char *)I;
1114 return FALSE;
1115}
1117{
1118 number n=(number)v->CopyD(NUMBER_CMD);
1119 poly p=pNSet(n);
1120 res->data = (char *)mp_MultP((matrix)u->CopyD(MATRIX_CMD),p,currRing);
1121 return FALSE;
1122}
1124{
1125 return jjTIMES_MA_N1(res,v,u);
1126}
1128{
1129 res->data = (char *)mp_MultI((matrix)u->CopyD(MATRIX_CMD),(long)v->Data(),currRing);
1130 return FALSE;
1131}
1133{
1134 return jjTIMES_MA_I1(res,v,u);
1135}
1137{
1138 matrix A=(matrix)u->Data(); matrix B=(matrix)v->Data();
1139 res->data = (char *)mp_Mult(A,B,currRing);
1140 if (res->data==NULL)
1141 {
1142 Werror("matrix size not compatible(%dx%d, %dx%d) in *",
1144 return TRUE;
1145 }
1146 if ((v->next!=NULL) || (u->next!=NULL))
1147 return jjOP_REST(res,u,v);
1148 return FALSE;
1149}
1151{
1152 ideal A=(ideal)u->Data(); ideal B=(ideal)v->Data();
1153 res->data = (char *)sm_Mult(A,B,currRing);
1154 if (res->data==NULL)
1155 {
1156 Werror("matrix size not compatible(%dx%d, %dx%d) in *",
1157 (int)A->rank,IDELEMS(A),(int)B->rank,IDELEMS(B));
1158 return TRUE;
1159 }
1160 if ((v->next!=NULL) || (u->next!=NULL))
1161 return jjOP_REST(res,u,v);
1162 return FALSE;
1163}
1165{
1166 number h=n_Sub((number)u->Data(),(number)v->Data(),coeffs_BIGINT);
1167 res->data = (char *) (n_GreaterZero(h,coeffs_BIGINT)||(n_IsZero(h,coeffs_BIGINT)));
1169 return FALSE;
1170}
1172{
1173 res->data = (char *)(long)((int)((long)u->Data()) >= (int)((long)v->Data()));
1174 return FALSE;
1175}
1177{
1178 res->data = (char *)(long) (nGreater((number)u->Data(),(number)v->Data())
1179 || nEqual((number)u->Data(),(number)v->Data()));
1180 return FALSE;
1181}
1183{
1184 number h=n_Sub((number)u->Data(),(number)v->Data(),coeffs_BIGINT);
1185 res->data = (char *)(long) (n_GreaterZero(h,coeffs_BIGINT)&&(!n_IsZero(h,coeffs_BIGINT)));
1187 return FALSE;
1188}
1190{
1191 res->data = (char *)(long)((int)((long)u->Data()) > (int)((long)v->Data()));
1192 return FALSE;
1193}
1195{
1196 res->data = (char *)(long)(nGreater((number)u->Data(),(number)v->Data()));
1197 return FALSE;
1198}
1200{
1201 return jjGE_BI(res,v,u);
1202}
1204{
1205 res->data = (char *)(long)((int)((long)u->Data()) <= (int)((long)v->Data()));
1206 return FALSE;
1207}
1209{
1210 return jjGE_N(res,v,u);
1211}
1213{
1214 return jjGT_BI(res,v,u);
1215}
1217{
1218 res->data = (char *)(long)((int)((long)u->Data()) < (int)((long)v->Data()));
1219 return FALSE;
1220}
1222{
1223 return jjGT_N(res,v,u);
1224}
1226{
1227 if (iiOp=='/') Warn("int division with `/`: use `div` instead in line >>%s<<",my_yylinebuf);
1228 long a= (long)u->Data();
1229 long b= (long)v->Data();
1230 if (b==0)
1231 {
1233 return TRUE;
1234 }
1235 long c=a%b;
1236 long r=0;
1237 switch (iiOp)
1238 {
1239 case '%':
1240 r=c; break;
1241 case '/':
1242 case INTDIV_CMD:
1243 r=((a-c) /b); break;
1244 }
1245 res->data=(void *)r;
1246 return FALSE;
1247}
1249{
1250 number q=(number)v->Data();
1251 if (n_IsZero(q,coeffs_BIGINT))
1252 {
1254 return TRUE;
1255 }
1256 q = n_Div((number)u->Data(),q,coeffs_BIGINT);
1258 res->data = (char *)q;
1259 return FALSE;
1260}
1262{
1263 number q=(number)v->Data();
1264 if (nIsZero(q))
1265 {
1267 return TRUE;
1268 }
1269 q = nDiv((number)u->Data(),q);
1270 nNormalize(q);
1271 res->data = (char *)q;
1272 return FALSE;
1273}
1275{
1276 poly q=(poly)v->Data();
1277 poly p=(poly)(u->Data());
1278 if (q!=NULL)
1279 {
1280 res->data=(void*)(pp_Divide(p /*(poly)(u->Data())*/ ,
1281 q /*(poly)(v->Data())*/ ,currRing));
1282 if (res->data!=NULL) pNormalize((poly)res->data);
1283 return errorreported; /*there may be errors in p_Divide: div. ny 0, etc.*/
1284 }
1285 else
1286 {
1287 WerrorS("div. by 0");
1288 return TRUE;
1289 }
1290
1291}
1293{
1294 poly q=(poly)v->Data();
1295 if (q==NULL)
1296 {
1298 return TRUE;
1299 }
1300 matrix m=(matrix)(u->Data());
1301 int r=m->rows();
1302 int c=m->cols();
1303 matrix mm=mpNew(r,c);
1304 unsigned i,j;
1305 for(i=r;i>0;i--)
1306 {
1307 for(j=c;j>0;j--)
1308 {
1309 if (pNext(q)!=NULL)
1310 {
1312 q /*(poly)(v->Data())*/, currRing );
1313 }
1314 else
1315 MATELEM(mm,i,j) = pp_DivideM(MATELEM(m,i,j),q,currRing);
1316 }
1317 }
1318 res->data=(char *)mm;
1319 return FALSE;
1320}
1322{
1323 res->data = (char *)((long)n_Equal((number)u->Data(),(number)v->Data(),coeffs_BIGINT));
1324 jjEQUAL_REST(res,u,v);
1325 return FALSE;
1326}
1328{
1329 res->data = (char *)((int)((long)u->Data()) == (int)((long)v->Data()));
1330 jjEQUAL_REST(res,u,v);
1331 return FALSE;
1332}
1334{
1335 res->data = (char *)((long)mp_Equal((matrix)u->Data(),(matrix)v->Data(),currRing));
1336 jjEQUAL_REST(res,u,v);
1337 return FALSE;
1338}
1340{
1341 res->data = (char *)((long)sm_Equal((ideal)u->Data(),(ideal)v->Data(),currRing));
1342 jjEQUAL_REST(res,u,v);
1343 return FALSE;
1344}
1346{
1347 res->data = (char *)(long)(u->Data()==v->Data());
1348 jjEQUAL_REST(res,u,v);
1349 return FALSE;
1350}
1352{
1353 res->data = (char *)((long)nEqual((number)u->Data(),(number)v->Data()));
1354 jjEQUAL_REST(res,u,v);
1355 return FALSE;
1356}
1358{
1359 poly p=(poly)u->Data();
1360 poly q=(poly)v->Data();
1361 res->data = (char *) ((long)pEqualPolys(p,q));
1362 jjEQUAL_REST(res,u,v);
1363 return FALSE;
1364}
1366{
1367 if ((res->data) && (u->next!=NULL) && (v->next!=NULL))
1368 {
1369 int save_iiOp=iiOp;
1370 if (iiOp==NOTEQUAL)
1371 iiExprArith2(res,u->next,EQUAL_EQUAL,v->next);
1372 else
1373 iiExprArith2(res,u->next,iiOp,v->next);
1374 iiOp=save_iiOp;
1375 }
1376 if (iiOp==NOTEQUAL) res->data=(char *)(!(long)res->data);
1377}
1379{
1380 res->data = (char *)((long)u->Data() && (long)v->Data());
1381 return FALSE;
1382}
1384{
1385 res->data = (char *)((long)u->Data() || (long)v->Data());
1386 return FALSE;
1387}
1389{
1390 res->rtyp=u->rtyp; u->rtyp=0;
1391 res->data=u->data; u->data=NULL;
1392 res->name=u->name; u->name=NULL;
1393 res->e=u->e; u->e=NULL;
1394 if (res->e==NULL) res->e=jjMakeSub(v);
1395 else
1396 {
1397 Subexpr sh=res->e;
1398 while (sh->next != NULL) sh=sh->next;
1399 sh->next=jjMakeSub(v);
1400 }
1401 if (u->next!=NULL)
1402 {
1404 BOOLEAN bo=iiExprArith2(rn,u->next,iiOp,v);
1405 res->next=rn;
1406 return bo;
1407 }
1408 return FALSE;
1409}
1411{
1412 if ((u->rtyp!=IDHDL)||(u->e!=NULL))
1413 {
1414 WerrorS("indexed object must have a name");
1415 return TRUE;
1416 }
1417 intvec * iv=(intvec *)v->Data();
1418 leftv p=NULL;
1419 int i;
1420 sleftv t;
1421 t.Init();
1422 t.rtyp=INT_CMD;
1423 for (i=0;i<iv->length(); i++)
1424 {
1425 t.data=(char *)((long)(*iv)[i]);
1426 if (p==NULL)
1427 {
1428 p=res;
1429 }
1430 else
1431 {
1432 p->next=(leftv)omAlloc0Bin(sleftv_bin);
1433 p=p->next;
1434 }
1435 p->rtyp=IDHDL;
1436 p->data=u->data;
1437 p->name=u->name;
1438 p->flag=u->flag;
1439 p->e=jjMakeSub(&t);
1440 }
1441 u->rtyp=0;
1442 u->data=NULL;
1443 u->name=NULL;
1444 return FALSE;
1445}
1447{
1448 poly p=(poly)u->Data();
1449 long i=(long)v->Data();
1450 long j=0;
1451 while (p!=NULL)
1452 {
1453 j++;
1454 if (j==i)
1455 {
1456 res->data=(char *)pHead(p);
1457 return FALSE;
1458 }
1459 pIter(p);
1460 }
1461 return FALSE;
1462}
1464{
1467 int l; poly p,pp;
1468 sBucketDestroyAdd(b, &pp, &l);
1469 long i=(long)v->Data();
1470 long j=0;
1471 p=pp;
1472 while (p!=NULL)
1473 {
1474 j++;
1475 if (j==i)
1476 {
1477 res->data=(char *)pHead(p);
1479 return FALSE;
1480 }
1481 pIter(p);
1482 }
1484 return FALSE;
1485}
1487{
1488 poly p=(poly)u->Data();
1489 poly r=NULL;
1490 intvec *iv=(intvec *)v->CopyD(INTVEC_CMD);
1491 int i;
1492 int sum=0;
1493 for(i=iv->length()-1;i>=0;i--)
1494 sum+=(*iv)[i];
1495 int j=0;
1496 while ((p!=NULL) && (sum>0))
1497 {
1498 j++;
1499 for(i=iv->length()-1;i>=0;i--)
1500 {
1501 if (j==(*iv)[i])
1502 {
1503 r=pAdd(r,pHead(p));
1504 sum-=j;
1505 (*iv)[i]=0;
1506 break;
1507 }
1508 }
1509 pIter(p);
1510 }
1511 delete iv;
1512 res->data=(char *)r;
1513 return FALSE;
1514}
1516{
1517 poly p=(poly)u->Data();
1518 int i=(int)(long)v->Data();
1519 res->data=(char *)p_Vec2Poly(p,i,currRing);
1520 return FALSE;
1521}
1523{
1524 poly p=(poly)u->CopyD(VECTOR_CMD);
1525 if (p!=NULL)
1526 {
1527 poly r=pOne();
1528 poly hp=r;
1529 intvec *iv=(intvec *)v->Data();
1530 int i;
1531 loop
1532 {
1533 for(i=0;i<iv->length();i++)
1534 {
1535 if (((int)pGetComp(p))==(*iv)[i])
1536 {
1537 poly h;
1538 pSplit(p,&h);
1539 pNext(hp)=p;
1540 p=h;
1541 pIter(hp);
1542 break;
1543 }
1544 }
1545 if (p==NULL) break;
1546 if (i==iv->length())
1547 {
1548 pLmDelete(&p);
1549 if (p==NULL) break;
1550 }
1551 }
1552 pLmDelete(&r);
1553 res->data=(char *)r;
1554 }
1555 return FALSE;
1556}
1559{
1560 if(u->name==NULL) return TRUE;
1561 long slen = strlen(u->name) + 14;
1562 char *nn = (char*) omAlloc(slen);
1563 snprintf(nn,slen,"%s(%d)",u->name,(int)(long)v->Data());
1564 char *n=omStrDup(nn);
1565 omFreeSize((ADDRESS)nn,slen);
1566 syMake(res,n);
1567 if (u->next!=NULL) return jjKLAMMER_rest(res,u->next,v);
1568 return FALSE;
1569}
1571{
1572 if(u->name==NULL) return TRUE;
1573 intvec * iv=(intvec *)v->Data();
1574 leftv p=NULL;
1575 int i;
1576 long slen = strlen(u->name) + 14;
1577 char *n = (char*) omAlloc(slen);
1578
1579 for (i=0;i<iv->length(); i++)
1580 {
1581 if (p==NULL)
1582 {
1583 p=res;
1584 }
1585 else
1586 {
1587 p->next=(leftv)omAlloc0Bin(sleftv_bin);
1588 p=p->next;
1589 }
1590 snprintf(n,slen,"%s(%d)",u->name,(*iv)[i]);
1591 syMake(p,omStrDup(n));
1592 }
1593 omFreeSize(n, slen);
1594 if (u->next!=NULL) return jjKLAMMER_rest(res,u->next,v);
1595 return FALSE;
1596}
1598{
1600 BOOLEAN b;
1601 if (v->Typ()==INTVEC_CMD)
1602 b=jjKLAMMER_IV(tmp,u,v);
1603 else
1604 b=jjKLAMMER(tmp,u,v);
1605 if (b)
1606 {
1607 omFreeBin(tmp,sleftv_bin);
1608 return TRUE;
1609 }
1610 leftv h=res;
1611 while (h->next!=NULL) h=h->next;
1612 h->next=tmp;
1613 return FALSE;
1614}
1616{
1617 void *d;
1618 Subexpr e;
1619 int typ;
1620 BOOLEAN t=FALSE;
1621 idhdl tmp_proc=NULL;
1622 if ((u->rtyp!=IDHDL)||(u->e!=NULL))
1623 {
1624 tmp_proc=(idhdl)omAlloc0(sizeof(idrec));
1625 tmp_proc->id="_auto";
1626 tmp_proc->typ=PROC_CMD;
1627 tmp_proc->data.pinf=(procinfo *)u->Data();
1628 tmp_proc->ref=1;
1629 d=u->data; u->data=(void *)tmp_proc;
1630 e=u->e; u->e=NULL;
1631 t=TRUE;
1632 typ=u->rtyp; u->rtyp=IDHDL;
1633 }
1634 BOOLEAN sl;
1635 if (u->req_packhdl==currPack)
1636 sl = iiMake_proc((idhdl)u->data,NULL,v);
1637 else
1638 sl = iiMake_proc((idhdl)u->data,u->req_packhdl,v);
1639 if (t)
1640 {
1641 u->rtyp=typ;
1642 u->data=d;
1643 u->e=e;
1644 omFreeSize(tmp_proc,sizeof(idrec));
1645 }
1646 if (sl) return TRUE;
1647 memcpy(res,&iiRETURNEXPR,sizeof(sleftv));
1648 iiRETURNEXPR.Init();
1649 return FALSE;
1650}
1652{
1653 //Print("try to map %s with %s\n",$3.Name(),$1.Name());
1654 if ((v->e==NULL)&&(v->name!=NULL)&&(v->next==NULL))
1655 {
1656 map m=(map)u->Data();
1657 leftv sl=iiMap(m,v->name);
1658 if (sl!=NULL)
1659 {
1660 memcpy(res,sl,sizeof(sleftv));
1662 return FALSE;
1663 }
1664 }
1665 else
1666 {
1667 Werror("%s(<name>) expected",u->Name());
1668 }
1669 return TRUE; /*sl==NULL or Werror*/
1670}
1672{
1673 u->next=(leftv)omAlloc(sizeof(sleftv));
1674 memcpy(u->next,v,sizeof(sleftv));
1675 v->Init();
1676 BOOLEAN bo=iiExprArithM(res,u,'[');
1677 u->next=NULL;
1678 return bo;
1679}
1681{
1682 intvec *c=(intvec*)u->Data();
1683 intvec* p=(intvec*)v->Data();
1684 int rl=p->length();
1685 number *x=(number *)omAlloc(rl*sizeof(number));
1686 number *q=(number *)omAlloc(rl*sizeof(number));
1687 int i;
1688 for(i=rl-1;i>=0;i--)
1689 {
1690 q[i]=n_Init((*p)[i], coeffs_BIGINT);
1691 x[i]=n_Init((*c)[i], coeffs_BIGINT);
1692 }
1693 CFArray iv(rl);
1694 number n=n_ChineseRemainderSym(x,q,rl,FALSE,iv,coeffs_BIGINT);
1695 for(i=rl-1;i>=0;i--)
1696 {
1697 n_Delete(&(q[i]),coeffs_BIGINT);
1699 }
1700 omFree(x); omFree(q);
1701 res->data=(char *)n;
1702 return FALSE;
1703}
1704#if 0
1705static BOOLEAN jjCHINREM_P(leftv res, leftv u, leftv v)
1706{
1707 lists c=(lists)u->CopyD(); // list of poly
1708 intvec* p=(intvec*)v->Data();
1709 int rl=p->length();
1710 poly r=NULL,h, result=NULL;
1711 number *x=(number *)omAlloc(rl*sizeof(number));
1712 number *q=(number *)omAlloc(rl*sizeof(number));
1713 int i;
1714 for(i=rl-1;i>=0;i--)
1715 {
1716 q[i]=nlInit((*p)[i]);
1717 }
1718 loop
1719 {
1720 for(i=rl-1;i>=0;i--)
1721 {
1722 if (c->m[i].Typ()!=POLY_CMD)
1723 {
1724 Werror("poly expected at pos %d",i+1);
1725 for(i=rl-1;i>=0;i--)
1726 {
1727 nlDelete(&(q[i]),currRing);
1728 }
1729 omFree(x); omFree(q); // delete c
1730 return TRUE;
1731 }
1732 h=((poly)c->m[i].Data());
1733 if (r==NULL) r=h;
1734 else if (pLmCmp(r,h)==-1) r=h;
1735 }
1736 if (r==NULL) break;
1737 for(i=rl-1;i>=0;i--)
1738 {
1739 h=((poly)c->m[i].Data());
1740 if (pLmCmp(r,h)==0)
1741 {
1742 x[i]=pGetCoeff(h);
1744 c->m[i].data=(char*)h;
1745 }
1746 else
1747 x[i]=nlInit(0);
1748 }
1749 number n=n_ChineseRemainder(x,q,rl,currRing->cf);
1750 for(i=rl-1;i>=0;i--)
1751 {
1752 nlDelete(&(x[i]),currRing);
1753 }
1754 h=pHead(r);
1755 pSetCoeff(h,n);
1757 }
1758 for(i=rl-1;i>=0;i--)
1759 {
1760 nlDelete(&(q[i]),currRing);
1761 }
1762 omFree(x); omFree(q);
1763 res->data=(char *)result;
1764 return FALSE;
1765}
1766#endif
1768{
1769 poly p=(poly)u->CopyD();
1770 long s=(long)v->Data();
1771 if (s+p_MinComp(p,currRing)<=0)
1772 { p_Delete(&p,currRing);return TRUE;}
1773 p_Shift(&p,s,currRing);
1774 res->data=p;
1775 return FALSE;
1776}
1778{
1779 ideal M=(ideal)u->CopyD();
1780 int s=(int)(long)v->Data();
1781 for(int i=IDELEMS(M)-1; i>=0;i--)
1782 {
1783 if (s+p_MinComp(M->m[i],currRing)<=0)
1784 { id_Delete(&M,currRing);return TRUE;}
1785 }
1787 res->data=M;
1788 return FALSE;
1789}
1792{
1793 poly p=(poly)v->Data();
1794 if ((p==NULL)||(pNext(p)!=NULL)) return TRUE;
1795 res->data=(char *)mp_CoeffProc((poly)u->Data(),p /*(poly)v->Data()*/,currRing);
1796 return FALSE;
1797}
1799{
1800 poly p=(poly)v->Data();
1801 if ((p==NULL)||(pNext(p)!=NULL)) return TRUE;
1802 res->data=(char *)mp_CoeffProcId((ideal)u->Data(),p /*(poly)v->Data()*/,currRing);
1803 return FALSE;
1804}
1806{
1807 int i=pVar((poly)v->Data());
1808 if (i==0)
1809 {
1810 WerrorS("ringvar expected");
1811 return TRUE;
1812 }
1813 res->data=(char *)mp_Coeffs((ideal)u->CopyD(),i,currRing);
1814 return FALSE;
1815}
1817{
1818 poly p = pInit();
1819 int i;
1820 for (i=1; i<=currRing->N; i++)
1821 {
1822 pSetExp(p, i, 1);
1823 }
1824 pSetm(p);
1825 res->data = (void*)idCoeffOfKBase((ideal)(u->Data()),
1826 (ideal)(v->Data()), p);
1827 pLmFree(&p);
1828 return FALSE;
1829}
1831{
1832 res->data=(char *)idDiffOp((ideal)u->Data(),(ideal)v->Data(),FALSE);
1833 return FALSE;
1834}
1836{
1837 int *iv=iv2array((intvec *)v->Data(),currRing);
1838 ideal I=(ideal)u->Data();
1839 int d=-1;
1840 int i;
1841 for(i=IDELEMS(I);i>=0;i--) d=si_max(d,(int)p_DegW(I->m[i],iv,currRing));
1842 omFreeSize( (ADDRESS)iv, (rVar(currRing)+1)*sizeof(int) );
1843 res->data = (char *)((long)d);
1844 return FALSE;
1845}
1847{
1848 poly p=(poly)u->Data();
1849 if (p!=NULL)
1850 {
1851 int *iv=iv2array((intvec *)v->Data(),currRing);
1852 const long d = p_DegW(p,iv,currRing);
1853 omFreeSize( (ADDRESS)iv, (rVar(currRing)+1)*sizeof(int) );
1854 res->data = (char *)(d);
1855 }
1856 else
1857 res->data=(char *)(long)(-1);
1858 return FALSE;
1859}
1861{
1862 int pos=(int)(long)v->Data();
1863 intvec *iv=(intvec*)u->Data();
1864 res->data=(void*)iv->delete_pos(pos-1);
1865 return res->data==NULL;
1866}
1868{
1869 int pos=(int)(long)v->Data();
1870 ideal I=(ideal)u->Data();
1871 res->data=(void*)id_Delete_Pos(I,pos-1,currRing);
1872 return res->data==NULL;
1873}
1875{
1876 intvec *iv=(intvec*)v->Data();
1877 ideal I=(ideal)u->Data();
1878 ideal tmp1=NULL;
1879 ideal tmp2;
1880 for(int i=iv->length()-1;i>=0;i--)
1881 {
1882 int pos= (*iv)[i];
1883 tmp2=id_Delete_Pos(I,pos-1,currRing);
1884 if (tmp1==NULL) /* first entry */
1885 { tmp1=I; }
1886 else
1887 { id_Delete(&I,currRing); }
1888 I=tmp2;
1889 if (I==NULL) break;
1890 }
1891 res->data=(void*)I;
1892 return res->data==NULL;
1893}
1895{
1896 matrix m=(matrix)u->Data();
1897 DetVariant d=mp_GetAlgorithmDet((char*)v->Data());
1898 res ->data = mp_Det(m,currRing,d);
1899 return FALSE;
1900}
1902{
1903 DetVariant d=mp_GetAlgorithmDet((char*)v->Data());
1904 ideal m=(ideal)u->Data();
1905 res ->data = sm_Det(m,currRing,d);
1906 return FALSE;
1907}
1909{
1910 int i=pVar((poly)v->Data());
1911 if (i==0)
1912 {
1913 WerrorS("ringvar expected");
1914 return TRUE;
1915 }
1916 res->data=(char *)pDiff((poly)(u->Data()),i);
1917 return FALSE;
1918}
1920{
1921 int i=pVar((poly)v->Data());
1922 if (i==0)
1923 {
1924 WerrorS("ringvar expected");
1925 return TRUE;
1926 }
1927 res->data=(char *)idDiff((matrix)(u->Data()),i);
1928 return FALSE;
1929}
1931{
1932 res->data=(char *)idDiffOp((ideal)u->Data(),(ideal)v->Data());
1933 return FALSE;
1934}
1936{
1939 {
1940 Warn("dim(%s,...) may be wrong because the mixed monomial ordering",v->Name());
1941 }
1942 if(currRing->qideal==NULL)
1943 res->data = (char *)((long)scDimIntRing((ideal)(v->Data()),(ideal)w->Data()));
1944 else
1945 {
1946 ideal q=idSimpleAdd(currRing->qideal,(ideal)w->Data());
1947 res->data = (char *)((long)scDimIntRing((ideal)(v->Data()),q));
1948 idDelete(&q);
1949 }
1950 return FALSE;
1951}
1953{
1954 ideal vi=(ideal)v->Data();
1955 int vl= IDELEMS(vi);
1956 ideal ui=(ideal)u->Data();
1957 unsigned ul= IDELEMS(ui);
1958 ideal R; matrix U;
1959 ideal m = idLift(vi,ui,&R, FALSE,hasFlag(v,FLAG_STD),TRUE,&U);
1960 if (m==NULL) return TRUE;
1961 // now make sure that all matrices have the correct size:
1963 assume (MATCOLS(U) == (int)ul);
1965 L->Init(3);
1966 L->m[0].rtyp=MATRIX_CMD; L->m[0].data=(void *)T;
1967 L->m[1].rtyp=u->Typ(); L->m[1].data=(void *)R;
1968 L->m[2].rtyp=MATRIX_CMD; L->m[2].data=(void *)U;
1969 res->data=(char *)L;
1970 return FALSE;
1971}
1973{
1974 res->data=(char *)idElimination((ideal)u->Data(),(poly)v->Data());
1975 //setFlag(res,FLAG_STD);
1976 return v->next!=NULL; //do not allow next like in eliminate(I,a(1..4))
1977}
1979{
1980 poly p=pOne();
1981 intvec *iv=(intvec*)v->Data();
1982 for(int i=iv->length()-1; i>=0; i--)
1983 {
1984 pSetExp(p,(*iv)[i],1);
1985 }
1986 pSetm(p);
1987 res->data=(char *)idElimination((ideal)u->Data(),p);
1988 pLmDelete(&p);
1989 //setFlag(res,FLAG_STD);
1990 return FALSE;
1991}
1993{
1994 //Print("exportto %s -> %s\n",v->Name(),u->Name() );
1995 return iiExport(v,0,IDPACKAGE((idhdl)u->data));
1996}
1998{
1999 WerrorS((char *)u->Data());
2000 EXTERN_VAR int inerror;
2001 inerror=3;
2002 return TRUE;
2003}
2005{
2006 number uu=(number)u->Data();number vv=(number)v->Data();
2008 number a,b;
2009 number p0=n_ExtGcd(uu,vv,&a,&b,coeffs_BIGINT);
2010 L->Init(3);
2011 L->m[0].rtyp=BIGINT_CMD; L->m[0].data=(void *)p0;
2012 L->m[1].rtyp=BIGINT_CMD; L->m[1].data=(void *)a;
2013 L->m[2].rtyp=BIGINT_CMD; L->m[2].data=(void *)b;
2014 res->rtyp=LIST_CMD;
2015 res->data=(char *)L;
2016 return FALSE;
2017}
2019{
2020 int uu=(int)(long)u->Data();int vv=(int)(long)v->Data();
2021 int p0=ABS(uu),p1=ABS(vv);
2022 int f0 = 1, f1 = 0, g0 = 0, g1 = 1, q, r;
2023
2024 while ( p1!=0 )
2025 {
2026 q=p0 / p1;
2027 r=p0 % p1;
2028 p0 = p1; p1 = r;
2029 r = g0 - g1 * q;
2030 g0 = g1; g1 = r;
2031 r = f0 - f1 * q;
2032 f0 = f1; f1 = r;
2033 }
2034 int a = f0;
2035 int b = g0;
2036 if ( uu /*(int)(long)u->Data()*/ < 0 ) a=-a;
2037 if ( vv /*(int)(long)v->Data()*/ < 0 ) b=-b;
2039 L->Init(3);
2040 L->m[0].rtyp=INT_CMD; L->m[0].data=(void *)(long)p0;
2041 L->m[1].rtyp=INT_CMD; L->m[1].data=(void *)(long)a;
2042 L->m[2].rtyp=INT_CMD; L->m[2].data=(void *)(long)b;
2043 res->data=(char *)L;
2044 return FALSE;
2045}
2047{
2048 poly r,pa,pb;
2049 BOOLEAN ret=singclap_extgcd((poly)u->Data(),(poly)v->Data(),r,pa,pb,currRing);
2050 if (ret) return TRUE;
2052 L->Init(3);
2053 res->data=(char *)L;
2054 L->m[0].data=(void *)r;
2055 L->m[0].rtyp=POLY_CMD;
2056 L->m[1].data=(void *)pa;
2057 L->m[1].rtyp=POLY_CMD;
2058 L->m[2].data=(void *)pb;
2059 L->m[2].rtyp=POLY_CMD;
2060 return FALSE;
2061}
2064{
2065 intvec *v=NULL;
2066 int sw=(int)(long)dummy->Data();
2067 int fac_sw=sw;
2068 if ((sw<0)||(sw>2)) fac_sw=1;
2070 ideal f=singclap_factorize((poly)(u->CopyD()), &v, fac_sw,currRing);
2071 if (f==NULL)
2072 return TRUE;
2073 switch(sw)
2074 {
2075 case 0:
2076 case 2:
2077 {
2079 l->Init(2);
2080 l->m[0].rtyp=IDEAL_CMD;
2081 l->m[0].data=(void *)f;
2082 l->m[1].rtyp=INTVEC_CMD;
2083 l->m[1].data=(void *)v;
2084 res->data=(void *)l;
2085 res->rtyp=LIST_CMD;
2086 return FALSE;
2087 }
2088 case 1:
2089 res->data=(void *)f;
2090 return FALSE;
2091 case 3:
2092 {
2093 poly p=f->m[0];
2094 int i=IDELEMS(f);
2095 f->m[0]=NULL;
2096 while(i>1)
2097 {
2098 i--;
2099 p=pMult(p,f->m[i]);
2100 f->m[i]=NULL;
2101 }
2102 res->data=(void *)p;
2103 res->rtyp=POLY_CMD;
2104 }
2105 return FALSE;
2106 }
2107 WerrorS("invalid switch");
2108 return TRUE;
2109}
2111{
2112 ideal_list p,h;
2113 h=kStdfac((ideal)v->Data(),NULL,testHomog,NULL,(ideal)w->Data());
2114 p=h;
2115 int l=0;
2116 while (p!=NULL) { p=p->next;l++; }
2118 L->Init(l);
2119 l=0;
2120 while(h!=NULL)
2121 {
2122 L->m[l].data=(char *)h->d;
2123 L->m[l].rtyp=IDEAL_CMD;
2124 p=h->next;
2125 omFreeSize(h,sizeof(*h));
2126 h=p;
2127 l++;
2128 }
2129 res->data=(void *)L;
2130 return FALSE;
2131}
2133{
2134 if (rField_is_Q(currRing))
2135 {
2136 number uu=(number)u->Data();
2137 number vv=(number)v->Data();
2138 res->data=(char *)n_Farey(uu,vv,currRing->cf);
2139 return FALSE;
2140 }
2141 else return TRUE;
2142}
2144{
2145 ideal uu=(ideal)u->Data();
2146 number vv=(number)v->Data();
2147 //timespec buf1,buf2;
2148 //clock_gettime(CLOCK_THREAD_CPUTIME_ID,&buf1);
2149 #if 1
2150 #ifdef HAVE_VSPACE
2151 int cpus = (long) feOptValue(FE_OPT_CPUS);
2152 if ((cpus>1) && (rField_is_Q(currRing)))
2153 res->data=(void*)id_Farey_0(uu,vv,currRing);
2154 else
2155 #endif
2156 #endif
2157 res->data=(void*)id_Farey(uu,vv,currRing);
2158 //clock_gettime(CLOCK_THREAD_CPUTIME_ID,&buf2);
2159 //const unsigned long SEC = 1000L*1000L*1000L;
2160 //all_farey+=((buf2.tv_sec-buf1.tv_sec)*SEC+
2161 // buf2.tv_nsec-buf1.tv_nsec);
2162 //farey_cnt++;
2163 return FALSE;
2164}
2165static BOOLEAN jjFAREY_LI(leftv res, leftv u, leftv v);
2167{
2168 ring r=(ring)u->Data();
2169 idhdl w;
2170 int op=iiOp;
2171 nMapFunc nMap;
2172
2173 if ((w=r->idroot->get(v->Name(),myynest))!=NULL)
2174 {
2175 int *perm=NULL;
2176 int *par_perm=NULL;
2177 int par_perm_size=0;
2178 BOOLEAN bo;
2179 nMap=n_SetMap(r->cf,currRing->cf);
2180 if (nMap==NULL)
2181 {
2182 // Allow imap/fetch to be make an exception only for:
2183 if (nCoeff_is_Extension(r->cf) && // Q(a..) -> Q(a..) || Q || Zp || Zp(a)
2184 ((n_SetMap(r->cf->extRing->cf,currRing->cf)!=NULL)
2185 || (nCoeff_is_Extension(currRing->cf) && (n_SetMap(r->cf->extRing->cf,currRing->cf->extRing->cf)!=NULL))))
2186 {
2187 par_perm_size=rPar(r);
2188 }
2189 else
2190 {
2191 goto err_fetch;
2192 }
2193 }
2194 if (
2195 (iiOp!=FETCH_CMD) || (r->N!=currRing->N) || (rPar(r)!=rPar(currRing))
2196#ifdef HAVE_SHIFTBBA
2198#endif
2199 )
2200 {
2201 perm=(int *)omAlloc0((r->N+1)*sizeof(int));
2202 if (par_perm_size!=0)
2203 par_perm=(int *)omAlloc0(par_perm_size*sizeof(int));
2204 op=IMAP_CMD;
2205 if (iiOp==IMAP_CMD)
2206 {
2207 int r_par=0;
2208 char ** r_par_names=NULL;
2209 if (r->cf->extRing!=NULL)
2210 {
2211 r_par=r->cf->extRing->N;
2212 r_par_names=r->cf->extRing->names;
2213 }
2214 int c_par=0;
2215 char ** c_par_names=NULL;
2216 if (currRing->cf->extRing!=NULL)
2217 {
2218 c_par=currRing->cf->extRing->N;
2219 c_par_names=currRing->cf->extRing->names;
2220 }
2221 if (!rIsLPRing(r))
2222 {
2223 maFindPerm(r->names, r->N, r_par_names, r_par,
2224 currRing->names,currRing->N,c_par_names, c_par,
2225 perm,par_perm, currRing->cf->type);
2226 }
2227 #ifdef HAVE_SHIFTBBA
2228 else
2229 {
2230 maFindPermLP(r->names, r->N, r_par_names, r_par,
2231 currRing->names,currRing->N,c_par_names, c_par,
2232 perm,par_perm, currRing->cf->type,r->isLPring);
2233 }
2234 #endif
2235 }
2236 else
2237 {
2238#ifdef HAVE_SHIFTBBA
2239 if (rIsLPRing(currRing))
2240 {
2241 maFetchPermLP(r, currRing, perm);
2242 }
2243 else
2244#endif
2245 {
2246 unsigned i;
2247 if (par_perm_size!=0)
2248 for(i=si_min(rPar(r),rPar(currRing));i>0;i--) par_perm[i-1]=-i;
2249 for(i=si_min(r->N,currRing->N);i>0;i--) perm[i]=i;
2250 }
2251 }
2252 }
2253 if ((iiOp==FETCH_CMD) && (BVERBOSE(V_IMAP)))
2254 {
2255 unsigned i;
2256 for(i=0;i<(unsigned)si_min(r->N,currRing->N);i++)
2257 {
2258 Print("// var nr %d: %s -> %s\n",i,r->names[i],currRing->names[i]);
2259 }
2260 for(i=0;i<(unsigned)si_min(rPar(r),rPar(currRing));i++) // possibly empty loop
2261 {
2262 Print("// par nr %d: %s -> %s\n",
2264 }
2265 }
2266 if (IDTYP(w)==ALIAS_CMD) w=(idhdl)IDDATA(w);
2267 sleftv tmpW;
2268 tmpW.Init();
2269 tmpW.rtyp=IDTYP(w);
2270 tmpW.data=IDDATA(w);
2271 if ((bo=maApplyFetch(op,NULL,res,&tmpW, r,
2272 perm,par_perm,par_perm_size,nMap)))
2273 {
2274 Werror("cannot map %s of type %s(%d)",v->name, Tok2Cmdname(w->typ),w->typ);
2275 }
2276 if (perm!=NULL)
2277 omFreeSize((ADDRESS)perm,(r->N+1)*sizeof(int));
2278 if (par_perm!=NULL)
2279 omFreeSize((ADDRESS)par_perm,par_perm_size*sizeof(int));
2280 return bo;
2281 }
2282 else
2283 {
2284 Werror("identifier %s not found in %s",v->Fullname(),u->Fullname());
2285 }
2286 return TRUE;
2287err_fetch:
2288 char *s1=nCoeffString(r->cf);
2289 char *s2=nCoeffString(currRing->cf);
2290 Werror("no identity map from %s (%s -> %s)",u->Fullname(),s1,s2);
2291 omFree(s2); omFree(s1);
2292 return TRUE;
2293}
2295{
2296 /*4
2297 * look for the substring what in the string where
2298 * return the position of the first char of what in where
2299 * or 0
2300 */
2301 char *where=(char *)u->Data();
2302 char *what=(char *)v->Data();
2303 char *found = strstr(where,what);
2304 if (found != NULL)
2305 {
2306 res->data=(char *)((found-where)+1);
2307 }
2308 /*else res->data=NULL;*/
2309 return FALSE;
2310}
2311
2313{
2314 assumeStdFlag(u);
2315 ideal id = (ideal)u->Data();
2316 int max_length = (int)(long)v->Data();
2317 if (max_length < 0)
2318 {
2319 WerrorS("length for fres must not be negative");
2320 return TRUE;
2321 }
2322 if (max_length == 0)
2323 {
2324 max_length = currRing->N+1;
2325 if (currRing->qideal != NULL)
2326 {
2327 Warn("full resolution in a qring may be infinite, "
2328 "setting max length to %d", max_length);
2329 }
2330 }
2331 char *method = (char *)w->Data();
2332 /* For the moment, only "complete" (default), "frame", or "extended frame"
2333 * are allowed. Another useful option would be "linear strand".
2334 */
2335 if (strcmp(method, "complete") != 0
2336 && strcmp(method, "frame") != 0
2337 && strcmp(method, "extended frame") != 0
2338 && strcmp(method, "single module") != 0)
2339 {
2340 WerrorS("wrong optional argument for fres");
2341 return TRUE;
2342 }
2343 syStrategy r = syFrank(id, max_length, method);
2344 assume(r->fullres != NULL);
2345 res->data = (void *)r;
2346 return FALSE;
2347}
2348
2350{
2352 w->rtyp = STRING_CMD;
2353 w->data = (char *)"complete"; // default
2354 BOOLEAN RES = jjFRES3(res, u, v, w);
2356 return RES;
2357}
2358
2360{
2361 res->data=(char *)fractalWalkProc(u,v);
2362 setFlag( res, FLAG_STD );
2363 return FALSE;
2364}
2366{
2367 int uu=(int)(long)u->Data();int vv=(int)(long)v->Data();
2368 int p0=ABS(uu),p1=ABS(vv);
2369 int r;
2370 while ( p1!=0 )
2371 {
2372 r=p0 % p1;
2373 p0 = p1; p1 = r;
2374 }
2375 res->data=(char *)(long)p0;
2376 return FALSE;
2377}
2379{
2380 number n1 = (number) u->Data();
2381 number n2 = (number) v->Data();
2382 res->data = n_Gcd(n1,n2,coeffs_BIGINT);
2383 return FALSE;
2384}
2386{
2387 number a=(number) u->Data();
2388 number b=(number) v->Data();
2389 if (nIsZero(a))
2390 {
2391 if (nIsZero(b)) res->data=(char *)nInit(1);
2392 else res->data=(char *)nCopy(b);
2393 }
2394 else
2395 {
2396 if (nIsZero(b)) res->data=(char *)nCopy(a);
2397 //else res->data=(char *)n_Gcd(a, b, currRing->cf);
2398 else res->data=(char *)n_SubringGcd(a, b, currRing->cf);
2399 }
2400 return FALSE;
2401}
2403{
2404 res->data=(void *)singclap_gcd((poly)(u->CopyD(POLY_CMD)),
2405 (poly)(v->CopyD(POLY_CMD)),currRing);
2406 return FALSE;
2407}
2409{
2410 if (rField_is_Z(currRing))
2411 {
2412 PrintS("// NOTE: computation of Hilbert series etc. is being\n");
2413 PrintS("// performed for generic fibre, that is, over Q\n");
2414 }
2415 assumeStdFlag(u);
2416 intvec *module_w=(intvec*)atGet(u,"isHomog",INTVEC_CMD);
2417#if 1
2418 switch((int)(long)v->Data())
2419 {
2420 case 1:
2421 res->data=(void *)hFirstSeries0b((ideal)u->Data(),currRing->qideal,NULL,module_w,currRing,coeffs_BIGINT);
2422 return FALSE;
2423 case 2:
2424 res->data=(void *)hSecondSeries0b((ideal)u->Data(),currRing->qideal,NULL,module_w,currRing,coeffs_BIGINT);
2425 return FALSE;
2426 }
2427#else
2428 intvec *iv=hFirstSeries((ideal)u->Data(),module_w,currRing->qideal);
2429 if (errorreported) return TRUE;
2430
2431 switch((int)(long)v->Data())
2432 {
2433 case 1:
2434 res->data=(void *)iv;
2435 return FALSE;
2436 case 2:
2437 res->data=(void *)hSecondSeries(iv);
2438 delete iv;
2439 return FALSE;
2440 }
2441 delete iv;
2442#endif
2444 return TRUE;
2445}
2447{
2448 int i=pVar((poly)v->Data());
2449 if (i==0)
2450 {
2451 WerrorS("ringvar expected");
2452 return TRUE;
2453 }
2454 poly p=pOne(); pSetExp(p,i,1); pSetm(p);
2455 int d=pWTotaldegree(p);
2456 pLmDelete(p);
2457 if (d==1)
2458 res->data = (char *)p_Homogen((poly)u->Data(), i, currRing);
2459 else
2460 WerrorS("variable must have weight 1");
2461 return (d!=1);
2462}
2464{
2465 int i=pVar((poly)v->Data());
2466 if (i==0)
2467 {
2468 WerrorS("ringvar expected");
2469 return TRUE;
2470 }
2471 pFDegProc deg;
2472 if (currRing->pLexOrder && (currRing->order[0]==ringorder_lp))
2473 deg=p_Totaldegree;
2474 else
2475 deg=currRing->pFDeg;
2476 poly p=pOne(); pSetExp(p,i,1); pSetm(p);
2477 int d=deg(p,currRing);
2478 pLmDelete(p);
2479 if (d==1)
2480 res->data = (char *)id_Homogen((ideal)u->Data(), i, currRing);
2481 else
2482 WerrorS("variable must have weight 1");
2483 return (d!=1);
2484}
2486{
2487 intvec *w=new intvec(rVar(currRing));
2488 intvec *vw=(intvec*)u->Data();
2489 ideal v_id=(ideal)v->Data();
2490 pFDegProc save_FDeg=currRing->pFDeg;
2491 pLDegProc save_LDeg=currRing->pLDeg;
2492 BOOLEAN save_pLexOrder=currRing->pLexOrder;
2493 currRing->pLexOrder=FALSE;
2494 kHomW=vw;
2495 kModW=w;
2497 res->data=(void *)(long)idHomModule(v_id,currRing->qideal,&w);
2498 currRing->pLexOrder=save_pLexOrder;
2499 kHomW=NULL;
2500 kModW=NULL;
2501 pRestoreDegProcs(currRing,save_FDeg,save_LDeg);
2502 if (w!=NULL) delete w;
2503 return FALSE;
2504}
2506{
2507 intvec *vw=(intvec*)u->Data();
2508 ideal v_id=(ideal)v->Data();
2509 res->data=(void *)(long)id_HomIdealW(v_id,currRing->qideal,vw,currRing);
2510 return FALSE;
2511}
2513{
2514 assumeStdFlag(u);
2515 res->data=(void *)scIndIndset((ideal)(u->Data()),(int)(long)(v->Data()),
2516 currRing->qideal);
2517 return FALSE;
2518}
2520{
2521 res->data=(char *)idSect((ideal)u->Data(),(ideal)v->Data());
2523 return FALSE;
2524}
2526{
2527 const lists L = (lists)l->Data();
2528 const int n = L->nr; assume (n >= 0);
2529 std::vector<ideal> V(n + 1);
2530
2531 for(int i = n; i >= 0; i--) V[i] = (ideal)(L->m[i].Data());
2532
2533 res->data=interpolation(V, (intvec*)v->Data());
2535 return errorreported;
2536}
2538{
2539 extern BOOLEAN jjStdJanetBasis(leftv res, leftv v,int flag);
2540 return jjStdJanetBasis(res,u,(int)(long)v->Data());
2541}
2542
2544{
2545 extern BOOLEAN jjStdJanetBasis(leftv res, leftv v,int flag);
2546 return jjStdJanetBasis(res,v,0);
2547}
2549{
2550 res->data = (char *)pJet((poly)u->CopyD(), (int)(long)v->Data());
2551 return FALSE;
2552}
2554{
2555 res->data = (char *)id_Jet((ideal)u->Data(),(int)(long)v->Data(),currRing);
2556 return FALSE;
2557}
2559{
2560 assumeStdFlag(u);
2561 intvec *w_u=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
2562 res->data = (char *)scKBase((int)(long)v->Data(),
2563 (ideal)(u->Data()),currRing->qideal, w_u);
2564 if (w_u!=NULL)
2565 {
2566 atSet(res,omStrDup("isHomog"),ivCopy(w_u),INTVEC_CMD);
2567 }
2568 return FALSE;
2569}
2572{
2573 return jjPREIMAGE(res,u,v,NULL);
2574}
2576{
2577 return mpKoszul(res, u,v,NULL);
2578}
2580{
2581 sleftv h;
2582 h.Init();
2583 h.rtyp=INT_CMD;
2584 h.data=(void *)(long)IDELEMS((ideal)v->Data());
2585 return mpKoszul(res, u, &h, v);
2586}
2588{
2589 int ul= IDELEMS((ideal)u->Data());
2590 int vl= IDELEMS((ideal)v->Data());
2591#ifdef HAVE_SHIFTBBA
2592 if (rIsLPRing(currRing))
2593 {
2594 if (currRing->LPncGenCount < ul)
2595 {
2596 Werror("At least %d ncgen variables are needed for this computation.", ul);
2597 return TRUE;
2598 }
2599 }
2600#endif
2601 ideal m = idLift((ideal)u->Data(),(ideal)v->Data(),NULL,FALSE,
2602 hasFlag(u,FLAG_STD));
2603 if (m==NULL) return TRUE;
2604 res->data = (char *)id_Module2formatedMatrix(m,ul,vl,currRing);
2605 return FALSE;
2606}
2608{
2609 if ((v->rtyp!=IDHDL)||(v->e!=NULL)) return TRUE;
2610 idhdl h=(idhdl)v->data;
2611#ifdef HAVE_SHIFTBBA
2612 if (rIsLPRing(currRing))
2613 {
2614 if (currRing->LPncGenCount < IDELEMS((ideal)u->Data()))
2615 {
2616 Werror("At least %d ncgen variables are needed for this computation.", IDELEMS((ideal)u->Data()));
2617 return TRUE;
2618 }
2619 }
2620#endif
2621 // CopyD for IDEAL_CMD and MODUL_CMD are identical:
2622 res->data = (char *)idLiftStd((ideal)u->Data(),
2623 &(h->data.umatrix),testHomog);
2624 setFlag(res,FLAG_STD); v->flag=0;
2625 return FALSE;
2626}
2627static BOOLEAN jjLOAD2(leftv /*res*/, leftv/* LIB */ , leftv v)
2628{
2629 return jjLOAD((char*)v->Data(),TRUE);
2630}
2631static BOOLEAN jjLOAD_E(leftv /*res*/, leftv v, leftv u)
2632{
2633 char * s=(char *)u->Data();
2634 if(strcmp(s, "with")==0)
2635 return jjLOAD((char*)v->Data(), TRUE);
2636 if (strcmp(s,"try")==0)
2637 return jjLOAD_TRY((char*)v->Data());
2638 WerrorS("invalid second argument");
2639 WerrorS("load(\"libname\" [,option]);");
2640 return TRUE;
2641}
2643{
2644 intvec *w_u=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
2645 tHomog hom=testHomog;
2646 if (w_u!=NULL)
2647 {
2648 //PrintS("modulo: wu:");w_u->show(INTVEC_CMD);PrintLn();
2649 w_u=ivCopy(w_u);
2650 hom=isHomog;
2651 }
2652 //else PrintS("modulo: wu:none\n");
2653 intvec *w_v=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
2654 if (w_v!=NULL)
2655 {
2656 //PrintS("modulo: wv:");w_v->show(INTVEC_CMD);PrintLn();
2657 w_v=ivCopy(w_v);
2658 hom=isHomog;
2659 }
2660 //else PrintS("modulo: wv:none\n");
2661 if ((w_u!=NULL) && (w_v==NULL))
2662 w_v=ivCopy(w_u);
2663 if ((w_v!=NULL) && (w_u==NULL))
2664 w_u=ivCopy(w_v);
2665 ideal u_id=(ideal)u->Data();
2666 ideal v_id=(ideal)v->Data();
2667 if (w_u!=NULL)
2668 {
2669 if ((*w_u).compare((w_v))!=0)
2670 {
2671 WarnS("incompatible weights");
2672 delete w_u; w_u=NULL;
2673 hom=testHomog;
2674 }
2675 else
2676 {
2677 if ((!idTestHomModule(u_id,currRing->qideal,w_v))
2678 || (!idTestHomModule(v_id,currRing->qideal,w_v)))
2679 {
2680 WarnS("wrong weights");
2681 delete w_u; w_u=NULL;
2682 hom=testHomog;
2683 }
2684 }
2685 }
2686 res->data = (char *)idModulo(u_id,v_id ,hom,&w_u);
2687 if (w_u!=NULL)
2688 {
2689 atSet(res,omStrDup("isHomog"),w_u,INTVEC_CMD);
2690 }
2691 delete w_v;
2692 //if (TEST_OPT_RETURN_SB) setFlag(res,FLAG_STD);
2693 return FALSE;
2694}
2696{
2697 number q=(number)v->Data();
2698 if (n_IsZero(q,coeffs_BIGINT))
2699 {
2701 return TRUE;
2702 }
2703 res->data =(char *) n_IntMod((number)u->Data(),q,coeffs_BIGINT);
2704 return FALSE;
2705}
2707{
2708 number q=(number)v->Data();
2709 if (nIsZero(q))
2710 {
2712 return TRUE;
2713 }
2714 res->data =(char *) n_IntMod((number)u->Data(),q,currRing->cf);
2715 return FALSE;
2716}
2718{
2719 poly q=(poly)v->Data();
2720 if (q==NULL)
2721 {
2723 return TRUE;
2724 }
2725 poly p=(poly)(u->Data());
2726 if (p==NULL)
2727 {
2728 res->data=NULL;
2729 return FALSE;
2730 }
2731 res->data=(void*)(singclap_pmod(p /*(poly)(u->Data())*/ ,
2732 q /*(poly)(v->Data())*/ ,currRing));
2733 return FALSE;
2734}
2737{
2738 return jjMONITOR2(res,v,NULL);
2739}
2741{
2742#if 0
2743 char *opt=(char *)v->Data();
2744 int mode=0;
2745 while(*opt!='\0')
2746 {
2747 if (*opt=='i') mode |= SI_PROT_I;
2748 else if (*opt=='o') mode |= SI_PROT_O;
2749 opt++;
2750 }
2751 monitor((char *)(u->Data()),mode);
2752#else
2753 si_link l=(si_link)u->Data();
2754 if (slOpen(l,SI_LINK_WRITE,u)) return TRUE;
2755 if(strcmp(l->m->type,"ASCII")!=0)
2756 {
2757 Werror("ASCII link required, not `%s`",l->m->type);
2758 slClose(l);
2759 return TRUE;
2760 }
2761 SI_LINK_SET_CLOSE_P(l); // febase handles the FILE*
2762 if ( l->name[0]!='\0') // "" is the stop condition
2763 {
2764 const char *opt;
2765 int mode=0;
2766 if (v==NULL) opt=(const char*)"i";
2767 else opt=(const char *)v->Data();
2768 while(*opt!='\0')
2769 {
2770 if (*opt=='i') mode |= SI_PROT_I;
2771 else if (*opt=='o') mode |= SI_PROT_O;
2772 opt++;
2773 }
2774 monitor((FILE *)l->data,mode);
2775 }
2776 else
2777 monitor(NULL,0);
2778 return FALSE;
2779#endif
2780}
2782{
2783 intvec *iv=(intvec *)v->Data();
2784 poly p=pOne();
2785 int e;
2786 BOOLEAN err=FALSE;
2787 for(unsigned i=si_min(currRing->N,iv->length()); i>0; i--)
2788 {
2789 e=(*iv)[i-1];
2790 if (e>=0) pSetExp(p,i,e);
2791 else err=TRUE;
2792 }
2793 if (iv->length()==(currRing->N+1))
2794 {
2795 res->rtyp=VECTOR_CMD;
2796 e=(*iv)[currRing->N];
2797 if (e>=0) pSetComp(p,e);
2798 else err=TRUE;
2799 }
2800 pSetm(p);
2801 res->data=(char*)p;
2802 if(err) { pDelete(&p); WerrorS("no negative exponent allowed"); }
2803 return err;
2804}
2806{
2807 // u: the name of the new type
2808 // v: the elements
2809 const char *s=(const char *)u->Data();
2810 newstruct_desc d=NULL;
2811 if (strlen(s)>=2)
2812 {
2813 d=newstructFromString((const char *)v->Data());
2814 if (d!=NULL) newstruct_setup(s,d);
2815 }
2816 else WerrorS("name of newstruct must be longer than 1 character");
2817 return d==NULL;
2818}
2820{
2821 idhdl h=(idhdl)u->data;
2822 int i=(int)(long)v->Data();
2823 int p=0;
2824 if ((0<i)
2825 && (rParameter(IDRING(h))!=NULL)
2826 && (i<=(p=rPar(IDRING(h)))))
2827 res->data=omStrDup(rParameter(IDRING(h))[i-1]);
2828 else
2829 {
2830 Werror("par number %d out of range 1..%d",i,p);
2831 return TRUE;
2832 }
2833 return FALSE;
2834}
2835#ifdef HAVE_PLURAL
2837{
2838 if( currRing->qideal != NULL )
2839 {
2840 WerrorS("basering must NOT be a qring!");
2841 return TRUE;
2842 }
2843
2844 if (iiOp==NCALGEBRA_CMD)
2845 {
2846 return nc_CallPlural(NULL,NULL,(poly)a->Data(),(poly)b->Data(),currRing,false,true,false,currRing);
2847 }
2848 else
2849 {
2850 ring r=rCopy(currRing);
2851 BOOLEAN result=nc_CallPlural(NULL,NULL,(poly)a->Data(),(poly)b->Data(),r,false,true,false,currRing);
2852 res->data=r;
2853 return result;
2854 }
2855}
2857{
2858 if( currRing->qideal != NULL )
2859 {
2860 WerrorS("basering must NOT be a qring!");
2861 return TRUE;
2862 }
2863
2864 if (iiOp==NCALGEBRA_CMD)
2865 {
2866 return nc_CallPlural(NULL,(matrix)b->Data(),(poly)a->Data(),NULL,currRing,false,true,false,currRing);
2867 }
2868 else
2869 {
2870 ring r=rCopy(currRing);
2871 BOOLEAN result=nc_CallPlural(NULL,(matrix)b->Data(),(poly)a->Data(),NULL,r,false,true,false,currRing);
2872 res->data=r;
2873 return result;
2874 }
2875}
2877{
2878 if( currRing->qideal != NULL )
2879 {
2880 WerrorS("basering must NOT be a qring!");
2881 return TRUE;
2882 }
2883
2884 if (iiOp==NCALGEBRA_CMD)
2885 {
2886 return nc_CallPlural((matrix)a->Data(),NULL,NULL,(poly)b->Data(),currRing,false,true,false,currRing);
2887 }
2888 else
2889 {
2890 ring r=rCopy(currRing);
2891 BOOLEAN result=nc_CallPlural((matrix)a->Data(),NULL,NULL,(poly)b->Data(),r,false,true,false,currRing);
2892 res->data=r;
2893 return result;
2894 }
2895}
2897{
2898 if( currRing->qideal != NULL )
2899 {
2900 WerrorS("basering must NOT be a qring!");
2901 return TRUE;
2902 }
2903
2904 if (iiOp==NCALGEBRA_CMD)
2905 {
2906 return nc_CallPlural((matrix)a->Data(),(matrix)b->Data(),NULL,NULL,currRing,false,true,false,currRing);
2907 }
2908 else
2909 {
2910 ring r=rCopy(currRing);
2911 BOOLEAN result=nc_CallPlural((matrix)a->Data(),(matrix)b->Data(),NULL,NULL,r,false,true,false,currRing);
2912 res->data=r;
2913 return result;
2914 }
2915}
2917{
2918 res->data=NULL;
2919
2921 {
2922 const poly q = (poly)b->Data();
2923
2924 if( q != NULL )
2925 {
2926 if( (poly)a->Data() != NULL )
2927 {
2929 {
2930 poly p = (poly)a->CopyD(POLY_CMD); // p = copy!
2931 res->data = nc_p_Bracket_qq(p,q, currRing); // p will be destroyed!
2932 }
2933 else if (rIsLPRing(currRing))
2934 {
2935 const poly p = (poly)a->Data();
2936 res->data = pAdd(ppMult_qq(p,q), pNeg(ppMult_qq(q,p)));
2937 }
2938 }
2939 }
2940 }
2941 return FALSE;
2942}
2944{
2945 res->data=NULL;
2946
2948 {
2949 const poly q = (poly)b->Data();
2950 if(q != NULL)
2951 {
2952 if((poly)a->Data() != NULL)
2953 {
2954 const poly p = (poly)a->Data();
2955 int k=(int)(long)c->Data();
2956 if (k > 0)
2957 {
2958 poly qq = pCopy(q);
2959 for (int i = 0; i < k; i++)
2960 {
2961 poly qq_ref = qq;
2962 if (rIsLPRing(currRing))
2963 {
2964 qq = pAdd(ppMult_qq(p,qq), pNeg(ppMult_qq(qq,p)));
2965 }
2966 else if (rIsPluralRing(currRing))
2967 {
2968 qq = nc_p_Bracket_qq(pCopy(p), qq, currRing);
2969 }
2970 pDelete(&qq_ref);
2971 if (qq == NULL) break;
2972 }
2973 res->data = qq;
2974 }
2975 else
2976 {
2977 Werror("invalid number of iterations");
2978 }
2979 }
2980 }
2981 }
2982 return FALSE;
2983}
2985{
2986 /* number, poly, vector, ideal, module, matrix */
2987 ring r = (ring)a->Data();
2988 if (r == currRing)
2989 {
2990 res->data = b->Data();
2991 res->rtyp = b->rtyp;
2992 return FALSE;
2993 }
2994 if (!rIsLikeOpposite(currRing, r))
2995 {
2996 Werror("%s is not an opposite ring to current ring",a->Fullname());
2997 return TRUE;
2998 }
2999 idhdl w;
3000 if( ((w=r->idroot->get(b->Name(),myynest))!=NULL) && (b->e==NULL))
3001 {
3002 int argtype = IDTYP(w);
3003 switch (argtype)
3004 {
3005 case NUMBER_CMD:
3006 {
3007 /* since basefields are equal, we can apply nCopy */
3008 res->data = nCopy((number)IDDATA(w));
3009 res->rtyp = argtype;
3010 break;
3011 }
3012 case POLY_CMD:
3013 case VECTOR_CMD:
3014 {
3015 poly q = (poly)IDDATA(w);
3016 res->data = pOppose(r,q,currRing);
3017 res->rtyp = argtype;
3018 break;
3019 }
3020 case IDEAL_CMD:
3021 case MODUL_CMD:
3022 {
3023 ideal Q = (ideal)IDDATA(w);
3024 res->data = idOppose(r,Q,currRing);
3025 res->rtyp = argtype;
3026 break;
3027 }
3028 case MATRIX_CMD:
3029 {
3030 ring save = currRing;
3031 rChangeCurrRing(r);
3032 matrix m = (matrix)IDDATA(w);
3034 rChangeCurrRing(save);
3035 ideal S = idOppose(r,Q,currRing);
3036 id_Delete(&Q, r);
3037 res->data = id_Module2Matrix(S,currRing);
3038 res->rtyp = argtype;
3039 break;
3040 }
3041 default:
3042 {
3043 WerrorS("unsupported type in oppose");
3044 return TRUE;
3045 }
3046 }
3047 }
3048 else
3049 {
3050 Werror("identifier %s not found in %s",b->Fullname(),a->Fullname());
3051 return TRUE;
3052 }
3053 return FALSE;
3054}
3055#endif /* HAVE_PLURAL */
3056
3058{
3059 if (ma->Typ()!=SMATRIX_CMD)
3060 {
3061 WerrorS("expected prune_map(`module`,`smatrix`)`");
3062 return TRUE;
3063 }
3064
3065 intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
3066 ideal v_id=(ideal)v->Data();
3067 if (w!=NULL)
3068 {
3069 if (!idTestHomModule(v_id,currRing->qideal,w))
3070 {
3071 WarnS("wrong weights");
3072 w=NULL;
3073 // and continue at the non-homog case below
3074 }
3075 else
3076 {
3077 w=ivCopy(w);
3078 intvec **ww=&w;
3079 ideal mat;
3080 int *g=(int*)omAlloc(v_id->rank*sizeof(int));
3081 res->data = (char *)idMinEmbedding_with_map_v(v_id,ww,mat,g);
3082 atSet(res,omStrDup("isHomog"),*ww,INTVEC_CMD);
3083 idhdl h=(idhdl)ma->data;
3084 idDelete(&IDIDEAL(h));
3085 IDIDEAL(h)=mat;
3086 for(int i=0;i<v_id->rank;i++) Print("v[%d]:%d ",i+1,g[i]); PrintLn();
3087 omFreeSize(g,v_id->rank*sizeof(int));
3088 return FALSE;
3089 }
3090 }
3091 ideal mat;
3092 int *g=(int*)omAlloc(v_id->rank*sizeof(int));
3093 res->data = (char *)idMinEmbedding_with_map_v(v_id,NULL,mat,g);
3094 for(int i=0;i<v_id->rank;i++) Print("v[%d]:%d ",i+1,g[i]); PrintLn();
3095 omFreeSize(g,v_id->rank*sizeof(int));
3096 idhdl h=(idhdl)ma->data;
3097 idDelete(&IDIDEAL(h));
3098 IDIDEAL(h)=mat;
3099 return FALSE;
3100}
3102{
3103 res->data = (char *)idQuot((ideal)u->Data(),(ideal)v->Data(),
3104 hasFlag(u,FLAG_STD),u->Typ()==v->Typ());
3105 //if (TEST_OPT_RETURN_SB) setFlag(res,FLAG_STD);
3106 return FALSE;
3107}
3109{
3110 int i=(int)(long)u->Data();
3111 int j=(int)(long)v->Data();
3112 if (j-i <0) {WerrorS("invalid range for random"); return TRUE;}
3113 res->data =(char *)(long)((i > j) ? i : (siRand() % (j-i+1)) + i);
3114 return FALSE;
3115}
3117{
3118 matrix m =(matrix)u->Data();
3119 int isRowEchelon = (int)(long)v->Data();
3120 if (isRowEchelon != 1) isRowEchelon = 0;
3121 int rank = luRank(m, isRowEchelon);
3122 res->data =(char *)(long)rank;
3123 return FALSE;
3124}
3126{
3127 si_link l=(si_link)u->Data();
3128 leftv r=slRead(l,v);
3129 if (r==NULL)
3130 {
3131 const char *s;
3132 if ((l!=NULL)&&(l->name!=NULL)) s=l->name;
3133 else s=sNoName_fe;
3134 Werror("cannot read from `%s`",s);
3135 return TRUE;
3136 }
3137 memcpy(res,r,sizeof(sleftv));
3139 return FALSE;
3140}
3142{
3143 ideal vi=(ideal)v->Data();
3144 if (currRing->qideal!=NULL || vi->ncols>1 || rIsPluralRing(currRing))
3146 res->data = (char *)kNF(vi,currRing->qideal,(poly)u->Data());
3147 return FALSE;
3148}
3150{
3151 ideal ui=(ideal)u->Data();
3152 ideal vi=(ideal)v->Data();
3153 if (currRing->qideal!=NULL || vi->ncols>1 || rIsPluralRing(currRing))
3155 res->data = (char *)kNF(vi,currRing->qideal,ui);
3156 return FALSE;
3157}
3159{
3160 int maxl=(int)(long)v->Data();
3161 if (maxl<0)
3162 {
3163 WerrorS("length for res must not be negative");
3164 return TRUE;
3165 }
3166 syStrategy r;
3167 intvec *weights=NULL;
3168 int wmaxl=maxl;
3169 ideal u_id=(ideal)u->Data();
3170
3171 maxl--;
3172 if (/*(*/ maxl==-1 /*)*/) /*&& (iiOp!=MRES_CMD)*/
3173 {
3174 maxl = currRing->N-1+2*(iiOp==MRES_CMD);
3175 if (currRing->qideal!=NULL)
3176 {
3177 Warn(
3178 "full resolution in a qring may be infinite, setting max length to %d",
3179 maxl+1);
3180 }
3181 }
3182 weights=(intvec*)atGet(u,"isHomog",INTVEC_CMD);
3183 if (weights!=NULL)
3184 {
3185 if (!idTestHomModule(u_id,currRing->qideal,weights))
3186 {
3187 WarnS("wrong weights given:");weights->show();PrintLn();
3188 weights=NULL;
3189 }
3190 }
3191 intvec *ww=NULL;
3192 int add_row_shift=0;
3193 if (weights!=NULL)
3194 {
3195 ww=ivCopy(weights);
3196 add_row_shift = ww->min_in();
3197 (*ww) -= add_row_shift;
3198 }
3199 unsigned save_opt=si_opt_1;
3201 if ((iiOp == RES_CMD) || (iiOp == MRES_CMD))
3202 {
3203 if (iiOp==MRES_CMD) u_id=(ideal)u->CopyD();
3204 r=syResolution(u_id,maxl, ww, iiOp==MRES_CMD);
3205 }
3206 else if (iiOp==SRES_CMD)
3207 // r=sySchreyerResolvente(u_id,maxl+1,&l);
3208 r=sySchreyer(u_id,maxl+1);
3209 else if (iiOp == LRES_CMD)
3210 {
3211 int dummy;
3212 if((currRing->qideal!=NULL)||
3213 (!idHomIdeal (u_id,NULL)))
3214 {
3215 WerrorS
3216 ("`lres` not implemented for inhomogeneous input or qring");
3217 return TRUE;
3218 }
3219 if(currRing->N == 1)
3220 WarnS("the current implementation of `lres` may not work in the case of a single variable");
3221 r=syLaScala3(u_id,&dummy);
3222 }
3223 else if (iiOp == KRES_CMD)
3224 {
3225 int dummy;
3226 if((currRing->qideal!=NULL)||
3227 (!idHomIdeal (u_id,NULL)))
3228 {
3229 WerrorS
3230 ("`kres` not implemented for inhomogeneous input or qring");
3231 return TRUE;
3232 }
3233 r=syKosz(u_id,&dummy);
3234 }
3235 else
3236 {
3237 int dummy;
3238 if((currRing->qideal!=NULL)||
3239 (!idHomIdeal (u_id,NULL)))
3240 {
3241 WerrorS
3242 ("`hres` not implemented for inhomogeneous input or qring");
3243 return TRUE;
3244 }
3245 ideal u_id_copy=idCopy(u_id);
3246 idSkipZeroes(u_id_copy);
3247 r=syHilb(u_id_copy,&dummy);
3248 idDelete(&u_id_copy);
3249 }
3250 if (r==NULL) return TRUE;
3251 if (r->list_length>wmaxl)
3252 {
3253 for(int i=wmaxl-1;i>=r->list_length;i--)
3254 {
3255 if (r->fullres[i]!=NULL) id_Delete(&r->fullres[i],currRing);
3256 if (r->minres[i]!=NULL) id_Delete(&r->minres[i],currRing);
3257 }
3258 }
3259 r->list_length=wmaxl;
3260 res->data=(void *)r;
3261 if ((weights!=NULL) && (ww!=NULL)) { delete ww; ww=NULL; }
3262 if ((r->weights!=NULL) && (r->weights[0]!=NULL))
3263 {
3264 ww=ivCopy(r->weights[0]);
3265 if (weights!=NULL) (*ww) += add_row_shift;
3266 atSet(res,omStrDup("isHomog"),ww,INTVEC_CMD);
3267 }
3268 else
3269 {
3270 if (weights!=NULL)
3271 {
3272 atSet(res,omStrDup("isHomog"),ivCopy(weights),INTVEC_CMD);
3273 }
3274 }
3275
3276 // test the La Scala case' output
3277 assume( ((iiOp == LRES_CMD) || (iiOp == HRES_CMD)) == (r->syRing != NULL) );
3278 assume( (r->syRing != NULL) == (r->resPairs != NULL) );
3279
3280 if(iiOp != HRES_CMD)
3281 assume( (r->minres != NULL) || (r->fullres != NULL) ); // is wrong for HRES_CMD...
3282 else
3283 assume( (r->orderedRes != NULL) || (r->res != NULL) ); // analog for hres...
3284
3285 si_opt_1=save_opt;
3286 return FALSE;
3287}
3289{
3290 number n1; int i;
3291
3292 if ((u->Typ() == BIGINT_CMD) ||
3293 ((u->Typ() == NUMBER_CMD) && rField_is_Q(currRing)))
3294 {
3295 n1 = (number)u->CopyD();
3296 }
3297 else if (u->Typ() == INT_CMD)
3298 {
3299 i = (int)(long)u->Data();
3300 n1 = n_Init(i, coeffs_BIGINT);
3301 }
3302 else
3303 {
3304 return TRUE;
3305 }
3306
3307 i = (int)(long)v->Data();
3308
3309 lists l = primeFactorisation(n1, i);
3310 n_Delete(&n1, coeffs_BIGINT);
3311 res->data = (char*)l;
3312 return FALSE;
3313}
3315{
3316 ring r=rMinusVar((ring)u->Data(),(char*)v->Data());
3317 res->data = (char *)r;
3318 return r==NULL;
3319}
3321{
3322 int left;
3323 if (u->Typ()==RING_CMD) left=0;
3324 else
3325 {
3326 leftv h=u;u=v;v=h;
3327 left=1;
3328 }
3329 ring r=rPlusVar((ring)u->Data(),(char*)v->Data(),left);
3330 res->data = (char *)r;
3331 return r==NULL;
3332}
3334{
3335 ring r;
3336 int i=rSum((ring)u->Data(),(ring)v->Data(),r);
3337 res->data = (char *)r;
3338 return (i==-1);
3339}
3340#define SIMPL_NORMALIZE 64
3341#define SIMPL_LMDIV 32
3342#define SIMPL_LMEQ 16
3343#define SIMPL_MULT 8
3344#define SIMPL_EQU 4
3345#define SIMPL_NULL 2
3346#define SIMPL_NORM 1
3348{
3349 int sw = (int)(long)v->Data();
3350 // CopyD for IDEAL_CMD and MODUL_CMD are identical:
3351 ideal id = (ideal)u->CopyD(IDEAL_CMD);
3352 if (sw & SIMPL_LMDIV)
3353 {
3354 id_DelDiv(id,currRing);
3355 }
3356 if (sw & SIMPL_LMEQ)
3357 {
3359 }
3360 if (sw & SIMPL_MULT)
3361 {
3363 }
3364 else if(sw & SIMPL_EQU)
3365 {
3367 }
3368 if (sw & SIMPL_NULL)
3369 {
3370 idSkipZeroes(id);
3371 }
3372 if (sw & SIMPL_NORM)
3373 {
3374 id_Norm(id,currRing);
3375 }
3376 if (sw & SIMPL_NORMALIZE)
3377 {
3379 }
3380 res->data = (char * )id;
3381 return FALSE;
3382}
3385{
3386 intvec *v=NULL;
3387 int sw=(int)(long)dummy->Data();
3388 int fac_sw=sw;
3389 if (sw<0) fac_sw=1;
3391 ideal f=singclap_sqrfree((poly)(u->CopyD()), &v, fac_sw, currRing);
3392 if (f==NULL)
3393 return TRUE;
3394 switch(sw)
3395 {
3396 case 0:
3397 case 2:
3398 {
3400 l->Init(2);
3401 l->m[0].rtyp=IDEAL_CMD;
3402 l->m[0].data=(void *)f;
3403 l->m[1].rtyp=INTVEC_CMD;
3404 l->m[1].data=(void *)v;
3405 res->data=(void *)l;
3406 res->rtyp=LIST_CMD;
3407 return FALSE;
3408 }
3409 case 1:
3410 res->data=(void *)f;
3411 return FALSE;
3412 case 3:
3413 {
3414 poly p=f->m[0];
3415 int i=IDELEMS(f);
3416 f->m[0]=NULL;
3417 while(i>1)
3418 {
3419 i--;
3420 p=pMult(p,f->m[i]);
3421 f->m[i]=NULL;
3422 }
3423 res->data=(void *)p;
3424 res->rtyp=POLY_CMD;
3425 }
3426 return FALSE;
3427 }
3428 WerrorS("invalid switch");
3429 return FALSE;
3430}
3432{
3433 res->data = omStrDup(slStatus((si_link) u->Data(), (char *) v->Data()));
3434 return FALSE;
3435}
3437{
3438 res->data = (void *)(long)slStatusSsiL((lists) u->Data(), (int)(long) v->Data());
3439 //return (res->data== (void*)(long)-2);
3440 return FALSE;
3441}
3443{
3444 int sw = (int)(long)v->Data();
3445 // CopyD for POLY_CMD and VECTOR_CMD are identical:
3446 poly p = (poly)u->CopyD(POLY_CMD);
3447 if (sw & SIMPL_NORM)
3448 {
3449 pNorm(p);
3450 }
3451 if (sw & SIMPL_NORMALIZE)
3452 {
3454 }
3455 res->data = (char * )p;
3456 return FALSE;
3457}
3459{
3460 ideal result;
3461 intvec *w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
3462 tHomog hom=testHomog;
3463 ideal u_id=(ideal)(u->Data());
3464 if (w!=NULL)
3465 {
3466 if (!idTestHomModule(u_id,currRing->qideal,w))
3467 {
3468 WarnS("wrong weights:");w->show();PrintLn();
3469 w=NULL;
3470 }
3471 else
3472 {
3473 w=ivCopy(w);
3474 hom=isHomog;
3475 }
3476 }
3477 bigintmat *vv=(bigintmat*)v->Data();
3478 intvec* vvv=new intvec(1,vv->cols());
3479 for(int i=0;i<vv->cols();i++)
3480 {
3481 (*vvv)[i]=n_Int(BIMATELEM(*vv,1,i+1),coeffs_BIGINT);
3482 }
3483 result=kStd(u_id,currRing->qideal,hom,&w,vvv);
3484 delete vvv;
3486 res->data = (char *)result;
3488 if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
3489 return FALSE;
3490}
3492{
3493 ideal result;
3494 assumeStdFlag(u);
3495 ideal i1=(ideal)(u->Data());
3496 int ii1=idElem(i1); /* size of i1 */
3497 ideal i0;
3498 int r=v->Typ();
3499 if ((/*v->Typ()*/r==POLY_CMD) ||(r==VECTOR_CMD))
3500 {
3501 poly p=(poly)v->Data();
3502 i0=idInit(1,i1->rank);
3503 i0->m[0]=p;
3504 i1=idSimpleAdd(i1,i0); //
3505 memset(i0->m,0,sizeof(poly)*IDELEMS(i0));
3506 idDelete(&i0);
3507 intvec *w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
3508 tHomog hom=testHomog;
3509
3510 if (w!=NULL)
3511 {
3512 if (!idTestHomModule(i1,currRing->qideal,w))
3513 {
3514 // no warnung: this is legal, if i in std(i,p)
3515 // is homogeneous, but p not
3516 w=NULL;
3517 }
3518 else
3519 {
3520 w=ivCopy(w);
3521 hom=isHomog;
3522 }
3523 }
3524 BITSET save1;
3525 SI_SAVE_OPT1(save1);
3527 /* ii1 appears to be the position of the first element of il that
3528 does not belong to the old SB ideal */
3529 result=kStd(i1,currRing->qideal,hom,&w,NULL,0,ii1);
3530 SI_RESTORE_OPT1(save1);
3531 idDelete(&i1);
3533 if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
3534 res->data = (char *)result;
3535 }
3536 else /*IDEAL/MODULE*/
3537 {
3538 i0=(ideal)v->CopyD();
3539 i1=idSimpleAdd(i1,i0); //
3540 memset(i0->m,0,sizeof(poly)*IDELEMS(i0));
3541 idDelete(&i0);
3542 intvec *w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
3543 tHomog hom=testHomog;
3544
3545 if (w!=NULL)
3546 {
3547 if (!idTestHomModule(i1,currRing->qideal,w))
3548 {
3549 // no warnung: this is legal, if i in std(i,p)
3550 // is homogeneous, but p not
3551 w=NULL;
3552 hom=isNotHomog;
3553 }
3554 else
3555 {
3556 w=ivCopy(w);
3557 hom=isHomog;
3558 }
3559 }
3560 BITSET save1;
3561 SI_SAVE_OPT1(save1);
3563 /* ii1 appears to be the position of the first element of i1 that
3564 does not belong to the old SB ideal */
3565 result=kStd(i1,currRing->qideal,hom,&w,NULL,0,ii1);
3566 SI_RESTORE_OPT1(save1);
3567 idDelete(&i1);
3569 if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
3570 res->data = (char *)result;
3571 }
3573 return FALSE;
3574}
3576{
3577 // see jjSYZYGY
3578 intvec *ww=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
3579 intvec *w=NULL;
3580 tHomog hom=testHomog;
3581 ideal I=(ideal)u->Data();
3582 GbVariant alg=syGetAlgorithm((char*)v->Data(),currRing,I);
3583 if (ww!=NULL)
3584 {
3585 if (idTestHomModule(I,currRing->qideal,ww))
3586 {
3587 w=ivCopy(ww);
3588 int add_row_shift=w->min_in();
3589 (*w)-=add_row_shift;
3590 hom=isHomog;
3591 }
3592 else
3593 {
3594 //WarnS("wrong weights");
3595 delete ww; ww=NULL;
3596 hom=testHomog;
3597 }
3598 }
3599 else
3600 {
3601 if (u->Typ()==IDEAL_CMD)
3602 if (idHomIdeal(I,currRing->qideal))
3603 hom=isHomog;
3604 }
3605 ideal S=idSyzygies(I,hom,&w,TRUE,FALSE,NULL,alg);
3606 if (w!=NULL) delete w;
3607 res->data = (char *)S;
3608 if (hom==isHomog)
3609 {
3610 int vl=S->rank;
3611 intvec *vv=new intvec(vl);
3612 if ((u->Typ()==IDEAL_CMD)||(ww==NULL))
3613 {
3614 for(int i=0;i<vl;i++)
3615 {
3616 if (I->m[i]!=NULL)
3617 (*vv)[i]=p_Deg(I->m[i],currRing);
3618 }
3619 }
3620 else
3621 {
3622 p_SetModDeg(ww, currRing);
3623 for(int i=0;i<vl;i++)
3624 {
3625 if (I->m[i]!=NULL)
3626 (*vv)[i]=currRing->pFDeg(I->m[i],currRing);
3627 }
3629 }
3630 if (idTestHomModule(S,currRing->qideal,vv))
3631 atSet(res,omStrDup("isHomog"),vv,INTVEC_CMD);
3632 else
3633 delete vv;
3634 }
3636 return FALSE;
3637}
3639{
3640 ideal A=(ideal)u->Data();
3641 ideal B=(ideal)v->Data();
3642 res->data = (char *)sm_Tensor(A,B,currRing);
3643 return FALSE;
3644}
3646{
3647 sleftv tmp_u,tmp_v,tmp_res;
3651 tmp_res.Init();
3652 tmp_res.rtyp=SMATRIX_CMD;
3653 BOOLEAN bo=jjTENSOR(&tmp_res,&tmp_u,&tmp_v);
3654 if (!bo)
3655 {
3658 }
3659 tmp_u.CleanUp();
3660 tmp_v.CleanUp();
3661 tmp_res.CleanUp();
3662 return bo;
3663}
3665{
3666 idhdl h=(idhdl)u->data;
3667 int i=(int)(long)v->Data();
3668 if ((0<i) && (i<=IDRING(h)->N))
3669 res->data=omStrDup(IDRING(h)->names[i-1]);
3670 else
3671 {
3672 Werror("var number %d out of range 1..%d",i,IDRING(h)->N);
3673 return TRUE;
3674 }
3675 return FALSE;
3676}
3678{
3679// input: u: a list with links of type
3680// ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
3681// v: timeout for select in milliseconds
3682// or 0 for polling
3683// returns: ERROR (via Werror): timeout negative
3684// -1: the read state of all links is eof
3685// 0: timeout (or polling): none ready
3686// i>0: (at least) L[i] is ready
3687 lists L = (lists)u->Data();
3688 int t = (int)(long)v->Data();
3689 if(t < 0)
3690 {
3691 t= -1;
3692 }
3693 int i = slStatusSsiL(L, t);
3694 if(i == -2) /* error */
3695 {
3696 return TRUE;
3697 }
3698 res->data = (void*)(long)i;
3699 return FALSE;
3700}
3702{
3703// input: u: a list with links of type
3704// ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
3705// v: timeout for select in milliseconds
3706// or 0 for polling
3707// or -1 for infinite
3708// returns: ERROR (via Werror): timeout negative
3709// -1: the read state of all links is eof or error
3710// 0: timeout (or polling): none ready
3711// 1: all links are ready
3712// (caution: at least one is ready, but some maybe dead)
3713 lists L = (lists)u->Data();
3714 BOOLEAN* ignore=(BOOLEAN*)omAlloc0((L->nr+1)*sizeof(BOOLEAN));
3715 int timeout = (int)(long)v->Data();
3716 if(timeout < 0)
3717 {
3718 timeout=-1;
3719 }
3720 int t = getRTimer()/TIMER_RESOLUTION; // in seconds
3721 int i;
3722 int ret = -1;
3723 for(unsigned nfinished = 0; nfinished <= ((unsigned)L->nr); nfinished++)
3724 {
3725 i = slStatusSsiL(L, timeout, ignore);
3726 if(i > 0) /* L[i] is ready */
3727 {
3728 ret = 1;
3729 ignore[i-1]=TRUE;
3730 timeout = si_max(0,timeout - 1000*(getRTimer()/TIMER_RESOLUTION - t));
3731 }
3732 else /* terminate the for loop */
3733 {
3734 omFreeSize(ignore,(L->nr+1)*sizeof(BOOLEAN));
3735 if(i == -2) /* error */
3736 {
3737 return TRUE;
3738 }
3739 if(i == 0) /* timeout */
3740 {
3741 ret = 0;
3742 }
3743 break;
3744 }
3745 }
3746 res->data = (void*)(long)ret;
3747 return FALSE;
3748}
3750{
3751 res->data = (char *)mp_Wedge((matrix)u->Data(),(int)(long)v->Data(),currRing);
3752 return FALSE;
3753}
3755{
3756 return TRUE;
3757}
3759{
3760 return TRUE;
3761}
3763{
3764 return TRUE;
3765}
3766
3767/*=================== operations with 1 arg.: static proc =================*/
3768/* must be ordered: first operations for chars (infix ops),
3769 * then alphabetically */
3770
3772{
3773// res->data = (char *)u->CopyD();
3774// also copy attributes:
3775 res->Copy(u);
3776 return FALSE;
3777}
3779{
3780 return FALSE;
3781}
3782//static BOOLEAN jjPLUSPLUS(leftv res, leftv u)
3783//{
3784// res->data = (char *)((int)(long)u->Data()+1);
3785// return FALSE;
3786//}
3787//static BOOLEAN jjMINUSMINUS(leftv res, leftv u)
3788//{
3789// res->data = (char *)((int)(long)u->Data()-1);
3790// return FALSE;
3791//}
3793{
3794 if (IDTYP((idhdl)u->data)==INT_CMD)
3795 {
3796 int i=IDINT((idhdl)u->data);
3797 if (iiOp==PLUSPLUS) i++;
3798 else i--;
3799 IDDATA((idhdl)u->data)=(char *)(long)i;
3800 return FALSE;
3801 }
3802 return TRUE;
3803}
3805{
3806 number n=(number)u->CopyD(BIGINT_CMD);
3808 res->data = (char *)n;
3809 return FALSE;
3810}
3812{
3813 res->data = (char *)(-(long)u->Data());
3814 return FALSE;
3815}
3817{
3818 number n=(number)u->CopyD(NUMBER_CMD);
3819 n=nInpNeg(n);
3820 res->data = (char *)n;
3821 return FALSE;
3822}
3824{
3825 res->data = (char *)pNeg((poly)u->CopyD(POLY_CMD));
3826 return FALSE;
3827}
3829{
3830 poly m1=pISet(-1);
3831 res->data = (char *)mp_MultP((matrix)u->CopyD(MATRIX_CMD),m1,currRing);
3832 return FALSE;
3833}
3835{
3836 intvec *iv=(intvec *)u->CopyD(INTVEC_CMD);
3837 (*iv)*=(-1);
3838 res->data = (char *)iv;
3839 return FALSE;
3840}
3842{
3844 (*bim)*=(-1);
3845 res->data = (char *)bim;
3846 return FALSE;
3847}
3848// dummy for python_module.so and similiar
3850{
3851 if (u->rtyp==IDHDL) rSetHdl((idhdl)u->data);
3852 else
3853 {
3854 ring r=(ring)u->Data();
3855 idhdl h=rFindHdl(r,NULL);
3856 if (h==NULL)
3857 {
3858 char name_buffer[100];
3859 STATIC_VAR int ending=1000000;
3860 ending++;
3861 snprintf(name_buffer,100, "PYTHON_RING_VAR%d",ending);
3862 h=enterid(name_buffer,0,RING_CMD,&IDROOT);
3863 IDRING(h)=rIncRefCnt(r);
3864 }
3865 rSetHdl(h);
3866 }
3867 return FALSE;
3868}
3870{
3871 return jjPROC(res,u,NULL);
3872}
3874{
3875 //matrix m=(matrix)v->Data();
3876 //lists l=mpBareiss(m,FALSE);
3877 intvec *iv;
3878 ideal m;
3879 sm_CallBareiss((ideal)v->Data(),0,0,m,&iv, currRing);
3881 l->Init(2);
3882 l->m[0].rtyp=MODUL_CMD;
3883 l->m[1].rtyp=INTVEC_CMD;
3884 l->m[0].data=(void *)m;
3885 l->m[1].data=(void *)iv;
3886 res->data = (char *)l;
3887 return FALSE;
3888}
3889//static BOOLEAN jjBAREISS_IM(leftv res, leftv v)
3890//{
3891// intvec *m=(intvec *)v->CopyD(INTMAT_CMD);
3892// ivTriangMat(m);
3893// res->data = (char *)m;
3894// return FALSE;
3895//}
3897{
3898 bigintmat *b=(bigintmat*)v->CopyD(BIGINTMAT_CMD);
3899 b->hnf();
3900 res->data=(char*)b;
3901 return FALSE;
3902}
3904{
3905 BOOLEAN bo=FALSE;
3906 number n=(number)u->CopyD();
3908 if (nMap!=NULL)
3909 res->data=nMap(n,coeffs_BIGINT,currRing->cf);
3910 else
3911 {
3912 Werror("cannot convert bigint to cring %s", nCoeffName(currRing->cf));
3913 bo=TRUE;
3914 }
3916 return bo;
3917}
3919{
3920 bigintmat *b=(bigintmat*)u->Data();
3921 res->data=(void *)bim2iv(b);
3922 return FALSE;
3923}
3925{
3926 sleftv tmp;
3927 BOOLEAN bo=jjBI2N(&tmp,u);
3928 if (!bo)
3929 {
3930 number n=(number) tmp.data;
3931 if (nIsZero(n)) { res->data=NULL;nDelete(&n); }
3932 else
3933 {
3934 res->data=(void *)pNSet(n);
3935 }
3936 }
3937 return bo;
3938}
3940{
3941 return iiExprArithM(res,u,iiOp);
3942}
3944{
3945 res->data = (char *)(long)rChar((ring)v->Data());
3946 return FALSE;
3947}
3949{
3950 ring r=(ring)v->Data();
3951 r->cf->ref++;
3952 res->data = (char *)r->cf;
3953 return FALSE;
3954}
3956{
3957 res->data = (char *)(long)MATCOLS((matrix)(v->Data()));
3958 return FALSE;
3959}
3961{
3962 res->data = (char *)(long)((bigintmat*)(v->Data()))->cols();
3963 return FALSE;
3964}
3966{
3967 res->data = (char *)(long)((intvec*)(v->Data()))->cols();
3968 return FALSE;
3969}
3971{
3972 // CopyD for POLY_CMD and VECTOR_CMD are identical:
3973 poly p=(poly)v->CopyD(POLY_CMD);
3974 if (p!=NULL) p_Cleardenom(p, currRing);
3975 res->data = (char *)p;
3976 return FALSE;
3977}
3979{
3980 res->data = (char *)(long)n_Size((number)v->Data(),coeffs_BIGINT);
3981 return FALSE;
3982}
3984{
3985 bigintmat* aa= (bigintmat *)v->Data();
3986 res->data = (char *)(long)(aa->rows()*aa->cols());
3987 return FALSE;
3988}
3990{
3991 res->data = (char *)(long)nSize((number)v->Data());
3992 return FALSE;
3993}
3995{
3996 lists l=(lists)v->Data();
3997 res->data = (char *)(long)(lSize(l)+1);
3998 return FALSE;
3999}
4001{
4002 matrix m=(matrix)v->Data();
4003 res->data = (char *)(long)(MATROWS(m)*MATCOLS(m));
4004 return FALSE;
4005}
4007{
4008 res->data = (char *)(long)((intvec*)(v->Data()))->length();
4009 return FALSE;
4010}
4012{
4013 ring r=(ring)v->Data();
4014 int elems=-1;
4015 if (rField_is_Zp(r)) elems=r->cf->ch;
4016 else if (rField_is_GF(r)) elems=r->cf->m_nfCharQ;
4017 else if (rField_is_Zp_a(r) && (r->cf->type==n_algExt))
4018 {
4019 extern int ipower ( int b, int n ); /* factory/cf_util */
4020 elems=ipower(r->cf->ch,r->cf->extRing->pFDeg(r->cf->extRing->qideal->m[0],r->cf->extRing));
4021 }
4022 res->data = (char *)(long)elems;
4023 return FALSE;
4024}
4026{
4027 int dummy;
4028 poly p=(poly)v->Data();
4029 if (p!=NULL) res->data = (char *)currRing->pLDeg(p,&dummy,currRing);
4030 else res->data=(char *)-1;
4031 return FALSE;
4032}
4034{
4035 ideal I=(ideal)u->Data();
4036 int d=-1;
4037 int dummy;
4038 int i;
4039 for(i=IDELEMS(I)-1;i>=0;i--)
4040 if (I->m[i]!=NULL) d=si_max(d,(int)currRing->pLDeg(I->m[i],&dummy,currRing));
4041 res->data = (char *)(long)d;
4042 return FALSE;
4043}
4045{
4046 SPrintStart();
4047 if (rField_is_Z(currRing))
4048 {
4049 PrintS("// NOTE: computation of degree is being performed for\n");
4050 PrintS("// generic fibre, that is, over Q\n");
4051 }
4053 intvec *module_w=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
4054 scDegree((ideal)v->Data(),module_w,currRing->qideal);
4055 char *s=SPrintEnd();
4056 int l=strlen(s)-1;
4057 s[l]='\0';
4058 res->data=(void*)s;
4059 return FALSE;
4060}
4062{
4063 if ((v->rtyp==IDHDL)
4064 && ((myynest==IDLEV((idhdl)v->data))||(0==IDLEV((idhdl)v->data))))
4065 {
4066 res->data=(void *)(long)(IDLEV((idhdl)v->data)+1);
4067 }
4068 else if (v->rtyp!=0) res->data=(void *)(-1);
4069 return FALSE;
4070}
4071
4072/// Return the denominator of the input number
4074{
4075 number n = reinterpret_cast<number>(v->CopyD());
4076 res->data = reinterpret_cast<void*>(n_GetDenom(n, currRing->cf));
4077 n_Delete(&n,currRing->cf);
4078 return FALSE;
4079}
4080
4081/// Return the numerator of the input number
4083{
4084 number n = reinterpret_cast<number>(v->CopyD());
4085 res->data = reinterpret_cast<void*>(n_GetNumerator(n, currRing->cf));
4086 n_Delete(&n,currRing->cf);
4087 return FALSE;
4088}
4089
4091{
4092 matrix m=(matrix)v->Data();
4093 res ->data = mp_Det(m,currRing);
4094 return FALSE;
4095}
4097{
4098 bigintmat * m=(bigintmat*)v->Data();
4099 int i,j;
4100 i=m->rows();j=m->cols();
4101 if(i==j)
4102 res->data = (char *)(long)singclap_det_bi(m,coeffs_BIGINT);
4103 else
4104 {
4105 Werror("det of %d x %d bigintmat",i,j);
4106 return TRUE;
4107 }
4108 return FALSE;
4109}
4110#ifdef SINGULAR_4_2
4111static BOOLEAN jjDET_N2(leftv res, leftv v)
4112{
4113 bigintmat * m=(bigintmat*)v->Data();
4114 number2 r=(number2)omAlloc0(sizeof(*r));
4115 int i,j;
4116 i=m->rows();j=m->cols();
4117 if(i==j)
4118 {
4119 r->n=m->det();
4120 r->cf=m->basecoeffs();
4121 }
4122 else
4123 {
4124 omFreeSize(r,sizeof(*r));
4125 Werror("det of %d x %d cmatrix",i,j);
4126 return TRUE;
4127 }
4128 res->data=(void*)r;
4129 return FALSE;
4130}
4131#endif
4133{
4134 intvec * m=(intvec*)v->Data();
4135 int i,j;
4136 i=m->rows();j=m->cols();
4137 if(i==j)
4138 res->data = (char *)(long)singclap_det_i(m,currRing);
4139 else
4140 {
4141 Werror("det of %d x %d intmat",i,j);
4142 return TRUE;
4143 }
4144 return FALSE;
4145}
4147{
4148 ideal I=(ideal)v->Data();
4149 res->data=(char*)sm_Det(I,currRing);
4150 return FALSE;
4151}
4153{
4155#ifdef HAVE_SHIFTBBA
4156 if (rIsLPRing(currRing))
4157 {
4159 {
4160 WerrorS("`dim` is not implemented for letterplace rings over rings");
4161 return TRUE;
4162 }
4163 if (currRing->qideal != NULL)
4164 {
4165 WerrorS("qring not supported by `dim` for letterplace rings at the moment");
4166 return TRUE;
4167 }
4168 int gkDim = lp_gkDim((ideal)(v->Data()));
4169 res->data = (char *)(long)gkDim;
4170 return (gkDim == -2);
4171 }
4172#endif
4174 {
4175 Warn("dim(%s) may be wrong because the mixed monomial ordering",v->Name());
4176 }
4177 res->data = (char *)(long)scDimIntRing((ideal)(v->Data()),currRing->qideal);
4178 return FALSE;
4179}
4181{
4182 si_link l = (si_link)v->Data();
4183 if (slDump(l))
4184 {
4185 const char *s;
4186 if ((l!=NULL)&&(l->name!=NULL)) s=l->name;
4187 else s=sNoName_fe;
4188 Werror("cannot dump to `%s`",s);
4189 return TRUE;
4190 }
4191 else
4192 return FALSE;
4193}
4195{
4196 res->data = (char *)pOne();
4197 int co=(int)(long)v->Data();
4198 if (co>0)
4199 {
4200 pSetComp((poly)res->data,co);
4201 pSetm((poly)res->data);
4202 }
4203 else WerrorS("argument of gen must be positive");
4204 return (co<=0);
4205}
4207{
4208 char * d = (char *)v->Data();
4209 char * s = (char *)omAlloc(strlen(d) + 13);
4210 strcpy( s, (char *)d);
4211 strcat( s, "\n;RETURN();\n");
4213 return yyparse();
4214}
4216{
4218 if (currRing->cf->convSingNFactoryN!=ndConvSingNFactoryN) /* conversion to factory*/
4219 {
4220 ideal_list p,h;
4221 h=kStdfac((ideal)v->Data(),NULL,testHomog,NULL);
4222 if (h==NULL)
4223 {
4224 L->Init(1);
4225 L->m[0].data=(char *)idInit(1);
4226 L->m[0].rtyp=IDEAL_CMD;
4227 }
4228 else
4229 {
4230 p=h;
4231 int l=0;
4232 while (p!=NULL) { p=p->next;l++; }
4233 L->Init(l);
4234 l=0;
4235 while(h!=NULL)
4236 {
4237 L->m[l].data=(char *)h->d;
4238 L->m[l].rtyp=IDEAL_CMD;
4239 p=h->next;
4240 omFreeSize(h,sizeof(*h));
4241 h=p;
4242 l++;
4243 }
4244 }
4245 }
4246 else
4247 {
4248 WarnS("no factorization implemented");
4249 L->Init(1);
4250 iiExprArith1(&(L->m[0]),v,STD_CMD);
4251 }
4252 res->data=(void *)L;
4253 return FALSE;
4254}
4256{
4257 intvec *v=NULL;
4259 ideal f=singclap_factorize((poly)(u->CopyD()), &v, 0,currRing);
4260 if (f==NULL) return TRUE;
4261 ivTest(v);
4263 l->Init(2);
4264 l->m[0].rtyp=IDEAL_CMD;
4265 l->m[0].data=(void *)f;
4266 l->m[1].rtyp=INTVEC_CMD;
4267 l->m[1].data=(void *)v;
4268 res->data=(void *)l;
4269 return FALSE;
4270}
4272{
4273 si_link l = (si_link)v->Data();
4274 if (slGetDump(l))
4275 {
4276 const char *s;
4277 if ((l!=NULL)&&(l->name!=NULL)) s=l->name;
4278 else s=sNoName_fe;
4279 Werror("cannot get dump from `%s`",s);
4280 return TRUE;
4281 }
4282 else
4283 return FALSE;
4284}
4286{
4288 ideal I=(ideal)v->Data();
4289 res->data=(void *)iiHighCorner(I,0);
4290 return FALSE;
4291}
4293{
4295 intvec *w=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
4296 BOOLEAN delete_w=FALSE;
4297 ideal I=(ideal)v->Data();
4298 int i;
4299 poly p=NULL,po=NULL;
4300 int rk=id_RankFreeModule(I,currRing);
4301 if (w==NULL)
4302 {
4303 w = new intvec(rk);
4304 delete_w=TRUE;
4305 }
4306 for(i=rk;i>0;i--)
4307 {
4308 p=iiHighCorner(I,i);
4309 if (p==NULL)
4310 {
4311 WerrorS("module must be zero-dimensional");
4312 if (delete_w) delete w;
4313 return TRUE;
4314 }
4315 if (po==NULL)
4316 {
4317 po=p;
4318 }
4319 else
4320 {
4321 // now po!=NULL, p!=NULL
4322 int d=(currRing->pFDeg(po,currRing)-(*w)[pGetComp(po)-1] - currRing->pFDeg(p,currRing)+(*w)[i-1]);
4323 if (d==0)
4324 d=pLmCmp(po,p);
4325 if (d > 0)
4326 {
4327 pDelete(&p);
4328 }
4329 else // (d < 0)
4330 {
4331 pDelete(&po); po=p;
4332 }
4333 }
4334 }
4335 if (delete_w) delete w;
4336 res->data=(void *)po;
4337 return FALSE;
4338}
4340{
4341 if (rField_is_Z(currRing))
4342 {
4343 PrintS("// NOTE: computation of Hilbert series etc. is being\n");
4344 PrintS("// performed for generic fibre, that is, over Q\n");
4345 }
4347 intvec *module_w=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
4348 //scHilbertPoly((ideal)v->Data(),currRing->qideal);
4349 hLookSeries((ideal)v->Data(),module_w,currRing->qideal);
4350 return FALSE;
4351}
4353{
4354 if (rField_is_Z(currRing))
4355 {
4356 PrintS("// NOTE: computation of Hilbert series etc. is being\n");
4357 PrintS("// performed for generic fibre, that is, over Q\n");
4358 }
4359 res->data=(void *)hSecondSeries((intvec *)v->Data());
4360 return FALSE;
4361}
4363{
4364 intvec *w=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
4365 ideal v_id=(ideal)v->Data();
4366 if (w==NULL)
4367 {
4368 res->data=(void *)(long)idHomModule(v_id,currRing->qideal,&w);
4369 if (res->data!=NULL)
4370 {
4371 if (v->rtyp==IDHDL)
4372 {
4373 char *s_isHomog=omStrDup("isHomog");
4374 if (v->e==NULL)
4375 atSet((idhdl)(v->data),s_isHomog,w,INTVEC_CMD);
4376 else
4377 atSet((idhdl)(v->LData()),s_isHomog,w,INTVEC_CMD);
4378 }
4379 else if (w!=NULL) delete w;
4380 } // if res->data==NULL then w==NULL
4381 }
4382 else
4383 {
4384 res->data=(void *)(long)idTestHomModule(v_id,currRing->qideal,w);
4385 if((res->data==NULL) && (v->rtyp==IDHDL))
4386 {
4387 if (v->e==NULL)
4388 atKill((idhdl)(v->data),"isHomog");
4389 else
4390 atKill((idhdl)(v->LData()),"isHomog");
4391 }
4392 }
4393 return FALSE;
4394}
4396{
4397#ifdef HAVE_SHIFTBBA
4398 if (rIsLPRing(currRing))
4399 {
4400 int deg = (int)(long)v->Data();
4401 if (deg > currRing->N/currRing->isLPring)
4402 {
4403 WerrorS("degree bound of Letterplace ring is to small");
4404 return TRUE;
4405 }
4406 }
4407#endif
4408 res->data = (char *)idMaxIdeal((int)(long)v->Data());
4410 return FALSE;
4411}
4413{
4414 matrix mat=(matrix)v->CopyD(MATRIX_CMD);
4415 IDELEMS((ideal)mat)=MATCOLS(mat)*MATROWS(mat);
4416 MATROWS(mat)=1;
4417 mat->rank=1;
4418 res->data=(char *)mat;
4419 return FALSE;
4420}
4422{
4423 map m=(map)v->CopyD(MAP_CMD);
4424 omFreeBinAddr((ADDRESS)m->preimage);
4425 m->preimage=NULL;
4426 ideal I=(ideal)m;
4427 I->rank=1;
4428 res->data=(char *)I;
4429 return FALSE;
4430}
4432{
4433 if (currRing!=NULL)
4434 {
4435 ring q=(ring)v->Data();
4436 if (rSamePolyRep(currRing, q))
4437 {
4438 if (q->qideal==NULL)
4439 res->data=(char *)idInit(1,1);
4440 else
4441 res->data=(char *)idCopy(q->qideal);
4442 return FALSE;
4443 }
4444 }
4445 WerrorS("can only get ideal from identical qring");
4446 return TRUE;
4447}
4449{
4450 intvec *iv = (intvec *)v->CopyD(INTMAT_CMD);
4451 iv->makeVector();
4452 res->data = iv;
4453 return FALSE;
4454}
4456{
4457 res->data = (char *)n_ImPart((number)v->Data(),currRing->cf);
4458 return FALSE;
4459}
4461{
4463 res->data=(void *)scIndIntvec((ideal)(v->Data()),currRing->qideal);
4464 return FALSE;
4465}
4467{
4468 ideal result=kInterRed((ideal)(v->Data()), currRing->qideal);
4469 if (TEST_OPT_PROT) { PrintLn(); mflush(); }
4470 res->data = result;
4471 return FALSE;
4472}
4474{
4475 bigintmat* aa= (bigintmat *)v->Data();
4476 int l=aa->cols();
4477 intvec *iv=new intvec(l);
4478 for(int i=0;i<l;i++) (*iv)[i]=iin_Int(BIMATELEM((*aa),1,i+1),coeffs_BIGINT);
4479 res->data = (void*)iv;
4480 return FALSE;
4481}
4483{
4484 res->data = (char *)(long)pVar((poly)v->Data());
4485 return FALSE;
4486}
4488{
4489 res->data = (char *)(long)(r_IsRingVar((char *)v->Data(), currRing->names,
4490 currRing->N)+1);
4491 return FALSE;
4492}
4494{
4495 res->data = (char *)0;
4496 return FALSE;
4497}
4499{
4500 ideal i=idInit(currRing->N,1);
4501 int k;
4502 poly p=(poly)(v->Data());
4503 for (k=currRing->N;k>0;k--)
4504 {
4505 i->m[k-1]=pDiff(p,k);
4506 }
4507 res->data = (char *)i;
4508 return FALSE;
4509}
4511{
4512 if (!nCoeff_is_transExt(currRing->cf))
4513 {
4514 WerrorS("differentiation not defined in the coefficient ring");
4515 return TRUE;
4516 }
4517 number n = (number) u->Data();
4518 number k = (number) v->Data();
4519 res->data = ntDiff(n,k,currRing->cf);
4520 return FALSE;
4521}
4522/*2
4523 * compute Jacobi matrix of a module/matrix
4524 * Jacobi(M) := ( diff(Mt,var(1))|, ... ,| diff(Mt,var(currRing->N)) ),
4525 * where Mt := transpose(M)
4526 * Note that this is consistent with the current conventions for jacob in Singular,
4527 * whereas M2 computes its transposed.
4528 */
4530{
4531 ideal id = (ideal)a->Data();
4532 id = id_Transp(id,currRing);
4533 int W = IDELEMS(id);
4534
4535 ideal result = idInit(W * currRing->N, id->rank);
4536 poly *p = result->m;
4537
4538 for( int v = 1; v <= currRing->N; v++ )
4539 {
4540 poly* q = id->m;
4541 for( int i = 0; i < W; i++, p++, q++ )
4542 *p = pDiff( *q, v );
4543 }
4544 idDelete(&id);
4545
4546 res->data = (char *)result;
4547 return FALSE;
4548}
4549
4551{
4552#ifdef HAVE_FLINT
4553 res->data = (char *)singflint_kernel((matrix)(v->Data()),currRing);
4554 return res->data==NULL;
4555#else
4556 return TRUE;
4557#endif
4558}
4560{
4561#ifdef HAVE_FLINT
4562 res->data = (char *)singflint_kernel((ideal)(v->Data()),currRing);
4563 return res->data==NULL;
4564#else
4565 return TRUE;
4566#endif
4567}
4569{
4571 res->data = (char *)scKBase(-1,(ideal)(v->Data()),currRing->qideal);
4572 return FALSE;
4573}
4575{
4576 res->data=(char *)syConvList((lists)v->Data());
4577 if (res->data != NULL)
4578 return FALSE;
4579 else
4580 return TRUE;
4581}
4583{
4584 poly p=(poly)v->Data();
4585 if (p==NULL)
4586 {
4587 res->data=(char *)nInit(0);
4588 }
4589 else
4590 {
4592 res->data=(char *)nCopy(pGetCoeff(p));
4593 }
4594 return FALSE;
4595}
4597{
4598 poly p=(poly)v->Data();
4599 int s=currRing->N;
4600 if (v->Typ()==VECTOR_CMD) s++;
4601 intvec *iv=new intvec(s);
4602 if (p!=NULL)
4603 {
4604 for(int i = currRing->N;i;i--)
4605 {
4606 (*iv)[i-1]=pGetExp(p,i);
4607 }
4608 if (s!=currRing->N)
4609 (*iv)[currRing->N]=pGetComp(p);
4610 }
4611 res->data=(char *)iv;
4612 return FALSE;
4613}
4615{
4616 poly p=(poly)v->Data();
4617 if (p == NULL)
4618 {
4619 res->data = (char*) NULL;
4620 }
4621 else
4622 {
4623 poly lm = pLmInit(p);
4624 pSetCoeff0(lm, nInit(1));
4625 res->data = (char*) lm;
4626 }
4627 return FALSE;
4628}
4629static BOOLEAN jjLOAD1(leftv /*res*/, leftv v)
4630{
4631 return jjLOAD((char*)v->Data(),FALSE);
4632}
4634{
4635 lists l=(lists)v->Data();
4636 long mm=(long)atGet(v,"maxExp",INT_CMD);
4637 int isLetterplace=(int)(long)atGet(v,"isLetterplaceRing",INT_CMD);
4638 ring r=rCompose(l,TRUE,mm,isLetterplace);
4639 res->data=(char *)r;
4640 return (r==NULL);
4641}
4643{
4644 /* call method jjPFAC2 with second argument = 0 (meaning that no
4645 valid bound for the prime factors has been given) */
4646 sleftv tmp;
4647 tmp.Init();
4648 tmp.rtyp = INT_CMD;
4649 return jjPFAC2(res, v, &tmp);
4650}
4652{
4653 sleftv a2,a3;
4654 memset(&a2,0,sizeof(a2));
4655 memset(&a3,0,sizeof(a3));
4656 a2.rtyp=INT_CMD; a2.data=(void*)10;
4657 a3.rtyp=INT_CMD; a3.data=(void*)1;
4658 return nuLagSolve(res,v,&a2,&a3);
4659}
4661{
4662 /* computes the LU-decomposition of a matrix M;
4663 i.e., M = P * L * U, where
4664 - P is a row permutation matrix,
4665 - L is in lower triangular form,
4666 - U is in upper row echelon form
4667 Then, we also have P * M = L * U.
4668 A list [P, L, U] is returned. */
4669 matrix mat = (matrix)v->Data();
4670 if (!idIsConstant((ideal)mat))
4671 {
4672 WerrorS("matrix must be constant");
4673 return TRUE;
4674 }
4675 matrix pMat;
4676 matrix lMat;
4677 matrix uMat;
4678
4679 luDecomp(mat, pMat, lMat, uMat);
4680
4682 ll->Init(3);
4683 ll->m[0].rtyp=MATRIX_CMD; ll->m[0].data=(void *)pMat;
4684 ll->m[1].rtyp=MATRIX_CMD; ll->m[1].data=(void *)lMat;
4685 ll->m[2].rtyp=MATRIX_CMD; ll->m[2].data=(void *)uMat;
4686 res->data=(char*)ll;
4687
4688 return FALSE;
4689}
4691{
4692 // clean out "_":
4693 sLastPrinted.CleanUp();
4694 // collect all info:
4695 omUpdateInfo();
4696 switch(((int)(long)v->Data()))
4697 {
4698 case 0:
4699 res->data=(char *)n_Init(om_Info.UsedBytes,coeffs_BIGINT);
4700 break;
4701 case 1:
4702 res->data = (char *)n_Init(om_Info.CurrentBytesSystem,coeffs_BIGINT);
4703 break;
4704 case 2:
4705 res->data = (char *)n_Init(om_Info.MaxBytesSystem,coeffs_BIGINT);
4706 break;
4707 default:
4708 omPrintStats(stdout);
4709 omPrintInfo(stdout);
4710 omPrintBinStats(stdout);
4711 res->data = (char *)0;
4712 res->rtyp = NONE;
4713 }
4714 return FALSE;
4715}
4716//static BOOLEAN jjMONITOR1(leftv res, leftv v)
4717//{
4718// return jjMONITOR2(res,v,NULL);
4719//}
4721{
4722 int t=v->Typ();
4723 ideal r,m;
4724 r=kMin_std((ideal)v->Data(),currRing->qideal,testHomog,NULL,m);
4726 l->Init(2);
4727 l->m[0].rtyp=t;
4728 l->m[0].data=(char *)r;
4729 setFlag(&(l->m[0]),FLAG_STD);
4730 l->m[1].rtyp=t;
4731 l->m[1].data=(char *)m;
4732 res->data=(char *)l;
4733 return FALSE;
4734}
4736{
4738 res->data = (char *)(long)scMultInt((ideal)(v->Data()),currRing->qideal);
4739 return FALSE;
4740}
4742{
4743 intvec *weights=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
4744
4745 syStrategy tmp=syCopy((syStrategy)v->Data());
4746 tmp = syMinimize(tmp); // enrich itself!
4747
4748 res->data=(char *)tmp;
4749
4750 if (weights!=NULL)
4751 atSet(res, omStrDup("isHomog"),ivCopy(weights),INTVEC_CMD);
4752
4753 return FALSE;
4754}
4756{
4757 number n,i; i=(number)v->Data();
4759 if (nMap!=NULL)
4760 n=nMap(i,currRing->cf,coeffs_BIGINT);
4761 else goto err;
4762 res->data=(void *)n;
4763 return FALSE;
4764err:
4765 WerrorS("cannot convert to bigint"); return TRUE;
4766}
4768{
4769 if ((v->rtyp==IDHDL)||(v->rtyp==ALIAS_CMD))
4770 res->data=omStrDup(v->name);
4771 else if (v->name==NULL)
4772 res->data=omStrDup("");
4773 else
4774 {
4775 res->data = (char *)v->name;
4776 v->name=NULL;
4777 }
4778 return FALSE;
4779}
4781{
4782 res->data=ipNameList(((ring)v->Data())->idroot);
4783 return FALSE;
4784}
4786{
4787 res->data=ipNameListLev((IDROOT),(int)(long)v->Data());
4788 return FALSE;
4789}
4791{
4792 res->data=(char*)(long)((long)v->Data()==0 ? 1 : 0);
4793 return FALSE;
4794}
4796{
4797 res->data = (char *)(long)(((ring)(v->Data()))->N);
4798 return FALSE;
4799}
4801{
4802 si_link l=(si_link)v->Data();
4803 if (iiOp==OPEN_CMD) return slOpen(l, SI_LINK_OPEN,v);
4804 else { slPrepClose(l); return slClose(l);}
4805}
4807{
4808 poly p=(poly)v->Data();
4809 res->data=(char *)( p==NULL ? -1 : currRing->pFDeg(p,currRing) );
4810 return FALSE;
4811}
4813{
4814 int i=(int)(long)v->Data();
4815 int p=0;
4816 p=rPar(currRing);
4817 if ((0<i) && (i<=p))
4818 {
4819 res->data=(char *)n_Param(i,currRing);
4820 }
4821 else
4822 {
4823 Werror("par number %d out of range 1..%d",i,p);
4824 return TRUE;
4825 }
4826 return FALSE;
4827}
4829{
4830 number nn=(number)v->Data();
4831 res->data = (char *)(long)n_ParDeg(nn, currRing->cf);
4832 return FALSE;
4833}
4835{
4836 if (currRing==NULL)
4837 {
4838 WerrorS("no ring active (1)");
4839 return TRUE;
4840 }
4841 int i=(int)(long)v->Data();
4842 int p=0;
4843 if ((0<i) && (rParameter(currRing)!=NULL) && (i<=(p=rPar(currRing))))
4844 res->data=omStrDup(rParameter(currRing)[i-1]);
4845 else
4846 {
4847 Werror("par number %d out of range 1..%d",i,p);
4848 return TRUE;
4849 }
4850 return FALSE;
4851}
4853{
4854 poly p=(poly)v->Data();
4855 if (p==NULL) { res->data=(char *)n_Init(0,coeffs_BIGINT); return FALSE; }
4856 if ((pNext(p)!=NULL)|| (!pIsConstant(p)))
4857 {
4858 WerrorS("poly must be constant");
4859 return TRUE;
4860 }
4861 number i=pGetCoeff(p);
4862 number n;
4864 if (nMap!=NULL)
4865 n=nMap(i,currRing->cf,coeffs_BIGINT);
4866 else goto err;
4867 res->data=(void *)n;
4868 return FALSE;
4869err:
4870 WerrorS("cannot convert to bigint"); return TRUE;
4871}
4873{
4874 poly p=(poly)v->Data();
4875 if (p==NULL) { /*res->data=(char *)0;*/ return FALSE; }
4876 if ((pNext(p)!=NULL)|| (!pIsConstant(p)))
4877 {
4878 WerrorS("poly must be constant");
4879 return TRUE;
4880 }
4881 res->data = (char *)(long)iin_Int(pGetCoeff(p),currRing->cf);
4882 return FALSE;
4883}
4885{
4886 map mapping=(map)v->Data();
4887 syMake(res,omStrDup(mapping->preimage));
4888 return FALSE;
4889}
4891{
4892 int i = IsPrime((int)(long)(v->Data()));
4893 res->data = (char *)(long)(i > 1 ? i : 2);
4894 return FALSE;
4895}
4897{
4898 intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
4899 ideal v_id=(ideal)v->Data();
4900 if (w!=NULL)
4901 {
4902 if (!idTestHomModule(v_id,currRing->qideal,w))
4903 {
4904 WarnS("wrong weights");
4905 w=NULL;
4906 // and continue at the non-homog case below
4907 }
4908 else
4909 {
4910 w=ivCopy(w);
4911 intvec **ww=&w;
4912 res->data = (char *)idMinEmbedding(v_id,FALSE,ww);
4913 atSet(res,omStrDup("isHomog"),*ww,INTVEC_CMD);
4914 return FALSE;
4915 }
4916 }
4917 res->data = (char *)idMinEmbedding(v_id);
4918 return FALSE;
4919}
4921{
4922 number n;
4923 poly p;
4924 if (((p=(poly)v->Data())!=NULL)
4925 && (pIsConstant(p)))
4926 {
4927 n=nCopy(pGetCoeff(p));
4928 }
4929 else
4930 {
4931 n=nInit(0);
4932 }
4933 res->data = (char *)n;
4934 return FALSE;
4935}
4937{
4938 char *s= (char *)v->Data();
4939 // try system keywords
4940 for(unsigned i=0; i<sArithBase.nCmdUsed; i++)
4941 {
4942 //Print("test %d, >>%s<<, tab:>>%s<<\n",i,s,sArithBase.sCmds[i].name);
4943 if (strcmp(s, sArithBase.sCmds[i].name) == 0)
4944 {
4945 res->data = (char *)1;
4946 return FALSE;
4947 }
4948 }
4949 // try blackbox names
4950 int id;
4951 blackboxIsCmd(s,id);
4952 if (id>0)
4953 {
4954 res->data = (char *)1;
4955 }
4956 return FALSE;
4957}
4959{
4960 matrix m =(matrix)v->Data();
4961 int rank = luRank(m, 0);
4962 res->data =(char *)(long)rank;
4963 return FALSE;
4964}
4966{
4967 return jjREAD2(res,v,NULL);
4968}
4970{
4971 res->data = (char *)(long)iiRegularity((lists)v->Data());
4972 return FALSE;
4973}
4975{
4976 res->data = (char *)n_RePart((number)v->Data(),currRing->cf);
4977 return FALSE;
4978}
4980{
4981 ring r=(ring)v->Data();
4982 if (r!=NULL)
4983 {
4984 res->data = (char *)rDecompose((ring)v->Data());
4985 if (res->data!=NULL)
4986 {
4987 long mm=r->wanted_maxExp;
4988 if (mm!=0) atSet(res,omStrDup("maxExp"),(void*)mm,INT_CMD);
4989 return FALSE;
4990 }
4991 }
4992 return TRUE;
4993}
4995{
4996 coeffs r=(coeffs)v->Data();
4997 if (r!=NULL)
4998 return rDecompose_CF(res,r);
4999 return TRUE;
5000}
5002{
5003 ring r=(ring)v->Data();
5004 if (r!=NULL)
5005 res->data = (char *)rDecompose_list_cf((ring)v->Data());
5006 return (r==NULL)||(res->data==NULL);
5007}
5009{
5010 ideal i = (ideal)v->Data();
5011 res->data = (char *)i->rank;
5012 return FALSE;
5013}
5015{
5016 res->data = (char *)(long)((bigintmat*)(v->Data()))->rows();
5017 return FALSE;
5018}
5020{
5021 res->data = (char *)(long)((intvec*)(v->Data()))->rows();
5022 return FALSE;
5023}
5025{
5026 res->data = (char *)(long)rPar(((ring)v->Data()));
5027 return FALSE;
5028}
5030{
5031 res->data = (char *)(long)atoi((char*)v->Data());
5032 return FALSE;
5033}
5035{
5036 const bool bIsSCA = rIsSCA(currRing);
5037
5038 if ((currRing->qideal!=NULL) && !bIsSCA)
5039 {
5040 WerrorS("qring not supported by slimgb at the moment");
5041 return TRUE;
5042 }
5044 {
5045 WerrorS("ordering must be global for slimgb");
5046 return TRUE;
5047 }
5049 WarnS("groebner base computations with inexact coefficients can not be trusted due to rounding errors");
5050 intvec *w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
5051 // tHomog hom=testHomog;
5052 ideal u_id=(ideal)u->Data();
5053 if (w!=NULL)
5054 {
5055 if (!idTestHomModule(u_id,currRing->qideal,w))
5056 {
5057 WarnS("wrong weights");
5058 w=NULL;
5059 }
5060 else
5061 {
5062 w=ivCopy(w);
5063 // hom=isHomog;
5064 }
5065 }
5066
5067 assume(u_id->rank>=id_RankFreeModule(u_id, currRing));
5068 res->data=(char *)t_rep_gb(currRing,
5069 u_id,u_id->rank);
5070 //res->data=(char *)t_rep_gb(currRing, u_id);
5071
5073 if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
5074 return FALSE;
5075}
5077{
5078 ideal result;
5079 ideal v_id=(ideal)v->Data();
5080 intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
5081 tHomog hom=testHomog;
5082 if (w!=NULL)
5083 {
5084 if (!idTestHomModule(v_id,currRing->qideal,w))
5085 {
5086 WarnS("wrong weights");
5087 w=NULL;
5088 }
5089 else
5090 {
5091 hom=isHomog;
5092 w=ivCopy(w);
5093 }
5094 }
5095 result=kSba(v_id,currRing->qideal,hom,&w,1,0);
5097 res->data = (char *)result;
5099 if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
5100 return FALSE;
5101}
5103{
5104 ideal result;
5105 ideal v_id=(ideal)v->Data();
5106 intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
5107 tHomog hom=testHomog;
5108 if (w!=NULL)
5109 {
5110 if (!idTestHomModule(v_id,currRing->qideal,w))
5111 {
5112 WarnS("wrong weights");
5113 w=NULL;
5114 }
5115 else
5116 {
5117 hom=isHomog;
5118 w=ivCopy(w);
5119 }
5120 }
5121 result=kSba(v_id,currRing->qideal,hom,&w,(int)(long)u->Data(),0);
5123 res->data = (char *)result;
5125 if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
5126 return FALSE;
5127}
5129{
5130 ideal result;
5131 ideal v_id=(ideal)v->Data();
5132 intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
5133 tHomog hom=testHomog;
5134 if (w!=NULL)
5135 {
5136 if (!idTestHomModule(v_id,currRing->qideal,w))
5137 {
5138 WarnS("wrong weights");
5139 w=NULL;
5140 }
5141 else
5142 {
5143 hom=isHomog;
5144 w=ivCopy(w);
5145 }
5146 }
5147 result=kSba(v_id,currRing->qideal,hom,&w,(int)(long)u->Data(),(int)(long)t->Data());
5149 res->data = (char *)result;
5151 if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
5152 return FALSE;
5153}
5155{
5157 WarnS("groebner base computations with inexact coefficients can not be trusted due to rounding errors");
5158 ideal result;
5159 ideal v_id=(ideal)v->Data();
5160 intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
5161 tHomog hom=testHomog;
5162 if (w!=NULL)
5163 {
5164 if (!idTestHomModule(v_id,currRing->qideal,w))
5165 {
5166 WarnS("wrong weights");
5167 w=NULL;
5168 }
5169 else
5170 {
5171 hom=isHomog;
5172 w=ivCopy(w);
5173 }
5174 }
5175 result=kStd(v_id,currRing->qideal,hom,&w);
5177 res->data = (char *)result;
5179 if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
5180 return FALSE;
5181}
5183{
5184 res->data = (char *)idSort((ideal)v->Data());
5185 return FALSE;
5186}
5188{
5190 intvec *v=NULL;
5191 ideal f=singclap_sqrfree((poly)(u->CopyD()), &v, 0, currRing);
5192 if (f==NULL) return TRUE;
5193 ivTest(v);
5195 l->Init(2);
5196 l->m[0].rtyp=IDEAL_CMD;
5197 l->m[0].data=(void *)f;
5198 l->m[1].rtyp=INTVEC_CMD;
5199 l->m[1].data=(void *)v;
5200 res->data=(void *)l;
5201 return FALSE;
5202}
5203#if 0
5205{
5206 intvec *w=NULL;
5207 res->data = (char *)idSyzygies((ideal)v->Data(),testHomog,&w);
5208 if (w!=NULL) delete w;
5210 return FALSE;
5211}
5212#else
5213// activate, if idSyz handle module weights correctly !
5215{
5216 ideal v_id=(ideal)v->Data();
5217#ifdef HAVE_SHIFTBBA
5218 if (rIsLPRing(currRing))
5219 {
5220 if (currRing->LPncGenCount < IDELEMS(v_id))
5221 {
5222 Werror("At least %d ncgen variables are needed for this computation.", IDELEMS(v_id));
5223 return TRUE;
5224 }
5225 }
5226#endif
5227 intvec *ww=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
5228 intvec *w=NULL;
5229 tHomog hom=testHomog;
5230 if (ww!=NULL)
5231 {
5232 if (idTestHomModule(v_id,currRing->qideal,ww))
5233 {
5234 w=ivCopy(ww);
5235 int add_row_shift=w->min_in();
5236 (*w)-=add_row_shift;
5237 hom=isHomog;
5238 }
5239 else
5240 {
5241 //WarnS("wrong weights");
5242 delete ww; ww=NULL;
5243 hom=testHomog;
5244 }
5245 }
5246 else
5247 {
5248 if (v->Typ()==IDEAL_CMD)
5249 if (idHomIdeal(v_id,currRing->qideal))
5250 hom=isHomog;
5251 }
5252 ideal S=idSyzygies(v_id,hom,&w);
5253 res->data = (char *)S;
5254 if (hom==isHomog)
5255 {
5256 int vl=S->rank;
5257 intvec *vv=new intvec(vl);
5258 if ((v->Typ()==IDEAL_CMD)||(ww==NULL))
5259 {
5260 for(int i=0;i<vl;i++)
5261 {
5262 if (v_id->m[i]!=NULL)
5263 (*vv)[i]=p_Deg(v_id->m[i],currRing);
5264 }
5265 }
5266 else
5267 {
5268 p_SetModDeg(ww, currRing);
5269 for(int i=0;i<vl;i++)
5270 {
5271 if (v_id->m[i]!=NULL)
5272 (*vv)[i]=currRing->pFDeg(v_id->m[i],currRing);
5273 }
5275 }
5276 if (idTestHomModule(S,currRing->qideal,vv))
5277 atSet(res,omStrDup("isHomog"),vv,INTVEC_CMD);
5278 else
5279 delete vv;
5280 }
5281 if (w!=NULL) delete w;
5282 return FALSE;
5283}
5284#endif
5286{
5287 res->data = (char *)(long)ivTrace((intvec*)(v->Data()));
5288 return FALSE;
5289}
5291{
5292 res->data = (char *)(((bigintmat*)(v->Data()))->transpose());
5293 return FALSE;
5294}
5296{
5297 res->data = (char *)ivTranp((intvec*)(v->Data()));
5298 return FALSE;
5299}
5301{
5302#ifdef HAVE_PLURAL
5303 ring r = (ring)a->Data();
5304 //if (rIsPluralRing(r))
5305 if (r->OrdSgn==1)
5306 {
5307 res->data = rOpposite(r);
5308 }
5309 else
5310 {
5311 WarnS("opposite only for global orderings");
5312 res->data = rCopy(r);
5313 }
5314 return FALSE;
5315#else
5316 return TRUE;
5317#endif
5318}
5320{
5321#ifdef HAVE_PLURAL
5322 ring r = (ring)a->Data();
5323 if (rIsPluralRing(r))
5324 {
5325 ring s = rEnvelope(r);
5326 res->data = s;
5327 }
5328 else res->data = rCopy(r);
5329 return FALSE;
5330#else
5331 return TRUE;
5332#endif
5333}
5335{
5336#ifdef HAVE_PLURAL
5337 ideal result;
5338 ideal v_id=(ideal)a->Data();
5340 result=(ideal)twostd(v_id);
5341 else /*commutative or shiftalgebra*/
5342 {
5343 return jjSTD(res,a);
5344 }
5345 res->data = (char *)result;
5348 return FALSE;
5349#else
5350 return TRUE;
5351#endif
5352}
5354{
5355#if defined(HAVE_SHIFTBBA) || defined(HAVE_PLURAL)// do not place above jjSTD in this file because we need to reference it
5356 if (rIsLPRing(currRing))
5357 {
5359 WarnS("groebner base computations with inexact coefficients can not be trusted due to rounding errors");
5360 ideal result;
5361 ideal v_id=(ideal)v->Data();
5362 /* intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD); */
5363 /* tHomog hom=testHomog; */
5364 /* if (w!=NULL) */
5365 /* { */
5366 /* if (!idTestHomModule(v_id,currRing->qideal,w)) */
5367 /* { */
5368 /* WarnS("wrong weights"); */
5369 /* w=NULL; */
5370 /* } */
5371 /* else */
5372 /* { */
5373 /* hom=isHomog; */
5374 /* w=ivCopy(w); */
5375 /* } */
5376 /* } */
5377 /* result=kStd(v_id,currRing->qideal,hom,&w); */
5378 result = rightgb(v_id, currRing->qideal);
5380 res->data = (char *)result;
5382 /* if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD); */
5383 return FALSE;
5384 }
5385 else if (rIsPluralRing(currRing))
5386 {
5387 ideal I=(ideal)v->Data();
5388
5389 ring A = currRing;
5390 ring Aopp = rOpposite(A);
5391 currRing = Aopp;
5392 ideal Iopp = idOppose(A, I, Aopp);
5393 ideal Jopp = kStd(Iopp,currRing->qideal,testHomog,NULL);
5394 currRing = A;
5395 ideal J = idOppose(Aopp, Jopp, A);
5396
5397 id_Delete(&Iopp, Aopp);
5398 id_Delete(&Jopp, Aopp);
5399 rDelete(Aopp);
5400
5401 idSkipZeroes(J);
5402 res->data = (char *)J;
5404 return FALSE;
5405 }
5406 else
5407 {
5408 return jjSTD(res, v);
5409 }
5410#else
5411 return TRUE;
5412#endif
5413}
5415{
5416 int t=(int)(long)v->data;
5417 switch (t)
5418 {
5419 case CRING_CMD:
5420 case INT_CMD:
5421 case POLY_CMD:
5422 case VECTOR_CMD:
5423 case STRING_CMD:
5424 case INTVEC_CMD:
5425 case IDEAL_CMD:
5426 case MATRIX_CMD:
5427 case MODUL_CMD:
5428 case MAP_CMD:
5429 case PROC_CMD:
5430 case RING_CMD:
5431 case SMATRIX_CMD:
5432 //case QRING_CMD:
5433 case INTMAT_CMD:
5434 case BIGINTMAT_CMD:
5435 case BIGINTVEC_CMD:
5436 case NUMBER_CMD:
5437 #ifdef SINGULAR_4_2
5438 case CNUMBER_CMD:
5439 #endif
5440 case BIGINT_CMD:
5441 case BUCKET_CMD:
5442 case LIST_CMD:
5443 case PACKAGE_CMD:
5444 case LINK_CMD:
5445 case RESOLUTION_CMD:
5446 res->data=omStrDup(Tok2Cmdname(t)); break;
5447 case DEF_CMD:
5448 case NONE: res->data=omStrDup("none"); break;
5449 default:
5450 {
5451 if (t>MAX_TOK)
5452 res->data=omStrDup(getBlackboxName(t));
5453 else
5454 res->data=omStrDup("?unknown type?");
5455 break;
5456 }
5457 }
5458 return FALSE;
5459}
5461{
5462 res->data=(char *)(long)pIsUnivariate((poly)v->Data());
5463 return FALSE;
5464}
5466{
5467 int i=(int)(long)v->Data();
5468 if ((0<i) && (i<=currRing->N))
5469 {
5470 poly p=pOne();
5471 pSetExp(p,i,1);
5472 pSetm(p);
5473 res->data=(char *)p;
5474 }
5475 else
5476 {
5477 Werror("var number %d out of range 1..%d",i,currRing->N);
5478 return TRUE;
5479 }
5480 return FALSE;
5481}
5483{
5484 if (currRing==NULL)
5485 {
5486 WerrorS("no ring active (2)");
5487 return TRUE;
5488 }
5489 int i=(int)(long)v->Data();
5490 if ((0<i) && (i<=currRing->N))
5491 res->data=omStrDup(currRing->names[i-1]);
5492 else
5493 {
5494 Werror("var number %d out of range 1..%d",i,currRing->N);
5495 return TRUE;
5496 }
5497 return FALSE;
5498}
5500{
5502#ifdef HAVE_SHIFTBBA
5503 if (rIsLPRing(currRing))
5504 {
5506 {
5507 WerrorS("`vdim` is not implemented for letterplace rings over rings");
5508 return TRUE;
5509 }
5510 if (currRing->qideal != NULL)
5511 {
5512 WerrorS("qring not supported by `vdim` for letterplace rings at the moment");
5513 return TRUE;
5514 }
5515 int kDim = lp_kDim((ideal)(v->Data()));
5516 res->data = (char *)(long)kDim;
5517 return (kDim == -2);
5518 }
5519#endif
5520 long l=scMult0Int((ideal)v->Data(),currRing->qideal);
5521 if (l<-1L)
5522 WerrorS("int overflow in vdim");
5523 res->data = (char *)l;
5524 return FALSE;
5525}
5527{
5528// input: u: a list with links of type
5529// ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
5530// returns: -1: the read state of all links is eof or error
5531// i>0: (at least) u[i] is ready
5532 lists L = (lists)u->Data();
5533 int i = slStatusSsiL(L, -1);
5534 if(i == -2) /* error */
5535 {
5536 return TRUE;
5537 }
5538 res->data = (void*)(long)i;
5539 return FALSE;
5540}
5542{
5543// input: u: a list with links of type
5544// ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
5545// returns: -1: the read state of all links is eof or error
5546// 1: all links are ready
5547// (caution: at least one is ready, but some maybe dead)
5548 lists L = (lists)u->Data();
5549 int i;
5550 int j = -1;
5551 BOOLEAN* ignore=(BOOLEAN*)omAlloc0((L->nr+1)*sizeof(BOOLEAN));
5552 for(int nfinished = 0; nfinished <= L->nr; nfinished++)
5553 {
5554 i = slStatusSsiL(L, -1, ignore);
5555 if(i == -2) /* error */
5556 {
5557 omFreeSize(ignore,(L->nr+1)*sizeof(BOOLEAN));
5558 return TRUE;
5559 }
5560 if((i == -1)||(j==0))
5561 {
5562 j=-1;
5563 break;
5564 }
5565 if (i>0)
5566 {
5567 j=1;
5568 ignore[i-1]=TRUE;
5569 }
5570 }
5571 omFreeSize(ignore,(L->nr+1)*sizeof(BOOLEAN));
5572 res->data = (void*)(long)j;
5573 return FALSE;
5574}
5575
5576BOOLEAN jjLOAD(const char *s, BOOLEAN autoexport)
5577{
5578 char libnamebuf[1024];
5580
5581#ifdef HAVE_DYNAMIC_LOADING
5582 extern BOOLEAN load_modules(const char *newlib, char *fullpath, BOOLEAN autoexport);
5583#endif /* HAVE_DYNAMIC_LOADING */
5584 switch(LT)
5585 {
5586 default:
5587 case LT_NONE:
5588 Werror("%s: unknown type", s);
5589 break;
5590 case LT_NOTFOUND:
5591 Werror("cannot open %s", s);
5592 break;
5593
5594 case LT_SINGULAR:
5595 {
5596 char *plib = iiConvName(s);
5597 idhdl pl = IDROOT->get_level(plib,0);
5598 if (pl==NULL)
5599 {
5600 pl = enterid( plib,0, PACKAGE_CMD, &(basePack->idroot), TRUE );
5601 IDPACKAGE(pl)->language = LANG_SINGULAR;
5602 IDPACKAGE(pl)->libname=omStrDup(s);
5603 }
5604 else if (IDTYP(pl)!=PACKAGE_CMD)
5605 {
5606 Werror("can not create package `%s`",plib);
5607 omFreeBinAddr(plib);
5608 return TRUE;
5609 }
5610 else /* package */
5611 {
5612 package pa=IDPACKAGE(pl);
5613 if ((pa->language==LANG_C)
5614 || (pa->language==LANG_MIX))
5615 {
5616 Werror("can not create package `%s` - binaries exists",plib);
5617 omFreeBinAddr(plib);
5618 return TRUE;
5619 }
5620 }
5621 omFreeBinAddr(plib);
5622 package savepack=currPack;
5623 currPack=IDPACKAGE(pl);
5624 IDPACKAGE(pl)->loaded=TRUE;
5625 char libnamebuf[1024];
5626 FILE * fp = feFopen( s, "r", libnamebuf, TRUE );
5627 BOOLEAN bo=iiLoadLIB(fp, libnamebuf, s, pl, autoexport, TRUE);
5628 currPack=savepack;
5629 IDPACKAGE(pl)->loaded=(!bo);
5630 return bo;
5631 }
5632 case LT_BUILTIN:
5633 SModulFunc_t iiGetBuiltinModInit(const char*);
5634 return load_builtin(s,autoexport, iiGetBuiltinModInit(s));
5635 case LT_MACH_O:
5636 case LT_ELF:
5637 case LT_HPUX:
5638#ifdef HAVE_DYNAMIC_LOADING
5639 return load_modules(s, libnamebuf, autoexport);
5640#else /* HAVE_DYNAMIC_LOADING */
5641 WerrorS("Dynamic modules are not supported by this version of Singular");
5642 break;
5643#endif /* HAVE_DYNAMIC_LOADING */
5644 }
5645 return TRUE;
5646}
5648static void WerrorS_dummy(const char *)
5649{
5651}
5653{
5654 if (!iiGetLibStatus(s))
5655 {
5656 void (*WerrorS_save)(const char *s) = WerrorS_callback;
5659 BOOLEAN bo=jjLOAD(s,TRUE);
5660 if (TEST_OPT_PROT && (bo || (WerrorS_dummy_cnt>0)))
5661 Print("loading of >%s< failed\n",s);
5662 WerrorS_callback=WerrorS_save;
5663 errorreported=0;
5664 }
5665 return FALSE;
5666}
5667
5669{
5670 res->data = (char *)strlen((char *)v->Data());
5671 return FALSE;
5672}
5674{
5675 res->data = (char *)(long)pLength((poly)v->Data());
5676 return FALSE;
5677}
5679{
5680 res->data = (char *)(long)idElem((ideal)v->Data());
5681 return FALSE;
5682}
5684{
5685 res->data = (char *)id_FreeModule((int)(long)v->Data(), currRing);
5686 return FALSE;
5687}
5689{
5690 res->data = (char *)id_Vec2Ideal((poly)v->Data(), currRing);
5691 return FALSE;
5692}
5694{
5695 res->data = rCharStr((ring)v->Data());
5696 return FALSE;
5697}
5699{
5700 res->data = (char *)pHead((poly)v->Data());
5701 return FALSE;
5702}
5704{
5705 res->data = (char *)id_Head((ideal)v->Data(),currRing);
5707 return FALSE;
5708}
5710{
5711 res->data = (char *)idMinBase((ideal)v->Data());
5712 return FALSE;
5713}
5714#if 0 // unused
5715static BOOLEAN jjsyMinBase(leftv res, leftv v)
5716{
5717 res->data = (char *)syMinBase((ideal)v->Data());
5718 return FALSE;
5719}
5720#endif
5722{
5723 res->data = (char *)pMaxComp((poly)v->Data());
5724 return FALSE;
5725}
5727{
5728 res->data = (char *)mp_Trace((matrix)v->Data(),currRing);
5729 return FALSE;
5730}
5732{
5733 res->data = (char *)mp_Transp((matrix)v->Data(),currRing);
5734 return FALSE;
5735}
5737{
5738 res->data = rOrdStr((ring)v->Data());
5739 return FALSE;
5740}
5742{
5743 res->data = rVarStr((ring)v->Data());
5744 return FALSE;
5745}
5747{
5748 res->data = rParStr((ring)v->Data());
5749 return FALSE;
5750}
5752{
5753 res->data=(char *)(long)sySize((syStrategy)v->Data());
5754 return FALSE;
5755}
5757{
5758 res->data = (char *)(long)syDim((syStrategy)v->Data());
5759 return FALSE;
5760}
5762{
5763 res->data = (char *)id_Transp((ideal)v->Data(),currRing);
5764 return FALSE;
5765}
5767{
5768 number n=(number)u->CopyD(); // n_Int may call n_Normalize
5769 res->data=(char *)(long)iin_Int(n,currRing->cf);
5770 n_Delete(&n,currRing->cf);
5771 return FALSE;
5772}
5774{
5775 number n=(number)u->Data();
5776 res->data=(char *)(long)iin_Int(n,coeffs_BIGINT );
5777 return FALSE;
5778}
5779/*=================== operations with 3 args.: static proc =================*/
5780/* must be ordered: first operations for chars (infix ops),
5781 * then alphabetically */
5783{
5784 char *s= (char *)u->Data();
5785 int r = (int)(long)v->Data();
5786 int c = (int)(long)w->Data();
5787 int l = strlen(s);
5788
5789 if ( (r<1) || (r>l) || (c<0) )
5790 {
5791 Werror("wrong range[%d,%d] in string %s",r,c,u->Fullname());
5792 return TRUE;
5793 }
5794 res->data = (char *)omAlloc((long)(c+1));
5795 snprintf((char *)res->data,c+1,"%-*.*s",c,c,s+r-1);
5796 return FALSE;
5797}
5799{
5800 intvec *iv = (intvec *)u->Data();
5801 int r = (int)(long)v->Data();
5802 int c = (int)(long)w->Data();
5803 if ((r<1)||(r>iv->rows())||(c<1)||(c>iv->cols()))
5804 {
5805 Werror("wrong range[%d,%d] in intmat %s(%d x %d)",
5806 r,c,u->Fullname(),iv->rows(),iv->cols());
5807 return TRUE;
5808 }
5809 res->data=u->data; u->data=NULL;
5810 res->rtyp=u->rtyp; u->rtyp=0;
5811 res->name=u->name; u->name=NULL;
5812 Subexpr e=jjMakeSub(v);
5813 e->next=jjMakeSub(w);
5814 if (u->e==NULL) res->e=e;
5815 else
5816 {
5817 Subexpr h=u->e;
5818 while (h->next!=NULL) h=h->next;
5819 h->next=e;
5820 res->e=u->e;
5821 u->e=NULL;
5822 }
5823 return FALSE;
5824}
5826{
5827 bigintmat *bim = (bigintmat *)u->Data();
5828 int r = (int)(long)v->Data();
5829 int c = (int)(long)w->Data();
5830 if ((r<1)||(r>bim->rows())||(c<1)||(c>bim->cols()))
5831 {
5832 Werror("wrong range[%d,%d] in bigintmat %s(%d x %d)",
5833 r,c,u->Fullname(),bim->rows(),bim->cols());
5834 return TRUE;
5835 }
5836 res->data=u->data; u->data=NULL;
5837 res->rtyp=u->rtyp; u->rtyp=0;
5838 res->name=u->name; u->name=NULL;
5839 Subexpr e=jjMakeSub(v);
5840 e->next=jjMakeSub(w);
5841 if (u->e==NULL)
5842 res->e=e;
5843 else
5844 {
5845 Subexpr h=u->e;
5846 while (h->next!=NULL) h=h->next;
5847 h->next=e;
5848 res->e=u->e;
5849 u->e=NULL;
5850 }
5851 return FALSE;
5852}
5854{
5855 matrix m= (matrix)u->Data();
5856 int r = (int)(long)v->Data();
5857 int c = (int)(long)w->Data();
5858 //Print("gen. elem %d, %d\n",r,c);
5859 if ((r<1)||(r>MATROWS(m))||(c<1)||(c>MATCOLS(m)))
5860 {
5861 Werror("wrong range[%d,%d] in matrix %s(%d x %d)",r,c,u->Fullname(),
5862 MATROWS(m),MATCOLS(m));
5863 return TRUE;
5864 }
5865 res->data=u->data; u->data=NULL;
5866 res->rtyp=u->rtyp; u->rtyp=0;
5867 res->name=u->name; u->name=NULL;
5868 Subexpr e=jjMakeSub(v);
5869 e->next=jjMakeSub(w);
5870 if (u->e==NULL)
5871 res->e=e;
5872 else
5873 {
5874 Subexpr h=u->e;
5875 while (h->next!=NULL) h=h->next;
5876 h->next=e;
5877 res->e=u->e;
5878 u->e=NULL;
5879 }
5880 return FALSE;
5881}
5883{
5884 ideal m= (ideal)u->Data();
5885 int r = (int)(long)v->Data();
5886 int c = (int)(long)w->Data();
5887 //Print("gen. elem %d, %d\n",r,c);
5888 if ((r<1)||(r>m->rank)||(c<1)||(c>IDELEMS(m)))
5889 {
5890 Werror("wrong range[%d,%d] in matrix %s(%d x %d)",r,c,u->Fullname(),
5891 (int)m->rank,IDELEMS(m));
5892 return TRUE;
5893 }
5894 res->data=u->data; u->data=NULL;
5895 res->rtyp=u->rtyp; u->rtyp=0;
5896 res->name=u->name; u->name=NULL;
5897 Subexpr e=jjMakeSub(v);
5898 e->next=jjMakeSub(w);
5899 if (u->e==NULL)
5900 res->e=e;
5901 else
5902 {
5903 Subexpr h=u->e;
5904 while (h->next!=NULL) h=h->next;
5905 h->next=e;
5906 res->e=u->e;
5907 u->e=NULL;
5908 }
5909 return FALSE;
5910}
5912{
5913 if ((u->rtyp!=IDHDL)||(u->e!=NULL))
5914 {
5915 WerrorS("cannot build expression lists from unnamed objects");
5916 return TRUE;
5917 }
5918
5919 leftv p=NULL;
5920 intvec *iv=(intvec *)w->Data();
5921 int l;
5922 BOOLEAN nok;
5923 sleftv ut;
5924 memcpy(&ut,u,sizeof(ut));
5925 sleftv t;
5926 t.Init();
5927 t.rtyp=INT_CMD;
5928 for (l=0;l< iv->length(); l++)
5929 {
5930 t.data=(char *)(long)((*iv)[l]);
5931 if (p==NULL)
5932 {
5933 p=res;
5934 }
5935 else
5936 {
5937 p->next=(leftv)omAlloc0Bin(sleftv_bin);
5938 p=p->next;
5939 }
5940 memcpy(u,&ut,sizeof(ut));
5941 if (u->Typ() == MATRIX_CMD)
5942 nok=jjBRACK_Ma(p,u,v,&t);
5943 else if (u->Typ() == BIGINTMAT_CMD)
5944 nok=jjBRACK_Bim(p,u,v,&t);
5945 else /* INTMAT_CMD */
5946 nok=jjBRACK_Im(p,u,v,&t);
5947 if (nok)
5948 {
5949 while (res->next!=NULL)
5950 {
5951 p=res->next->next;
5953 // res->e aufraeumen !!!!
5954 res->next=p;
5955 }
5956 return TRUE;
5957 }
5958 }
5959 return FALSE;
5960}
5962{
5963 if ((u->rtyp!=IDHDL)||(u->e!=NULL))
5964 {
5965 WerrorS("cannot build expression lists from unnamed objects");
5966 return TRUE;
5967 }
5968 leftv p=NULL;
5969 intvec *iv=(intvec *)v->Data();
5970 int l;
5971 BOOLEAN nok;
5972 sleftv ut;
5973 memcpy(&ut,u,sizeof(ut));
5974 sleftv t;
5975 t.Init();
5976 t.rtyp=INT_CMD;
5977 for (l=0;l< iv->length(); l++)
5978 {
5979 t.data=(char *)(long)((*iv)[l]);
5980 if (p==NULL)
5981 {
5982 p=res;
5983 }
5984 else
5985 {
5986 p->next=(leftv)omAlloc0Bin(sleftv_bin);
5987 p=p->next;
5988 }
5989 memcpy(u,&ut,sizeof(ut));
5990 if (u->Typ() == MATRIX_CMD)
5991 nok=jjBRACK_Ma(p,u,&t,w);
5992 else if (u->Typ() == BIGINTMAT_CMD)
5993 nok=jjBRACK_Bim(p,u,&t,w);
5994 else /* INTMAT_CMD */
5995 nok=jjBRACK_Im(p,u,&t,w);
5996 if (nok)
5997 {
5998 while (res->next!=NULL)
5999 {
6000 p=res->next->next;
6002 // res->e aufraeumen !!
6003 res->next=p;
6004 }
6005 return TRUE;
6006 }
6007 }
6008 return FALSE;
6009}
6011{
6012 if ((u->rtyp!=IDHDL)||(u->e!=NULL))
6013 {
6014 WerrorS("cannot build expression lists from unnamed objects");
6015 return TRUE;
6016 }
6017 leftv p=NULL;
6018 intvec *vv=(intvec *)v->Data();
6019 intvec *wv=(intvec *)w->Data();
6020 int vl;
6021 int wl;
6022 BOOLEAN nok;
6023
6024 sleftv t1,t2,ut;
6025 memcpy(&ut,u,sizeof(ut));
6026 t1.Init();
6027 t1.rtyp=INT_CMD;
6028 t2.Init();
6029 t2.rtyp=INT_CMD;
6030 for (vl=0;vl< vv->length(); vl++)
6031 {
6032 t1.data=(char *)(long)((*vv)[vl]);
6033 for (wl=0;wl< wv->length(); wl++)
6034 {
6035 t2.data=(char *)(long)((*wv)[wl]);
6036 if (p==NULL)
6037 {
6038 p=res;
6039 }
6040 else
6041 {
6042 p->next=(leftv)omAlloc0Bin(sleftv_bin);
6043 p=p->next;
6044 }
6045 memcpy(u,&ut,sizeof(ut));
6046 if (u->Typ() == MATRIX_CMD)
6047 nok=jjBRACK_Ma(p,u,&t1,&t2);
6048 else if (u->Typ() == BIGINTMAT_CMD)
6049 nok=jjBRACK_Bim(p,u,&t1,&t2);
6050 else /* INTMAT_CMD */
6051 nok=jjBRACK_Im(p,u,&t1,&t2);
6052 if (nok)
6053 {
6054 res->CleanUp();
6055 return TRUE;
6056 }
6057 }
6058 }
6059 return FALSE;
6060}
6062{
6063 v->next=(leftv)omAllocBin(sleftv_bin);
6064 memcpy(v->next,w,sizeof(sleftv));
6065 w->Init();
6066 return jjPROC(res,u,v);
6067}
6069{
6070 u->next=(leftv)omAlloc(sizeof(sleftv));
6071 memcpy(u->next,v,sizeof(sleftv));
6072 v->Init();
6073 u->next->next=(leftv)omAlloc(sizeof(sleftv));
6074 memcpy(u->next->next,w,sizeof(sleftv));
6075 w->Init();
6076 BOOLEAN bo=iiExprArithM(res,u,'[');
6077 u->next=NULL;
6078 return bo;
6079}
6081{
6082 intvec *iv;
6083 ideal m;
6085 int k=(int)(long)w->Data();
6086 if (k>=0)
6087 {
6088 sm_CallBareiss((ideal)u->Data(),(int)(long)v->Data(),(int)(long)w->Data(),m,&iv, currRing);
6089 l->Init(2);
6090 l->m[0].rtyp=MODUL_CMD;
6091 l->m[1].rtyp=INTVEC_CMD;
6092 l->m[0].data=(void *)m;
6093 l->m[1].data=(void *)iv;
6094 }
6095 else
6096 {
6097 m=sm_CallSolv((ideal)u->Data(), currRing);
6098 l->Init(1);
6099 l->m[0].rtyp=IDEAL_CMD;
6100 l->m[0].data=(void *)m;
6101 }
6102 res->data = (char *)l;
6103 return FALSE;
6104}
6106{
6107 if ((w->rtyp!=IDHDL)||(w->e!=NULL))
6108 {
6109 WerrorS("3rd argument must be a name of a matrix");
6110 return TRUE;
6111 }
6112 ideal i=(ideal)u->Data();
6113 int rank=(int)i->rank;
6114 BOOLEAN r=jjCOEFFS_Id(res,u,v);
6115 if (r) return TRUE;
6116 mp_Monomials((matrix)res->data, rank, pVar((poly)v->Data()),(matrix)w->Data(),currRing);
6117 return FALSE;
6118}
6120{
6121 res->data=(void*)idCoeffOfKBase((ideal)(u->Data()),
6122 (ideal)(v->Data()),(poly)(w->Data()));
6123 return FALSE;
6124}
6126{
6127 if ((w->rtyp!=IDHDL)||(w->e!=NULL))
6128 {
6129 WerrorS("3rd argument must be a name of a matrix");
6130 return TRUE;
6131 }
6132 // CopyD for POLY_CMD and VECTOR_CMD are identical:
6133 poly p=(poly)u->CopyD(POLY_CMD);
6134 ideal i=idInit(1,1);
6135 i->m[0]=p;
6136 sleftv t;
6137 t.Init();
6138 t.data=(char *)i;
6139 t.rtyp=IDEAL_CMD;
6140 int rank=1;
6141 if (u->Typ()==VECTOR_CMD)
6142 {
6143 i->rank=rank=pMaxComp(p);
6144 t.rtyp=MODUL_CMD;
6145 }
6146 BOOLEAN r=jjCOEFFS_Id(res,&t,v);
6147 t.CleanUp();
6148 if (r) return TRUE;
6149 mp_Monomials((matrix)res->data, rank, pVar((poly)v->Data()),(matrix)w->Data(),currRing);
6150 return FALSE;
6151}
6153{
6154 ideal I=(ideal)u->Data();
6155 GbVariant alg=syGetAlgorithm((char*)w->Data(),currRing,I);
6156 res->data=(char *)idElimination(I,(poly)v->Data(),NULL,alg);
6157 //setFlag(res,FLAG_STD);
6158 return v->next!=NULL; //do not allow next like in eliminate(I,a(1..4))
6159}
6161{
6162 bigintmat *ww=(bigintmat*)w->Data();
6163 intvec* vvv=new intvec(1,ww->cols());
6164 for(int i=0;i<ww->cols();i++)
6165 {
6166 (*vvv)[i]=n_Int(BIMATELEM(*ww,1,i+1),coeffs_BIGINT);
6167 }
6168
6169 res->data=(char *)idElimination((ideal)u->Data(),(poly)v->Data(),
6170 vvv);
6171 delete vvv;
6172 //setFlag(res,FLAG_STD);
6173 return FALSE;
6174}
6176{
6177 /*4
6178 * look for the substring what in the string where
6179 * starting at position n
6180 * return the position of the first char of what in where
6181 * or 0
6182 */
6183 int n=(int)(long)w->Data();
6184 char *where=(char *)u->Data();
6185 char *what=(char *)v->Data();
6186 char *found;
6187 if ((1>n)||(n>(int)strlen(where)))
6188 {
6189 Werror("start position %d out of range",n);
6190 return TRUE;
6191 }
6192 found = strchr(where+n-1,*what);
6193 if (*(what+1)!='\0')
6194 {
6195 while((found !=NULL) && (strncmp(found+1,what+1,strlen(what+1))!=0))
6196 {
6197 found=strchr(found+1,*what);
6198 }
6199 }
6200 if (found != NULL)
6201 {
6202 res->data=(char *)((found-where)+1);
6203 }
6204 return FALSE;
6205}
6207{
6208 if ((int)(long)w->Data()==0)
6209 res->data=(char *)walkProc(u,v);
6210 else
6211 res->data=(char *)fractalWalkProc(u,v);
6212 setFlag( res, FLAG_STD );
6213 return FALSE;
6214}
6216{
6217 intvec *wdegree=(intvec*)w->Data();
6218 if (wdegree->length()!=currRing->N)
6219 {
6220 Werror("weight vector must have size %d, not %d",
6221 currRing->N,wdegree->length());
6222 return TRUE;
6223 }
6224 if (rField_is_Z(currRing))
6225 {
6226 PrintS("// NOTE: computation of Hilbert series etc. is being\n");
6227 PrintS("// performed for generic fibre, that is, over Q\n");
6228 }
6229 assumeStdFlag(u);
6230 intvec *module_w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
6231 if (errorreported) return TRUE;
6232
6233 switch((int)(long)v->Data())
6234 {
6235 case 1:
6236 res->data=(void *)hFirstSeries0b((ideal)u->Data(),currRing->qideal,wdegree,module_w,currRing,coeffs_BIGINT);
6237 return FALSE;
6238 case 2:
6239 res->data=(void *)hSecondSeries0b((ideal)u->Data(),currRing->qideal,wdegree,module_w,currRing,coeffs_BIGINT);
6240 return FALSE;
6241 }
6243 return TRUE;
6244}
6246{
6247 if (rField_is_Z(currRing))
6248 {
6249 PrintS("// NOTE: computation of Hilbert series etc. is being\n");
6250 PrintS("// performed for generic fibre, that is, over Q\n");
6251 }
6252 assumeStdFlag(u);
6253 ring Qt =(ring)v->Data();
6254 char *name=(char*)w->Data();
6255 poly h;
6256 if (u->Typ()==IDEAL_CMD)
6257 h=hFirstSeries0p((ideal)u->Data(),currRing->qideal,NULL,currRing,Qt);
6258 else
6259 {
6260 intvec *module_w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
6261 h=hFirstSeries0m((ideal)u->Data(),currRing->qideal,NULL,module_w,currRing,Qt);
6262 }
6263 idhdl hh=enterid(name,myynest,POLY_CMD,&(Qt->idroot),FALSE,FALSE);
6264 IDPOLY(hh)=h;
6265 return FALSE;
6266}
6268{
6269 PrintS("TODO\n");
6270 int i=pVar((poly)v->Data());
6271 if (i==0)
6272 {
6273 WerrorS("ringvar expected");
6274 return TRUE;
6275 }
6276 poly p=pOne(); pSetExp(p,i,1); pSetm(p);
6277 int d=pWTotaldegree(p);
6278 pLmDelete(p);
6279 if (d==1)
6280 res->data = (char *)id_Homogen((ideal)u->Data(), i, currRing);
6281 else
6282 WerrorS("variable must have weight 1");
6283 return (d!=1);
6284}
6286{
6287 PrintS("TODO\n");
6288 int i=pVar((poly)v->Data());
6289 if (i==0)
6290 {
6291 WerrorS("ringvar expected");
6292 return TRUE;
6293 }
6294 poly p=pOne(); pSetExp(p,i,1); pSetm(p);
6295 int d=pWTotaldegree(p);
6296 pLmDelete(p);
6297 if (d==1)
6298 res->data = (char *)p_Homogen((poly)u->Data(), i, currRing);
6299 else
6300 WerrorS("variable must have weight 1");
6301 return (d!=1);
6302}
6304{
6305 intvec *w=(intvec *)v3->Data();
6306 intvec *vw=(intvec*)v2->Data();
6307 ideal v_id=(ideal)v1->Data();
6308 res->data=(void *)(long)id_HomModuleW(v_id,currRing->qideal,vw,w,currRing);
6309 return FALSE;
6310}
6312{
6313 intvec* im= new intvec((int)(long)v->Data(),(int)(long)w->Data(), 0);
6314 intvec* arg = (intvec*) u->Data();
6315 int i, n = si_min(im->cols()*im->rows(), arg->cols()*arg->rows());
6316
6317 for (i=0; i<n; i++)
6318 {
6319 (*im)[i] = (*arg)[i];
6320 }
6321
6322 res->data = (char *)im;
6323 return FALSE;
6324}
6326{
6327 ideal I1=(ideal)u->Data();
6328 ideal I2=(ideal)v->Data();
6329 ideal I3=(ideal)w->Data();
6330 resolvente r=(resolvente)omAlloc0(3*sizeof(ideal));
6331 r[0]=I1;
6332 r[1]=I2;
6333 r[2]=I3;
6334 res->data=(char *)idMultSect(r,3);
6335 omFreeSize((ADDRESS)r,3*sizeof(ideal));
6336 return FALSE;
6337}
6339{
6340 ideal I=(ideal)u->Data();
6341 GbVariant alg=syGetAlgorithm((char*)w->Data(),currRing,I);
6342 res->data=(char *)idSect(I,(ideal)v->Data(),alg);
6344 return FALSE;
6345}
6347{
6348 int *iw=iv2array((intvec *)w->Data(),currRing);
6349 res->data = (char *)ppJetW((poly)u->Data(),(int)(long)v->Data(),iw);
6350 omFreeSize( (ADDRESS)iw, (rVar(currRing)+1)*sizeof(int) );
6351 return FALSE;
6352}
6354{
6355 if (!pIsUnit((poly)v->Data()))
6356 {
6357 WerrorS("2nd argument must be a unit");
6358 return TRUE;
6359 }
6360 res->data = (char *)p_Series((int)(long)w->Data(),(poly)u->CopyD(),(poly)v->CopyD(),NULL,currRing);
6361 return FALSE;
6362}
6364{
6365 res->data = (char *)id_JetW((ideal)u->Data(),(int)(long)v->Data(),
6366 (intvec *)w->Data(),currRing);
6367 return FALSE;
6368}
6370{
6371 if (!mp_IsDiagUnit((matrix)v->Data(), currRing))
6372 {
6373 WerrorS("2nd argument must be a diagonal matrix of units");
6374 return TRUE;
6375 }
6376 res->data = (char *)idSeries((int)(long)w->Data(),(ideal)u->CopyD(),
6377 (matrix)v->CopyD());
6378 return FALSE;
6379}
6381{
6382 /* Here's the use pattern for the minor command:
6383 minor ( matrix_expression m, int_expression minorSize,
6384 optional ideal_expression IasSB, optional int_expression k,
6385 optional string_expression algorithm,
6386 optional int_expression cachedMinors,
6387 optional int_expression cachedMonomials )
6388 This method here assumes that there are at least two arguments.
6389 - If IasSB is present, it must be a std basis. All minors will be
6390 reduced w.r.t. IasSB.
6391 - If k is absent, all non-zero minors will be computed.
6392 If k is present and k > 0, the first k non-zero minors will be
6393 computed.
6394 If k is present and k < 0, the first |k| minors (some of which
6395 may be zero) will be computed.
6396 If k is present and k = 0, an error is reported.
6397 - If algorithm is absent, all the following arguments must be absent too.
6398 In this case, a heuristic picks the best-suited algorithm (among
6399 Bareiss, Laplace, and Laplace with caching).
6400 If algorithm is present, it must be one of "Bareiss", "bareiss",
6401 "Laplace", "laplace", "Cache", "cache". In the cases "Cache" and
6402 "cache" two more arguments may be given, determining how many entries
6403 the cache may have at most, and how many cached monomials there are at
6404 most. (Cached monomials are counted over all cached polynomials.)
6405 If these two additional arguments are not provided, 200 and 100000
6406 will be used as defaults.
6407 */
6408 matrix m;
6409 leftv u=v->next;
6410 v->next=NULL;
6411 int v_typ=v->Typ();
6412 if (v_typ==MATRIX_CMD)
6413 {
6414 m = (matrix)v->Data();
6415 }
6416 else
6417 {
6418 if (v_typ==0)
6419 {
6420 Werror("`%s` is undefined",v->Fullname());
6421 return TRUE;
6422 }
6423 // try to convert to MATRIX:
6424 int ii=iiTestConvert(v_typ,MATRIX_CMD);
6425 BOOLEAN bo;
6426 sleftv tmp;
6427 if (ii>0) bo=iiConvert(v_typ,MATRIX_CMD,ii,v,&tmp);
6428 else bo=TRUE;
6429 if (bo)
6430 {
6431 Werror("cannot convert %s to matrix",Tok2Cmdname(v_typ));
6432 return TRUE;
6433 }
6434 m=(matrix)tmp.data;
6435 }
6436 const int mk = (int)(long)u->Data();
6437 bool noIdeal = true; bool noK = true; bool noAlgorithm = true;
6438 bool noCacheMinors = true; bool noCacheMonomials = true;
6439 ideal IasSB; int k; char* algorithm; int cacheMinors; int cacheMonomials;
6440
6441 /* here come the different cases of correct argument sets */
6442 if ((u->next != NULL) && (u->next->Typ() == IDEAL_CMD))
6443 {
6444 IasSB = (ideal)u->next->Data();
6445 noIdeal = false;
6446 if ((u->next->next != NULL) && (u->next->next->Typ() == INT_CMD))
6447 {
6448 k = (int)(long)u->next->next->Data();
6449 noK = false;
6450 if ((u->next->next->next != NULL) &&
6451 (u->next->next->next->Typ() == STRING_CMD))
6452 {
6453 algorithm = (char*)u->next->next->next->Data();
6454 noAlgorithm = false;
6455 if ((u->next->next->next->next != NULL) &&
6456 (u->next->next->next->next->Typ() == INT_CMD))
6457 {
6458 cacheMinors = (int)(long)u->next->next->next->next->Data();
6459 noCacheMinors = false;
6460 if ((u->next->next->next->next->next != NULL) &&
6461 (u->next->next->next->next->next->Typ() == INT_CMD))
6462 {
6463 cacheMonomials =
6464 (int)(long)u->next->next->next->next->next->Data();
6465 noCacheMonomials = false;
6466 }
6467 }
6468 }
6469 }
6470 }
6471 else if ((u->next != NULL) && (u->next->Typ() == INT_CMD))
6472 {
6473 k = (int)(long)u->next->Data();
6474 noK = false;
6475 if ((u->next->next != NULL) && (u->next->next->Typ() == STRING_CMD))
6476 {
6477 algorithm = (char*)u->next->next->Data();
6478 noAlgorithm = false;
6479 if ((u->next->next->next != NULL) &&
6480 (u->next->next->next->Typ() == INT_CMD))
6481 {
6482 cacheMinors = (int)(long)u->next->next->next->Data();
6483 noCacheMinors = false;
6484 if ((u->next->next->next->next != NULL) &&
6485 (u->next->next->next->next->Typ() == INT_CMD))
6486 {
6487 cacheMonomials = (int)(long)u->next->next->next->next->Data();
6488 noCacheMonomials = false;
6489 }
6490 }
6491 }
6492 }
6493 else if ((u->next != NULL) && (u->next->Typ() == STRING_CMD))
6494 {
6495 algorithm = (char*)u->next->Data();
6496 noAlgorithm = false;
6497 if ((u->next->next != NULL) && (u->next->next->Typ() == INT_CMD))
6498 {
6499 cacheMinors = (int)(long)u->next->next->Data();
6500 noCacheMinors = false;
6501 if ((u->next->next->next != NULL) &&
6502 (u->next->next->next->Typ() == INT_CMD))
6503 {
6504 cacheMonomials = (int)(long)u->next->next->next->Data();
6505 noCacheMonomials = false;
6506 }
6507 }
6508 }
6509
6510 /* upper case conversion for the algorithm if present */
6511 if (!noAlgorithm)
6512 {
6513 if (strcmp(algorithm, "bareiss") == 0)
6514 algorithm = (char*)"Bareiss";
6515 if (strcmp(algorithm, "laplace") == 0)
6516 algorithm = (char*)"Laplace";
6517 if (strcmp(algorithm, "cache") == 0)
6518 algorithm = (char*)"Cache";
6519 }
6520
6521 v->next=u;
6522 /* here come some tests */
6523 if (!noIdeal)
6524 {
6525 assumeStdFlag(u->next);
6526 }
6527 if ((!noK) && (k == 0))
6528 {
6529 WerrorS("Provided number of minors to be computed is zero.");
6530 return TRUE;
6531 }
6532 if ((!noAlgorithm) && (strcmp(algorithm, "Bareiss") != 0)
6533 && (strcmp(algorithm, "Laplace") != 0)
6534 && (strcmp(algorithm, "Cache") != 0))
6535 {
6536 WerrorS("Expected as algorithm one of 'B/bareiss', 'L/laplace', or 'C/cache'.");
6537 return TRUE;
6538 }
6539 if ((!noAlgorithm) && (strcmp(algorithm, "Bareiss") == 0)
6541 {
6542 Werror("Bareiss algorithm not defined over coefficient rings %s",
6543 "with zero divisors.");
6544 return TRUE;
6545 }
6546 if ((mk < 1) || (mk > m->rows()) || (mk > m->cols()))
6547 {
6548 ideal I=idInit(1,1);
6549 if (mk<1) I->m[0]=p_One(currRing);
6550 //Werror("invalid size of minors: %d (matrix is (%d x %d))", mk,
6551 // m->rows(), m->cols());
6552 res->data=(void*)I;
6553 return FALSE;
6554 }
6555 if ((!noAlgorithm) && (strcmp(algorithm, "Cache") == 0)
6556 && (noCacheMinors || noCacheMonomials))
6557 {
6558 cacheMinors = 200;
6559 cacheMonomials = 100000;
6560 }
6561
6562 /* here come the actual procedure calls */
6563 if (noAlgorithm)
6564 res->data = getMinorIdealHeuristic(m, mk, (noK ? 0 : k),
6565 (noIdeal ? 0 : IasSB), false);
6566 else if (strcmp(algorithm, "Cache") == 0)
6567 res->data = getMinorIdealCache(m, mk, (noK ? 0 : k),
6568 (noIdeal ? 0 : IasSB), 3, cacheMinors,
6569 cacheMonomials, false);
6570 else
6571 res->data = getMinorIdeal(m, mk, (noK ? 0 : k), algorithm,
6572 (noIdeal ? 0 : IasSB), false);
6573 if (v_typ!=MATRIX_CMD) idDelete((ideal *)&m);
6574 return FALSE;
6575}
6577{
6578 if ((ma->rtyp!=IDHDL)||(ma->e!=NULL))
6579 {
6580 WerrorS("3rd argument must have a name");
6581 return TRUE;
6582 }
6583 int maxl=(int)(long)v->Data();
6584 if (maxl<0)
6585 {
6586 WerrorS("length for res must not be negative");
6587 return TRUE;
6588 }
6589 syStrategy r;
6590 intvec *weights=NULL;
6591 int wmaxl=maxl;
6592 ideal u_id=(ideal)u->Data();
6593
6594 maxl--;
6595 if (/*(*/ maxl==-1 /*)*/)
6596 {
6597 maxl = currRing->N-1+2;
6598 if (currRing->qideal!=NULL)
6599 {
6600 Warn(
6601 "full resolution in a qring may be infinite, setting max length to %d",
6602 maxl+1);
6603 }
6604 }
6605 weights=(intvec*)atGet(u,"isHomog",INTVEC_CMD);
6606 if (weights!=NULL)
6607 {
6608 if (!idTestHomModule(u_id,currRing->qideal,weights))
6609 {
6610 WarnS("wrong weights given:");weights->show();PrintLn();
6611 weights=NULL;
6612 }
6613 }
6614 intvec *ww=NULL;
6615 int add_row_shift=0;
6616 if (weights!=NULL)
6617 {
6618 ww=ivCopy(weights);
6619 add_row_shift = ww->min_in();
6620 (*ww) -= add_row_shift;
6621 }
6622 unsigned save_opt=si_opt_1;
6624 u_id=(ideal)u->CopyD();
6625 ideal mat;
6626 r=syMres_with_map(u_id,maxl,ww,mat);
6627 idhdl h=(idhdl)ma->data;
6628 idDelete(&IDIDEAL(h));
6629 IDIDEAL(h)=mat;
6630 if (r->list_length>wmaxl)
6631 {
6632 for(int i=wmaxl-1;i>=r->list_length;i--)
6633 {
6634 if (r->fullres[i]!=NULL) id_Delete(&r->fullres[i],currRing);
6635 if (r->minres[i]!=NULL) id_Delete(&r->minres[i],currRing);
6636 }
6637 }
6638 r->list_length=wmaxl;
6639 res->data=(void *)r;
6640 if ((weights!=NULL) && (ww!=NULL)) { delete ww; ww=NULL; }
6641 if ((r->weights!=NULL) && (r->weights[0]!=NULL))
6642 {
6643 ww=ivCopy(r->weights[0]);
6644 if (weights!=NULL) (*ww) += add_row_shift;
6645 atSet(res,omStrDup("isHomog"),ww,INTVEC_CMD);
6646 }
6647 else
6648 {
6649 if (weights!=NULL)
6650 {
6651 atSet(res,omStrDup("isHomog"),ivCopy(weights),INTVEC_CMD);
6652 }
6653 }
6654 assume( (r->syRing != NULL) == (r->resPairs != NULL) );
6655 assume( (r->minres != NULL) || (r->fullres != NULL) );
6656 si_opt_1=save_opt;
6657 return FALSE;
6658}
6660{
6661 // u: the name of the new type
6662 // v: the parent type
6663 // w: the elements
6664 newstruct_desc d=newstructChildFromString((const char *)v->Data(),
6665 (const char *)w->Data());
6666 if (d!=NULL) newstruct_setup((const char *)u->Data(),d);
6667 return (d==NULL);
6668}
6670{
6671 // handles preimage(r,phi,i) and kernel(r,phi)
6672 idhdl h;
6673 ring rr;
6674 map mapping;
6675 BOOLEAN kernel_cmd= (iiOp==KERNEL_CMD);
6676
6677 if ((v->name==NULL) || (!kernel_cmd && (w->name==NULL)))
6678 {
6679 WerrorS("2nd/3rd arguments must have names");
6680 return TRUE;
6681 }
6682 rr=(ring)u->Data();
6683 const char *ring_name=u->Name();
6684 if ((h=rr->idroot->get(v->name,myynest))!=NULL)
6685 {
6686 if (h->typ==MAP_CMD)
6687 {
6688 mapping=IDMAP(h);
6689 idhdl preim_ring=IDROOT->get(mapping->preimage,myynest);
6690 if ((preim_ring==NULL)
6691 || (IDRING(preim_ring)!=currRing))
6692 {
6693 Werror("preimage ring `%s` is not the basering",mapping->preimage);
6694 return TRUE;
6695 }
6696 }
6697 else if (h->typ==IDEAL_CMD)
6698 {
6699 mapping=IDMAP(h);
6700 }
6701 else
6702 {
6703 Werror("`%s` is no map nor ideal",IDID(h));
6704 return TRUE;
6705 }
6706 }
6707 else
6708 {
6709 Werror("`%s` is not defined in `%s`",v->name,ring_name);
6710 return TRUE;
6711 }
6712 ideal image;
6713 if (kernel_cmd) image=idInit(1,1);
6714 else
6715 {
6716 if ((h=rr->idroot->get(w->name,myynest))!=NULL)
6717 {
6718 if (h->typ==IDEAL_CMD)
6719 {
6720 image=IDIDEAL(h);
6721 }
6722 else
6723 {
6724 Werror("`%s` is no ideal",IDID(h));
6725 return TRUE;
6726 }
6727 }
6728 else
6729 {
6730 Werror("`%s` is not defined in `%s`",w->name,ring_name);
6731 return TRUE;
6732 }
6733 }
6734 if (((currRing->qideal!=NULL) && (rHasLocalOrMixedOrdering(currRing)))
6735 || ((rr->qideal!=NULL) && (rHasLocalOrMixedOrdering(rr))))
6736 {
6737 WarnS("preimage in local qring may be wrong: use Ring::preimageLoc instead");
6738 }
6739 res->data=(char *)maGetPreimage(rr,mapping,image,currRing);
6740 if (kernel_cmd) idDelete(&image);
6741 return (res->data==NULL/* is of type ideal, should not be NULL*/);
6742}
6744{
6745 int di, k;
6746 int i=(int)(long)u->Data();
6747 int r=(int)(long)v->Data();
6748 int c=(int)(long)w->Data();
6749 if ((r<=0) || (c<=0)) return TRUE;
6750 intvec *iv = new intvec(r, c, 0);
6751 if (iv->rows()==0)
6752 {
6753 delete iv;
6754 return TRUE;
6755 }
6756 if (i!=0)
6757 {
6758 if (i<0) i = -i;
6759 di = 2 * i + 1;
6760 for (k=0; k<iv->length(); k++)
6761 {
6762 (*iv)[k] = ((siRand() % di) - i);
6763 }
6764 }
6765 res->data = (char *)iv;
6766 return FALSE;
6767}
6768#ifdef SINGULAR_4_2
6769static BOOLEAN jjRANDOM_CF(leftv res, leftv u, leftv v, leftv w)
6770// <coeff>, par1, par2 -> number2
6771{
6772 coeffs cf=(coeffs)u->Data();
6773 if ((cf==NULL) ||(cf->cfRandom==NULL))
6774 {
6775 Werror("no random function defined for coeff %d",cf->type);
6776 return TRUE;
6777 }
6778 else
6779 {
6780 number n= n_Random(siRand,(number)v->Data(),(number)w->Data(),cf);
6781 number2 nn=(number2)omAlloc(sizeof(*nn));
6782 nn->cf=cf;
6783 nn->n=n;
6784 res->data=nn;
6785 return FALSE;
6786 }
6787 return TRUE;
6788}
6789#endif
6791 int &ringvar, poly &monomexpr)
6792{
6793 monomexpr=(poly)w->Data();
6794 poly p=(poly)v->Data();
6795#if 0
6796 if (pLength(monomexpr)>1)
6797 {
6798 Werror("`%s` substitutes a ringvar only by a term",
6800 return TRUE;
6801 }
6802#endif
6803 if ((ringvar=pVar(p))==0)
6804 {
6805 if ((p!=NULL) && (currRing->cf->extRing!=NULL))
6806 {
6807 number n = pGetCoeff(p);
6808 ringvar= -n_IsParam(n, currRing);
6809 }
6810 if(ringvar==0)
6811 {
6812 WerrorS("ringvar/par expected");
6813 return TRUE;
6814 }
6815 }
6816 return FALSE;
6817}
6819{
6820 // generic conversion from polyBucket to poly:
6821 // force this to be the first try everytime
6822 poly p; int l;
6823 sBucket_pt bu=(sBucket_pt)w->CopyD();
6824 sBucketDestroyAdd(bu,&p,&l);
6825 sleftv tmpw;
6826 tmpw.Init();
6827 tmpw.rtyp=POLY_CMD;
6828 tmpw.data=p;
6829 return iiExprArith3(res, iiOp, u, v, &tmpw);
6830}
6832{
6833 int ringvar;
6834 poly monomexpr;
6835 BOOLEAN nok=jjSUBST_Test(v,w,ringvar,monomexpr);
6836 if (nok) return TRUE;
6837 poly p=(poly)u->Data();
6838 if (ringvar>0)
6839 {
6840 int mm=p_MaxExpPerVar(p,ringvar,currRing);
6841 if (!rIsLPRing(currRing) &&
6842 (monomexpr!=NULL) && (p!=NULL) && (mm!=0) &&
6843 ((unsigned long)pTotaldegree(monomexpr) > (currRing->bitmask / (unsigned long)mm/2)))
6844 {
6845 Warn("possible OVERFLOW in subst, max exponent is %ld, substituting deg %d by deg %d",currRing->bitmask/2, pTotaldegree(monomexpr), mm);
6846 //return TRUE;
6847 }
6848 if ((monomexpr==NULL)||(pNext(monomexpr)==NULL))
6849 res->data = pSubst((poly)u->CopyD(res->rtyp),ringvar,monomexpr);
6850 else
6851 res->data= pSubstPoly(p,ringvar,monomexpr);
6852 }
6853 else
6854 {
6855 if (rIsLPRing(currRing))
6856 {
6857 WerrorS("Substituting parameters not implemented for Letterplace rings.");
6858 return TRUE;
6859 }
6860 res->data=pSubstPar(p,-ringvar,monomexpr);
6861 }
6862 return FALSE;
6863}
6865{
6866 int ringvar;
6867 poly monomexpr;
6868 BOOLEAN nok=jjSUBST_Test(v,w,ringvar,monomexpr);
6869 if (nok) return TRUE;
6870 ideal id=(ideal)u->Data();
6871 if (ringvar>0)
6872 {
6873 BOOLEAN overflow=FALSE;
6874 if (!rIsLPRing(currRing) && (monomexpr!=NULL))
6875 {
6876 long deg_monexp=pTotaldegree(monomexpr);
6877 for(int i=IDELEMS(id)-1;i>=0;i--)
6878 {
6879 poly p=id->m[i];
6880 int mm=p_MaxExpPerVar(p,ringvar,currRing);
6881 if ((p!=NULL) && (mm!=0) &&
6882 ((unsigned long)deg_monexp > (currRing->bitmask / (unsigned long)mm/2)))
6883 {
6884 overflow=TRUE;
6885 break;
6886 }
6887 }
6888 }
6889 if (overflow)
6890 Warn("possible OVERFLOW in subst, max exponent is %ld",currRing->bitmask/2);
6891 if ((monomexpr==NULL)||(pNext(monomexpr)==NULL))
6892 {
6893 if (res->rtyp==MATRIX_CMD) id=(ideal)mp_Copy((matrix)id,currRing);
6894 else id=id_Copy(id,currRing);
6895 res->data = id_Subst(id, ringvar, monomexpr, currRing);
6896 }
6897 else
6898 res->data = idSubstPoly(id,ringvar,monomexpr);
6899 }
6900 else
6901 {
6902 if (rIsLPRing(currRing))
6903 {
6904 WerrorS("Substituting parameters not implemented for Letterplace rings.");
6905 return TRUE;
6906 }
6907 res->data = idSubstPar(id,-ringvar,monomexpr);
6908 }
6909 return FALSE;
6910}
6911// we do not want to have jjSUBST_Id_X inlined:
6913 int input_type);
6915{
6916 return jjSUBST_Id_X(res,u,v,w,INT_CMD);
6917}
6919{
6920 return jjSUBST_Id_X(res,u,v,w,NUMBER_CMD);
6921}
6922static BOOLEAN jjSUBST_Id_X(leftv res, leftv u, leftv v,leftv w, int input_type)
6923{
6924 sleftv tmp;
6925 tmp.Init();
6926 // do not check the result, conversion from int/number to poly works always
6927 iiConvert(input_type,POLY_CMD,iiTestConvert(input_type,POLY_CMD),w,&tmp);
6928 BOOLEAN b=jjSUBST_Id(res,u,v,&tmp);
6929 tmp.CleanUp();
6930 return b;
6931}
6933{
6934 int mi=(int)(long)v->Data();
6935 int ni=(int)(long)w->Data();
6936 if ((mi<1)||(ni<1))
6937 {
6938 Werror("converting ideal to matrix: dimensions must be positive(%dx%d)",mi,ni);
6939 return TRUE;
6940 }
6941 matrix m=mpNew(mi,ni);
6942 ideal I=(ideal)u->CopyD(IDEAL_CMD);
6943 int i=si_min(IDELEMS(I),mi*ni);
6944 //for(i=i-1;i>=0;i--)
6945 //{
6946 // m->m[i]=I->m[i];
6947 // I->m[i]=NULL;
6948 //}
6949 memcpy(m->m,I->m,i*sizeof(poly));
6950 memset(I->m,0,i*sizeof(poly));
6951 id_Delete(&I,currRing);
6952 res->data = (char *)m;
6953 return FALSE;
6954}
6956{
6957 int mi=(int)(long)v->Data();
6958 int ni=(int)(long)w->Data();
6959 if ((mi<0)||(ni<1))
6960 {
6961 Werror("converting module to matrix: dimensions must be positive(%dx%d)",mi,ni);
6962 return TRUE;
6963 }
6964 res->data = (char *)id_Module2formatedMatrix((ideal)u->CopyD(MODUL_CMD),
6965 mi,ni,currRing);
6966 return FALSE;
6967}
6969{
6970 int mi=(int)(long)v->Data();
6971 int ni=(int)(long)w->Data();
6972 if ((mi<1)||(ni<1))
6973 {
6974 Werror("converting matrix to matrix: dimensions must be positive(%dx%d)",mi,ni);
6975 return TRUE;
6976 }
6977 matrix m=mpNew(mi,ni);
6979 int r=si_min(MATROWS(I),mi);
6980 int c=si_min(MATCOLS(I),ni);
6981 int i,j;
6982 for(i=r;i>0;i--)
6983 {
6984 for(j=c;j>0;j--)
6985 {
6986 MATELEM(m,i,j)=MATELEM(I,i,j);
6987 MATELEM(I,i,j)=NULL;
6988 }
6989 }
6990 id_Delete((ideal *)&I,currRing);
6991 res->data = (char *)m;
6992 return FALSE;
6993}
6995{
6996 if (w->rtyp!=IDHDL) return TRUE; /* idhdhl required */
6997 intvec *w_u=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
6998 tHomog hom=testHomog;
6999 if (w_u!=NULL)
7000 {
7001 w_u=ivCopy(w_u);
7002 hom=isHomog;
7003 }
7004 intvec *w_v=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
7005 if (w_v!=NULL)
7006 {
7007 w_v=ivCopy(w_v);
7008 hom=isHomog;
7009 }
7010 if ((w_u!=NULL) && (w_v==NULL))
7011 w_v=ivCopy(w_u);
7012 if ((w_v!=NULL) && (w_u==NULL))
7013 w_u=ivCopy(w_v);
7014 ideal u_id=(ideal)u->Data();
7015 ideal v_id=(ideal)v->Data();
7016 if (w_u!=NULL)
7017 {
7018 if ((*w_u).compare((w_v))!=0)
7019 {
7020 WarnS("incompatible weights");
7021 delete w_u; w_u=NULL;
7022 hom=testHomog;
7023 }
7024 else
7025 {
7026 if ((!idTestHomModule(u_id,currRing->qideal,w_v))
7027 || (!idTestHomModule(v_id,currRing->qideal,w_v)))
7028 {
7029 WarnS("wrong weights");
7030 delete w_u; w_u=NULL;
7031 hom=testHomog;
7032 }
7033 }
7034 }
7035 idhdl h=(idhdl)w->data;
7036 res->data = (char *)idModulo(u_id,v_id ,hom,&w_u, &(h->data.umatrix));
7037 if (w_u!=NULL)
7038 {
7039 atSet(res,omStrDup("isHomog"),w_u,INTVEC_CMD);
7040 }
7041 delete w_v;
7042 //if (TEST_OPT_RETURN_SB) setFlag(res,FLAG_STD);
7043 return FALSE;
7044}
7046{
7047 if (w->rtyp!=IDHDL) return TRUE; /* idhdhl required */
7048 intvec *w_u=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
7049 tHomog hom=testHomog;
7050 if (w_u!=NULL)
7051 {
7052 w_u=ivCopy(w_u);
7053 hom=isHomog;
7054 }
7055 intvec *w_v=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
7056 if (w_v!=NULL)
7057 {
7058 w_v=ivCopy(w_v);
7059 hom=isHomog;
7060 }
7061 if ((w_u!=NULL) && (w_v==NULL))
7062 w_v=ivCopy(w_u);
7063 if ((w_v!=NULL) && (w_u==NULL))
7064 w_u=ivCopy(w_v);
7065 ideal u_id=(ideal)u->Data();
7066 GbVariant alg=syGetAlgorithm((char*)w->Data(),currRing,u_id);
7067 ideal v_id=(ideal)v->Data();
7068 if (w_u!=NULL)
7069 {
7070 if ((*w_u).compare((w_v))!=0)
7071 {
7072 WarnS("incompatible weights");
7073 delete w_u; w_u=NULL;
7074 hom=testHomog;
7075 }
7076 else
7077 {
7078 if ((!idTestHomModule(u_id,currRing->qideal,w_v))
7079 || (!idTestHomModule(v_id,currRing->qideal,w_v)))
7080 {
7081 WarnS("wrong weights");
7082 delete w_u; w_u=NULL;
7083 hom=testHomog;
7084 }
7085 }
7086 }
7087 res->data = (char *)idModulo(u_id,v_id ,hom,&w_u, NULL,alg);
7088 if (w_u!=NULL)
7089 {
7090 atSet(res,omStrDup("isHomog"),w_u,INTVEC_CMD);
7091 }
7092 delete w_v;
7093 //if (TEST_OPT_RETURN_SB) setFlag(res,FLAG_STD);
7094 return FALSE;
7095}
7097{
7098 int mi=(int)(long)v->Data();
7099 int ni=(int)(long)w->Data();
7100 if ((mi<0)||(ni<1))
7101 {
7102 Werror("converting to smatrix: dimensions must be positive(%dx%d)",mi,ni);
7103 return TRUE;
7104 }
7105 res->data = (char *)id_ResizeModule((ideal)u->CopyD(),
7106 mi,ni,currRing);
7107 return FALSE;
7108}
7110{
7111 if (w->rtyp!=IDHDL) return TRUE;
7112 int ul= IDELEMS((ideal)u->Data());
7113 int vl= IDELEMS((ideal)v->Data());
7114#ifdef HAVE_SHIFTBBA
7115 if (rIsLPRing(currRing))
7116 {
7117 if (currRing->LPncGenCount < ul)
7118 {
7119 Werror("At least %d ncgen variables are needed for this computation.", ul);
7120 return TRUE;
7121 }
7122 }
7123#endif
7124 ideal m
7125 = idLift((ideal)u->Data(),(ideal)v->Data(),NULL,FALSE,hasFlag(u,FLAG_STD),
7126 FALSE, (matrix *)(&(IDMATRIX((idhdl)(w->data)))));
7127 if (m==NULL) return TRUE;
7128 res->data = (char *)id_Module2formatedMatrix(m,ul,vl,currRing);
7129 return FALSE;
7130}
7132{
7133 if ((v->rtyp!=IDHDL)||(v->e!=NULL)) return TRUE;
7134 if ((w->rtyp!=IDHDL)||(w->e!=NULL)) return TRUE;
7135 idhdl hv=(idhdl)v->data;
7136 idhdl hw=(idhdl)w->data;
7137#ifdef HAVE_SHIFTBBA
7138 if (rIsLPRing(currRing))
7139 {
7140 if (currRing->LPncGenCount < IDELEMS((ideal)u->Data()))
7141 {
7142 Werror("At least %d ncgen variables are needed for this computation.", IDELEMS((ideal)u->Data()));
7143 return TRUE;
7144 }
7145 }
7146#endif
7147 // CopyD for IDEAL_CMD and MODUL_CMD are identical:
7148 res->data = (char *)idLiftStd((ideal)u->Data(),
7149 &(hv->data.umatrix),testHomog,
7150 &(hw->data.uideal));
7151 setFlag(res,FLAG_STD); v->flag=0; w->flag=0;
7152 return FALSE;
7153}
7155{
7156 if ((v->rtyp!=IDHDL)||(v->e!=NULL)) return TRUE;
7157 idhdl hv=(idhdl)v->data;
7158 GbVariant alg=syGetAlgorithm((char*)w->Data(),currRing,(ideal)u->Data());
7159#ifdef HAVE_SHIFTBBA
7160 if (rIsLPRing(currRing))
7161 {
7162 if (currRing->LPncGenCount < IDELEMS((ideal)u->Data()))
7163 {
7164 Werror("At least %d ncgen variables are needed for this computation.", IDELEMS((ideal)u->Data()));
7165 return TRUE;
7166 }
7167 }
7168#endif
7169 // CopyD for IDEAL_CMD and MODUL_CMD are identical:
7170 res->data = (char *)idLiftStd((ideal)u->Data(),
7171 &(hv->data.umatrix),testHomog,
7172 NULL,alg);
7173 setFlag(res,FLAG_STD); v->flag=0;
7174 return FALSE;
7175}
7177{
7179 if (!idIsZeroDim((ideal)v->Data()))
7180 {
7181 Werror("`%s` must be 0-dimensional",v->Name());
7182 return TRUE;
7183 }
7184 res->data = (char *)redNF((ideal)v->CopyD(),(poly)u->CopyD(),
7185 (poly)w->CopyD());
7186 return FALSE;
7187}
7189{
7191 if (!idIsZeroDim((ideal)v->Data()))
7192 {
7193 Werror("`%s` must be 0-dimensional",v->Name());
7194 return TRUE;
7195 }
7196 res->data = (char *)redNF((ideal)v->CopyD(),(ideal)u->CopyD(),
7197 (matrix)w->CopyD());
7198 return FALSE;
7199}
7201{
7203 res->data = (char *)kNF((ideal)v->Data(),currRing->qideal,(poly)u->Data(),
7204 0,(int)(long)w->Data());
7205 return FALSE;
7206}
7208{
7210 res->data = (char *)kNF((ideal)v->Data(),currRing->qideal,(ideal)u->Data(),
7211 0,(int)(long)w->Data());
7212 return FALSE;
7213}
7214#ifdef OLD_RES
7216{
7217 int maxl=(int)v->Data();
7218 ideal u_id=(ideal)u->Data();
7219 int l=0;
7220 resolvente r;
7221 intvec **weights=NULL;
7222 int wmaxl=maxl;
7223 maxl--;
7224 unsigned save_opt=si_opt_1;
7226 if ((maxl==-1) && (iiOp!=MRES_CMD))
7227 maxl = currRing->N-1;
7228 if ((iiOp == RES_CMD) || (iiOp == MRES_CMD))
7229 {
7230 intvec * iv=(intvec*)atGet(u,"isHomog",INTVEC_CMD);
7231 if (iv!=NULL)
7232 {
7233 l=1;
7234 if (!idTestHomModule(u_id,currRing->qideal,iv))
7235 {
7236 WarnS("wrong weights");
7237 iv=NULL;
7238 }
7239 else
7240 {
7241 weights = (intvec**)omAlloc0Bin(char_ptr_bin);
7242 weights[0] = ivCopy(iv);
7243 }
7244 }
7245 r=syResolvente(u_id,maxl,&l, &weights, iiOp==MRES_CMD);
7246 }
7247 else
7248 r=sySchreyerResolvente((ideal)u->Data(),maxl+1,&l);
7249 if (r==NULL) return TRUE;
7250 int t3=u->Typ();
7251 iiMakeResolv(r,l,wmaxl,w->name,t3,weights);
7252 si_opt_1=save_opt;
7253 return FALSE;
7254}
7255#endif
7257{
7258 res->data=(void *)rInit(u,v,w);
7259 return (res->data==NULL);
7260}
7262{
7263 int yes;
7264 jjSTATUS2(res, u, v);
7265 yes = (strcmp((char *) res->data, (char *) w->Data()) == 0);
7266 omFreeBinAddr((ADDRESS) res->data);
7267 res->data = (void *)(long)yes;
7268 return FALSE;
7269}
7271{
7272 intvec *vw=(intvec *)w->Data(); // weights of vars
7273 if (vw->length()!=currRing->N)
7274 {
7275 Werror("%d weights for %d variables",vw->length(),currRing->N);
7276 return TRUE;
7277 }
7278 ideal result;
7279 intvec *ww=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
7280 tHomog hom=testHomog;
7281 ideal u_id=(ideal)(u->Data());
7282 if (ww!=NULL)
7283 {
7284 if (!idTestHomModule(u_id,currRing->qideal,ww))
7285 {
7286 WarnS("wrong weights");
7287 ww=NULL;
7288 }
7289 else
7290 {
7291 ww=ivCopy(ww);
7292 hom=isHomog;
7293 }
7294 }
7295 bigintmat *vv=(bigintmat*)v->Data();
7296 intvec* vvv=new intvec(1,vv->cols());
7297 for(int i=0;i<vv->cols();i++)
7298 {
7299 (*vvv)[i]=n_Int(BIMATELEM(*vv,1,i+1),coeffs_BIGINT);
7300 }
7301 result=kStd(u_id,
7302 currRing->qideal,
7303 hom,
7304 &ww, // module weights
7305 vvv, // hilbert series
7306 0,0, // syzComp, newIdeal
7307 vw); // weights of vars
7309 delete vvv;
7310 res->data = (char *)result;
7312 if (ww!=NULL) atSet(res,omStrDup("isHomog"),ww,INTVEC_CMD);
7313 return FALSE;
7314}
7315
7316/*=================== operations with many arg.: static proc =================*/
7317/* must be ordered: first operations for chars (infix ops),
7318 * then alphabetically */
7320{
7321#ifdef HAVE_SDB
7322 sdb_show_bp();
7323#endif
7324 return FALSE;
7325}
7327{
7328#ifdef HAVE_SDB
7329 if(v->Typ()==PROC_CMD)
7330 {
7331 int lineno=0;
7332 if((v->next!=NULL) && (v->next->Typ()==INT_CMD))
7333 {
7334 lineno=(int)(long)v->next->Data();
7335 }
7336 return sdb_set_breakpoint(v->Name(),lineno);
7337 }
7338 return TRUE;
7339#else
7340 return FALSE;
7341#endif
7342}
7344{
7345 return iiExprArith1(res,v,iiOp);
7346}
7348{
7349 leftv v=u->next;
7350 u->next=NULL;
7351 BOOLEAN b=iiExprArith2(res,u,iiOp,v, (iiOp > 255));
7352 u->next=v;
7353 return b;
7354}
7356{
7357 leftv v = u->next;
7358 leftv w = v->next;
7359 u->next = NULL;
7360 v->next = NULL;
7361 BOOLEAN b = iiExprArith3(res, iiOp, u, v, w);
7362 u->next = v;
7363 v->next = w;
7364 return b;
7365}
7366
7368{
7369 const short t[]={4,VECTOR_CMD,POLY_CMD,MATRIX_CMD,MATRIX_CMD};
7370 if (iiCheckTypes(v,t,1))
7371 {
7372 idhdl c=(idhdl)v->next->next->data;
7373 if (v->next->next->next->rtyp!=IDHDL) return TRUE;
7374 idhdl m=(idhdl)v->next->next->next->data;
7375 idDelete((ideal *)&(c->data.uideal));
7376 idDelete((ideal *)&(m->data.uideal));
7377 mp_Coef2((poly)v->Data(),(poly)v->next->Data(),
7378 (matrix *)&(c->data.umatrix),(matrix *)&(m->data.umatrix),currRing);
7379 return FALSE;
7380 }
7381 return TRUE;
7382}
7383
7385{ // may have 3 or 4 arguments
7386 leftv v1=v;
7387 leftv v2=v1->next;
7388 leftv v3=v2->next;
7389 leftv v4=v3->next;
7390 assumeStdFlag(v2);
7391
7392 int i1=iiTestConvert(v1->Typ(),MODUL_CMD);
7393 int i2=iiTestConvert(v2->Typ(),MODUL_CMD);
7394
7395 if((i1==0)||(i2==0)
7396 ||(v3->Typ()!=INT_CMD)||((v4!=NULL)&&(v4->Typ()!=INTVEC_CMD)))
7397 {
7398 WarnS("<module>,<module>,<int>[,<intvec>] expected!");
7399 return TRUE;
7400 }
7401
7402 sleftv w1,w2;
7403 iiConvert(v1->Typ(),MODUL_CMD,i1,v1,&w1);
7404 iiConvert(v2->Typ(),MODUL_CMD,i2,v2,&w2);
7405 ideal P=(ideal)w1.Data();
7406 ideal Q=(ideal)w2.Data();
7407
7408 int n=(int)(long)v3->Data();
7409 int *w=NULL;
7410 if(v4!=NULL)
7411 {
7412 w = iv2array((intvec *)v4->Data(),currRing);
7413 int * w0 = w + 1;
7414 int i = currRing->N;
7415 while( (i > 0) && ((*w0) > 0) )
7416 {
7417 w0++;
7418 i--;
7419 }
7420 if(i>0)
7421 WarnS("not all weights are positive!");
7422 }
7423
7424 matrix T;
7425 ideal R;
7426 idLiftW(P,Q,n,T,R,w);
7427
7428 w1.CleanUp();
7429 w2.CleanUp();
7430 if(w!=NULL)
7431 omFreeSize( (ADDRESS)w, (rVar(currRing)+1)*sizeof(int) );
7432
7434 L->Init(2);
7435 L->m[1].rtyp=v1->Typ();
7436 if(v1->Typ()==POLY_CMD||v1->Typ()==VECTOR_CMD)
7437 {
7438 if(v1->Typ()==POLY_CMD)
7439 p_Shift(&R->m[0],-1,currRing);
7440 L->m[1].data=(void *)R->m[0];
7441 R->m[0]=NULL;
7442 idDelete(&R);
7443 }
7444 else if(v1->Typ()==IDEAL_CMD||v1->Typ()==MATRIX_CMD)
7445 L->m[1].data=(void *)id_Module2Matrix(R,currRing);
7446 else
7447 {
7448 L->m[1].rtyp=MODUL_CMD;
7449 L->m[1].data=(void *)R;
7450 }
7451 L->m[0].rtyp=MATRIX_CMD;
7452 L->m[0].data=(char *)T;
7453
7454 res->data=L;
7455
7456 return FALSE;
7457}
7458
7459//BOOLEAN jjDISPATCH(leftv res, leftv v)
7460//{
7461// WerrorS("`dispatch`: not implemented");
7462// return TRUE;
7463//}
7464
7465//static BOOLEAN jjEXPORTTO_M(leftv res, leftv u)
7466//{
7467// int l=u->listLength();
7468// if (l<2) return TRUE;
7469// BOOLEAN b;
7470// leftv v=u->next;
7471// leftv zz=v;
7472// leftv z=zz;
7473// u->next=NULL;
7474// do
7475// {
7476// leftv z=z->next;
7477// b=iiExprArith2(res,u,iiOp,z, (iiOp > 255));
7478// if (b) break;
7479// } while (z!=NULL);
7480// u->next=zz;
7481// return b;
7482//}
7484{
7485 int s=1;
7486 leftv h=v;
7487 if (h!=NULL) s=exprlist_length(h);
7488 ideal id=idInit(s,1);
7489 int rank=1;
7490 int i=0;
7491 poly p;
7492 int dest_type=POLY_CMD;
7493 if (iiOp==MODUL_CMD) dest_type=VECTOR_CMD;
7494 while (h!=NULL)
7495 {
7496 // use standard type conversions to poly/vector
7497 int ri;
7498 int ht=h->Typ();
7499 if (ht==dest_type)
7500 {
7501 p=(poly)h->CopyD();
7502 if (p!=NULL) rank=si_max(rank,(int)pMaxComp(p));
7503 }
7504 else if ((ri=iiTestConvert(ht,dest_type,dConvertTypes))!=0)
7505 {
7506 sleftv tmp;
7507 leftv hnext=h->next;
7508 h->next=NULL;
7509 iiConvert(ht,dest_type,ri,h,&tmp,dConvertTypes);
7510 h->next=hnext;
7511 p=(poly)tmp.data;
7512 if (p!=NULL) rank=si_max(rank,(int)pMaxComp(p));
7513 }
7514 else
7515 {
7516 idDelete(&id);
7517 return TRUE;
7518 }
7519 id->m[i]=p;
7520 i++;
7521 h=h->next;
7522 }
7523 id->rank=rank;
7524 res->data=(char *)id;
7525 return FALSE;
7526}
7528{
7529 ring r=(ring)u->Data();
7530 leftv v=u->next;
7531 leftv perm_var_l=v->next;
7532 leftv perm_par_l=v->next->next;
7533 if ((perm_var_l->Typ()!=INTVEC_CMD)
7534 ||((perm_par_l!=NULL)&&(perm_par_l->Typ()!=INTVEC_CMD))
7535 ||(u->Typ()!=RING_CMD))
7536 {
7537 WerrorS("fetch(<ring>,<name>[,<intvec>[,<intvec>])");
7538 return TRUE;
7539 }
7540 intvec *perm_var_v=(intvec*)perm_var_l->Data();
7541 intvec *perm_par_v=NULL;
7542 if (perm_par_l!=NULL)
7543 perm_par_v=(intvec*)perm_par_l->Data();
7544 idhdl w;
7545 nMapFunc nMap;
7546
7547 if ((w=r->idroot->get(v->Name(),myynest))!=NULL)
7548 {
7549 int *perm=NULL;
7550 int *par_perm=NULL;
7551 int par_perm_size=0;
7552 BOOLEAN bo;
7553 if ((nMap=n_SetMap(r->cf,currRing->cf))==NULL)
7554 {
7555 // Allow imap/fetch to be make an exception only for:
7556 if (nCoeff_is_Extension(r->cf) && // Q(a..) -> Q(a..) || Q || Zp || Zp(a)
7557 ((n_SetMap(r->cf->extRing->cf,currRing->cf)!=NULL)
7558 || (nCoeff_is_Extension(currRing->cf) && (n_SetMap(r->cf->extRing->cf,currRing->cf->extRing->cf)!=NULL))))
7559 {
7560 par_perm_size=rPar(r);
7561 }
7562 else
7563 {
7564 goto err_fetch;
7565 }
7566 }
7567 else
7568 par_perm_size=rPar(r);
7569 perm=(int *)omAlloc0((rVar(r)+1)*sizeof(int));
7570 if (par_perm_size!=0)
7571 par_perm=(int *)omAlloc0(par_perm_size*sizeof(int));
7572 int i;
7573 if (perm_par_l==NULL)
7574 {
7575 if (par_perm_size!=0)
7576 for(i=si_min(rPar(r),rPar(currRing))-1;i>=0;i--) par_perm[i]=-(i+1);
7577 }
7578 else
7579 {
7580 if (par_perm_size==0) WarnS("source ring has no parameters");
7581 else
7582 {
7583 for(i=rPar(r)-1;i>=0;i--)
7584 {
7585 if (i<perm_par_v->length()) par_perm[i]=(*perm_par_v)[i];
7586 if ((par_perm[i]<-rPar(currRing))
7587 || (par_perm[i]>rVar(currRing)))
7588 {
7589 Warn("invalid entry for par %d: %d\n",i,par_perm[i]);
7590 par_perm[i]=0;
7591 }
7592 }
7593 }
7594 }
7595 for(i=rVar(r)-1;i>=0;i--)
7596 {
7597 if (i<perm_var_v->length()) perm[i+1]=(*perm_var_v)[i];
7598 if ((perm[i]<-rPar(currRing))
7599 || (perm[i]>rVar(currRing)))
7600 {
7601 Warn("invalid entry for var %d: %d\n",i,perm[i]);
7602 perm[i]=0;
7603 }
7604 }
7605 if (BVERBOSE(V_IMAP))
7606 {
7607 for(i=1;i<=si_min(rVar(r),rVar(currRing));i++)
7608 {
7609 if (perm[i]>0)
7610 Print("// var nr %d: %s -> var %s\n",i,r->names[i-1],currRing->names[perm[i]-1]);
7611 else if (perm[i]<0)
7612 Print("// var nr %d: %s -> par %s\n",i,r->names[i-1],rParameter(currRing)[-perm[i]-1]);
7613 }
7614 for(i=1;i<=si_min(rPar(r),rPar(currRing));i++) // possibly empty loop
7615 {
7616 if (par_perm[i-1]<0)
7617 Print("// par nr %d: %s -> par %s\n",
7618 i,rParameter(r)[i-1],rParameter(currRing)[-par_perm[i-1]-1]);
7619 else if (par_perm[i-1]>0)
7620 Print("// par nr %d: %s -> var %s\n",
7621 i,rParameter(r)[i-1],currRing->names[par_perm[i-1]-1]);
7622 }
7623 }
7624 if (IDTYP(w)==ALIAS_CMD) w=(idhdl)IDDATA(w);
7625 sleftv tmpW;
7626 tmpW.Init();
7627 tmpW.rtyp=IDTYP(w);
7628 tmpW.data=IDDATA(w);
7629 if ((bo=maApplyFetch(IMAP_CMD,NULL,res,&tmpW, r,
7630 perm,par_perm,par_perm_size,nMap)))
7631 {
7632 Werror("cannot map %s of type %s(%d)",v->name, Tok2Cmdname(w->typ),w->typ);
7633 }
7634 if (perm!=NULL)
7635 omFreeSize((ADDRESS)perm,(rVar(r)+1)*sizeof(int));
7636 if (par_perm!=NULL)
7637 omFreeSize((ADDRESS)par_perm,par_perm_size*sizeof(int));
7638 return bo;
7639 }
7640 else
7641 {
7642 Werror("identifier %s not found in %s",v->Fullname(),u->Fullname());
7643 }
7644 return TRUE;
7645err_fetch:
7646 char *s1=nCoeffString(r->cf);
7647 char *s2=nCoeffString(currRing->cf);
7648 Werror("no identity map from %s (%s -> %s)",u->Fullname(),s1,s2);
7650 return TRUE;
7651}
7653{
7654 leftv h=v;
7655 int l=v->listLength();
7656 resolvente r=(resolvente)omAlloc0(l*sizeof(ideal));
7657 BOOLEAN *copied=(BOOLEAN *)omAlloc0(l*sizeof(BOOLEAN));
7658 int t=0;
7659 // try to convert to IDEAL_CMD
7660 while (h!=NULL)
7661 {
7662 if (iiTestConvert(h->Typ(),IDEAL_CMD)!=0)
7663 {
7664 t=IDEAL_CMD;
7665 }
7666 else break;
7667 h=h->next;
7668 }
7669 // if failure, try MODUL_CMD
7670 if (t==0)
7671 {
7672 h=v;
7673 while (h!=NULL)
7674 {
7675 if (iiTestConvert(h->Typ(),MODUL_CMD)!=0)
7676 {
7677 t=MODUL_CMD;
7678 }
7679 else break;
7680 h=h->next;
7681 }
7682 }
7683 // check for success in converting
7684 if (t==0)
7685 {
7686 WerrorS("cannot convert to ideal or module");
7687 return TRUE;
7688 }
7689 // call idMultSect
7690 h=v;
7691 int i=0;
7692 sleftv tmp;
7693 while (h!=NULL)
7694 {
7695 if (h->Typ()==t)
7696 {
7697 r[i]=(ideal)h->Data(); /*no copy*/
7698 h=h->next;
7699 }
7700 else if(iiConvert(h->Typ(),t,iiTestConvert(h->Typ(),t),h,&tmp))
7701 {
7702 omFreeSize((ADDRESS)copied,l*sizeof(BOOLEAN));
7703 omFreeSize((ADDRESS)r,l*sizeof(ideal));
7704 Werror("cannot convert arg. %d to %s",i+1,Tok2Cmdname(t));
7705 return TRUE;
7706 }
7707 else
7708 {
7709 r[i]=(ideal)tmp.Data(); /*now it's a copy*/
7710 copied[i]=TRUE;
7711 h=tmp.next;
7712 }
7713 i++;
7714 }
7715 res->rtyp=t;
7716 res->data=(char *)idMultSect(r,i);
7717 while(i>0)
7718 {
7719 i--;
7720 if (copied[i]) idDelete(&(r[i]));
7721 }
7722 omFreeSize((ADDRESS)copied,l*sizeof(BOOLEAN));
7723 omFreeSize((ADDRESS)r,l*sizeof(ideal));
7724 return FALSE;
7725}
7727{
7728 /* computation of the inverse of a quadratic matrix A
7729 using the L-U-decomposition of A;
7730 There are two valid parametrisations:
7731 1) exactly one argument which is just the matrix A,
7732 2) exactly three arguments P, L, U which already
7733 realise the L-U-decomposition of A, that is,
7734 P * A = L * U, and P, L, and U satisfy the
7735 properties decribed in method 'jjLU_DECOMP';
7736 see there;
7737 If A is invertible, the list [1, A^(-1)] is returned,
7738 otherwise the list [0] is returned. Thus, the user may
7739 inspect the first entry of the returned list to see
7740 whether A is invertible. */
7741 matrix iMat; int invertible;
7742 const short t1[]={1,MATRIX_CMD};
7743 const short t2[]={3,MATRIX_CMD,MATRIX_CMD,MATRIX_CMD};
7744 if (iiCheckTypes(v,t1))
7745 {
7746 matrix aMat = (matrix)v->Data();
7747 int rr = aMat->rows();
7748 int cc = aMat->cols();
7749 if (rr != cc)
7750 {
7751 Werror("given matrix (%d x %d) is not quadratic, hence not invertible", rr, cc);
7752 return TRUE;
7753 }
7754 if (!idIsConstant((ideal)aMat))
7755 {
7756 WerrorS("matrix must be constant");
7757 return TRUE;
7758 }
7759 invertible = luInverse(aMat, iMat);
7760 }
7761 else if (iiCheckTypes(v,t2))
7762 {
7763 matrix pMat = (matrix)v->Data();
7764 matrix lMat = (matrix)v->next->Data();
7765 matrix uMat = (matrix)v->next->next->Data();
7766 int rr = uMat->rows();
7767 int cc = uMat->cols();
7768 if (rr != cc)
7769 {
7770 Werror("third matrix (%d x %d) is not quadratic, hence not invertible",
7771 rr, cc);
7772 return TRUE;
7773 }
7774 if (!idIsConstant((ideal)pMat)
7775 || (!idIsConstant((ideal)lMat))
7776 || (!idIsConstant((ideal)uMat))
7777 )
7778 {
7779 WerrorS("matricesx must be constant");
7780 return TRUE;
7781 }
7782 invertible = luInverseFromLUDecomp(pMat, lMat, uMat, iMat);
7783 }
7784 else
7785 {
7786 Werror("expected either one or three matrices");
7787 return TRUE;
7788 }
7789
7790 /* build the return structure; a list with either one or two entries */
7792 if (invertible)
7793 {
7794 ll->Init(2);
7795 ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)invertible;
7796 ll->m[1].rtyp=MATRIX_CMD; ll->m[1].data=(void *)iMat;
7797 }
7798 else
7799 {
7800 ll->Init(1);
7801 ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)invertible;
7802 }
7803
7804 res->data=(char*)ll;
7805 return FALSE;
7806}
7808{
7809 /* for solving a linear equation system A * x = b, via the
7810 given LU-decomposition of the matrix A;
7811 There is one valid parametrisation:
7812 1) exactly four arguments P, L, U, b;
7813 P, L, and U realise the L-U-decomposition of A, that is,
7814 P * A = L * U, and P, L, and U satisfy the
7815 properties decribed in method 'jjLU_DECOMP';
7816 see there;
7817 b is the right-hand side vector of the equation system;
7818 The method will return a list of either 1 entry or three entries:
7819 1) [0] if there is no solution to the system;
7820 2) [1, x, H] if there is at least one solution;
7821 x is any solution of the given linear system,
7822 H is the matrix with column vectors spanning the homogeneous
7823 solution space.
7824 The method produces an error if matrix and vector sizes do not fit. */
7825 const short t[]={4,MATRIX_CMD,MATRIX_CMD,MATRIX_CMD,MATRIX_CMD};
7826 if (!iiCheckTypes(v,t))
7827 {
7828 WerrorS("expected exactly three matrices and one vector as input");
7829 return TRUE;
7830 }
7831 matrix pMat = (matrix)v->Data();
7832 matrix lMat = (matrix)v->next->Data();
7833 matrix uMat = (matrix)v->next->next->Data();
7834 matrix bVec = (matrix)v->next->next->next->Data();
7835 matrix xVec; int solvable; matrix homogSolSpace;
7836 if (pMat->rows() != pMat->cols())
7837 {
7838 Werror("first matrix (%d x %d) is not quadratic",
7839 pMat->rows(), pMat->cols());
7840 return TRUE;
7841 }
7842 if (lMat->rows() != lMat->cols())
7843 {
7844 Werror("second matrix (%d x %d) is not quadratic",
7845 lMat->rows(), lMat->cols());
7846 return TRUE;
7847 }
7848 if (lMat->rows() != uMat->rows())
7849 {
7850 Werror("second matrix (%d x %d) and third matrix (%d x %d) do not fit",
7851 lMat->rows(), lMat->cols(), uMat->rows(), uMat->cols());
7852 return TRUE;
7853 }
7854 if (uMat->rows() != bVec->rows())
7855 {
7856 Werror("third matrix (%d x %d) and vector (%d x 1) do not fit",
7857 uMat->rows(), uMat->cols(), bVec->rows());
7858 return TRUE;
7859 }
7860 if (!idIsConstant((ideal)pMat)
7861 ||(!idIsConstant((ideal)lMat))
7862 ||(!idIsConstant((ideal)uMat))
7863 )
7864 {
7865 WerrorS("matrices must be constant");
7866 return TRUE;
7867 }
7868 solvable = luSolveViaLUDecomp(pMat, lMat, uMat, bVec, xVec, homogSolSpace);
7869
7870 /* build the return structure; a list with either one or three entries */
7872 if (solvable)
7873 {
7874 ll->Init(3);
7875 ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)solvable;
7876 ll->m[1].rtyp=MATRIX_CMD; ll->m[1].data=(void *)xVec;
7877 ll->m[2].rtyp=MATRIX_CMD; ll->m[2].data=(void *)homogSolSpace;
7878 }
7879 else
7880 {
7881 ll->Init(1);
7882 ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)solvable;
7883 }
7884
7885 res->data=(char*)ll;
7886 return FALSE;
7887}
7889{
7890 int i=0;
7891 leftv h=v;
7892 if (h!=NULL) i=exprlist_length(h);
7893 intvec *iv=new intvec(i);
7894 i=0;
7895 while (h!=NULL)
7896 {
7897 if(h->Typ()==INT_CMD)
7898 {
7899 (*iv)[i]=(int)(long)h->Data();
7900 }
7901 else if (h->Typ()==INTVEC_CMD)
7902 {
7903 intvec *ivv=(intvec*)h->Data();
7904 for(int j=0;j<ivv->length();j++,i++)
7905 {
7906 (*iv)[i]=(*ivv)[j];
7907 }
7908 i--;
7909 }
7910 else
7911 {
7912 delete iv;
7913 return TRUE;
7914 }
7915 i++;
7916 h=h->next;
7917 }
7918 res->data=(char *)iv;
7919 return FALSE;
7920}
7922{
7923 leftv h=v;
7924 int l=0;
7925 while (h!=NULL)
7926 {
7927 if(h->Typ()==INT_CMD) l++;
7928 else if (h->Typ()==BIGINT_CMD) l++;
7929 else if (h->Typ()==INTVEC_CMD)
7930 {
7931 intvec *ivv=(intvec*)h->Data();
7932 l+=ivv->rows();
7933 }
7934 else if (h->Typ()==BIGINTVEC_CMD)
7935 {
7936 bigintmat *ivv=(bigintmat *)h->Data();
7937 l+=ivv->rows();
7938 }
7939 else return TRUE;
7940 h=h->next;
7941 }
7942 bigintmat *bim=new bigintmat(1,l,coeffs_BIGINT);
7943 h=v;
7944 int i=0;
7945 while (h!=NULL)
7946 {
7947 if(h->Typ()==INT_CMD)
7948 {
7949 number tp = n_Init((long)(h->Data()), coeffs_BIGINT);
7950 bim->set(i++, tp);
7951 n_Delete(&tp, coeffs_BIGINT);
7952 }
7953 else if (h->Typ()==INTVEC_CMD)
7954 {
7955 intvec *ivv=(intvec*)h->Data();
7956 for(int j=0;j<ivv->length();j++)
7957 {
7958 number tp = n_Init((long)(*ivv)[j], coeffs_BIGINT);
7959 bim->set(i++, tp);
7960 n_Delete(&tp, coeffs_BIGINT);
7961 }
7962 }
7963 else if(h->Typ()==BIGINT_CMD)
7964 {
7965 number tp = (number)h->Data();
7966 bim->set(i++, tp);
7967 }
7968 else if(h->Typ()==BIGINTVEC_CMD)
7969 {
7970 bigintmat *b=(bigintmat*)h->Data();
7971 for(int j=0;j<b->cols();j++)
7972 {
7973 number tp=BIMATELEM((*b),1,j);
7974 bim->set(i++, tp);
7975 }
7976 }
7977 h=h->next;
7978 }
7979 res->data=(char *)bim;
7980 return FALSE;
7981}
7983{
7984 const short t1[]={4,POLY_CMD,POLY_CMD,POLY_CMD,INTVEC_CMD};
7985 const short t2[]={4,VECTOR_CMD,POLY_CMD,POLY_CMD,INTVEC_CMD};
7986 const short t3[]={4,IDEAL_CMD,MATRIX_CMD,INT_CMD,INTVEC_CMD};
7987 const short t4[]={4,MODUL_CMD,MATRIX_CMD,INT_CMD,INTVEC_CMD};
7988 leftv u1=u;
7989 leftv u2=u1->next;
7990 leftv u3=u2->next;
7991 leftv u4=u3->next;
7992 if (iiCheckTypes(u,t1)||iiCheckTypes(u,t2))
7993 {
7994 if(!pIsUnit((poly)u2->Data()))
7995 {
7996 WerrorS("2nd argument must be a unit");
7997 return TRUE;
7998 }
7999 res->rtyp=u1->Typ();
8000 res->data=(char*)pSeries((int)(long)u3->Data(),pCopy((poly)u1->Data()),
8001 pCopy((poly)u2->Data()),(intvec*)u4->Data());
8002 return FALSE;
8003 }
8004 else
8005 if (iiCheckTypes(u,t3)||iiCheckTypes(u,t4))
8006 {
8007 if(!mp_IsDiagUnit((matrix)u2->Data(), currRing))
8008 {
8009 WerrorS("2nd argument must be a diagonal matrix of units");
8010 return TRUE;
8011 }
8012 res->rtyp=u1->Typ();
8013 res->data=(char*)idSeries(
8014 (int)(long)u3->Data(),
8015 idCopy((ideal)u1->Data()),
8016 mp_Copy((matrix)u2->Data(), currRing),
8017 (intvec*)u4->Data()
8018 );
8019 return FALSE;
8020 }
8021 else
8022 {
8023 Werror("%s(`poly`,`poly`,`int`,`intvec`) exppected",
8024 Tok2Cmdname(iiOp));
8025 return TRUE;
8026 }
8027}
8028#if 0
8029static BOOLEAN jjBRACKET_PL(leftv res, leftv u)
8030{
8031 int ut=u->Typ();
8032 leftv v=u->next; u->next=NULL;
8033 leftv w=v->next; v->next=NULL;
8034 if ((ut!=CRING_CMD)&&(ut!=RING_CMD))
8035 {
8036 BOOLEAN bo=TRUE;
8037 if (w==NULL)
8038 {
8039 bo=iiExprArith2(res,u,'[',v);
8040 }
8041 else if (w->next==NULL)
8042 {
8043 bo=iiExprArith3(res,'[',u,v,w);
8044 }
8045 v->next=w;
8046 u->next=v;
8047 return bo;
8048 }
8049 v->next=w;
8050 u->next=v;
8051 #ifdef SINGULAR_4_1
8052 // construct new rings:
8053 while (u!=NULL)
8054 {
8055 Print("name: %s,\n",u->Name());
8056 u=u->next;
8057 }
8058 #else
8059 res->Init();
8060 res->rtyp=NONE;
8061 return TRUE;
8062 #endif
8063}
8064#endif
8066{
8068 && ((strcmp(u->Name(),"real")==0) || (strcmp(u->Name(),"complex")==0)))
8069 {
8070 memcpy(res,u,sizeof(sleftv));
8071 u->Init();
8072 return FALSE;
8073 }
8074 leftv v=u->next;
8075 BOOLEAN b;
8076 if(v==NULL) // p()
8078 else if ((v->next==NULL) // p(1)
8079 || (u->Typ()!=UNKNOWN)) // p(1,2), p proc or map
8080 {
8081 u->next=NULL;
8082 b=iiExprArith2(res,u,iiOp,v);
8083 u->next=v;
8084 }
8085 else // p(1,2), p undefined
8086 {
8087 if (v->Typ()!=INT_CMD)
8088 {
8089 Werror("`%s` undefined or `int` expected while building `%s(`",u->name,u->name);
8090 return TRUE;
8091 }
8092 int l=u->listLength();
8093 size_t len=strlen(u->name) + 12*l;
8094 char * nn = (char *)omAlloc(len);
8095 snprintf(nn,len,"%s(%d",u->name,(int)(long)v->Data());
8096 char *s=nn;
8097 do
8098 {
8099 while (*s!='\0') s++;
8100 v=v->next;
8101 if (v->Typ()!=INT_CMD)
8102 {
8103 Werror("`%s` undefined or `int` expected while building `%s(`",u->name,u->name);
8104 omFree((ADDRESS)nn);
8105 return TRUE;
8106 }
8107 snprintf(s,len-(nn-s),",%d",(int)(long)v->Data());
8108 } while (v->next!=NULL);
8109 while (*s!='\0') s++;
8110 nn=strcat(nn,")");
8111 char *n=omStrDup(nn);
8112 omFree((ADDRESS)nn);
8113 syMake(res,n);
8114 b=FALSE;
8115 }
8116 return b;
8117}
8119{
8120 const short t1[]={4,IDEAL_CMD,IDEAL_CMD,MATRIX_CMD,STRING_CMD};
8121 const short t2[]={4,MODUL_CMD,MODUL_CMD,MATRIX_CMD,STRING_CMD};
8122 leftv u=U;
8123 leftv v=u->next;
8124 leftv w=v->next;
8125 leftv u4=w->next;
8126 if (w->rtyp!=IDHDL) return TRUE;
8127 if (iiCheckTypes(U,t1)||iiCheckTypes(U,t2))
8128 {
8129 // see jjLIFT3
8130 ideal I=(ideal)u->Data();
8131 int ul= IDELEMS(I /*(ideal)u->Data()*/);
8132 int vl= IDELEMS((ideal)v->Data());
8133 GbVariant alg=syGetAlgorithm((char*)u4->Data(),currRing,I);
8134 ideal m
8135 = idLift(I,(ideal)v->Data(),NULL,FALSE,hasFlag(u,FLAG_STD),
8136 FALSE, (matrix *)(&(IDMATRIX((idhdl)(w->data)))),alg);
8137 if (m==NULL) return TRUE;
8138 res->data = (char *)id_Module2formatedMatrix(m,ul,vl,currRing);
8139 return FALSE;
8140 }
8141 else
8142 {
8143 Werror("%s(`ideal`,`ideal`,`matrix`,`string`)\n"
8144 "or (`module`,`module`,`matrix`,`string`) expected",
8145 Tok2Cmdname(iiOp));
8146 return TRUE;
8147 }
8148}
8150{
8151 // we have 4 or 5 arguments
8152 leftv u=U;
8153 leftv v=u->next;
8154 leftv u3=v->next;
8155 leftv u4=u3->next;
8156 leftv u5=u4->next; // might be NULL
8157
8158 ideal *syz=NULL;
8159 GbVariant alg=GbDefault;
8160 ideal h11=NULL;
8161
8162 if(u5==NULL)
8163 {
8164 // test all three possibilities for 4 arguments
8165 const short t1[]={4,IDEAL_CMD,MATRIX_CMD,MODUL_CMD,STRING_CMD};
8166 const short t2[]={4,MODUL_CMD,MATRIX_CMD,MODUL_CMD,STRING_CMD};
8167 const short t3[]={4,IDEAL_CMD,MATRIX_CMD,MODUL_CMD,IDEAL_CMD};
8168 const short t4[]={4,MODUL_CMD,MATRIX_CMD,MODUL_CMD,MODUL_CMD};
8169 const short t5[]={4,IDEAL_CMD,MATRIX_CMD,STRING_CMD,IDEAL_CMD};
8170 const short t6[]={4,MODUL_CMD,MATRIX_CMD,STRING_CMD,MODUL_CMD};
8171
8172 if(iiCheckTypes(U,t1)||iiCheckTypes(U,t2))
8173 {
8174 if ((u3->rtyp!=IDHDL)||(u3->e!=NULL)) return TRUE;
8175 idhdl hw=(idhdl)u3->data;
8176 syz=&(hw->data.uideal);
8177 alg=syGetAlgorithm((char*)u4->Data(),currRing,(ideal)u->Data());
8178 }
8179 else if(iiCheckTypes(U,t3)||iiCheckTypes(U,t4))
8180 {
8181 if ((u3->rtyp!=IDHDL)||(u3->e!=NULL)) return TRUE;
8182 idhdl hw=(idhdl)u3->data;
8183 syz=&(hw->data.uideal);
8184 h11=(ideal)u4->Data();
8185 }
8186 else if(iiCheckTypes(U,t5)||iiCheckTypes(U,t6))
8187 {
8188 alg=syGetAlgorithm((char*)u3->Data(),currRing,(ideal)u->Data());
8189 h11=(ideal)u4->Data();
8190 }
8191 else
8192 {
8193 Werror("%s(`ideal/module`,`matrix`[,`module`][,`string`][,`ideal/module`]) expected",Tok2Cmdname(iiOp));
8194 return TRUE;
8195 }
8196 }
8197 else
8198 {
8199 // we have 5 arguments
8200 const short t1[]={5,IDEAL_CMD,MATRIX_CMD,MODUL_CMD,STRING_CMD,IDEAL_CMD};
8201 const short t2[]={5,MODUL_CMD,MATRIX_CMD,MODUL_CMD,STRING_CMD,MODUL_CMD};
8202 if(iiCheckTypes(U,t1)||iiCheckTypes(U,t2))
8203 {
8204 idhdl hw=(idhdl)u3->data;
8205 syz=&(hw->data.uideal);
8206 alg=syGetAlgorithm((char*)u4->Data(),currRing,(ideal)u->Data());
8207 h11=(ideal)u5->Data();
8208 }
8209 else
8210 {
8211 Werror("%s(`ideal/module`,`matrix`[,`module`][,`string`][,`ideal/module`]) expected",Tok2Cmdname(iiOp));
8212 return TRUE;
8213 }
8214 }
8215
8216#ifdef HAVE_SHIFTBBA
8217 if (rIsLPRing(currRing))
8218 {
8219 if (currRing->LPncGenCount < IDELEMS((ideal)u->Data()))
8220 {
8221 Werror("At least %d ncgen variables are needed for this computation.", IDELEMS((ideal)u->Data()));
8222 return TRUE;
8223 }
8224 }
8225#endif
8226
8227 if ((v->rtyp!=IDHDL)||(v->e!=NULL)) return TRUE;
8228 idhdl hv=(idhdl)v->data;
8229 // CopyD for IDEAL_CMD and MODUL_CMD are identical:
8230 res->rtyp = u->Typ();
8231 res->data = (char *)idLiftStd((ideal)u->Data(),
8232 &(hv->data.umatrix),testHomog,
8233 syz,alg,h11);
8234 setFlag(res,FLAG_STD); v->flag=0;
8235 if(syz!=NULL)
8236 u3->flag=0;
8237 return FALSE;
8238}
8240{
8241 int sl=0;
8242 if (v!=NULL) sl = v->listLength();
8243 lists L;
8244 if((sl==1)&&(v->Typ()==RESOLUTION_CMD))
8245 {
8246 int add_row_shift = 0;
8247 intvec *weights=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
8248 if (weights!=NULL) add_row_shift=weights->min_in();
8249 L=syConvRes((syStrategy)v->Data(),FALSE,add_row_shift);
8250 }
8251 else
8252 {
8254 leftv h=NULL;
8255 int i;
8256 int rt;
8257
8258 L->Init(sl);
8259 for (i=0;i<sl;i++)
8260 {
8261 if (h!=NULL)
8262 { /* e.g. not in the first step:
8263 * h is the pointer to the old sleftv,
8264 * v is the pointer to the next sleftv
8265 * (in this moment) */
8266 h->next=v;
8267 }
8268 h=v;
8269 v=v->next;
8270 h->next=NULL;
8271 rt=h->Typ();
8272 if (rt==0)
8273 {
8274 L->Clean();
8275 Werror("`%s` is undefined",h->Fullname());
8276 return TRUE;
8277 }
8278 if (rt==RING_CMD)
8279 {
8280 L->m[i].rtyp=rt;
8281 L->m[i].data=rIncRefCnt(((ring)h->Data()));
8282 }
8283 else
8284 L->m[i].Copy(h);
8285 }
8286 }
8287 res->data=(char *)L;
8288 return FALSE;
8289}
8291{
8292 leftv v=u->next;
8293 leftv w=v->next;
8294 leftv u4=w->next;
8295 GbVariant alg;
8296 ideal u_id,v_id;
8297 // we have 4 arguments
8298 const short t1[]={4,IDEAL_CMD,IDEAL_CMD,MATRIX_CMD,STRING_CMD};
8299 const short t2[]={4,MODUL_CMD,MODUL_CMD,MATRIX_CMD,STRING_CMD};
8300 if(iiCheckTypes(u,t1)||iiCheckTypes(u,t2)||(w->rtyp!=IDHDL))
8301 {
8302 u_id=(ideal)u->Data();
8303 v_id=(ideal)v->Data();
8304 alg=syGetAlgorithm((char*)u4->Data(),currRing,u_id);
8305 }
8306 else
8307 {
8308 Werror("%s(`ideal/module`,`ideal/module`[,`matrix`][,`string`]) expected",Tok2Cmdname(iiOp));
8309 return TRUE;
8310 }
8311 intvec *w_u=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
8312 tHomog hom=testHomog;
8313 if (w_u!=NULL)
8314 {
8315 w_u=ivCopy(w_u);
8316 hom=isHomog;
8317 }
8318 intvec *w_v=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
8319 if (w_v!=NULL)
8320 {
8321 w_v=ivCopy(w_v);
8322 hom=isHomog;
8323 }
8324 if ((w_u!=NULL) && (w_v==NULL))
8325 w_v=ivCopy(w_u);
8326 if ((w_v!=NULL) && (w_u==NULL))
8327 w_u=ivCopy(w_v);
8328 if (w_u!=NULL)
8329 {
8330 if ((*w_u).compare((w_v))!=0)
8331 {
8332 WarnS("incompatible weights");
8333 delete w_u; w_u=NULL;
8334 hom=testHomog;
8335 }
8336 else
8337 {
8338 if ((!idTestHomModule(u_id,currRing->qideal,w_v))
8339 || (!idTestHomModule(v_id,currRing->qideal,w_v)))
8340 {
8341 WarnS("wrong weights");
8342 delete w_u; w_u=NULL;
8343 hom=testHomog;
8344 }
8345 }
8346 }
8347 idhdl h=(idhdl)w->data;
8348 res->data = (char *)idModulo(u_id,v_id ,hom,&w_u, &(h->data.umatrix),alg);
8349 if (w_u!=NULL)
8350 {
8351 atSet(res,omStrDup("isHomog"),w_u,INTVEC_CMD);
8352 }
8353 delete w_v;
8354 //if (TEST_OPT_RETURN_SB) setFlag(res,FLAG_STD);
8355 return FALSE;
8356}
8358{
8359 res->data=(void *)ipNameList(IDROOT);
8360 return FALSE;
8361}
8363{
8364 if(v==NULL)
8365 {
8366 res->data=(char *)showOption();
8367 return FALSE;
8368 }
8369 res->rtyp=NONE;
8370 return setOption(res,v);
8371}
8373{
8374 leftv u1=u;
8375 leftv u2=u1->next;
8376 leftv u3=u2->next;
8377 leftv u4=u3->next;
8378 int u1t=u1->Typ(); if (u1t==BUCKET_CMD) u1t=POLY_CMD;
8379 int u2t=u2->Typ(); if (u2t==BUCKET_CMD) u2t=POLY_CMD;
8380 if((u3->Typ()==INT_CMD)&&(u4->Typ()==INTVEC_CMD))
8381 {
8382 int save_d=Kstd1_deg;
8383 Kstd1_deg=(int)(long)u3->Data();
8384 kModW=(intvec *)u4->Data();
8385 BITSET save2;
8386 SI_SAVE_OPT2(save2);
8388 u2->next=NULL;
8389 BOOLEAN r=jjCALL2ARG(res,u);
8390 kModW=NULL;
8391 Kstd1_deg=save_d;
8392 SI_RESTORE_OPT2(save2);
8393 u->next->next=u3;
8394 return r;
8395 }
8396 else
8397 if((u1t==IDEAL_CMD)&&(u2t==MATRIX_CMD)&&(u3->Typ()==IDEAL_CMD)&&
8398 (u4->Typ()==INT_CMD))
8399 {
8400 assumeStdFlag(u3);
8401 if(!mp_IsDiagUnit((matrix)u2->Data(), currRing))
8402 {
8403 WerrorS("2nd argument must be a diagonal matrix of units");
8404 return TRUE;
8405 }
8406 res->data=(char*)redNF(
8407 idCopy((ideal)u3->Data()),
8408 idCopy((ideal)u1->Data()),
8409 mp_Copy((matrix)u2->Data(), currRing),
8410 (int)(long)u4->Data()
8411 );
8412 return FALSE;
8413 }
8414 else
8415 if((u1t==POLY_CMD)&&(u2t==POLY_CMD)&&(u3->Typ()==IDEAL_CMD)&&
8416 (u4->Typ()==INT_CMD))
8417 {
8418 poly u1p;
8419 if (u1->Typ()==BUCKET_CMD) u1p=sBucketPeek((sBucket_pt)u1->Data());
8420 else u1p=(poly)u1->Data();
8421 poly u2p;
8422 if (u2->Typ()==BUCKET_CMD) u2p=sBucketPeek((sBucket_pt)u2->Data());
8423 else u2p=(poly)u2->Data();
8424 assumeStdFlag(u3);
8425 if(!pIsUnit(u2p))
8426 {
8427 WerrorS("2nd argument must be a unit");
8428 return TRUE;
8429 }
8430 res->rtyp=POLY_CMD;
8431 res->data=(char*)redNF((ideal)u3->CopyD(),pCopy(u1p),
8432 pCopy(u2p),(int)(long)u4->Data());
8433 return FALSE;
8434 }
8435 else
8436 {
8437 Werror("%s(`poly`,`ideal`,`int`,`intvec`) expected",Tok2Cmdname(iiOp));
8438 Werror("%s(`ideal`,`matrix`,`ideal`,`int`) expected",Tok2Cmdname(iiOp));
8439 Werror("%s(`poly`,`poly`,`ideal`,`int`) expected",Tok2Cmdname(iiOp));
8440 return TRUE;
8441 }
8442}
8444{
8445 leftv u1=u;
8446 leftv u2=u1->next;
8447 leftv u3=u2->next;
8448 leftv u4=u3->next;
8449 leftv u5=u4->next;
8450 if((u1->Typ()==IDEAL_CMD)&&(u2->Typ()==MATRIX_CMD)&&(u3->Typ()==IDEAL_CMD)&&
8451 (u4->Typ()==INT_CMD)&&(u5->Typ()==INTVEC_CMD))
8452 {
8453 assumeStdFlag(u3);
8454 if(!mp_IsDiagUnit((matrix)u2->Data(), currRing))
8455 {
8456 WerrorS("2nd argument must be a diagonal matrix of units");
8457 return TRUE;
8458 }
8459 res->data=(char*)redNF(
8460 idCopy((ideal)u3->Data()),
8461 idCopy((ideal)u1->Data()),
8462 mp_Copy((matrix)u2->Data(),currRing),
8463 (int)(long)u4->Data(),
8464 (intvec*)u5->Data()
8465 );
8466 return FALSE;
8467 }
8468 else
8469 if((u1->Typ()==POLY_CMD)&&(u2->Typ()==POLY_CMD)&&(u3->Typ()==IDEAL_CMD)&&
8470 (u4->Typ()==INT_CMD)&&(u5->Typ()==INTVEC_CMD))
8471 {
8472 assumeStdFlag(u3);
8473 if(!pIsUnit((poly)u2->Data()))
8474 {
8475 WerrorS("2nd argument must be a unit");
8476 return TRUE;
8477 }
8478 res->rtyp=POLY_CMD;
8479 res->data=(char*)redNF(idCopy((ideal)u3->Data()),pCopy((poly)u1->Data()),
8480 pCopy((poly)u2->Data()),
8481 (int)(long)u4->Data(),(intvec*)u5->Data());
8482 return FALSE;
8483 }
8484 else
8485 {
8486 Werror("%s(`ideal`,`ideal`,`matrix`,`int`,`intvec`) exppected",
8487 Tok2Cmdname(iiOp));
8488 return TRUE;
8489 }
8490}
8492{
8493 unsigned i=1;
8494 unsigned nCount = (sArithBase.nCmdUsed-1)/3;
8495 if((3*nCount)<sArithBase.nCmdUsed) nCount++;
8496 //Print("CMDS: %d/%d\n", sArithBase.nCmdUsed,
8497 // sArithBase.nCmdAllocated);
8498 for(i=0; i<nCount; i++)
8499 {
8500 Print("%-20s",sArithBase.sCmds[i+1].name);
8501 if(i+1+nCount<sArithBase.nCmdUsed)
8502 Print("%-20s",sArithBase.sCmds[i+1+nCount].name);
8503 if(i+1+2*nCount<sArithBase.nCmdUsed)
8504 Print("%-20s",sArithBase.sCmds[i+1+2*nCount].name);
8505 //if ((i%3)==1) PrintLn();
8506 PrintLn();
8507 }
8508 PrintLn();
8510 return FALSE;
8511}
8512
8514{
8515 int l = 0;
8516 int k = 0;
8518 struct blackbox_list *bb_list = NULL;
8519 unsigned nCount = (sArithBase.nCmdUsed-1) / 3;
8520
8521 if ((3*nCount) < sArithBase.nCmdUsed)
8522 {
8523 nCount++;
8524 }
8525 bb_list = getBlackboxTypes();
8526 // count the number of entries;
8527 for (unsigned i=0; i<nCount; i++)
8528 {
8529 l++;
8530 if (i + 1 + nCount < sArithBase.nCmdUsed)
8531 {
8532 l++;
8533 }
8534 if(i+1+2*nCount<sArithBase.nCmdUsed)
8535 {
8536 l++;
8537 }
8538 }
8539 for (int i = 0; i < bb_list->count; i++)
8540 {
8541 if (bb_list->list[i] != NULL)
8542 {
8543 l++;
8544 }
8545 }
8546 // initiate list
8547 L->Init(l);
8548 k = 0;
8549 for (unsigned i=0; i<nCount; i++)
8550 {
8551 L->m[k].rtyp = STRING_CMD;
8552 L->m[k].data = omStrDup(sArithBase.sCmds[i+1].name);
8553 k++;
8554 // Print("%-20s", sArithBase.sCmds[i+1].name);
8555 if (i + 1 + nCount < sArithBase.nCmdUsed)
8556 {
8557 L->m[k].rtyp = STRING_CMD;
8558 L->m[k].data = omStrDup(sArithBase.sCmds[i+1+nCount].name);
8559 k++;
8560 // Print("%-20s", sArithBase.sCmds[i+1 + nCount].name);
8561 }
8562 if(i+1+2*nCount<sArithBase.nCmdUsed)
8563 {
8564 L->m[k].rtyp = STRING_CMD;
8565 L->m[k].data = omStrDup(sArithBase.sCmds[i+1+2*nCount].name);
8566 k++;
8567 // Print("%-20s", sArithBase.sCmds[i+1+2*nCount].name);
8568 }
8569 // PrintLn();
8570 }
8571
8572 // assign blackbox types
8573 for (int i = 0; i < bb_list->count; i++)
8574 {
8575 if (bb_list->list[i] != NULL)
8576 {
8577 L->m[k].rtyp = STRING_CMD;
8578 // already used strdup in getBlackBoxTypes
8579 L->m[k].data = bb_list->list[i];
8580 k++;
8581 }
8582 }
8583 // free the struct (not the list entries itself, which were allocated
8584 // by strdup)
8585 omfree(bb_list->list);
8586 omfree(bb_list);
8587
8588 // pass the resultant list to the res datastructure
8589 res->data=(void *)L;
8590
8591 return FALSE;
8592}
8594{
8595 if (v == NULL)
8596 {
8597 res->data = omStrDup("");
8598 return FALSE;
8599 }
8600 int n = v->listLength();
8601 if (n == 1)
8602 {
8603 res->data = v->String();
8604 return FALSE;
8605 }
8606
8607 char** slist = (char**) omAlloc(n*sizeof(char*));
8608 int i, j;
8609
8610 for (i=0, j=0; i<n; i++, v = v ->next)
8611 {
8612 slist[i] = v->String();
8613 assume(slist[i] != NULL);
8614 j+=strlen(slist[i]);
8615 }
8616 char* s = (char*) omAlloc((j+1)*sizeof(char));
8617 *s='\0';
8618 for (i=0;i<n;i++)
8619 {
8620 strcat(s, slist[i]);
8621 omFree(slist[i]);
8622 }
8623 omFreeSize(slist, n*sizeof(char*));
8624 res->data = s;
8625 return FALSE;
8626}
8628{
8629 do
8630 {
8631 if (v->Typ()!=INT_CMD)
8632 return TRUE;
8633 test_cmd((int)(long)v->Data());
8634 v=v->next;
8635 }
8636 while (v!=NULL);
8637 return FALSE;
8638}
8639
8640#if defined(__alpha) && !defined(linux)
8641extern "C"
8642{
8643 void usleep(unsigned long usec);
8644};
8645#endif
8647{
8648 /* compute two factors of h(x,y) modulo x^(d+1) in K[[x]][y],
8649 see a detailed documentation in /kernel/linear_algebra/linearAlgebra.h
8650
8651 valid argument lists:
8652 - (poly h, int d),
8653 - (poly h, int d, poly f0, poly g0), optional: factors of h(0,y),
8654 - (poly h, int d, int xIndex, int yIndex), optional: indices of vars x & y
8655 in list of ring vars,
8656 - (poly h, int d, poly f0, poly g0, int xIndex, int yIndec),
8657 optional: all 4 optional args
8658 (The defaults are xIndex = 1, yIndex = 2, f0 and g0 polynomials as found
8659 by singclap_factorize and h(0, y)
8660 has exactly two distinct monic factors [possibly with exponent > 1].)
8661 result:
8662 - list with the two factors f and g such that
8663 h(x,y) = f(x,y)*g(x,y) mod x^(d+1) */
8664
8665 poly h = NULL;
8666 int d = 1;
8667 poly f0 = NULL;
8668 poly g0 = NULL;
8669 int xIndex = 1; /* default index if none provided */
8670 int yIndex = 2; /* default index if none provided */
8671
8672 leftv u = v; int factorsGiven = 0;
8673 if ((u == NULL) || (u->Typ() != POLY_CMD))
8674 {
8675 WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
8676 return TRUE;
8677 }
8678 else h = (poly)u->Data();
8679 u = u->next;
8680 if ((u == NULL) || (u->Typ() != INT_CMD))
8681 {
8682 WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
8683 return TRUE;
8684 }
8685 else d = (int)(long)u->Data();
8686 u = u->next;
8687 if ((u != NULL) && (u->Typ() == POLY_CMD))
8688 {
8689 if ((u->next == NULL) || (u->next->Typ() != POLY_CMD))
8690 {
8691 WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
8692 return TRUE;
8693 }
8694 else
8695 {
8696 f0 = (poly)u->Data();
8697 g0 = (poly)u->next->Data();
8698 factorsGiven = 1;
8699 u = u->next->next;
8700 }
8701 }
8702 if ((u != NULL) && (u->Typ() == INT_CMD))
8703 {
8704 if ((u->next == NULL) || (u->next->Typ() != INT_CMD))
8705 {
8706 WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
8707 return TRUE;
8708 }
8709 else
8710 {
8711 xIndex = (int)(long)u->Data();
8712 yIndex = (int)(long)u->next->Data();
8713 u = u->next->next;
8714 }
8715 }
8716 if (u != NULL)
8717 {
8718 WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
8719 return TRUE;
8720 }
8721
8722 /* checks for provided arguments */
8723 if (pIsConstant(h) || (factorsGiven && (pIsConstant(f0) || pIsConstant(g0))))
8724 {
8725 WerrorS("expected non-constant polynomial argument(s)");
8726 return TRUE;
8727 }
8728 int n = rVar(currRing);
8729 if ((xIndex < 1) || (n < xIndex))
8730 {
8731 Werror("index for variable x (%d) out of range [1..%d]", xIndex, n);
8732 return TRUE;
8733 }
8734 if ((yIndex < 1) || (n < yIndex))
8735 {
8736 Werror("index for variable y (%d) out of range [1..%d]", yIndex, n);
8737 return TRUE;
8738 }
8739 if (xIndex == yIndex)
8740 {
8741 WerrorS("expected distinct indices for variables x and y");
8742 return TRUE;
8743 }
8744
8745 /* computation of f0 and g0 if missing */
8746 if (factorsGiven == 0)
8747 {
8748 poly h0 = pSubst(pCopy(h), xIndex, NULL);
8749 intvec* v = NULL;
8750 ideal i = singclap_factorize(h0, &v, 0,currRing);
8751
8752 ivTest(v);
8753
8754 if (i == NULL) return TRUE;
8755
8756 idTest(i);
8757
8758 if ((v->rows() != 3) || ((*v)[0] =! 1) || (!nIsOne(pGetCoeff(i->m[0]))))
8759 {
8760 WerrorS("expected h(0,y) to have exactly two distinct monic factors");
8761 return TRUE;
8762 }
8763 f0 = pPower(pCopy(i->m[1]), (*v)[1]);
8764 g0 = pPower(pCopy(i->m[2]), (*v)[2]);
8765 idDelete(&i);
8766 }
8767
8768 poly f; poly g;
8769 henselFactors(xIndex, yIndex, h, f0, g0, d, f, g);
8771 L->Init(2);
8772 L->m[0].rtyp = POLY_CMD; L->m[0].data=(void*)f;
8773 L->m[1].rtyp = POLY_CMD; L->m[1].data=(void*)g;
8774 res->rtyp = LIST_CMD;
8775 res->data = (char*)L;
8776 return FALSE;
8777}
8779{
8780 if ((v->Typ() != LINK_CMD) ||
8781 (v->next->Typ() != STRING_CMD) ||
8782 (v->next->next->Typ() != STRING_CMD) ||
8783 (v->next->next->next->Typ() != INT_CMD))
8784 return TRUE;
8785 jjSTATUS3(res, v, v->next, v->next->next);
8786#if defined(HAVE_USLEEP)
8787 if (((long) res->data) == 0L)
8788 {
8789 int i_s = (int)(long) v->next->next->next->Data();
8790 if (i_s > 0)
8791 {
8792 usleep((int)(long) v->next->next->next->Data());
8793 jjSTATUS3(res, v, v->next, v->next->next);
8794 }
8795 }
8796#elif defined(HAVE_SLEEP)
8797 if (((int) res->data) == 0)
8798 {
8799 int i_s = (int) v->next->next->next->Data();
8800 if (i_s > 0)
8801 {
8802 si_sleep((is - 1)/1000000 + 1);
8803 jjSTATUS3(res, v, v->next, v->next->next);
8804 }
8805 }
8806#endif
8807 return FALSE;
8808}
8810{
8811 leftv v = u->next; // number of args > 0
8812 if (v==NULL) return TRUE;
8813 leftv w = v->next;
8814 if (w==NULL) return TRUE;
8815 leftv rest = w->next;
8816
8817 u->next = NULL;
8818 v->next = NULL;
8819 w->next = NULL;
8820 BOOLEAN b = iiExprArith3(res, iiOp, u, v, w);
8821 if ((rest!=NULL) && (!b))
8822 {
8823 leftv tmp_next=res->next;
8824 res->next=rest;
8825 sleftv tmp_res;
8826 tmp_res.Init();
8827 b = iiExprArithM(&tmp_res,res,iiOp);
8828 memcpy(res,&tmp_res,sizeof(tmp_res));
8829 res->next=tmp_next;
8830 }
8831 u->next = v;
8832 v->next = w;
8833 // rest was w->next, but is already cleaned
8834 return b;
8835}
8837{
8838 if ((INPUT->Typ() != MATRIX_CMD) ||
8839 (INPUT->next->Typ() != NUMBER_CMD) ||
8840 (INPUT->next->next->Typ() != NUMBER_CMD) ||
8841 (INPUT->next->next->next->Typ() != NUMBER_CMD))
8842 {
8843 WerrorS("expected (matrix, number, number, number) as arguments");
8844 return TRUE;
8845 }
8846 leftv u = INPUT; leftv v = u->next; leftv w = v->next; leftv x = w->next;
8847 res->data = (char *)qrDoubleShift((matrix)(u->Data()),
8848 (number)(v->Data()),
8849 (number)(w->Data()),
8850 (number)(x->Data()));
8851 return FALSE;
8852}
8854{ ideal result;
8855 leftv u = INPUT; /* an ideal, weighted homogeneous and standard */
8856 leftv v = u->next; /* one additional polynomial or ideal */
8857 leftv h = v->next; /* Hilbert vector */
8858 leftv w = h->next; /* weight vector */
8859 assumeStdFlag(u);
8860 ideal i1=(ideal)(u->Data());
8861 ideal i0;
8862 if (((u->Typ()!=IDEAL_CMD)&&(u->Typ()!=MODUL_CMD))
8863 || (h->Typ()!=INTVEC_CMD)
8864 || (w->Typ()!=INTVEC_CMD))
8865 {
8866 WerrorS("expected `std(`ideal/module`,`poly/vector`,`intvec`,`intvec`)");
8867 return TRUE;
8868 }
8869 intvec *vw=(intvec *)w->Data(); // weights of vars
8870 /* merging std_hilb_w and std_1 */
8871 if (vw->length()!=currRing->N)
8872 {
8873 Werror("%d weights for %d variables",vw->length(),currRing->N);
8874 return TRUE;
8875 }
8876 int r=v->Typ();
8877 BOOLEAN cleanup_i0=FALSE;
8878 if ((r==POLY_CMD) ||(r==VECTOR_CMD))
8879 {
8880 i0=idInit(1,i1->rank);
8881 i0->m[0]=(poly)v->Data();
8882 cleanup_i0=TRUE;
8883 }
8884 else if (r==IDEAL_CMD)/* IDEAL */
8885 {
8886 i0=(ideal)v->Data();
8887 }
8888 else
8889 {
8890 WerrorS("expected `std(`ideal/module`,`poly/vector`,`intvec`,`intvec`)");
8891 return TRUE;
8892 }
8893 int ii0=idElem(i0);
8894 i1 = idSimpleAdd(i1,i0);
8895 if (cleanup_i0)
8896 {
8897 memset(i0->m,0,sizeof(poly)*IDELEMS(i0));
8898 idDelete(&i0);
8899 }
8900 intvec *ww=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
8901 tHomog hom=testHomog;
8902 /* u_id from jjSTD_W is now i1 as in jjSTD_1 */
8903 if (ww!=NULL)
8904 {
8905 if (!idTestHomModule(i1,currRing->qideal,ww))
8906 {
8907 WarnS("wrong weights");
8908 ww=NULL;
8909 }
8910 else
8911 {
8912 ww=ivCopy(ww);
8913 hom=isHomog;
8914 }
8915 }
8916 BITSET save1;
8917 SI_SAVE_OPT1(save1);
8919 result=kStd(i1,
8920 currRing->qideal,
8921 hom,
8922 &ww, // module weights
8923 (intvec *)h->Data(), // hilbert series
8924 0, // syzComp, whatever it is...
8925 IDELEMS(i1)-ii0, // new ideal
8926 vw); // weights of vars
8927 SI_RESTORE_OPT1(save1);
8928 idDelete(&i1);
8930 res->data = (char *)result;
8932 if (ww!=NULL) atSet(res,omStrDup("isHomog"),ww,INTVEC_CMD);
8933 return FALSE;
8934}
8935
8937{
8938 //Print("construct ring\n");
8939 if (a->Typ()!=CRING_CMD)
8940 {
8941 WerrorS("expected `cring` [ `id` ... ]");
8942 return TRUE;
8943 }
8944 assume(a->next!=NULL);
8945 leftv names=a->next;
8946 int N=names->listLength();
8947 char **n=(char**)omAlloc0(N*sizeof(char*));
8948 for(int i=0; i<N;i++,names=names->next)
8949 {
8950 n[i]=(char *)names->Name();
8951 }
8952 coeffs cf=(coeffs)a->CopyD();
8953 res->data=rDefault(cf,N,n, ringorder_dp);
8954 omFreeSize(n,N*sizeof(char*));
8955 return FALSE;
8956}
8957
8958static Subexpr jjMakeSub(leftv e)
8959{
8960 assume( e->Typ()==INT_CMD );
8961 Subexpr r=(Subexpr)omAlloc0Bin(sSubexpr_bin);
8962 r->start =(int)(long)e->Data();
8963 return r;
8964}
8966{
8967 int c=(int)(long)u->Data();
8968 switch(c)
8969 {
8970 case 0:{
8971 PrintS("delete all variables\n");
8972 killlocals(0);
8973 WerrorS("restarting...");
8974 break;
8975 };
8976 default: WerrorS("not implemented");
8977 }
8978 return FALSE;
8979}
8980#define D(A) (A)
8981#define NULL_VAL NULL
8982#define IPARITH
8983#include "table.h"
8984
8985#include "iparith.inc"
8986
8987/*=================== operations with 2 args. ============================*/
8988/* must be ordered: first operations for chars (infix ops),
8989 * then alphabetically */
8990
8992 BOOLEAN proccall,
8993 const struct sValCmd2* dA2,
8994 int at, int bt,
8995 const struct sConvertTypes *dConvertTypes)
8996{
8997 BOOLEAN call_failed=FALSE;
8998
8999 if (!errorreported)
9000 {
9001 int i=0;
9002 iiOp=op;
9003 while (dA2[i].cmd==op)
9004 {
9005 if ((at==dA2[i].arg1)
9006 && (bt==dA2[i].arg2))
9007 {
9008 res->rtyp=dA2[i].res;
9009 if (currRing!=NULL)
9010 {
9011 if (check_valid(dA2[i].valid_for,op)) break;
9012 }
9013 else
9014 {
9015 if (RingDependend(dA2[i].res))
9016 {
9017 WerrorS("no ring active (3)");
9018 break;
9019 }
9020 }
9021 if (traceit&TRACE_CALL)
9022 Print("call %s(%s,%s)\n",iiTwoOps(op),Tok2Cmdname(at),Tok2Cmdname(bt));
9023 if ((call_failed=dA2[i].p(res,a,b)))
9024 {
9025 break;// leave loop, goto error handling
9026 }
9027 a->CleanUp();
9028 b->CleanUp();
9029 //Print("op: %d,result typ:%d\n",op,res->rtyp);
9030 return FALSE;
9031 }
9032 i++;
9033 }
9034 // implicite type conversion ----------------------------------------------
9035 if (dA2[i].cmd!=op)
9036 {
9037 int ai,bi;
9040 BOOLEAN failed=FALSE;
9041 i=0; /*iiTabIndex(dArithTab2,JJTAB2LEN,op);*/
9042 //Print("op: %c, type: %s %s\n",op,Tok2Cmdname(at),Tok2Cmdname(bt));
9043 while (dA2[i].cmd==op)
9044 {
9045 //Print("test %s %s\n",Tok2Cmdname(dA2[i].arg1),Tok2Cmdname(dA2[i].arg2));
9046 if ((dA2[i].valid_for & NO_CONVERSION)==0)
9047 {
9048 if ((ai=iiTestConvert(at,dA2[i].arg1,dConvertTypes))!=0)
9049 {
9050 if ((bi=iiTestConvert(bt,dA2[i].arg2,dConvertTypes))!=0)
9051 {
9052 res->rtyp=dA2[i].res;
9053 if (currRing!=NULL)
9054 {
9055 if (check_valid(dA2[i].valid_for,op)) break;
9056 }
9057 else
9058 {
9059 if (RingDependend(dA2[i].res))
9060 {
9061 WerrorS("no ring active (4)");
9062 break;
9063 }
9064 }
9065 if (traceit&TRACE_CALL)
9066 Print("call %s(%s,%s)\n",iiTwoOps(op),
9067 Tok2Cmdname(dA2[i].arg1),Tok2Cmdname(dA2[i].arg2));
9068 failed= ((iiConvert(at,dA2[i].arg1,ai,a,an))
9069 || (iiConvert(bt,dA2[i].arg2,bi,b,bn))
9070 || (call_failed=dA2[i].p(res,an,bn)));
9071 // everything done, clean up temp. variables
9072 if (failed)
9073 {
9074 // leave loop, goto error handling
9075 break;
9076 }
9077 else
9078 {
9079 // everything ok, clean up and return
9080 an->CleanUp();
9081 bn->CleanUp();
9084 return FALSE;
9085 }
9086 }
9087 }
9088 }
9089 i++;
9090 }
9091 an->CleanUp();
9092 bn->CleanUp();
9095 }
9096 // error handling ---------------------------------------------------
9097 const char *s=NULL;
9098 if (!errorreported)
9099 {
9100 if ((at==0) && (a->Fullname()!=sNoName_fe))
9101 {
9102 s=a->Fullname();
9103 }
9104 else if ((bt==0) && (b->Fullname()!=sNoName_fe))
9105 {
9106 s=b->Fullname();
9107 }
9108 if (s!=NULL)
9109 Werror("`%s` is not defined",s);
9110 else
9111 {
9112 i=0; /*iiTabIndex(dArithTab2,JJTAB2LEN,op);*/
9113 s = iiTwoOps(op);
9114 if (proccall)
9115 {
9116 Werror("%s(`%s`,`%s`) failed"
9117 ,s,Tok2Cmdname(at),Tok2Cmdname(bt));
9118 }
9119 else
9120 {
9121 Werror("`%s` %s `%s` failed"
9122 ,Tok2Cmdname(at),s,Tok2Cmdname(bt));
9123 }
9124 if ((!call_failed) && BVERBOSE(V_SHOW_USE))
9125 {
9126 while (dA2[i].cmd==op)
9127 {
9128 if(((at==dA2[i].arg1)||(bt==dA2[i].arg2))
9129 && (dA2[i].res!=0)
9130 && (dA2[i].p!=jjWRONG2))
9131 {
9132 if (proccall)
9133 Werror("expected %s(`%s`,`%s`)"
9134 ,s,Tok2Cmdname(dA2[i].arg1),Tok2Cmdname(dA2[i].arg2));
9135 else
9136 Werror("expected `%s` %s `%s`"
9137 ,Tok2Cmdname(dA2[i].arg1),s,Tok2Cmdname(dA2[i].arg2));
9138 }
9139 i++;
9140 }
9141 }
9142 }
9143 }
9144 a->CleanUp();
9145 b->CleanUp();
9146 res->rtyp = UNKNOWN;
9147 }
9148 return TRUE;
9149}
9151 const struct sValCmd2* dA2,
9152 int at,
9153 const struct sConvertTypes *dConvertTypes)
9154{
9155 res->Init();
9156 leftv b=a->next;
9157 a->next=NULL;
9158 int bt=b->Typ();
9160 a->next=b;
9161 a->CleanUp(); // to clean up the chain, content already done in iiExprArith2TabIntern
9162 return bo;
9163}
9165{
9166 res->Init();
9167
9168 if (!errorreported)
9169 {
9170#ifdef SIQ
9171 if (siq>0)
9172 {
9173 //Print("siq:%d\n",siq);
9175 memcpy(&d->arg1,a,sizeof(sleftv));
9176 a->Init();
9177 memcpy(&d->arg2,b,sizeof(sleftv));
9178 b->Init();
9179 d->argc=2;
9180 d->op=op;
9181 res->data=(char *)d;
9182 res->rtyp=COMMAND;
9183 return FALSE;
9184 }
9185#endif
9186 int at=a->Typ();
9187 int bt=b->Typ();
9188 // handling bb-objects ----------------------------------------------------
9189 if (at>MAX_TOK)
9190 {
9191 blackbox *bb=getBlackboxStuff(at);
9192 if (bb!=NULL)
9193 {
9194 if(!bb->blackbox_Op2(op,res,a,b)) return FALSE;
9195 // if not defined, try generic (attrib, ..)
9196 }
9197 else
9198 return TRUE;
9199 }
9200 else if ((bt>MAX_TOK)&&(op!='('))
9201 {
9202 blackbox *bb=getBlackboxStuff(bt);
9203 if (bb!=NULL)
9204 {
9205 if(!bb->blackbox_Op2(op,res,a,b)) return FALSE;
9206 // if not defined, try generic (attrib, ..)
9207 }
9208 else
9209 return TRUE;
9210 }
9211 int i=iiTabIndex(dArithTab2,JJTAB2LEN,op);
9212 return iiExprArith2TabIntern(res,a,op,b,proccall,dArith2+i,at,bt,dConvertTypes);
9213 }
9214 a->CleanUp();
9215 b->CleanUp();
9216 return TRUE;
9217}
9218
9219/*==================== operations with 1 arg. ===============================*/
9220/* must be ordered: first operations for chars (infix ops),
9221 * then alphabetically */
9222
9223BOOLEAN iiExprArith1Tab(leftv res, leftv a, int op, const struct sValCmd1* dA1, int at, const struct sConvertTypes *dConvertTypes)
9224{
9225 res->Init();
9226 BOOLEAN call_failed=FALSE;
9227
9228 if (!errorreported)
9229 {
9230 BOOLEAN failed=FALSE;
9231 iiOp=op;
9232 int i = 0;
9233 while (dA1[i].cmd==op)
9234 {
9235 if (at==dA1[i].arg)
9236 {
9237 if (currRing!=NULL)
9238 {
9239 if (check_valid(dA1[i].valid_for,op)) break;
9240 }
9241 else
9242 {
9243 if (RingDependend(dA1[i].res))
9244 {
9245 WerrorS("no ring active (5)");
9246 break;
9247 }
9248 }
9249 if (traceit&TRACE_CALL)
9250 Print("call %s(%s)\n",iiTwoOps(op),Tok2Cmdname(at));
9251 res->rtyp=dA1[i].res;
9252 if ((call_failed=dA1[i].p(res,a)))
9253 {
9254 break;// leave loop, goto error handling
9255 }
9256 if (a->Next()!=NULL)
9257 {
9259 failed=iiExprArith1(res->next,a->next,op);
9260 }
9261 a->CleanUp();
9262 return failed;
9263 }
9264 i++;
9265 }
9266 // implicite type conversion --------------------------------------------
9267 if (dA1[i].cmd!=op)
9268 {
9270 i=0;
9271 //Print("fuer %c , typ: %s\n",op,Tok2Cmdname(at));
9272 while (dA1[i].cmd==op)
9273 {
9274 int ai;
9275 //Print("test %s\n",Tok2Cmdname(dA1[i].arg));
9276 if ((dA1[i].valid_for & NO_CONVERSION)==0)
9277 {
9278 if ((ai=iiTestConvert(at,dA1[i].arg,dConvertTypes))!=0)
9279 {
9280 if (currRing!=NULL)
9281 {
9282 if (check_valid(dA1[i].valid_for,op)) break;
9283 }
9284 else
9285 {
9286 if (RingDependend(dA1[i].res))
9287 {
9288 WerrorS("no ring active (6)");
9289 break;
9290 }
9291 }
9292 if (traceit&TRACE_CALL)
9293 Print("call %s(%s)\n",iiTwoOps(op),Tok2Cmdname(dA1[i].arg));
9294 res->rtyp=dA1[i].res;
9295 failed= ((iiConvert(at,dA1[i].arg,ai,a,an,dConvertTypes))
9296 || (call_failed=dA1[i].p(res,an)));
9297 // everything done, clean up temp. variables
9298 if (failed)
9299 {
9300 // leave loop, goto error handling
9301 break;
9302 }
9303 else
9304 {
9305 if (an->Next() != NULL)
9306 {
9307 res->next = (leftv)omAllocBin(sleftv_bin);
9308 failed=iiExprArith1(res->next,an->next,op);
9309 }
9310 // everything ok, clean up and return
9311 an->CleanUp();
9313 return failed;
9314 }
9315 }
9316 }
9317 i++;
9318 }
9319 an->CleanUp();
9321 }
9322 // error handling
9323 if (!errorreported)
9324 {
9325 if ((at==0) && (a->Fullname()!=sNoName_fe))
9326 {
9327 Werror("`%s` is not defined",a->Fullname());
9328 }
9329 else
9330 {
9331 i=0;
9332 const char *s = iiTwoOps(op);
9333 Werror("%s(`%s`) failed"
9334 ,s,Tok2Cmdname(at));
9335 if ((!call_failed) && BVERBOSE(V_SHOW_USE))
9336 {
9337 while (dA1[i].cmd==op)
9338 {
9339 if ((dA1[i].res!=0)
9340 && (dA1[i].p!=jjWRONG))
9341 Werror("expected %s(`%s`)"
9342 ,s,Tok2Cmdname(dA1[i].arg));
9343 i++;
9344 }
9345 }
9346 }
9347 }
9348 res->rtyp = UNKNOWN;
9349 }
9350 a->CleanUp();
9351 return TRUE;
9352}
9354{
9355 if (!errorreported)
9356 {
9357 res->Init();
9358#ifdef SIQ
9359 if (siq>0)
9360 {
9361 //Print("siq:%d\n",siq);
9363 memcpy(&d->arg1,a,sizeof(sleftv));
9364 a->Init();
9365 d->op=op;
9366 d->argc=1;
9367 res->data=(char *)d;
9368 res->rtyp=COMMAND;
9369 return FALSE;
9370 }
9371#endif
9372 int at=a->Typ();
9373 // handling bb-objects ----------------------------------------------------
9374 if(op>MAX_TOK) // explicit type conversion to bb
9375 {
9376 blackbox *bb=getBlackboxStuff(op);
9377 if (bb!=NULL)
9378 {
9379 res->rtyp=op;
9380 res->data=bb->blackbox_Init(bb);
9381 return bb->blackbox_Assign(res,a);
9382 }
9383 else
9384 return TRUE;
9385 }
9386 else if (at>MAX_TOK) // argument is of bb-type
9387 {
9388 blackbox *bb=getBlackboxStuff(at);
9389 if (bb!=NULL)
9390 {
9391 if(!bb->blackbox_Op1(op,res,a)) return FALSE;
9392 // if not defined, try generic routines (attrib, defined,..)
9393 }
9394 else
9395 return TRUE;
9396 }
9397 if (errorreported) return TRUE;
9398
9399 int i=iiTabIndex(dArithTab1,JJTAB1LEN,op);
9400 return iiExprArith1Tab(res,a,op, dArith1+i,at,dConvertTypes);
9401 }
9402 a->CleanUp();
9403 return TRUE;
9404}
9405
9406/*=================== operations with 3 args. ============================*/
9407/* must be ordered: first operations for chars (infix ops),
9408 * then alphabetically */
9409
9411 const struct sValCmd3* dA3, int at, int bt, int ct,
9412 const struct sConvertTypes *dConvertTypes)
9413{
9414 BOOLEAN call_failed=FALSE;
9415
9416 assume(dA3[0].cmd==op);
9417
9418 if (!errorreported)
9419 {
9420 int i=0;
9421 iiOp=op;
9422 while (dA3[i].cmd==op)
9423 {
9424 if ((at==dA3[i].arg1)
9425 && (bt==dA3[i].arg2)
9426 && (ct==dA3[i].arg3))
9427 {
9428 res->rtyp=dA3[i].res;
9429 if (currRing!=NULL)
9430 {
9431 if (check_valid(dA3[i].valid_for,op)) break;
9432 }
9433 if (traceit&TRACE_CALL)
9434 Print("call %s(%s,%s,%s)\n",
9436 if ((call_failed=dA3[i].p(res,a,b,c)))
9437 {
9438 break;// leave loop, goto error handling
9439 }
9440 a->CleanUp();
9441 b->CleanUp();
9442 c->CleanUp();
9443 return FALSE;
9444 }
9445 i++;
9446 }
9447 // implicite type conversion ----------------------------------------------
9448 if (dA3[i].cmd!=op)
9449 {
9450 int ai,bi,ci;
9454 BOOLEAN failed=FALSE;
9455 i=0;
9456 //while ((dA3[i].cmd!=op)&&(dA3[i].cmd!=0)) i++;
9457 while (dA3[i].cmd==op)
9458 {
9459 if ((dA3[i].valid_for & NO_CONVERSION)==0)
9460 {
9461 if ((ai=iiTestConvert(at,dA3[i].arg1,dConvertTypes))!=0)
9462 {
9463 if ((bi=iiTestConvert(bt,dA3[i].arg2,dConvertTypes))!=0)
9464 {
9465 if ((ci=iiTestConvert(ct,dA3[i].arg3,dConvertTypes))!=0)
9466 {
9467 res->rtyp=dA3[i].res;
9468 if (currRing!=NULL)
9469 {
9470 if (check_valid(dA3[i].valid_for,op)) break;
9471 }
9472 if (traceit&TRACE_CALL)
9473 Print("call %s(%s,%s,%s)\n",
9474 iiTwoOps(op),Tok2Cmdname(dA3[i].arg1),
9475 Tok2Cmdname(dA3[i].arg2),Tok2Cmdname(dA3[i].arg3));
9476 failed= ((iiConvert(at,dA3[i].arg1,ai,a,an,dConvertTypes))
9477 || (iiConvert(bt,dA3[i].arg2,bi,b,bn,dConvertTypes))
9478 || (iiConvert(ct,dA3[i].arg3,ci,c,cn,dConvertTypes))
9479 || (call_failed=dA3[i].p(res,an,bn,cn)));
9480 // everything done, clean up temp. variables
9481 if (failed)
9482 {
9483 // leave loop, goto error handling
9484 break;
9485 }
9486 else
9487 {
9488 // everything ok, clean up and return
9489 an->CleanUp();
9490 bn->CleanUp();
9491 cn->CleanUp();
9495 //Print("op: %d,result typ:%d\n",op,res->rtyp);
9496 return FALSE;
9497 }
9498 }
9499 }
9500 }
9501 }
9502 i++;
9503 }
9504 an->CleanUp();
9505 bn->CleanUp();
9506 cn->CleanUp();
9510 }
9511 // error handling ---------------------------------------------------
9512 if (!errorreported)
9513 {
9514 const char *s=NULL;
9515 if ((at==0) && (a->Fullname()!=sNoName_fe))
9516 {
9517 s=a->Fullname();
9518 }
9519 else if ((bt==0) && (b->Fullname()!=sNoName_fe))
9520 {
9521 s=b->Fullname();
9522 }
9523 else if ((ct==0) && (c->Fullname()!=sNoName_fe))
9524 {
9525 s=c->Fullname();
9526 }
9527 if (s!=NULL)
9528 Werror("`%s` is not defined",s);
9529 else
9530 {
9531 i=0;
9532 //while ((dA3[i].cmd!=op)&&(dA3[i].cmd!=0)) i++;
9533 const char *s = iiTwoOps(op);
9534 Werror("%s(`%s`,`%s`,`%s`) failed"
9535 ,s,Tok2Cmdname(at),Tok2Cmdname(bt),Tok2Cmdname(ct));
9536 if ((!call_failed) && BVERBOSE(V_SHOW_USE))
9537 {
9538 while (dA3[i].cmd==op)
9539 {
9540 if(((at==dA3[i].arg1)
9541 ||(bt==dA3[i].arg2)
9542 ||(ct==dA3[i].arg3))
9543 && (dA3[i].res!=0))
9544 {
9545 Werror("expected %s(`%s`,`%s`,`%s`)"
9546 ,s,Tok2Cmdname(dA3[i].arg1)
9547 ,Tok2Cmdname(dA3[i].arg2)
9548 ,Tok2Cmdname(dA3[i].arg3));
9549 }
9550 i++;
9551 }
9552 }
9553 }
9554 }
9555 res->rtyp = UNKNOWN;
9556 }
9557 a->CleanUp();
9558 b->CleanUp();
9559 c->CleanUp();
9560 //Print("op: %d,result typ:%d\n",op,res->rtyp);
9561 return TRUE;
9562}
9564{
9565 res->Init();
9566
9567 if (!errorreported)
9568 {
9569#ifdef SIQ
9570 if (siq>0)
9571 {
9572 //Print("siq:%d\n",siq);
9574 memcpy(&d->arg1,a,sizeof(sleftv));
9575 a->Init();
9576 memcpy(&d->arg2,b,sizeof(sleftv));
9577 b->Init();
9578 memcpy(&d->arg3,c,sizeof(sleftv));
9579 c->Init();
9580 d->op=op;
9581 d->argc=3;
9582 res->data=(char *)d;
9583 res->rtyp=COMMAND;
9584 return FALSE;
9585 }
9586#endif
9587 int at=a->Typ();
9588 // handling bb-objects ----------------------------------------------
9589 if (at>MAX_TOK)
9590 {
9591 blackbox *bb=getBlackboxStuff(at);
9592 if (bb!=NULL)
9593 {
9594 if(!bb->blackbox_Op3(op,res,a,b,c)) return FALSE;
9595 // otherwise, try defaul (attrib,..)
9596 }
9597 else
9598 return TRUE;
9599 if (errorreported) return TRUE;
9600 }
9601 int bt=b->Typ();
9602 int ct=c->Typ();
9603
9604 iiOp=op;
9605 int i=0;
9606 while ((dArith3[i].cmd!=op)&&(dArith3[i].cmd!=0)) i++;
9607 return iiExprArith3TabIntern(res,op,a,b,c,dArith3+i,at,bt,ct,dConvertTypes);
9608 }
9609 a->CleanUp();
9610 b->CleanUp();
9611 c->CleanUp();
9612 //Print("op: %d,result typ:%d\n",op,res->rtyp);
9613 return TRUE;
9614}
9616 const struct sValCmd3* dA3,
9617 int at,
9618 const struct sConvertTypes *dConvertTypes)
9619{
9620 res->Init();
9621 leftv b=a->next;
9622 a->next=NULL;
9623 int bt=b->Typ();
9624 leftv c=b->next;
9625 b->next=NULL;
9626 int ct=c->Typ();
9627 BOOLEAN bo=iiExprArith3TabIntern(res,op,a,b,c,dA3,at,bt,ct,dConvertTypes);
9628 b->next=c;
9629 a->next=b;
9630 a->CleanUp(); // to cleanup the chain, content already done
9631 return bo;
9632}
9633/*==================== operations with many arg. ===============================*/
9634/* must be ordered: first operations for chars (infix ops),
9635 * then alphabetically */
9636
9637#if 0 // unused
9638static BOOLEAN jjANY2LIST(leftv res, leftv v, int cnt)
9639{
9640 // cnt = 0: all
9641 // cnt = 1: only first one
9642 leftv next;
9643 BOOLEAN failed = TRUE;
9644 if(v==NULL) return failed;
9645 res->rtyp = LIST_CMD;
9646 if(cnt) v->next = NULL;
9647 next = v->next; // saving next-pointer
9648 failed = jjLIST_PL(res, v);
9649 v->next = next; // writeback next-pointer
9650 return failed;
9651}
9652#endif
9653
9655{
9656 res->Init();
9657
9658 if (!errorreported)
9659 {
9660#ifdef SIQ
9661 if (siq>0)
9662 {
9663 //Print("siq:%d\n",siq);
9665 d->op=op;
9666 res->data=(char *)d;
9667 if (a!=NULL)
9668 {
9669 d->argc=a->listLength();
9670 // else : d->argc=0;
9671 memcpy(&d->arg1,a,sizeof(sleftv));
9672 switch(d->argc)
9673 {
9674 case 3:
9675 memcpy(&d->arg3,a->next->next,sizeof(sleftv));
9676 a->next->next->Init(); /* no break */
9677 case 2:
9678 memcpy(&d->arg2,a->next,sizeof(sleftv));
9679 a->next->Init();
9680 a->next->next=d->arg2.next;
9681 d->arg2.next=NULL; /* no break */
9682 case 1:
9683 a->Init();
9684 a->next=d->arg1.next;
9685 d->arg1.next=NULL;
9686 }
9687 if (d->argc>3) a->next=NULL;
9688 a->name=NULL;
9689 a->rtyp=0;
9690 a->data=NULL;
9691 a->e=NULL;
9692 a->attribute=NULL;
9693 a->CleanUp();
9694 }
9695 res->rtyp=COMMAND;
9696 return FALSE;
9697 }
9698#endif
9699 if ((a!=NULL) && (a->Typ()>MAX_TOK))
9700 {
9701 blackbox *bb=getBlackboxStuff(a->Typ());
9702 if (bb!=NULL)
9703 {
9704 if(!bb->blackbox_OpM(op,res,a)) return FALSE;
9705 // otherwise, try default
9706 }
9707 else
9708 return TRUE;
9709 if (errorreported) return TRUE;
9710 }
9711 int args=0;
9712 if (a!=NULL) args=a->listLength();
9713
9714 iiOp=op;
9715 int i=0;
9716 while ((dArithM[i].cmd!=op)&&(dArithM[i].cmd!=0)) i++;
9717 while (dArithM[i].cmd==op)
9718 {
9719 if ((args==dArithM[i].number_of_args)
9720 || (dArithM[i].number_of_args==-1)
9721 || ((dArithM[i].number_of_args==-2)&&(args>0)))
9722 {
9723 res->rtyp=dArithM[i].res;
9724 if (currRing!=NULL)
9725 {
9726 if (check_valid(dArithM[i].valid_for,op)) break;
9727 }
9728 if (traceit&TRACE_CALL)
9729 Print("call %s(... (%d args))\n", iiTwoOps(op),args);
9730 if (dArithM[i].p(res,a))
9731 {
9732 break;// leave loop, goto error handling
9733 }
9734 if (a!=NULL) a->CleanUp();
9735 //Print("op: %d,result typ:%d\n",op,res->rtyp);
9736 return FALSE;
9737 }
9738 i++;
9739 }
9740 // error handling
9741 if (!errorreported)
9742 {
9743 if ((args>0) && (a->rtyp==0) && (a->Name()!=sNoName_fe))
9744 {
9745 Werror("`%s` is not defined",a->Fullname());
9746 }
9747 else
9748 {
9749 const char *s = iiTwoOps(op);
9750 Werror("%s(...) failed",s);
9751 }
9752 }
9753 res->rtyp = UNKNOWN;
9754 }
9755 if (a!=NULL) a->CleanUp();
9756 //Print("op: %d,result typ:%d\n",op,res->rtyp);
9757 return TRUE;
9758}
9759
9760/*=================== general utilities ============================*/
9761int IsCmd(const char *n, int & tok)
9762{
9763 int i;
9764 int an=1;
9765 int en=sArithBase.nLastIdentifier;
9766
9767 loop
9768 //for(an=0; an<sArithBase.nCmdUsed; )
9769 {
9770 if(an>=en-1)
9771 {
9772 if (strcmp(n, sArithBase.sCmds[an].name) == 0)
9773 {
9774 i=an;
9775 break;
9776 }
9777 else if ((an!=en) && (strcmp(n, sArithBase.sCmds[en].name) == 0))
9778 {
9779 i=en;
9780 break;
9781 }
9782 else
9783 {
9784 // -- blackbox extensions:
9785 // return 0;
9786 return blackboxIsCmd(n,tok);
9787 }
9788 }
9789 i=(an+en)/2;
9790 if (*n < *(sArithBase.sCmds[i].name))
9791 {
9792 en=i-1;
9793 }
9794 else if (*n > *(sArithBase.sCmds[i].name))
9795 {
9796 an=i+1;
9797 }
9798 else
9799 {
9800 int v=strcmp(n,sArithBase.sCmds[i].name);
9801 if(v<0)
9802 {
9803 en=i-1;
9804 }
9805 else if(v>0)
9806 {
9807 an=i+1;
9808 }
9809 else /*v==0*/
9810 {
9811 break;
9812 }
9813 }
9814 }
9815 lastreserved=sArithBase.sCmds[i].name;
9816 tok=sArithBase.sCmds[i].tokval;
9817 if(sArithBase.sCmds[i].alias==2)
9818 {
9819 Warn("outdated identifier `%s` used - please change your code",
9820 sArithBase.sCmds[i].name);
9821 sArithBase.sCmds[i].alias=1;
9822 }
9823 #if 0
9824 if (currRingHdl==NULL)
9825 {
9826 #ifdef SIQ
9827 if (siq<=0)
9828 {
9829 #endif
9830 if ((tok>=BEGIN_RING) && (tok<=END_RING))
9831 {
9832 WerrorS("no ring active");
9833 return 0;
9834 }
9835 #ifdef SIQ
9836 }
9837 #endif
9838 }
9839 #endif
9840 if (!expected_parms)
9841 {
9842 switch (tok)
9843 {
9844 case IDEAL_CMD:
9845 case INT_CMD:
9846 case INTVEC_CMD:
9847 case MAP_CMD:
9848 case MATRIX_CMD:
9849 case MODUL_CMD:
9850 case POLY_CMD:
9851 case PROC_CMD:
9852 case RING_CMD:
9853 case STRING_CMD:
9854 cmdtok = tok;
9855 break;
9856 }
9857 }
9858 return sArithBase.sCmds[i].toktype;
9859}
9860static int iiTabIndex(const jjValCmdTab dArithTab, const int len, const int op)
9861{
9862 // user defined types are not in the pre-computed table:
9863 if (op>MAX_TOK) return 0;
9864
9865 int a=0;
9866 int e=len;
9867 int p=len/2;
9868 do
9869 {
9870 if (op==dArithTab[p].cmd) return dArithTab[p].start;
9871 if (op<dArithTab[p].cmd) e=p-1;
9872 else a = p+1;
9873 p=a+(e-a)/2;
9874 }
9875 while ( a <= e);
9876
9877 // catch missing a cmd:
9878 // may be missing as a op for blackbox, if the first operand is "undef" instead of bb
9879 // Print("op %d (%c) unknown",op,op);
9880 return 0;
9881}
9882
9883typedef char si_char_2[2];
9885const char * Tok2Cmdname(int tok)
9886{
9887 if (tok <= 0)
9888 {
9889 return sArithBase.sCmds[0].name;
9890 }
9891 if (tok==ANY_TYPE) return "any_type";
9892 if (tok==COMMAND) return "command";
9893 if (tok==NONE) return "nothing";
9894 if (tok < 128)
9895 {
9896 Tok2Cmdname_buf[0]=(char)tok;
9897 return Tok2Cmdname_buf;
9898 }
9899 //if (tok==IFBREAK) return "if_break";
9900 //if (tok==VECTOR_FROM_POLYS) return "vector_from_polys";
9901 //if (tok==ORDER_VECTOR) return "ordering";
9902 //if (tok==REF_VAR) return "ref";
9903 //if (tok==OBJECT) return "object";
9904 //if (tok==PRINT_EXPR) return "print_expr";
9905 if (tok==IDHDL) return "identifier";
9906 if (tok>MAX_TOK) return getBlackboxName(tok);
9907 unsigned i;
9908 for(i=0; i<sArithBase.nCmdUsed; i++)
9909 //while (sArithBase.sCmds[i].tokval!=0)
9910 {
9911 if ((sArithBase.sCmds[i].tokval == tok)&&
9912 (sArithBase.sCmds[i].alias==0))
9913 {
9914 return sArithBase.sCmds[i].name;
9915 }
9916 }
9917 // try gain for alias/old names:
9918 for(i=0; i<sArithBase.nCmdUsed; i++)
9919 {
9920 if (sArithBase.sCmds[i].tokval == tok)
9921 {
9922 return sArithBase.sCmds[i].name;
9923 }
9924 }
9925 return sArithBase.sCmds[0].name;
9926}
9927
9928
9929/*---------------------------------------------------------------------*/
9930/**
9931 * @brief compares to entry of cmdsname-list
9932
9933 @param[in] a
9934 @param[in] b
9935
9936 @return <ReturnValue>
9937**/
9938/*---------------------------------------------------------------------*/
9939static int _gentable_sort_cmds( const void *a, const void *b )
9940{
9941 cmdnames *pCmdL = (cmdnames*)a;
9942 cmdnames *pCmdR = (cmdnames*)b;
9943
9944 if(a==NULL || b==NULL) return 0;
9945
9946 /* empty entries goes to the end of the list for later reuse */
9947 if(pCmdL->name==NULL) return 1;
9948 if(pCmdR->name==NULL) return -1;
9949
9950 /* $INVALID$ must come first */
9951 if(strcmp(pCmdL->name, "$INVALID$")==0) return -1;
9952 if(strcmp(pCmdR->name, "$INVALID$")==0) return 1;
9953
9954 /* tokval=-1 are reserved names at the end */
9955 if (pCmdL->tokval==-1)
9956 {
9957 if (pCmdR->tokval==-1)
9958 return strcmp(pCmdL->name, pCmdR->name);
9959 /* pCmdL->tokval==-1, pCmdL goes at the end */
9960 return 1;
9961 }
9962 /* pCmdR->tokval==-1, pCmdR goes at the end */
9963 if(pCmdR->tokval==-1) return -1;
9964
9965 return strcmp(pCmdL->name, pCmdR->name);
9966}
9967
9968/*---------------------------------------------------------------------*/
9969/**
9970 * @brief initialisation of arithmetic structured data
9971
9972 @retval 0 on success
9973
9974**/
9975/*---------------------------------------------------------------------*/
9977{
9978 //printf("iiInitArithmetic()\n");
9979 memset(&sArithBase, 0, sizeof(sArithBase));
9980 iiInitCmdName();
9981 /* fix last-identifier */
9982#if 0
9983 /* we expect that gentable allready did every thing */
9984 for(sArithBase.nLastIdentifier=sArithBase.nCmdUsed-1;
9985 sArithBase.nLastIdentifier>0; sArithBase.nLastIdentifier--) {
9986 if(sArithBase.sCmds[sArithBase.nLastIdentifier].tokval>=0) break;
9987 }
9988#endif
9989 //Print("L=%d\n", sArithBase.nLastIdentifier);
9990
9991 //iiArithAddCmd(szName, nAlias, nTokval, nToktype);
9992 //iiArithAddCmd("mygcd", 1, GCD_CMD, CMD_2);
9993
9994 //iiArithAddCmd("Top", 0,-1,0);
9995
9996
9997 //for(i=0; i<sArithBase.nCmdUsed; i++) {
9998 // printf("CMD[%03d] %s, %d, %d, %d\n", i,
9999 // sArithBase.sCmds[i].name,
10000 // sArithBase.sCmds[i].alias,
10001 // sArithBase.sCmds[i].tokval,
10002 // sArithBase.sCmds[i].toktype);
10003 //}
10004 //iiArithRemoveCmd("Top");
10005 //iiArithAddCmd("mygcd", 2, GCD_CMD, CMD_2);
10006 //iiArithRemoveCmd("mygcd");
10007 //iiArithAddCmd("kkk", 1, 1234, CMD_1);
10008 return 0;
10009}
10010
10011int iiArithFindCmd(const char *szName)
10012{
10013 int an=0;
10014 int i = 0,v = 0;
10015 int en=sArithBase.nLastIdentifier;
10016
10017 loop
10018 //for(an=0; an<sArithBase.nCmdUsed; )
10019 {
10020 if(an>=en-1)
10021 {
10022 if (strcmp(szName, sArithBase.sCmds[an].name) == 0)
10023 {
10024 //Print("RET-an=%d %s\n", an, sArithBase.sCmds[an].name);
10025 return an;
10026 }
10027 else if (strcmp(szName, sArithBase.sCmds[en].name) == 0)
10028 {
10029 //Print("RET-en=%d %s\n", en, sArithBase.sCmds[en].name);
10030 return en;
10031 }
10032 else
10033 {
10034 //Print("RET- 1\n");
10035 return -1;
10036 }
10037 }
10038 i=(an+en)/2;
10039 if (*szName < *(sArithBase.sCmds[i].name))
10040 {
10041 en=i-1;
10042 }
10043 else if (*szName > *(sArithBase.sCmds[i].name))
10044 {
10045 an=i+1;
10046 }
10047 else
10048 {
10049 v=strcmp(szName,sArithBase.sCmds[i].name);
10050 if(v<0)
10051 {
10052 en=i-1;
10053 }
10054 else if(v>0)
10055 {
10056 an=i+1;
10057 }
10058 else /*v==0*/
10059 {
10060 //Print("RET-i=%d %s\n", i, sArithBase.sCmds[i].name);
10061 return i;
10062 }
10063 }
10064 }
10065 //if(i>=0 && i<sArithBase.nCmdUsed)
10066 // return i;
10067 //PrintS("RET-2\n");
10068 return -2;
10069}
10070
10071char *iiArithGetCmd( int nPos )
10072{
10073 if(nPos<0) return NULL;
10074 if(nPos<(int)sArithBase.nCmdUsed)
10075 return sArithBase.sCmds[nPos].name;
10076 return NULL;
10077}
10078
10079int iiArithRemoveCmd(const char *szName)
10080{
10081 int nIndex;
10082 if(szName==NULL) return -1;
10083
10084 nIndex = iiArithFindCmd(szName);
10085 if(nIndex<0 || nIndex>=(int)sArithBase.nCmdUsed)
10086 {
10087 Print("'%s' not found (%d)\n", szName, nIndex);
10088 return -1;
10089 }
10090 omFreeBinAddr(sArithBase.sCmds[nIndex].name);
10091 sArithBase.sCmds[nIndex].name=NULL;
10092 qsort(sArithBase.sCmds, sArithBase.nCmdUsed, sizeof(cmdnames),
10094 sArithBase.nCmdUsed--;
10095
10096 /* fix last-identifier */
10097 for(sArithBase.nLastIdentifier=sArithBase.nCmdUsed-1;
10098 sArithBase.nLastIdentifier>0; sArithBase.nLastIdentifier--)
10099 {
10100 if(sArithBase.sCmds[sArithBase.nLastIdentifier].tokval>=0) break;
10101 }
10102 //Print("L=%d\n", sArithBase.nLastIdentifier);
10103 return 0;
10104}
10105
10107 const char *szName,
10108 short nAlias,
10109 short nTokval,
10110 short nToktype,
10111 short nPos
10112 )
10113{
10114 //printf("AddCmd(%s, %d, %d, %d, %d)\n", szName, nAlias,
10115 // nTokval, nToktype, nPos);
10116 if(nPos>=0)
10117 {
10118 // no checks: we rely on a correct generated code in iparith.inc
10119 assume((unsigned)nPos < sArithBase.nCmdAllocated);
10120 assume(szName!=NULL);
10121 sArithBase.sCmds[nPos].name = omStrDup(szName);
10122 sArithBase.sCmds[nPos].alias = nAlias;
10123 sArithBase.sCmds[nPos].tokval = nTokval;
10124 sArithBase.sCmds[nPos].toktype = nToktype;
10125 sArithBase.nCmdUsed++;
10126 //if(nTokval>0) sArithBase.nLastIdentifier++;
10127 }
10128 else
10129 {
10130 if(szName==NULL) return -1;
10131 int nIndex = iiArithFindCmd(szName);
10132 if(nIndex>=0)
10133 {
10134 Print("'%s' already exists at %d\n", szName, nIndex);
10135 return -1;
10136 }
10137
10138 if(sArithBase.nCmdUsed>=sArithBase.nCmdAllocated)
10139 {
10140 /* needs to create new slots */
10141 unsigned long nSize = (sArithBase.nCmdAllocated+1)*sizeof(cmdnames);
10142 sArithBase.sCmds = (cmdnames *)omRealloc(sArithBase.sCmds, nSize);
10143 if(sArithBase.sCmds==NULL) return -1;
10144 sArithBase.nCmdAllocated++;
10145 }
10146 /* still free slots available */
10147 sArithBase.sCmds[sArithBase.nCmdUsed].name = omStrDup(szName);
10148 sArithBase.sCmds[sArithBase.nCmdUsed].alias = nAlias;
10149 sArithBase.sCmds[sArithBase.nCmdUsed].tokval = nTokval;
10150 sArithBase.sCmds[sArithBase.nCmdUsed].toktype = nToktype;
10151 sArithBase.nCmdUsed++;
10152
10153 qsort(sArithBase.sCmds, sArithBase.nCmdUsed, sizeof(cmdnames),
10155 for(sArithBase.nLastIdentifier=sArithBase.nCmdUsed-1;
10156 sArithBase.nLastIdentifier>0; sArithBase.nLastIdentifier--)
10157 {
10158 if(sArithBase.sCmds[sArithBase.nLastIdentifier].tokval>=0) break;
10159 }
10160 //Print("L=%d\n", sArithBase.nLastIdentifier);
10161 }
10162 return 0;
10163}
10164
10165static BOOLEAN check_valid(const int p, const int op)
10166{
10168 {
10169 if ((p & NC_MASK)==NO_NC)
10170 {
10171 WerrorS("not implemented for non-commutative rings");
10172 return TRUE;
10173 }
10174 else if ((p & NC_MASK)==COMM_PLURAL)
10175 {
10176 Warn("assume commutative subalgebra for cmd `%s` in >>%s<<",Tok2Cmdname(op),my_yylinebuf);
10177 return FALSE;
10178 }
10179 /* else, ALLOW_PLURAL */
10180 }
10181 else if (rIsLPRing(currRing))
10182 {
10183 if ((p & ALLOW_LP)==0)
10184 {
10185 Werror("`%s` not implemented for letterplace rings in >>%s<<",Tok2Cmdname(op),my_yylinebuf);
10186 return TRUE;
10187 }
10188 }
10190 {
10191 if ((p & RING_MASK)==0 /*NO_RING*/)
10192 {
10193 WerrorS("not implemented for rings with rings as coeffients");
10194 return TRUE;
10195 }
10197 {
10198 WerrorS("not implemented for rings with rings as coeffients and non-global orderings");
10199 return TRUE;
10200 }
10201 /* else ALLOW_RING */
10202 else if (((p & ZERODIVISOR_MASK)==NO_ZERODIVISOR)
10204 {
10205 WerrorS("domain required as coeffients");
10206 return TRUE;
10207 }
10208 /* else ALLOW_ZERODIVISOR */
10209 else if(((p & WARN_RING)==WARN_RING)&&(myynest==0))
10210 {
10211 WarnS("considering the image in Q[...]");
10212 }
10213 }
10214 return FALSE;
10215}
10216// --------------------------------------------------------------------
10218{
10219 if ((currRing!=NULL)
10221 && (!rField_is_Z(currRing)))
10222 {
10223 WerrorS("not implemented for rings with rings as coeffients (except ZZ)");
10224 return TRUE;
10225 }
10226 coeffs cf;
10227 lists c=(lists)u->CopyD(); // list of ideal or bigint/int
10228 int rl=c->nr+1;
10229 int return_type=c->m[0].Typ();
10230 if ((return_type!=IDEAL_CMD)
10231 && (return_type!=MODUL_CMD)
10232 && (return_type!=SMATRIX_CMD)
10233 && (return_type!=MATRIX_CMD)
10234 && (return_type!=POLY_CMD))
10235 {
10236 if((return_type==BIGINT_CMD)
10237 ||(return_type==INT_CMD))
10238 return_type=BIGINT_CMD;
10239 else if (return_type==LIST_CMD)
10240 {
10241 // create a tmp list of the correct size
10243 res_l->Init(rl /*c->nr+1*/);
10244 BOOLEAN bo=FALSE;
10245 int tab_pos=iiTabIndex(dArithTab2,JJTAB2LEN,CHINREM_CMD);
10246 for (unsigned i=0;i<=(unsigned)c->nr;i++)
10247 {
10248 sleftv tmp;
10249 tmp.Copy(v);
10250 bo=iiExprArith2TabIntern(&res_l->m[i],&c->m[i],CHINREM_CMD,&tmp,TRUE,dArith2+tab_pos,c->m[i].rtyp,tmp.rtyp,dConvertTypes);
10251 if (bo) { Werror("chinrem failed for list entry %d",i+1); break;}
10252 }
10253 c->Clean();
10254 res->data=res_l;
10255 res->rtyp=LIST_CMD;
10256 return bo;
10257 }
10258 else
10259 {
10260 c->Clean();
10261 WerrorS("poly/ideal/module/matrix/list expected");
10262 return TRUE;
10263 }
10264 }
10265 if (return_type==BIGINT_CMD)
10267 else
10268 {
10269 cf=currRing->cf;
10270 if (nCoeff_is_Extension(cf) && (cf->extRing!=NULL))
10271 cf=cf->extRing->cf;
10272 }
10273 lists pl=NULL;
10274 intvec *p=NULL;
10275 if (v->Typ()==LIST_CMD)
10276 {
10277 pl=(lists)v->Data();
10278 if (pl->nr!=rl-1)
10279 {
10280 Werror("wromg number of primes (%d:%d) for chinrem",pl->nr+1,rl);
10281 return TRUE;
10282 }
10283 }
10284 else
10285 {
10286 p=(intvec*)v->Data();
10287 if (p->length()!=rl)
10288 {
10289 Werror("wromg number of primes (%d:%d) for chinrem",p->length(),rl);
10290 return TRUE;
10291 }
10292 }
10293 ideal result;
10294 ideal *x=(ideal *)omAlloc(rl*sizeof(ideal));
10295 number *xx=NULL;
10297 int i;
10298 if (return_type!=BIGINT_CMD)
10299 {
10300 for(i=rl-1;i>=0;i--)
10301 {
10302 if (c->m[i].Typ()!=return_type)
10303 {
10304 Werror("%s expected at pos %d",Tok2Cmdname(return_type),i+1);
10305 omFree(x); // delete c
10306 return TRUE;
10307 }
10308 if (return_type==POLY_CMD)
10309 {
10310 x[i]=idInit(1,1);
10311 x[i]->m[0]=(poly)c->m[i].CopyD();
10312 }
10313 else
10314 {
10315 x[i]=(ideal)c->m[i].CopyD();
10316 }
10317 //c->m[i].Init();
10318 }
10319 }
10320 else
10321 {
10322 if (nMap==NULL)
10323 {
10324 Werror("not implemented: map bigint -> %s", nCoeffName(cf));
10325 return TRUE;
10326 }
10327 xx=(number *)omAlloc(rl*sizeof(number));
10328 for(i=rl-1;i>=0;i--)
10329 {
10330 if (c->m[i].Typ()==INT_CMD)
10331 {
10332 xx[i]=n_Init(((int)(long)c->m[i].Data()),cf);
10333 }
10334 else if (c->m[i].Typ()==BIGINT_CMD)
10335 {
10336 xx[i]=nMap((number)c->m[i].Data(),coeffs_BIGINT,cf);
10337 }
10338 else
10339 {
10340 Werror("bigint expected at pos %d",i+1);
10341 omFree(x); // delete c
10342 omFree(xx); // delete c
10343 return TRUE;
10344 }
10345 }
10346 }
10347 number *q=(number *)omAlloc(rl*sizeof(number));
10348 if (p!=NULL)
10349 {
10350 for(i=rl-1;i>=0;i--)
10351 {
10352 q[i]=n_Init((*p)[i], cf);
10353 }
10354 }
10355 else
10356 {
10357 for(i=rl-1;i>=0;i--)
10358 {
10359 if (pl->m[i].Typ()==INT_CMD)
10360 {
10361 q[i]=n_Init((int)(long)pl->m[i].Data(),cf);
10362 }
10363 else if (pl->m[i].Typ()==BIGINT_CMD)
10364 {
10365 q[i]=nMap((number)(pl->m[i].Data()),coeffs_BIGINT,cf);
10366 }
10367 else
10368 {
10369 Werror("bigint expected at pos %d",i+1);
10370 for(i++;i<rl;i++)
10371 {
10372 n_Delete(&(q[i]),cf);
10373 }
10374 omFree(x); // delete c
10375 omFree(q); // delete pl
10376 if (xx!=NULL) omFree(xx); // delete c
10377 return TRUE;
10378 }
10379 }
10380 }
10381 if (return_type==BIGINT_CMD)
10382 {
10383 CFArray i_v(rl);
10384 number n=n_ChineseRemainderSym(xx,q,rl,TRUE,i_v,coeffs_BIGINT);
10385 res->data=(char *)n;
10386 }
10387 else
10388 {
10389 #if 0
10390 #ifdef HAVE_VSPACE
10391 int cpus = (long) feOptValue(FE_OPT_CPUS);
10392 if ((cpus>1) && (rField_is_Q(currRing)))
10393 result=id_ChineseRemainder_0(x,q,rl,currRing); // deletes also x
10394 else
10395 #endif
10396 #endif
10397 result=id_ChineseRemainder(x,q,rl,currRing); // deletes also x
10398 c->Clean();
10399 if ((return_type==POLY_CMD) &&(result!=NULL))
10400 {
10401 res->data=(char *)result->m[0];
10402 result->m[0]=NULL;
10403 idDelete(&result);
10404 }
10405 else
10406 res->data=(char *)result;
10407 }
10408 for(i=rl-1;i>=0;i--)
10409 {
10410 n_Delete(&(q[i]),cf);
10411 }
10412 omFree(q);
10413 res->rtyp=return_type;
10414 return result==NULL;
10415}
10417{
10418 lists c=(lists)u->CopyD();
10420 res_l->Init(c->nr+1);
10421 BOOLEAN bo=FALSE;
10422 int tab_pos=iiTabIndex(dArithTab2,JJTAB2LEN,FAREY_CMD);
10423 for (unsigned i=0;i<=(unsigned)c->nr;i++)
10424 {
10425 sleftv tmp;
10426 tmp.Copy(v);
10427 bo=iiExprArith2TabIntern(&res_l->m[i],&c->m[i],FAREY_CMD,&tmp,TRUE,dArith2+tab_pos,c->m[i].rtyp,tmp.rtyp,dConvertTypes);
10428 if (bo) { Werror("farey failed for list entry %d",i+1); break;}
10429 }
10430 c->Clean();
10431 res->data=res_l;
10432 return bo;
10433}
10434// --------------------------------------------------------------------
10435static int jjCOMPARE_ALL(const void * aa, const void * bb)
10436{
10437 leftv a=(leftv)aa;
10438 int at=a->Typ();
10439 leftv b=(leftv)bb;
10440 int bt=b->Typ();
10441 if (at < bt) return -1;
10442 if (at > bt) return 1;
10443 int tab_pos=iiTabIndex(dArithTab2,JJTAB2LEN,'<');
10444 sleftv tmp;
10445 tmp.Init();
10446 iiOp='<';
10447 BOOLEAN bo=iiExprArith2TabIntern(&tmp,a,'<',b,FALSE,dArith2+tab_pos,at,bt,dConvertTypes);
10448 if (bo)
10449 {
10450 Werror(" no `<` for %s",Tok2Cmdname(at));
10451 unsigned long ad=(unsigned long)a->Data();
10452 unsigned long bd=(unsigned long)b->Data();
10453 if (ad<bd) return -1;
10454 else if (ad==bd) return 0;
10455 else return 1;
10456 }
10457 else if (tmp.data==NULL) /* not < */
10458 {
10460 tab_pos=iiTabIndex(dArithTab2,JJTAB2LEN,EQUAL_EQUAL);
10462 if (bo)
10463 {
10464 Werror(" no `==` for %s",Tok2Cmdname(at));
10465 unsigned long ad=(unsigned long)a->Data();
10466 unsigned long bd=(unsigned long)b->Data();
10467 if (ad<bd) return -1;
10468 else if (ad==bd) return 0;
10469 else return 1;
10470 }
10471 else if (tmp.data==NULL) /* not <,== */ return 1;
10472 else return 0;
10473 }
10474 else return -1;
10475}
10477{
10478 lists l=(lists)arg->Data();
10479 if (l->nr>0)
10480 {
10481 qsort(l->m,l->nr+1,sizeof(sleftv),jjCOMPARE_ALL);
10482 }
10483 return FALSE;
10484}
10486{
10487 lists l=(lists)arg->Data();
10488 if (l->nr>0)
10489 {
10490 qsort(l->m,l->nr+1,sizeof(sleftv),jjCOMPARE_ALL);
10491 int i, j, len;
10492 len=l->nr;
10493 i=0;
10494 while(i<len)
10495 {
10496 if(jjCOMPARE_ALL(&(l->m[i]),&(l->m[i+1]))==0)
10497 {
10498 l->m[i].CleanUp();
10499 for(j=i; j<len;j++) l->m[j]=l->m[j+1];
10500 memset(&(l->m[len]),0,sizeof(sleftv));
10501 l->m[len].rtyp=DEF_CMD;
10502 len--;
10503 }
10504 else
10505 i++;
10506 }
10507 //Print("new len:%d\n",len);
10508 }
10509 return FALSE;
10510}
ideal getMinorIdealCache(const matrix mat, const int minorSize, const int k, const ideal iSB, const int cacheStrategy, const int cacheN, const int cacheW, const bool allDifferent)
Returns the specified set of minors (= subdeterminantes) of the given matrix.
ideal getMinorIdeal(const matrix mat, const int minorSize, const int k, const char *algorithm, const ideal iSB, const bool allDifferent)
Returns the specified set of minors (= subdeterminantes) of the given matrix.
ideal getMinorIdealHeuristic(const matrix mat, const int minorSize, const int k, const ideal iSB, const bool allDifferent)
Returns the specified set of minors (= subdeterminantes) of the given matrix.
void atSet(idhdl root, char *name, void *data, int typ)
Definition attrib.cc:153
void * atGet(idhdl root, const char *name, int t, void *defaultReturnValue)
Definition attrib.cc:132
#define atKill(H, A)
Definition attrib.h:49
static int ABS(int v)
Definition auxiliary.h:112
static int si_max(const int a, const int b)
Definition auxiliary.h:124
int BOOLEAN
Definition auxiliary.h:87
#define TRUE
Definition auxiliary.h:100
#define FALSE
Definition auxiliary.h:96
void * ADDRESS
Definition auxiliary.h:119
static int si_min(const int a, const int b)
Definition auxiliary.h:125
intvec * bim2iv(bigintmat *b)
Definition bigintmat.cc:339
bigintmat * bimMult(bigintmat *a, bigintmat *b)
Definition bigintmat.cc:253
bigintmat * bimSub(bigintmat *a, bigintmat *b)
Definition bigintmat.cc:216
bigintmat * bimAdd(bigintmat *a, bigintmat *b)
Matrix-Add/-Sub/-Mult so oder mit operator+/-/* ? @Note: NULL as a result means an error (non-compati...
Definition bigintmat.cc:180
#define BIMATELEM(M, I, J)
Definition bigintmat.h:133
struct blackbox_list * getBlackboxTypes()
return array of all define types.
Definition blackbox.cc:245
const char * getBlackboxName(const int t)
return the name to the type given by t (r/o)
Definition blackbox.cc:213
blackbox * getBlackboxStuff(const int t)
return the structure to the type given by t
Definition blackbox.cc:17
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:219
void printBlackboxTypes()
list all defined type (for debugging)
Definition blackbox.cc:236
void ** list
Definition blackbox.h:86
struct for containing list of blackbox names and the number of them.
Definition blackbox.h:84
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition cf_gcd.cc:676
Array< CanonicalForm > CFArray
const CanonicalForm CFMap CFMap & N
Definition cfEzgcd.cc:56
int l
Definition cfEzgcd.cc:100
int m
Definition cfEzgcd.cc:128
int i
Definition cfEzgcd.cc:132
int k
Definition cfEzgcd.cc:99
Variable x
Definition cfModGcd.cc:4090
int p
Definition cfModGcd.cc:4086
g
Definition cfModGcd.cc:4098
CanonicalForm fp
Definition cfModGcd.cc:4110
CanonicalForm cf
Definition cfModGcd.cc:4091
CanonicalForm b
Definition cfModGcd.cc:4111
CanonicalForm map(const CanonicalForm &primElem, const Variable &alpha, const CanonicalForm &F, const Variable &beta)
map from to such that is mapped onto
int ipower(int b, int m)
int ipower ( int b, int m )
Definition cf_util.cc:27
FILE * f
Definition checklibs.c:9
poly singclap_pmod(poly f, poly g, const ring r)
Definition clapsing.cc:702
ideal singclap_factorize(poly f, intvec **v, int with_exps, const ring r)
Definition clapsing.cc:948
VAR int singclap_factorize_retry
Definition clapsing.cc:946
poly singclap_pdivide(poly f, poly g, const ring r)
Definition clapsing.cc:624
BOOLEAN singclap_extgcd(poly f, poly g, poly &res, poly &pa, poly &pb, const ring r)
Definition clapsing.cc:489
number singclap_det_bi(bigintmat *m, const coeffs cf)
Definition clapsing.cc:1800
int singclap_det_i(intvec *m, const ring)
Definition clapsing.cc:1782
ideal singclap_sqrfree(poly f, intvec **v, int with_exps, const ring r)
Definition clapsing.cc:1338
Matrices of numbers.
Definition bigintmat.h:51
int cols() const
Definition bigintmat.h:144
int rows() const
Definition bigintmat.h:145
void set(int i, int j, number n, const coeffs C=NULL)
replace an entry with a copy (delete old + copy new!). NOTE: starts at [1,1]
Definition bigintmat.cc:93
int compare(const bigintmat *op) const
Definition bigintmat.cc:360
Definition idrec.h:35
utypes data
Definition idrec.h:40
int typ
Definition idrec.h:43
short ref
Definition idrec.h:46
const char * id
Definition idrec.h:39
void makeVector()
Definition intvec.h:102
intvec * delete_pos(int p)
Definition intvec.cc:842
void show(int mat=0, int spaces=0) const
Definition intvec.cc:149
int min_in()
Definition intvec.h:121
int length() const
Definition intvec.h:94
int compare(const intvec *o) const
Definition intvec.cc:206
int cols() const
Definition intvec.h:95
int rows() const
Definition intvec.h:96
long rank
Definition matpol.h:19
int & cols()
Definition matpol.h:24
int & rows()
Definition matpol.h:23
Class used for (list of) interpreter objects.
Definition subexpr.h:83
void * CopyD(int t)
Definition subexpr.cc:714
int Typ()
Definition subexpr.cc:1048
const char * name
Definition subexpr.h:87
package req_packhdl
Definition subexpr.h:106
int rtyp
Definition subexpr.h:91
void * Data()
Definition subexpr.cc:1192
void Init()
Definition subexpr.h:107
leftv next
Definition subexpr.h:86
const char * Name()
Definition subexpr.h:120
int listLength()
Definition subexpr.cc:51
void Copy(leftv e)
Definition subexpr.cc:689
void * data
Definition subexpr.h:88
leftv Next()
Definition subexpr.h:136
void CleanUp(ring r=currRing)
Definition subexpr.cc:351
BITSET flag
Definition subexpr.h:90
const char * Fullname()
Definition subexpr.h:125
Subexpr e
Definition subexpr.h:105
attr attribute
Definition subexpr.h:89
sleftv * m
Definition lists.h:46
void Clean(ring r=currRing)
Definition lists.h:26
INLINE_THIS void Init(int l=0)
int nr
Definition lists.h:44
Coefficient rings, fields and other domains suitable for Singular polynomials.
static FORCE_INLINE int n_ParDeg(number n, const coeffs r)
Definition coeffs.h:763
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
Definition coeffs.h:637
static FORCE_INLINE number n_Param(const int iParameter, const coeffs r)
return the (iParameter^th) parameter as a NEW number NOTE: parameter numbering: 1....
Definition coeffs.h:776
static FORCE_INLINE long n_Int(number &n, const coeffs r)
conversion of n to an int; 0 if not possible in Z/pZ: the representing int lying in (-p/2 ....
Definition coeffs.h:548
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of 'a' and 'b', i.e., a+b
Definition coeffs.h:651
static FORCE_INLINE number n_GetDenom(number &n, const coeffs r)
return the denominator of n (if elements of r are by nature not fractional, result is 1)
Definition coeffs.h:604
static FORCE_INLINE BOOLEAN nCoeff_is_Extension(const coeffs r)
Definition coeffs.h:839
static FORCE_INLINE number n_Random(siRandProc p, number p1, number p2, const coeffs cf)
Definition coeffs.h:959
@ n_algExt
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic
Definition coeffs.h:35
static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
in Z: return the gcd of 'a' and 'b' in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ,...
Definition coeffs.h:665
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:952
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff 'n' is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2),...
Definition coeffs.h:498
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:701
static FORCE_INLINE number n_InpNeg(number n, const coeffs r)
in-place negation of n MUST BE USED: n = n_InpNeg(n) (no copy is returned)
Definition coeffs.h:558
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:633
static FORCE_INLINE number n_Farey(number a, number b, const coeffs r)
Definition coeffs.h:760
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of 'a' and 'b', i.e., a/b; raises an error if 'b' is not invertible in r exceptio...
Definition coeffs.h:616
static FORCE_INLINE number n_RePart(number i, const coeffs cf)
Definition coeffs.h:783
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition coeffs.h:468
static FORCE_INLINE int n_Size(number n, const coeffs r)
return a non-negative measure for the complexity of n; return 0 only when n represents zero; (used fo...
Definition coeffs.h:571
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of 'a' and 'b', i.e., a-b
Definition coeffs.h:656
static FORCE_INLINE number n_ChineseRemainderSym(number *a, number *b, int rl, BOOLEAN sym, CFArray &inv_cache, const coeffs r)
Definition coeffs.h:757
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition coeffs.h:459
static FORCE_INLINE char * nCoeffName(const coeffs cf)
Definition coeffs.h:956
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:672
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition coeffs.h:539
static FORCE_INLINE number n_IntMod(number a, number b, const coeffs r)
for r a field, return n_Init(0,r) always: n_Div(a,b,r)*b+n_IntMod(a,b,r)==a n_IntMod(a,...
Definition coeffs.h:629
static FORCE_INLINE BOOLEAN n_Equal(number a, number b, const coeffs r)
TRUE iff 'a' and 'b' represent the same number; they may have different representations.
Definition coeffs.h:464
static FORCE_INLINE number n_GetNumerator(number &n, const coeffs r)
return the numerator of n (if elements of r are by nature not fractional, result is n)
Definition coeffs.h:609
static FORCE_INLINE number n_SubringGcd(number a, number b, const coeffs r)
Definition coeffs.h:667
static FORCE_INLINE number n_ImPart(number i, const coeffs cf)
Definition coeffs.h:786
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition coeffs.h:80
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition coeffs.h:579
static FORCE_INLINE BOOLEAN nCoeff_is_transExt(const coeffs r)
TRUE iff r represents a transcendental extension field.
Definition coeffs.h:911
static BOOLEAN pa(leftv res, leftv args)
Definition cohomo.cc:3770
static BOOLEAN pb(leftv res, leftv args)
Definition cohomo.cc:3796
#define Print
Definition emacs.cc:80
#define Warn
Definition emacs.cc:77
#define WarnS
Definition emacs.cc:78
return result
const CanonicalForm int s
Definition facAbsFact.cc:51
CanonicalForm res
Definition facAbsFact.cc:60
const CanonicalForm & w
Definition facAbsFact.cc:51
b *CanonicalForm B
Definition facBivar.cc:52
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
bool found
CFList tmp1
Definition facFqBivar.cc:75
CFList tmp2
Definition facFqBivar.cc:75
int j
Definition facHensel.cc:110
‘factory.h’ is the user interface to Factory.
VAR void(* WerrorS_callback)(const char *s)
Definition feFopen.cc:21
FILE * feFopen(const char *path, const char *mode, char *where, short useWerror, short path_only)
Definition feFopen.cc:47
VAR short errorreported
Definition feFopen.cc:23
void WerrorS(const char *s)
Definition feFopen.cc:24
static void * feOptValue(feOptIndex opt)
Definition feOpt.h:40
VAR char my_yylinebuf[80]
Definition febase.cc:44
VAR int myynest
Definition febase.cc:41
void monitor(void *F, int mode)
Definition febase.cc:68
if(!FE_OPT_NO_SHELL_FLAG)
Definition fehelp.cc:1000
void newBuffer(char *s, feBufferTypes t, procinfo *pi, int lineno)
Definition fevoices.cc:166
const char sNoName_fe[]
Definition fevoices.cc:57
@ BT_execute
Definition fevoices.h:23
This file is work in progress and currently not part of the official Singular.
matrix singflint_kernel(matrix m, const ring R)
#define COMM_PLURAL
Definition gentable.cc:31
static int _gentable_sort_cmds(const void *a, const void *b)
compares to entry of cmdsname-list
Definition gentable.cc:191
#define jjWRONG3
Definition gentable.cc:126
#define NO_ZERODIVISOR
Definition gentable.cc:42
#define NO_LRING
Definition gentable.cc:54
#define NO_CONVERSION
Definition gentable.cc:51
int iiTestConvert(int inputType, int outputType)
Definition gentable.cc:298
const char * iiTwoOps(int t)
Definition gentable.cc:258
#define ALLOW_LP
Definition gentable.cc:33
#define RING_MASK
Definition gentable.cc:20
#define WARN_RING
Definition gentable.cc:49
#define NC_MASK
Definition gentable.cc:34
#define jjWRONG2
Definition gentable.cc:125
const char * Tok2Cmdname(int tok)
Definition gentable.cc:137
#define jjWRONG
Definition gentable.cc:124
static int RingDependend(int t)
Definition gentable.cc:23
#define NO_NC
Definition gentable.cc:29
#define ZERODIVISOR_MASK
Definition gentable.cc:21
#define STATIC_VAR
Definition globaldefs.h:7
#define EXTERN_VAR
Definition globaldefs.h:6
#define VAR
Definition globaldefs.h:5
@ PLUSPLUS
Definition grammar.cc:274
@ END_RING
Definition grammar.cc:311
@ IDEAL_CMD
Definition grammar.cc:285
@ MATRIX_CMD
Definition grammar.cc:287
@ BUCKET_CMD
Definition grammar.cc:284
@ BIGINTMAT_CMD
Definition grammar.cc:278
@ IMAP_CMD
Definition grammar.cc:299
@ GE
Definition grammar.cc:269
@ EQUAL_EQUAL
Definition grammar.cc:268
@ MAP_CMD
Definition grammar.cc:286
@ PROC_CMD
Definition grammar.cc:281
@ LE
Definition grammar.cc:270
@ BEGIN_RING
Definition grammar.cc:283
@ INTMAT_CMD
Definition grammar.cc:280
@ MODUL_CMD
Definition grammar.cc:288
@ SMATRIX_CMD
Definition grammar.cc:292
@ VECTOR_CMD
Definition grammar.cc:293
@ RESOLUTION_CMD
Definition grammar.cc:291
@ NOTEQUAL
Definition grammar.cc:273
@ BIGINTVEC_CMD
Definition grammar.cc:279
@ NUMBER_CMD
Definition grammar.cc:289
@ POLY_CMD
Definition grammar.cc:290
@ RING_CMD
Definition grammar.cc:282
@ FETCH_CMD
Definition grammar.cc:296
int cmdtok
Definition grammar.cc:174
BOOLEAN expected_parms
Definition grammar.cc:173
int yyparse(void)
Definition grammar.cc:2149
BOOLEAN yyInRingConstruction
Definition grammar.cc:172
ideal scKBase(int deg, ideal s, ideal Q, intvec *mv)
Definition hdegree.cc:1413
int scDimIntRing(ideal vid, ideal Q)
scDimInt for ring-coefficients
Definition hdegree.cc:136
long scMult0Int(ideal S, ideal Q)
Definition hdegree.cc:924
intvec * scIndIntvec(ideal S, ideal Q)
Definition hdegree.cc:284
int lp_kDim(const ideal _G)
Definition hdegree.cc:2080
int lp_gkDim(const ideal _G)
Definition hdegree.cc:1826
int scMultInt(ideal S, ideal Q)
Definition hdegree.cc:901
poly hFirstSeries0m(ideal A, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const ring Qt)
Definition hilb.cc:2080
poly hFirstSeries0p(ideal A, ideal Q, intvec *wdegree, const ring src, const ring Qt)
Definition hilb.cc:2037
intvec * hSecondSeries(intvec *hseries1)
Definition hilb.cc:707
intvec * hFirstSeries(ideal A, intvec *module_w, ideal Q, intvec *wdegree)
Definition hilb.cc:2167
bigintmat * hFirstSeries0b(ideal I, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const coeffs biv_cf)
Definition hilb.cc:2672
bigintmat * hSecondSeries0b(ideal I, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const coeffs biv_cf)
Definition hilb.cc:2694
void scDegree(ideal S, intvec *modulweight, ideal Q)
Definition hilb.cc:2710
void hLookSeries(ideal S, intvec *modulweight, ideal Q, intvec *wdegree)
Definition hilb.cc:873
GbVariant syGetAlgorithm(char *n, const ring r, const ideal)
Definition ideals.cc:3641
matrix idCoeffOfKBase(ideal arg, ideal kbase, poly how)
Definition ideals.cc:2629
void idLiftW(ideal P, ideal Q, int n, matrix &T, ideal &R, int *w)
Definition ideals.cc:1336
ideal idSyzygies(ideal h1, tHomog h, intvec **w, BOOLEAN setSyzComp, BOOLEAN setRegularity, int *deg, GbVariant alg)
Definition ideals.cc:830
matrix idDiff(matrix i, int k)
Definition ideals.cc:2146
BOOLEAN idTestHomModule(ideal m, ideal Q, intvec *w)
Definition ideals.cc:2077
ideal idLiftStd(ideal h1, matrix *T, tHomog hi, ideal *S, GbVariant alg, ideal h11)
Definition ideals.cc:976
ideal idQuot(ideal h1, ideal h2, BOOLEAN h1IsStb, BOOLEAN resultIsIdeal)
Definition ideals.cc:1506
ideal idSeries(int n, ideal M, matrix U, intvec *w)
Definition ideals.cc:2129
ideal idMinEmbedding_with_map_v(ideal arg, intvec **w, ideal &trans, int *g)
Definition ideals.cc:2835
matrix idDiffOp(ideal I, ideal J, BOOLEAN multiply)
Definition ideals.cc:2159
ideal idElimination(ideal h1, poly delVar, intvec *hilb, GbVariant alg)
Definition ideals.cc:1605
ideal idSect(ideal h1, ideal h2, GbVariant alg)
Definition ideals.cc:315
ideal idMultSect(resolvente arg, int length, GbVariant alg)
Definition ideals.cc:471
ideal idLift(ideal mod, ideal submod, ideal *rest, BOOLEAN goodShape, BOOLEAN isSB, BOOLEAN divide, matrix *unit, GbVariant alg)
represents the generators of submod in terms of the generators of mod (Matrix(SM)*U-Matrix(rest)) = M...
Definition ideals.cc:1105
ideal idModulo(ideal h2, ideal h1, tHomog hom, intvec **w, matrix *T, GbVariant alg)
Definition ideals.cc:2422
ideal idMinBase(ideal h1, ideal *SB)
Definition ideals.cc:51
ideal id_Farey(ideal x, number N, const ring r)
Definition ideals.cc:3064
ideal idMinEmbedding(ideal arg, BOOLEAN inPlace, intvec **w)
Definition ideals.cc:2814
GbVariant
Definition ideals.h:119
@ GbDefault
Definition ideals.h:120
#define idDelete(H)
delete an ideal
Definition ideals.h:29
#define idSimpleAdd(A, B)
Definition ideals.h:42
#define idIsConstant(I)
Definition ideals.h:40
ideal id_Copy(ideal h1, const ring r)
copy an ideal
static BOOLEAN idIsZeroDim(ideal i)
Definition ideals.h:179
static BOOLEAN idHomModule(ideal m, ideal Q, intvec **w)
Definition ideals.h:96
#define idTest(id)
Definition ideals.h:47
static BOOLEAN idHomIdeal(ideal id, ideal Q=NULL)
Definition ideals.h:91
static ideal idMult(ideal h1, ideal h2)
hh := h1 * h2
Definition ideals.h:84
ideal idCopy(ideal A)
Definition ideals.h:60
ideal idAdd(ideal h1, ideal h2)
h1 + h2
Definition ideals.h:68
#define idMaxIdeal(D)
initialise the maximal ideal (at 0)
Definition ideals.h:33
ideal * resolvente
Definition ideals.h:18
static intvec * idSort(ideal id, BOOLEAN nolex=TRUE)
Definition ideals.h:187
ideal interpolation(const std::vector< ideal > &L, intvec *v)
EXTERN_VAR int inerror
static BOOLEAN length(leftv result, leftv arg)
Definition interval.cc:257
intvec * ivSub(intvec *a, intvec *b)
Definition intvec.cc:297
int ivTrace(intvec *o)
Definition intvec.cc:339
intvec * ivAdd(intvec *a, intvec *b)
Definition intvec.cc:249
intvec * ivMult(intvec *a, intvec *b)
Definition intvec.cc:349
intvec * ivTranp(intvec *o)
Definition intvec.cc:327
intvec * ivCopy(const intvec *o)
Definition intvec.h:145
#define ivTest(v)
Definition intvec.h:169
#define IMATELEM(M, I, J)
Definition intvec.h:85
static BOOLEAN jjUMINUS_MA(leftv res, leftv u)
Definition iparith.cc:3828
static BOOLEAN jjOP_BIM_I(leftv res, leftv u, leftv v)
Definition iparith.cc:243
static BOOLEAN jjRANK1(leftv res, leftv v)
Definition iparith.cc:4958
static BOOLEAN jjINDEX_V_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1522
static BOOLEAN jjIMPART(leftv res, leftv v)
Definition iparith.cc:4455
static BOOLEAN jjIm2Iv(leftv res, leftv v)
Definition iparith.cc:4448
const char * name
Definition gentable.cc:58
#define SIMPL_EQU
Definition iparith.cc:3344
static BOOLEAN jjQUOT(leftv res, leftv u, leftv v)
Definition iparith.cc:3101
static BOOLEAN jjUMINUS_IV(leftv res, leftv u)
Definition iparith.cc:3834
static BOOLEAN jjOPPOSITE(leftv res, leftv a)
Definition iparith.cc:5300
static int _gentable_sort_cmds(const void *a, const void *b)
compares to entry of cmdsname-list
Definition iparith.cc:9939
BOOLEAN jjWAITALL1(leftv res, leftv u)
Definition iparith.cc:5541
static BOOLEAN jjRESTART(leftv, leftv u)
Definition iparith.cc:8965
static BOOLEAN jjidHead(leftv res, leftv v)
Definition iparith.cc:5703
static BOOLEAN jjHILBERT(leftv, leftv v)
Definition iparith.cc:4339
static BOOLEAN jjTIMES_MA_P1(leftv res, leftv u, leftv v)
Definition iparith.cc:1098
static BOOLEAN jjLEADMONOM(leftv res, leftv v)
Definition iparith.cc:4614
static BOOLEAN jjOP_IV_I(leftv res, leftv u, leftv v)
Definition iparith.cc:279
static BOOLEAN jjstrlen(leftv res, leftv v)
Definition iparith.cc:5668
static BOOLEAN jjBRACK_Bim(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:5825
static BOOLEAN jjEXTGCD_P(leftv res, leftv u, leftv v)
Definition iparith.cc:2046
static BOOLEAN jjDET_BI(leftv res, leftv v)
Definition iparith.cc:4096
BOOLEAN jjWAIT1ST1(leftv res, leftv u)
Definition iparith.cc:5526
BOOLEAN jjLOAD(const char *s, BOOLEAN autoexport)
load lib/module given in v
Definition iparith.cc:5576
static BOOLEAN jjMATRIX_Mo(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6955
static BOOLEAN jjP2I(leftv res, leftv v)
Definition iparith.cc:4872
static BOOLEAN jjIS_RINGVAR_P(leftv res, leftv v)
Definition iparith.cc:4482
static BOOLEAN jjDOTDOT(leftv res, leftv u, leftv v)
Definition iparith.cc:332
static BOOLEAN jjFWALK3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6206
static BOOLEAN jjREPART(leftv res, leftv v)
Definition iparith.cc:4974
static BOOLEAN jjTIMES_MA_BI2(leftv res, leftv u, leftv v)
Definition iparith.cc:1094
static BOOLEAN jjMAP(leftv res, leftv u, leftv v)
Definition iparith.cc:1651
static BOOLEAN jjGT_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:1182
static BOOLEAN jjN2BI(leftv res, leftv v)
Definition iparith.cc:4755
static BOOLEAN jjRESERVEDLIST0(leftv res, leftv)
Definition iparith.cc:8513
short start
Definition iparith.cc:126
static BOOLEAN jjCHAR(leftv res, leftv v)
Definition iparith.cc:3943
static BOOLEAN jjOP_I_IM(leftv res, leftv u, leftv v)
Definition iparith.cc:315
static BOOLEAN jjBRACK_Ma_IV_I(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:5961
static BOOLEAN jjROWS_IV(leftv res, leftv v)
Definition iparith.cc:5019
static BOOLEAN jjLIFTSTD(leftv res, leftv u, leftv v)
Definition iparith.cc:2607
static BOOLEAN jjNULL(leftv, leftv)
Definition iparith.cc:3778
static BOOLEAN jjNEWSTRUCT2(leftv, leftv u, leftv v)
Definition iparith.cc:2805
static BOOLEAN jjBIV2IV(leftv res, leftv v)
Definition iparith.cc:4473
static BOOLEAN jjMONITOR2(leftv res, leftv u, leftv v)
Definition iparith.cc:2740
static BOOLEAN jjDIM(leftv res, leftv v)
Definition iparith.cc:4152
static BOOLEAN jjCOUNT_BIM(leftv res, leftv v)
Definition iparith.cc:3983
static BOOLEAN jjBRACKET(leftv res, leftv a, leftv b)
Definition iparith.cc:2916
static BOOLEAN jjCOLS_IV(leftv res, leftv v)
Definition iparith.cc:3965
static BOOLEAN jjNAMES_I(leftv res, leftv v)
Definition iparith.cc:4785
static BOOLEAN jjMULT(leftv res, leftv v)
Definition iparith.cc:4735
static BOOLEAN jjHOMOG1_WI(leftv res, leftv v, leftv u)
Definition iparith.cc:2505
static BOOLEAN jjPARDEG(leftv res, leftv v)
Definition iparith.cc:4828
static BOOLEAN jjDENOMINATOR(leftv res, leftv v)
Return the denominator of the input number.
Definition iparith.cc:4073
static BOOLEAN jjRANDOM(leftv res, leftv u, leftv v)
Definition iparith.cc:3108
static BOOLEAN jjIDEAL_Ma(leftv res, leftv v)
Definition iparith.cc:4412
static BOOLEAN jjDIVISION(leftv res, leftv u, leftv v)
Definition iparith.cc:1952
static BOOLEAN jjOP_I_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:296
static BOOLEAN jjmpTransp(leftv res, leftv v)
Definition iparith.cc:5731
static BOOLEAN jjOPTION_PL(leftv res, leftv v)
Definition iparith.cc:8362
static BOOLEAN jjEQUAL_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:1321
static BOOLEAN jjDET_S(leftv res, leftv v)
Definition iparith.cc:4146
static BOOLEAN jjL2R(leftv res, leftv v)
Definition iparith.cc:4574
static BOOLEAN jjREDUCE5(leftv res, leftv u)
Definition iparith.cc:8443
static BOOLEAN jjrCharStr(leftv res, leftv v)
Definition iparith.cc:5693
static BOOLEAN jjSUBST_Id_I(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6914
static BOOLEAN jjMINUS_B_P(leftv res, leftv u, leftv v)
Definition iparith.cc:908
static BOOLEAN jjHILBERT_IV(leftv res, leftv v)
Definition iparith.cc:4352
int iiArithFindCmd(const char *szName)
Definition iparith.cc:10011
static BOOLEAN jjIDEAL_R(leftv res, leftv v)
Definition iparith.cc:4431
static BOOLEAN jjINDEPSET(leftv res, leftv v)
Definition iparith.cc:4460
static BOOLEAN jjTYPEOF(leftv res, leftv v)
Definition iparith.cc:5414
static BOOLEAN jjLU_SOLVE(leftv res, leftv v)
Definition iparith.cc:7807
static BOOLEAN jjFACSTD(leftv res, leftv v)
Definition iparith.cc:4215
static BOOLEAN jjMEMORY(leftv res, leftv v)
Definition iparith.cc:4690
static BOOLEAN jjidTransp(leftv res, leftv v)
Definition iparith.cc:5761
static BOOLEAN jjLIFT(leftv res, leftv u, leftv v)
Definition iparith.cc:2587
static BOOLEAN jjUMINUS_BIM(leftv res, leftv u)
Definition iparith.cc:3841
static BOOLEAN jjSUBST_Bu(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6818
static BOOLEAN jjTIMES_MA_N2(leftv res, leftv u, leftv v)
Definition iparith.cc:1123
static BOOLEAN jjDIM_R(leftv res, leftv v)
Definition iparith.cc:5756
BOOLEAN jjSORTLIST(leftv, leftv arg)
Definition iparith.cc:10476
static BOOLEAN jjDUMP(leftv, leftv v)
Definition iparith.cc:4180
static BOOLEAN jjpMaxComp(leftv res, leftv v)
Definition iparith.cc:5721
static BOOLEAN jjCOEFFS1(leftv res, leftv v)
Definition iparith.cc:3948
static BOOLEAN jjREDUCE3_ID(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7207
static BOOLEAN jjELIMIN_HILB(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6160
static int jjCOMPARE_ALL(const void *aa, const void *bb)
Definition iparith.cc:10435
static BOOLEAN jjNAMEOF(leftv res, leftv v)
Definition iparith.cc:4767
static BOOLEAN jjPlural_mat_poly(leftv res, leftv a, leftv b)
Definition iparith.cc:2876
static BOOLEAN jjTIMES_SM(leftv res, leftv u, leftv v)
Definition iparith.cc:1150
static BOOLEAN jjMOD_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:2695
BOOLEAN jjUNIQLIST(leftv, leftv arg)
Definition iparith.cc:10485
static BOOLEAN jjTIMES_MA_I2(leftv res, leftv u, leftv v)
Definition iparith.cc:1132
static BOOLEAN jjSTATUS2L(leftv res, leftv u, leftv v)
Definition iparith.cc:3436
BOOLEAN(* proc3)(leftv, leftv, leftv, leftv)
Definition iparith.cc:160
static BOOLEAN jjGT_I(leftv res, leftv u, leftv v)
Definition iparith.cc:1189
static BOOLEAN jjPRIME(leftv res, leftv v)
Definition iparith.cc:4890
static BOOLEAN jjPFAC2(leftv res, leftv u, leftv v)
Definition iparith.cc:3288
static BOOLEAN jjidVec2Ideal(leftv res, leftv v)
Definition iparith.cc:5688
static BOOLEAN jjJACOB_P(leftv res, leftv v)
Definition iparith.cc:4498
static BOOLEAN jjSQR_FREE(leftv res, leftv u)
Definition iparith.cc:5187
static BOOLEAN jjSTD_HILB_W(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7270
static BOOLEAN jjEQUAL_I(leftv res, leftv u, leftv v)
Definition iparith.cc:1327
static BOOLEAN jjTIMES_MA_P2(leftv res, leftv u, leftv v)
Definition iparith.cc:1107
static BOOLEAN jjMODULO3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6994
static BOOLEAN jjSBA_1(leftv res, leftv v, leftv u)
Definition iparith.cc:5102
#define SIMPL_NORM
Definition iparith.cc:3346
static BOOLEAN jjCOEFFS3_P(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6125
static BOOLEAN jjCALL1MANY(leftv res, leftv u)
Definition iparith.cc:3939
static BOOLEAN jjPLUS_MA(leftv res, leftv u, leftv v)
Definition iparith.cc:823
short tokval
Definition gentable.cc:60
static BOOLEAN jjMINUS_V(leftv res, leftv u, leftv v)
Definition iparith.cc:903
static BOOLEAN jjINTERRED(leftv res, leftv v)
Definition iparith.cc:4466
static BOOLEAN jjJACOB_M(leftv res, leftv a)
Definition iparith.cc:4529
static BOOLEAN jjJET_ID_IV(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6363
static BOOLEAN jjTIMES_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:1053
static BOOLEAN jjBAREISS(leftv res, leftv v)
Definition iparith.cc:3873
static BOOLEAN jjREAD(leftv res, leftv v)
Definition iparith.cc:4965
static BOOLEAN jjLT_N(leftv res, leftv u, leftv v)
Definition iparith.cc:1221
static BOOLEAN jjMINUS_MA(leftv res, leftv u, leftv v)
Definition iparith.cc:951
static BOOLEAN jjFactModD_M(leftv res, leftv v)
Definition iparith.cc:8646
static BOOLEAN jjMATRIX_Id(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6932
static BOOLEAN jjEXTGCD_I(leftv res, leftv u, leftv v)
Definition iparith.cc:2018
static BOOLEAN jjIS_RINGVAR_S(leftv res, leftv v)
Definition iparith.cc:4487
static BOOLEAN jjDelete_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:1867
static BOOLEAN jjLE_N(leftv res, leftv u, leftv v)
Definition iparith.cc:1208
static BOOLEAN jjSUBST_P(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6831
static BOOLEAN jjROWS_BIM(leftv res, leftv v)
Definition iparith.cc:5014
static BOOLEAN jjCOMPARE_S(leftv res, leftv u, leftv v)
Definition iparith.cc:478
#define SIMPL_LMEQ
Definition iparith.cc:3342
int iiInitArithmetic()
initialisation of arithmetic structured data
Definition iparith.cc:9976
static BOOLEAN jjOR_I(leftv res, leftv u, leftv v)
Definition iparith.cc:1383
static BOOLEAN jjTIMES_MA_I1(leftv res, leftv u, leftv v)
Definition iparith.cc:1127
static BOOLEAN jjLIFTSTD_SYZ(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7131
static BOOLEAN jjBAREISS3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6080
static BOOLEAN jjRESERVED0(leftv, leftv)
Definition iparith.cc:8491
static BOOLEAN jjTIMES_MA_N1(leftv res, leftv u, leftv v)
Definition iparith.cc:1116
static BOOLEAN jjLIFT_4(leftv res, leftv U)
Definition iparith.cc:8118
static BOOLEAN jjSLIM_GB(leftv res, leftv u)
Definition iparith.cc:5034
static BOOLEAN jjMSTD(leftv res, leftv v)
Definition iparith.cc:4720
#define bit31
Definition iparith.cc:120
short cmd
Definition iparith.cc:125
static BOOLEAN jjBREAK1(leftv, leftv v)
Definition iparith.cc:7326
static BOOLEAN jjJET_ID_M(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6369
static BOOLEAN jjMINUS_BIM(leftv res, leftv u, leftv v)
Definition iparith.cc:941
static BOOLEAN jjnInt(leftv res, leftv u)
Definition iparith.cc:5766
static BOOLEAN jjSQR_FREE2(leftv res, leftv u, leftv dummy)
Definition iparith.cc:3384
static BOOLEAN jjCOEFFS3_Id(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6105
static BOOLEAN jjREGULARITY(leftv res, leftv v)
Definition iparith.cc:4969
static BOOLEAN jjHOMOG_W_M(leftv res, leftv v1, leftv v2, leftv v3)
Definition iparith.cc:6303
static BOOLEAN jjMINUS_N(leftv res, leftv u, leftv v)
Definition iparith.cc:898
static BOOLEAN jjBREAK0(leftv, leftv)
Definition iparith.cc:7319
static BOOLEAN jjTRACE_IV(leftv res, leftv v)
Definition iparith.cc:5285
BOOLEAN iiExprArith2(leftv res, leftv a, int op, leftv b, BOOLEAN proccall)
Definition iparith.cc:9164
static BOOLEAN jjMONOM(leftv res, leftv v)
Definition iparith.cc:2781
static BOOLEAN jjSort_Id(leftv res, leftv v)
Definition iparith.cc:5182
static BOOLEAN jjCOEF_M(leftv, leftv v)
Definition iparith.cc:7367
static BOOLEAN jjidMinBase(leftv res, leftv v)
Definition iparith.cc:5709
static BOOLEAN jjDEG_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1846
static BOOLEAN jjRING_2(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6068
static BOOLEAN jjMINUS_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:931
static BOOLEAN jjPREIMAGE_R(leftv res, leftv v)
Definition iparith.cc:4884
static BOOLEAN jjHOMOG_P(leftv res, leftv u, leftv v)
Definition iparith.cc:2446
static BOOLEAN jjBRACK_Im(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:5798
static BOOLEAN jjMATRIX_Ma(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6968
static BOOLEAN jjidMaxIdeal(leftv res, leftv v)
Definition iparith.cc:4395
static BOOLEAN jjMINOR_M(leftv res, leftv v)
Definition iparith.cc:6380
static BOOLEAN jjCOUNT_BI(leftv res, leftv v)
Definition iparith.cc:3978
static BOOLEAN jjPROC3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6061
static BOOLEAN jjKERNEL_M(leftv res, leftv v)
Definition iparith.cc:4550
static BOOLEAN jjCOLS_BIM(leftv res, leftv v)
Definition iparith.cc:3960
static BOOLEAN jjREDUCE3_CP(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7176
struct sValCmd3 * psValCmd3
Definition iparith.cc:185
static BOOLEAN jjBRACK_Ma_I_IV(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:5911
static BOOLEAN jjLE_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:1199
static BOOLEAN jjPLUS_B_P(leftv res, leftv u, leftv v)
Definition iparith.cc:794
static BOOLEAN jjPlural_mat_mat(leftv res, leftv a, leftv b)
Definition iparith.cc:2896
static BOOLEAN jjIDEAL_Map(leftv res, leftv v)
Definition iparith.cc:4421
static BOOLEAN jjPARSTR2(leftv res, leftv u, leftv v)
Definition iparith.cc:2819
BOOLEAN(* proc2)(leftv, leftv, leftv)
Definition iparith.cc:149
static BOOLEAN jjKoszul(leftv res, leftv u, leftv v)
Definition iparith.cc:2575
static BOOLEAN jjTIMES_N(leftv res, leftv u, leftv v)
Definition iparith.cc:996
static BOOLEAN jjINTERSECT_PL(leftv res, leftv v)
Definition iparith.cc:7652
static BOOLEAN jjTIMES_MA(leftv res, leftv u, leftv v)
Definition iparith.cc:1136
static BOOLEAN jjTIMES_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1060
static BOOLEAN jjPLUS_I(leftv res, leftv u, leftv v)
Definition iparith.cc:754
static BOOLEAN jjINTERSEC3S(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6338
static BOOLEAN jjRES3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7215
static BOOLEAN jjBIGINTVEC_PL(leftv res, leftv v)
Definition iparith.cc:7921
static BOOLEAN jjJET_P_IV(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6346
static BOOLEAN jjREDUCE_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:3149
static BOOLEAN jjCOEF(leftv res, leftv u, leftv v)
Definition iparith.cc:1791
BOOLEAN iiExprArith3Tab(leftv res, leftv a, int op, const struct sValCmd3 *dA3, int at, const struct sConvertTypes *dConvertTypes)
apply an operation 'op' to arguments a, a->next and a->next->next return TRUE on failure
Definition iparith.cc:9615
static BOOLEAN jjOP_REST(leftv res, leftv u, leftv v)
Definition iparith.cc:505
static BOOLEAN jjEXECUTE(leftv, leftv v)
Definition iparith.cc:4206
static BOOLEAN jjDEG_M_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1835
static BOOLEAN jjSTATUS3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7261
static BOOLEAN jjLEADEXP(leftv res, leftv v)
Definition iparith.cc:4596
static BOOLEAN jjDEG_M(leftv res, leftv u)
Definition iparith.cc:4033
static BOOLEAN jjPLUS_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:803
static BOOLEAN jjDIFF_COEF(leftv res, leftv u, leftv v)
Definition iparith.cc:4510
int iiArithRemoveCmd(char *szName)
static BOOLEAN jjGE_N(leftv res, leftv u, leftv v)
Definition iparith.cc:1176
static BOOLEAN jjEQUAL_SM(leftv res, leftv u, leftv v)
Definition iparith.cc:1339
static BOOLEAN jjINTERPOLATION(leftv res, leftv l, leftv v)
Definition iparith.cc:2525
static BOOLEAN jjSIMPL_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:3347
static BOOLEAN jjRING3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7256
static BOOLEAN jjREDUCE_P(leftv res, leftv u, leftv v)
Definition iparith.cc:3141
static BOOLEAN jjDIV_Ma(leftv res, leftv u, leftv v)
Definition iparith.cc:1292
static BOOLEAN jjFRES3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:2312
static BOOLEAN jjMODULO(leftv res, leftv u, leftv v)
Definition iparith.cc:2642
static BOOLEAN jjCOMPARE_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:338
STATIC_VAR int WerrorS_dummy_cnt
Definition iparith.cc:5647
static BOOLEAN jjREAD2(leftv res, leftv u, leftv v)
Definition iparith.cc:3125
static BOOLEAN jjREDUCE3_P(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7200
static BOOLEAN jjPAR1(leftv res, leftv v)
Definition iparith.cc:4812
static BOOLEAN jjnlInt(leftv res, leftv u)
Definition iparith.cc:5773
cmdnames * sCmds
array of existing commands
Definition iparith.cc:182
static BOOLEAN jjFAREY_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:2143
static BOOLEAN jjPLUS_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:872
static BOOLEAN jjGCD_N(leftv res, leftv u, leftv v)
Definition iparith.cc:2385
static BOOLEAN jjELIMIN(leftv res, leftv u, leftv v)
Definition iparith.cc:1972
static BOOLEAN jjPLUSPLUS(leftv, leftv u)
Definition iparith.cc:3792
static Subexpr jjMakeSub(leftv e)
Definition iparith.cc:8958
static BOOLEAN jjCHINREM_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:1680
static BOOLEAN jjROWS(leftv res, leftv v)
Definition iparith.cc:5008
static BOOLEAN jjJET_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:2553
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:8991
int IsCmd(const char *n, int &tok)
Definition iparith.cc:9761
static BOOLEAN jjSBA(leftv res, leftv v)
Definition iparith.cc:5076
static BOOLEAN jjOP_IM_I(leftv res, leftv u, leftv v)
Definition iparith.cc:300
static BOOLEAN jjJanetBasis(leftv res, leftv v)
Definition iparith.cc:2543
static BOOLEAN jjKBASE(leftv res, leftv v)
Definition iparith.cc:4568
static BOOLEAN jjTENSOR(leftv res, leftv u, leftv v)
Definition iparith.cc:3638
static BOOLEAN jjmpTrace(leftv res, leftv v)
Definition iparith.cc:5726
static BOOLEAN jjRING_PL(leftv res, leftv a)
Definition iparith.cc:8936
static BOOLEAN jjREDUCE4(leftv res, leftv u)
Definition iparith.cc:8372
static BOOLEAN jjFWALK(leftv res, leftv u, leftv v)
Definition iparith.cc:2359
static BOOLEAN jjTEST(leftv, leftv v)
Definition iparith.cc:8627
static BOOLEAN jjDIFF_ID_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:1930
static BOOLEAN jjSYZ_2(leftv res, leftv u, leftv v)
Definition iparith.cc:3575
static BOOLEAN jjPRUNE(leftv res, leftv v)
Definition iparith.cc:4896
static BOOLEAN jjDIVISION4(leftv res, leftv v)
Definition iparith.cc:7384
unsigned nLastIdentifier
valid identifiers are slot 1..nLastIdentifier
Definition iparith.cc:189
static BOOLEAN jjDEFINED(leftv res, leftv v)
Definition iparith.cc:4061
static BOOLEAN jjLagSolve(leftv res, leftv v)
Definition iparith.cc:4651
static BOOLEAN jjRING_1(leftv res, leftv u, leftv v)
Definition iparith.cc:1671
static BOOLEAN jjVDIM(leftv res, leftv v)
Definition iparith.cc:5499
static BOOLEAN jjOP_I_BIM(leftv res, leftv u, leftv v)
Definition iparith.cc:258
static BOOLEAN jjCOUNT_N(leftv res, leftv v)
Definition iparith.cc:3989
static BOOLEAN jjHILBERT2(leftv res, leftv u, leftv v)
Definition iparith.cc:2408
static BOOLEAN jjFIND2(leftv res, leftv u, leftv v)
Definition iparith.cc:2294
static BOOLEAN jjCOEF_Id(leftv res, leftv u, leftv v)
Definition iparith.cc:1798
static BOOLEAN jjP2N(leftv res, leftv v)
Definition iparith.cc:4920
static BOOLEAN jjE(leftv res, leftv v)
Definition iparith.cc:4194
static BOOLEAN jjPOWER_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:624
static BOOLEAN jjTIMES_MA_BI1(leftv res, leftv u, leftv v)
Definition iparith.cc:1084
BOOLEAN iiExprArith1(leftv res, leftv a, int op)
Definition iparith.cc:9353
static BOOLEAN jjSTD_HILB_WP(leftv res, leftv INPUT)
Definition iparith.cc:8853
static BOOLEAN jjLISTRING(leftv res, leftv v)
Definition iparith.cc:4633
static BOOLEAN jjCOEFFS2_KB(leftv res, leftv u, leftv v)
Definition iparith.cc:1816
#define SIMPL_NULL
Definition iparith.cc:3345
static BOOLEAN jjLIFTSTD_M(leftv res, leftv U)
Definition iparith.cc:8149
static BOOLEAN jjELIMIN_ALG(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6152
static BOOLEAN jjVAR1(leftv res, leftv v)
Definition iparith.cc:5465
static BOOLEAN jjLEADCOEF(leftv res, leftv v)
Definition iparith.cc:4582
static BOOLEAN jjVARSTR2(leftv res, leftv u, leftv v)
Definition iparith.cc:3664
static BOOLEAN jjPLUS_N(leftv res, leftv u, leftv v)
Definition iparith.cc:771
static BOOLEAN jjSUBST_Id_X(leftv res, leftv u, leftv v, leftv w, int input_type)
Definition iparith.cc:6922
static BOOLEAN jjUMINUS_BI(leftv res, leftv u)
Definition iparith.cc:3804
int iiArithAddCmd(const char *szName, short nAlias, short nTokval, short nToktype, short nPos=-1)
Definition iparith.cc:10106
static BOOLEAN jjpLength(leftv res, leftv v)
Definition iparith.cc:5673
static BOOLEAN jjJET_P_P(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6353
static BOOLEAN jjLT_I(leftv res, leftv u, leftv v)
Definition iparith.cc:1216
static BOOLEAN jjIS_RINGVAR0(leftv res, leftv)
Definition iparith.cc:4493
static BOOLEAN jjEXTGCD_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:2004
static BOOLEAN jjBI2P(leftv res, leftv u)
Definition iparith.cc:3924
static BOOLEAN jjTWOSTD(leftv res, leftv a)
Definition iparith.cc:5334
static BOOLEAN jjGCD_I(leftv res, leftv u, leftv v)
Definition iparith.cc:2365
static BOOLEAN jjCONTRACT(leftv res, leftv u, leftv v)
Definition iparith.cc:1830
short toktype
Definition gentable.cc:61
static BOOLEAN jjFAC_P(leftv res, leftv u)
Definition iparith.cc:4255
static BOOLEAN jjREDUCE3_CID(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7188
static BOOLEAN jjFAREY_LI(leftv res, leftv u, leftv v)
Definition iparith.cc:10416
static BOOLEAN jjTRANSP_BIM(leftv res, leftv v)
Definition iparith.cc:5290
static BOOLEAN jjCOUNT_RES(leftv res, leftv v)
Definition iparith.cc:5751
#define ii_div_by_0
Definition iparith.cc:216
static BOOLEAN jjDelete_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1860
static BOOLEAN jjGE_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:1164
static BOOLEAN jjrOrdStr(leftv res, leftv v)
Definition iparith.cc:5736
static BOOLEAN jjKERNEL(leftv res, leftv u, leftv v)
Definition iparith.cc:2571
static BOOLEAN jjINTERSECT3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6325
static BOOLEAN jjBRACK_Ma(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:5853
sValCmdTab jjValCmdTab[]
Definition iparith.cc:129
static BOOLEAN jjMOD_N(leftv res, leftv u, leftv v)
Definition iparith.cc:2706
static BOOLEAN jjLOAD_E(leftv, leftv v, leftv u)
Definition iparith.cc:2631
static BOOLEAN jjNEWSTRUCT3(leftv, leftv u, leftv v, leftv w)
Definition iparith.cc:6659
static BOOLEAN jjHOMOG_P_W(leftv res, leftv u, leftv v, leftv)
Definition iparith.cc:6285
static BOOLEAN jjpHead(leftv res, leftv v)
Definition iparith.cc:5698
static BOOLEAN jjSUBST_Id(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6864
static BOOLEAN jjEQUAL_R(leftv res, leftv u, leftv v)
Definition iparith.cc:1345
static BOOLEAN jjCOUNT_L(leftv res, leftv v)
Definition iparith.cc:3994
struct sValCmdM * psValCmdM
Definition iparith.cc:186
static BOOLEAN jjDET_I(leftv res, leftv v)
Definition iparith.cc:4132
static BOOLEAN jjCOUNT_RG(leftv res, leftv v)
Definition iparith.cc:4011
static BOOLEAN jjSMATRIX_Mo(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7096
static BOOLEAN jjINTERSECT(leftv res, leftv u, leftv v)
Definition iparith.cc:2519
static BOOLEAN jjrVarStr(leftv res, leftv v)
Definition iparith.cc:5741
static BOOLEAN jjOP_BI_BIM(leftv res, leftv u, leftv v)
Definition iparith.cc:275
static BOOLEAN jjDIFF_P(leftv res, leftv u, leftv v)
Definition iparith.cc:1908
static BOOLEAN check_valid(const int p, const int op)
Definition iparith.cc:10165
static BOOLEAN jjSTRING_PL(leftv res, leftv v)
Definition iparith.cc:8593
static BOOLEAN jjMINUS_B(leftv res, leftv u, leftv v)
Definition iparith.cc:918
static BOOLEAN jjRSUM(leftv res, leftv u, leftv v)
Definition iparith.cc:3333
static BOOLEAN jjINDEX_I(leftv res, leftv u, leftv v)
Definition iparith.cc:1388
static BOOLEAN jjPOWER_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:567
static BOOLEAN jjMONITOR1(leftv res, leftv v)
Definition iparith.cc:2736
static BOOLEAN jjKLAMMER_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1570
static BOOLEAN jjFETCH(leftv res, leftv u, leftv v)
Definition iparith.cc:2166
static BOOLEAN jjCALL3ARG(leftv res, leftv u)
Definition iparith.cc:7355
static BOOLEAN jjSTD_1(leftv res, leftv u, leftv v)
Definition iparith.cc:3491
static BOOLEAN jjUMINUS_N(leftv res, leftv u)
Definition iparith.cc:3816
static BOOLEAN jjNUMERATOR(leftv res, leftv v)
Return the numerator of the input number.
Definition iparith.cc:4082
static BOOLEAN jjORD(leftv res, leftv v)
Definition iparith.cc:4806
static BOOLEAN jjTIMES_P(leftv res, leftv u, leftv v)
Definition iparith.cc:1006
static BOOLEAN jjUMINUS_I(leftv res, leftv u)
Definition iparith.cc:3811
static BOOLEAN jjPREIMAGE(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6669
static BOOLEAN jjBRACK_Ma_IV_IV(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6010
static BOOLEAN jjMRES_MAP(leftv res, leftv u, leftv v, leftv ma)
Definition iparith.cc:6576
static BOOLEAN jjPLUS_SM(leftv res, leftv u, leftv v)
Definition iparith.cc:835
BOOLEAN jjLOAD_TRY(const char *s)
Definition iparith.cc:5652
static BOOLEAN jjLIFT3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7109
static BOOLEAN jjENVELOPE(leftv res, leftv a)
Definition iparith.cc:5319
static BOOLEAN jjSetRing(leftv, leftv u)
Definition iparith.cc:3849
VAR int iiOp
Definition iparith.cc:218
static BOOLEAN jjMINUS_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:893
static BOOLEAN jjTIMES_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:989
static BOOLEAN jjFACSTD2(leftv res, leftv v, leftv w)
Definition iparith.cc:2110
static BOOLEAN jjINTVEC_PL(leftv res, leftv v)
Definition iparith.cc:7888
STATIC_VAR SArithBase sArithBase
Base entry for arithmetic.
Definition iparith.cc:197
static BOOLEAN jjEXPORTTO(leftv, leftv u, leftv v)
Definition iparith.cc:1992
static BOOLEAN jjPlural_num_poly(leftv res, leftv a, leftv b)
Definition iparith.cc:2836
static BOOLEAN jjDIV_P(leftv res, leftv u, leftv v)
Definition iparith.cc:1274
static BOOLEAN jjKBASE2(leftv res, leftv u, leftv v)
Definition iparith.cc:2558
static BOOLEAN jjPOWER_I(leftv res, leftv u, leftv v)
Definition iparith.cc:521
#define SIMPL_MULT
Definition iparith.cc:3343
static BOOLEAN jjRES(leftv res, leftv u, leftv v)
Definition iparith.cc:3158
static int iin_Int(number &n, coeffs cf)
Definition iparith.cc:221
static BOOLEAN jjPLUS_P_MA(leftv res, leftv u, leftv v)
Definition iparith.cc:858
static BOOLEAN jjMINRES_R(leftv res, leftv v)
Definition iparith.cc:4741
static BOOLEAN jjCOLS(leftv res, leftv v)
Definition iparith.cc:3955
static BOOLEAN jjPLUS_BIM(leftv res, leftv u, leftv v)
Definition iparith.cc:813
static BOOLEAN jjP2BI(leftv res, leftv v)
Definition iparith.cc:4852
static void WerrorS_dummy(const char *)
Definition iparith.cc:5648
static BOOLEAN jjGE_I(leftv res, leftv u, leftv v)
Definition iparith.cc:1171
long farey_cnt
Definition iparith.cc:9
static BOOLEAN jjTRANSP_IV(leftv res, leftv v)
Definition iparith.cc:5295
static BOOLEAN jjGT_N(leftv res, leftv u, leftv v)
Definition iparith.cc:1194
static BOOLEAN jjUNIVARIATE(leftv res, leftv v)
Definition iparith.cc:5460
static BOOLEAN jjMODULO4(leftv res, leftv u)
Definition iparith.cc:8290
static BOOLEAN jjHOMOG_ID_W(leftv res, leftv u, leftv v, leftv)
Definition iparith.cc:6267
static BOOLEAN jjWEDGE(leftv res, leftv u, leftv v)
Definition iparith.cc:3749
static BOOLEAN jjCOMPARE_P(leftv res, leftv u, leftv v)
Definition iparith.cc:451
static BOOLEAN jjFIND3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6175
static BOOLEAN jjLU_INVERSE(leftv res, leftv v)
Definition iparith.cc:7726
static BOOLEAN jjMODULO3S(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7045
static BOOLEAN jjBAREISS_BIM(leftv res, leftv v)
Definition iparith.cc:3896
static BOOLEAN jjPLUS_MA_P(leftv res, leftv u, leftv v)
Definition iparith.cc:847
static BOOLEAN jjSIMPL_P(leftv res, leftv u, leftv v)
Definition iparith.cc:3442
static BOOLEAN jjPFAC1(leftv res, leftv v)
Definition iparith.cc:4642
static BOOLEAN jjQRDS(leftv res, leftv INPUT)
Definition iparith.cc:8836
static BOOLEAN jjELIMIN_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1978
static BOOLEAN jjHILBERT3Qt(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6245
static BOOLEAN jjCONTENT(leftv res, leftv v)
Definition iparith.cc:3970
static BOOLEAN jjDIFF_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:1919
static BOOLEAN jjSTD(leftv res, leftv v)
Definition iparith.cc:5154
static BOOLEAN jjTIMES_BIM(leftv res, leftv u, leftv v)
Definition iparith.cc:1072
static BOOLEAN jjTIMES_I(leftv res, leftv u, leftv v)
Definition iparith.cc:977
static BOOLEAN jjDIV_N(leftv res, leftv u, leftv v)
Definition iparith.cc:1261
static BOOLEAN jjINTMAT3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6311
static BOOLEAN jjCOUNT_IV(leftv res, leftv v)
Definition iparith.cc:4006
static BOOLEAN jjFRES(leftv res, leftv u, leftv v)
Definition iparith.cc:2349
unsigned nCmdAllocated
number of commands-slots allocated
Definition iparith.cc:188
static BOOLEAN jjDUMMY(leftv res, leftv u)
Definition iparith.cc:3771
static BOOLEAN jjS2I(leftv res, leftv v)
Definition iparith.cc:5029
static BOOLEAN jjKLAMMER(leftv res, leftv u, leftv v)
Definition iparith.cc:1558
BOOLEAN iiExprArith2Tab(leftv res, leftv a, int op, const struct sValCmd2 *dA2, int at, const struct sConvertTypes *dConvertTypes)
apply an operation 'op' to arguments a and a->next return TRUE on failure
Definition iparith.cc:9150
static BOOLEAN jjBI2N(leftv res, leftv u)
Definition iparith.cc:3903
short alias
Definition gentable.cc:59
static BOOLEAN jjRIGHTSTD(leftv res, leftv v)
Definition iparith.cc:5353
BOOLEAN iiExprArithM(leftv res, leftv a, int op)
Definition iparith.cc:9654
static BOOLEAN jjCOMPARE_MA(leftv res, leftv u, leftv v)
Definition iparith.cc:423
BOOLEAN iiExprArith3(leftv res, int op, leftv a, leftv b, leftv c)
Definition iparith.cc:9563
static BOOLEAN jjGETDUMP(leftv, leftv v)
Definition iparith.cc:4271
static BOOLEAN jjidFreeModule(leftv res, leftv v)
Definition iparith.cc:5683
static BOOLEAN jjFAREY_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:2132
static BOOLEAN jjBRACKET_REC(leftv res, leftv a, leftv b, leftv c)
Definition iparith.cc:2943
static BOOLEAN jjCOMPARE_IV_I(leftv res, leftv u, leftv v)
Definition iparith.cc:396
static BOOLEAN jjRANDOM_Im(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6743
static BOOLEAN jjRESERVEDNAME(leftv res, leftv v)
Definition iparith.cc:4936
struct sValCmd1 * psValCmd1
Definition iparith.cc:183
static BOOLEAN jjDIVMOD_I(leftv res, leftv u, leftv v)
Definition iparith.cc:1225
static BOOLEAN jjLE_I(leftv res, leftv u, leftv v)
Definition iparith.cc:1203
static BOOLEAN jjTENSOR_Ma(leftv res, leftv u, leftv v)
Definition iparith.cc:3645
static BOOLEAN jjCOEFFS3_KB(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6119
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:9410
static BOOLEAN jjRMINUS(leftv res, leftv u, leftv v)
Definition iparith.cc:3314
BOOLEAN jjPROC(leftv res, leftv u, leftv v)
Definition iparith.cc:1615
static BOOLEAN jjPLUS_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:766
static BOOLEAN jjHILBERT3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6215
static BOOLEAN jjDET2(leftv res, leftv u, leftv v)
Definition iparith.cc:1894
static BOOLEAN jjSTD_HILB(leftv res, leftv u, leftv v)
Definition iparith.cc:3458
static BOOLEAN jjAND_I(leftv res, leftv u, leftv v)
Definition iparith.cc:1378
static BOOLEAN jjINDEX_P_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1486
static BOOLEAN jjRPAR(leftv res, leftv v)
Definition iparith.cc:5024
static BOOLEAN jjJanetBasis2(leftv res, leftv u, leftv v)
Definition iparith.cc:2537
static BOOLEAN jjLOAD1(leftv, leftv v)
Definition iparith.cc:4629
static BOOLEAN jjCOLON(leftv res, leftv u, leftv v)
Definition iparith.cc:319
const char * Tok2Cmdname(int tok)
Definition iparith.cc:9885
static BOOLEAN jjRPLUS(leftv res, leftv u, leftv v)
Definition iparith.cc:3320
static BOOLEAN jjKERNEL_SM(leftv res, leftv v)
Definition iparith.cc:4559
static BOOLEAN jjCOLCOL(leftv res, leftv u, leftv v)
Definition iparith.cc:692
long all_farey
Definition iparith.cc:8
static BOOLEAN jjFAC_P2(leftv res, leftv u, leftv dummy)
Definition iparith.cc:2063
static BOOLEAN jjHOMOG_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:2463
static BOOLEAN jjrParStr(leftv res, leftv v)
Definition iparith.cc:5746
struct sValCmd2 * psValCmd2
Definition iparith.cc:184
static BOOLEAN jjDEG(leftv res, leftv v)
Definition iparith.cc:4025
static BOOLEAN jjFETCH_M(leftv res, leftv u)
Definition iparith.cc:7527
static BOOLEAN jjINDEX_V(leftv res, leftv u, leftv v)
Definition iparith.cc:1515
static BOOLEAN jjRINGLIST(leftv res, leftv v)
Definition iparith.cc:4979
static BOOLEAN jjidElem(leftv res, leftv v)
Definition iparith.cc:5678
static BOOLEAN jjDIM2(leftv res, leftv v, leftv w)
Definition iparith.cc:1935
static BOOLEAN jjOP_BIM_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:262
static BOOLEAN jjGCD_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:2378
static BOOLEAN jjBI2IM(leftv res, leftv u)
Definition iparith.cc:3918
static BOOLEAN jjRANK2(leftv res, leftv u, leftv v)
Definition iparith.cc:3116
static BOOLEAN jjDEGREE(leftv res, leftv v)
Definition iparith.cc:4044
static BOOLEAN jjLIFTSTD_ALG(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7154
static BOOLEAN jjINDEPSET2(leftv res, leftv u, leftv v)
Definition iparith.cc:2512
static BOOLEAN jjWAITALL2(leftv res, leftv u, leftv v)
Definition iparith.cc:3701
static BOOLEAN jjOpenClose(leftv, leftv v)
Definition iparith.cc:4800
static BOOLEAN jjBRACK_S(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:5782
static BOOLEAN jjUMINUS_P(leftv res, leftv u)
Definition iparith.cc:3823
static BOOLEAN jjMINUS_SM(leftv res, leftv u, leftv v)
Definition iparith.cc:964
static BOOLEAN jjHIGHCORNER_M(leftv res, leftv v)
Definition iparith.cc:4292
static BOOLEAN jjNAMES(leftv res, leftv v)
Definition iparith.cc:4780
static BOOLEAN jjINDEX_P(leftv res, leftv u, leftv v)
Definition iparith.cc:1446
static BOOLEAN jjHIGHCORNER(leftv res, leftv v)
Definition iparith.cc:4285
static BOOLEAN jjEQUAL_Ma(leftv res, leftv u, leftv v)
Definition iparith.cc:1333
static BOOLEAN jjNAMES0(leftv res, leftv)
Definition iparith.cc:8357
#define SIMPL_NORMALIZE
Definition iparith.cc:3340
static BOOLEAN jjLOAD2(leftv, leftv, leftv v)
Definition iparith.cc:2627
static BOOLEAN jjALIGN_M(leftv res, leftv u, leftv v)
Definition iparith.cc:1777
static BOOLEAN jjWAIT1ST2(leftv res, leftv u, leftv v)
Definition iparith.cc:3677
static BOOLEAN jjDIV_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:1248
static BOOLEAN jjCOMPARE_BIM(leftv res, leftv u, leftv v)
Definition iparith.cc:366
static BOOLEAN jjEQUAL_N(leftv res, leftv u, leftv v)
Definition iparith.cc:1351
static BOOLEAN jjDelete_ID_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1874
static BOOLEAN jjDET2_S(leftv res, leftv u, leftv v)
Definition iparith.cc:1901
static BOOLEAN jjCOEFFS_Id(leftv res, leftv u, leftv v)
Definition iparith.cc:1805
STATIC_VAR si_char_2 Tok2Cmdname_buf
Definition iparith.cc:9884
static BOOLEAN jjPROC1(leftv res, leftv u)
Definition iparith.cc:3869
static BOOLEAN jjNOT(leftv res, leftv v)
Definition iparith.cc:4790
static BOOLEAN jjPARSTR1(leftv res, leftv v)
Definition iparith.cc:4834
static BOOLEAN jjSUBST_Id_N(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6918
static BOOLEAN jjJET4(leftv res, leftv u)
Definition iparith.cc:7982
static BOOLEAN jjOPPOSE(leftv res, leftv a, leftv b)
Definition iparith.cc:2984
static BOOLEAN jjMOD_P(leftv res, leftv u, leftv v)
Definition iparith.cc:2717
BOOLEAN iiExprArith1Tab(leftv res, leftv a, int op, const struct sValCmd1 *dA1, int at, const struct sConvertTypes *dConvertTypes)
apply an operation 'op' to an argument a return TRUE on failure
Definition iparith.cc:9223
static BOOLEAN jjPLUS_B(leftv res, leftv u, leftv v)
Definition iparith.cc:781
static BOOLEAN jjGCD_P(leftv res, leftv u, leftv v)
Definition iparith.cc:2402
static BOOLEAN jjHOMOG1(leftv res, leftv v)
Definition iparith.cc:4362
static BOOLEAN jjDET(leftv res, leftv v)
Definition iparith.cc:4090
static void jjEQUAL_REST(leftv res, leftv u, leftv v)
Definition iparith.cc:1365
static BOOLEAN jjCOUNT_M(leftv res, leftv v)
Definition iparith.cc:4000
static BOOLEAN jjPLUS_V(leftv res, leftv u, leftv v)
Definition iparith.cc:776
#define SIMPL_LMDIV
Definition iparith.cc:3341
int iiTokType(int op)
Definition iparith.cc:229
static BOOLEAN jjKoszul_Id(leftv res, leftv u, leftv v)
Definition iparith.cc:2579
static BOOLEAN jjKLAMMER_rest(leftv res, leftv u, leftv v)
Definition iparith.cc:1597
static BOOLEAN jjCHINREM_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:10217
static BOOLEAN jjPLUS_S(leftv res, leftv u, leftv v)
Definition iparith.cc:862
static BOOLEAN jjHOMOG1_W(leftv res, leftv v, leftv u)
Definition iparith.cc:2485
static BOOLEAN jjSBA_2(leftv res, leftv v, leftv u, leftv t)
Definition iparith.cc:5128
static BOOLEAN jjINDEX_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1410
char si_char_2[2]
Definition iparith.cc:9883
unsigned nCmdUsed
number of commands used
Definition iparith.cc:187
static BOOLEAN jjRING_LIST(leftv res, leftv v)
Definition iparith.cc:5001
static BOOLEAN jjBRACK_SM(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:5882
static BOOLEAN jjSUBST_Test(leftv v, leftv w, int &ringvar, poly &monomexpr)
Definition iparith.cc:6790
static BOOLEAN jjMINUS_I(leftv res, leftv u, leftv v)
Definition iparith.cc:877
static BOOLEAN jjJET_P(leftv res, leftv u, leftv v)
Definition iparith.cc:2548
static BOOLEAN jjVARSTR1(leftv res, leftv v)
Definition iparith.cc:5482
char * iiArithGetCmd(int nPos)
Definition iparith.cc:10071
static BOOLEAN jjSTATUS_M(leftv res, leftv v)
Definition iparith.cc:8778
static BOOLEAN jjCALL1ARG(leftv res, leftv v)
Definition iparith.cc:7343
static BOOLEAN jjPRUNE_MAP(leftv res, leftv v, leftv ma)
Definition iparith.cc:3057
static BOOLEAN jjLT_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:1212
static BOOLEAN jjPOWER_P(leftv res, leftv u, leftv v)
Definition iparith.cc:601
BOOLEAN jjLIST_PL(leftv res, leftv v)
Definition iparith.cc:8239
static BOOLEAN jjPLUSMINUS_Gen(leftv res, leftv u, leftv v)
Definition iparith.cc:630
static BOOLEAN jjCALL2ARG(leftv res, leftv u)
Definition iparith.cc:7347
static BOOLEAN jjINDEX_PBu(leftv res, leftv u, leftv v)
Definition iparith.cc:1463
static int iiTabIndex(const jjValCmdTab dArithTab, const int len, const int op)
Definition iparith.cc:9860
static BOOLEAN jjSYZYGY(leftv res, leftv v)
Definition iparith.cc:5214
static BOOLEAN jjPOWER_N(leftv res, leftv u, leftv v)
Definition iparith.cc:583
static BOOLEAN jjKLAMMER_PL(leftv res, leftv u)
Definition iparith.cc:8065
static BOOLEAN jjSUBST_M(leftv res, leftv u)
Definition iparith.cc:8809
static BOOLEAN jjEQUAL_P(leftv res, leftv u, leftv v)
Definition iparith.cc:1357
static BOOLEAN jjLU_DECOMP(leftv res, leftv v)
Definition iparith.cc:4660
static BOOLEAN jjPlural_num_mat(leftv res, leftv a, leftv b)
Definition iparith.cc:2856
static BOOLEAN jjIDEAL_PL(leftv res, leftv v)
Definition iparith.cc:7483
static BOOLEAN jjNVARS(leftv res, leftv v)
Definition iparith.cc:4795
static BOOLEAN jjERROR(leftv, leftv u)
Definition iparith.cc:1997
static BOOLEAN jjSTATUS2(leftv res, leftv u, leftv v)
Definition iparith.cc:3431
static BOOLEAN jjALIGN_V(leftv res, leftv u, leftv v)
Definition iparith.cc:1767
static BOOLEAN jjRINGLIST_C(leftv res, leftv v)
Definition iparith.cc:4994
BOOLEAN iiConvert(int inputType, int outputType, int index, leftv input, leftv output, const struct sConvertTypes *dConvertTypes)
Definition ipconv.cc:457
const struct sConvertTypes dConvertTypes[]
Definition table.h:1321
VAR omBin sip_command_bin
Definition ipid.cc:45
lists ipNameListLev(idhdl root, int lev)
Definition ipid.cc:629
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition ipid.cc:258
VAR package basePack
Definition ipid.cc:58
VAR idhdl currRingHdl
Definition ipid.cc:59
VAR package currPack
Definition ipid.cc:57
lists ipNameList(idhdl root)
Definition ipid.cc:606
VAR coeffs coeffs_BIGINT
Definition ipid.cc:50
#define IDMAP(a)
Definition ipid.h:135
#define IDMATRIX(a)
Definition ipid.h:134
EXTERN_VAR omBin sleftv_bin
Definition ipid.h:145
ip_command * command
Definition ipid.h:23
#define IDDATA(a)
Definition ipid.h:126
#define hasFlag(A, F)
Definition ipid.h:112
#define setFlag(A, F)
Definition ipid.h:113
#define IDIDEAL(a)
Definition ipid.h:133
#define IDPOLY(a)
Definition ipid.h:130
#define IDID(a)
Definition ipid.h:122
#define IDROOT
Definition ipid.h:19
#define IDINT(a)
Definition ipid.h:125
#define FLAG_TWOSTD
Definition ipid.h:107
BOOLEAN load_builtin(const char *newlib, BOOLEAN autoexport, SModulFunc_t init)
Definition iplib.cc:1304
#define IDPACKAGE(a)
Definition ipid.h:139
#define IDLEV(a)
Definition ipid.h:121
int(* SModulFunc_t)(SModulFunctions *)
Definition ipid.h:81
#define IDRING(a)
Definition ipid.h:127
#define IDTYP(a)
Definition ipid.h:119
#define FLAG_STD
Definition ipid.h:106
BOOLEAN iiLoadLIB(FILE *fp, const char *libnamebuf, const char *newlib, idhdl pl, BOOLEAN autoexport, BOOLEAN tellerror)
Definition iplib.cc:983
char * iiConvName(const char *libname)
Definition iplib.cc:1439
BOOLEAN iiGetLibStatus(const char *lib)
Definition iplib.cc:77
BOOLEAN iiMake_proc(idhdl pn, package pack, leftv args)
Definition iplib.cc:513
BOOLEAN iiTryLoadLib(leftv v, const char *id)
Definition iplib.cc:832
BOOLEAN load_modules(const char *newlib, char *fullname, BOOLEAN autoexport)
Definition iplib.cc:1294
INST_VAR sleftv iiRETURNEXPR
Definition iplib.cc:483
SModulFunc_t iiGetBuiltinModInit(const char *libname)
Definition iplib.cc:816
lists rDecompose(const ring r)
Definition ipshell.cc:2142
lists rDecompose_list_cf(const ring r)
Definition ipshell.cc:2103
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:6557
ring rInit(leftv pn, leftv rv, leftv ord)
Definition ipshell.cc:5609
leftv iiMap(map theMap, const char *what)
Definition ipshell.cc:613
int iiRegularity(lists L)
Definition ipshell.cc:1036
BOOLEAN rDecompose_CF(leftv res, const coeffs C)
Definition ipshell.cc:1932
void iiMakeResolv(resolvente r, int length, int rlen, char *name, int typ0, intvec **weights)
Definition ipshell.cc:845
void killlocals(int v)
Definition ipshell.cc:386
int exprlist_length(leftv v)
Definition ipshell.cc:550
BOOLEAN mpKoszul(leftv res, leftv c, leftv b, leftv id)
Definition ipshell.cc:3075
poly iiHighCorner(ideal I, int ak)
Definition ipshell.cc:1596
lists scIndIndset(ideal S, BOOLEAN all, ideal Q)
Definition ipshell.cc:1102
idhdl rFindHdl(ring r, idhdl n)
Definition ipshell.cc:1690
syStrategy syConvList(lists li)
Definition ipshell.cc:3238
void test_cmd(int i)
Definition ipshell.cc:512
ring rCompose(const lists L, const BOOLEAN check_comp, const long bitmask, const int isLetterplace)
Definition ipshell.cc:2771
const char * lastreserved
Definition ipshell.cc:82
lists syConvRes(syStrategy syzstr, BOOLEAN toDel, int add_row_shift)
Definition ipshell.cc:3166
void rSetHdl(idhdl h)
Definition ipshell.cc:5110
BOOLEAN iiExport(leftv v, int toLev)
Definition ipshell.cc:1501
const struct sValCmd1 dArith1[]
Definition table.h:38
short arg
Definition gentable.cc:80
short res
Definition gentable.cc:70
BOOLEAN(* proc3)(leftv, leftv, leftv, leftv)
Definition ipshell.h:145
short arg1
Definition gentable.cc:71
const struct sValCmd2 dArith2[]
Definition table.h:325
short number_of_args
Definition gentable.cc:98
short valid_for
Definition gentable.cc:99
BOOLEAN(* proc2)(leftv, leftv, leftv)
Definition ipshell.h:134
BOOLEAN setOption(leftv res, leftv v)
Definition misc_ip.cc:570
short cmd
Definition gentable.cc:86
short cmd
Definition gentable.cc:69
short valid_for
Definition gentable.cc:91
short cmd
Definition gentable.cc:78
short valid_for
Definition gentable.cc:73
short res
Definition gentable.cc:97
short res
Definition gentable.cc:87
short arg1
Definition gentable.cc:88
short arg2
Definition gentable.cc:89
BOOLEAN(* proc1)(leftv, leftv)
Definition ipshell.h:122
const struct sValCmdM dArithM[]
Definition table.h:937
short valid_for
Definition gentable.cc:81
short arg3
Definition gentable.cc:90
short res
Definition gentable.cc:79
short arg2
Definition gentable.cc:72
const struct sValCmd3 dArith3[]
Definition table.h:801
short cmd
Definition gentable.cc:96
STATIC_VAR jList * T
Definition janet.cc:30
STATIC_VAR Poly * h
Definition janet.cc:971
ListNode * next
Definition janet.h:31
ideal id_Farey_0(ideal x, number N, const ring r)
Definition kChinese.cc:298
ideal id_ChineseRemainder_0(ideal *xx, number *q, int rl, const ring r)
Definition kChinese.cc:196
long kHomModDeg(poly p, const ring r)
Definition kstd1.cc:2419
ideal kMin_std(ideal F, ideal Q, tHomog h, intvec **w, ideal &M, intvec *hilb, int syzComp, int reduced)
Definition kstd1.cc:3086
ideal kInterRed(ideal F, const ideal Q)
Definition kstd1.cc:3809
VAR intvec * kHomW
Definition kstd1.cc:2407
VAR intvec * kModW
Definition kstd1.cc:2407
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition kstd1.cc:3237
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:2688
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:2484
EXTERN_VAR int Kstd1_deg
Definition kstd1.h:52
ideal rightgb(ideal F, const ideal Q)
Definition kstd2.cc:4954
poly redNF(poly h, int &max_ind, int nonorm, kStrategy strat)
Definition kstd2.cc:2315
ideal_list kStdfac(ideal F, ideal Q, tHomog h, intvec **w, ideal D)
Definition kstdfac.cc:800
char * showOption()
Definition misc_ip.cc:711
VAR idhdl h0
Definition libparse.cc:1143
VAR char libnamebuf[1024]
Definition libparse.cc:1098
static bool rIsSCA(const ring r)
Definition nc.h:190
ideal idOppose(ring Rop_src, ideal I, const ring Rop_dst)
opposes a module I from Rop to currRing(dst)
poly pOppose(ring Rop_src, poly p, const ring Rop_dst)
opposes a vector p from Rop to currRing (dst!)
BOOLEAN rIsLikeOpposite(ring rBase, ring rCandidate)
checks whether rings rBase and rCandidate could be opposite to each other returns TRUE if it is so
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,...
poly nc_p_Bracket_qq(poly p, const poly q, const ring r)
returns [p,q], destroys p
int luRank(const matrix aMat, const bool isRowEchelon, const ring R)
Computes the rank of a given (m x n)-matrix.
bool luInverseFromLUDecomp(const matrix pMat, const matrix lMat, const matrix uMat, matrix &iMat, const ring R)
This code computes the inverse by inverting lMat and uMat, and then performing two matrix multiplicat...
void henselFactors(const int xIndex, const int yIndex, const poly h, const poly f0, const poly g0, const int d, poly &f, poly &g)
Computes a factorization of a polynomial h(x, y) in K[[x]][y] up to a certain degree in x,...
bool luInverse(const matrix aMat, matrix &iMat, const ring R)
This code first computes the LU-decomposition of aMat, and then calls the method for inverting a matr...
void luDecomp(const matrix aMat, matrix &pMat, matrix &lMat, matrix &uMat, const ring R)
LU-decomposition of a given (m x n)-matrix.
bool luSolveViaLUDecomp(const matrix pMat, const matrix lMat, const matrix uMat, const matrix bVec, matrix &xVec, matrix &H)
Solves the linear system A * x = b, where A is an (m x n)-matrix which is given by its LU-decompositi...
lists qrDoubleShift(const matrix A, const number tol1, const number tol2, const number tol3, const ring r=currRing)
Computes all eigenvalues of a given real quadratic matrix with multiplicites.
VAR omBin slists_bin
Definition lists.cc:23
int lSize(lists L)
Definition lists.cc:25
BOOLEAN jjANY2LIST(leftv res, leftv v, int cnt)
LINLINE void nlDelete(number *a, const coeffs r)
Definition longrat.cc:2658
LINLINE number nlInit(long i, const coeffs r)
Definition longrat.cc:2598
void maFetchPermLP(const ring preimage_r, const ring dst_r, int *perm)
Definition maps.cc:306
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:163
void maFindPermLP(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, int lV)
Definition maps.cc:231
poly pSubstPoly(poly p, int var, poly image)
Definition maps_ip.cc:402
ideal idSubstPoly(ideal id, int n, poly e)
Definition maps_ip.cc:424
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:45
ideal idSubstPar(ideal id, int n, poly e)
Definition maps_ip.cc:385
poly pSubstPar(poly p, int par, poly image)
Definition maps_ip.cc:265
BOOLEAN mp_IsDiagUnit(matrix U, const ring R)
Definition matpol.cc:809
matrix mp_Wedge(matrix a, int ar, const ring R)
Definition matpol.cc:1744
matrix mp_Transp(matrix a, const ring R)
Definition matpol.cc:247
ideal sm_Tensor(ideal A, ideal B, const ring r)
Definition matpol.cc:1824
ideal sm_Add(ideal a, ideal b, const ring R)
Definition matpol.cc:1864
matrix mp_CoeffProc(poly f, poly vars, const ring R)
Definition matpol.cc:392
matrix pMultMp(poly p, matrix a, const ring R)
Definition matpol.cc:158
void mp_Monomials(matrix c, int r, int var, matrix m, const ring R)
Definition matpol.cc:355
DetVariant mp_GetAlgorithmDet(matrix m, const ring r)
Definition matpol.cc:2105
matrix mp_CoeffProcId(ideal I, poly vars, const ring R)
Definition matpol.cc:469
poly sm_Det(ideal a, const ring r, DetVariant d)
Definition matpol.cc:2160
matrix mp_MultI(matrix a, long f, const ring R)
c = f*a
Definition matpol.cc:128
ideal sm_Sub(ideal a, ideal b, const ring R)
Definition matpol.cc:1874
ideal sm_Mult(ideal a, ideal b, const ring R)
Definition matpol.cc:1884
matrix mp_Sub(matrix a, matrix b, const ring R)
Definition matpol.cc:189
poly mp_Det(matrix a, const ring r, DetVariant d)
Definition matpol.cc:2136
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition matpol.cc:37
int mp_Compare(matrix a, matrix b, const ring R)
Definition matpol.cc:636
BOOLEAN sm_Equal(ideal a, ideal b, const ring R)
Definition matpol.cc:1996
matrix mp_Mult(matrix a, matrix b, const ring R)
Definition matpol.cc:206
BOOLEAN mp_Equal(matrix a, matrix b, const ring R)
Definition matpol.cc:655
matrix mp_Coeffs(ideal I, int var, const ring R)
corresponds to Maple's coeffs: var has to be the number of a variable
Definition matpol.cc:306
void mp_Coef2(poly v, poly mon, matrix *c, matrix *m, const ring R)
corresponds to Macauley's coef: the exponent vector of vars has to contain the variables,...
Definition matpol.cc:574
matrix mp_MultP(matrix a, poly p, const ring R)
multiply a matrix 'a' by a poly 'p', destroy the args
Definition matpol.cc:141
matrix mp_Copy(matrix a, const ring r)
copies matrix a (from ring r to r)
Definition matpol.cc:57
matrix mp_Add(matrix a, matrix b, const ring R)
Definition matpol.cc:172
matrix mp_InitP(int r, int c, poly p, const ring R)
make it a p * unit matrix
Definition matpol.cc:106
poly mp_Trace(matrix a, const ring R)
Definition matpol.cc:268
#define MATELEM(mat, i, j)
1-based access to matrix
Definition matpol.h:29
ip_smatrix * matrix
Definition matpol.h:43
#define MATROWS(i)
Definition matpol.h:26
#define MATCOLS(i)
Definition matpol.h:27
DetVariant
Definition matpol.h:35
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:358
This file provides miscellaneous functionality.
#define TIMER_RESOLUTION
Definition mod2.h:35
#define assume(x)
Definition mod2.h:387
lib_types type_of_LIB(const char *newlib, char *libnamebuf)
Definition mod_lib.cc:27
lib_types
Definition mod_raw.h:16
@ LT_MACH_O
Definition mod_raw.h:16
@ LT_HPUX
Definition mod_raw.h:16
@ LT_SINGULAR
Definition mod_raw.h:16
@ LT_BUILTIN
Definition mod_raw.h:16
@ LT_ELF
Definition mod_raw.h:16
@ LT_NONE
Definition mod_raw.h:16
@ LT_NOTFOUND
Definition mod_raw.h:16
#define pIter(p)
Definition monomials.h:37
#define pNext(p)
Definition monomials.h:36
#define pSetCoeff0(p, n)
Definition monomials.h:59
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition monomials.h:44
BOOLEAN nuLagSolve(leftv res, leftv arg1, leftv arg2, leftv arg3)
find the (complex) roots an univariate polynomial Determines the roots of an univariate polynomial us...
Definition ipshell.cc:4662
slists * lists
The main handler for Singular numbers which are suitable for Singular polynomials.
Definition ap.h:40
ideal twostd(ideal I)
Compute two-sided GB:
Definition nc.cc:18
void newstruct_setup(const char *n, newstruct_desc d)
Definition newstruct.cc:699
newstruct_desc newstructChildFromString(const char *parent, const char *s)
Definition newstruct.cc:810
newstruct_desc newstructFromString(const char *s)
Definition newstruct.cc:803
CanonicalForm ndConvSingNFactoryN(number, BOOLEAN, const coeffs)
Definition numbers.cc:307
#define nDiv(a, b)
Definition numbers.h:32
#define nDelete(n)
Definition numbers.h:16
#define nInpNeg(n)
Definition numbers.h:21
#define nIsZero(n)
Definition numbers.h:19
#define nEqual(n1, n2)
Definition numbers.h:20
#define nSub(n1, n2)
Definition numbers.h:22
#define nCopy(n)
Definition numbers.h:15
#define nGreater(a, b)
Definition numbers.h:28
#define nAdd(n1, n2)
Definition numbers.h:18
#define nSize(n)
Definition numbers.h:39
#define nInvers(a)
Definition numbers.h:33
#define nIsOne(n)
Definition numbers.h:25
#define nNormalize(n)
Definition numbers.h:30
#define nInit(i)
Definition numbers.h:24
#define nMult(n1, n2)
Definition numbers.h:17
#define nPower(a, b, res)
Definition numbers.h:38
#define omStrDup(s)
#define omfree(addr)
#define omFreeSize(addr, size)
#define omAlloc(size)
#define omAllocBin(bin)
#define omAlloc0Bin(bin)
#define omRealloc(addr, size)
#define omFree(addr)
#define omAlloc0(size)
#define omFreeBin(addr, bin)
#define omFreeBinAddr(addr)
#define NULL
Definition omList.c:12
omInfo_t om_Info
Definition omStats.c:16
VAR unsigned si_opt_2
Definition options.c:6
VAR unsigned si_opt_1
Definition options.c:5
#define SI_SAVE_OPT2(A)
Definition options.h:22
#define Sy_bitL(x)
Definition options.h:32
#define BVERBOSE(a)
Definition options.h:35
#define OPT_REDTAIL_SYZ
Definition options.h:88
#define OPT_SB_1
Definition options.h:96
#define SI_SAVE_OPT1(A)
Definition options.h:21
#define SI_RESTORE_OPT1(A)
Definition options.h:24
#define SI_RESTORE_OPT2(A)
Definition options.h:25
#define Sy_bit(x)
Definition options.h:31
#define TEST_OPT_DEGBOUND
Definition options.h:115
#define TEST_OPT_RETURN_SB
Definition options.h:114
#define TEST_OPT_PROT
Definition options.h:105
#define V_IMAP
Definition options.h:53
#define V_DEG_STOP
Definition options.h:73
#define V_SHOW_USE
Definition options.h:52
static int index(p_Length length, p_Ord ord)
void pRestoreDegProcs(ring r, pFDegProc old_FDeg, pLDegProc old_lDeg)
Definition p_polys.cc:3670
poly p_Homogen(poly p, int varnum, const ring r)
Definition p_polys.cc:3274
poly pp_DivideM(poly a, poly b, const ring r)
Definition p_polys.cc:1637
void p_Shift(poly *p, int i, const ring r)
shifts components of the vector p by i
Definition p_polys.cc:4756
void p_Normalize(poly p, const ring r)
Definition p_polys.cc:3835
int p_MaxExpPerVar(poly p, int i, const ring r)
max exponent of variable x_i in p
Definition p_polys.cc:5042
int p_Compare(const poly a, const poly b, const ring R)
Definition p_polys.cc:4946
poly p_Series(int n, poly p, poly u, intvec *w, const ring R)
Definition p_polys.cc:4548
long p_DegW(poly p, const int *w, const ring R)
Definition p_polys.cc:691
poly p_Cleardenom(poly p, const ring r)
Definition p_polys.cc:2849
poly p_Vec2Poly(poly v, int k, const ring r)
Definition p_polys.cc:3594
void p_SetModDeg(intvec *w, ring r)
Definition p_polys.cc:3694
poly p_One(const ring r)
Definition p_polys.cc:1314
void pSetDegProcs(ring r, pFDegProc new_FDeg, pLDegProc new_lDeg)
Definition p_polys.cc:3658
long p_Deg(poly a, const ring r)
Definition p_polys.cc:586
static poly p_Neg(poly p, const ring r)
Definition p_polys.h:1107
static int pLength(poly a)
Definition p_polys.h:190
static long p_MinComp(poly p, ring lmRing, ring tailRing)
Definition p_polys.h:313
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:901
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition p_polys.h:1160
static long p_Totaldegree(poly p, const ring r)
Definition p_polys.h:1521
void rChangeCurrRing(ring r)
Definition polys.cc:15
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
poly pp_Divide(poly p, poly q, const ring r)
polynomial division a/b, ignoring the rest via singclap_pdivide resp. idLift does not destroy a,...
Definition polys.cc:176
poly singclap_gcd(poly f, poly g, const ring r)
polynomial gcd via singclap_gcd_r resp. idSyzygies destroys f and g
Definition polys.cc:382
Compatibility layer for legacy polynomial operations (over currRing)
#define pAdd(p, q)
Definition polys.h:203
static long pTotaldegree(poly p)
Definition polys.h:282
#define pDelete(p_ptr)
Definition polys.h:186
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL
Definition polys.h:67
#define pSetm(p)
Definition polys.h:271
#define pIsConstant(p)
like above, except that Comp must be 0
Definition polys.h:238
#define pSplit(p, r)
Definition polys.h:265
#define pNeg(p)
Definition polys.h:198
#define pGetComp(p)
Component.
Definition polys.h:37
#define pDiff(a, b)
Definition polys.h:296
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
Definition polys.h:31
void pNorm(poly p)
Definition polys.h:362
#define pNSet(n)
Definition polys.h:313
#define pVar(m)
Definition polys.h:380
#define pJet(p, m)
Definition polys.h:367
#define pSub(a, b)
Definition polys.h:287
#define ppMult_qq(p, q)
Definition polys.h:208
#define ppJetW(p, m, iv)
Definition polys.h:368
#define pMaxComp(p)
Definition polys.h:299
#define pLmInit(p)
like pInit, except that expvector is initialized to that of p, p must be != NULL
Definition polys.h:64
#define pIsUnit(p)
return true if the Lm is a constant <>0
Definition polys.h:240
#define pPower(p, q)
Definition polys.h:204
#define pSetComp(p, v)
Definition polys.h:38
#define pLmDelete(p)
assume p != NULL, deletes Lm(p)->coef and Lm(p)
Definition polys.h:76
#define pMult(p, q)
Definition polys.h:207
static void pLmFree(poly p)
frees the space of the monomial m, assumes m != NULL coef is not freed, m is not advanced
Definition polys.h:70
#define pSubst(p, n, e)
Definition polys.h:365
#define pSeries(n, p, u, w)
Definition polys.h:371
#define pGetExp(p, i)
Exponent.
Definition polys.h:41
#define pNormalize(p)
Definition polys.h:317
#define pInit()
allocates a new monomial and initializes everything to 0
Definition polys.h:61
#define pEqualPolys(p1, p2)
Definition polys.h:399
#define pSetExp(p, i, v)
Definition polys.h:42
#define pLmCmp(p, q)
returns 0|1|-1 if p=q|p>q|p<q w.r.t monomial ordering
Definition polys.h:105
#define pCopy(p)
return a copy of the poly
Definition polys.h:185
#define pLmFreeAndNext(p)
assumes p != NULL, deletes p, returns pNext(p)
Definition polys.h:74
#define pOne()
Definition polys.h:315
#define pIsUnivariate(p)
Definition polys.h:249
#define pISet(i)
Definition polys.h:312
#define pWTotaldegree(p)
Definition polys.h:283
ideal maGetPreimage(ring theImageRing, map theMap, ideal id, const ring dst_r)
Definition preimage.cc:57
int IsPrime(int p)
Definition prime.cc:61
void SPrintStart()
Definition reporter.cc:246
const char feNotImplemented[]
Definition reporter.cc:54
void PrintS(const char *s)
Definition reporter.cc:284
char * SPrintEnd()
Definition reporter.cc:273
void PrintLn()
Definition reporter.cc:310
void Werror(const char *fmt,...)
Definition reporter.cc:189
EXTERN_VAR int traceit
Definition reporter.h:24
#define TRACE_CALL
Definition reporter.h:44
#define SI_PROT_O
Definition reporter.h:54
#define SI_PROT_I
Definition reporter.h:53
#define mflush()
Definition reporter.h:58
int rSum(ring r1, ring r2, ring &sum)
Definition ring.cc:1405
int r_IsRingVar(const char *n, char **names, int N)
Definition ring.cc:213
int rChar(ring r)
Definition ring.cc:716
ring rMinusVar(const ring r, char *v)
undo rPlusVar
Definition ring.cc:5963
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:1802
char * rParStr(ring r)
Definition ring.cc:652
char * rCharStr(const ring r)
TODO: make it a virtual method of coeffs, together with: Decompose & Compose, rParameter & rPar.
Definition ring.cc:650
ring rOpposite(ring src)
Definition ring.cc:5364
char * rOrdStr(ring r)
Definition ring.cc:524
void rDelete(ring r)
unconditionally deletes fields in r
Definition ring.cc:452
ring rDefault(const coeffs cf, int N, char **n, int ord_size, rRingOrder_t *ord, int *block0, int *block1, int **wvhdl, unsigned long bitmask)
Definition ring.cc:103
char * rVarStr(ring r)
Definition ring.cc:626
ring rPlusVar(const ring r, char *v, int left)
K[x],"y" -> K[x,y] resp. K[y,x].
Definition ring.cc:5881
ring rEnvelope(ring R)
Definition ring.cc:5758
int n_IsParam(const number m, const ring r)
TODO: rewrite somehow...
Definition ring.cc:5860
ring rCopy(ring r)
Definition ring.cc:1734
static BOOLEAN rField_is_Zp_a(const ring r)
Definition ring.h:534
static BOOLEAN rField_is_Z(const ring r)
Definition ring.h:514
static BOOLEAN rField_is_Zp(const ring r)
Definition ring.h:505
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition ring.h:405
long(* pFDegProc)(poly p, ring r)
Definition ring.h:38
static ring rIncRefCnt(ring r)
Definition ring.h:846
static BOOLEAN rField_is_Domain(const ring r)
Definition ring.h:492
long(* pLDegProc)(poly p, int *length, ring r)
Definition ring.h:37
static int rPar(const ring r)
(r->cf->P)
Definition ring.h:604
static BOOLEAN rIsLPRing(const ring r)
Definition ring.h:416
@ ringorder_lp
Definition ring.h:77
@ ringorder_dp
Definition ring.h:78
static BOOLEAN rField_is_Q(const ring r)
Definition ring.h:511
static char const ** rParameter(const ring r)
(r->cf->parameter)
Definition ring.h:630
static BOOLEAN rField_is_numeric(const ring r)
Definition ring.h:520
BOOLEAN rHasMixedOrdering(const ring r)
Definition ring.h:768
static BOOLEAN rField_is_GF(const ring r)
Definition ring.h:526
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition ring.h:597
BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition ring.h:767
#define rField_is_Ring(R)
Definition ring.h:490
idrec * idhdl
Definition ring.h:21
void sBucket_Add_p(sBucket_pt bucket, poly p, int length)
adds poly p to bucket destroys p!
Definition sbuckets.cc:203
void sBucketCanonicalize(sBucket_pt bucket)
Definition sbuckets.cc:401
sBucket_pt sBucketCreate(const ring r)
Definition sbuckets.cc:96
poly sBucketPeek(sBucket_pt b)
Definition sbuckets.cc:455
sBucket * sBucket_pt
Definition sbuckets.h:16
void sBucketDestroyAdd(sBucket_pt bucket, poly *p, int *length)
Definition sbuckets.h:68
BOOLEAN sdb_set_breakpoint(const char *pp, int given_lineno)
Definition sdb.cc:64
void sdb_show_bp()
Definition sdb.cc:57
ideal id_Vec2Ideal(poly vec, const ring R)
ideal idInit(int idsize, int rank)
initialise an ideal / module
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
void id_Norm(ideal id, const ring r)
ideal id = (id[i]), result is leadcoeff(id[i]) = 1
BOOLEAN id_HomModuleW(ideal id, ideal Q, const intvec *w, const intvec *module_w, const ring r)
void id_Normalize(ideal I, const ring r)
normialize all polys in id
ideal id_Transp(ideal a, const ring rRing)
transpose a module
ideal id_FreeModule(int i, const ring r)
the free module of rank i
ideal id_Homogen(ideal h, int varnum, const ring r)
ideal id_Power(ideal given, int exp, const ring r)
matrix id_Module2Matrix(ideal mod, const ring R)
ideal id_Head(ideal h, const ring r)
returns the ideals of initial terms
BOOLEAN id_HomIdealW(ideal id, ideal Q, const intvec *w, const ring r)
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
void id_DelDiv(ideal id, const ring r)
delete id[j], if LT(j) == coeff*mon*LT(i) and vice versa, i.e., delete id[i], if LT(i) == coeff*mon*L...
void id_DelMultiples(ideal id, const ring r)
ideal id = (id[i]), c any unit if id[i] = c*id[j] then id[j] is deleted for j > i
matrix id_Module2formatedMatrix(ideal mod, int rows, int cols, const ring R)
ideal id_Matrix2Module(matrix mat, const ring R)
converts mat to module, destroys mat
ideal id_ResizeModule(ideal mod, int rows, int cols, const ring R)
ideal id_Delete_Pos(const ideal I, const int p, const ring r)
void id_DelEquals(ideal id, const ring r)
ideal id = (id[i]) if id[i] = id[j] then id[j] is deleted for j > i
ideal id_Jet(const ideal i, int d, const ring R)
void id_DelLmEquals(ideal id, const ring r)
Delete id[j], if Lm(j) == Lm(i) and both LC(j), LC(i) are units and j > i.
ideal id_JetW(const ideal i, int d, intvec *iv, const ring R)
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
void id_Shift(ideal M, int s, const ring r)
ideal id_ChineseRemainder(ideal *xx, number *q, int rl, const ring r)
ideal id_Subst(ideal id, int n, poly e, const ring r)
#define IDELEMS(i)
static int idElem(const ideal F)
number of non-zero polys in F
int siRand()
Definition sirandom.c:42
#define R
Definition sirandom.c:27
#define A
Definition sirandom.c:24
#define M
Definition sirandom.c:25
#define Q
Definition sirandom.c:26
void sm_CallBareiss(ideal I, int x, int y, ideal &M, intvec **iv, const ring R)
Definition sparsmat.cc:347
ideal sm_CallSolv(ideal I, const ring R)
Definition sparsmat.cc:2316
sleftv * leftv
Definition structs.h:57
tHomog
Definition structs.h:35
@ isHomog
Definition structs.h:37
@ testHomog
Definition structs.h:38
@ isNotHomog
Definition structs.h:36
#define BITSET
Definition structs.h:16
EXTERN_VAR omBin char_ptr_bin
Definition structs.h:77
#define loop
Definition structs.h:75
VAR omBin sSubexpr_bin
Definition subexpr.cc:40
void syMake(leftv v, const char *id, package pa)
Definition subexpr.cc:1613
INST_VAR sleftv sLastPrinted
Definition subexpr.cc:46
VAR BOOLEAN siq
Definition subexpr.cc:48
BOOLEAN assumeStdFlag(leftv h)
Definition subexpr.cc:1587
@ LANG_SINGULAR
Definition subexpr.h:22
@ LANG_MIX
Definition subexpr.h:22
@ LANG_C
Definition subexpr.h:22
@ LANG_TOP
Definition subexpr.h:22
resolvente syResolvente(ideal arg, int maxlength, int *length, intvec ***weights, BOOLEAN minim)
Definition syz.cc:401
syStrategy syMres_with_map(ideal arg, int maxlength, intvec *w, ideal &trans)
Definition syz.cc:1176
syStrategy syResolution(ideal arg, int maxlength, intvec *w, BOOLEAN minim)
Definition syz.cc:626
ideal syMinBase(ideal arg)
Definition syz.cc:1017
syStrategy syHilb(ideal arg, int *length)
Definition syz2.cc:950
resolvente sySchreyerResolvente(ideal arg, int maxlength, int *length, BOOLEAN isMonomial=FALSE, BOOLEAN notReplace=FALSE)
Definition syz0.cc:855
syStrategy sySchreyer(ideal arg, int maxlength)
Definition syz0.cc:1018
ring syRing
Definition syz.h:56
int syDim(syStrategy syzstr)
Definition syz1.cc:1850
syStrategy syMinimize(syStrategy syzstr)
Definition syz1.cc:2393
syStrategy syCopy(syStrategy syzstr)
Definition syz1.cc:1885
resolvente minres
Definition syz.h:58
syStrategy syKosz(ideal arg, int *length)
Definition syz3.cc:1766
int sySize(syStrategy syzstr)
Definition syz1.cc:1830
short list_length
Definition syz.h:62
resolvente res
Definition syz.h:47
resolvente fullres
Definition syz.h:57
intvec ** weights
Definition syz.h:45
ssyStrategy * syStrategy
Definition syz.h:36
resolvente orderedRes
Definition syz.h:48
SRes resPairs
Definition syz.h:49
syStrategy syFrank(const ideal arg, const int length, const char *method, const bool use_cache=true, const bool use_tensor_trick=false)
Definition syz4.cc:792
syStrategy syLaScala3(ideal arg, int *length)
Definition syz1.cc:2432
int name
New type name for int.
ideal t_rep_gb(const ring r, ideal arg_I, int syz_comp, BOOLEAN F4_mode)
Definition tgb.cc:3581
int getRTimer()
Definition timer.cc:150
#define IDHDL
Definition tok.h:31
@ NCALGEBRA_CMD
Definition tok.h:138
@ ALIAS_CMD
Definition tok.h:34
@ BIGINT_CMD
Definition tok.h:38
@ CRING_CMD
Definition tok.h:56
@ LIST_CMD
Definition tok.h:118
@ INTVEC_CMD
Definition tok.h:101
@ PACKAGE_CMD
Definition tok.h:150
@ DEF_CMD
Definition tok.h:58
@ LRES_CMD
Definition tok.h:120
@ SUBST_CMD
Definition tok.h:188
@ HRES_CMD
Definition tok.h:91
@ KRES_CMD
Definition tok.h:109
@ OPEN_CMD
Definition tok.h:145
@ CNUMBER_CMD
Definition tok.h:47
@ LINK_CMD
Definition tok.h:117
@ STD_CMD
Definition tok.h:186
@ CHINREM_CMD
Definition tok.h:45
@ MRES_CMD
Definition tok.h:131
@ STRING_CMD
Definition tok.h:187
@ SRES_CMD
Definition tok.h:184
@ INTDIV_CMD
Definition tok.h:97
@ INT_CMD
Definition tok.h:96
@ KERNEL_CMD
Definition tok.h:107
@ FAREY_CMD
Definition tok.h:77
@ MAX_TOK
Definition tok.h:220
@ RES_CMD
Definition tok.h:169
#define NONE
Definition tok.h:223
#define COMMAND
Definition tok.h:29
#define UNKNOWN
Definition tok.h:224
#define ANY_TYPE
Definition tok.h:30
number ntDiff(number a, number d, const coeffs cf)
Definition transext.cc:897
ideal fractalWalkProc(leftv first, leftv second)
Definition walk_ip.cc:161
ideal walkProc(leftv first, leftv second)
Definition walk_ip.cc:55
int * iv2array(intvec *iv, const ring R)
Definition weight.cc:200
BOOLEAN jjStdJanetBasis(leftv res, leftv v, int flag)
flag: 0: JB, 1: SB
Definition wrapper.cc:50
#define omPrintStats(F)
Definition xalloc.h:231
#define omPrintInfo(F)
Definition xalloc.h:232
#define omPrintBinStats(F)
Definition xalloc.h:233
#define omUpdateInfo()
Definition xalloc.h:230