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 #ifdef HAVE_VSPACE
2150 int cpus = (long) feOptValue(FE_OPT_CPUS);
2151 if ((cpus>1) && (rField_is_Q(currRing)))
2152 res->data=(void*)id_Farey_0(uu,vv,currRing);
2153 else
2154 #endif
2155 res->data=(void*)id_Farey(uu,vv,currRing);
2156 //clock_gettime(CLOCK_THREAD_CPUTIME_ID,&buf2);
2157 //const unsigned long SEC = 1000L*1000L*1000L;
2158 //all_farey+=((buf2.tv_sec-buf1.tv_sec)*SEC+
2159 // buf2.tv_nsec-buf1.tv_nsec);
2160 //farey_cnt++;
2161 return FALSE;
2162}
2163static BOOLEAN jjFAREY_LI(leftv res, leftv u, leftv v);
2165{
2166 ring r=(ring)u->Data();
2167 idhdl w;
2168 int op=iiOp;
2169 nMapFunc nMap;
2170
2171 if ((w=r->idroot->get(v->Name(),myynest))!=NULL)
2172 {
2173 int *perm=NULL;
2174 int *par_perm=NULL;
2175 int par_perm_size=0;
2176 BOOLEAN bo;
2177 nMap=n_SetMap(r->cf,currRing->cf);
2178 if (nMap==NULL)
2179 {
2180 // Allow imap/fetch to be make an exception only for:
2181 if (nCoeff_is_Extension(r->cf) && // Q(a..) -> Q(a..) || Q || Zp || Zp(a)
2182 ((n_SetMap(r->cf->extRing->cf,currRing->cf)!=NULL)
2183 || (nCoeff_is_Extension(currRing->cf) && (n_SetMap(r->cf->extRing->cf,currRing->cf->extRing->cf)!=NULL))))
2184 {
2185 par_perm_size=rPar(r);
2186 }
2187 else
2188 {
2189 goto err_fetch;
2190 }
2191 }
2192 if (
2193 (iiOp!=FETCH_CMD) || (r->N!=currRing->N) || (rPar(r)!=rPar(currRing))
2194#ifdef HAVE_SHIFTBBA
2196#endif
2197 )
2198 {
2199 perm=(int *)omAlloc0((r->N+1)*sizeof(int));
2200 if (par_perm_size!=0)
2201 par_perm=(int *)omAlloc0(par_perm_size*sizeof(int));
2202 op=IMAP_CMD;
2203 if (iiOp==IMAP_CMD)
2204 {
2205 int r_par=0;
2206 char ** r_par_names=NULL;
2207 if (r->cf->extRing!=NULL)
2208 {
2209 r_par=r->cf->extRing->N;
2210 r_par_names=r->cf->extRing->names;
2211 }
2212 int c_par=0;
2213 char ** c_par_names=NULL;
2214 if (currRing->cf->extRing!=NULL)
2215 {
2216 c_par=currRing->cf->extRing->N;
2217 c_par_names=currRing->cf->extRing->names;
2218 }
2219 if (!rIsLPRing(r))
2220 {
2221 maFindPerm(r->names, r->N, r_par_names, r_par,
2222 currRing->names,currRing->N,c_par_names, c_par,
2223 perm,par_perm, currRing->cf->type);
2224 }
2225 #ifdef HAVE_SHIFTBBA
2226 else
2227 {
2228 maFindPermLP(r->names, r->N, r_par_names, r_par,
2229 currRing->names,currRing->N,c_par_names, c_par,
2230 perm,par_perm, currRing->cf->type,r->isLPring);
2231 }
2232 #endif
2233 }
2234 else
2235 {
2236#ifdef HAVE_SHIFTBBA
2237 if (rIsLPRing(currRing))
2238 {
2239 maFetchPermLP(r, currRing, perm);
2240 }
2241 else
2242#endif
2243 {
2244 unsigned i;
2245 if (par_perm_size!=0)
2246 for(i=si_min(rPar(r),rPar(currRing));i>0;i--) par_perm[i-1]=-i;
2247 for(i=si_min(r->N,currRing->N);i>0;i--) perm[i]=i;
2248 }
2249 }
2250 }
2251 if ((iiOp==FETCH_CMD) && (BVERBOSE(V_IMAP)))
2252 {
2253 unsigned i;
2254 for(i=0;i<(unsigned)si_min(r->N,currRing->N);i++)
2255 {
2256 Print("// var nr %d: %s -> %s\n",i,r->names[i],currRing->names[i]);
2257 }
2258 for(i=0;i<(unsigned)si_min(rPar(r),rPar(currRing));i++) // possibly empty loop
2259 {
2260 Print("// par nr %d: %s -> %s\n",
2262 }
2263 }
2264 if (IDTYP(w)==ALIAS_CMD) w=(idhdl)IDDATA(w);
2265 sleftv tmpW;
2266 tmpW.Init();
2267 tmpW.rtyp=IDTYP(w);
2268 tmpW.data=IDDATA(w);
2269 if ((bo=maApplyFetch(op,NULL,res,&tmpW, r,
2270 perm,par_perm,par_perm_size,nMap)))
2271 {
2272 Werror("cannot map %s of type %s(%d)",v->name, Tok2Cmdname(w->typ),w->typ);
2273 }
2274 if (perm!=NULL)
2275 omFreeSize((ADDRESS)perm,(r->N+1)*sizeof(int));
2276 if (par_perm!=NULL)
2277 omFreeSize((ADDRESS)par_perm,par_perm_size*sizeof(int));
2278 return bo;
2279 }
2280 else
2281 {
2282 Werror("identifier %s not found in %s",v->Fullname(),u->Fullname());
2283 }
2284 return TRUE;
2285err_fetch:
2286 char *s1=nCoeffString(r->cf);
2287 char *s2=nCoeffString(currRing->cf);
2288 Werror("no identity map from %s (%s -> %s)",u->Fullname(),s1,s2);
2289 omFree(s2); omFree(s1);
2290 return TRUE;
2291}
2293{
2294 /*4
2295 * look for the substring what in the string where
2296 * return the position of the first char of what in where
2297 * or 0
2298 */
2299 char *where=(char *)u->Data();
2300 char *what=(char *)v->Data();
2301 char *found = strstr(where,what);
2302 if (found != NULL)
2303 {
2304 res->data=(char *)((found-where)+1);
2305 }
2306 /*else res->data=NULL;*/
2307 return FALSE;
2308}
2309
2311{
2312 assumeStdFlag(u);
2313 ideal id = (ideal)u->Data();
2314 int max_length = (int)(long)v->Data();
2315 if (max_length < 0)
2316 {
2317 WerrorS("length for fres must not be negative");
2318 return TRUE;
2319 }
2320 if (max_length == 0)
2321 {
2322 max_length = currRing->N+1;
2323 if (currRing->qideal != NULL)
2324 {
2325 Warn("full resolution in a qring may be infinite, "
2326 "setting max length to %d", max_length);
2327 }
2328 }
2329 char *method = (char *)w->Data();
2330 /* For the moment, only "complete" (default), "frame", or "extended frame"
2331 * are allowed. Another useful option would be "linear strand".
2332 */
2333 if (strcmp(method, "complete") != 0
2334 && strcmp(method, "frame") != 0
2335 && strcmp(method, "extended frame") != 0
2336 && strcmp(method, "single module") != 0)
2337 {
2338 WerrorS("wrong optional argument for fres");
2339 return TRUE;
2340 }
2341 syStrategy r = syFrank(id, max_length, method);
2342 assume(r->fullres != NULL);
2343 res->data = (void *)r;
2344 return FALSE;
2345}
2346
2348{
2350 w->rtyp = STRING_CMD;
2351 w->data = (char *)"complete"; // default
2352 BOOLEAN RES = jjFRES3(res, u, v, w);
2354 return RES;
2355}
2356
2358{
2359 res->data=(char *)fractalWalkProc(u,v);
2360 setFlag( res, FLAG_STD );
2361 return FALSE;
2362}
2364{
2365 int uu=(int)(long)u->Data();int vv=(int)(long)v->Data();
2366 int p0=ABS(uu),p1=ABS(vv);
2367 int r;
2368 while ( p1!=0 )
2369 {
2370 r=p0 % p1;
2371 p0 = p1; p1 = r;
2372 }
2373 res->data=(char *)(long)p0;
2374 return FALSE;
2375}
2377{
2378 number n1 = (number) u->Data();
2379 number n2 = (number) v->Data();
2380 res->data = n_Gcd(n1,n2,coeffs_BIGINT);
2381 return FALSE;
2382}
2384{
2385 number a=(number) u->Data();
2386 number b=(number) v->Data();
2387 if (nIsZero(a))
2388 {
2389 if (nIsZero(b)) res->data=(char *)nInit(1);
2390 else res->data=(char *)nCopy(b);
2391 }
2392 else
2393 {
2394 if (nIsZero(b)) res->data=(char *)nCopy(a);
2395 //else res->data=(char *)n_Gcd(a, b, currRing->cf);
2396 else res->data=(char *)n_SubringGcd(a, b, currRing->cf);
2397 }
2398 return FALSE;
2399}
2401{
2402 res->data=(void *)singclap_gcd((poly)(u->CopyD(POLY_CMD)),
2403 (poly)(v->CopyD(POLY_CMD)),currRing);
2404 return FALSE;
2405}
2407{
2408 if (rField_is_Z(currRing))
2409 {
2410 PrintS("// NOTE: computation of Hilbert series etc. is being\n");
2411 PrintS("// performed for generic fibre, that is, over Q\n");
2412 }
2413 assumeStdFlag(u);
2414 intvec *module_w=(intvec*)atGet(u,"isHomog",INTVEC_CMD);
2415#if 1
2416 switch((int)(long)v->Data())
2417 {
2418 case 1:
2419 res->data=(void *)hFirstSeries0b((ideal)u->Data(),currRing->qideal,NULL,module_w,currRing,coeffs_BIGINT);
2420 return FALSE;
2421 case 2:
2422 res->data=(void *)hSecondSeries0b((ideal)u->Data(),currRing->qideal,NULL,module_w,currRing,coeffs_BIGINT);
2423 return FALSE;
2424 }
2425#else
2426 intvec *iv=hFirstSeries((ideal)u->Data(),module_w,currRing->qideal);
2427 if (errorreported) return TRUE;
2428
2429 switch((int)(long)v->Data())
2430 {
2431 case 1:
2432 res->data=(void *)iv;
2433 return FALSE;
2434 case 2:
2435 res->data=(void *)hSecondSeries(iv);
2436 delete iv;
2437 return FALSE;
2438 }
2439 delete iv;
2440#endif
2442 return TRUE;
2443}
2445{
2446 int i=pVar((poly)v->Data());
2447 if (i==0)
2448 {
2449 WerrorS("ringvar expected");
2450 return TRUE;
2451 }
2452 poly p=pOne(); pSetExp(p,i,1); pSetm(p);
2453 int d=pWTotaldegree(p);
2454 pLmDelete(p);
2455 if (d==1)
2456 res->data = (char *)p_Homogen((poly)u->Data(), i, currRing);
2457 else
2458 WerrorS("variable must have weight 1");
2459 return (d!=1);
2460}
2462{
2463 int i=pVar((poly)v->Data());
2464 if (i==0)
2465 {
2466 WerrorS("ringvar expected");
2467 return TRUE;
2468 }
2469 pFDegProc deg;
2470 if (currRing->pLexOrder && (currRing->order[0]==ringorder_lp))
2471 deg=p_Totaldegree;
2472 else
2473 deg=currRing->pFDeg;
2474 poly p=pOne(); pSetExp(p,i,1); pSetm(p);
2475 int d=deg(p,currRing);
2476 pLmDelete(p);
2477 if (d==1)
2478 res->data = (char *)id_Homogen((ideal)u->Data(), i, currRing);
2479 else
2480 WerrorS("variable must have weight 1");
2481 return (d!=1);
2482}
2484{
2485 intvec *w=new intvec(rVar(currRing));
2486 intvec *vw=(intvec*)u->Data();
2487 ideal v_id=(ideal)v->Data();
2488 pFDegProc save_FDeg=currRing->pFDeg;
2489 pLDegProc save_LDeg=currRing->pLDeg;
2490 BOOLEAN save_pLexOrder=currRing->pLexOrder;
2491 currRing->pLexOrder=FALSE;
2492 kHomW=vw;
2493 kModW=w;
2495 res->data=(void *)(long)idHomModule(v_id,currRing->qideal,&w);
2496 currRing->pLexOrder=save_pLexOrder;
2497 kHomW=NULL;
2498 kModW=NULL;
2499 pRestoreDegProcs(currRing,save_FDeg,save_LDeg);
2500 if (w!=NULL) delete w;
2501 return FALSE;
2502}
2504{
2505 intvec *vw=(intvec*)u->Data();
2506 ideal v_id=(ideal)v->Data();
2507 res->data=(void *)(long)id_HomIdealW(v_id,currRing->qideal,vw,currRing);
2508 return FALSE;
2509}
2511{
2512 assumeStdFlag(u);
2513 res->data=(void *)scIndIndset((ideal)(u->Data()),(int)(long)(v->Data()),
2514 currRing->qideal);
2515 return FALSE;
2516}
2518{
2519 res->data=(char *)idSect((ideal)u->Data(),(ideal)v->Data());
2521 return FALSE;
2522}
2524{
2525 const lists L = (lists)l->Data();
2526 const int n = L->nr; assume (n >= 0);
2527 std::vector<ideal> V(n + 1);
2528
2529 for(int i = n; i >= 0; i--) V[i] = (ideal)(L->m[i].Data());
2530
2531 res->data=interpolation(V, (intvec*)v->Data());
2533 return errorreported;
2534}
2536{
2537 extern BOOLEAN jjStdJanetBasis(leftv res, leftv v,int flag);
2538 return jjStdJanetBasis(res,u,(int)(long)v->Data());
2539}
2540
2542{
2543 extern BOOLEAN jjStdJanetBasis(leftv res, leftv v,int flag);
2544 return jjStdJanetBasis(res,v,0);
2545}
2547{
2548 res->data = (char *)pJet((poly)u->CopyD(), (int)(long)v->Data());
2549 return FALSE;
2550}
2552{
2553 res->data = (char *)id_Jet((ideal)u->Data(),(int)(long)v->Data(),currRing);
2554 return FALSE;
2555}
2557{
2558 assumeStdFlag(u);
2559 intvec *w_u=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
2560 res->data = (char *)scKBase((int)(long)v->Data(),
2561 (ideal)(u->Data()),currRing->qideal, w_u);
2562 if (w_u!=NULL)
2563 {
2564 atSet(res,omStrDup("isHomog"),ivCopy(w_u),INTVEC_CMD);
2565 }
2566 return FALSE;
2567}
2570{
2571 return jjPREIMAGE(res,u,v,NULL);
2572}
2574{
2575 return mpKoszul(res, u,v,NULL);
2576}
2578{
2579 sleftv h;
2580 h.Init();
2581 h.rtyp=INT_CMD;
2582 h.data=(void *)(long)IDELEMS((ideal)v->Data());
2583 return mpKoszul(res, u, &h, v);
2584}
2586{
2587 int ul= IDELEMS((ideal)u->Data());
2588 int vl= IDELEMS((ideal)v->Data());
2589#ifdef HAVE_SHIFTBBA
2590 if (rIsLPRing(currRing))
2591 {
2592 if (currRing->LPncGenCount < ul)
2593 {
2594 Werror("At least %d ncgen variables are needed for this computation.", ul);
2595 return TRUE;
2596 }
2597 }
2598#endif
2599 ideal m = idLift((ideal)u->Data(),(ideal)v->Data(),NULL,FALSE,
2600 hasFlag(u,FLAG_STD));
2601 if (m==NULL) return TRUE;
2602 res->data = (char *)id_Module2formatedMatrix(m,ul,vl,currRing);
2603 return FALSE;
2604}
2606{
2607 if ((v->rtyp!=IDHDL)||(v->e!=NULL)) return TRUE;
2608 idhdl h=(idhdl)v->data;
2609#ifdef HAVE_SHIFTBBA
2610 if (rIsLPRing(currRing))
2611 {
2612 if (currRing->LPncGenCount < IDELEMS((ideal)u->Data()))
2613 {
2614 Werror("At least %d ncgen variables are needed for this computation.", IDELEMS((ideal)u->Data()));
2615 return TRUE;
2616 }
2617 }
2618#endif
2619 // CopyD for IDEAL_CMD and MODUL_CMD are identical:
2620 res->data = (char *)idLiftStd((ideal)u->Data(),
2621 &(h->data.umatrix),testHomog);
2622 setFlag(res,FLAG_STD); v->flag=0;
2623 return FALSE;
2624}
2625static BOOLEAN jjLOAD2(leftv /*res*/, leftv/* LIB */ , leftv v)
2626{
2627 return jjLOAD((char*)v->Data(),TRUE);
2628}
2629static BOOLEAN jjLOAD_E(leftv /*res*/, leftv v, leftv u)
2630{
2631 char * s=(char *)u->Data();
2632 if(strcmp(s, "with")==0)
2633 return jjLOAD((char*)v->Data(), TRUE);
2634 if (strcmp(s,"try")==0)
2635 return jjLOAD_TRY((char*)v->Data());
2636 WerrorS("invalid second argument");
2637 WerrorS("load(\"libname\" [,option]);");
2638 return TRUE;
2639}
2641{
2642 intvec *w_u=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
2643 tHomog hom=testHomog;
2644 if (w_u!=NULL)
2645 {
2646 //PrintS("modulo: wu:");w_u->show(INTVEC_CMD);PrintLn();
2647 w_u=ivCopy(w_u);
2648 hom=isHomog;
2649 }
2650 //else PrintS("modulo: wu:none\n");
2651 intvec *w_v=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
2652 if (w_v!=NULL)
2653 {
2654 //PrintS("modulo: wv:");w_v->show(INTVEC_CMD);PrintLn();
2655 w_v=ivCopy(w_v);
2656 hom=isHomog;
2657 }
2658 //else PrintS("modulo: wv:none\n");
2659 if ((w_u!=NULL) && (w_v==NULL))
2660 w_v=ivCopy(w_u);
2661 if ((w_v!=NULL) && (w_u==NULL))
2662 w_u=ivCopy(w_v);
2663 ideal u_id=(ideal)u->Data();
2664 ideal v_id=(ideal)v->Data();
2665 if (w_u!=NULL)
2666 {
2667 if ((*w_u).compare((w_v))!=0)
2668 {
2669 WarnS("incompatible weights");
2670 delete w_u; w_u=NULL;
2671 hom=testHomog;
2672 }
2673 else
2674 {
2675 if ((!idTestHomModule(u_id,currRing->qideal,w_v))
2676 || (!idTestHomModule(v_id,currRing->qideal,w_v)))
2677 {
2678 WarnS("wrong weights");
2679 delete w_u; w_u=NULL;
2680 hom=testHomog;
2681 }
2682 }
2683 }
2684 res->data = (char *)idModulo(u_id,v_id ,hom,&w_u);
2685 if (w_u!=NULL)
2686 {
2687 atSet(res,omStrDup("isHomog"),w_u,INTVEC_CMD);
2688 }
2689 delete w_v;
2690 //if (TEST_OPT_RETURN_SB) setFlag(res,FLAG_STD);
2691 return FALSE;
2692}
2694{
2695 number q=(number)v->Data();
2696 if (n_IsZero(q,coeffs_BIGINT))
2697 {
2699 return TRUE;
2700 }
2701 res->data =(char *) n_IntMod((number)u->Data(),q,coeffs_BIGINT);
2702 return FALSE;
2703}
2705{
2706 number q=(number)v->Data();
2707 if (nIsZero(q))
2708 {
2710 return TRUE;
2711 }
2712 res->data =(char *) n_IntMod((number)u->Data(),q,currRing->cf);
2713 return FALSE;
2714}
2716{
2717 poly q=(poly)v->Data();
2718 if (q==NULL)
2719 {
2721 return TRUE;
2722 }
2723 poly p=(poly)(u->Data());
2724 if (p==NULL)
2725 {
2726 res->data=NULL;
2727 return FALSE;
2728 }
2729 res->data=(void*)(singclap_pmod(p /*(poly)(u->Data())*/ ,
2730 q /*(poly)(v->Data())*/ ,currRing));
2731 return FALSE;
2732}
2735{
2736 return jjMONITOR2(res,v,NULL);
2737}
2739{
2740#if 0
2741 char *opt=(char *)v->Data();
2742 int mode=0;
2743 while(*opt!='\0')
2744 {
2745 if (*opt=='i') mode |= SI_PROT_I;
2746 else if (*opt=='o') mode |= SI_PROT_O;
2747 opt++;
2748 }
2749 monitor((char *)(u->Data()),mode);
2750#else
2751 si_link l=(si_link)u->Data();
2752 if (slOpen(l,SI_LINK_WRITE,u)) return TRUE;
2753 if(strcmp(l->m->type,"ASCII")!=0)
2754 {
2755 Werror("ASCII link required, not `%s`",l->m->type);
2756 slClose(l);
2757 return TRUE;
2758 }
2759 SI_LINK_SET_CLOSE_P(l); // febase handles the FILE*
2760 if ( l->name[0]!='\0') // "" is the stop condition
2761 {
2762 const char *opt;
2763 int mode=0;
2764 if (v==NULL) opt=(const char*)"i";
2765 else opt=(const char *)v->Data();
2766 while(*opt!='\0')
2767 {
2768 if (*opt=='i') mode |= SI_PROT_I;
2769 else if (*opt=='o') mode |= SI_PROT_O;
2770 opt++;
2771 }
2772 monitor((FILE *)l->data,mode);
2773 }
2774 else
2775 monitor(NULL,0);
2776 return FALSE;
2777#endif
2778}
2780{
2781 intvec *iv=(intvec *)v->Data();
2782 poly p=pOne();
2783 int e;
2784 BOOLEAN err=FALSE;
2785 for(unsigned i=si_min(currRing->N,iv->length()); i>0; i--)
2786 {
2787 e=(*iv)[i-1];
2788 if (e>=0) pSetExp(p,i,e);
2789 else err=TRUE;
2790 }
2791 if (iv->length()==(currRing->N+1))
2792 {
2793 res->rtyp=VECTOR_CMD;
2794 e=(*iv)[currRing->N];
2795 if (e>=0) pSetComp(p,e);
2796 else err=TRUE;
2797 }
2798 pSetm(p);
2799 res->data=(char*)p;
2800 if(err) { pDelete(&p); WerrorS("no negative exponent allowed"); }
2801 return err;
2802}
2804{
2805 // u: the name of the new type
2806 // v: the elements
2807 const char *s=(const char *)u->Data();
2808 newstruct_desc d=NULL;
2809 if (strlen(s)>=2)
2810 {
2811 d=newstructFromString((const char *)v->Data());
2812 if (d!=NULL) newstruct_setup(s,d);
2813 }
2814 else WerrorS("name of newstruct must be longer than 1 character");
2815 return d==NULL;
2816}
2818{
2819 idhdl h=(idhdl)u->data;
2820 int i=(int)(long)v->Data();
2821 int p=0;
2822 if ((0<i)
2823 && (rParameter(IDRING(h))!=NULL)
2824 && (i<=(p=rPar(IDRING(h)))))
2825 res->data=omStrDup(rParameter(IDRING(h))[i-1]);
2826 else
2827 {
2828 Werror("par number %d out of range 1..%d",i,p);
2829 return TRUE;
2830 }
2831 return FALSE;
2832}
2833#ifdef HAVE_PLURAL
2835{
2836 if( currRing->qideal != NULL )
2837 {
2838 WerrorS("basering must NOT be a qring!");
2839 return TRUE;
2840 }
2841
2842 if (iiOp==NCALGEBRA_CMD)
2843 {
2844 return nc_CallPlural(NULL,NULL,(poly)a->Data(),(poly)b->Data(),currRing,false,true,false,currRing);
2845 }
2846 else
2847 {
2848 ring r=rCopy(currRing);
2849 BOOLEAN result=nc_CallPlural(NULL,NULL,(poly)a->Data(),(poly)b->Data(),r,false,true,false,currRing);
2850 res->data=r;
2851 return result;
2852 }
2853}
2855{
2856 if( currRing->qideal != NULL )
2857 {
2858 WerrorS("basering must NOT be a qring!");
2859 return TRUE;
2860 }
2861
2862 if (iiOp==NCALGEBRA_CMD)
2863 {
2864 return nc_CallPlural(NULL,(matrix)b->Data(),(poly)a->Data(),NULL,currRing,false,true,false,currRing);
2865 }
2866 else
2867 {
2868 ring r=rCopy(currRing);
2869 BOOLEAN result=nc_CallPlural(NULL,(matrix)b->Data(),(poly)a->Data(),NULL,r,false,true,false,currRing);
2870 res->data=r;
2871 return result;
2872 }
2873}
2875{
2876 if( currRing->qideal != NULL )
2877 {
2878 WerrorS("basering must NOT be a qring!");
2879 return TRUE;
2880 }
2881
2882 if (iiOp==NCALGEBRA_CMD)
2883 {
2884 return nc_CallPlural((matrix)a->Data(),NULL,NULL,(poly)b->Data(),currRing,false,true,false,currRing);
2885 }
2886 else
2887 {
2888 ring r=rCopy(currRing);
2889 BOOLEAN result=nc_CallPlural((matrix)a->Data(),NULL,NULL,(poly)b->Data(),r,false,true,false,currRing);
2890 res->data=r;
2891 return result;
2892 }
2893}
2895{
2896 if( currRing->qideal != NULL )
2897 {
2898 WerrorS("basering must NOT be a qring!");
2899 return TRUE;
2900 }
2901
2902 if (iiOp==NCALGEBRA_CMD)
2903 {
2904 return nc_CallPlural((matrix)a->Data(),(matrix)b->Data(),NULL,NULL,currRing,false,true,false,currRing);
2905 }
2906 else
2907 {
2908 ring r=rCopy(currRing);
2909 BOOLEAN result=nc_CallPlural((matrix)a->Data(),(matrix)b->Data(),NULL,NULL,r,false,true,false,currRing);
2910 res->data=r;
2911 return result;
2912 }
2913}
2915{
2916 res->data=NULL;
2917
2919 {
2920 const poly q = (poly)b->Data();
2921
2922 if( q != NULL )
2923 {
2924 if( (poly)a->Data() != NULL )
2925 {
2927 {
2928 poly p = (poly)a->CopyD(POLY_CMD); // p = copy!
2929 res->data = nc_p_Bracket_qq(p,q, currRing); // p will be destroyed!
2930 }
2931 else if (rIsLPRing(currRing))
2932 {
2933 const poly p = (poly)a->Data();
2934 res->data = pAdd(ppMult_qq(p,q), pNeg(ppMult_qq(q,p)));
2935 }
2936 }
2937 }
2938 }
2939 return FALSE;
2940}
2942{
2943 res->data=NULL;
2944
2946 {
2947 const poly q = (poly)b->Data();
2948 if(q != NULL)
2949 {
2950 if((poly)a->Data() != NULL)
2951 {
2952 const poly p = (poly)a->Data();
2953 int k=(int)(long)c->Data();
2954 if (k > 0)
2955 {
2956 poly qq = pCopy(q);
2957 for (int i = 0; i < k; i++)
2958 {
2959 poly qq_ref = qq;
2960 if (rIsLPRing(currRing))
2961 {
2962 qq = pAdd(ppMult_qq(p,qq), pNeg(ppMult_qq(qq,p)));
2963 }
2964 else if (rIsPluralRing(currRing))
2965 {
2966 qq = nc_p_Bracket_qq(pCopy(p), qq, currRing);
2967 }
2968 pDelete(&qq_ref);
2969 if (qq == NULL) break;
2970 }
2971 res->data = qq;
2972 }
2973 else
2974 {
2975 Werror("invalid number of iterations");
2976 }
2977 }
2978 }
2979 }
2980 return FALSE;
2981}
2983{
2984 /* number, poly, vector, ideal, module, matrix */
2985 ring r = (ring)a->Data();
2986 if (r == currRing)
2987 {
2988 res->data = b->Data();
2989 res->rtyp = b->rtyp;
2990 return FALSE;
2991 }
2992 if (!rIsLikeOpposite(currRing, r))
2993 {
2994 Werror("%s is not an opposite ring to current ring",a->Fullname());
2995 return TRUE;
2996 }
2997 idhdl w;
2998 if( ((w=r->idroot->get(b->Name(),myynest))!=NULL) && (b->e==NULL))
2999 {
3000 int argtype = IDTYP(w);
3001 switch (argtype)
3002 {
3003 case NUMBER_CMD:
3004 {
3005 /* since basefields are equal, we can apply nCopy */
3006 res->data = nCopy((number)IDDATA(w));
3007 res->rtyp = argtype;
3008 break;
3009 }
3010 case POLY_CMD:
3011 case VECTOR_CMD:
3012 {
3013 poly q = (poly)IDDATA(w);
3014 res->data = pOppose(r,q,currRing);
3015 res->rtyp = argtype;
3016 break;
3017 }
3018 case IDEAL_CMD:
3019 case MODUL_CMD:
3020 {
3021 ideal Q = (ideal)IDDATA(w);
3022 res->data = idOppose(r,Q,currRing);
3023 res->rtyp = argtype;
3024 break;
3025 }
3026 case MATRIX_CMD:
3027 {
3028 ring save = currRing;
3029 rChangeCurrRing(r);
3030 matrix m = (matrix)IDDATA(w);
3032 rChangeCurrRing(save);
3033 ideal S = idOppose(r,Q,currRing);
3034 id_Delete(&Q, r);
3035 res->data = id_Module2Matrix(S,currRing);
3036 res->rtyp = argtype;
3037 break;
3038 }
3039 default:
3040 {
3041 WerrorS("unsupported type in oppose");
3042 return TRUE;
3043 }
3044 }
3045 }
3046 else
3047 {
3048 Werror("identifier %s not found in %s",b->Fullname(),a->Fullname());
3049 return TRUE;
3050 }
3051 return FALSE;
3052}
3053#endif /* HAVE_PLURAL */
3054
3056{
3057 if (ma->Typ()!=SMATRIX_CMD)
3058 {
3059 WerrorS("expected prune_map(`module`,`smatrix`)`");
3060 return TRUE;
3061 }
3062
3063 intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
3064 ideal v_id=(ideal)v->Data();
3065 if (w!=NULL)
3066 {
3067 if (!idTestHomModule(v_id,currRing->qideal,w))
3068 {
3069 WarnS("wrong weights");
3070 w=NULL;
3071 // and continue at the non-homog case below
3072 }
3073 else
3074 {
3075 w=ivCopy(w);
3076 intvec **ww=&w;
3077 ideal mat;
3078 int *g=(int*)omAlloc(v_id->rank*sizeof(int));
3079 res->data = (char *)idMinEmbedding_with_map_v(v_id,ww,mat,g);
3080 atSet(res,omStrDup("isHomog"),*ww,INTVEC_CMD);
3081 idhdl h=(idhdl)ma->data;
3082 idDelete(&IDIDEAL(h));
3083 IDIDEAL(h)=mat;
3084 for(int i=0;i<v_id->rank;i++) Print("v[%d]:%d ",i+1,g[i]); PrintLn();
3085 omFreeSize(g,v_id->rank*sizeof(int));
3086 return FALSE;
3087 }
3088 }
3089 ideal mat;
3090 int *g=(int*)omAlloc(v_id->rank*sizeof(int));
3091 res->data = (char *)idMinEmbedding_with_map_v(v_id,NULL,mat,g);
3092 for(int i=0;i<v_id->rank;i++) Print("v[%d]:%d ",i+1,g[i]); PrintLn();
3093 omFreeSize(g,v_id->rank*sizeof(int));
3094 idhdl h=(idhdl)ma->data;
3095 idDelete(&IDIDEAL(h));
3096 IDIDEAL(h)=mat;
3097 return FALSE;
3098}
3100{
3101 res->data = (char *)idQuot((ideal)u->Data(),(ideal)v->Data(),
3102 hasFlag(u,FLAG_STD),u->Typ()==v->Typ());
3103 //if (TEST_OPT_RETURN_SB) setFlag(res,FLAG_STD);
3104 return FALSE;
3105}
3107{
3108 int i=(int)(long)u->Data();
3109 int j=(int)(long)v->Data();
3110 if (j-i <0) {WerrorS("invalid range for random"); return TRUE;}
3111 res->data =(char *)(long)((i > j) ? i : (siRand() % (j-i+1)) + i);
3112 return FALSE;
3113}
3115{
3116 matrix m =(matrix)u->Data();
3117 int isRowEchelon = (int)(long)v->Data();
3118 if (isRowEchelon != 1) isRowEchelon = 0;
3119 int rank = luRank(m, isRowEchelon);
3120 res->data =(char *)(long)rank;
3121 return FALSE;
3122}
3124{
3125 si_link l=(si_link)u->Data();
3126 leftv r=slRead(l,v);
3127 if (r==NULL)
3128 {
3129 const char *s;
3130 if ((l!=NULL)&&(l->name!=NULL)) s=l->name;
3131 else s=sNoName_fe;
3132 Werror("cannot read from `%s`",s);
3133 return TRUE;
3134 }
3135 memcpy(res,r,sizeof(sleftv));
3137 return FALSE;
3138}
3140{
3141 ideal vi=(ideal)v->Data();
3142 if (currRing->qideal!=NULL || vi->ncols>1 || rIsPluralRing(currRing))
3144 res->data = (char *)kNF(vi,currRing->qideal,(poly)u->Data());
3145 return FALSE;
3146}
3148{
3149 ideal ui=(ideal)u->Data();
3150 ideal vi=(ideal)v->Data();
3151 if (currRing->qideal!=NULL || vi->ncols>1 || rIsPluralRing(currRing))
3153 res->data = (char *)kNF(vi,currRing->qideal,ui);
3154 return FALSE;
3155}
3157{
3158 int maxl=(int)(long)v->Data();
3159 if (maxl<0)
3160 {
3161 WerrorS("length for res must not be negative");
3162 return TRUE;
3163 }
3164 syStrategy r;
3165 intvec *weights=NULL;
3166 int wmaxl=maxl;
3167 ideal u_id=(ideal)u->Data();
3168
3169 maxl--;
3170 if (/*(*/ maxl==-1 /*)*/) /*&& (iiOp!=MRES_CMD)*/
3171 {
3172 maxl = currRing->N-1+2*(iiOp==MRES_CMD);
3173 if (currRing->qideal!=NULL)
3174 {
3175 Warn(
3176 "full resolution in a qring may be infinite, setting max length to %d",
3177 maxl+1);
3178 }
3179 }
3180 weights=(intvec*)atGet(u,"isHomog",INTVEC_CMD);
3181 if (weights!=NULL)
3182 {
3183 if (!idTestHomModule(u_id,currRing->qideal,weights))
3184 {
3185 WarnS("wrong weights given:");weights->show();PrintLn();
3186 weights=NULL;
3187 }
3188 }
3189 intvec *ww=NULL;
3190 int add_row_shift=0;
3191 if (weights!=NULL)
3192 {
3193 ww=ivCopy(weights);
3194 add_row_shift = ww->min_in();
3195 (*ww) -= add_row_shift;
3196 }
3197 unsigned save_opt=si_opt_1;
3199 if ((iiOp == RES_CMD) || (iiOp == MRES_CMD))
3200 {
3201 r=syResolution(u_id,maxl, ww, iiOp==MRES_CMD);
3202 }
3203 else if (iiOp==SRES_CMD)
3204 // r=sySchreyerResolvente(u_id,maxl+1,&l);
3205 r=sySchreyer(u_id,maxl+1);
3206 else if (iiOp == LRES_CMD)
3207 {
3208 int dummy;
3209 if((currRing->qideal!=NULL)||
3210 (!idHomIdeal (u_id,NULL)))
3211 {
3212 WerrorS
3213 ("`lres` not implemented for inhomogeneous input or qring");
3214 return TRUE;
3215 }
3216 if(currRing->N == 1)
3217 WarnS("the current implementation of `lres` may not work in the case of a single variable");
3218 r=syLaScala3(u_id,&dummy);
3219 }
3220 else if (iiOp == KRES_CMD)
3221 {
3222 int dummy;
3223 if((currRing->qideal!=NULL)||
3224 (!idHomIdeal (u_id,NULL)))
3225 {
3226 WerrorS
3227 ("`kres` not implemented for inhomogeneous input or qring");
3228 return TRUE;
3229 }
3230 r=syKosz(u_id,&dummy);
3231 }
3232 else
3233 {
3234 int dummy;
3235 if((currRing->qideal!=NULL)||
3236 (!idHomIdeal (u_id,NULL)))
3237 {
3238 WerrorS
3239 ("`hres` not implemented for inhomogeneous input or qring");
3240 return TRUE;
3241 }
3242 ideal u_id_copy=idCopy(u_id);
3243 idSkipZeroes(u_id_copy);
3244 r=syHilb(u_id_copy,&dummy);
3245 idDelete(&u_id_copy);
3246 }
3247 if (r==NULL) return TRUE;
3248 if (r->list_length>wmaxl)
3249 {
3250 for(int i=wmaxl-1;i>=r->list_length;i--)
3251 {
3252 if (r->fullres[i]!=NULL) id_Delete(&r->fullres[i],currRing);
3253 if (r->minres[i]!=NULL) id_Delete(&r->minres[i],currRing);
3254 }
3255 }
3256 r->list_length=wmaxl;
3257 res->data=(void *)r;
3258 if ((weights!=NULL) && (ww!=NULL)) { delete ww; ww=NULL; }
3259 if ((r->weights!=NULL) && (r->weights[0]!=NULL))
3260 {
3261 ww=ivCopy(r->weights[0]);
3262 if (weights!=NULL) (*ww) += add_row_shift;
3263 atSet(res,omStrDup("isHomog"),ww,INTVEC_CMD);
3264 }
3265 else
3266 {
3267 if (weights!=NULL)
3268 {
3269 atSet(res,omStrDup("isHomog"),ivCopy(weights),INTVEC_CMD);
3270 }
3271 }
3272
3273 // test the La Scala case' output
3274 assume( ((iiOp == LRES_CMD) || (iiOp == HRES_CMD)) == (r->syRing != NULL) );
3275 assume( (r->syRing != NULL) == (r->resPairs != NULL) );
3276
3277 if(iiOp != HRES_CMD)
3278 assume( (r->minres != NULL) || (r->fullres != NULL) ); // is wrong for HRES_CMD...
3279 else
3280 assume( (r->orderedRes != NULL) || (r->res != NULL) ); // analog for hres...
3281
3282 si_opt_1=save_opt;
3283 return FALSE;
3284}
3286{
3287 number n1; int i;
3288
3289 if ((u->Typ() == BIGINT_CMD) ||
3290 ((u->Typ() == NUMBER_CMD) && rField_is_Q(currRing)))
3291 {
3292 n1 = (number)u->CopyD();
3293 }
3294 else if (u->Typ() == INT_CMD)
3295 {
3296 i = (int)(long)u->Data();
3297 n1 = n_Init(i, coeffs_BIGINT);
3298 }
3299 else
3300 {
3301 return TRUE;
3302 }
3303
3304 i = (int)(long)v->Data();
3305
3306 lists l = primeFactorisation(n1, i);
3307 n_Delete(&n1, coeffs_BIGINT);
3308 res->data = (char*)l;
3309 return FALSE;
3310}
3312{
3313 ring r=rMinusVar((ring)u->Data(),(char*)v->Data());
3314 res->data = (char *)r;
3315 return r==NULL;
3316}
3318{
3319 int left;
3320 if (u->Typ()==RING_CMD) left=0;
3321 else
3322 {
3323 leftv h=u;u=v;v=h;
3324 left=1;
3325 }
3326 ring r=rPlusVar((ring)u->Data(),(char*)v->Data(),left);
3327 res->data = (char *)r;
3328 return r==NULL;
3329}
3331{
3332 ring r;
3333 int i=rSum((ring)u->Data(),(ring)v->Data(),r);
3334 res->data = (char *)r;
3335 return (i==-1);
3336}
3337#define SIMPL_NORMALIZE 64
3338#define SIMPL_LMDIV 32
3339#define SIMPL_LMEQ 16
3340#define SIMPL_MULT 8
3341#define SIMPL_EQU 4
3342#define SIMPL_NULL 2
3343#define SIMPL_NORM 1
3345{
3346 int sw = (int)(long)v->Data();
3347 // CopyD for IDEAL_CMD and MODUL_CMD are identical:
3348 ideal id = (ideal)u->CopyD(IDEAL_CMD);
3349 if (sw & SIMPL_LMDIV)
3350 {
3351 id_DelDiv(id,currRing);
3352 }
3353 if (sw & SIMPL_LMEQ)
3354 {
3356 }
3357 if (sw & SIMPL_MULT)
3358 {
3360 }
3361 else if(sw & SIMPL_EQU)
3362 {
3364 }
3365 if (sw & SIMPL_NULL)
3366 {
3367 idSkipZeroes(id);
3368 }
3369 if (sw & SIMPL_NORM)
3370 {
3371 id_Norm(id,currRing);
3372 }
3373 if (sw & SIMPL_NORMALIZE)
3374 {
3376 }
3377 res->data = (char * )id;
3378 return FALSE;
3379}
3382{
3383 intvec *v=NULL;
3384 int sw=(int)(long)dummy->Data();
3385 int fac_sw=sw;
3386 if (sw<0) fac_sw=1;
3388 ideal f=singclap_sqrfree((poly)(u->CopyD()), &v, fac_sw, currRing);
3389 if (f==NULL)
3390 return TRUE;
3391 switch(sw)
3392 {
3393 case 0:
3394 case 2:
3395 {
3397 l->Init(2);
3398 l->m[0].rtyp=IDEAL_CMD;
3399 l->m[0].data=(void *)f;
3400 l->m[1].rtyp=INTVEC_CMD;
3401 l->m[1].data=(void *)v;
3402 res->data=(void *)l;
3403 res->rtyp=LIST_CMD;
3404 return FALSE;
3405 }
3406 case 1:
3407 res->data=(void *)f;
3408 return FALSE;
3409 case 3:
3410 {
3411 poly p=f->m[0];
3412 int i=IDELEMS(f);
3413 f->m[0]=NULL;
3414 while(i>1)
3415 {
3416 i--;
3417 p=pMult(p,f->m[i]);
3418 f->m[i]=NULL;
3419 }
3420 res->data=(void *)p;
3421 res->rtyp=POLY_CMD;
3422 }
3423 return FALSE;
3424 }
3425 WerrorS("invalid switch");
3426 return FALSE;
3427}
3429{
3430 res->data = omStrDup(slStatus((si_link) u->Data(), (char *) v->Data()));
3431 return FALSE;
3432}
3434{
3435 res->data = (void *)(long)slStatusSsiL((lists) u->Data(), (int)(long) v->Data());
3436 //return (res->data== (void*)(long)-2);
3437 return FALSE;
3438}
3440{
3441 int sw = (int)(long)v->Data();
3442 // CopyD for POLY_CMD and VECTOR_CMD are identical:
3443 poly p = (poly)u->CopyD(POLY_CMD);
3444 if (sw & SIMPL_NORM)
3445 {
3446 pNorm(p);
3447 }
3448 if (sw & SIMPL_NORMALIZE)
3449 {
3451 }
3452 res->data = (char * )p;
3453 return FALSE;
3454}
3456{
3457 ideal result;
3458 intvec *w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
3459 tHomog hom=testHomog;
3460 ideal u_id=(ideal)(u->Data());
3461 if (w!=NULL)
3462 {
3463 if (!idTestHomModule(u_id,currRing->qideal,w))
3464 {
3465 WarnS("wrong weights:");w->show();PrintLn();
3466 w=NULL;
3467 }
3468 else
3469 {
3470 w=ivCopy(w);
3471 hom=isHomog;
3472 }
3473 }
3474 bigintmat *vv=(bigintmat*)v->Data();
3475 result=kStd2(u_id,currRing->qideal,hom,&w,vv);
3477 res->data = (char *)result;
3479 if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
3480 return FALSE;
3481}
3483{
3484 ideal result;
3485 assumeStdFlag(u);
3486 ideal i1=(ideal)(u->Data());
3487 int ii1=idElem(i1); /* size of i1 */
3488 ideal i0;
3489 int r=v->Typ();
3490 if ((/*v->Typ()*/r==POLY_CMD) ||(r==VECTOR_CMD))
3491 {
3492 poly p=(poly)v->Data();
3493 i0=idInit(1,i1->rank);
3494 i0->m[0]=p;
3495 i1=idSimpleAdd(i1,i0); //
3496 memset(i0->m,0,sizeof(poly)*IDELEMS(i0));
3497 idDelete(&i0);
3498 intvec *w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
3499 tHomog hom=testHomog;
3500
3501 if (w!=NULL)
3502 {
3503 if (!idTestHomModule(i1,currRing->qideal,w))
3504 {
3505 // no warnung: this is legal, if i in std(i,p)
3506 // is homogeneous, but p not
3507 w=NULL;
3508 }
3509 else
3510 {
3511 w=ivCopy(w);
3512 hom=isHomog;
3513 }
3514 }
3515 BITSET save1;
3516 SI_SAVE_OPT1(save1);
3518 /* ii1 appears to be the position of the first element of il that
3519 does not belong to the old SB ideal */
3520 result=kStd2(i1,currRing->qideal,hom,&w,(bigintmat*)NULL,0,ii1);
3521 SI_RESTORE_OPT1(save1);
3522 idDelete(&i1);
3524 if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
3525 res->data = (char *)result;
3526 }
3527 else /*IDEAL/MODULE*/
3528 {
3529 i0=(ideal)v->CopyD();
3530 i1=idSimpleAdd(i1,i0); //
3531 memset(i0->m,0,sizeof(poly)*IDELEMS(i0));
3532 idDelete(&i0);
3533 intvec *w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
3534 tHomog hom=testHomog;
3535
3536 if (w!=NULL)
3537 {
3538 if (!idTestHomModule(i1,currRing->qideal,w))
3539 {
3540 // no warnung: this is legal, if i in std(i,p)
3541 // is homogeneous, but p not
3542 w=NULL;
3543 hom=isNotHomog;
3544 }
3545 else
3546 {
3547 w=ivCopy(w);
3548 hom=isHomog;
3549 }
3550 }
3551 BITSET save1;
3552 SI_SAVE_OPT1(save1);
3554 /* ii1 appears to be the position of the first element of i1 that
3555 does not belong to the old SB ideal */
3556 result=kStd2(i1,currRing->qideal,hom,&w,(bigintmat*)NULL,0,ii1);
3557 SI_RESTORE_OPT1(save1);
3558 idDelete(&i1);
3560 if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
3561 res->data = (char *)result;
3562 }
3564 return FALSE;
3565}
3567{
3568 // see jjSYZYGY
3569 intvec *ww=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
3570 intvec *w=NULL;
3571 tHomog hom=testHomog;
3572 ideal I=(ideal)u->Data();
3573 GbVariant alg=syGetAlgorithm((char*)v->Data(),currRing,I);
3574 if (ww!=NULL)
3575 {
3576 if (idTestHomModule(I,currRing->qideal,ww))
3577 {
3578 w=ivCopy(ww);
3579 int add_row_shift=w->min_in();
3580 (*w)-=add_row_shift;
3581 hom=isHomog;
3582 }
3583 else
3584 {
3585 //WarnS("wrong weights");
3586 delete ww; ww=NULL;
3587 hom=testHomog;
3588 }
3589 }
3590 else
3591 {
3592 if (u->Typ()==IDEAL_CMD)
3593 if (idHomIdeal(I,currRing->qideal))
3594 hom=isHomog;
3595 }
3596 ideal S=idSyzygies(I,hom,&w,TRUE,FALSE,NULL,alg);
3597 if (w!=NULL) delete w;
3598 res->data = (char *)S;
3599 if (hom==isHomog)
3600 {
3601 int vl=S->rank;
3602 intvec *vv=new intvec(vl);
3603 if ((u->Typ()==IDEAL_CMD)||(ww==NULL))
3604 {
3605 for(int i=0;i<vl;i++)
3606 {
3607 if (I->m[i]!=NULL)
3608 (*vv)[i]=p_Deg(I->m[i],currRing);
3609 }
3610 }
3611 else
3612 {
3613 p_SetModDeg(ww, currRing);
3614 for(int i=0;i<vl;i++)
3615 {
3616 if (I->m[i]!=NULL)
3617 (*vv)[i]=currRing->pFDeg(I->m[i],currRing);
3618 }
3620 }
3621 if (idTestHomModule(S,currRing->qideal,vv))
3622 atSet(res,omStrDup("isHomog"),vv,INTVEC_CMD);
3623 else
3624 delete vv;
3625 }
3627 return FALSE;
3628}
3630{
3631 ideal A=(ideal)u->Data();
3632 ideal B=(ideal)v->Data();
3633 res->data = (char *)sm_Tensor(A,B,currRing);
3634 return FALSE;
3635}
3637{
3638 sleftv tmp_u,tmp_v,tmp_res;
3642 tmp_res.Init();
3643 tmp_res.rtyp=SMATRIX_CMD;
3644 BOOLEAN bo=jjTENSOR(&tmp_res,&tmp_u,&tmp_v);
3645 if (!bo)
3646 {
3649 }
3650 tmp_u.CleanUp();
3651 tmp_v.CleanUp();
3652 tmp_res.CleanUp();
3653 return bo;
3654}
3656{
3657 idhdl h=(idhdl)u->data;
3658 int i=(int)(long)v->Data();
3659 if ((0<i) && (i<=IDRING(h)->N))
3660 res->data=omStrDup(IDRING(h)->names[i-1]);
3661 else
3662 {
3663 Werror("var number %d out of range 1..%d",i,IDRING(h)->N);
3664 return TRUE;
3665 }
3666 return FALSE;
3667}
3669{
3670// input: u: a list with links of type
3671// ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
3672// v: timeout for select in milliseconds
3673// or 0 for polling
3674// returns: ERROR (via Werror): timeout negative
3675// -1: the read state of all links is eof
3676// 0: timeout (or polling): none ready
3677// i>0: (at least) L[i] is ready
3678 lists L = (lists)u->Data();
3679 int t = (int)(long)v->Data();
3680 if(t < 0)
3681 {
3682 t= -1;
3683 }
3684 int i = slStatusSsiL(L, t);
3685 if(i == -2) /* error */
3686 {
3687 return TRUE;
3688 }
3689 res->data = (void*)(long)i;
3690 return FALSE;
3691}
3693{
3694// input: u: a list with links of type
3695// ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
3696// v: timeout for select in milliseconds
3697// or 0 for polling
3698// or -1 for infinite
3699// returns: ERROR (via Werror): timeout negative
3700// -1: the read state of all links is eof or error
3701// 0: timeout (or polling): none ready
3702// 1: all links are ready
3703// (caution: at least one is ready, but some maybe dead)
3704 lists L = (lists)u->Data();
3705 BOOLEAN* ignore=(BOOLEAN*)omAlloc0((L->nr+1)*sizeof(BOOLEAN));
3706 int timeout = (int)(long)v->Data();
3707 if(timeout < 0)
3708 {
3709 timeout=-1;
3710 }
3711 int t = getRTimer()/TIMER_RESOLUTION; // in seconds
3712 int i;
3713 int ret = -1;
3714 for(unsigned nfinished = 0; nfinished <= ((unsigned)L->nr); nfinished++)
3715 {
3716 i = slStatusSsiL(L, timeout, ignore);
3717 if(i > 0) /* L[i] is ready */
3718 {
3719 ret = 1;
3720 ignore[i-1]=TRUE;
3721 timeout = si_max(0,timeout - 1000*(getRTimer()/TIMER_RESOLUTION - t));
3722 }
3723 else /* terminate the for loop */
3724 {
3725 omFreeSize(ignore,(L->nr+1)*sizeof(BOOLEAN));
3726 if(i == -2) /* error */
3727 {
3728 return TRUE;
3729 }
3730 if(i == 0) /* timeout */
3731 {
3732 ret = 0;
3733 }
3734 break;
3735 }
3736 }
3737 res->data = (void*)(long)ret;
3738 return FALSE;
3739}
3741{
3742 res->data = (char *)mp_Wedge((matrix)u->Data(),(int)(long)v->Data(),currRing);
3743 return FALSE;
3744}
3746{
3747 return TRUE;
3748}
3750{
3751 return TRUE;
3752}
3754{
3755 return TRUE;
3756}
3757
3758/*=================== operations with 1 arg.: static proc =================*/
3759/* must be ordered: first operations for chars (infix ops),
3760 * then alphabetically */
3761
3763{
3764// res->data = (char *)u->CopyD();
3765// also copy attributes:
3766 res->Copy(u);
3767 return FALSE;
3768}
3770{
3771 return FALSE;
3772}
3773//static BOOLEAN jjPLUSPLUS(leftv res, leftv u)
3774//{
3775// res->data = (char *)((int)(long)u->Data()+1);
3776// return FALSE;
3777//}
3778//static BOOLEAN jjMINUSMINUS(leftv res, leftv u)
3779//{
3780// res->data = (char *)((int)(long)u->Data()-1);
3781// return FALSE;
3782//}
3784{
3785 if (IDTYP((idhdl)u->data)==INT_CMD)
3786 {
3787 int i=IDINT((idhdl)u->data);
3788 if (iiOp==PLUSPLUS) i++;
3789 else i--;
3790 IDDATA((idhdl)u->data)=(char *)(long)i;
3791 return FALSE;
3792 }
3793 return TRUE;
3794}
3796{
3797 number n=(number)u->CopyD(BIGINT_CMD);
3799 res->data = (char *)n;
3800 return FALSE;
3801}
3803{
3804 res->data = (char *)(-(long)u->Data());
3805 return FALSE;
3806}
3808{
3809 number n=(number)u->CopyD(NUMBER_CMD);
3810 n=nInpNeg(n);
3811 res->data = (char *)n;
3812 return FALSE;
3813}
3815{
3816 res->data = (char *)pNeg((poly)u->CopyD(POLY_CMD));
3817 return FALSE;
3818}
3820{
3821 poly m1=pISet(-1);
3822 res->data = (char *)mp_MultP((matrix)u->CopyD(MATRIX_CMD),m1,currRing);
3823 return FALSE;
3824}
3826{
3827 intvec *iv=(intvec *)u->CopyD(INTVEC_CMD);
3828 (*iv)*=(-1);
3829 res->data = (char *)iv;
3830 return FALSE;
3831}
3833{
3835 (*bim)*=(-1);
3836 res->data = (char *)bim;
3837 return FALSE;
3838}
3839// dummy for python_module.so and similiar
3841{
3842 if (u->rtyp==IDHDL) rSetHdl((idhdl)u->data);
3843 else
3844 {
3845 ring r=(ring)u->Data();
3846 idhdl h=rFindHdl(r,NULL);
3847 if (h==NULL)
3848 {
3849 char name_buffer[100];
3850 STATIC_VAR int ending=1000000;
3851 ending++;
3852 snprintf(name_buffer,100, "PYTHON_RING_VAR%d",ending);
3853 h=enterid(name_buffer,0,RING_CMD,&IDROOT);
3854 IDRING(h)=rIncRefCnt(r);
3855 }
3856 rSetHdl(h);
3857 }
3858 return FALSE;
3859}
3861{
3862 return jjPROC(res,u,NULL);
3863}
3865{
3866 //matrix m=(matrix)v->Data();
3867 //lists l=mpBareiss(m,FALSE);
3868 intvec *iv;
3869 ideal m;
3870 sm_CallBareiss((ideal)v->Data(),0,0,m,&iv, currRing);
3872 l->Init(2);
3873 l->m[0].rtyp=MODUL_CMD;
3874 l->m[1].rtyp=INTVEC_CMD;
3875 l->m[0].data=(void *)m;
3876 l->m[1].data=(void *)iv;
3877 res->data = (char *)l;
3878 return FALSE;
3879}
3880//static BOOLEAN jjBAREISS_IM(leftv res, leftv v)
3881//{
3882// intvec *m=(intvec *)v->CopyD(INTMAT_CMD);
3883// ivTriangMat(m);
3884// res->data = (char *)m;
3885// return FALSE;
3886//}
3888{
3889 bigintmat *b=(bigintmat*)v->CopyD(BIGINTMAT_CMD);
3890 b->hnf();
3891 res->data=(char*)b;
3892 return FALSE;
3893}
3895{
3896 BOOLEAN bo=FALSE;
3897 number n=(number)u->CopyD();
3899 if (nMap!=NULL)
3900 res->data=nMap(n,coeffs_BIGINT,currRing->cf);
3901 else
3902 {
3903 Werror("cannot convert bigint to cring %s", nCoeffName(currRing->cf));
3904 bo=TRUE;
3905 }
3907 return bo;
3908}
3910{
3911 bigintmat *b=(bigintmat*)u->Data();
3912 res->data=(void *)bim2iv(b);
3913 return FALSE;
3914}
3916{
3917 sleftv tmp;
3918 BOOLEAN bo=jjBI2N(&tmp,u);
3919 if (!bo)
3920 {
3921 number n=(number) tmp.data;
3922 if (nIsZero(n)) { res->data=NULL;nDelete(&n); }
3923 else
3924 {
3925 res->data=(void *)pNSet(n);
3926 }
3927 }
3928 return bo;
3929}
3931{
3932 return iiExprArithM(res,u,iiOp);
3933}
3935{
3936 res->data = (char *)(long)rChar((ring)v->Data());
3937 return FALSE;
3938}
3940{
3941 ring r=(ring)v->Data();
3942 r->cf->ref++;
3943 res->data = (char *)r->cf;
3944 return FALSE;
3945}
3947{
3948 res->data = (char *)(long)MATCOLS((matrix)(v->Data()));
3949 return FALSE;
3950}
3952{
3953 res->data = (char *)(long)((bigintmat*)(v->Data()))->cols();
3954 return FALSE;
3955}
3957{
3958 res->data = (char *)(long)((intvec*)(v->Data()))->cols();
3959 return FALSE;
3960}
3962{
3963 // CopyD for POLY_CMD and VECTOR_CMD are identical:
3964 poly p=(poly)v->CopyD(POLY_CMD);
3965 if (p!=NULL) p_Cleardenom(p, currRing);
3966 res->data = (char *)p;
3967 return FALSE;
3968}
3970{
3971 res->data = (char *)(long)n_Size((number)v->Data(),coeffs_BIGINT);
3972 return FALSE;
3973}
3975{
3976 bigintmat* aa= (bigintmat *)v->Data();
3977 res->data = (char *)(long)(aa->rows()*aa->cols());
3978 return FALSE;
3979}
3981{
3982 res->data = (char *)(long)nSize((number)v->Data());
3983 return FALSE;
3984}
3986{
3987 lists l=(lists)v->Data();
3988 res->data = (char *)(long)(lSize(l)+1);
3989 return FALSE;
3990}
3992{
3993 matrix m=(matrix)v->Data();
3994 res->data = (char *)(long)(MATROWS(m)*MATCOLS(m));
3995 return FALSE;
3996}
3998{
3999 res->data = (char *)(long)((intvec*)(v->Data()))->length();
4000 return FALSE;
4001}
4003{
4004 ring r=(ring)v->Data();
4005 int elems=-1;
4006 if (rField_is_Zp(r)) elems=r->cf->ch;
4007 else if (rField_is_GF(r)) elems=r->cf->m_nfCharQ;
4008 else if (rField_is_Zp_a(r) && (r->cf->type==n_algExt))
4009 {
4010 extern int ipower ( int b, int n ); /* factory/cf_util */
4011 elems=ipower(r->cf->ch,r->cf->extRing->pFDeg(r->cf->extRing->qideal->m[0],r->cf->extRing));
4012 }
4013 res->data = (char *)(long)elems;
4014 return FALSE;
4015}
4017{
4018 int dummy;
4019 poly p=(poly)v->Data();
4020 if (p!=NULL) res->data = (char *)currRing->pLDeg(p,&dummy,currRing);
4021 else res->data=(char *)-1;
4022 return FALSE;
4023}
4025{
4026 ideal I=(ideal)u->Data();
4027 int d=-1;
4028 int dummy;
4029 int i;
4030 for(i=IDELEMS(I)-1;i>=0;i--)
4031 if (I->m[i]!=NULL) d=si_max(d,(int)currRing->pLDeg(I->m[i],&dummy,currRing));
4032 res->data = (char *)(long)d;
4033 return FALSE;
4034}
4036{
4037 SPrintStart();
4038 if (rField_is_Z(currRing))
4039 {
4040 PrintS("// NOTE: computation of degree is being performed for\n");
4041 PrintS("// generic fibre, that is, over Q\n");
4042 }
4044 intvec *module_w=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
4045 scDegree((ideal)v->Data(),module_w,currRing->qideal);
4046 char *s=SPrintEnd();
4047 int l=strlen(s)-1;
4048 s[l]='\0';
4049 res->data=(void*)s;
4050 return FALSE;
4051}
4053{
4054 if ((v->rtyp==IDHDL)
4055 && ((myynest==IDLEV((idhdl)v->data))||(0==IDLEV((idhdl)v->data))))
4056 {
4057 res->data=(void *)(long)(IDLEV((idhdl)v->data)+1);
4058 }
4059 else if (v->rtyp!=0) res->data=(void *)(-1);
4060 return FALSE;
4061}
4062
4063/// Return the denominator of the input number
4065{
4066 number n = reinterpret_cast<number>(v->CopyD());
4067 res->data = reinterpret_cast<void*>(n_GetDenom(n, currRing->cf));
4068 n_Delete(&n,currRing->cf);
4069 return FALSE;
4070}
4071
4072/// Return the numerator of the input number
4074{
4075 number n = reinterpret_cast<number>(v->CopyD());
4076 res->data = reinterpret_cast<void*>(n_GetNumerator(n, currRing->cf));
4077 n_Delete(&n,currRing->cf);
4078 return FALSE;
4079}
4080
4082{
4083 matrix m=(matrix)v->Data();
4084 res ->data = mp_Det(m,currRing);
4085 return FALSE;
4086}
4088{
4089 bigintmat * m=(bigintmat*)v->Data();
4090 int i,j;
4091 i=m->rows();j=m->cols();
4092 if(i==j)
4093 res->data = (char *)(long)singclap_det_bi(m,coeffs_BIGINT);
4094 else
4095 {
4096 Werror("det of %d x %d bigintmat",i,j);
4097 return TRUE;
4098 }
4099 return FALSE;
4100}
4101#ifdef SINGULAR_4_2
4102static BOOLEAN jjDET_N2(leftv res, leftv v)
4103{
4104 bigintmat * m=(bigintmat*)v->Data();
4105 number2 r=(number2)omAlloc0(sizeof(*r));
4106 int i,j;
4107 i=m->rows();j=m->cols();
4108 if(i==j)
4109 {
4110 r->n=m->det();
4111 r->cf=m->basecoeffs();
4112 }
4113 else
4114 {
4115 omFreeSize(r,sizeof(*r));
4116 Werror("det of %d x %d cmatrix",i,j);
4117 return TRUE;
4118 }
4119 res->data=(void*)r;
4120 return FALSE;
4121}
4122#endif
4124{
4125 intvec * m=(intvec*)v->Data();
4126 int i,j;
4127 i=m->rows();j=m->cols();
4128 if(i==j)
4129 res->data = (char *)(long)singclap_det_i(m,currRing);
4130 else
4131 {
4132 Werror("det of %d x %d intmat",i,j);
4133 return TRUE;
4134 }
4135 return FALSE;
4136}
4138{
4139 ideal I=(ideal)v->Data();
4140 res->data=(char*)sm_Det(I,currRing);
4141 return FALSE;
4142}
4144{
4146#ifdef HAVE_SHIFTBBA
4147 if (rIsLPRing(currRing))
4148 {
4150 {
4151 WerrorS("`dim` is not implemented for letterplace rings over rings");
4152 return TRUE;
4153 }
4154 if (currRing->qideal != NULL)
4155 {
4156 WerrorS("qring not supported by `dim` for letterplace rings at the moment");
4157 return TRUE;
4158 }
4159 int gkDim = lp_gkDim((ideal)(v->Data()));
4160 res->data = (char *)(long)gkDim;
4161 return (gkDim == -2);
4162 }
4163#endif
4165 {
4166 Warn("dim(%s) may be wrong because the mixed monomial ordering",v->Name());
4167 }
4168 res->data = (char *)(long)scDimIntRing((ideal)(v->Data()),currRing->qideal);
4169 return FALSE;
4170}
4172{
4173 si_link l = (si_link)v->Data();
4174 if (slDump(l))
4175 {
4176 const char *s;
4177 if ((l!=NULL)&&(l->name!=NULL)) s=l->name;
4178 else s=sNoName_fe;
4179 Werror("cannot dump to `%s`",s);
4180 return TRUE;
4181 }
4182 else
4183 return FALSE;
4184}
4186{
4187 res->data = (char *)pOne();
4188 int co=(int)(long)v->Data();
4189 if (co>0)
4190 {
4191 pSetComp((poly)res->data,co);
4192 pSetm((poly)res->data);
4193 }
4194 else WerrorS("argument of gen must be positive");
4195 return (co<=0);
4196}
4198{
4199 char * d = (char *)v->Data();
4200 char * s = (char *)omAlloc(strlen(d) + 13);
4201 strcpy( s, (char *)d);
4202 strcat( s, "\n;RETURN();\n");
4204 return yyparse();
4205}
4207{
4209 if (currRing->cf->convSingNFactoryN!=ndConvSingNFactoryN) /* conversion to factory*/
4210 {
4211 ideal_list p,h;
4212 h=kStdfac((ideal)v->Data(),NULL,testHomog,NULL);
4213 if (h==NULL)
4214 {
4215 L->Init(1);
4216 L->m[0].data=(char *)idInit(1);
4217 L->m[0].rtyp=IDEAL_CMD;
4218 }
4219 else
4220 {
4221 p=h;
4222 int l=0;
4223 while (p!=NULL) { p=p->next;l++; }
4224 L->Init(l);
4225 l=0;
4226 while(h!=NULL)
4227 {
4228 L->m[l].data=(char *)h->d;
4229 L->m[l].rtyp=IDEAL_CMD;
4230 p=h->next;
4231 omFreeSize(h,sizeof(*h));
4232 h=p;
4233 l++;
4234 }
4235 }
4236 }
4237 else
4238 {
4239 WarnS("no factorization implemented");
4240 L->Init(1);
4241 iiExprArith1(&(L->m[0]),v,STD_CMD);
4242 }
4243 res->data=(void *)L;
4244 return FALSE;
4245}
4247{
4248 intvec *v=NULL;
4250 ideal f=singclap_factorize((poly)(u->CopyD()), &v, 0,currRing);
4251 if (f==NULL) return TRUE;
4252 ivTest(v);
4254 l->Init(2);
4255 l->m[0].rtyp=IDEAL_CMD;
4256 l->m[0].data=(void *)f;
4257 l->m[1].rtyp=INTVEC_CMD;
4258 l->m[1].data=(void *)v;
4259 res->data=(void *)l;
4260 return FALSE;
4261}
4263{
4264 si_link l = (si_link)v->Data();
4265 if (slGetDump(l))
4266 {
4267 const char *s;
4268 if ((l!=NULL)&&(l->name!=NULL)) s=l->name;
4269 else s=sNoName_fe;
4270 Werror("cannot get dump from `%s`",s);
4271 return TRUE;
4272 }
4273 else
4274 return FALSE;
4275}
4277{
4279 ideal I=(ideal)v->Data();
4280 res->data=(void *)iiHighCorner(I,0);
4281 return FALSE;
4282}
4284{
4286 intvec *w=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
4287 BOOLEAN delete_w=FALSE;
4288 ideal I=(ideal)v->Data();
4289 int i;
4290 poly p=NULL,po=NULL;
4291 int rk=id_RankFreeModule(I,currRing);
4292 if (w==NULL)
4293 {
4294 w = new intvec(rk);
4295 delete_w=TRUE;
4296 }
4297 for(i=rk;i>0;i--)
4298 {
4299 p=iiHighCorner(I,i);
4300 if (p==NULL)
4301 {
4302 WerrorS("module must be zero-dimensional");
4303 if (delete_w) delete w;
4304 return TRUE;
4305 }
4306 if (po==NULL)
4307 {
4308 po=p;
4309 }
4310 else
4311 {
4312 // now po!=NULL, p!=NULL
4313 int d=(currRing->pFDeg(po,currRing)-(*w)[pGetComp(po)-1] - currRing->pFDeg(p,currRing)+(*w)[i-1]);
4314 if (d==0)
4315 d=pLmCmp(po,p);
4316 if (d > 0)
4317 {
4318 pDelete(&p);
4319 }
4320 else // (d < 0)
4321 {
4322 pDelete(&po); po=p;
4323 }
4324 }
4325 }
4326 if (delete_w) delete w;
4327 res->data=(void *)po;
4328 return FALSE;
4329}
4331{
4332 if (rField_is_Z(currRing))
4333 {
4334 PrintS("// NOTE: computation of Hilbert series etc. is being\n");
4335 PrintS("// performed for generic fibre, that is, over Q\n");
4336 }
4338 intvec *module_w=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
4339 //scHilbertPoly((ideal)v->Data(),currRing->qideal);
4340 hLookSeries((ideal)v->Data(),module_w,currRing->qideal);
4341 return FALSE;
4342}
4344{
4345 if (rField_is_Z(currRing))
4346 {
4347 PrintS("// NOTE: computation of Hilbert series etc. is being\n");
4348 PrintS("// performed for generic fibre, that is, over Q\n");
4349 }
4350 res->data=(void *)hSecondSeries((intvec *)v->Data());
4351 return FALSE;
4352}
4354{
4355 intvec *w=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
4356 ideal v_id=(ideal)v->Data();
4357 if (w==NULL)
4358 {
4359 res->data=(void *)(long)idHomModule(v_id,currRing->qideal,&w);
4360 if (res->data!=NULL)
4361 {
4362 if (v->rtyp==IDHDL)
4363 {
4364 char *s_isHomog=omStrDup("isHomog");
4365 if (v->e==NULL)
4366 atSet((idhdl)(v->data),s_isHomog,w,INTVEC_CMD);
4367 else
4368 atSet((idhdl)(v->LData()),s_isHomog,w,INTVEC_CMD);
4369 }
4370 else if (w!=NULL) delete w;
4371 } // if res->data==NULL then w==NULL
4372 }
4373 else
4374 {
4375 res->data=(void *)(long)idTestHomModule(v_id,currRing->qideal,w);
4376 if((res->data==NULL) && (v->rtyp==IDHDL))
4377 {
4378 if (v->e==NULL)
4379 atKill((idhdl)(v->data),"isHomog");
4380 else
4381 atKill((idhdl)(v->LData()),"isHomog");
4382 }
4383 }
4384 return FALSE;
4385}
4387{
4388#ifdef HAVE_SHIFTBBA
4389 if (rIsLPRing(currRing))
4390 {
4391 int deg = (int)(long)v->Data();
4392 if (deg > currRing->N/currRing->isLPring)
4393 {
4394 WerrorS("degree bound of Letterplace ring is to small");
4395 return TRUE;
4396 }
4397 }
4398#endif
4399 res->data = (char *)idMaxIdeal((int)(long)v->Data());
4401 return FALSE;
4402}
4404{
4405 matrix mat=(matrix)v->CopyD(MATRIX_CMD);
4406 IDELEMS((ideal)mat)=MATCOLS(mat)*MATROWS(mat);
4407 MATROWS(mat)=1;
4408 mat->rank=1;
4409 res->data=(char *)mat;
4410 return FALSE;
4411}
4413{
4414 map m=(map)v->CopyD(MAP_CMD);
4415 omFreeBinAddr((ADDRESS)m->preimage);
4416 m->preimage=NULL;
4417 ideal I=(ideal)m;
4418 I->rank=1;
4419 res->data=(char *)I;
4420 return FALSE;
4421}
4423{
4424 if (currRing!=NULL)
4425 {
4426 ring q=(ring)v->Data();
4427 if (rSamePolyRep(currRing, q))
4428 {
4429 if (q->qideal==NULL)
4430 res->data=(char *)idInit(1,1);
4431 else
4432 res->data=(char *)idCopy(q->qideal);
4433 return FALSE;
4434 }
4435 }
4436 WerrorS("can only get ideal from identical qring");
4437 return TRUE;
4438}
4440{
4441 intvec *iv = (intvec *)v->CopyD(INTMAT_CMD);
4442 iv->makeVector();
4443 res->data = iv;
4444 return FALSE;
4445}
4447{
4448 res->data = (char *)n_ImPart((number)v->Data(),currRing->cf);
4449 return FALSE;
4450}
4452{
4454 res->data=(void *)scIndIntvec((ideal)(v->Data()),currRing->qideal);
4455 return FALSE;
4456}
4458{
4459 ideal result=kInterRed((ideal)(v->Data()), currRing->qideal);
4460 if (TEST_OPT_PROT) { PrintLn(); mflush(); }
4461 res->data = result;
4462 return FALSE;
4463}
4465{
4466 bigintmat* aa= (bigintmat *)v->Data();
4467 int l=aa->cols();
4468 intvec *iv=new intvec(l);
4469 for(int i=0;i<l;i++) (*iv)[i]=iin_Int(BIMATELEM((*aa),1,i+1),coeffs_BIGINT);
4470 res->data = (void*)iv;
4471 return FALSE;
4472}
4474{
4475 res->data = (char *)(long)pVar((poly)v->Data());
4476 return FALSE;
4477}
4479{
4480 res->data = (char *)(long)(r_IsRingVar((char *)v->Data(), currRing->names,
4481 currRing->N)+1);
4482 return FALSE;
4483}
4485{
4486 res->data = (char *)0;
4487 return FALSE;
4488}
4490{
4491 ideal i=idInit(currRing->N,1);
4492 int k;
4493 poly p=(poly)(v->Data());
4494 for (k=currRing->N;k>0;k--)
4495 {
4496 i->m[k-1]=pDiff(p,k);
4497 }
4498 res->data = (char *)i;
4499 return FALSE;
4500}
4502{
4503 if (!nCoeff_is_transExt(currRing->cf))
4504 {
4505 WerrorS("differentiation not defined in the coefficient ring");
4506 return TRUE;
4507 }
4508 number n = (number) u->Data();
4509 number k = (number) v->Data();
4510 res->data = ntDiff(n,k,currRing->cf);
4511 return FALSE;
4512}
4513/*2
4514 * compute Jacobi matrix of a module/matrix
4515 * Jacobi(M) := ( diff(Mt,var(1))|, ... ,| diff(Mt,var(currRing->N)) ),
4516 * where Mt := transpose(M)
4517 * Note that this is consistent with the current conventions for jacob in Singular,
4518 * whereas M2 computes its transposed.
4519 */
4521{
4522 ideal id = (ideal)a->Data();
4523 id = id_Transp(id,currRing);
4524 int W = IDELEMS(id);
4525
4526 ideal result = idInit(W * currRing->N, id->rank);
4527 poly *p = result->m;
4528
4529 for( int v = 1; v <= currRing->N; v++ )
4530 {
4531 poly* q = id->m;
4532 for( int i = 0; i < W; i++, p++, q++ )
4533 *p = pDiff( *q, v );
4534 }
4535 idDelete(&id);
4536
4537 res->data = (char *)result;
4538 return FALSE;
4539}
4540
4542{
4543#ifdef HAVE_FLINT
4544 res->data = (char *)singflint_kernel((matrix)(v->Data()),currRing);
4545 return res->data==NULL;
4546#else
4547 return TRUE;
4548#endif
4549}
4551{
4552#ifdef HAVE_FLINT
4553 res->data = (char *)singflint_kernel((ideal)(v->Data()),currRing);
4554 return res->data==NULL;
4555#else
4556 return TRUE;
4557#endif
4558}
4560{
4562 res->data = (char *)scKBase(-1,(ideal)(v->Data()),currRing->qideal);
4563 return FALSE;
4564}
4566{
4567 res->data=(char *)syConvList((lists)v->Data());
4568 if (res->data != NULL)
4569 return FALSE;
4570 else
4571 return TRUE;
4572}
4574{
4575 poly p=(poly)v->Data();
4576 if (p==NULL)
4577 {
4578 res->data=(char *)nInit(0);
4579 }
4580 else
4581 {
4583 res->data=(char *)nCopy(pGetCoeff(p));
4584 }
4585 return FALSE;
4586}
4588{
4589 poly p=(poly)v->Data();
4590 int s=currRing->N;
4591 if (v->Typ()==VECTOR_CMD) s++;
4592 intvec *iv=new intvec(s);
4593 if (p!=NULL)
4594 {
4595 for(int i = currRing->N;i;i--)
4596 {
4597 (*iv)[i-1]=pGetExp(p,i);
4598 }
4599 if (s!=currRing->N)
4600 (*iv)[currRing->N]=pGetComp(p);
4601 }
4602 res->data=(char *)iv;
4603 return FALSE;
4604}
4606{
4607 poly p=(poly)v->Data();
4608 if (p == NULL)
4609 {
4610 res->data = (char*) NULL;
4611 }
4612 else
4613 {
4614 poly lm = pLmInit(p);
4615 pSetCoeff0(lm, nInit(1));
4616 res->data = (char*) lm;
4617 }
4618 return FALSE;
4619}
4620static BOOLEAN jjLOAD1(leftv /*res*/, leftv v)
4621{
4622 return jjLOAD((char*)v->Data(),FALSE);
4623}
4625{
4626 lists l=(lists)v->Data();
4627 long mm=(long)atGet(v,"maxExp",INT_CMD);
4628 int isLetterplace=(int)(long)atGet(v,"isLetterplaceRing",INT_CMD);
4629 ring r=rCompose(l,TRUE,mm,isLetterplace);
4630 res->data=(char *)r;
4631 return (r==NULL);
4632}
4634{
4635 /* call method jjPFAC2 with second argument = 0 (meaning that no
4636 valid bound for the prime factors has been given) */
4637 sleftv tmp;
4638 tmp.Init();
4639 tmp.rtyp = INT_CMD;
4640 return jjPFAC2(res, v, &tmp);
4641}
4643{
4644 sleftv a2,a3;
4645 memset(&a2,0,sizeof(a2));
4646 memset(&a3,0,sizeof(a3));
4647 a2.rtyp=INT_CMD; a2.data=(void*)10;
4648 a3.rtyp=INT_CMD; a3.data=(void*)1;
4649 return nuLagSolve(res,v,&a2,&a3);
4650}
4652{
4653 /* computes the LU-decomposition of a matrix M;
4654 i.e., M = P * L * U, where
4655 - P is a row permutation matrix,
4656 - L is in lower triangular form,
4657 - U is in upper row echelon form
4658 Then, we also have P * M = L * U.
4659 A list [P, L, U] is returned. */
4660 matrix mat = (matrix)v->Data();
4661 if (!idIsConstant((ideal)mat))
4662 {
4663 WerrorS("matrix must be constant");
4664 return TRUE;
4665 }
4666 matrix pMat;
4667 matrix lMat;
4668 matrix uMat;
4669
4670 luDecomp(mat, pMat, lMat, uMat);
4671
4673 ll->Init(3);
4674 ll->m[0].rtyp=MATRIX_CMD; ll->m[0].data=(void *)pMat;
4675 ll->m[1].rtyp=MATRIX_CMD; ll->m[1].data=(void *)lMat;
4676 ll->m[2].rtyp=MATRIX_CMD; ll->m[2].data=(void *)uMat;
4677 res->data=(char*)ll;
4678
4679 return FALSE;
4680}
4682{
4683 // clean out "_":
4684 sLastPrinted.CleanUp();
4685 // collect all info:
4686 omUpdateInfo();
4687 switch(((int)(long)v->Data()))
4688 {
4689 case 0:
4690 res->data=(char *)n_Init(om_Info.UsedBytes,coeffs_BIGINT);
4691 break;
4692 case 1:
4693 res->data = (char *)n_Init(om_Info.CurrentBytesSystem,coeffs_BIGINT);
4694 break;
4695 case 2:
4696 res->data = (char *)n_Init(om_Info.MaxBytesSystem,coeffs_BIGINT);
4697 break;
4698 default:
4699 omPrintStats(stdout);
4700 omPrintInfo(stdout);
4701 omPrintBinStats(stdout);
4702 res->data = (char *)0;
4703 res->rtyp = NONE;
4704 }
4705 return FALSE;
4706}
4707//static BOOLEAN jjMONITOR1(leftv res, leftv v)
4708//{
4709// return jjMONITOR2(res,v,NULL);
4710//}
4712{
4713 int t=v->Typ();
4714 ideal r,m;
4715 r=kMin_std2((ideal)v->Data(),currRing->qideal,testHomog,NULL,m,NULL);
4717 l->Init(2);
4718 l->m[0].rtyp=t;
4719 l->m[0].data=(char *)r;
4720 setFlag(&(l->m[0]),FLAG_STD);
4721 l->m[1].rtyp=t;
4722 l->m[1].data=(char *)m;
4723 res->data=(char *)l;
4724 return FALSE;
4725}
4727{
4729 res->data = (char *)(long)scMultInt((ideal)(v->Data()),currRing->qideal);
4730 return FALSE;
4731}
4733{
4734 intvec *weights=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
4735
4736 syStrategy tmp=syCopy((syStrategy)v->Data());
4737 tmp = syMinimize(tmp); // enrich itself!
4738
4739 res->data=(char *)tmp;
4740
4741 if (weights!=NULL)
4742 atSet(res, omStrDup("isHomog"),ivCopy(weights),INTVEC_CMD);
4743
4744 return FALSE;
4745}
4747{
4748 number n,i; i=(number)v->Data();
4750 if (nMap!=NULL)
4751 n=nMap(i,currRing->cf,coeffs_BIGINT);
4752 else goto err;
4753 res->data=(void *)n;
4754 return FALSE;
4755err:
4756 WerrorS("cannot convert to bigint"); return TRUE;
4757}
4759{
4760 if ((v->rtyp==IDHDL)||(v->rtyp==ALIAS_CMD))
4761 res->data=omStrDup(v->name);
4762 else if (v->name==NULL)
4763 res->data=omStrDup("");
4764 else
4765 {
4766 res->data = (char *)v->name;
4767 v->name=NULL;
4768 }
4769 return FALSE;
4770}
4772{
4773 res->data=ipNameList(((ring)v->Data())->idroot);
4774 return FALSE;
4775}
4777{
4778 res->data=ipNameListLev((IDROOT),(int)(long)v->Data());
4779 return FALSE;
4780}
4782{
4783 res->data=(char*)(long)((long)v->Data()==0 ? 1 : 0);
4784 return FALSE;
4785}
4787{
4788 res->data = (char *)(long)(((ring)(v->Data()))->N);
4789 return FALSE;
4790}
4792{
4793 si_link l=(si_link)v->Data();
4794 if (iiOp==OPEN_CMD) return slOpen(l, SI_LINK_OPEN,v);
4795 else { slPrepClose(l); return slClose(l);}
4796}
4798{
4799 poly p=(poly)v->Data();
4800 res->data=(char *)( p==NULL ? -1 : currRing->pFDeg(p,currRing) );
4801 return FALSE;
4802}
4804{
4805 int i=(int)(long)v->Data();
4806 int p=0;
4807 p=rPar(currRing);
4808 if ((0<i) && (i<=p))
4809 {
4810 res->data=(char *)n_Param(i,currRing);
4811 }
4812 else
4813 {
4814 Werror("par number %d out of range 1..%d",i,p);
4815 return TRUE;
4816 }
4817 return FALSE;
4818}
4820{
4821 number nn=(number)v->Data();
4822 res->data = (char *)(long)n_ParDeg(nn, currRing->cf);
4823 return FALSE;
4824}
4826{
4827 if (currRing==NULL)
4828 {
4829 WerrorS("no ring active (1)");
4830 return TRUE;
4831 }
4832 int i=(int)(long)v->Data();
4833 int p=0;
4834 if ((0<i) && (rParameter(currRing)!=NULL) && (i<=(p=rPar(currRing))))
4835 res->data=omStrDup(rParameter(currRing)[i-1]);
4836 else
4837 {
4838 Werror("par number %d out of range 1..%d",i,p);
4839 return TRUE;
4840 }
4841 return FALSE;
4842}
4844{
4845 poly p=(poly)v->Data();
4846 if (p==NULL) { res->data=(char *)n_Init(0,coeffs_BIGINT); return FALSE; }
4847 if ((pNext(p)!=NULL)|| (!pIsConstant(p)))
4848 {
4849 WerrorS("poly must be constant");
4850 return TRUE;
4851 }
4852 number i=pGetCoeff(p);
4853 number n;
4855 if (nMap!=NULL)
4856 n=nMap(i,currRing->cf,coeffs_BIGINT);
4857 else goto err;
4858 res->data=(void *)n;
4859 return FALSE;
4860err:
4861 WerrorS("cannot convert to bigint"); return TRUE;
4862}
4864{
4865 poly p=(poly)v->Data();
4866 if (p==NULL) { /*res->data=(char *)0;*/ return FALSE; }
4867 if ((pNext(p)!=NULL)|| (!pIsConstant(p)))
4868 {
4869 WerrorS("poly must be constant");
4870 return TRUE;
4871 }
4872 res->data = (char *)(long)iin_Int(pGetCoeff(p),currRing->cf);
4873 return FALSE;
4874}
4876{
4877 map mapping=(map)v->Data();
4878 syMake(res,omStrDup(mapping->preimage));
4879 return FALSE;
4880}
4882{
4883 int i = IsPrime((int)(long)(v->Data()));
4884 res->data = (char *)(long)(i > 1 ? i : 2);
4885 return FALSE;
4886}
4888{
4889 intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
4890 ideal v_id=(ideal)v->Data();
4891 if (w!=NULL)
4892 {
4893 if (!idTestHomModule(v_id,currRing->qideal,w))
4894 {
4895 WarnS("wrong weights");
4896 w=NULL;
4897 // and continue at the non-homog case below
4898 }
4899 else
4900 {
4901 w=ivCopy(w);
4902 intvec **ww=&w;
4903 res->data = (char *)idMinEmbedding(v_id,FALSE,ww);
4904 atSet(res,omStrDup("isHomog"),*ww,INTVEC_CMD);
4905 return FALSE;
4906 }
4907 }
4908 res->data = (char *)idMinEmbedding(v_id);
4909 return FALSE;
4910}
4912{
4913 number n;
4914 poly p;
4915 if (((p=(poly)v->Data())!=NULL)
4916 && (pIsConstant(p)))
4917 {
4918 n=nCopy(pGetCoeff(p));
4919 }
4920 else
4921 {
4922 n=nInit(0);
4923 }
4924 res->data = (char *)n;
4925 return FALSE;
4926}
4928{
4929 char *s= (char *)v->Data();
4930 // try system keywords
4931 for(unsigned i=0; i<sArithBase.nCmdUsed; i++)
4932 {
4933 //Print("test %d, >>%s<<, tab:>>%s<<\n",i,s,sArithBase.sCmds[i].name);
4934 if (strcmp(s, sArithBase.sCmds[i].name) == 0)
4935 {
4936 res->data = (char *)1;
4937 return FALSE;
4938 }
4939 }
4940 // try blackbox names
4941 int id;
4942 blackboxIsCmd(s,id);
4943 if (id>0)
4944 {
4945 res->data = (char *)1;
4946 }
4947 return FALSE;
4948}
4950{
4951 matrix m =(matrix)v->Data();
4952 int rank = luRank(m, 0);
4953 res->data =(char *)(long)rank;
4954 return FALSE;
4955}
4957{
4958 return jjREAD2(res,v,NULL);
4959}
4961{
4962 res->data = (char *)(long)iiRegularity((lists)v->Data());
4963 return FALSE;
4964}
4966{
4967 res->data = (char *)n_RePart((number)v->Data(),currRing->cf);
4968 return FALSE;
4969}
4971{
4972 ring r=(ring)v->Data();
4973 if (r!=NULL)
4974 {
4975 res->data = (char *)rDecompose((ring)v->Data());
4976 if (res->data!=NULL)
4977 {
4978 long mm=r->wanted_maxExp;
4979 if (mm!=0) atSet(res,omStrDup("maxExp"),(void*)mm,INT_CMD);
4980 return FALSE;
4981 }
4982 }
4983 return TRUE;
4984}
4986{
4987 coeffs r=(coeffs)v->Data();
4988 if (r!=NULL)
4989 return rDecompose_CF(res,r);
4990 return TRUE;
4991}
4993{
4994 ring r=(ring)v->Data();
4995 if (r!=NULL)
4996 res->data = (char *)rDecompose_list_cf((ring)v->Data());
4997 return (r==NULL)||(res->data==NULL);
4998}
5000{
5001 ideal i = (ideal)v->Data();
5002 res->data = (char *)i->rank;
5003 return FALSE;
5004}
5006{
5007 res->data = (char *)(long)((bigintmat*)(v->Data()))->rows();
5008 return FALSE;
5009}
5011{
5012 res->data = (char *)(long)((intvec*)(v->Data()))->rows();
5013 return FALSE;
5014}
5016{
5017 res->data = (char *)(long)rPar(((ring)v->Data()));
5018 return FALSE;
5019}
5021{
5022 res->data = (char *)(long)atoi((char*)v->Data());
5023 return FALSE;
5024}
5026{
5027 const bool bIsSCA = rIsSCA(currRing);
5028
5029 if ((currRing->qideal!=NULL) && !bIsSCA)
5030 {
5031 WerrorS("qring not supported by slimgb at the moment");
5032 return TRUE;
5033 }
5035 {
5036 WerrorS("ordering must be global for slimgb");
5037 return TRUE;
5038 }
5040 WarnS("groebner base computations with inexact coefficients can not be trusted due to rounding errors");
5041 intvec *w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
5042 // tHomog hom=testHomog;
5043 ideal u_id=(ideal)u->Data();
5044 if (w!=NULL)
5045 {
5046 if (!idTestHomModule(u_id,currRing->qideal,w))
5047 {
5048 WarnS("wrong weights");
5049 w=NULL;
5050 }
5051 else
5052 {
5053 w=ivCopy(w);
5054 // hom=isHomog;
5055 }
5056 }
5057
5058 assume(u_id->rank>=id_RankFreeModule(u_id, currRing));
5059 res->data=(char *)t_rep_gb(currRing,
5060 u_id,u_id->rank);
5061 //res->data=(char *)t_rep_gb(currRing, u_id);
5062
5064 if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
5065 return FALSE;
5066}
5068{
5069 ideal result;
5070 ideal v_id=(ideal)v->Data();
5071 intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
5072 tHomog hom=testHomog;
5073 if (w!=NULL)
5074 {
5075 if (!idTestHomModule(v_id,currRing->qideal,w))
5076 {
5077 WarnS("wrong weights");
5078 w=NULL;
5079 }
5080 else
5081 {
5082 hom=isHomog;
5083 w=ivCopy(w);
5084 }
5085 }
5086 result=kSba(v_id,currRing->qideal,hom,&w,1,0,NULL);
5088 res->data = (char *)result;
5090 if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
5091 return FALSE;
5092}
5094{
5095 ideal result;
5096 ideal v_id=(ideal)v->Data();
5097 intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
5098 tHomog hom=testHomog;
5099 if (w!=NULL)
5100 {
5101 if (!idTestHomModule(v_id,currRing->qideal,w))
5102 {
5103 WarnS("wrong weights");
5104 w=NULL;
5105 }
5106 else
5107 {
5108 hom=isHomog;
5109 w=ivCopy(w);
5110 }
5111 }
5112 result=kSba(v_id,currRing->qideal,hom,&w,(int)(long)u->Data(),0,NULL);
5114 res->data = (char *)result;
5116 if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
5117 return FALSE;
5118}
5120{
5121 ideal result;
5122 ideal v_id=(ideal)v->Data();
5123 intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
5124 tHomog hom=testHomog;
5125 if (w!=NULL)
5126 {
5127 if (!idTestHomModule(v_id,currRing->qideal,w))
5128 {
5129 WarnS("wrong weights");
5130 w=NULL;
5131 }
5132 else
5133 {
5134 hom=isHomog;
5135 w=ivCopy(w);
5136 }
5137 }
5138 result=kSba(v_id,currRing->qideal,hom,&w,(int)(long)u->Data(),(int)(long)t->Data(),NULL);
5140 res->data = (char *)result;
5142 if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
5143 return FALSE;
5144}
5146{
5148 WarnS("groebner base computations with inexact coefficients can not be trusted due to rounding errors");
5149 ideal result;
5150 ideal v_id=(ideal)v->Data();
5151 intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
5152 tHomog hom=testHomog;
5153 if (w!=NULL)
5154 {
5155 if (!idTestHomModule(v_id,currRing->qideal,w))
5156 {
5157 WarnS("wrong weights");
5158 w=NULL;
5159 }
5160 else
5161 {
5162 hom=isHomog;
5163 w=ivCopy(w);
5164 }
5165 }
5166 result=kStd2(v_id,currRing->qideal,hom,&w,(bigintmat*)NULL);
5168 res->data = (char *)result;
5170 if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
5171 return FALSE;
5172}
5174{
5175 res->data = (char *)idSort((ideal)v->Data());
5176 return FALSE;
5177}
5179{
5181 intvec *v=NULL;
5182 ideal f=singclap_sqrfree((poly)(u->CopyD()), &v, 0, currRing);
5183 if (f==NULL) return TRUE;
5184 ivTest(v);
5186 l->Init(2);
5187 l->m[0].rtyp=IDEAL_CMD;
5188 l->m[0].data=(void *)f;
5189 l->m[1].rtyp=INTVEC_CMD;
5190 l->m[1].data=(void *)v;
5191 res->data=(void *)l;
5192 return FALSE;
5193}
5194#if 0
5196{
5197 intvec *w=NULL;
5198 res->data = (char *)idSyzygies((ideal)v->Data(),testHomog,&w);
5199 if (w!=NULL) delete w;
5201 return FALSE;
5202}
5203#else
5204// activate, if idSyz handle module weights correctly !
5206{
5207 ideal v_id=(ideal)v->Data();
5208#ifdef HAVE_SHIFTBBA
5209 if (rIsLPRing(currRing))
5210 {
5211 if (currRing->LPncGenCount < IDELEMS(v_id))
5212 {
5213 Werror("At least %d ncgen variables are needed for this computation.", IDELEMS(v_id));
5214 return TRUE;
5215 }
5216 }
5217#endif
5218 intvec *ww=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
5219 intvec *w=NULL;
5220 tHomog hom=testHomog;
5221 if (ww!=NULL)
5222 {
5223 if (idTestHomModule(v_id,currRing->qideal,ww))
5224 {
5225 w=ivCopy(ww);
5226 int add_row_shift=w->min_in();
5227 (*w)-=add_row_shift;
5228 hom=isHomog;
5229 }
5230 else
5231 {
5232 //WarnS("wrong weights");
5233 delete ww; ww=NULL;
5234 hom=testHomog;
5235 }
5236 }
5237 else
5238 {
5239 if (v->Typ()==IDEAL_CMD)
5240 if (idHomIdeal(v_id,currRing->qideal))
5241 hom=isHomog;
5242 }
5243 ideal S=idSyzygies(v_id,hom,&w);
5244 res->data = (char *)S;
5245 if (hom==isHomog)
5246 {
5247 int vl=S->rank;
5248 intvec *vv=new intvec(vl);
5249 if ((v->Typ()==IDEAL_CMD)||(ww==NULL))
5250 {
5251 for(int i=0;i<vl;i++)
5252 {
5253 if (v_id->m[i]!=NULL)
5254 (*vv)[i]=p_Deg(v_id->m[i],currRing);
5255 }
5256 }
5257 else
5258 {
5259 p_SetModDeg(ww, currRing);
5260 for(int i=0;i<vl;i++)
5261 {
5262 if (v_id->m[i]!=NULL)
5263 (*vv)[i]=currRing->pFDeg(v_id->m[i],currRing);
5264 }
5266 }
5267 if (idTestHomModule(S,currRing->qideal,vv))
5268 atSet(res,omStrDup("isHomog"),vv,INTVEC_CMD);
5269 else
5270 delete vv;
5271 }
5272 if (w!=NULL) delete w;
5273 return FALSE;
5274}
5275#endif
5277{
5278 res->data = (char *)(long)ivTrace((intvec*)(v->Data()));
5279 return FALSE;
5280}
5282{
5283 res->data = (char *)(((bigintmat*)(v->Data()))->transpose());
5284 return FALSE;
5285}
5287{
5288 res->data = (char *)ivTranp((intvec*)(v->Data()));
5289 return FALSE;
5290}
5292{
5293#ifdef HAVE_PLURAL
5294 ring r = (ring)a->Data();
5295 //if (rIsPluralRing(r))
5296 if (r->OrdSgn==1)
5297 {
5298 res->data = rOpposite(r);
5299 }
5300 else
5301 {
5302 WarnS("opposite only for global orderings");
5303 res->data = rCopy(r);
5304 }
5305 return FALSE;
5306#else
5307 return TRUE;
5308#endif
5309}
5311{
5312#ifdef HAVE_PLURAL
5313 ring r = (ring)a->Data();
5314 if (rIsPluralRing(r))
5315 {
5316 ring s = rEnvelope(r);
5317 res->data = s;
5318 }
5319 else res->data = rCopy(r);
5320 return FALSE;
5321#else
5322 return TRUE;
5323#endif
5324}
5326{
5327#ifdef HAVE_PLURAL
5328 ideal result;
5329 ideal v_id=(ideal)a->Data();
5331 result=(ideal)twostd(v_id);
5332 else /*commutative or shiftalgebra*/
5333 {
5334 return jjSTD(res,a);
5335 }
5336 res->data = (char *)result;
5339 return FALSE;
5340#else
5341 return TRUE;
5342#endif
5343}
5345{
5346#if defined(HAVE_SHIFTBBA) || defined(HAVE_PLURAL)// do not place above jjSTD in this file because we need to reference it
5347 if (rIsLPRing(currRing))
5348 {
5350 WarnS("groebner base computations with inexact coefficients can not be trusted due to rounding errors");
5351 ideal result;
5352 ideal v_id=(ideal)v->Data();
5353 /* intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD); */
5354 /* tHomog hom=testHomog; */
5355 /* if (w!=NULL) */
5356 /* { */
5357 /* if (!idTestHomModule(v_id,currRing->qideal,w)) */
5358 /* { */
5359 /* WarnS("wrong weights"); */
5360 /* w=NULL; */
5361 /* } */
5362 /* else */
5363 /* { */
5364 /* hom=isHomog; */
5365 /* w=ivCopy(w); */
5366 /* } */
5367 /* } */
5368 /* result=kStd2(v_id,currRing->qideal,hom,&w); */
5369 result = rightgb(v_id, currRing->qideal);
5371 res->data = (char *)result;
5373 /* if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD); */
5374 return FALSE;
5375 }
5376 else if (rIsPluralRing(currRing))
5377 {
5378 ideal I=(ideal)v->Data();
5379
5380 ring A = currRing;
5381 ring Aopp = rOpposite(A);
5382 currRing = Aopp;
5383 ideal Iopp = idOppose(A, I, Aopp);
5384 ideal Jopp = kStd2(Iopp,currRing->qideal,testHomog,NULL,(bigintmat*)NULL);
5385 currRing = A;
5386 ideal J = idOppose(Aopp, Jopp, A);
5387
5388 id_Delete(&Iopp, Aopp);
5389 id_Delete(&Jopp, Aopp);
5390 rDelete(Aopp);
5391
5392 idSkipZeroes(J);
5393 res->data = (char *)J;
5395 return FALSE;
5396 }
5397 else
5398 {
5399 return jjSTD(res, v);
5400 }
5401#else
5402 return TRUE;
5403#endif
5404}
5406{
5407 int t=(int)(long)v->data;
5408 switch (t)
5409 {
5410 case CRING_CMD:
5411 case INT_CMD:
5412 case POLY_CMD:
5413 case VECTOR_CMD:
5414 case STRING_CMD:
5415 case INTVEC_CMD:
5416 case IDEAL_CMD:
5417 case MATRIX_CMD:
5418 case MODUL_CMD:
5419 case MAP_CMD:
5420 case PROC_CMD:
5421 case RING_CMD:
5422 case SMATRIX_CMD:
5423 //case QRING_CMD:
5424 case INTMAT_CMD:
5425 case BIGINTMAT_CMD:
5426 case BIGINTVEC_CMD:
5427 case NUMBER_CMD:
5428 #ifdef SINGULAR_4_2
5429 case CNUMBER_CMD:
5430 #endif
5431 case BIGINT_CMD:
5432 case BUCKET_CMD:
5433 case LIST_CMD:
5434 case PACKAGE_CMD:
5435 case LINK_CMD:
5436 case RESOLUTION_CMD:
5437 res->data=omStrDup(Tok2Cmdname(t)); break;
5438 case DEF_CMD:
5439 case NONE: res->data=omStrDup("none"); break;
5440 default:
5441 {
5442 if (t>MAX_TOK)
5443 res->data=omStrDup(getBlackboxName(t));
5444 else
5445 res->data=omStrDup("?unknown type?");
5446 break;
5447 }
5448 }
5449 return FALSE;
5450}
5452{
5453 res->data=(char *)(long)pIsUnivariate((poly)v->Data());
5454 return FALSE;
5455}
5457{
5458 int i=(int)(long)v->Data();
5459 if ((0<i) && (i<=currRing->N))
5460 {
5461 poly p=pOne();
5462 pSetExp(p,i,1);
5463 pSetm(p);
5464 res->data=(char *)p;
5465 }
5466 else
5467 {
5468 Werror("var number %d out of range 1..%d",i,currRing->N);
5469 return TRUE;
5470 }
5471 return FALSE;
5472}
5474{
5475 if (currRing==NULL)
5476 {
5477 WerrorS("no ring active (2)");
5478 return TRUE;
5479 }
5480 int i=(int)(long)v->Data();
5481 if ((0<i) && (i<=currRing->N))
5482 res->data=omStrDup(currRing->names[i-1]);
5483 else
5484 {
5485 Werror("var number %d out of range 1..%d",i,currRing->N);
5486 return TRUE;
5487 }
5488 return FALSE;
5489}
5491{
5493#ifdef HAVE_SHIFTBBA
5494 if (rIsLPRing(currRing))
5495 {
5497 {
5498 WerrorS("`vdim` is not implemented for letterplace rings over rings");
5499 return TRUE;
5500 }
5501 if (currRing->qideal != NULL)
5502 {
5503 WerrorS("qring not supported by `vdim` for letterplace rings at the moment");
5504 return TRUE;
5505 }
5506 int kDim = lp_kDim((ideal)(v->Data()));
5507 res->data = (char *)(long)kDim;
5508 return (kDim == -2);
5509 }
5510#endif
5511 long l=scMult0Int((ideal)v->Data(),currRing->qideal);
5512 if (l<-1L)
5513 WerrorS("int overflow in vdim");
5514 res->data = (char *)l;
5515 return FALSE;
5516}
5518{
5519// input: u: a list with links of type
5520// ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
5521// returns: -1: the read state of all links is eof or error
5522// i>0: (at least) u[i] is ready
5523 lists L = (lists)u->Data();
5524 int i = slStatusSsiL(L, -1);
5525 if(i == -2) /* error */
5526 {
5527 return TRUE;
5528 }
5529 res->data = (void*)(long)i;
5530 return FALSE;
5531}
5533{
5534// input: u: a list with links of type
5535// ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
5536// returns: -1: the read state of all links is eof or error
5537// 1: all links are ready
5538// (caution: at least one is ready, but some maybe dead)
5539 lists L = (lists)u->Data();
5540 int i;
5541 int j = -1;
5542 BOOLEAN* ignore=(BOOLEAN*)omAlloc0((L->nr+1)*sizeof(BOOLEAN));
5543 for(int nfinished = 0; nfinished <= L->nr; nfinished++)
5544 {
5545 i = slStatusSsiL(L, -1, ignore);
5546 if(i == -2) /* error */
5547 {
5548 omFreeSize(ignore,(L->nr+1)*sizeof(BOOLEAN));
5549 return TRUE;
5550 }
5551 if((i == -1)||(j==0))
5552 {
5553 j=-1;
5554 break;
5555 }
5556 if (i>0)
5557 {
5558 j=1;
5559 ignore[i-1]=TRUE;
5560 }
5561 }
5562 omFreeSize(ignore,(L->nr+1)*sizeof(BOOLEAN));
5563 res->data = (void*)(long)j;
5564 return FALSE;
5565}
5566
5567BOOLEAN jjLOAD(const char *s, BOOLEAN autoexport)
5568{
5569 char libnamebuf[1024];
5571
5572#ifdef HAVE_DYNAMIC_LOADING
5573 extern BOOLEAN load_modules(const char *newlib, char *fullpath, BOOLEAN autoexport);
5574#endif /* HAVE_DYNAMIC_LOADING */
5575 switch(LT)
5576 {
5577 default:
5578 case LT_NONE:
5579 Werror("%s: unknown type", s);
5580 break;
5581 case LT_NOTFOUND:
5582 Werror("cannot open %s", s);
5583 break;
5584
5585 case LT_SINGULAR:
5586 {
5587 char *plib = iiConvName(s);
5588 idhdl pl = IDROOT->get_level(plib,0);
5589 if (pl==NULL)
5590 {
5591 pl = enterid( plib,0, PACKAGE_CMD, &(basePack->idroot), TRUE );
5592 IDPACKAGE(pl)->language = LANG_SINGULAR;
5593 IDPACKAGE(pl)->libname=omStrDup(s);
5594 }
5595 else if (IDTYP(pl)!=PACKAGE_CMD)
5596 {
5597 Werror("can not create package `%s`",plib);
5598 omFreeBinAddr(plib);
5599 return TRUE;
5600 }
5601 else /* package */
5602 {
5603 package pa=IDPACKAGE(pl);
5604 if ((pa->language==LANG_C)
5605 || (pa->language==LANG_MIX))
5606 {
5607 Werror("can not create package `%s` - binaries exists",plib);
5608 omFreeBinAddr(plib);
5609 return TRUE;
5610 }
5611 }
5612 omFreeBinAddr(plib);
5613 package savepack=currPack;
5614 currPack=IDPACKAGE(pl);
5615 IDPACKAGE(pl)->loaded=TRUE;
5616 char libnamebuf[1024];
5617 FILE * fp = feFopen( s, "r", libnamebuf, TRUE );
5618 BOOLEAN bo=iiLoadLIB(fp, libnamebuf, s, pl, autoexport, TRUE);
5619 currPack=savepack;
5620 IDPACKAGE(pl)->loaded=(!bo);
5621 return bo;
5622 }
5623 case LT_BUILTIN:
5624 SModulFunc_t iiGetBuiltinModInit(const char*);
5625 return load_builtin(s,autoexport, iiGetBuiltinModInit(s));
5626 case LT_MACH_O:
5627 case LT_ELF:
5628 case LT_HPUX:
5629#ifdef HAVE_DYNAMIC_LOADING
5630 return load_modules(s, libnamebuf, autoexport);
5631#else /* HAVE_DYNAMIC_LOADING */
5632 WerrorS("Dynamic modules are not supported by this version of Singular");
5633 break;
5634#endif /* HAVE_DYNAMIC_LOADING */
5635 }
5636 return TRUE;
5637}
5639static void WerrorS_dummy(const char *)
5640{
5642}
5644{
5645 if (!iiGetLibStatus(s))
5646 {
5647 void (*WerrorS_save)(const char *s) = WerrorS_callback;
5650 BOOLEAN bo=jjLOAD(s,TRUE);
5651 if (TEST_OPT_PROT && (bo || (WerrorS_dummy_cnt>0)))
5652 Print("loading of >%s< failed\n",s);
5653 WerrorS_callback=WerrorS_save;
5654 errorreported=0;
5655 }
5656 return FALSE;
5657}
5658
5660{
5661 res->data = (char *)strlen((char *)v->Data());
5662 return FALSE;
5663}
5665{
5666 res->data = (char *)(long)pLength((poly)v->Data());
5667 return FALSE;
5668}
5670{
5671 res->data = (char *)(long)idElem((ideal)v->Data());
5672 return FALSE;
5673}
5675{
5676 res->data = (char *)id_FreeModule((int)(long)v->Data(), currRing);
5677 return FALSE;
5678}
5680{
5681 res->data = (char *)id_Vec2Ideal((poly)v->Data(), currRing);
5682 return FALSE;
5683}
5685{
5686 res->data = rCharStr((ring)v->Data());
5687 return FALSE;
5688}
5690{
5691 res->data = (char *)pHead((poly)v->Data());
5692 return FALSE;
5693}
5695{
5696 res->data = (char *)id_Head((ideal)v->Data(),currRing);
5698 return FALSE;
5699}
5701{
5702 res->data = (char *)idMinBase((ideal)v->Data());
5703 return FALSE;
5704}
5705#if 0 // unused
5706static BOOLEAN jjsyMinBase(leftv res, leftv v)
5707{
5708 res->data = (char *)syMinBase((ideal)v->Data());
5709 return FALSE;
5710}
5711#endif
5713{
5714 res->data = (char *)pMaxComp((poly)v->Data());
5715 return FALSE;
5716}
5718{
5719 res->data = (char *)mp_Trace((matrix)v->Data(),currRing);
5720 return FALSE;
5721}
5723{
5724 res->data = (char *)mp_Transp((matrix)v->Data(),currRing);
5725 return FALSE;
5726}
5728{
5729 res->data = rOrdStr((ring)v->Data());
5730 return FALSE;
5731}
5733{
5734 res->data = rVarStr((ring)v->Data());
5735 return FALSE;
5736}
5738{
5739 res->data = rParStr((ring)v->Data());
5740 return FALSE;
5741}
5743{
5744 res->data=(char *)(long)sySize((syStrategy)v->Data());
5745 return FALSE;
5746}
5748{
5749 res->data = (char *)(long)syDim((syStrategy)v->Data());
5750 return FALSE;
5751}
5753{
5754 res->data = (char *)id_Transp((ideal)v->Data(),currRing);
5755 return FALSE;
5756}
5758{
5759 number n=(number)u->CopyD(); // n_Int may call n_Normalize
5760 res->data=(char *)(long)iin_Int(n,currRing->cf);
5761 n_Delete(&n,currRing->cf);
5762 return FALSE;
5763}
5765{
5766 number n=(number)u->Data();
5767 res->data=(char *)(long)iin_Int(n,coeffs_BIGINT );
5768 return FALSE;
5769}
5770/*=================== operations with 3 args.: static proc =================*/
5771/* must be ordered: first operations for chars (infix ops),
5772 * then alphabetically */
5774{
5775 char *s= (char *)u->Data();
5776 int r = (int)(long)v->Data();
5777 int c = (int)(long)w->Data();
5778 int l = strlen(s);
5779
5780 if ( (r<1) || (r>l) || (c<0) )
5781 {
5782 Werror("wrong range[%d,%d] in string %s",r,c,u->Fullname());
5783 return TRUE;
5784 }
5785 res->data = (char *)omAlloc((long)(c+1));
5786 snprintf((char *)res->data,c+1,"%-*.*s",c,c,s+r-1);
5787 return FALSE;
5788}
5790{
5791 intvec *iv = (intvec *)u->Data();
5792 int r = (int)(long)v->Data();
5793 int c = (int)(long)w->Data();
5794 if ((r<1)||(r>iv->rows())||(c<1)||(c>iv->cols()))
5795 {
5796 Werror("wrong range[%d,%d] in intmat %s(%d x %d)",
5797 r,c,u->Fullname(),iv->rows(),iv->cols());
5798 return TRUE;
5799 }
5800 res->data=u->data; u->data=NULL;
5801 res->rtyp=u->rtyp; u->rtyp=0;
5802 res->name=u->name; u->name=NULL;
5803 Subexpr e=jjMakeSub(v);
5804 e->next=jjMakeSub(w);
5805 if (u->e==NULL) res->e=e;
5806 else
5807 {
5808 Subexpr h=u->e;
5809 while (h->next!=NULL) h=h->next;
5810 h->next=e;
5811 res->e=u->e;
5812 u->e=NULL;
5813 }
5814 return FALSE;
5815}
5817{
5818 bigintmat *bim = (bigintmat *)u->Data();
5819 int r = (int)(long)v->Data();
5820 int c = (int)(long)w->Data();
5821 if ((r<1)||(r>bim->rows())||(c<1)||(c>bim->cols()))
5822 {
5823 Werror("wrong range[%d,%d] in bigintmat %s(%d x %d)",
5824 r,c,u->Fullname(),bim->rows(),bim->cols());
5825 return TRUE;
5826 }
5827 res->data=u->data; u->data=NULL;
5828 res->rtyp=u->rtyp; u->rtyp=0;
5829 res->name=u->name; u->name=NULL;
5830 Subexpr e=jjMakeSub(v);
5831 e->next=jjMakeSub(w);
5832 if (u->e==NULL)
5833 res->e=e;
5834 else
5835 {
5836 Subexpr h=u->e;
5837 while (h->next!=NULL) h=h->next;
5838 h->next=e;
5839 res->e=u->e;
5840 u->e=NULL;
5841 }
5842 return FALSE;
5843}
5845{
5846 matrix m= (matrix)u->Data();
5847 int r = (int)(long)v->Data();
5848 int c = (int)(long)w->Data();
5849 //Print("gen. elem %d, %d\n",r,c);
5850 if ((r<1)||(r>MATROWS(m))||(c<1)||(c>MATCOLS(m)))
5851 {
5852 Werror("wrong range[%d,%d] in matrix %s(%d x %d)",r,c,u->Fullname(),
5853 MATROWS(m),MATCOLS(m));
5854 return TRUE;
5855 }
5856 res->data=u->data; u->data=NULL;
5857 res->rtyp=u->rtyp; u->rtyp=0;
5858 res->name=u->name; u->name=NULL;
5859 Subexpr e=jjMakeSub(v);
5860 e->next=jjMakeSub(w);
5861 if (u->e==NULL)
5862 res->e=e;
5863 else
5864 {
5865 Subexpr h=u->e;
5866 while (h->next!=NULL) h=h->next;
5867 h->next=e;
5868 res->e=u->e;
5869 u->e=NULL;
5870 }
5871 return FALSE;
5872}
5874{
5875 ideal m= (ideal)u->Data();
5876 int r = (int)(long)v->Data();
5877 int c = (int)(long)w->Data();
5878 //Print("gen. elem %d, %d\n",r,c);
5879 if ((r<1)||(r>m->rank)||(c<1)||(c>IDELEMS(m)))
5880 {
5881 Werror("wrong range[%d,%d] in matrix %s(%d x %d)",r,c,u->Fullname(),
5882 (int)m->rank,IDELEMS(m));
5883 return TRUE;
5884 }
5885 res->data=u->data; u->data=NULL;
5886 res->rtyp=u->rtyp; u->rtyp=0;
5887 res->name=u->name; u->name=NULL;
5888 Subexpr e=jjMakeSub(v);
5889 e->next=jjMakeSub(w);
5890 if (u->e==NULL)
5891 res->e=e;
5892 else
5893 {
5894 Subexpr h=u->e;
5895 while (h->next!=NULL) h=h->next;
5896 h->next=e;
5897 res->e=u->e;
5898 u->e=NULL;
5899 }
5900 return FALSE;
5901}
5903{
5904 if ((u->rtyp!=IDHDL)||(u->e!=NULL))
5905 {
5906 WerrorS("cannot build expression lists from unnamed objects");
5907 return TRUE;
5908 }
5909
5910 leftv p=NULL;
5911 intvec *iv=(intvec *)w->Data();
5912 int l;
5913 BOOLEAN nok;
5914 sleftv ut;
5915 memcpy(&ut,u,sizeof(ut));
5916 sleftv t;
5917 t.Init();
5918 t.rtyp=INT_CMD;
5919 for (l=0;l< iv->length(); l++)
5920 {
5921 t.data=(char *)(long)((*iv)[l]);
5922 if (p==NULL)
5923 {
5924 p=res;
5925 }
5926 else
5927 {
5928 p->next=(leftv)omAlloc0Bin(sleftv_bin);
5929 p=p->next;
5930 }
5931 memcpy(u,&ut,sizeof(ut));
5932 if (u->Typ() == MATRIX_CMD)
5933 nok=jjBRACK_Ma(p,u,v,&t);
5934 else if (u->Typ() == BIGINTMAT_CMD)
5935 nok=jjBRACK_Bim(p,u,v,&t);
5936 else /* INTMAT_CMD */
5937 nok=jjBRACK_Im(p,u,v,&t);
5938 if (nok)
5939 {
5940 while (res->next!=NULL)
5941 {
5942 p=res->next->next;
5944 // res->e aufraeumen !!!!
5945 res->next=p;
5946 }
5947 return TRUE;
5948 }
5949 }
5950 return FALSE;
5951}
5953{
5954 if ((u->rtyp!=IDHDL)||(u->e!=NULL))
5955 {
5956 WerrorS("cannot build expression lists from unnamed objects");
5957 return TRUE;
5958 }
5959 leftv p=NULL;
5960 intvec *iv=(intvec *)v->Data();
5961 int l;
5962 BOOLEAN nok;
5963 sleftv ut;
5964 memcpy(&ut,u,sizeof(ut));
5965 sleftv t;
5966 t.Init();
5967 t.rtyp=INT_CMD;
5968 for (l=0;l< iv->length(); l++)
5969 {
5970 t.data=(char *)(long)((*iv)[l]);
5971 if (p==NULL)
5972 {
5973 p=res;
5974 }
5975 else
5976 {
5977 p->next=(leftv)omAlloc0Bin(sleftv_bin);
5978 p=p->next;
5979 }
5980 memcpy(u,&ut,sizeof(ut));
5981 if (u->Typ() == MATRIX_CMD)
5982 nok=jjBRACK_Ma(p,u,&t,w);
5983 else if (u->Typ() == BIGINTMAT_CMD)
5984 nok=jjBRACK_Bim(p,u,&t,w);
5985 else /* INTMAT_CMD */
5986 nok=jjBRACK_Im(p,u,&t,w);
5987 if (nok)
5988 {
5989 while (res->next!=NULL)
5990 {
5991 p=res->next->next;
5993 // res->e aufraeumen !!
5994 res->next=p;
5995 }
5996 return TRUE;
5997 }
5998 }
5999 return FALSE;
6000}
6002{
6003 if ((u->rtyp!=IDHDL)||(u->e!=NULL))
6004 {
6005 WerrorS("cannot build expression lists from unnamed objects");
6006 return TRUE;
6007 }
6008 leftv p=NULL;
6009 intvec *vv=(intvec *)v->Data();
6010 intvec *wv=(intvec *)w->Data();
6011 int vl;
6012 int wl;
6013 BOOLEAN nok;
6014
6015 sleftv t1,t2,ut;
6016 memcpy(&ut,u,sizeof(ut));
6017 t1.Init();
6018 t1.rtyp=INT_CMD;
6019 t2.Init();
6020 t2.rtyp=INT_CMD;
6021 for (vl=0;vl< vv->length(); vl++)
6022 {
6023 t1.data=(char *)(long)((*vv)[vl]);
6024 for (wl=0;wl< wv->length(); wl++)
6025 {
6026 t2.data=(char *)(long)((*wv)[wl]);
6027 if (p==NULL)
6028 {
6029 p=res;
6030 }
6031 else
6032 {
6033 p->next=(leftv)omAlloc0Bin(sleftv_bin);
6034 p=p->next;
6035 }
6036 memcpy(u,&ut,sizeof(ut));
6037 if (u->Typ() == MATRIX_CMD)
6038 nok=jjBRACK_Ma(p,u,&t1,&t2);
6039 else if (u->Typ() == BIGINTMAT_CMD)
6040 nok=jjBRACK_Bim(p,u,&t1,&t2);
6041 else /* INTMAT_CMD */
6042 nok=jjBRACK_Im(p,u,&t1,&t2);
6043 if (nok)
6044 {
6045 res->CleanUp();
6046 return TRUE;
6047 }
6048 }
6049 }
6050 return FALSE;
6051}
6053{
6054 v->next=(leftv)omAllocBin(sleftv_bin);
6055 memcpy(v->next,w,sizeof(sleftv));
6056 w->Init();
6057 return jjPROC(res,u,v);
6058}
6060{
6061 u->next=(leftv)omAlloc(sizeof(sleftv));
6062 memcpy(u->next,v,sizeof(sleftv));
6063 v->Init();
6064 u->next->next=(leftv)omAlloc(sizeof(sleftv));
6065 memcpy(u->next->next,w,sizeof(sleftv));
6066 w->Init();
6067 BOOLEAN bo=iiExprArithM(res,u,'[');
6068 u->next=NULL;
6069 return bo;
6070}
6072{
6073 intvec *iv;
6074 ideal m;
6076 int k=(int)(long)w->Data();
6077 if (k>=0)
6078 {
6079 sm_CallBareiss((ideal)u->Data(),(int)(long)v->Data(),(int)(long)w->Data(),m,&iv, currRing);
6080 l->Init(2);
6081 l->m[0].rtyp=MODUL_CMD;
6082 l->m[1].rtyp=INTVEC_CMD;
6083 l->m[0].data=(void *)m;
6084 l->m[1].data=(void *)iv;
6085 }
6086 else
6087 {
6088 m=sm_CallSolv((ideal)u->Data(), currRing);
6089 l->Init(1);
6090 l->m[0].rtyp=IDEAL_CMD;
6091 l->m[0].data=(void *)m;
6092 }
6093 res->data = (char *)l;
6094 return FALSE;
6095}
6097{
6098 if ((w->rtyp!=IDHDL)||(w->e!=NULL))
6099 {
6100 WerrorS("3rd argument must be a name of a matrix");
6101 return TRUE;
6102 }
6103 ideal i=(ideal)u->Data();
6104 int rank=(int)i->rank;
6105 BOOLEAN r=jjCOEFFS_Id(res,u,v);
6106 if (r) return TRUE;
6107 mp_Monomials((matrix)res->data, rank, pVar((poly)v->Data()),(matrix)w->Data(),currRing);
6108 return FALSE;
6109}
6111{
6112 res->data=(void*)idCoeffOfKBase((ideal)(u->Data()),
6113 (ideal)(v->Data()),(poly)(w->Data()));
6114 return FALSE;
6115}
6117{
6118 if ((w->rtyp!=IDHDL)||(w->e!=NULL))
6119 {
6120 WerrorS("3rd argument must be a name of a matrix");
6121 return TRUE;
6122 }
6123 // CopyD for POLY_CMD and VECTOR_CMD are identical:
6124 poly p=(poly)u->CopyD(POLY_CMD);
6125 ideal i=idInit(1,1);
6126 i->m[0]=p;
6127 sleftv t;
6128 t.Init();
6129 t.data=(char *)i;
6130 t.rtyp=IDEAL_CMD;
6131 int rank=1;
6132 if (u->Typ()==VECTOR_CMD)
6133 {
6134 i->rank=rank=pMaxComp(p);
6135 t.rtyp=MODUL_CMD;
6136 }
6137 BOOLEAN r=jjCOEFFS_Id(res,&t,v);
6138 t.CleanUp();
6139 if (r) return TRUE;
6140 mp_Monomials((matrix)res->data, rank, pVar((poly)v->Data()),(matrix)w->Data(),currRing);
6141 return FALSE;
6142}
6144{
6145 ideal I=(ideal)u->Data();
6146 GbVariant alg=syGetAlgorithm((char*)w->Data(),currRing,I);
6147 res->data=(char *)idElimination(I,(poly)v->Data(),NULL,alg);
6148 //setFlag(res,FLAG_STD);
6149 return v->next!=NULL; //do not allow next like in eliminate(I,a(1..4))
6150}
6152{
6153 bigintmat *ww=(bigintmat*)w->Data();
6154
6155 res->data=(char *)idElimination2((ideal)u->Data(),(poly)v->Data(),
6156 ww);
6157 //setFlag(res,FLAG_STD);
6158 return FALSE;
6159}
6161{
6162 /*4
6163 * look for the substring what in the string where
6164 * starting at position n
6165 * return the position of the first char of what in where
6166 * or 0
6167 */
6168 int n=(int)(long)w->Data();
6169 char *where=(char *)u->Data();
6170 char *what=(char *)v->Data();
6171 char *found;
6172 if ((1>n)||(n>(int)strlen(where)))
6173 {
6174 Werror("start position %d out of range",n);
6175 return TRUE;
6176 }
6177 found = strchr(where+n-1,*what);
6178 if (*(what+1)!='\0')
6179 {
6180 while((found !=NULL) && (strncmp(found+1,what+1,strlen(what+1))!=0))
6181 {
6182 found=strchr(found+1,*what);
6183 }
6184 }
6185 if (found != NULL)
6186 {
6187 res->data=(char *)((found-where)+1);
6188 }
6189 return FALSE;
6190}
6192{
6193 if ((int)(long)w->Data()==0)
6194 res->data=(char *)walkProc(u,v);
6195 else
6196 res->data=(char *)fractalWalkProc(u,v);
6197 setFlag( res, FLAG_STD );
6198 return FALSE;
6199}
6201{
6202 intvec *wdegree=(intvec*)w->Data();
6203 if (wdegree->length()!=currRing->N)
6204 {
6205 Werror("weight vector must have size %d, not %d",
6206 currRing->N,wdegree->length());
6207 return TRUE;
6208 }
6209 if (rField_is_Z(currRing))
6210 {
6211 PrintS("// NOTE: computation of Hilbert series etc. is being\n");
6212 PrintS("// performed for generic fibre, that is, over Q\n");
6213 }
6214 assumeStdFlag(u);
6215 intvec *module_w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
6216 if (errorreported) return TRUE;
6217
6218 switch((int)(long)v->Data())
6219 {
6220 case 1:
6221 res->data=(void *)hFirstSeries0b((ideal)u->Data(),currRing->qideal,wdegree,module_w,currRing,coeffs_BIGINT);
6222 return FALSE;
6223 case 2:
6224 res->data=(void *)hSecondSeries0b((ideal)u->Data(),currRing->qideal,wdegree,module_w,currRing,coeffs_BIGINT);
6225 return FALSE;
6226 }
6228 return TRUE;
6229}
6231{
6232 if (rField_is_Z(currRing))
6233 {
6234 PrintS("// NOTE: computation of Hilbert series etc. is being\n");
6235 PrintS("// performed for generic fibre, that is, over Q\n");
6236 }
6237 assumeStdFlag(u);
6238 ring Qt =(ring)v->Data();
6239 char *name=(char*)w->Data();
6240 poly h;
6241 if (u->Typ()==IDEAL_CMD)
6242 h=hFirstSeries0p((ideal)u->Data(),currRing->qideal,NULL,currRing,Qt);
6243 else
6244 {
6245 intvec *module_w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
6246 h=hFirstSeries0m((ideal)u->Data(),currRing->qideal,NULL,module_w,currRing,Qt);
6247 }
6248 idhdl hh=enterid(name,myynest,POLY_CMD,&(Qt->idroot),FALSE,FALSE);
6249 IDPOLY(hh)=h;
6250 return FALSE;
6251}
6253{
6254 PrintS("TODO\n");
6255 int i=pVar((poly)v->Data());
6256 if (i==0)
6257 {
6258 WerrorS("ringvar expected");
6259 return TRUE;
6260 }
6261 poly p=pOne(); pSetExp(p,i,1); pSetm(p);
6262 int d=pWTotaldegree(p);
6263 pLmDelete(p);
6264 if (d==1)
6265 res->data = (char *)id_Homogen((ideal)u->Data(), i, currRing);
6266 else
6267 WerrorS("variable must have weight 1");
6268 return (d!=1);
6269}
6271{
6272 PrintS("TODO\n");
6273 int i=pVar((poly)v->Data());
6274 if (i==0)
6275 {
6276 WerrorS("ringvar expected");
6277 return TRUE;
6278 }
6279 poly p=pOne(); pSetExp(p,i,1); pSetm(p);
6280 int d=pWTotaldegree(p);
6281 pLmDelete(p);
6282 if (d==1)
6283 res->data = (char *)p_Homogen((poly)u->Data(), i, currRing);
6284 else
6285 WerrorS("variable must have weight 1");
6286 return (d!=1);
6287}
6289{
6290 intvec *w=(intvec *)v3->Data();
6291 intvec *vw=(intvec*)v2->Data();
6292 ideal v_id=(ideal)v1->Data();
6293 res->data=(void *)(long)id_HomModuleW(v_id,currRing->qideal,vw,w,currRing);
6294 return FALSE;
6295}
6297{
6298 intvec* im= new intvec((int)(long)v->Data(),(int)(long)w->Data(), 0);
6299 intvec* arg = (intvec*) u->Data();
6300 int i, n = si_min(im->cols()*im->rows(), arg->cols()*arg->rows());
6301
6302 for (i=0; i<n; i++)
6303 {
6304 (*im)[i] = (*arg)[i];
6305 }
6306
6307 res->data = (char *)im;
6308 return FALSE;
6309}
6311{
6312 ideal I1=(ideal)u->Data();
6313 ideal I2=(ideal)v->Data();
6314 ideal I3=(ideal)w->Data();
6315 resolvente r=(resolvente)omAlloc0(3*sizeof(ideal));
6316 r[0]=I1;
6317 r[1]=I2;
6318 r[2]=I3;
6319 res->data=(char *)idMultSect(r,3);
6320 omFreeSize((ADDRESS)r,3*sizeof(ideal));
6321 return FALSE;
6322}
6324{
6325 ideal I=(ideal)u->Data();
6326 GbVariant alg=syGetAlgorithm((char*)w->Data(),currRing,I);
6327 res->data=(char *)idSect(I,(ideal)v->Data(),alg);
6329 return FALSE;
6330}
6332{
6333 int *iw=iv2array((intvec *)w->Data(),currRing);
6334 res->data = (char *)ppJetW((poly)u->Data(),(int)(long)v->Data(),iw);
6335 omFreeSize( (ADDRESS)iw, (rVar(currRing)+1)*sizeof(int) );
6336 return FALSE;
6337}
6339{
6340 if (!pIsUnit((poly)v->Data()))
6341 {
6342 WerrorS("2nd argument must be a unit");
6343 return TRUE;
6344 }
6345 res->data = (char *)p_Series((int)(long)w->Data(),(poly)u->CopyD(),(poly)v->CopyD(),NULL,currRing);
6346 return FALSE;
6347}
6349{
6350 res->data = (char *)id_JetW((ideal)u->Data(),(int)(long)v->Data(),
6351 (intvec *)w->Data(),currRing);
6352 return FALSE;
6353}
6355{
6356 if (!mp_IsDiagUnit((matrix)v->Data(), currRing))
6357 {
6358 WerrorS("2nd argument must be a diagonal matrix of units");
6359 return TRUE;
6360 }
6361 res->data = (char *)idSeries((int)(long)w->Data(),(ideal)u->CopyD(),
6362 (matrix)v->CopyD());
6363 return FALSE;
6364}
6366{
6367 /* Here's the use pattern for the minor command:
6368 minor ( matrix_expression m, int_expression minorSize,
6369 optional ideal_expression IasSB, optional int_expression k,
6370 optional string_expression algorithm,
6371 optional int_expression cachedMinors,
6372 optional int_expression cachedMonomials )
6373 This method here assumes that there are at least two arguments.
6374 - If IasSB is present, it must be a std basis. All minors will be
6375 reduced w.r.t. IasSB.
6376 - If k is absent, all non-zero minors will be computed.
6377 If k is present and k > 0, the first k non-zero minors will be
6378 computed.
6379 If k is present and k < 0, the first |k| minors (some of which
6380 may be zero) will be computed.
6381 If k is present and k = 0, an error is reported.
6382 - If algorithm is absent, all the following arguments must be absent too.
6383 In this case, a heuristic picks the best-suited algorithm (among
6384 Bareiss, Laplace, and Laplace with caching).
6385 If algorithm is present, it must be one of "Bareiss", "bareiss",
6386 "Laplace", "laplace", "Cache", "cache". In the cases "Cache" and
6387 "cache" two more arguments may be given, determining how many entries
6388 the cache may have at most, and how many cached monomials there are at
6389 most. (Cached monomials are counted over all cached polynomials.)
6390 If these two additional arguments are not provided, 200 and 100000
6391 will be used as defaults.
6392 */
6393 matrix m;
6394 leftv u=v->next;
6395 v->next=NULL;
6396 int v_typ=v->Typ();
6397 if (v_typ==MATRIX_CMD)
6398 {
6399 m = (matrix)v->Data();
6400 }
6401 else
6402 {
6403 if (v_typ==0)
6404 {
6405 Werror("`%s` is undefined",v->Fullname());
6406 return TRUE;
6407 }
6408 // try to convert to MATRIX:
6409 int ii=iiTestConvert(v_typ,MATRIX_CMD);
6410 BOOLEAN bo;
6411 sleftv tmp;
6412 if (ii>0) bo=iiConvert(v_typ,MATRIX_CMD,ii,v,&tmp);
6413 else bo=TRUE;
6414 if (bo)
6415 {
6416 Werror("cannot convert %s to matrix",Tok2Cmdname(v_typ));
6417 return TRUE;
6418 }
6419 m=(matrix)tmp.data;
6420 }
6421 const int mk = (int)(long)u->Data();
6422 bool noIdeal = true; bool noK = true; bool noAlgorithm = true;
6423 bool noCacheMinors = true; bool noCacheMonomials = true;
6424 ideal IasSB; int k; char* algorithm; int cacheMinors; int cacheMonomials;
6425
6426 /* here come the different cases of correct argument sets */
6427 if ((u->next != NULL) && (u->next->Typ() == IDEAL_CMD))
6428 {
6429 IasSB = (ideal)u->next->Data();
6430 noIdeal = false;
6431 if ((u->next->next != NULL) && (u->next->next->Typ() == INT_CMD))
6432 {
6433 k = (int)(long)u->next->next->Data();
6434 noK = false;
6435 if ((u->next->next->next != NULL) &&
6436 (u->next->next->next->Typ() == STRING_CMD))
6437 {
6438 algorithm = (char*)u->next->next->next->Data();
6439 noAlgorithm = false;
6440 if ((u->next->next->next->next != NULL) &&
6441 (u->next->next->next->next->Typ() == INT_CMD))
6442 {
6443 cacheMinors = (int)(long)u->next->next->next->next->Data();
6444 noCacheMinors = false;
6445 if ((u->next->next->next->next->next != NULL) &&
6446 (u->next->next->next->next->next->Typ() == INT_CMD))
6447 {
6448 cacheMonomials =
6449 (int)(long)u->next->next->next->next->next->Data();
6450 noCacheMonomials = false;
6451 }
6452 }
6453 }
6454 }
6455 }
6456 else if ((u->next != NULL) && (u->next->Typ() == INT_CMD))
6457 {
6458 k = (int)(long)u->next->Data();
6459 noK = false;
6460 if ((u->next->next != NULL) && (u->next->next->Typ() == STRING_CMD))
6461 {
6462 algorithm = (char*)u->next->next->Data();
6463 noAlgorithm = false;
6464 if ((u->next->next->next != NULL) &&
6465 (u->next->next->next->Typ() == INT_CMD))
6466 {
6467 cacheMinors = (int)(long)u->next->next->next->Data();
6468 noCacheMinors = false;
6469 if ((u->next->next->next->next != NULL) &&
6470 (u->next->next->next->next->Typ() == INT_CMD))
6471 {
6472 cacheMonomials = (int)(long)u->next->next->next->next->Data();
6473 noCacheMonomials = false;
6474 }
6475 }
6476 }
6477 }
6478 else if ((u->next != NULL) && (u->next->Typ() == STRING_CMD))
6479 {
6480 algorithm = (char*)u->next->Data();
6481 noAlgorithm = false;
6482 if ((u->next->next != NULL) && (u->next->next->Typ() == INT_CMD))
6483 {
6484 cacheMinors = (int)(long)u->next->next->Data();
6485 noCacheMinors = false;
6486 if ((u->next->next->next != NULL) &&
6487 (u->next->next->next->Typ() == INT_CMD))
6488 {
6489 cacheMonomials = (int)(long)u->next->next->next->Data();
6490 noCacheMonomials = false;
6491 }
6492 }
6493 }
6494
6495 /* upper case conversion for the algorithm if present */
6496 if (!noAlgorithm)
6497 {
6498 if (strcmp(algorithm, "bareiss") == 0)
6499 algorithm = (char*)"Bareiss";
6500 if (strcmp(algorithm, "laplace") == 0)
6501 algorithm = (char*)"Laplace";
6502 if (strcmp(algorithm, "cache") == 0)
6503 algorithm = (char*)"Cache";
6504 }
6505
6506 v->next=u;
6507 /* here come some tests */
6508 if (!noIdeal)
6509 {
6510 assumeStdFlag(u->next);
6511 }
6512 if ((!noK) && (k == 0))
6513 {
6514 WerrorS("Provided number of minors to be computed is zero.");
6515 return TRUE;
6516 }
6517 if ((!noAlgorithm) && (strcmp(algorithm, "Bareiss") != 0)
6518 && (strcmp(algorithm, "Laplace") != 0)
6519 && (strcmp(algorithm, "Cache") != 0))
6520 {
6521 WerrorS("Expected as algorithm one of 'B/bareiss', 'L/laplace', or 'C/cache'.");
6522 return TRUE;
6523 }
6524 if ((!noAlgorithm) && (strcmp(algorithm, "Bareiss") == 0)
6526 {
6527 Werror("Bareiss algorithm not defined over coefficient rings %s",
6528 "with zero divisors.");
6529 return TRUE;
6530 }
6531 if ((mk < 1) || (mk > m->rows()) || (mk > m->cols()))
6532 {
6533 ideal I=idInit(1,1);
6534 if (mk<1) I->m[0]=p_One(currRing);
6535 //Werror("invalid size of minors: %d (matrix is (%d x %d))", mk,
6536 // m->rows(), m->cols());
6537 res->data=(void*)I;
6538 return FALSE;
6539 }
6540 if ((!noAlgorithm) && (strcmp(algorithm, "Cache") == 0)
6541 && (noCacheMinors || noCacheMonomials))
6542 {
6543 cacheMinors = 200;
6544 cacheMonomials = 100000;
6545 }
6546
6547 /* here come the actual procedure calls */
6548 if (noAlgorithm)
6549 res->data = getMinorIdealHeuristic(m, mk, (noK ? 0 : k),
6550 (noIdeal ? 0 : IasSB), false);
6551 else if (strcmp(algorithm, "Cache") == 0)
6552 res->data = getMinorIdealCache(m, mk, (noK ? 0 : k),
6553 (noIdeal ? 0 : IasSB), 3, cacheMinors,
6554 cacheMonomials, false);
6555 else
6556 res->data = getMinorIdeal(m, mk, (noK ? 0 : k), algorithm,
6557 (noIdeal ? 0 : IasSB), false);
6558 if (v_typ!=MATRIX_CMD) idDelete((ideal *)&m);
6559 return FALSE;
6560}
6562{
6563 if ((ma->rtyp!=IDHDL)||(ma->e!=NULL))
6564 {
6565 WerrorS("3rd argument must have a name");
6566 return TRUE;
6567 }
6568 int maxl=(int)(long)v->Data();
6569 if (maxl<0)
6570 {
6571 WerrorS("length for res must not be negative");
6572 return TRUE;
6573 }
6574 syStrategy r;
6575 intvec *weights=NULL;
6576 int wmaxl=maxl;
6577 ideal u_id=(ideal)u->Data();
6578
6579 maxl--;
6580 if (/*(*/ maxl==-1 /*)*/)
6581 {
6582 maxl = currRing->N-1+2;
6583 if (currRing->qideal!=NULL)
6584 {
6585 Warn(
6586 "full resolution in a qring may be infinite, setting max length to %d",
6587 maxl+1);
6588 }
6589 }
6590 weights=(intvec*)atGet(u,"isHomog",INTVEC_CMD);
6591 if (weights!=NULL)
6592 {
6593 if (!idTestHomModule(u_id,currRing->qideal,weights))
6594 {
6595 WarnS("wrong weights given:");weights->show();PrintLn();
6596 weights=NULL;
6597 }
6598 }
6599 intvec *ww=NULL;
6600 int add_row_shift=0;
6601 if (weights!=NULL)
6602 {
6603 ww=ivCopy(weights);
6604 add_row_shift = ww->min_in();
6605 (*ww) -= add_row_shift;
6606 }
6607 unsigned save_opt=si_opt_1;
6609 u_id=(ideal)u->CopyD();
6610 ideal mat;
6611 r=syMres_with_map(u_id,maxl,ww,mat);
6612 idhdl h=(idhdl)ma->data;
6613 idDelete(&IDIDEAL(h));
6614 IDIDEAL(h)=mat;
6615 if (r->list_length>wmaxl)
6616 {
6617 for(int i=wmaxl-1;i>=r->list_length;i--)
6618 {
6619 if (r->fullres[i]!=NULL) id_Delete(&r->fullres[i],currRing);
6620 if (r->minres[i]!=NULL) id_Delete(&r->minres[i],currRing);
6621 }
6622 }
6623 r->list_length=wmaxl;
6624 res->data=(void *)r;
6625 if ((weights!=NULL) && (ww!=NULL)) { delete ww; ww=NULL; }
6626 if ((r->weights!=NULL) && (r->weights[0]!=NULL))
6627 {
6628 ww=ivCopy(r->weights[0]);
6629 if (weights!=NULL) (*ww) += add_row_shift;
6630 atSet(res,omStrDup("isHomog"),ww,INTVEC_CMD);
6631 }
6632 else
6633 {
6634 if (weights!=NULL)
6635 {
6636 atSet(res,omStrDup("isHomog"),ivCopy(weights),INTVEC_CMD);
6637 }
6638 }
6639 assume( (r->syRing != NULL) == (r->resPairs != NULL) );
6640 assume( (r->minres != NULL) || (r->fullres != NULL) );
6641 si_opt_1=save_opt;
6642 return FALSE;
6643}
6645{
6646 // u: the name of the new type
6647 // v: the parent type
6648 // w: the elements
6649 newstruct_desc d=newstructChildFromString((const char *)v->Data(),
6650 (const char *)w->Data());
6651 if (d!=NULL) newstruct_setup((const char *)u->Data(),d);
6652 return (d==NULL);
6653}
6655{
6656 // handles preimage(r,phi,i) and kernel(r,phi)
6657 idhdl h;
6658 ring rr;
6659 map mapping;
6660 BOOLEAN kernel_cmd= (iiOp==KERNEL_CMD);
6661
6662 if ((v->name==NULL) || (!kernel_cmd && (w->name==NULL)))
6663 {
6664 WerrorS("2nd/3rd arguments must have names");
6665 return TRUE;
6666 }
6667 rr=(ring)u->Data();
6668 const char *ring_name=u->Name();
6669 if ((h=rr->idroot->get(v->name,myynest))!=NULL)
6670 {
6671 if (h->typ==MAP_CMD)
6672 {
6673 mapping=IDMAP(h);
6674 idhdl preim_ring=IDROOT->get(mapping->preimage,myynest);
6675 if ((preim_ring==NULL)
6676 || (IDRING(preim_ring)!=currRing))
6677 {
6678 Werror("preimage ring `%s` is not the basering",mapping->preimage);
6679 return TRUE;
6680 }
6681 }
6682 else if (h->typ==IDEAL_CMD)
6683 {
6684 mapping=IDMAP(h);
6685 }
6686 else
6687 {
6688 Werror("`%s` is no map nor ideal",IDID(h));
6689 return TRUE;
6690 }
6691 }
6692 else
6693 {
6694 Werror("`%s` is not defined in `%s`",v->name,ring_name);
6695 return TRUE;
6696 }
6697 ideal image;
6698 if (kernel_cmd) image=idInit(1,1);
6699 else
6700 {
6701 if ((h=rr->idroot->get(w->name,myynest))!=NULL)
6702 {
6703 if (h->typ==IDEAL_CMD)
6704 {
6705 image=IDIDEAL(h);
6706 }
6707 else
6708 {
6709 Werror("`%s` is no ideal",IDID(h));
6710 return TRUE;
6711 }
6712 }
6713 else
6714 {
6715 Werror("`%s` is not defined in `%s`",w->name,ring_name);
6716 return TRUE;
6717 }
6718 }
6719 if (((currRing->qideal!=NULL) && (rHasLocalOrMixedOrdering(currRing)))
6720 || ((rr->qideal!=NULL) && (rHasLocalOrMixedOrdering(rr))))
6721 {
6722 WarnS("preimage in local qring may be wrong: use Ring::preimageLoc instead");
6723 }
6724 res->data=(char *)maGetPreimage(rr,mapping,image,currRing);
6725 if (kernel_cmd) idDelete(&image);
6726 return (res->data==NULL/* is of type ideal, should not be NULL*/);
6727}
6729{
6730 int di, k;
6731 int i=(int)(long)u->Data();
6732 int r=(int)(long)v->Data();
6733 int c=(int)(long)w->Data();
6734 if ((r<=0) || (c<=0)) return TRUE;
6735 intvec *iv = new intvec(r, c, 0);
6736 if (iv->rows()==0)
6737 {
6738 delete iv;
6739 return TRUE;
6740 }
6741 if (i!=0)
6742 {
6743 if (i<0) i = -i;
6744 di = 2 * i + 1;
6745 for (k=0; k<iv->length(); k++)
6746 {
6747 (*iv)[k] = ((siRand() % di) - i);
6748 }
6749 }
6750 res->data = (char *)iv;
6751 return FALSE;
6752}
6753#ifdef SINGULAR_4_2
6754static BOOLEAN jjRANDOM_CF(leftv res, leftv u, leftv v, leftv w)
6755// <coeff>, par1, par2 -> number2
6756{
6757 coeffs cf=(coeffs)u->Data();
6758 if ((cf==NULL) ||(cf->cfRandom==NULL))
6759 {
6760 Werror("no random function defined for coeff %d",cf->type);
6761 return TRUE;
6762 }
6763 else
6764 {
6765 number n= n_Random(siRand,(number)v->Data(),(number)w->Data(),cf);
6766 number2 nn=(number2)omAlloc(sizeof(*nn));
6767 nn->cf=cf;
6768 nn->n=n;
6769 res->data=nn;
6770 return FALSE;
6771 }
6772 return TRUE;
6773}
6774#endif
6776 int &ringvar, poly &monomexpr)
6777{
6778 monomexpr=(poly)w->Data();
6779 poly p=(poly)v->Data();
6780#if 0
6781 if (pLength(monomexpr)>1)
6782 {
6783 Werror("`%s` substitutes a ringvar only by a term",
6785 return TRUE;
6786 }
6787#endif
6788 if ((ringvar=pVar(p))==0)
6789 {
6790 if ((p!=NULL) && (currRing->cf->extRing!=NULL))
6791 {
6792 number n = pGetCoeff(p);
6793 ringvar= -n_IsParam(n, currRing);
6794 }
6795 if(ringvar==0)
6796 {
6797 WerrorS("ringvar/par expected");
6798 return TRUE;
6799 }
6800 }
6801 return FALSE;
6802}
6804{
6805 // generic conversion from polyBucket to poly:
6806 // force this to be the first try everytime
6807 poly p; int l;
6808 sBucket_pt bu=(sBucket_pt)w->CopyD();
6809 sBucketDestroyAdd(bu,&p,&l);
6810 sleftv tmpw;
6811 tmpw.Init();
6812 tmpw.rtyp=POLY_CMD;
6813 tmpw.data=p;
6814 return iiExprArith3(res, iiOp, u, v, &tmpw);
6815}
6817{
6818 int ringvar;
6819 poly monomexpr;
6820 BOOLEAN nok=jjSUBST_Test(v,w,ringvar,monomexpr);
6821 if (nok) return TRUE;
6822 poly p=(poly)u->Data();
6823 if (ringvar>0)
6824 {
6825 int mm=p_MaxExpPerVar(p,ringvar,currRing);
6826 if (!rIsLPRing(currRing) &&
6827 (monomexpr!=NULL) && (p!=NULL) && (mm!=0) &&
6828 ((unsigned long)pTotaldegree(monomexpr) > (currRing->bitmask / (unsigned long)mm/2)))
6829 {
6830 Warn("possible OVERFLOW in subst, max exponent is %ld, substituting deg %d by deg %d",currRing->bitmask/2, pTotaldegree(monomexpr), mm);
6831 //return TRUE;
6832 }
6833 if ((monomexpr==NULL)||(pNext(monomexpr)==NULL))
6834 res->data = pSubst((poly)u->CopyD(res->rtyp),ringvar,monomexpr);
6835 else
6836 res->data= pSubstPoly(p,ringvar,monomexpr);
6837 }
6838 else
6839 {
6840 if (rIsLPRing(currRing))
6841 {
6842 WerrorS("Substituting parameters not implemented for Letterplace rings.");
6843 return TRUE;
6844 }
6845 res->data=pSubstPar(p,-ringvar,monomexpr);
6846 }
6847 return FALSE;
6848}
6850{
6851 int ringvar;
6852 poly monomexpr;
6853 BOOLEAN nok=jjSUBST_Test(v,w,ringvar,monomexpr);
6854 if (nok) return TRUE;
6855 ideal id=(ideal)u->Data();
6856 if (ringvar>0)
6857 {
6858 BOOLEAN overflow=FALSE;
6859 if (!rIsLPRing(currRing) && (monomexpr!=NULL))
6860 {
6861 long deg_monexp=pTotaldegree(monomexpr);
6862 for(int i=IDELEMS(id)-1;i>=0;i--)
6863 {
6864 poly p=id->m[i];
6865 int mm=p_MaxExpPerVar(p,ringvar,currRing);
6866 if ((p!=NULL) && (mm!=0) &&
6867 ((unsigned long)deg_monexp > (currRing->bitmask / (unsigned long)mm/2)))
6868 {
6869 overflow=TRUE;
6870 break;
6871 }
6872 }
6873 }
6874 if (overflow)
6875 Warn("possible OVERFLOW in subst, max exponent is %ld",currRing->bitmask/2);
6876 if ((monomexpr==NULL)||(pNext(monomexpr)==NULL))
6877 {
6878 if (res->rtyp==MATRIX_CMD) id=(ideal)mp_Copy((matrix)id,currRing);
6879 else id=id_Copy(id,currRing);
6880 res->data = id_Subst(id, ringvar, monomexpr, currRing);
6881 }
6882 else
6883 res->data = idSubstPoly(id,ringvar,monomexpr);
6884 }
6885 else
6886 {
6887 if (rIsLPRing(currRing))
6888 {
6889 WerrorS("Substituting parameters not implemented for Letterplace rings.");
6890 return TRUE;
6891 }
6892 res->data = idSubstPar(id,-ringvar,monomexpr);
6893 }
6894 return FALSE;
6895}
6896// we do not want to have jjSUBST_Id_X inlined:
6898 int input_type);
6900{
6901 return jjSUBST_Id_X(res,u,v,w,INT_CMD);
6902}
6904{
6905 return jjSUBST_Id_X(res,u,v,w,NUMBER_CMD);
6906}
6907static BOOLEAN jjSUBST_Id_X(leftv res, leftv u, leftv v,leftv w, int input_type)
6908{
6909 sleftv tmp;
6910 tmp.Init();
6911 // do not check the result, conversion from int/number to poly works always
6912 iiConvert(input_type,POLY_CMD,iiTestConvert(input_type,POLY_CMD),w,&tmp);
6913 BOOLEAN b=jjSUBST_Id(res,u,v,&tmp);
6914 tmp.CleanUp();
6915 return b;
6916}
6918{
6919 int mi=(int)(long)v->Data();
6920 int ni=(int)(long)w->Data();
6921 if ((mi<1)||(ni<1))
6922 {
6923 Werror("converting ideal to matrix: dimensions must be positive(%dx%d)",mi,ni);
6924 return TRUE;
6925 }
6926 matrix m=mpNew(mi,ni);
6927 ideal I=(ideal)u->CopyD(IDEAL_CMD);
6928 int i=si_min(IDELEMS(I),mi*ni);
6929 //for(i=i-1;i>=0;i--)
6930 //{
6931 // m->m[i]=I->m[i];
6932 // I->m[i]=NULL;
6933 //}
6934 memcpy(m->m,I->m,i*sizeof(poly));
6935 memset(I->m,0,i*sizeof(poly));
6936 id_Delete(&I,currRing);
6937 res->data = (char *)m;
6938 return FALSE;
6939}
6941{
6942 int mi=(int)(long)v->Data();
6943 int ni=(int)(long)w->Data();
6944 if ((mi<0)||(ni<1))
6945 {
6946 Werror("converting module to matrix: dimensions must be positive(%dx%d)",mi,ni);
6947 return TRUE;
6948 }
6949 res->data = (char *)id_Module2formatedMatrix((ideal)u->CopyD(MODUL_CMD),
6950 mi,ni,currRing);
6951 return FALSE;
6952}
6954{
6955 int mi=(int)(long)v->Data();
6956 int ni=(int)(long)w->Data();
6957 if ((mi<1)||(ni<1))
6958 {
6959 Werror("converting matrix to matrix: dimensions must be positive(%dx%d)",mi,ni);
6960 return TRUE;
6961 }
6962 matrix m=mpNew(mi,ni);
6964 int r=si_min(MATROWS(I),mi);
6965 int c=si_min(MATCOLS(I),ni);
6966 int i,j;
6967 for(i=r;i>0;i--)
6968 {
6969 for(j=c;j>0;j--)
6970 {
6971 MATELEM(m,i,j)=MATELEM(I,i,j);
6972 MATELEM(I,i,j)=NULL;
6973 }
6974 }
6975 id_Delete((ideal *)&I,currRing);
6976 res->data = (char *)m;
6977 return FALSE;
6978}
6980{
6981 if (w->rtyp!=IDHDL) return TRUE; /* idhdhl required */
6982 intvec *w_u=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
6983 tHomog hom=testHomog;
6984 if (w_u!=NULL)
6985 {
6986 w_u=ivCopy(w_u);
6987 hom=isHomog;
6988 }
6989 intvec *w_v=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
6990 if (w_v!=NULL)
6991 {
6992 w_v=ivCopy(w_v);
6993 hom=isHomog;
6994 }
6995 if ((w_u!=NULL) && (w_v==NULL))
6996 w_v=ivCopy(w_u);
6997 if ((w_v!=NULL) && (w_u==NULL))
6998 w_u=ivCopy(w_v);
6999 ideal u_id=(ideal)u->Data();
7000 ideal v_id=(ideal)v->Data();
7001 if (w_u!=NULL)
7002 {
7003 if ((*w_u).compare((w_v))!=0)
7004 {
7005 WarnS("incompatible weights");
7006 delete w_u; w_u=NULL;
7007 hom=testHomog;
7008 }
7009 else
7010 {
7011 if ((!idTestHomModule(u_id,currRing->qideal,w_v))
7012 || (!idTestHomModule(v_id,currRing->qideal,w_v)))
7013 {
7014 WarnS("wrong weights");
7015 delete w_u; w_u=NULL;
7016 hom=testHomog;
7017 }
7018 }
7019 }
7020 idhdl h=(idhdl)w->data;
7021 res->data = (char *)idModulo(u_id,v_id ,hom,&w_u, &(h->data.umatrix));
7022 if (w_u!=NULL)
7023 {
7024 atSet(res,omStrDup("isHomog"),w_u,INTVEC_CMD);
7025 }
7026 delete w_v;
7027 //if (TEST_OPT_RETURN_SB) setFlag(res,FLAG_STD);
7028 return FALSE;
7029}
7031{
7032 if (w->rtyp!=IDHDL) return TRUE; /* idhdhl required */
7033 intvec *w_u=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
7034 tHomog hom=testHomog;
7035 if (w_u!=NULL)
7036 {
7037 w_u=ivCopy(w_u);
7038 hom=isHomog;
7039 }
7040 intvec *w_v=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
7041 if (w_v!=NULL)
7042 {
7043 w_v=ivCopy(w_v);
7044 hom=isHomog;
7045 }
7046 if ((w_u!=NULL) && (w_v==NULL))
7047 w_v=ivCopy(w_u);
7048 if ((w_v!=NULL) && (w_u==NULL))
7049 w_u=ivCopy(w_v);
7050 ideal u_id=(ideal)u->Data();
7051 GbVariant alg=syGetAlgorithm((char*)w->Data(),currRing,u_id);
7052 ideal v_id=(ideal)v->Data();
7053 if (w_u!=NULL)
7054 {
7055 if ((*w_u).compare((w_v))!=0)
7056 {
7057 WarnS("incompatible weights");
7058 delete w_u; w_u=NULL;
7059 hom=testHomog;
7060 }
7061 else
7062 {
7063 if ((!idTestHomModule(u_id,currRing->qideal,w_v))
7064 || (!idTestHomModule(v_id,currRing->qideal,w_v)))
7065 {
7066 WarnS("wrong weights");
7067 delete w_u; w_u=NULL;
7068 hom=testHomog;
7069 }
7070 }
7071 }
7072 res->data = (char *)idModulo(u_id,v_id ,hom,&w_u, NULL,alg);
7073 if (w_u!=NULL)
7074 {
7075 atSet(res,omStrDup("isHomog"),w_u,INTVEC_CMD);
7076 }
7077 delete w_v;
7078 //if (TEST_OPT_RETURN_SB) setFlag(res,FLAG_STD);
7079 return FALSE;
7080}
7082{
7083 int mi=(int)(long)v->Data();
7084 int ni=(int)(long)w->Data();
7085 if ((mi<0)||(ni<1))
7086 {
7087 Werror("converting to smatrix: dimensions must be positive(%dx%d)",mi,ni);
7088 return TRUE;
7089 }
7090 res->data = (char *)id_ResizeModule((ideal)u->CopyD(),
7091 mi,ni,currRing);
7092 return FALSE;
7093}
7095{
7096 if (w->rtyp!=IDHDL) return TRUE;
7097 int ul= IDELEMS((ideal)u->Data());
7098 int vl= IDELEMS((ideal)v->Data());
7099#ifdef HAVE_SHIFTBBA
7100 if (rIsLPRing(currRing))
7101 {
7102 if (currRing->LPncGenCount < ul)
7103 {
7104 Werror("At least %d ncgen variables are needed for this computation.", ul);
7105 return TRUE;
7106 }
7107 }
7108#endif
7109 ideal m
7110 = idLift((ideal)u->Data(),(ideal)v->Data(),NULL,FALSE,hasFlag(u,FLAG_STD),
7111 FALSE, (matrix *)(&(IDMATRIX((idhdl)(w->data)))));
7112 if (m==NULL) return TRUE;
7113 res->data = (char *)id_Module2formatedMatrix(m,ul,vl,currRing);
7114 return FALSE;
7115}
7117{
7118 if ((v->rtyp!=IDHDL)||(v->e!=NULL)) return TRUE;
7119 if ((w->rtyp!=IDHDL)||(w->e!=NULL)) return TRUE;
7120 idhdl hv=(idhdl)v->data;
7121 idhdl hw=(idhdl)w->data;
7122#ifdef HAVE_SHIFTBBA
7123 if (rIsLPRing(currRing))
7124 {
7125 if (currRing->LPncGenCount < IDELEMS((ideal)u->Data()))
7126 {
7127 Werror("At least %d ncgen variables are needed for this computation.", IDELEMS((ideal)u->Data()));
7128 return TRUE;
7129 }
7130 }
7131#endif
7132 // CopyD for IDEAL_CMD and MODUL_CMD are identical:
7133 res->data = (char *)idLiftStd((ideal)u->Data(),
7134 &(hv->data.umatrix),testHomog,
7135 &(hw->data.uideal));
7136 setFlag(res,FLAG_STD); v->flag=0; w->flag=0;
7137 return FALSE;
7138}
7140{
7141 if ((v->rtyp!=IDHDL)||(v->e!=NULL)) return TRUE;
7142 idhdl hv=(idhdl)v->data;
7143 GbVariant alg=syGetAlgorithm((char*)w->Data(),currRing,(ideal)u->Data());
7144#ifdef HAVE_SHIFTBBA
7145 if (rIsLPRing(currRing))
7146 {
7147 if (currRing->LPncGenCount < IDELEMS((ideal)u->Data()))
7148 {
7149 Werror("At least %d ncgen variables are needed for this computation.", IDELEMS((ideal)u->Data()));
7150 return TRUE;
7151 }
7152 }
7153#endif
7154 // CopyD for IDEAL_CMD and MODUL_CMD are identical:
7155 res->data = (char *)idLiftStd((ideal)u->Data(),
7156 &(hv->data.umatrix),testHomog,
7157 NULL,alg);
7158 setFlag(res,FLAG_STD); v->flag=0;
7159 return FALSE;
7160}
7162{
7164 if (!idIsZeroDim((ideal)v->Data()))
7165 {
7166 Werror("`%s` must be 0-dimensional",v->Name());
7167 return TRUE;
7168 }
7169 res->data = (char *)redNF((ideal)v->CopyD(),(poly)u->CopyD(),
7170 (poly)w->CopyD());
7171 return FALSE;
7172}
7174{
7176 if (!idIsZeroDim((ideal)v->Data()))
7177 {
7178 Werror("`%s` must be 0-dimensional",v->Name());
7179 return TRUE;
7180 }
7181 res->data = (char *)redNF((ideal)v->CopyD(),(ideal)u->CopyD(),
7182 (matrix)w->CopyD());
7183 return FALSE;
7184}
7186{
7188 res->data = (char *)kNF((ideal)v->Data(),currRing->qideal,(poly)u->Data(),
7189 0,(int)(long)w->Data());
7190 return FALSE;
7191}
7193{
7195 res->data = (char *)kNF((ideal)v->Data(),currRing->qideal,(ideal)u->Data(),
7196 0,(int)(long)w->Data());
7197 return FALSE;
7198}
7199#ifdef OLD_RES
7201{
7202 int maxl=(int)v->Data();
7203 ideal u_id=(ideal)u->Data();
7204 int l=0;
7205 resolvente r;
7206 intvec **weights=NULL;
7207 int wmaxl=maxl;
7208 maxl--;
7209 unsigned save_opt=si_opt_1;
7211 if ((maxl==-1) && (iiOp!=MRES_CMD))
7212 maxl = currRing->N-1;
7213 if ((iiOp == RES_CMD) || (iiOp == MRES_CMD))
7214 {
7215 intvec * iv=(intvec*)atGet(u,"isHomog",INTVEC_CMD);
7216 if (iv!=NULL)
7217 {
7218 l=1;
7219 if (!idTestHomModule(u_id,currRing->qideal,iv))
7220 {
7221 WarnS("wrong weights");
7222 iv=NULL;
7223 }
7224 else
7225 {
7226 weights = (intvec**)omAlloc0Bin(char_ptr_bin);
7227 weights[0] = ivCopy(iv);
7228 }
7229 }
7230 r=syResolvente(u_id,maxl,&l, &weights, iiOp==MRES_CMD);
7231 }
7232 else
7233 r=sySchreyerResolvente((ideal)u->Data(),maxl+1,&l);
7234 if (r==NULL) return TRUE;
7235 int t3=u->Typ();
7236 iiMakeResolv(r,l,wmaxl,w->name,t3,weights);
7237 si_opt_1=save_opt;
7238 return FALSE;
7239}
7240#endif
7242{
7243 res->data=(void *)rInit(u,v,w);
7244 return (res->data==NULL);
7245}
7247{
7248 int yes;
7249 jjSTATUS2(res, u, v);
7250 yes = (strcmp((char *) res->data, (char *) w->Data()) == 0);
7251 omFreeBinAddr((ADDRESS) res->data);
7252 res->data = (void *)(long)yes;
7253 return FALSE;
7254}
7256{
7257 intvec *vw=(intvec *)w->Data(); // weights of vars
7258 if (vw->length()!=currRing->N)
7259 {
7260 Werror("%d weights for %d variables",vw->length(),currRing->N);
7261 return TRUE;
7262 }
7263 ideal result;
7264 intvec *ww=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
7265 tHomog hom=testHomog;
7266 ideal u_id=(ideal)(u->Data());
7267 if (ww!=NULL)
7268 {
7269 if (!idTestHomModule(u_id,currRing->qideal,ww))
7270 {
7271 WarnS("wrong weights");
7272 ww=NULL;
7273 }
7274 else
7275 {
7276 ww=ivCopy(ww);
7277 hom=isHomog;
7278 }
7279 }
7280 bigintmat *vv=(bigintmat*)v->Data();
7281 result=kStd2(u_id,
7282 currRing->qideal,
7283 hom,
7284 &ww, // module weights
7285 vv, // hilbert series
7286 0,0, // syzComp, newIdeal
7287 vw); // weights of vars
7289 res->data = (char *)result;
7291 if (ww!=NULL) atSet(res,omStrDup("isHomog"),ww,INTVEC_CMD);
7292 return FALSE;
7293}
7294
7295/*=================== operations with many arg.: static proc =================*/
7296/* must be ordered: first operations for chars (infix ops),
7297 * then alphabetically */
7299{
7300#ifdef HAVE_SDB
7301 sdb_show_bp();
7302#endif
7303 return FALSE;
7304}
7306{
7307#ifdef HAVE_SDB
7308 if(v->Typ()==PROC_CMD)
7309 {
7310 int lineno=0;
7311 if((v->next!=NULL) && (v->next->Typ()==INT_CMD))
7312 {
7313 lineno=(int)(long)v->next->Data();
7314 }
7315 return sdb_set_breakpoint(v->Name(),lineno);
7316 }
7317 return TRUE;
7318#else
7319 return FALSE;
7320#endif
7321}
7323{
7324 return iiExprArith1(res,v,iiOp);
7325}
7327{
7328 leftv v=u->next;
7329 u->next=NULL;
7330 BOOLEAN b=iiExprArith2(res,u,iiOp,v, (iiOp > 255));
7331 u->next=v;
7332 return b;
7333}
7335{
7336 leftv v = u->next;
7337 leftv w = v->next;
7338 u->next = NULL;
7339 v->next = NULL;
7340 BOOLEAN b = iiExprArith3(res, iiOp, u, v, w);
7341 u->next = v;
7342 v->next = w;
7343 return b;
7344}
7345
7347{
7348 const short t[]={4,VECTOR_CMD,POLY_CMD,MATRIX_CMD,MATRIX_CMD};
7349 if (iiCheckTypes(v,t,1))
7350 {
7351 idhdl c=(idhdl)v->next->next->data;
7352 if (v->next->next->next->rtyp!=IDHDL) return TRUE;
7353 idhdl m=(idhdl)v->next->next->next->data;
7354 idDelete((ideal *)&(c->data.uideal));
7355 idDelete((ideal *)&(m->data.uideal));
7356 mp_Coef2((poly)v->Data(),(poly)v->next->Data(),
7357 (matrix *)&(c->data.umatrix),(matrix *)&(m->data.umatrix),currRing);
7358 return FALSE;
7359 }
7360 return TRUE;
7361}
7362
7364{ // may have 3 or 4 arguments
7365 leftv v1=v;
7366 leftv v2=v1->next;
7367 leftv v3=v2->next;
7368 leftv v4=v3->next;
7369 assumeStdFlag(v2);
7370
7371 int i1=iiTestConvert(v1->Typ(),MODUL_CMD);
7372 int i2=iiTestConvert(v2->Typ(),MODUL_CMD);
7373
7374 if((i1==0)||(i2==0)
7375 ||(v3->Typ()!=INT_CMD)||((v4!=NULL)&&(v4->Typ()!=INTVEC_CMD)))
7376 {
7377 WarnS("<module>,<module>,<int>[,<intvec>] expected!");
7378 return TRUE;
7379 }
7380
7381 sleftv w1,w2;
7382 iiConvert(v1->Typ(),MODUL_CMD,i1,v1,&w1);
7383 iiConvert(v2->Typ(),MODUL_CMD,i2,v2,&w2);
7384 ideal P=(ideal)w1.Data();
7385 ideal Q=(ideal)w2.Data();
7386
7387 int n=(int)(long)v3->Data();
7388 int *w=NULL;
7389 if(v4!=NULL)
7390 {
7391 w = iv2array((intvec *)v4->Data(),currRing);
7392 int * w0 = w + 1;
7393 int i = currRing->N;
7394 while( (i > 0) && ((*w0) > 0) )
7395 {
7396 w0++;
7397 i--;
7398 }
7399 if(i>0)
7400 WarnS("not all weights are positive!");
7401 }
7402
7403 matrix T;
7404 ideal R;
7405 idLiftW(P,Q,n,T,R,w);
7406
7407 w1.CleanUp();
7408 w2.CleanUp();
7409 if(w!=NULL)
7410 omFreeSize( (ADDRESS)w, (rVar(currRing)+1)*sizeof(int) );
7411
7413 L->Init(2);
7414 L->m[1].rtyp=v1->Typ();
7415 if(v1->Typ()==POLY_CMD||v1->Typ()==VECTOR_CMD)
7416 {
7417 if(v1->Typ()==POLY_CMD)
7418 p_Shift(&R->m[0],-1,currRing);
7419 L->m[1].data=(void *)R->m[0];
7420 R->m[0]=NULL;
7421 idDelete(&R);
7422 }
7423 else if(v1->Typ()==IDEAL_CMD||v1->Typ()==MATRIX_CMD)
7424 L->m[1].data=(void *)id_Module2Matrix(R,currRing);
7425 else
7426 {
7427 L->m[1].rtyp=MODUL_CMD;
7428 L->m[1].data=(void *)R;
7429 }
7430 L->m[0].rtyp=MATRIX_CMD;
7431 L->m[0].data=(char *)T;
7432
7433 res->data=L;
7434
7435 return FALSE;
7436}
7437
7438//BOOLEAN jjDISPATCH(leftv res, leftv v)
7439//{
7440// WerrorS("`dispatch`: not implemented");
7441// return TRUE;
7442//}
7443
7444//static BOOLEAN jjEXPORTTO_M(leftv res, leftv u)
7445//{
7446// int l=u->listLength();
7447// if (l<2) return TRUE;
7448// BOOLEAN b;
7449// leftv v=u->next;
7450// leftv zz=v;
7451// leftv z=zz;
7452// u->next=NULL;
7453// do
7454// {
7455// leftv z=z->next;
7456// b=iiExprArith2(res,u,iiOp,z, (iiOp > 255));
7457// if (b) break;
7458// } while (z!=NULL);
7459// u->next=zz;
7460// return b;
7461//}
7463{
7464 leftv h=v;
7465 int s=exprlist_length(h);
7466 ideal id=idInit(s,1);
7467 int rank=1;
7468 int i=0;
7469 poly p;
7470 int dest_type=POLY_CMD;
7471 if (iiOp==MODUL_CMD) dest_type=VECTOR_CMD;
7472 while (h!=NULL)
7473 {
7474 // use standard type conversions to poly/vector
7475 int ri;
7476 int ht=h->Typ();
7477 if (ht==dest_type)
7478 {
7479 p=(poly)h->CopyD();
7480 if (p!=NULL) rank=si_max(rank,(int)pMaxComp(p));
7481 }
7482 else if ((ri=iiTestConvert(ht,dest_type,dConvertTypes))!=0)
7483 {
7484 sleftv tmp;
7485 leftv hnext=h->next;
7486 h->next=NULL;
7487 iiConvert(ht,dest_type,ri,h,&tmp,dConvertTypes);
7488 h->next=hnext;
7489 p=(poly)tmp.data;
7490 if (p!=NULL) rank=si_max(rank,(int)pMaxComp(p));
7491 }
7492 else
7493 {
7494 idDelete(&id);
7495 return TRUE;
7496 }
7497 id->m[i]=p;
7498 i++;
7499 h=h->next;
7500 }
7501 id->rank=rank;
7502 res->data=(char *)id;
7503 return FALSE;
7504}
7506{
7507 ring r=(ring)u->Data();
7508 leftv v=u->next;
7509 leftv perm_var_l=v->next;
7510 leftv perm_par_l=v->next->next;
7511 if ((perm_var_l->Typ()!=INTVEC_CMD)
7512 ||((perm_par_l!=NULL)&&(perm_par_l->Typ()!=INTVEC_CMD))
7513 ||(u->Typ()!=RING_CMD))
7514 {
7515 WerrorS("fetch(<ring>,<name>[,<intvec>[,<intvec>])");
7516 return TRUE;
7517 }
7518 intvec *perm_var_v=(intvec*)perm_var_l->Data();
7519 intvec *perm_par_v=NULL;
7520 if (perm_par_l!=NULL)
7521 perm_par_v=(intvec*)perm_par_l->Data();
7522 idhdl w;
7523 nMapFunc nMap;
7524
7525 if ((w=r->idroot->get(v->Name(),myynest))!=NULL)
7526 {
7527 int *perm=NULL;
7528 int *par_perm=NULL;
7529 int par_perm_size=0;
7530 BOOLEAN bo;
7531 if ((nMap=n_SetMap(r->cf,currRing->cf))==NULL)
7532 {
7533 // Allow imap/fetch to be make an exception only for:
7534 if (nCoeff_is_Extension(r->cf) && // Q(a..) -> Q(a..) || Q || Zp || Zp(a)
7535 ((n_SetMap(r->cf->extRing->cf,currRing->cf)!=NULL)
7536 || (nCoeff_is_Extension(currRing->cf) && (n_SetMap(r->cf->extRing->cf,currRing->cf->extRing->cf)!=NULL))))
7537 {
7538 par_perm_size=rPar(r);
7539 }
7540 else
7541 {
7542 goto err_fetch;
7543 }
7544 }
7545 else
7546 par_perm_size=rPar(r);
7547 perm=(int *)omAlloc0((rVar(r)+1)*sizeof(int));
7548 if (par_perm_size!=0)
7549 par_perm=(int *)omAlloc0(par_perm_size*sizeof(int));
7550 int i;
7551 if (perm_par_l==NULL)
7552 {
7553 if (par_perm_size!=0)
7554 for(i=si_min(rPar(r),rPar(currRing))-1;i>=0;i--) par_perm[i]=-(i+1);
7555 }
7556 else
7557 {
7558 if (par_perm_size==0) WarnS("source ring has no parameters");
7559 else
7560 {
7561 for(i=rPar(r)-1;i>=0;i--)
7562 {
7563 if (i<perm_par_v->length()) par_perm[i]=(*perm_par_v)[i];
7564 if ((par_perm[i]<-rPar(currRing))
7565 || (par_perm[i]>rVar(currRing)))
7566 {
7567 Warn("invalid entry for par %d: %d\n",i,par_perm[i]);
7568 par_perm[i]=0;
7569 }
7570 }
7571 }
7572 }
7573 for(i=rVar(r)-1;i>=0;i--)
7574 {
7575 if (i<perm_var_v->length()) perm[i+1]=(*perm_var_v)[i];
7576 if ((perm[i]<-rPar(currRing))
7577 || (perm[i]>rVar(currRing)))
7578 {
7579 Warn("invalid entry for var %d: %d\n",i,perm[i]);
7580 perm[i]=0;
7581 }
7582 }
7583 if (BVERBOSE(V_IMAP))
7584 {
7585 for(i=1;i<=si_min(rVar(r),rVar(currRing));i++)
7586 {
7587 if (perm[i]>0)
7588 Print("// var nr %d: %s -> var %s\n",i,r->names[i-1],currRing->names[perm[i]-1]);
7589 else if (perm[i]<0)
7590 Print("// var nr %d: %s -> par %s\n",i,r->names[i-1],rParameter(currRing)[-perm[i]-1]);
7591 }
7592 for(i=1;i<=si_min(rPar(r),rPar(currRing));i++) // possibly empty loop
7593 {
7594 if (par_perm[i-1]<0)
7595 Print("// par nr %d: %s -> par %s\n",
7596 i,rParameter(r)[i-1],rParameter(currRing)[-par_perm[i-1]-1]);
7597 else if (par_perm[i-1]>0)
7598 Print("// par nr %d: %s -> var %s\n",
7599 i,rParameter(r)[i-1],currRing->names[par_perm[i-1]-1]);
7600 }
7601 }
7602 if (IDTYP(w)==ALIAS_CMD) w=(idhdl)IDDATA(w);
7603 sleftv tmpW;
7604 tmpW.Init();
7605 tmpW.rtyp=IDTYP(w);
7606 tmpW.data=IDDATA(w);
7607 if ((bo=maApplyFetch(IMAP_CMD,NULL,res,&tmpW, r,
7608 perm,par_perm,par_perm_size,nMap)))
7609 {
7610 Werror("cannot map %s of type %s(%d)",v->name, Tok2Cmdname(w->typ),w->typ);
7611 }
7612 if (perm!=NULL)
7613 omFreeSize((ADDRESS)perm,(rVar(r)+1)*sizeof(int));
7614 if (par_perm!=NULL)
7615 omFreeSize((ADDRESS)par_perm,par_perm_size*sizeof(int));
7616 return bo;
7617 }
7618 else
7619 {
7620 Werror("identifier %s not found in %s",v->Fullname(),u->Fullname());
7621 }
7622 return TRUE;
7623err_fetch:
7624 char *s1=nCoeffString(r->cf);
7625 char *s2=nCoeffString(currRing->cf);
7626 Werror("no identity map from %s (%s -> %s)",u->Fullname(),s1,s2);
7628 return TRUE;
7629}
7631{
7632 leftv h=v;
7633 int l=v->listLength();
7634 resolvente r=(resolvente)omAlloc0(l*sizeof(ideal));
7635 BOOLEAN *copied=(BOOLEAN *)omAlloc0(l*sizeof(BOOLEAN));
7636 int t=0;
7637 // try to convert to IDEAL_CMD
7638 while (h!=NULL)
7639 {
7640 if (iiTestConvert(h->Typ(),IDEAL_CMD)!=0)
7641 {
7642 t=IDEAL_CMD;
7643 }
7644 else break;
7645 h=h->next;
7646 }
7647 // if failure, try MODUL_CMD
7648 if (t==0)
7649 {
7650 h=v;
7651 while (h!=NULL)
7652 {
7653 if (iiTestConvert(h->Typ(),MODUL_CMD)!=0)
7654 {
7655 t=MODUL_CMD;
7656 }
7657 else break;
7658 h=h->next;
7659 }
7660 }
7661 // check for success in converting
7662 if (t==0)
7663 {
7664 WerrorS("cannot convert to ideal or module");
7665 return TRUE;
7666 }
7667 // call idMultSect
7668 h=v;
7669 int i=0;
7670 sleftv tmp;
7671 while (h!=NULL)
7672 {
7673 if (h->Typ()==t)
7674 {
7675 r[i]=(ideal)h->Data(); /*no copy*/
7676 h=h->next;
7677 }
7678 else if(iiConvert(h->Typ(),t,iiTestConvert(h->Typ(),t),h,&tmp))
7679 {
7680 omFreeSize((ADDRESS)copied,l*sizeof(BOOLEAN));
7681 omFreeSize((ADDRESS)r,l*sizeof(ideal));
7682 Werror("cannot convert arg. %d to %s",i+1,Tok2Cmdname(t));
7683 return TRUE;
7684 }
7685 else
7686 {
7687 r[i]=(ideal)tmp.Data(); /*now it's a copy*/
7688 copied[i]=TRUE;
7689 h=tmp.next;
7690 }
7691 i++;
7692 }
7693 res->rtyp=t;
7694 res->data=(char *)idMultSect(r,i);
7695 while(i>0)
7696 {
7697 i--;
7698 if (copied[i]) idDelete(&(r[i]));
7699 }
7700 omFreeSize((ADDRESS)copied,l*sizeof(BOOLEAN));
7701 omFreeSize((ADDRESS)r,l*sizeof(ideal));
7702 return FALSE;
7703}
7705{
7706 /* computation of the inverse of a quadratic matrix A
7707 using the L-U-decomposition of A;
7708 There are two valid parametrisations:
7709 1) exactly one argument which is just the matrix A,
7710 2) exactly three arguments P, L, U which already
7711 realise the L-U-decomposition of A, that is,
7712 P * A = L * U, and P, L, and U satisfy the
7713 properties decribed in method 'jjLU_DECOMP';
7714 see there;
7715 If A is invertible, the list [1, A^(-1)] is returned,
7716 otherwise the list [0] is returned. Thus, the user may
7717 inspect the first entry of the returned list to see
7718 whether A is invertible. */
7719 matrix iMat; int invertible;
7720 const short t1[]={1,MATRIX_CMD};
7721 const short t2[]={3,MATRIX_CMD,MATRIX_CMD,MATRIX_CMD};
7722 if (iiCheckTypes(v,t1))
7723 {
7724 matrix aMat = (matrix)v->Data();
7725 int rr = aMat->rows();
7726 int cc = aMat->cols();
7727 if (rr != cc)
7728 {
7729 Werror("given matrix (%d x %d) is not quadratic, hence not invertible", rr, cc);
7730 return TRUE;
7731 }
7732 if (!idIsConstant((ideal)aMat))
7733 {
7734 WerrorS("matrix must be constant");
7735 return TRUE;
7736 }
7737 invertible = luInverse(aMat, iMat);
7738 }
7739 else if (iiCheckTypes(v,t2))
7740 {
7741 matrix pMat = (matrix)v->Data();
7742 matrix lMat = (matrix)v->next->Data();
7743 matrix uMat = (matrix)v->next->next->Data();
7744 int rr = uMat->rows();
7745 int cc = uMat->cols();
7746 if (rr != cc)
7747 {
7748 Werror("third matrix (%d x %d) is not quadratic, hence not invertible",
7749 rr, cc);
7750 return TRUE;
7751 }
7752 if (!idIsConstant((ideal)pMat)
7753 || (!idIsConstant((ideal)lMat))
7754 || (!idIsConstant((ideal)uMat))
7755 )
7756 {
7757 WerrorS("matricesx must be constant");
7758 return TRUE;
7759 }
7760 invertible = luInverseFromLUDecomp(pMat, lMat, uMat, iMat);
7761 }
7762 else
7763 {
7764 Werror("expected either one or three matrices");
7765 return TRUE;
7766 }
7767
7768 /* build the return structure; a list with either one or two entries */
7770 if (invertible)
7771 {
7772 ll->Init(2);
7773 ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)invertible;
7774 ll->m[1].rtyp=MATRIX_CMD; ll->m[1].data=(void *)iMat;
7775 }
7776 else
7777 {
7778 ll->Init(1);
7779 ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)invertible;
7780 }
7781
7782 res->data=(char*)ll;
7783 return FALSE;
7784}
7786{
7787 /* for solving a linear equation system A * x = b, via the
7788 given LU-decomposition of the matrix A;
7789 There is one valid parametrisation:
7790 1) exactly four arguments P, L, U, b;
7791 P, L, and U realise the L-U-decomposition of A, that is,
7792 P * A = L * U, and P, L, and U satisfy the
7793 properties decribed in method 'jjLU_DECOMP';
7794 see there;
7795 b is the right-hand side vector of the equation system;
7796 The method will return a list of either 1 entry or three entries:
7797 1) [0] if there is no solution to the system;
7798 2) [1, x, H] if there is at least one solution;
7799 x is any solution of the given linear system,
7800 H is the matrix with column vectors spanning the homogeneous
7801 solution space.
7802 The method produces an error if matrix and vector sizes do not fit. */
7803 const short t[]={4,MATRIX_CMD,MATRIX_CMD,MATRIX_CMD,MATRIX_CMD};
7804 if (!iiCheckTypes(v,t))
7805 {
7806 WerrorS("expected exactly three matrices and one vector as input");
7807 return TRUE;
7808 }
7809 matrix pMat = (matrix)v->Data();
7810 matrix lMat = (matrix)v->next->Data();
7811 matrix uMat = (matrix)v->next->next->Data();
7812 matrix bVec = (matrix)v->next->next->next->Data();
7813 matrix xVec; int solvable; matrix homogSolSpace;
7814 if (pMat->rows() != pMat->cols())
7815 {
7816 Werror("first matrix (%d x %d) is not quadratic",
7817 pMat->rows(), pMat->cols());
7818 return TRUE;
7819 }
7820 if (lMat->rows() != lMat->cols())
7821 {
7822 Werror("second matrix (%d x %d) is not quadratic",
7823 lMat->rows(), lMat->cols());
7824 return TRUE;
7825 }
7826 if (lMat->rows() != uMat->rows())
7827 {
7828 Werror("second matrix (%d x %d) and third matrix (%d x %d) do not fit",
7829 lMat->rows(), lMat->cols(), uMat->rows(), uMat->cols());
7830 return TRUE;
7831 }
7832 if (uMat->rows() != bVec->rows())
7833 {
7834 Werror("third matrix (%d x %d) and vector (%d x 1) do not fit",
7835 uMat->rows(), uMat->cols(), bVec->rows());
7836 return TRUE;
7837 }
7838 if (!idIsConstant((ideal)pMat)
7839 ||(!idIsConstant((ideal)lMat))
7840 ||(!idIsConstant((ideal)uMat))
7841 )
7842 {
7843 WerrorS("matrices must be constant");
7844 return TRUE;
7845 }
7846 solvable = luSolveViaLUDecomp(pMat, lMat, uMat, bVec, xVec, homogSolSpace);
7847
7848 /* build the return structure; a list with either one or three entries */
7850 if (solvable)
7851 {
7852 ll->Init(3);
7853 ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)solvable;
7854 ll->m[1].rtyp=MATRIX_CMD; ll->m[1].data=(void *)xVec;
7855 ll->m[2].rtyp=MATRIX_CMD; ll->m[2].data=(void *)homogSolSpace;
7856 }
7857 else
7858 {
7859 ll->Init(1);
7860 ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)solvable;
7861 }
7862
7863 res->data=(char*)ll;
7864 return FALSE;
7865}
7867{
7868 leftv h=v;
7869 int i=exprlist_length(h);
7870 intvec *iv=new intvec(i);
7871 i=0;
7872 while (h!=NULL)
7873 {
7874 if(h->Typ()==INT_CMD)
7875 {
7876 (*iv)[i]=(int)(long)h->Data();
7877 }
7878 else if (h->Typ()==INTVEC_CMD)
7879 {
7880 intvec *ivv=(intvec*)h->Data();
7881 for(int j=0;j<ivv->length();j++,i++)
7882 {
7883 (*iv)[i]=(*ivv)[j];
7884 }
7885 i--;
7886 }
7887 else
7888 {
7889 delete iv;
7890 return TRUE;
7891 }
7892 i++;
7893 h=h->next;
7894 }
7895 res->data=(char *)iv;
7896 return FALSE;
7897}
7899{
7900 leftv h=v;
7901 int l=0;
7902 while (h!=NULL)
7903 {
7904 if(h->Typ()==INT_CMD) l++;
7905 else if (h->Typ()==BIGINT_CMD) l++;
7906 else if (h->Typ()==INTVEC_CMD)
7907 {
7908 intvec *ivv=(intvec*)h->Data();
7909 l+=ivv->rows();
7910 }
7911 else if (h->Typ()==BIGINTVEC_CMD)
7912 {
7913 bigintmat *ivv=(bigintmat *)h->Data();
7914 l+=ivv->rows();
7915 }
7916 else return TRUE;
7917 h=h->next;
7918 }
7919 bigintmat *bim=new bigintmat(1,l,coeffs_BIGINT);
7920 h=v;
7921 int i=0;
7922 while (h!=NULL)
7923 {
7924 if(h->Typ()==INT_CMD)
7925 {
7926 number tp = n_Init((long)(h->Data()), coeffs_BIGINT);
7927 bim->set(i++, tp);
7928 n_Delete(&tp, coeffs_BIGINT);
7929 }
7930 else if (h->Typ()==INTVEC_CMD)
7931 {
7932 intvec *ivv=(intvec*)h->Data();
7933 for(int j=0;j<ivv->length();j++)
7934 {
7935 number tp = n_Init((long)(*ivv)[j], coeffs_BIGINT);
7936 bim->set(i++, tp);
7937 n_Delete(&tp, coeffs_BIGINT);
7938 }
7939 }
7940 else if(h->Typ()==BIGINT_CMD)
7941 {
7942 number tp = (number)h->Data();
7943 bim->set(i++, tp);
7944 }
7945 else if(h->Typ()==BIGINTVEC_CMD)
7946 {
7947 bigintmat *b=(bigintmat*)h->Data();
7948 for(int j=0;j<b->cols();j++)
7949 {
7950 number tp=BIMATELEM((*b),1,j);
7951 bim->set(i++, tp);
7952 }
7953 }
7954 h=h->next;
7955 }
7956 res->data=(char *)bim;
7957 return FALSE;
7958}
7960{
7961 const short t1[]={4,POLY_CMD,POLY_CMD,POLY_CMD,INTVEC_CMD};
7962 const short t2[]={4,VECTOR_CMD,POLY_CMD,POLY_CMD,INTVEC_CMD};
7963 const short t3[]={4,IDEAL_CMD,MATRIX_CMD,INT_CMD,INTVEC_CMD};
7964 const short t4[]={4,MODUL_CMD,MATRIX_CMD,INT_CMD,INTVEC_CMD};
7965 leftv u1=u;
7966 leftv u2=u1->next;
7967 leftv u3=u2->next;
7968 leftv u4=u3->next;
7969 if (iiCheckTypes(u,t1)||iiCheckTypes(u,t2))
7970 {
7971 if(!pIsUnit((poly)u2->Data()))
7972 {
7973 WerrorS("2nd argument must be a unit");
7974 return TRUE;
7975 }
7976 res->rtyp=u1->Typ();
7977 res->data=(char*)pSeries((int)(long)u3->Data(),pCopy((poly)u1->Data()),
7978 pCopy((poly)u2->Data()),(intvec*)u4->Data());
7979 return FALSE;
7980 }
7981 else
7982 if (iiCheckTypes(u,t3)||iiCheckTypes(u,t4))
7983 {
7984 if(!mp_IsDiagUnit((matrix)u2->Data(), currRing))
7985 {
7986 WerrorS("2nd argument must be a diagonal matrix of units");
7987 return TRUE;
7988 }
7989 res->rtyp=u1->Typ();
7990 res->data=(char*)idSeries(
7991 (int)(long)u3->Data(),
7992 idCopy((ideal)u1->Data()),
7993 mp_Copy((matrix)u2->Data(), currRing),
7994 (intvec*)u4->Data()
7995 );
7996 return FALSE;
7997 }
7998 else
7999 {
8000 Werror("%s(`poly`,`poly`,`int`,`intvec`) exppected",
8001 Tok2Cmdname(iiOp));
8002 return TRUE;
8003 }
8004}
8005#if 0
8006static BOOLEAN jjBRACKET_PL(leftv res, leftv u)
8007{
8008 int ut=u->Typ();
8009 leftv v=u->next; u->next=NULL;
8010 leftv w=v->next; v->next=NULL;
8011 if ((ut!=CRING_CMD)&&(ut!=RING_CMD))
8012 {
8013 BOOLEAN bo=TRUE;
8014 if (w==NULL)
8015 {
8016 bo=iiExprArith2(res,u,'[',v);
8017 }
8018 else if (w->next==NULL)
8019 {
8020 bo=iiExprArith3(res,'[',u,v,w);
8021 }
8022 v->next=w;
8023 u->next=v;
8024 return bo;
8025 }
8026 v->next=w;
8027 u->next=v;
8028 #ifdef SINGULAR_4_1
8029 // construct new rings:
8030 while (u!=NULL)
8031 {
8032 Print("name: %s,\n",u->Name());
8033 u=u->next;
8034 }
8035 #else
8036 res->Init();
8037 res->rtyp=NONE;
8038 return TRUE;
8039 #endif
8040}
8041#endif
8043{
8045 && ((strcmp(u->Name(),"real")==0) || (strcmp(u->Name(),"complex")==0)))
8046 {
8047 memcpy(res,u,sizeof(sleftv));
8048 u->Init();
8049 return FALSE;
8050 }
8051 leftv v=u->next;
8052 BOOLEAN b;
8053 if(v==NULL) // p()
8055 else if ((v->next==NULL) // p(1)
8056 || (u->Typ()!=UNKNOWN)) // p(1,2), p proc or map
8057 {
8058 u->next=NULL;
8059 b=iiExprArith2(res,u,iiOp,v);
8060 u->next=v;
8061 }
8062 else // p(1,2), p undefined
8063 {
8064 if (v->Typ()!=INT_CMD)
8065 {
8066 Werror("`%s` undefined or `int` expected while building `%s(`",u->name,u->name);
8067 return TRUE;
8068 }
8069 int l=u->listLength();
8070 size_t len=strlen(u->name) + 12*l;
8071 char * nn = (char *)omAlloc(len);
8072 snprintf(nn,len,"%s(%d",u->name,(int)(long)v->Data());
8073 char *s=nn;
8074 do
8075 {
8076 while (*s!='\0') s++;
8077 v=v->next;
8078 if (v->Typ()!=INT_CMD)
8079 {
8080 Werror("`%s` undefined or `int` expected while building `%s(`",u->name,u->name);
8081 omFree((ADDRESS)nn);
8082 return TRUE;
8083 }
8084 snprintf(s,len-(nn-s),",%d",(int)(long)v->Data());
8085 } while (v->next!=NULL);
8086 while (*s!='\0') s++;
8087 nn=strcat(nn,")");
8088 char *n=omStrDup(nn);
8089 omFree((ADDRESS)nn);
8090 syMake(res,n);
8091 b=FALSE;
8092 }
8093 return b;
8094}
8096{
8097 const short t1[]={4,IDEAL_CMD,IDEAL_CMD,MATRIX_CMD,STRING_CMD};
8098 const short t2[]={4,MODUL_CMD,MODUL_CMD,MATRIX_CMD,STRING_CMD};
8099 leftv u=U;
8100 leftv v=u->next;
8101 leftv w=v->next;
8102 leftv u4=w->next;
8103 if (w->rtyp!=IDHDL) return TRUE;
8104 if (iiCheckTypes(U,t1)||iiCheckTypes(U,t2))
8105 {
8106 // see jjLIFT3
8107 ideal I=(ideal)u->Data();
8108 int ul= IDELEMS(I /*(ideal)u->Data()*/);
8109 int vl= IDELEMS((ideal)v->Data());
8110 GbVariant alg=syGetAlgorithm((char*)u4->Data(),currRing,I);
8111 ideal m
8112 = idLift(I,(ideal)v->Data(),NULL,FALSE,hasFlag(u,FLAG_STD),
8113 FALSE, (matrix *)(&(IDMATRIX((idhdl)(w->data)))),alg);
8114 if (m==NULL) return TRUE;
8115 res->data = (char *)id_Module2formatedMatrix(m,ul,vl,currRing);
8116 return FALSE;
8117 }
8118 else
8119 {
8120 Werror("%s(`ideal`,`ideal`,`matrix`,`string`)\n"
8121 "or (`module`,`module`,`matrix`,`string`) expected",
8122 Tok2Cmdname(iiOp));
8123 return TRUE;
8124 }
8125}
8127{
8128 // we have 4 or 5 arguments
8129 leftv u=U;
8130 leftv v=u->next;
8131 leftv u3=v->next;
8132 leftv u4=u3->next;
8133 leftv u5=u4->next; // might be NULL
8134
8135 ideal *syz=NULL;
8136 GbVariant alg=GbDefault;
8137 ideal h11=NULL;
8138
8139 if(u5==NULL)
8140 {
8141 // test all three possibilities for 4 arguments
8142 const short t1[]={4,IDEAL_CMD,MATRIX_CMD,MODUL_CMD,STRING_CMD};
8143 const short t2[]={4,MODUL_CMD,MATRIX_CMD,MODUL_CMD,STRING_CMD};
8144 const short t3[]={4,IDEAL_CMD,MATRIX_CMD,MODUL_CMD,IDEAL_CMD};
8145 const short t4[]={4,MODUL_CMD,MATRIX_CMD,MODUL_CMD,MODUL_CMD};
8146 const short t5[]={4,IDEAL_CMD,MATRIX_CMD,STRING_CMD,IDEAL_CMD};
8147 const short t6[]={4,MODUL_CMD,MATRIX_CMD,STRING_CMD,MODUL_CMD};
8148
8149 if(iiCheckTypes(U,t1)||iiCheckTypes(U,t2))
8150 {
8151 if ((u3->rtyp!=IDHDL)||(u3->e!=NULL)) return TRUE;
8152 idhdl hw=(idhdl)u3->data;
8153 syz=&(hw->data.uideal);
8154 alg=syGetAlgorithm((char*)u4->Data(),currRing,(ideal)u->Data());
8155 }
8156 else if(iiCheckTypes(U,t3)||iiCheckTypes(U,t4))
8157 {
8158 if ((u3->rtyp!=IDHDL)||(u3->e!=NULL)) return TRUE;
8159 idhdl hw=(idhdl)u3->data;
8160 syz=&(hw->data.uideal);
8161 h11=(ideal)u4->Data();
8162 }
8163 else if(iiCheckTypes(U,t5)||iiCheckTypes(U,t6))
8164 {
8165 alg=syGetAlgorithm((char*)u3->Data(),currRing,(ideal)u->Data());
8166 h11=(ideal)u4->Data();
8167 }
8168 else
8169 {
8170 Werror("%s(`ideal/module`,`matrix`[,`module`][,`string`][,`ideal/module`]) expected",Tok2Cmdname(iiOp));
8171 return TRUE;
8172 }
8173 }
8174 else
8175 {
8176 // we have 5 arguments
8177 const short t1[]={5,IDEAL_CMD,MATRIX_CMD,MODUL_CMD,STRING_CMD,IDEAL_CMD};
8178 const short t2[]={5,MODUL_CMD,MATRIX_CMD,MODUL_CMD,STRING_CMD,MODUL_CMD};
8179 if(iiCheckTypes(U,t1)||iiCheckTypes(U,t2))
8180 {
8181 idhdl hw=(idhdl)u3->data;
8182 syz=&(hw->data.uideal);
8183 alg=syGetAlgorithm((char*)u4->Data(),currRing,(ideal)u->Data());
8184 h11=(ideal)u5->Data();
8185 }
8186 else
8187 {
8188 Werror("%s(`ideal/module`,`matrix`[,`module`][,`string`][,`ideal/module`]) expected",Tok2Cmdname(iiOp));
8189 return TRUE;
8190 }
8191 }
8192
8193#ifdef HAVE_SHIFTBBA
8194 if (rIsLPRing(currRing))
8195 {
8196 if (currRing->LPncGenCount < IDELEMS((ideal)u->Data()))
8197 {
8198 Werror("At least %d ncgen variables are needed for this computation.", IDELEMS((ideal)u->Data()));
8199 return TRUE;
8200 }
8201 }
8202#endif
8203
8204 if ((v->rtyp!=IDHDL)||(v->e!=NULL)) return TRUE;
8205 idhdl hv=(idhdl)v->data;
8206 // CopyD for IDEAL_CMD and MODUL_CMD are identical:
8207 res->rtyp = u->Typ();
8208 res->data = (char *)idLiftStd((ideal)u->Data(),
8209 &(hv->data.umatrix),testHomog,
8210 syz,alg,h11);
8211 setFlag(res,FLAG_STD); v->flag=0;
8212 if(syz!=NULL)
8213 u3->flag=0;
8214 return FALSE;
8215}
8217{
8218 int sl=0;
8219 if (v!=NULL) sl = v->listLength();
8220 lists L;
8221 if((sl==1)&&(v->Typ()==RESOLUTION_CMD))
8222 {
8223 int add_row_shift = 0;
8224 intvec *weights=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
8225 if (weights!=NULL) add_row_shift=weights->min_in();
8226 L=syConvRes((syStrategy)v->Data(),FALSE,add_row_shift);
8227 }
8228 else
8229 {
8231 leftv h=NULL;
8232 int i;
8233 int rt;
8234
8235 L->Init(sl);
8236 for (i=0;i<sl;i++)
8237 {
8238 if (h!=NULL)
8239 { /* e.g. not in the first step:
8240 * h is the pointer to the old sleftv,
8241 * v is the pointer to the next sleftv
8242 * (in this moment) */
8243 h->next=v;
8244 }
8245 h=v;
8246 v=v->next;
8247 h->next=NULL;
8248 rt=h->Typ();
8249 if (rt==0)
8250 {
8251 L->Clean();
8252 Werror("`%s` is undefined",h->Fullname());
8253 return TRUE;
8254 }
8255 if (rt==RING_CMD)
8256 {
8257 L->m[i].rtyp=rt;
8258 L->m[i].data=rIncRefCnt(((ring)h->Data()));
8259 }
8260 else
8261 L->m[i].Copy(h);
8262 }
8263 }
8264 res->data=(char *)L;
8265 return FALSE;
8266}
8268{
8269 leftv v=u->next;
8270 leftv w=v->next;
8271 leftv u4=w->next;
8272 GbVariant alg;
8273 ideal u_id,v_id;
8274 // we have 4 arguments
8275 const short t1[]={4,IDEAL_CMD,IDEAL_CMD,MATRIX_CMD,STRING_CMD};
8276 const short t2[]={4,MODUL_CMD,MODUL_CMD,MATRIX_CMD,STRING_CMD};
8277 if(iiCheckTypes(u,t1)||iiCheckTypes(u,t2)||(w->rtyp!=IDHDL))
8278 {
8279 u_id=(ideal)u->Data();
8280 v_id=(ideal)v->Data();
8281 alg=syGetAlgorithm((char*)u4->Data(),currRing,u_id);
8282 }
8283 else
8284 {
8285 Werror("%s(`ideal/module`,`ideal/module`[,`matrix`][,`string`]) expected",Tok2Cmdname(iiOp));
8286 return TRUE;
8287 }
8288 intvec *w_u=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
8289 tHomog hom=testHomog;
8290 if (w_u!=NULL)
8291 {
8292 w_u=ivCopy(w_u);
8293 hom=isHomog;
8294 }
8295 intvec *w_v=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
8296 if (w_v!=NULL)
8297 {
8298 w_v=ivCopy(w_v);
8299 hom=isHomog;
8300 }
8301 if ((w_u!=NULL) && (w_v==NULL))
8302 w_v=ivCopy(w_u);
8303 if ((w_v!=NULL) && (w_u==NULL))
8304 w_u=ivCopy(w_v);
8305 if (w_u!=NULL)
8306 {
8307 if ((*w_u).compare((w_v))!=0)
8308 {
8309 WarnS("incompatible weights");
8310 delete w_u; w_u=NULL;
8311 hom=testHomog;
8312 }
8313 else
8314 {
8315 if ((!idTestHomModule(u_id,currRing->qideal,w_v))
8316 || (!idTestHomModule(v_id,currRing->qideal,w_v)))
8317 {
8318 WarnS("wrong weights");
8319 delete w_u; w_u=NULL;
8320 hom=testHomog;
8321 }
8322 }
8323 }
8324 idhdl h=(idhdl)w->data;
8325 res->data = (char *)idModulo(u_id,v_id ,hom,&w_u, &(h->data.umatrix),alg);
8326 if (w_u!=NULL)
8327 {
8328 atSet(res,omStrDup("isHomog"),w_u,INTVEC_CMD);
8329 }
8330 delete w_v;
8331 //if (TEST_OPT_RETURN_SB) setFlag(res,FLAG_STD);
8332 return FALSE;
8333}
8335{
8336 res->data=(void *)ipNameList(IDROOT);
8337 return FALSE;
8338}
8340{
8341 if(v==NULL)
8342 {
8343 res->data=(char *)showOption();
8344 return FALSE;
8345 }
8346 res->rtyp=NONE;
8347 return setOption(res,v);
8348}
8350{
8351 leftv u1=u;
8352 leftv u2=u1->next;
8353 leftv u3=u2->next;
8354 leftv u4=u3->next;
8355 int u1t=u1->Typ(); if (u1t==BUCKET_CMD) u1t=POLY_CMD;
8356 int u2t=u2->Typ(); if (u2t==BUCKET_CMD) u2t=POLY_CMD;
8357 if((u3->Typ()==INT_CMD)&&(u4->Typ()==INTVEC_CMD))
8358 {
8359 int save_d=Kstd1_deg;
8360 Kstd1_deg=(int)(long)u3->Data();
8361 kModW=(intvec *)u4->Data();
8362 BITSET save2;
8363 SI_SAVE_OPT2(save2);
8365 u2->next=NULL;
8366 BOOLEAN r=jjCALL2ARG(res,u);
8367 kModW=NULL;
8368 Kstd1_deg=save_d;
8369 SI_RESTORE_OPT2(save2);
8370 u->next->next=u3;
8371 return r;
8372 }
8373 else
8374 if((u1t==IDEAL_CMD)&&(u2t==MATRIX_CMD)&&(u3->Typ()==IDEAL_CMD)&&
8375 (u4->Typ()==INT_CMD))
8376 {
8377 assumeStdFlag(u3);
8378 if(!mp_IsDiagUnit((matrix)u2->Data(), currRing))
8379 {
8380 WerrorS("2nd argument must be a diagonal matrix of units");
8381 return TRUE;
8382 }
8383 res->data=(char*)redNF(
8384 idCopy((ideal)u3->Data()),
8385 idCopy((ideal)u1->Data()),
8386 mp_Copy((matrix)u2->Data(), currRing),
8387 (int)(long)u4->Data()
8388 );
8389 return FALSE;
8390 }
8391 else
8392 if((u1t==POLY_CMD)&&(u2t==POLY_CMD)&&(u3->Typ()==IDEAL_CMD)&&
8393 (u4->Typ()==INT_CMD))
8394 {
8395 poly u1p;
8396 if (u1->Typ()==BUCKET_CMD) u1p=sBucketPeek((sBucket_pt)u1->Data());
8397 else u1p=(poly)u1->Data();
8398 poly u2p;
8399 if (u2->Typ()==BUCKET_CMD) u2p=sBucketPeek((sBucket_pt)u2->Data());
8400 else u2p=(poly)u2->Data();
8401 assumeStdFlag(u3);
8402 if(!pIsUnit(u2p))
8403 {
8404 WerrorS("2nd argument must be a unit");
8405 return TRUE;
8406 }
8407 res->rtyp=POLY_CMD;
8408 res->data=(char*)redNF((ideal)u3->CopyD(),pCopy(u1p),
8409 pCopy(u2p),(int)(long)u4->Data());
8410 return FALSE;
8411 }
8412 else
8413 {
8414 Werror("%s(`poly`,`ideal`,`int`,`intvec`) expected",Tok2Cmdname(iiOp));
8415 Werror("%s(`ideal`,`matrix`,`ideal`,`int`) expected",Tok2Cmdname(iiOp));
8416 Werror("%s(`poly`,`poly`,`ideal`,`int`) expected",Tok2Cmdname(iiOp));
8417 return TRUE;
8418 }
8419}
8421{
8422 leftv u1=u;
8423 leftv u2=u1->next;
8424 leftv u3=u2->next;
8425 leftv u4=u3->next;
8426 leftv u5=u4->next;
8427 if((u1->Typ()==IDEAL_CMD)&&(u2->Typ()==MATRIX_CMD)&&(u3->Typ()==IDEAL_CMD)&&
8428 (u4->Typ()==INT_CMD)&&(u5->Typ()==INTVEC_CMD))
8429 {
8430 assumeStdFlag(u3);
8431 if(!mp_IsDiagUnit((matrix)u2->Data(), currRing))
8432 {
8433 WerrorS("2nd argument must be a diagonal matrix of units");
8434 return TRUE;
8435 }
8436 res->data=(char*)redNF(
8437 idCopy((ideal)u3->Data()),
8438 idCopy((ideal)u1->Data()),
8439 mp_Copy((matrix)u2->Data(),currRing),
8440 (int)(long)u4->Data(),
8441 (intvec*)u5->Data()
8442 );
8443 return FALSE;
8444 }
8445 else
8446 if((u1->Typ()==POLY_CMD)&&(u2->Typ()==POLY_CMD)&&(u3->Typ()==IDEAL_CMD)&&
8447 (u4->Typ()==INT_CMD)&&(u5->Typ()==INTVEC_CMD))
8448 {
8449 assumeStdFlag(u3);
8450 if(!pIsUnit((poly)u2->Data()))
8451 {
8452 WerrorS("2nd argument must be a unit");
8453 return TRUE;
8454 }
8455 res->rtyp=POLY_CMD;
8456 res->data=(char*)redNF(idCopy((ideal)u3->Data()),pCopy((poly)u1->Data()),
8457 pCopy((poly)u2->Data()),
8458 (int)(long)u4->Data(),(intvec*)u5->Data());
8459 return FALSE;
8460 }
8461 else
8462 {
8463 Werror("%s(`ideal`,`ideal`,`matrix`,`int`,`intvec`) exppected",
8464 Tok2Cmdname(iiOp));
8465 return TRUE;
8466 }
8467}
8469{
8470 unsigned i=1;
8471 unsigned nCount = (sArithBase.nCmdUsed-1)/3;
8472 if((3*nCount)<sArithBase.nCmdUsed) nCount++;
8473 //Print("CMDS: %d/%d\n", sArithBase.nCmdUsed,
8474 // sArithBase.nCmdAllocated);
8475 for(i=0; i<nCount; i++)
8476 {
8477 Print("%-20s",sArithBase.sCmds[i+1].name);
8478 if(i+1+nCount<sArithBase.nCmdUsed)
8479 Print("%-20s",sArithBase.sCmds[i+1+nCount].name);
8480 if(i+1+2*nCount<sArithBase.nCmdUsed)
8481 Print("%-20s",sArithBase.sCmds[i+1+2*nCount].name);
8482 //if ((i%3)==1) PrintLn();
8483 PrintLn();
8484 }
8485 PrintLn();
8487 return FALSE;
8488}
8489
8491{
8492 int l = 0;
8493 int k = 0;
8495 struct blackbox_list *bb_list = NULL;
8496 unsigned nCount = (sArithBase.nCmdUsed-1) / 3;
8497
8498 if ((3*nCount) < sArithBase.nCmdUsed)
8499 {
8500 nCount++;
8501 }
8502 bb_list = getBlackboxTypes();
8503 // count the number of entries;
8504 for (unsigned i=0; i<nCount; i++)
8505 {
8506 l++;
8507 if (i + 1 + nCount < sArithBase.nCmdUsed)
8508 {
8509 l++;
8510 }
8511 if(i+1+2*nCount<sArithBase.nCmdUsed)
8512 {
8513 l++;
8514 }
8515 }
8516 for (int i = 0; i < bb_list->count; i++)
8517 {
8518 if (bb_list->list[i] != NULL)
8519 {
8520 l++;
8521 }
8522 }
8523 // initiate list
8524 L->Init(l);
8525 k = 0;
8526 for (unsigned i=0; i<nCount; i++)
8527 {
8528 L->m[k].rtyp = STRING_CMD;
8529 L->m[k].data = omStrDup(sArithBase.sCmds[i+1].name);
8530 k++;
8531 // Print("%-20s", sArithBase.sCmds[i+1].name);
8532 if (i + 1 + nCount < sArithBase.nCmdUsed)
8533 {
8534 L->m[k].rtyp = STRING_CMD;
8535 L->m[k].data = omStrDup(sArithBase.sCmds[i+1+nCount].name);
8536 k++;
8537 // Print("%-20s", sArithBase.sCmds[i+1 + nCount].name);
8538 }
8539 if(i+1+2*nCount<sArithBase.nCmdUsed)
8540 {
8541 L->m[k].rtyp = STRING_CMD;
8542 L->m[k].data = omStrDup(sArithBase.sCmds[i+1+2*nCount].name);
8543 k++;
8544 // Print("%-20s", sArithBase.sCmds[i+1+2*nCount].name);
8545 }
8546 // PrintLn();
8547 }
8548
8549 // assign blackbox types
8550 for (int i = 0; i < bb_list->count; i++)
8551 {
8552 if (bb_list->list[i] != NULL)
8553 {
8554 L->m[k].rtyp = STRING_CMD;
8555 // already used strdup in getBlackBoxTypes
8556 L->m[k].data = bb_list->list[i];
8557 k++;
8558 }
8559 }
8560 // free the struct (not the list entries itself, which were allocated
8561 // by strdup)
8562 omfree(bb_list->list);
8563 omfree(bb_list);
8564
8565 // pass the resultant list to the res datastructure
8566 res->data=(void *)L;
8567
8568 return FALSE;
8569}
8571{
8572 if (v == NULL)
8573 {
8574 res->data = omStrDup("");
8575 return FALSE;
8576 }
8577 int n = v->listLength();
8578 if (n == 1)
8579 {
8580 res->data = v->String();
8581 return FALSE;
8582 }
8583
8584 char** slist = (char**) omAlloc(n*sizeof(char*));
8585 int i, j;
8586
8587 for (i=0, j=0; i<n; i++, v = v ->next)
8588 {
8589 slist[i] = v->String();
8590 assume(slist[i] != NULL);
8591 j+=strlen(slist[i]);
8592 }
8593 char* s = (char*) omAlloc((j+1)*sizeof(char));
8594 *s='\0';
8595 for (i=0;i<n;i++)
8596 {
8597 strcat(s, slist[i]);
8598 omFree(slist[i]);
8599 }
8600 omFreeSize(slist, n*sizeof(char*));
8601 res->data = s;
8602 return FALSE;
8603}
8605{
8606 do
8607 {
8608 if (v->Typ()!=INT_CMD)
8609 return TRUE;
8610 test_cmd((int)(long)v->Data());
8611 v=v->next;
8612 }
8613 while (v!=NULL);
8614 return FALSE;
8615}
8616
8617#if defined(__alpha) && !defined(linux)
8618extern "C"
8619{
8620 void usleep(unsigned long usec);
8621};
8622#endif
8624{
8625 /* compute two factors of h(x,y) modulo x^(d+1) in K[[x]][y],
8626 see a detailed documentation in /kernel/linear_algebra/linearAlgebra.h
8627
8628 valid argument lists:
8629 - (poly h, int d),
8630 - (poly h, int d, poly f0, poly g0), optional: factors of h(0,y),
8631 - (poly h, int d, int xIndex, int yIndex), optional: indices of vars x & y
8632 in list of ring vars,
8633 - (poly h, int d, poly f0, poly g0, int xIndex, int yIndec),
8634 optional: all 4 optional args
8635 (The defaults are xIndex = 1, yIndex = 2, f0 and g0 polynomials as found
8636 by singclap_factorize and h(0, y)
8637 has exactly two distinct monic factors [possibly with exponent > 1].)
8638 result:
8639 - list with the two factors f and g such that
8640 h(x,y) = f(x,y)*g(x,y) mod x^(d+1) */
8641
8642 poly h = NULL;
8643 int d = 1;
8644 poly f0 = NULL;
8645 poly g0 = NULL;
8646 int xIndex = 1; /* default index if none provided */
8647 int yIndex = 2; /* default index if none provided */
8648
8649 leftv u = v; int factorsGiven = 0;
8650 if ((u == NULL) || (u->Typ() != POLY_CMD))
8651 {
8652 WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
8653 return TRUE;
8654 }
8655 else h = (poly)u->Data();
8656 u = u->next;
8657 if ((u == NULL) || (u->Typ() != INT_CMD))
8658 {
8659 WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
8660 return TRUE;
8661 }
8662 else d = (int)(long)u->Data();
8663 u = u->next;
8664 if ((u != NULL) && (u->Typ() == POLY_CMD))
8665 {
8666 if ((u->next == NULL) || (u->next->Typ() != POLY_CMD))
8667 {
8668 WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
8669 return TRUE;
8670 }
8671 else
8672 {
8673 f0 = (poly)u->Data();
8674 g0 = (poly)u->next->Data();
8675 factorsGiven = 1;
8676 u = u->next->next;
8677 }
8678 }
8679 if ((u != NULL) && (u->Typ() == INT_CMD))
8680 {
8681 if ((u->next == NULL) || (u->next->Typ() != INT_CMD))
8682 {
8683 WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
8684 return TRUE;
8685 }
8686 else
8687 {
8688 xIndex = (int)(long)u->Data();
8689 yIndex = (int)(long)u->next->Data();
8690 u = u->next->next;
8691 }
8692 }
8693 if (u != NULL)
8694 {
8695 WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
8696 return TRUE;
8697 }
8698
8699 /* checks for provided arguments */
8700 if (pIsConstant(h) || (factorsGiven && (pIsConstant(f0) || pIsConstant(g0))))
8701 {
8702 WerrorS("expected non-constant polynomial argument(s)");
8703 return TRUE;
8704 }
8705 int n = rVar(currRing);
8706 if ((xIndex < 1) || (n < xIndex))
8707 {
8708 Werror("index for variable x (%d) out of range [1..%d]", xIndex, n);
8709 return TRUE;
8710 }
8711 if ((yIndex < 1) || (n < yIndex))
8712 {
8713 Werror("index for variable y (%d) out of range [1..%d]", yIndex, n);
8714 return TRUE;
8715 }
8716 if (xIndex == yIndex)
8717 {
8718 WerrorS("expected distinct indices for variables x and y");
8719 return TRUE;
8720 }
8721
8722 /* computation of f0 and g0 if missing */
8723 if (factorsGiven == 0)
8724 {
8725 poly h0 = pSubst(pCopy(h), xIndex, NULL);
8726 intvec* v = NULL;
8727 ideal i = singclap_factorize(h0, &v, 0,currRing);
8728
8729 ivTest(v);
8730
8731 if (i == NULL) return TRUE;
8732
8733 idTest(i);
8734
8735 if ((v->rows() != 3) || ((*v)[0] =! 1) || (!nIsOne(pGetCoeff(i->m[0]))))
8736 {
8737 WerrorS("expected h(0,y) to have exactly two distinct monic factors");
8738 return TRUE;
8739 }
8740 f0 = pPower(pCopy(i->m[1]), (*v)[1]);
8741 g0 = pPower(pCopy(i->m[2]), (*v)[2]);
8742 idDelete(&i);
8743 }
8744
8745 poly f; poly g;
8746 henselFactors(xIndex, yIndex, h, f0, g0, d, f, g);
8748 L->Init(2);
8749 L->m[0].rtyp = POLY_CMD; L->m[0].data=(void*)f;
8750 L->m[1].rtyp = POLY_CMD; L->m[1].data=(void*)g;
8751 res->rtyp = LIST_CMD;
8752 res->data = (char*)L;
8753 return FALSE;
8754}
8756{
8757 if ((v->Typ() != LINK_CMD) ||
8758 (v->next->Typ() != STRING_CMD) ||
8759 (v->next->next->Typ() != STRING_CMD) ||
8760 (v->next->next->next->Typ() != INT_CMD))
8761 return TRUE;
8762 jjSTATUS3(res, v, v->next, v->next->next);
8763#if defined(HAVE_USLEEP)
8764 if (((long) res->data) == 0L)
8765 {
8766 int i_s = (int)(long) v->next->next->next->Data();
8767 if (i_s > 0)
8768 {
8769 usleep((int)(long) v->next->next->next->Data());
8770 jjSTATUS3(res, v, v->next, v->next->next);
8771 }
8772 }
8773#elif defined(HAVE_SLEEP)
8774 if (((int) res->data) == 0)
8775 {
8776 int i_s = (int) v->next->next->next->Data();
8777 if (i_s > 0)
8778 {
8779 si_sleep((is - 1)/1000000 + 1);
8780 jjSTATUS3(res, v, v->next, v->next->next);
8781 }
8782 }
8783#endif
8784 return FALSE;
8785}
8787{
8788 leftv v = u->next; // number of args > 0
8789 if (v==NULL) return TRUE;
8790 leftv w = v->next;
8791 if (w==NULL) return TRUE;
8792 leftv rest = w->next;
8793
8794 u->next = NULL;
8795 v->next = NULL;
8796 w->next = NULL;
8797 BOOLEAN b = iiExprArith3(res, iiOp, u, v, w);
8798 if ((rest!=NULL) && (!b))
8799 {
8800 leftv tmp_next=res->next;
8801 res->next=rest;
8802 sleftv tmp_res;
8803 tmp_res.Init();
8804 b = iiExprArithM(&tmp_res,res,iiOp);
8805 memcpy(res,&tmp_res,sizeof(tmp_res));
8806 res->next=tmp_next;
8807 }
8808 u->next = v;
8809 v->next = w;
8810 // rest was w->next, but is already cleaned
8811 return b;
8812}
8814{
8815 if ((INPUT->Typ() != MATRIX_CMD) ||
8816 (INPUT->next->Typ() != NUMBER_CMD) ||
8817 (INPUT->next->next->Typ() != NUMBER_CMD) ||
8818 (INPUT->next->next->next->Typ() != NUMBER_CMD))
8819 {
8820 WerrorS("expected (matrix, number, number, number) as arguments");
8821 return TRUE;
8822 }
8823 leftv u = INPUT; leftv v = u->next; leftv w = v->next; leftv x = w->next;
8824 res->data = (char *)qrDoubleShift((matrix)(u->Data()),
8825 (number)(v->Data()),
8826 (number)(w->Data()),
8827 (number)(x->Data()));
8828 return FALSE;
8829}
8831{ ideal result;
8832 leftv u = INPUT; /* an ideal, weighted homogeneous and standard */
8833 leftv v = u->next; /* one additional polynomial or ideal */
8834 leftv h = v->next; /* Hilbert vector */
8835 leftv w = h->next; /* weight vector */
8836 assumeStdFlag(u);
8837 ideal i1=(ideal)(u->Data());
8838 ideal i0;
8839 if (((u->Typ()!=IDEAL_CMD)&&(u->Typ()!=MODUL_CMD))
8840 || (h->Typ()!=BIGINTVEC_CMD)
8841 || (w->Typ()!=INTVEC_CMD))
8842 {
8843 WerrorS("expected `std(`ideal/module`,`poly/vector`,`bigintvec`,`intvec`)");
8844 return TRUE;
8845 }
8846 intvec *vw=(intvec *)w->Data(); // weights of vars
8847 /* merging std_hilb_w and std_1 */
8848 if (vw->length()!=currRing->N)
8849 {
8850 Werror("%d weights for %d variables",vw->length(),currRing->N);
8851 return TRUE;
8852 }
8853 int r=v->Typ();
8854 BOOLEAN cleanup_i0=FALSE;
8855 if ((r==POLY_CMD) ||(r==VECTOR_CMD))
8856 {
8857 i0=idInit(1,i1->rank);
8858 i0->m[0]=(poly)v->Data();
8859 cleanup_i0=TRUE;
8860 }
8861 else if (r==IDEAL_CMD)/* IDEAL */
8862 {
8863 i0=(ideal)v->Data();
8864 }
8865 else
8866 {
8867 WerrorS("expected `std(`ideal/module`,`poly/vector`,`intvec`,`intvec`)");
8868 return TRUE;
8869 }
8870 int ii0=idElem(i0);
8871 i1 = idSimpleAdd(i1,i0);
8872 if (cleanup_i0)
8873 {
8874 memset(i0->m,0,sizeof(poly)*IDELEMS(i0));
8875 idDelete(&i0);
8876 }
8877 intvec *ww=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
8878 tHomog hom=testHomog;
8879 /* u_id from jjSTD_W is now i1 as in jjSTD_1 */
8880 if (ww!=NULL)
8881 {
8882 if (!idTestHomModule(i1,currRing->qideal,ww))
8883 {
8884 WarnS("wrong weights");
8885 ww=NULL;
8886 }
8887 else
8888 {
8889 ww=ivCopy(ww);
8890 hom=isHomog;
8891 }
8892 }
8893 BITSET save1;
8894 SI_SAVE_OPT1(save1);
8896 result=kStd2(i1,
8897 currRing->qideal,
8898 hom,
8899 &ww, // module weights
8900 (bigintmat *)h->Data(), // hilbert series
8901 0, // syzComp, whatever it is...
8902 IDELEMS(i1)-ii0, // new ideal
8903 vw); // weights of vars
8904 SI_RESTORE_OPT1(save1);
8905 idDelete(&i1);
8907 res->data = (char *)result;
8909 if (ww!=NULL) atSet(res,omStrDup("isHomog"),ww,INTVEC_CMD);
8910 return FALSE;
8911}
8912
8914{
8915 //Print("construct ring\n");
8916 if (a->Typ()!=CRING_CMD)
8917 {
8918 WerrorS("expected `cring` [ `id` ... ]");
8919 return TRUE;
8920 }
8921 assume(a->next!=NULL);
8922 leftv names=a->next;
8923 int N=names->listLength();
8924 char **n=(char**)omAlloc0(N*sizeof(char*));
8925 for(int i=0; i<N;i++,names=names->next)
8926 {
8927 n[i]=(char *)names->Name();
8928 }
8929 coeffs cf=(coeffs)a->CopyD();
8930 res->data=rDefault(cf,N,n, ringorder_dp);
8931 omFreeSize(n,N*sizeof(char*));
8932 return FALSE;
8933}
8934
8935static Subexpr jjMakeSub(leftv e)
8936{
8937 assume( e->Typ()==INT_CMD );
8938 Subexpr r=(Subexpr)omAlloc0Bin(sSubexpr_bin);
8939 r->start =(int)(long)e->Data();
8940 return r;
8941}
8943{
8944 int c=(int)(long)u->Data();
8945 switch(c)
8946 {
8947 case 0:{
8948 PrintS("delete all variables\n");
8949 killlocals(0);
8950 WerrorS("restarting...");
8951 break;
8952 };
8953 default: WerrorS("not implemented");
8954 }
8955 return FALSE;
8956}
8957#define D(A) (A)
8958#define NULL_VAL NULL
8959#define IPARITH
8960#include "table.h"
8961
8962#include "iparith.inc"
8963
8964/*=================== operations with 2 args. ============================*/
8965/* must be ordered: first operations for chars (infix ops),
8966 * then alphabetically */
8967
8969 BOOLEAN proccall,
8970 const struct sValCmd2* dA2,
8971 int at, int bt,
8972 const struct sConvertTypes *dConvertTypes)
8973{
8974 BOOLEAN call_failed=FALSE;
8975
8976 if (!errorreported)
8977 {
8978 int i=0;
8979 iiOp=op;
8980 while (dA2[i].cmd==op)
8981 {
8982 if ((at==dA2[i].arg1)
8983 && (bt==dA2[i].arg2))
8984 {
8985 res->rtyp=dA2[i].res;
8986 if (currRing!=NULL)
8987 {
8988 if (check_valid(dA2[i].valid_for,op)) break;
8989 }
8990 else
8991 {
8992 if (RingDependend(dA2[i].res))
8993 {
8994 WerrorS("no ring active (3)");
8995 break;
8996 }
8997 }
8998 if (traceit&TRACE_CALL)
8999 Print("call %s(%s,%s)\n",iiTwoOps(op),Tok2Cmdname(at),Tok2Cmdname(bt));
9000 if ((call_failed=dA2[i].p(res,a,b)))
9001 {
9002 break;// leave loop, goto error handling
9003 }
9004 a->CleanUp();
9005 b->CleanUp();
9006 //Print("op: %d,result typ:%d\n",op,res->rtyp);
9007 return FALSE;
9008 }
9009 i++;
9010 }
9011 // implicite type conversion ----------------------------------------------
9012 if (dA2[i].cmd!=op)
9013 {
9014 int ai,bi;
9017 BOOLEAN failed=FALSE;
9018 i=0; /*iiTabIndex(dArithTab2,JJTAB2LEN,op);*/
9019 //Print("op: %c, type: %s %s\n",op,Tok2Cmdname(at),Tok2Cmdname(bt));
9020 while (dA2[i].cmd==op)
9021 {
9022 //Print("test %s %s\n",Tok2Cmdname(dA2[i].arg1),Tok2Cmdname(dA2[i].arg2));
9023 if ((dA2[i].valid_for & NO_CONVERSION)==0)
9024 {
9025 if ((ai=iiTestConvert(at,dA2[i].arg1,dConvertTypes))!=0)
9026 {
9027 if ((bi=iiTestConvert(bt,dA2[i].arg2,dConvertTypes))!=0)
9028 {
9029 res->rtyp=dA2[i].res;
9030 if (currRing!=NULL)
9031 {
9032 if (check_valid(dA2[i].valid_for,op)) break;
9033 }
9034 else
9035 {
9036 if (RingDependend(dA2[i].res))
9037 {
9038 WerrorS("no ring active (4)");
9039 break;
9040 }
9041 }
9042 if (traceit&TRACE_CALL)
9043 Print("call %s(%s,%s)\n",iiTwoOps(op),
9044 Tok2Cmdname(dA2[i].arg1),Tok2Cmdname(dA2[i].arg2));
9045 failed= ((iiConvert(at,dA2[i].arg1,ai,a,an))
9046 || (iiConvert(bt,dA2[i].arg2,bi,b,bn))
9047 || (call_failed=dA2[i].p(res,an,bn)));
9048 // everything done, clean up temp. variables
9049 if (failed)
9050 {
9051 // leave loop, goto error handling
9052 break;
9053 }
9054 else
9055 {
9056 // everything ok, clean up and return
9057 an->CleanUp();
9058 bn->CleanUp();
9061 return FALSE;
9062 }
9063 }
9064 }
9065 }
9066 i++;
9067 }
9068 an->CleanUp();
9069 bn->CleanUp();
9072 }
9073 // error handling ---------------------------------------------------
9074 const char *s=NULL;
9075 if (!errorreported)
9076 {
9077 if ((at==0) && (a->Fullname()!=sNoName_fe))
9078 {
9079 s=a->Fullname();
9080 }
9081 else if ((bt==0) && (b->Fullname()!=sNoName_fe))
9082 {
9083 s=b->Fullname();
9084 }
9085 if (s!=NULL)
9086 Werror("`%s` is not defined",s);
9087 else
9088 {
9089 i=0; /*iiTabIndex(dArithTab2,JJTAB2LEN,op);*/
9090 s = iiTwoOps(op);
9091 if (proccall)
9092 {
9093 Werror("%s(`%s`,`%s`) failed"
9094 ,s,Tok2Cmdname(at),Tok2Cmdname(bt));
9095 }
9096 else
9097 {
9098 Werror("`%s` %s `%s` failed"
9099 ,Tok2Cmdname(at),s,Tok2Cmdname(bt));
9100 }
9101 if ((!call_failed) && BVERBOSE(V_SHOW_USE))
9102 {
9103 while (dA2[i].cmd==op)
9104 {
9105 if(((at==dA2[i].arg1)||(bt==dA2[i].arg2))
9106 && (dA2[i].res!=0)
9107 && (dA2[i].p!=jjWRONG2))
9108 {
9109 if (proccall)
9110 Werror("expected %s(`%s`,`%s`)"
9111 ,s,Tok2Cmdname(dA2[i].arg1),Tok2Cmdname(dA2[i].arg2));
9112 else
9113 Werror("expected `%s` %s `%s`"
9114 ,Tok2Cmdname(dA2[i].arg1),s,Tok2Cmdname(dA2[i].arg2));
9115 }
9116 i++;
9117 }
9118 }
9119 }
9120 }
9121 a->CleanUp();
9122 b->CleanUp();
9123 res->rtyp = UNKNOWN;
9124 }
9125 return TRUE;
9126}
9128 const struct sValCmd2* dA2,
9129 int at,
9130 const struct sConvertTypes *dConvertTypes)
9131{
9132 res->Init();
9133 leftv b=a->next;
9134 a->next=NULL;
9135 int bt=b->Typ();
9137 a->next=b;
9138 a->CleanUp(); // to clean up the chain, content already done in iiExprArith2TabIntern
9139 return bo;
9140}
9142{
9143 res->Init();
9144
9145 if (!errorreported)
9146 {
9147#ifdef SIQ
9148 if (siq>0)
9149 {
9150 //Print("siq:%d\n",siq);
9152 memcpy(&d->arg1,a,sizeof(sleftv));
9153 a->Init();
9154 memcpy(&d->arg2,b,sizeof(sleftv));
9155 b->Init();
9156 d->argc=2;
9157 d->op=op;
9158 res->data=(char *)d;
9159 res->rtyp=COMMAND;
9160 return FALSE;
9161 }
9162#endif
9163 int at=a->Typ();
9164 int bt=b->Typ();
9165 // handling bb-objects ----------------------------------------------------
9166 if (at>MAX_TOK)
9167 {
9168 blackbox *bb=getBlackboxStuff(at);
9169 if (bb!=NULL)
9170 {
9171 if(!bb->blackbox_Op2(op,res,a,b)) return FALSE;
9172 // if not defined, try generic (attrib, ..)
9173 }
9174 else
9175 return TRUE;
9176 }
9177 else if ((bt>MAX_TOK)&&(op!='('))
9178 {
9179 blackbox *bb=getBlackboxStuff(bt);
9180 if (bb!=NULL)
9181 {
9182 if(!bb->blackbox_Op2(op,res,a,b)) return FALSE;
9183 // if not defined, try generic (attrib, ..)
9184 }
9185 else
9186 return TRUE;
9187 }
9188 int i=iiTabIndex(dArithTab2,JJTAB2LEN,op);
9189 return iiExprArith2TabIntern(res,a,op,b,proccall,dArith2+i,at,bt,dConvertTypes);
9190 }
9191 a->CleanUp();
9192 b->CleanUp();
9193 return TRUE;
9194}
9195
9196/*==================== operations with 1 arg. ===============================*/
9197/* must be ordered: first operations for chars (infix ops),
9198 * then alphabetically */
9199
9200BOOLEAN iiExprArith1Tab(leftv res, leftv a, int op, const struct sValCmd1* dA1, int at, const struct sConvertTypes *dConvertTypes)
9201{
9202 res->Init();
9203 BOOLEAN call_failed=FALSE;
9204
9205 if (!errorreported)
9206 {
9207 BOOLEAN failed=FALSE;
9208 iiOp=op;
9209 int i = 0;
9210 while (dA1[i].cmd==op)
9211 {
9212 if (at==dA1[i].arg)
9213 {
9214 if (currRing!=NULL)
9215 {
9216 if (check_valid(dA1[i].valid_for,op)) break;
9217 }
9218 else
9219 {
9220 if (RingDependend(dA1[i].res))
9221 {
9222 WerrorS("no ring active (5)");
9223 break;
9224 }
9225 }
9226 if (traceit&TRACE_CALL)
9227 Print("call %s(%s)\n",iiTwoOps(op),Tok2Cmdname(at));
9228 res->rtyp=dA1[i].res;
9229 if ((call_failed=dA1[i].p(res,a)))
9230 {
9231 break;// leave loop, goto error handling
9232 }
9233 if (a->Next()!=NULL)
9234 {
9236 failed=iiExprArith1(res->next,a->next,op);
9237 }
9238 a->CleanUp();
9239 return failed;
9240 }
9241 i++;
9242 }
9243 // implicite type conversion --------------------------------------------
9244 if (dA1[i].cmd!=op)
9245 {
9247 i=0;
9248 //Print("fuer %c , typ: %s\n",op,Tok2Cmdname(at));
9249 while (dA1[i].cmd==op)
9250 {
9251 int ai;
9252 //Print("test %s\n",Tok2Cmdname(dA1[i].arg));
9253 if ((dA1[i].valid_for & NO_CONVERSION)==0)
9254 {
9255 if ((ai=iiTestConvert(at,dA1[i].arg,dConvertTypes))!=0)
9256 {
9257 if (currRing!=NULL)
9258 {
9259 if (check_valid(dA1[i].valid_for,op)) break;
9260 }
9261 else
9262 {
9263 if (RingDependend(dA1[i].res))
9264 {
9265 WerrorS("no ring active (6)");
9266 break;
9267 }
9268 }
9269 if (traceit&TRACE_CALL)
9270 Print("call %s(%s)\n",iiTwoOps(op),Tok2Cmdname(dA1[i].arg));
9271 res->rtyp=dA1[i].res;
9272 failed= ((iiConvert(at,dA1[i].arg,ai,a,an,dConvertTypes))
9273 || (call_failed=dA1[i].p(res,an)));
9274 // everything done, clean up temp. variables
9275 if (failed)
9276 {
9277 // leave loop, goto error handling
9278 break;
9279 }
9280 else
9281 {
9282 if (an->Next() != NULL)
9283 {
9284 res->next = (leftv)omAllocBin(sleftv_bin);
9285 failed=iiExprArith1(res->next,an->next,op);
9286 }
9287 // everything ok, clean up and return
9288 an->CleanUp();
9290 return failed;
9291 }
9292 }
9293 }
9294 i++;
9295 }
9296 an->CleanUp();
9298 }
9299 // error handling
9300 if (!errorreported)
9301 {
9302 if ((at==0) && (a->Fullname()!=sNoName_fe))
9303 {
9304 Werror("`%s` is not defined",a->Fullname());
9305 }
9306 else
9307 {
9308 i=0;
9309 const char *s = iiTwoOps(op);
9310 Werror("%s(`%s`) failed"
9311 ,s,Tok2Cmdname(at));
9312 if ((!call_failed) && BVERBOSE(V_SHOW_USE))
9313 {
9314 while (dA1[i].cmd==op)
9315 {
9316 if ((dA1[i].res!=0)
9317 && (dA1[i].p!=jjWRONG))
9318 Werror("expected %s(`%s`)"
9319 ,s,Tok2Cmdname(dA1[i].arg));
9320 i++;
9321 }
9322 }
9323 }
9324 }
9325 res->rtyp = UNKNOWN;
9326 }
9327 a->CleanUp();
9328 return TRUE;
9329}
9331{
9332 if (!errorreported)
9333 {
9334 res->Init();
9335#ifdef SIQ
9336 if (siq>0)
9337 {
9338 //Print("siq:%d\n",siq);
9340 memcpy(&d->arg1,a,sizeof(sleftv));
9341 a->Init();
9342 d->op=op;
9343 d->argc=1;
9344 res->data=(char *)d;
9345 res->rtyp=COMMAND;
9346 return FALSE;
9347 }
9348#endif
9349 int at=a->Typ();
9350 // handling bb-objects ----------------------------------------------------
9351 if(op>MAX_TOK) // explicit type conversion to bb
9352 {
9353 blackbox *bb=getBlackboxStuff(op);
9354 if (bb!=NULL)
9355 {
9356 res->rtyp=op;
9357 res->data=bb->blackbox_Init(bb);
9358 return bb->blackbox_Assign(res,a);
9359 }
9360 else
9361 return TRUE;
9362 }
9363 else if (at>MAX_TOK) // argument is of bb-type
9364 {
9365 blackbox *bb=getBlackboxStuff(at);
9366 if (bb!=NULL)
9367 {
9368 if(!bb->blackbox_Op1(op,res,a)) return FALSE;
9369 // if not defined, try generic routines (attrib, defined,..)
9370 }
9371 else
9372 return TRUE;
9373 }
9374 if (errorreported) return TRUE;
9375
9376 int i=iiTabIndex(dArithTab1,JJTAB1LEN,op);
9377 return iiExprArith1Tab(res,a,op, dArith1+i,at,dConvertTypes);
9378 }
9379 a->CleanUp();
9380 return TRUE;
9381}
9382
9383/*=================== operations with 3 args. ============================*/
9384/* must be ordered: first operations for chars (infix ops),
9385 * then alphabetically */
9386
9388 const struct sValCmd3* dA3, int at, int bt, int ct,
9389 const struct sConvertTypes *dConvertTypes)
9390{
9391 BOOLEAN call_failed=FALSE;
9392
9393 assume(dA3[0].cmd==op);
9394
9395 if (!errorreported)
9396 {
9397 int i=0;
9398 iiOp=op;
9399 while (dA3[i].cmd==op)
9400 {
9401 if ((at==dA3[i].arg1)
9402 && (bt==dA3[i].arg2)
9403 && (ct==dA3[i].arg3))
9404 {
9405 res->rtyp=dA3[i].res;
9406 if (currRing!=NULL)
9407 {
9408 if (check_valid(dA3[i].valid_for,op)) break;
9409 }
9410 if (traceit&TRACE_CALL)
9411 Print("call %s(%s,%s,%s)\n",
9413 if ((call_failed=dA3[i].p(res,a,b,c)))
9414 {
9415 break;// leave loop, goto error handling
9416 }
9417 a->CleanUp();
9418 b->CleanUp();
9419 c->CleanUp();
9420 return FALSE;
9421 }
9422 i++;
9423 }
9424 // implicite type conversion ----------------------------------------------
9425 if (dA3[i].cmd!=op)
9426 {
9427 int ai,bi,ci;
9431 BOOLEAN failed=FALSE;
9432 i=0;
9433 //while ((dA3[i].cmd!=op)&&(dA3[i].cmd!=0)) i++;
9434 while (dA3[i].cmd==op)
9435 {
9436 if ((dA3[i].valid_for & NO_CONVERSION)==0)
9437 {
9438 if ((ai=iiTestConvert(at,dA3[i].arg1,dConvertTypes))!=0)
9439 {
9440 if ((bi=iiTestConvert(bt,dA3[i].arg2,dConvertTypes))!=0)
9441 {
9442 if ((ci=iiTestConvert(ct,dA3[i].arg3,dConvertTypes))!=0)
9443 {
9444 res->rtyp=dA3[i].res;
9445 if (currRing!=NULL)
9446 {
9447 if (check_valid(dA3[i].valid_for,op)) break;
9448 }
9449 if (traceit&TRACE_CALL)
9450 Print("call %s(%s,%s,%s)\n",
9451 iiTwoOps(op),Tok2Cmdname(dA3[i].arg1),
9452 Tok2Cmdname(dA3[i].arg2),Tok2Cmdname(dA3[i].arg3));
9453 failed= ((iiConvert(at,dA3[i].arg1,ai,a,an,dConvertTypes))
9454 || (iiConvert(bt,dA3[i].arg2,bi,b,bn,dConvertTypes))
9455 || (iiConvert(ct,dA3[i].arg3,ci,c,cn,dConvertTypes))
9456 || (call_failed=dA3[i].p(res,an,bn,cn)));
9457 // everything done, clean up temp. variables
9458 if (failed)
9459 {
9460 // leave loop, goto error handling
9461 break;
9462 }
9463 else
9464 {
9465 // everything ok, clean up and return
9466 an->CleanUp();
9467 bn->CleanUp();
9468 cn->CleanUp();
9472 //Print("op: %d,result typ:%d\n",op,res->rtyp);
9473 return FALSE;
9474 }
9475 }
9476 }
9477 }
9478 }
9479 i++;
9480 }
9481 an->CleanUp();
9482 bn->CleanUp();
9483 cn->CleanUp();
9487 }
9488 // error handling ---------------------------------------------------
9489 if (!errorreported)
9490 {
9491 const char *s=NULL;
9492 if ((at==0) && (a->Fullname()!=sNoName_fe))
9493 {
9494 s=a->Fullname();
9495 }
9496 else if ((bt==0) && (b->Fullname()!=sNoName_fe))
9497 {
9498 s=b->Fullname();
9499 }
9500 else if ((ct==0) && (c->Fullname()!=sNoName_fe))
9501 {
9502 s=c->Fullname();
9503 }
9504 if (s!=NULL)
9505 Werror("`%s` is not defined",s);
9506 else
9507 {
9508 i=0;
9509 //while ((dA3[i].cmd!=op)&&(dA3[i].cmd!=0)) i++;
9510 const char *s = iiTwoOps(op);
9511 Werror("%s(`%s`,`%s`,`%s`) failed"
9512 ,s,Tok2Cmdname(at),Tok2Cmdname(bt),Tok2Cmdname(ct));
9513 if ((!call_failed) && BVERBOSE(V_SHOW_USE))
9514 {
9515 while (dA3[i].cmd==op)
9516 {
9517 if(((at==dA3[i].arg1)
9518 ||(bt==dA3[i].arg2)
9519 ||(ct==dA3[i].arg3))
9520 && (dA3[i].res!=0))
9521 {
9522 Werror("expected %s(`%s`,`%s`,`%s`)"
9523 ,s,Tok2Cmdname(dA3[i].arg1)
9524 ,Tok2Cmdname(dA3[i].arg2)
9525 ,Tok2Cmdname(dA3[i].arg3));
9526 }
9527 i++;
9528 }
9529 }
9530 }
9531 }
9532 res->rtyp = UNKNOWN;
9533 }
9534 a->CleanUp();
9535 b->CleanUp();
9536 c->CleanUp();
9537 //Print("op: %d,result typ:%d\n",op,res->rtyp);
9538 return TRUE;
9539}
9541{
9542 res->Init();
9543
9544 if (!errorreported)
9545 {
9546#ifdef SIQ
9547 if (siq>0)
9548 {
9549 //Print("siq:%d\n",siq);
9551 memcpy(&d->arg1,a,sizeof(sleftv));
9552 a->Init();
9553 memcpy(&d->arg2,b,sizeof(sleftv));
9554 b->Init();
9555 memcpy(&d->arg3,c,sizeof(sleftv));
9556 c->Init();
9557 d->op=op;
9558 d->argc=3;
9559 res->data=(char *)d;
9560 res->rtyp=COMMAND;
9561 return FALSE;
9562 }
9563#endif
9564 int at=a->Typ();
9565 // handling bb-objects ----------------------------------------------
9566 if (at>MAX_TOK)
9567 {
9568 blackbox *bb=getBlackboxStuff(at);
9569 if (bb!=NULL)
9570 {
9571 if(!bb->blackbox_Op3(op,res,a,b,c)) return FALSE;
9572 // otherwise, try defaul (attrib,..)
9573 }
9574 else
9575 return TRUE;
9576 if (errorreported) return TRUE;
9577 }
9578 int bt=b->Typ();
9579 int ct=c->Typ();
9580
9581 iiOp=op;
9582 int i=0;
9583 while ((dArith3[i].cmd!=op)&&(dArith3[i].cmd!=0)) i++;
9584 return iiExprArith3TabIntern(res,op,a,b,c,dArith3+i,at,bt,ct,dConvertTypes);
9585 }
9586 a->CleanUp();
9587 b->CleanUp();
9588 c->CleanUp();
9589 //Print("op: %d,result typ:%d\n",op,res->rtyp);
9590 return TRUE;
9591}
9593 const struct sValCmd3* dA3,
9594 int at,
9595 const struct sConvertTypes *dConvertTypes)
9596{
9597 res->Init();
9598 leftv b=a->next;
9599 a->next=NULL;
9600 int bt=b->Typ();
9601 leftv c=b->next;
9602 b->next=NULL;
9603 int ct=c->Typ();
9604 BOOLEAN bo=iiExprArith3TabIntern(res,op,a,b,c,dA3,at,bt,ct,dConvertTypes);
9605 b->next=c;
9606 a->next=b;
9607 a->CleanUp(); // to cleanup the chain, content already done
9608 return bo;
9609}
9610/*==================== operations with many arg. ===============================*/
9611/* must be ordered: first operations for chars (infix ops),
9612 * then alphabetically */
9613
9614#if 0 // unused
9615static BOOLEAN jjANY2LIST(leftv res, leftv v, int cnt)
9616{
9617 // cnt = 0: all
9618 // cnt = 1: only first one
9619 leftv next;
9620 BOOLEAN failed = TRUE;
9621 if(v==NULL) return failed;
9622 res->rtyp = LIST_CMD;
9623 if(cnt) v->next = NULL;
9624 next = v->next; // saving next-pointer
9625 failed = jjLIST_PL(res, v);
9626 v->next = next; // writeback next-pointer
9627 return failed;
9628}
9629#endif
9630
9632{
9633 res->Init();
9634
9635 if (!errorreported)
9636 {
9637#ifdef SIQ
9638 if (siq>0)
9639 {
9640 //Print("siq:%d\n",siq);
9642 d->op=op;
9643 res->data=(char *)d;
9644 if (a!=NULL)
9645 {
9646 d->argc=a->listLength();
9647 // else : d->argc=0;
9648 memcpy(&d->arg1,a,sizeof(sleftv));
9649 switch(d->argc)
9650 {
9651 case 3:
9652 memcpy(&d->arg3,a->next->next,sizeof(sleftv));
9653 a->next->next->Init(); /* no break */
9654 case 2:
9655 memcpy(&d->arg2,a->next,sizeof(sleftv));
9656 a->next->Init();
9657 a->next->next=d->arg2.next;
9658 d->arg2.next=NULL; /* no break */
9659 case 1:
9660 a->Init();
9661 a->next=d->arg1.next;
9662 d->arg1.next=NULL;
9663 }
9664 if (d->argc>3) a->next=NULL;
9665 a->name=NULL;
9666 a->rtyp=0;
9667 a->data=NULL;
9668 a->e=NULL;
9669 a->attribute=NULL;
9670 a->CleanUp();
9671 }
9672 res->rtyp=COMMAND;
9673 return FALSE;
9674 }
9675#endif
9676 if ((a!=NULL) && (a->Typ()>MAX_TOK))
9677 {
9678 blackbox *bb=getBlackboxStuff(a->Typ());
9679 if (bb!=NULL)
9680 {
9681 if(!bb->blackbox_OpM(op,res,a)) return FALSE;
9682 // otherwise, try default
9683 }
9684 else
9685 return TRUE;
9686 if (errorreported) return TRUE;
9687 }
9688 int args=0;
9689 if (a!=NULL) args=a->listLength();
9690
9691 iiOp=op;
9692 int i=0;
9693 while ((dArithM[i].cmd!=op)&&(dArithM[i].cmd!=0)) i++;
9694 while (dArithM[i].cmd==op)
9695 {
9696 if ((args==dArithM[i].number_of_args)
9697 || (dArithM[i].number_of_args==-1)
9698 || ((dArithM[i].number_of_args==-2)&&(args>0)))
9699 {
9700 res->rtyp=dArithM[i].res;
9701 if (currRing!=NULL)
9702 {
9703 if (check_valid(dArithM[i].valid_for,op)) break;
9704 }
9705 if (traceit&TRACE_CALL)
9706 Print("call %s(... (%d args))\n", iiTwoOps(op),args);
9707 if (dArithM[i].p(res,a))
9708 {
9709 break;// leave loop, goto error handling
9710 }
9711 if (a!=NULL) a->CleanUp();
9712 //Print("op: %d,result typ:%d\n",op,res->rtyp);
9713 return FALSE;
9714 }
9715 i++;
9716 }
9717 // error handling
9718 if (!errorreported)
9719 {
9720 if ((args>0) && (a->rtyp==0) && (a->Name()!=sNoName_fe))
9721 {
9722 Werror("`%s` is not defined",a->Fullname());
9723 }
9724 else
9725 {
9726 const char *s = iiTwoOps(op);
9727 Werror("%s(...) failed",s);
9728 }
9729 }
9730 res->rtyp = UNKNOWN;
9731 }
9732 if (a!=NULL) a->CleanUp();
9733 //Print("op: %d,result typ:%d\n",op,res->rtyp);
9734 return TRUE;
9735}
9736
9737/*=================== general utilities ============================*/
9738int IsCmd(const char *n, int & tok)
9739{
9740 int i;
9741 int an=1;
9742 int en=sArithBase.nLastIdentifier;
9743
9744 loop
9745 //for(an=0; an<sArithBase.nCmdUsed; )
9746 {
9747 if(an>=en-1)
9748 {
9749 if (strcmp(n, sArithBase.sCmds[an].name) == 0)
9750 {
9751 i=an;
9752 break;
9753 }
9754 else if ((an!=en) && (strcmp(n, sArithBase.sCmds[en].name) == 0))
9755 {
9756 i=en;
9757 break;
9758 }
9759 else
9760 {
9761 // -- blackbox extensions:
9762 // return 0;
9763 return blackboxIsCmd(n,tok);
9764 }
9765 }
9766 i=(an+en)/2;
9767 if (*n < *(sArithBase.sCmds[i].name))
9768 {
9769 en=i-1;
9770 }
9771 else if (*n > *(sArithBase.sCmds[i].name))
9772 {
9773 an=i+1;
9774 }
9775 else
9776 {
9777 int v=strcmp(n,sArithBase.sCmds[i].name);
9778 if(v<0)
9779 {
9780 en=i-1;
9781 }
9782 else if(v>0)
9783 {
9784 an=i+1;
9785 }
9786 else /*v==0*/
9787 {
9788 break;
9789 }
9790 }
9791 }
9792 lastreserved=sArithBase.sCmds[i].name;
9793 tok=sArithBase.sCmds[i].tokval;
9794 if(sArithBase.sCmds[i].alias==2)
9795 {
9796 Warn("outdated identifier `%s` used - please change your code",
9797 sArithBase.sCmds[i].name);
9798 sArithBase.sCmds[i].alias=1;
9799 }
9800 #if 0
9801 if (currRingHdl==NULL)
9802 {
9803 #ifdef SIQ
9804 if (siq<=0)
9805 {
9806 #endif
9807 if ((tok>=BEGIN_RING) && (tok<=END_RING))
9808 {
9809 WerrorS("no ring active");
9810 return 0;
9811 }
9812 #ifdef SIQ
9813 }
9814 #endif
9815 }
9816 #endif
9817 if (!expected_parms)
9818 {
9819 switch (tok)
9820 {
9821 case IDEAL_CMD:
9822 case INT_CMD:
9823 case INTVEC_CMD:
9824 case MAP_CMD:
9825 case MATRIX_CMD:
9826 case MODUL_CMD:
9827 case POLY_CMD:
9828 case PROC_CMD:
9829 case RING_CMD:
9830 case STRING_CMD:
9831 cmdtok = tok;
9832 break;
9833 }
9834 }
9835 return sArithBase.sCmds[i].toktype;
9836}
9837static int iiTabIndex(const jjValCmdTab dArithTab, const int len, const int op)
9838{
9839 // user defined types are not in the pre-computed table:
9840 if (op>MAX_TOK) return 0;
9841
9842 int a=0;
9843 int e=len;
9844 int p=len/2;
9845 do
9846 {
9847 if (op==dArithTab[p].cmd) return dArithTab[p].start;
9848 if (op<dArithTab[p].cmd) e=p-1;
9849 else a = p+1;
9850 p=a+(e-a)/2;
9851 }
9852 while ( a <= e);
9853
9854 // catch missing a cmd:
9855 // may be missing as a op for blackbox, if the first operand is "undef" instead of bb
9856 // Print("op %d (%c) unknown",op,op);
9857 return 0;
9858}
9859
9860typedef char si_char_2[2];
9862const char * Tok2Cmdname(int tok)
9863{
9864 if (tok <= 0)
9865 {
9866 return sArithBase.sCmds[0].name;
9867 }
9868 if (tok==ANY_TYPE) return "any_type";
9869 if (tok==COMMAND) return "command";
9870 if (tok==NONE) return "nothing";
9871 if (tok < 128)
9872 {
9873 Tok2Cmdname_buf[0]=(char)tok;
9874 return Tok2Cmdname_buf;
9875 }
9876 //if (tok==IFBREAK) return "if_break";
9877 //if (tok==VECTOR_FROM_POLYS) return "vector_from_polys";
9878 //if (tok==ORDER_VECTOR) return "ordering";
9879 //if (tok==REF_VAR) return "ref";
9880 //if (tok==OBJECT) return "object";
9881 //if (tok==PRINT_EXPR) return "print_expr";
9882 if (tok==IDHDL) return "identifier";
9883 if (tok>MAX_TOK) return getBlackboxName(tok);
9884 unsigned i;
9885 for(i=0; i<sArithBase.nCmdUsed; i++)
9886 //while (sArithBase.sCmds[i].tokval!=0)
9887 {
9888 if ((sArithBase.sCmds[i].tokval == tok)&&
9889 (sArithBase.sCmds[i].alias==0))
9890 {
9891 return sArithBase.sCmds[i].name;
9892 }
9893 }
9894 // try gain for alias/old names:
9895 for(i=0; i<sArithBase.nCmdUsed; i++)
9896 {
9897 if (sArithBase.sCmds[i].tokval == tok)
9898 {
9899 return sArithBase.sCmds[i].name;
9900 }
9901 }
9902 return sArithBase.sCmds[0].name;
9903}
9904
9905
9906/*---------------------------------------------------------------------*/
9907/**
9908 * @brief compares to entry of cmdsname-list
9909
9910 @param[in] a
9911 @param[in] b
9912
9913 @return <ReturnValue>
9914**/
9915/*---------------------------------------------------------------------*/
9916static int _gentable_sort_cmds( const void *a, const void *b )
9917{
9918 cmdnames *pCmdL = (cmdnames*)a;
9919 cmdnames *pCmdR = (cmdnames*)b;
9920
9921 if(a==NULL || b==NULL) return 0;
9922
9923 /* empty entries goes to the end of the list for later reuse */
9924 if(pCmdL->name==NULL) return 1;
9925 if(pCmdR->name==NULL) return -1;
9926
9927 /* $INVALID$ must come first */
9928 if(strcmp(pCmdL->name, "$INVALID$")==0) return -1;
9929 if(strcmp(pCmdR->name, "$INVALID$")==0) return 1;
9930
9931 /* tokval=-1 are reserved names at the end */
9932 if (pCmdL->tokval==-1)
9933 {
9934 if (pCmdR->tokval==-1)
9935 return strcmp(pCmdL->name, pCmdR->name);
9936 /* pCmdL->tokval==-1, pCmdL goes at the end */
9937 return 1;
9938 }
9939 /* pCmdR->tokval==-1, pCmdR goes at the end */
9940 if(pCmdR->tokval==-1) return -1;
9941
9942 return strcmp(pCmdL->name, pCmdR->name);
9943}
9944
9945/*---------------------------------------------------------------------*/
9946/**
9947 * @brief initialisation of arithmetic structured data
9948
9949 @retval 0 on success
9950
9951**/
9952/*---------------------------------------------------------------------*/
9954{
9955 //printf("iiInitArithmetic()\n");
9956 memset(&sArithBase, 0, sizeof(sArithBase));
9957 iiInitCmdName();
9958 /* fix last-identifier */
9959#if 0
9960 /* we expect that gentable allready did every thing */
9961 for(sArithBase.nLastIdentifier=sArithBase.nCmdUsed-1;
9962 sArithBase.nLastIdentifier>0; sArithBase.nLastIdentifier--) {
9963 if(sArithBase.sCmds[sArithBase.nLastIdentifier].tokval>=0) break;
9964 }
9965#endif
9966 //Print("L=%d\n", sArithBase.nLastIdentifier);
9967
9968 //iiArithAddCmd(szName, nAlias, nTokval, nToktype);
9969 //iiArithAddCmd("mygcd", 1, GCD_CMD, CMD_2);
9970
9971 //iiArithAddCmd("Top", 0,-1,0);
9972
9973
9974 //for(i=0; i<sArithBase.nCmdUsed; i++) {
9975 // printf("CMD[%03d] %s, %d, %d, %d\n", i,
9976 // sArithBase.sCmds[i].name,
9977 // sArithBase.sCmds[i].alias,
9978 // sArithBase.sCmds[i].tokval,
9979 // sArithBase.sCmds[i].toktype);
9980 //}
9981 //iiArithRemoveCmd("Top");
9982 //iiArithAddCmd("mygcd", 2, GCD_CMD, CMD_2);
9983 //iiArithRemoveCmd("mygcd");
9984 //iiArithAddCmd("kkk", 1, 1234, CMD_1);
9985 return 0;
9986}
9987
9988int iiArithFindCmd(const char *szName)
9989{
9990 int an=0;
9991 int i = 0,v = 0;
9992 int en=sArithBase.nLastIdentifier;
9993
9994 loop
9995 //for(an=0; an<sArithBase.nCmdUsed; )
9996 {
9997 if(an>=en-1)
9998 {
9999 if (strcmp(szName, sArithBase.sCmds[an].name) == 0)
10000 {
10001 //Print("RET-an=%d %s\n", an, sArithBase.sCmds[an].name);
10002 return an;
10003 }
10004 else if (strcmp(szName, sArithBase.sCmds[en].name) == 0)
10005 {
10006 //Print("RET-en=%d %s\n", en, sArithBase.sCmds[en].name);
10007 return en;
10008 }
10009 else
10010 {
10011 //Print("RET- 1\n");
10012 return -1;
10013 }
10014 }
10015 i=(an+en)/2;
10016 if (*szName < *(sArithBase.sCmds[i].name))
10017 {
10018 en=i-1;
10019 }
10020 else if (*szName > *(sArithBase.sCmds[i].name))
10021 {
10022 an=i+1;
10023 }
10024 else
10025 {
10026 v=strcmp(szName,sArithBase.sCmds[i].name);
10027 if(v<0)
10028 {
10029 en=i-1;
10030 }
10031 else if(v>0)
10032 {
10033 an=i+1;
10034 }
10035 else /*v==0*/
10036 {
10037 //Print("RET-i=%d %s\n", i, sArithBase.sCmds[i].name);
10038 return i;
10039 }
10040 }
10041 }
10042 //if(i>=0 && i<sArithBase.nCmdUsed)
10043 // return i;
10044 //PrintS("RET-2\n");
10045 return -2;
10046}
10047
10048char *iiArithGetCmd( int nPos )
10049{
10050 if(nPos<0) return NULL;
10051 if(nPos<(int)sArithBase.nCmdUsed)
10052 return sArithBase.sCmds[nPos].name;
10053 return NULL;
10054}
10055
10056int iiArithRemoveCmd(const char *szName)
10057{
10058 int nIndex;
10059 if(szName==NULL) return -1;
10060
10061 nIndex = iiArithFindCmd(szName);
10062 if(nIndex<0 || nIndex>=(int)sArithBase.nCmdUsed)
10063 {
10064 Print("'%s' not found (%d)\n", szName, nIndex);
10065 return -1;
10066 }
10067 omFreeBinAddr(sArithBase.sCmds[nIndex].name);
10068 sArithBase.sCmds[nIndex].name=NULL;
10069 qsort(sArithBase.sCmds, sArithBase.nCmdUsed, sizeof(cmdnames),
10071 sArithBase.nCmdUsed--;
10072
10073 /* fix last-identifier */
10074 for(sArithBase.nLastIdentifier=sArithBase.nCmdUsed-1;
10075 sArithBase.nLastIdentifier>0; sArithBase.nLastIdentifier--)
10076 {
10077 if(sArithBase.sCmds[sArithBase.nLastIdentifier].tokval>=0) break;
10078 }
10079 //Print("L=%d\n", sArithBase.nLastIdentifier);
10080 return 0;
10081}
10082
10084 const char *szName,
10085 short nAlias,
10086 short nTokval,
10087 short nToktype,
10088 short nPos
10089 )
10090{
10091 //printf("AddCmd(%s, %d, %d, %d, %d)\n", szName, nAlias,
10092 // nTokval, nToktype, nPos);
10093 if(nPos>=0)
10094 {
10095 // no checks: we rely on a correct generated code in iparith.inc
10096 assume((unsigned)nPos < sArithBase.nCmdAllocated);
10097 assume(szName!=NULL);
10098 sArithBase.sCmds[nPos].name = omStrDup(szName);
10099 sArithBase.sCmds[nPos].alias = nAlias;
10100 sArithBase.sCmds[nPos].tokval = nTokval;
10101 sArithBase.sCmds[nPos].toktype = nToktype;
10102 sArithBase.nCmdUsed++;
10103 //if(nTokval>0) sArithBase.nLastIdentifier++;
10104 }
10105 else
10106 {
10107 if(szName==NULL) return -1;
10108 int nIndex = iiArithFindCmd(szName);
10109 if(nIndex>=0)
10110 {
10111 Print("'%s' already exists at %d\n", szName, nIndex);
10112 return -1;
10113 }
10114
10115 if(sArithBase.nCmdUsed>=sArithBase.nCmdAllocated)
10116 {
10117 /* needs to create new slots */
10118 unsigned long nSize = (sArithBase.nCmdAllocated+1)*sizeof(cmdnames);
10119 sArithBase.sCmds = (cmdnames *)omRealloc(sArithBase.sCmds, nSize);
10120 if(sArithBase.sCmds==NULL) return -1;
10121 sArithBase.nCmdAllocated++;
10122 }
10123 /* still free slots available */
10124 sArithBase.sCmds[sArithBase.nCmdUsed].name = omStrDup(szName);
10125 sArithBase.sCmds[sArithBase.nCmdUsed].alias = nAlias;
10126 sArithBase.sCmds[sArithBase.nCmdUsed].tokval = nTokval;
10127 sArithBase.sCmds[sArithBase.nCmdUsed].toktype = nToktype;
10128 sArithBase.nCmdUsed++;
10129
10130 qsort(sArithBase.sCmds, sArithBase.nCmdUsed, sizeof(cmdnames),
10132 for(sArithBase.nLastIdentifier=sArithBase.nCmdUsed-1;
10133 sArithBase.nLastIdentifier>0; sArithBase.nLastIdentifier--)
10134 {
10135 if(sArithBase.sCmds[sArithBase.nLastIdentifier].tokval>=0) break;
10136 }
10137 //Print("L=%d\n", sArithBase.nLastIdentifier);
10138 }
10139 return 0;
10140}
10141
10142static BOOLEAN check_valid(const int p, const int op)
10143{
10145 {
10146 if ((p & NC_MASK)==NO_NC)
10147 {
10148 WerrorS("not implemented for non-commutative rings");
10149 return TRUE;
10150 }
10151 else if ((p & NC_MASK)==COMM_PLURAL)
10152 {
10153 Warn("assume commutative subalgebra for cmd `%s` in >>%s<<",Tok2Cmdname(op),my_yylinebuf);
10154 return FALSE;
10155 }
10156 /* else, ALLOW_PLURAL */
10157 }
10158 else if (rIsLPRing(currRing))
10159 {
10160 if ((p & ALLOW_LP)==0)
10161 {
10162 Werror("`%s` not implemented for letterplace rings in >>%s<<",Tok2Cmdname(op),my_yylinebuf);
10163 return TRUE;
10164 }
10165 }
10167 {
10168 if ((p & RING_MASK)==0 /*NO_RING*/)
10169 {
10170 WerrorS("not implemented for rings with rings as coeffients");
10171 return TRUE;
10172 }
10174 {
10175 WerrorS("not implemented for rings with rings as coeffients and non-global orderings");
10176 return TRUE;
10177 }
10178 /* else ALLOW_RING */
10179 else if (((p & ZERODIVISOR_MASK)==NO_ZERODIVISOR)
10181 {
10182 WerrorS("domain required as coeffients");
10183 return TRUE;
10184 }
10185 /* else ALLOW_ZERODIVISOR */
10186 else if(((p & WARN_RING)==WARN_RING)&&(myynest==0))
10187 {
10188 WarnS("considering the image in Q[...]");
10189 }
10190 }
10191 return FALSE;
10192}
10193// --------------------------------------------------------------------
10195{
10196 if ((currRing!=NULL)
10198 && (!rField_is_Z(currRing)))
10199 {
10200 WerrorS("not implemented for rings with rings as coeffients (except ZZ)");
10201 return TRUE;
10202 }
10203 coeffs cf;
10204 lists c=(lists)u->CopyD(); // list of ideal or bigint/int
10205 int rl=c->nr+1;
10206 int return_type=c->m[0].Typ();
10207 if ((return_type!=IDEAL_CMD)
10208 && (return_type!=MODUL_CMD)
10209 && (return_type!=SMATRIX_CMD)
10210 && (return_type!=MATRIX_CMD)
10211 && (return_type!=POLY_CMD))
10212 {
10213 if((return_type==BIGINT_CMD)
10214 ||(return_type==INT_CMD))
10215 return_type=BIGINT_CMD;
10216 else if (return_type==LIST_CMD)
10217 {
10218 // create a tmp list of the correct size
10220 res_l->Init(rl /*c->nr+1*/);
10221 BOOLEAN bo=FALSE;
10222 int tab_pos=iiTabIndex(dArithTab2,JJTAB2LEN,CHINREM_CMD);
10223 for (unsigned i=0;i<=(unsigned)c->nr;i++)
10224 {
10225 sleftv tmp;
10226 tmp.Copy(v);
10227 bo=iiExprArith2TabIntern(&res_l->m[i],&c->m[i],CHINREM_CMD,&tmp,TRUE,dArith2+tab_pos,c->m[i].rtyp,tmp.rtyp,dConvertTypes);
10228 if (bo) { Werror("chinrem failed for list entry %d",i+1); break;}
10229 }
10230 c->Clean();
10231 res->data=res_l;
10232 res->rtyp=LIST_CMD;
10233 return bo;
10234 }
10235 else
10236 {
10237 c->Clean();
10238 WerrorS("poly/ideal/module/matrix/list expected");
10239 return TRUE;
10240 }
10241 }
10242 if (return_type==BIGINT_CMD)
10244 else
10245 {
10246 cf=currRing->cf;
10247 if (nCoeff_is_Extension(cf) && (cf->extRing!=NULL))
10248 cf=cf->extRing->cf;
10249 }
10250 lists pl=NULL;
10251 intvec *p=NULL;
10252 if (v->Typ()==LIST_CMD)
10253 {
10254 pl=(lists)v->Data();
10255 if (pl->nr!=rl-1)
10256 {
10257 Werror("wromg number of primes (%d:%d) for chinrem",pl->nr+1,rl);
10258 return TRUE;
10259 }
10260 }
10261 else
10262 {
10263 p=(intvec*)v->Data();
10264 if (p->length()!=rl)
10265 {
10266 Werror("wromg number of primes (%d:%d) for chinrem",p->length(),rl);
10267 return TRUE;
10268 }
10269 }
10270 ideal result;
10271 ideal *x=(ideal *)omAlloc(rl*sizeof(ideal));
10272 number *xx=NULL;
10274 int i;
10275 if (return_type!=BIGINT_CMD)
10276 {
10277 for(i=rl-1;i>=0;i--)
10278 {
10279 if (c->m[i].Typ()!=return_type)
10280 {
10281 Werror("%s expected at pos %d",Tok2Cmdname(return_type),i+1);
10282 omFree(x); // delete c
10283 return TRUE;
10284 }
10285 if (return_type==POLY_CMD)
10286 {
10287 x[i]=idInit(1,1);
10288 x[i]->m[0]=(poly)c->m[i].CopyD();
10289 }
10290 else
10291 {
10292 x[i]=(ideal)c->m[i].CopyD();
10293 }
10294 //c->m[i].Init();
10295 }
10296 }
10297 else
10298 {
10299 if (nMap==NULL)
10300 {
10301 Werror("not implemented: map bigint -> %s", nCoeffName(cf));
10302 return TRUE;
10303 }
10304 xx=(number *)omAlloc(rl*sizeof(number));
10305 for(i=rl-1;i>=0;i--)
10306 {
10307 if (c->m[i].Typ()==INT_CMD)
10308 {
10309 xx[i]=n_Init(((int)(long)c->m[i].Data()),cf);
10310 }
10311 else if (c->m[i].Typ()==BIGINT_CMD)
10312 {
10313 xx[i]=nMap((number)c->m[i].Data(),coeffs_BIGINT,cf);
10314 }
10315 else
10316 {
10317 Werror("bigint expected at pos %d",i+1);
10318 omFree(x); // delete c
10319 omFree(xx); // delete c
10320 return TRUE;
10321 }
10322 }
10323 }
10324 number *q=(number *)omAlloc(rl*sizeof(number));
10325 if (p!=NULL)
10326 {
10327 for(i=rl-1;i>=0;i--)
10328 {
10329 q[i]=n_Init((*p)[i], cf);
10330 }
10331 }
10332 else
10333 {
10334 for(i=rl-1;i>=0;i--)
10335 {
10336 if (pl->m[i].Typ()==INT_CMD)
10337 {
10338 q[i]=n_Init((int)(long)pl->m[i].Data(),cf);
10339 }
10340 else if (pl->m[i].Typ()==BIGINT_CMD)
10341 {
10342 q[i]=nMap((number)(pl->m[i].Data()),coeffs_BIGINT,cf);
10343 }
10344 else
10345 {
10346 Werror("bigint expected at pos %d",i+1);
10347 for(i++;i<rl;i++)
10348 {
10349 n_Delete(&(q[i]),cf);
10350 }
10351 omFree(x); // delete c
10352 omFree(q); // delete pl
10353 if (xx!=NULL) omFree(xx); // delete c
10354 return TRUE;
10355 }
10356 }
10357 }
10358 if (return_type==BIGINT_CMD)
10359 {
10360 CFArray i_v(rl);
10361 number n=n_ChineseRemainderSym(xx,q,rl,TRUE,i_v,coeffs_BIGINT);
10362 res->data=(char *)n;
10363 }
10364 else
10365 {
10366 /* called in modular.lib::chinrem_recursive: too many proc.
10367 #ifdef HAVE_VSPACE
10368 int cpus = (long) feOptValue(FE_OPT_CPUS);
10369 if ((cpus>1) && (rField_is_Q(currRing)))
10370 result=id_ChineseRemainder_0(x,q,rl,currRing); // deletes also x
10371 else
10372 #endif
10373 */
10374 result=id_ChineseRemainder(x,q,rl,currRing); // deletes also x
10375 c->Clean();
10376 if ((return_type==POLY_CMD) &&(result!=NULL))
10377 {
10378 res->data=(char *)result->m[0];
10379 result->m[0]=NULL;
10380 idDelete(&result);
10381 }
10382 else
10383 res->data=(char *)result;
10384 }
10385 for(i=rl-1;i>=0;i--)
10386 {
10387 n_Delete(&(q[i]),cf);
10388 }
10389 omFree(q);
10390 res->rtyp=return_type;
10391 return result==NULL;
10392}
10394{
10395 lists c=(lists)u->CopyD();
10397 res_l->Init(c->nr+1);
10398 BOOLEAN bo=FALSE;
10399 int tab_pos=iiTabIndex(dArithTab2,JJTAB2LEN,FAREY_CMD);
10400 for (unsigned i=0;i<=(unsigned)c->nr;i++)
10401 {
10402 sleftv tmp;
10403 tmp.Copy(v);
10404 bo=iiExprArith2TabIntern(&res_l->m[i],&c->m[i],FAREY_CMD,&tmp,TRUE,dArith2+tab_pos,c->m[i].rtyp,tmp.rtyp,dConvertTypes);
10405 if (bo) { Werror("farey failed for list entry %d",i+1); break;}
10406 }
10407 c->Clean();
10408 res->data=res_l;
10409 return bo;
10410}
10411// --------------------------------------------------------------------
10412static int jjCOMPARE_ALL(const void * aa, const void * bb)
10413{
10414 leftv a=(leftv)aa;
10415 int at=a->Typ();
10416 leftv b=(leftv)bb;
10417 int bt=b->Typ();
10418 if (at < bt) return -1;
10419 if (at > bt) return 1;
10420 int tab_pos=iiTabIndex(dArithTab2,JJTAB2LEN,'<');
10421 sleftv tmp;
10422 tmp.Init();
10423 iiOp='<';
10424 BOOLEAN bo=iiExprArith2TabIntern(&tmp,a,'<',b,FALSE,dArith2+tab_pos,at,bt,dConvertTypes);
10425 if (bo)
10426 {
10427 Werror(" no `<` for %s",Tok2Cmdname(at));
10428 unsigned long ad=(unsigned long)a->Data();
10429 unsigned long bd=(unsigned long)b->Data();
10430 if (ad<bd) return -1;
10431 else if (ad==bd) return 0;
10432 else return 1;
10433 }
10434 else if (tmp.data==NULL) /* not < */
10435 {
10437 tab_pos=iiTabIndex(dArithTab2,JJTAB2LEN,EQUAL_EQUAL);
10439 if (bo)
10440 {
10441 Werror(" no `==` for %s",Tok2Cmdname(at));
10442 unsigned long ad=(unsigned long)a->Data();
10443 unsigned long bd=(unsigned long)b->Data();
10444 if (ad<bd) return -1;
10445 else if (ad==bd) return 0;
10446 else return 1;
10447 }
10448 else if (tmp.data==NULL) /* not <,== */ return 1;
10449 else return 0;
10450 }
10451 else return -1;
10452}
10454{
10455 lists l=(lists)arg->Data();
10456 if (l->nr>0)
10457 {
10458 qsort(l->m,l->nr+1,sizeof(sleftv),jjCOMPARE_ALL);
10459 }
10460 return FALSE;
10461}
10463{
10464 lists l=(lists)arg->Data();
10465 if (l->nr>0)
10466 {
10467 qsort(l->m,l->nr+1,sizeof(sleftv),jjCOMPARE_ALL);
10468 int i, j, len;
10469 len=l->nr;
10470 i=0;
10471 while(i<len)
10472 {
10473 if(jjCOMPARE_ALL(&(l->m[i]),&(l->m[i+1]))==0)
10474 {
10475 l->m[i].CleanUp();
10476 for(j=i; j<len;j++) l->m[j]=l->m[j+1];
10477 memset(&(l->m[len]),0,sizeof(sleftv));
10478 l->m[len].rtyp=DEF_CMD;
10479 len--;
10480 }
10481 else
10482 i++;
10483 }
10484 //Print("new len:%d\n",len);
10485 }
10486 return FALSE;
10487}
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:113
#define BITSET
Definition auxiliary.h:85
static int si_max(const int a, const int b)
Definition auxiliary.h:125
int BOOLEAN
Definition auxiliary.h:88
#define TRUE
Definition auxiliary.h:101
#define FALSE
Definition auxiliary.h:97
void * ADDRESS
Definition auxiliary.h:120
static int si_min(const int a, const int b)
Definition auxiliary.h:126
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:1801
int singclap_det_i(intvec *m, const ring)
Definition clapsing.cc:1783
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:103
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:122
int length() const
Definition intvec.h:95
int compare(const intvec *o) const
Definition intvec.cc:206
int cols() const
Definition intvec.h:96
int rows() const
Definition intvec.h:97
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:963
@ 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:956
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:960
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:2063
poly hFirstSeries0p(ideal A, ideal Q, intvec *wdegree, const ring src, const ring Qt)
Definition hilb.cc:2020
intvec * hSecondSeries(intvec *hseries1)
Definition hilb.cc:707
intvec * hFirstSeries(ideal A, intvec *module_w, ideal Q, intvec *wdegree)
Definition hilb.cc:2150
bigintmat * hFirstSeries0b(ideal I, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const coeffs biv_cf)
Definition hilb.cc:2655
bigintmat * hSecondSeries0b(ideal I, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const coeffs biv_cf)
Definition hilb.cc:2677
void scDegree(ideal S, intvec *modulweight, ideal Q)
Definition hilb.cc:2693
void hLookSeries(ideal S, intvec *modulweight, ideal Q, intvec *wdegree)
Definition hilb.cc:856
GbVariant syGetAlgorithm(char *n, const ring r, const ideal)
Definition ideals.cc:3666
matrix idCoeffOfKBase(ideal arg, ideal kbase, poly how)
Definition ideals.cc:2639
void idLiftW(ideal P, ideal Q, int n, matrix &T, ideal &R, int *w)
Definition ideals.cc:1342
ideal idSyzygies(ideal h1, tHomog h, intvec **w, BOOLEAN setSyzComp, BOOLEAN setRegularity, int *deg, GbVariant alg)
Definition ideals.cc:836
matrix idDiff(matrix i, int k)
Definition ideals.cc:2160
BOOLEAN idTestHomModule(ideal m, ideal Q, intvec *w)
Definition ideals.cc:2091
ideal idLiftStd(ideal h1, matrix *T, tHomog hi, ideal *S, GbVariant alg, ideal h11)
Definition ideals.cc:982
ideal idQuot(ideal h1, ideal h2, BOOLEAN h1IsStb, BOOLEAN resultIsIdeal)
Definition ideals.cc:1512
ideal idSeries(int n, ideal M, matrix U, intvec *w)
Definition ideals.cc:2143
ideal idMinEmbedding_with_map_v(ideal arg, intvec **w, ideal &trans, int *g)
Definition ideals.cc:2845
ideal idElimination2(ideal h1, poly delVar, bigintmat *hilb, GbVariant alg)
Definition ideals.cc:1611
matrix idDiffOp(ideal I, ideal J, BOOLEAN multiply)
Definition ideals.cc:2173
ideal idElimination(ideal h1, poly delVar, intvec *hilb, GbVariant alg)
Definition ideals.cc:1855
ideal idSect(ideal h1, ideal h2, GbVariant alg)
Definition ideals.cc:315
ideal idMultSect(resolvente arg, int length, GbVariant alg)
Definition ideals.cc:472
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:1111
ideal idModulo(ideal h2, ideal h1, tHomog hom, intvec **w, matrix *T, GbVariant alg)
Definition ideals.cc:2434
ideal idMinBase(ideal h1, ideal *SB)
Definition ideals.cc:51
ideal id_Farey(ideal x, number N, const ring r)
Definition ideals.cc:3074
ideal idMinEmbedding(ideal arg, BOOLEAN inPlace, intvec **w)
Definition ideals.cc:2824
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:180
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:188
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:146
#define ivTest(v)
Definition intvec.h:172
#define IMATELEM(M, I, J)
Definition intvec.h:86
static BOOLEAN jjUMINUS_MA(leftv res, leftv u)
Definition iparith.cc:3819
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:4949
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:4446
static BOOLEAN jjIm2Iv(leftv res, leftv v)
Definition iparith.cc:4439
const char * name
Definition gentable.cc:58
#define SIMPL_EQU
Definition iparith.cc:3341
static BOOLEAN jjQUOT(leftv res, leftv u, leftv v)
Definition iparith.cc:3099
static BOOLEAN jjUMINUS_IV(leftv res, leftv u)
Definition iparith.cc:3825
static BOOLEAN jjOPPOSITE(leftv res, leftv a)
Definition iparith.cc:5291
static int _gentable_sort_cmds(const void *a, const void *b)
compares to entry of cmdsname-list
Definition iparith.cc:9916
BOOLEAN jjWAITALL1(leftv res, leftv u)
Definition iparith.cc:5532
static BOOLEAN jjRESTART(leftv, leftv u)
Definition iparith.cc:8942
static BOOLEAN jjidHead(leftv res, leftv v)
Definition iparith.cc:5694
static BOOLEAN jjHILBERT(leftv, leftv v)
Definition iparith.cc:4330
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:4605
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:5659
static BOOLEAN jjBRACK_Bim(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:5816
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:4087
BOOLEAN jjWAIT1ST1(leftv res, leftv u)
Definition iparith.cc:5517
BOOLEAN jjLOAD(const char *s, BOOLEAN autoexport)
load lib/module given in v
Definition iparith.cc:5567
static BOOLEAN jjMATRIX_Mo(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6940
static BOOLEAN jjP2I(leftv res, leftv v)
Definition iparith.cc:4863
static BOOLEAN jjIS_RINGVAR_P(leftv res, leftv v)
Definition iparith.cc:4473
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:6191
static BOOLEAN jjREPART(leftv res, leftv v)
Definition iparith.cc:4965
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:4746
static BOOLEAN jjRESERVEDLIST0(leftv res, leftv)
Definition iparith.cc:8490
short start
Definition iparith.cc:126
static BOOLEAN jjCHAR(leftv res, leftv v)
Definition iparith.cc:3934
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:5952
static BOOLEAN jjROWS_IV(leftv res, leftv v)
Definition iparith.cc:5010
static BOOLEAN jjLIFTSTD(leftv res, leftv u, leftv v)
Definition iparith.cc:2605
static BOOLEAN jjNULL(leftv, leftv)
Definition iparith.cc:3769
static BOOLEAN jjNEWSTRUCT2(leftv, leftv u, leftv v)
Definition iparith.cc:2803
static BOOLEAN jjBIV2IV(leftv res, leftv v)
Definition iparith.cc:4464
static BOOLEAN jjMONITOR2(leftv res, leftv u, leftv v)
Definition iparith.cc:2738
static BOOLEAN jjDIM(leftv res, leftv v)
Definition iparith.cc:4143
static BOOLEAN jjCOUNT_BIM(leftv res, leftv v)
Definition iparith.cc:3974
static BOOLEAN jjBRACKET(leftv res, leftv a, leftv b)
Definition iparith.cc:2914
static BOOLEAN jjCOLS_IV(leftv res, leftv v)
Definition iparith.cc:3956
static BOOLEAN jjNAMES_I(leftv res, leftv v)
Definition iparith.cc:4776
static BOOLEAN jjMULT(leftv res, leftv v)
Definition iparith.cc:4726
static BOOLEAN jjHOMOG1_WI(leftv res, leftv v, leftv u)
Definition iparith.cc:2503
static BOOLEAN jjPARDEG(leftv res, leftv v)
Definition iparith.cc:4819
static BOOLEAN jjDENOMINATOR(leftv res, leftv v)
Return the denominator of the input number.
Definition iparith.cc:4064
static BOOLEAN jjRANDOM(leftv res, leftv u, leftv v)
Definition iparith.cc:3106
static BOOLEAN jjIDEAL_Ma(leftv res, leftv v)
Definition iparith.cc:4403
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:5722
static BOOLEAN jjOPTION_PL(leftv res, leftv v)
Definition iparith.cc:8339
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:4137
static BOOLEAN jjL2R(leftv res, leftv v)
Definition iparith.cc:4565
static BOOLEAN jjREDUCE5(leftv res, leftv u)
Definition iparith.cc:8420
static BOOLEAN jjrCharStr(leftv res, leftv v)
Definition iparith.cc:5684
static BOOLEAN jjSUBST_Id_I(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6899
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:4343
int iiArithFindCmd(const char *szName)
Definition iparith.cc:9988
static BOOLEAN jjIDEAL_R(leftv res, leftv v)
Definition iparith.cc:4422
static BOOLEAN jjINDEPSET(leftv res, leftv v)
Definition iparith.cc:4451
static BOOLEAN jjTYPEOF(leftv res, leftv v)
Definition iparith.cc:5405
static BOOLEAN jjLU_SOLVE(leftv res, leftv v)
Definition iparith.cc:7785
static BOOLEAN jjFACSTD(leftv res, leftv v)
Definition iparith.cc:4206
static BOOLEAN jjMEMORY(leftv res, leftv v)
Definition iparith.cc:4681
static BOOLEAN jjidTransp(leftv res, leftv v)
Definition iparith.cc:5752
static BOOLEAN jjLIFT(leftv res, leftv u, leftv v)
Definition iparith.cc:2585
static BOOLEAN jjUMINUS_BIM(leftv res, leftv u)
Definition iparith.cc:3832
static BOOLEAN jjSUBST_Bu(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6803
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:5747
BOOLEAN jjSORTLIST(leftv, leftv arg)
Definition iparith.cc:10453
static BOOLEAN jjDUMP(leftv, leftv v)
Definition iparith.cc:4171
static BOOLEAN jjpMaxComp(leftv res, leftv v)
Definition iparith.cc:5712
static BOOLEAN jjCOEFFS1(leftv res, leftv v)
Definition iparith.cc:3939
static BOOLEAN jjREDUCE3_ID(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7192
static BOOLEAN jjELIMIN_HILB(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6151
static int jjCOMPARE_ALL(const void *aa, const void *bb)
Definition iparith.cc:10412
static BOOLEAN jjNAMEOF(leftv res, leftv v)
Definition iparith.cc:4758
static BOOLEAN jjPlural_mat_poly(leftv res, leftv a, leftv b)
Definition iparith.cc:2874
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:2693
BOOLEAN jjUNIQLIST(leftv, leftv arg)
Definition iparith.cc:10462
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:3433
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:4881
static BOOLEAN jjPFAC2(leftv res, leftv u, leftv v)
Definition iparith.cc:3285
static BOOLEAN jjidVec2Ideal(leftv res, leftv v)
Definition iparith.cc:5679
static BOOLEAN jjJACOB_P(leftv res, leftv v)
Definition iparith.cc:4489
static BOOLEAN jjSQR_FREE(leftv res, leftv u)
Definition iparith.cc:5178
static BOOLEAN jjSTD_HILB_W(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7255
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:6979
static BOOLEAN jjSBA_1(leftv res, leftv v, leftv u)
Definition iparith.cc:5093
#define SIMPL_NORM
Definition iparith.cc:3343
static BOOLEAN jjCOEFFS3_P(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6116
static BOOLEAN jjCALL1MANY(leftv res, leftv u)
Definition iparith.cc:3930
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:4457
static BOOLEAN jjJACOB_M(leftv res, leftv a)
Definition iparith.cc:4520
static BOOLEAN jjJET_ID_IV(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6348
static BOOLEAN jjTIMES_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:1053
static BOOLEAN jjBAREISS(leftv res, leftv v)
Definition iparith.cc:3864
static BOOLEAN jjREAD(leftv res, leftv v)
Definition iparith.cc:4956
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:8623
static BOOLEAN jjMATRIX_Id(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6917
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:4478
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:6816
static BOOLEAN jjROWS_BIM(leftv res, leftv v)
Definition iparith.cc:5005
static BOOLEAN jjCOMPARE_S(leftv res, leftv u, leftv v)
Definition iparith.cc:478
#define SIMPL_LMEQ
Definition iparith.cc:3339
int iiInitArithmetic()
initialisation of arithmetic structured data
Definition iparith.cc:9953
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:7116
static BOOLEAN jjBAREISS3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6071
static BOOLEAN jjRESERVED0(leftv, leftv)
Definition iparith.cc:8468
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:8095
static BOOLEAN jjSLIM_GB(leftv res, leftv u)
Definition iparith.cc:5025
static BOOLEAN jjMSTD(leftv res, leftv v)
Definition iparith.cc:4711
#define bit31
Definition iparith.cc:120
short cmd
Definition iparith.cc:125
static BOOLEAN jjBREAK1(leftv, leftv v)
Definition iparith.cc:7305
static BOOLEAN jjJET_ID_M(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6354
static BOOLEAN jjMINUS_BIM(leftv res, leftv u, leftv v)
Definition iparith.cc:941
static BOOLEAN jjnInt(leftv res, leftv u)
Definition iparith.cc:5757
static BOOLEAN jjSQR_FREE2(leftv res, leftv u, leftv dummy)
Definition iparith.cc:3381
static BOOLEAN jjCOEFFS3_Id(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6096
static BOOLEAN jjREGULARITY(leftv res, leftv v)
Definition iparith.cc:4960
static BOOLEAN jjHOMOG_W_M(leftv res, leftv v1, leftv v2, leftv v3)
Definition iparith.cc:6288
static BOOLEAN jjMINUS_N(leftv res, leftv u, leftv v)
Definition iparith.cc:898
static BOOLEAN jjBREAK0(leftv, leftv)
Definition iparith.cc:7298
static BOOLEAN jjTRACE_IV(leftv res, leftv v)
Definition iparith.cc:5276
BOOLEAN iiExprArith2(leftv res, leftv a, int op, leftv b, BOOLEAN proccall)
Definition iparith.cc:9141
static BOOLEAN jjMONOM(leftv res, leftv v)
Definition iparith.cc:2779
static BOOLEAN jjSort_Id(leftv res, leftv v)
Definition iparith.cc:5173
static BOOLEAN jjCOEF_M(leftv, leftv v)
Definition iparith.cc:7346
static BOOLEAN jjidMinBase(leftv res, leftv v)
Definition iparith.cc:5700
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:6059
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:4875
static BOOLEAN jjHOMOG_P(leftv res, leftv u, leftv v)
Definition iparith.cc:2444
static BOOLEAN jjBRACK_Im(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:5789
static BOOLEAN jjMATRIX_Ma(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6953
static BOOLEAN jjidMaxIdeal(leftv res, leftv v)
Definition iparith.cc:4386
static BOOLEAN jjMINOR_M(leftv res, leftv v)
Definition iparith.cc:6365
static BOOLEAN jjCOUNT_BI(leftv res, leftv v)
Definition iparith.cc:3969
static BOOLEAN jjPROC3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6052
static BOOLEAN jjKERNEL_M(leftv res, leftv v)
Definition iparith.cc:4541
static BOOLEAN jjCOLS_BIM(leftv res, leftv v)
Definition iparith.cc:3951
static BOOLEAN jjREDUCE3_CP(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7161
struct sValCmd3 * psValCmd3
Definition iparith.cc:185
static BOOLEAN jjBRACK_Ma_I_IV(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:5902
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:2894
static BOOLEAN jjIDEAL_Map(leftv res, leftv v)
Definition iparith.cc:4412
static BOOLEAN jjPARSTR2(leftv res, leftv u, leftv v)
Definition iparith.cc:2817
BOOLEAN(* proc2)(leftv, leftv, leftv)
Definition iparith.cc:149
static BOOLEAN jjKoszul(leftv res, leftv u, leftv v)
Definition iparith.cc:2573
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:7630
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:6323
static BOOLEAN jjRES3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7200
static BOOLEAN jjBIGINTVEC_PL(leftv res, leftv v)
Definition iparith.cc:7898
static BOOLEAN jjJET_P_IV(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6331
static BOOLEAN jjREDUCE_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:3147
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:9592
static BOOLEAN jjOP_REST(leftv res, leftv u, leftv v)
Definition iparith.cc:505
static BOOLEAN jjEXECUTE(leftv, leftv v)
Definition iparith.cc:4197
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:7246
static BOOLEAN jjLEADEXP(leftv res, leftv v)
Definition iparith.cc:4587
static BOOLEAN jjDEG_M(leftv res, leftv u)
Definition iparith.cc:4024
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:4501
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:2523
static BOOLEAN jjSIMPL_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:3344
static BOOLEAN jjRING3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7241
static BOOLEAN jjREDUCE_P(leftv res, leftv u, leftv v)
Definition iparith.cc:3139
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:2310
static BOOLEAN jjMODULO(leftv res, leftv u, leftv v)
Definition iparith.cc:2640
static BOOLEAN jjCOMPARE_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:338
STATIC_VAR int WerrorS_dummy_cnt
Definition iparith.cc:5638
static BOOLEAN jjREAD2(leftv res, leftv u, leftv v)
Definition iparith.cc:3123
static BOOLEAN jjREDUCE3_P(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7185
static BOOLEAN jjPAR1(leftv res, leftv v)
Definition iparith.cc:4803
static BOOLEAN jjnlInt(leftv res, leftv u)
Definition iparith.cc:5764
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:2383
static BOOLEAN jjELIMIN(leftv res, leftv u, leftv v)
Definition iparith.cc:1972
static BOOLEAN jjPLUSPLUS(leftv, leftv u)
Definition iparith.cc:3783
static Subexpr jjMakeSub(leftv e)
Definition iparith.cc:8935
static BOOLEAN jjCHINREM_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:1680
static BOOLEAN jjROWS(leftv res, leftv v)
Definition iparith.cc:4999
static BOOLEAN jjJET_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:2551
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:8968
int IsCmd(const char *n, int &tok)
Definition iparith.cc:9738
static BOOLEAN jjSBA(leftv res, leftv v)
Definition iparith.cc:5067
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:2541
static BOOLEAN jjKBASE(leftv res, leftv v)
Definition iparith.cc:4559
static BOOLEAN jjTENSOR(leftv res, leftv u, leftv v)
Definition iparith.cc:3629
static BOOLEAN jjmpTrace(leftv res, leftv v)
Definition iparith.cc:5717
static BOOLEAN jjRING_PL(leftv res, leftv a)
Definition iparith.cc:8913
static BOOLEAN jjREDUCE4(leftv res, leftv u)
Definition iparith.cc:8349
static BOOLEAN jjFWALK(leftv res, leftv u, leftv v)
Definition iparith.cc:2357
static BOOLEAN jjTEST(leftv, leftv v)
Definition iparith.cc:8604
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:3566
static BOOLEAN jjPRUNE(leftv res, leftv v)
Definition iparith.cc:4887
static BOOLEAN jjDIVISION4(leftv res, leftv v)
Definition iparith.cc:7363
unsigned nLastIdentifier
valid identifiers are slot 1..nLastIdentifier
Definition iparith.cc:189
static BOOLEAN jjDEFINED(leftv res, leftv v)
Definition iparith.cc:4052
static BOOLEAN jjLagSolve(leftv res, leftv v)
Definition iparith.cc:4642
static BOOLEAN jjRING_1(leftv res, leftv u, leftv v)
Definition iparith.cc:1671
static BOOLEAN jjVDIM(leftv res, leftv v)
Definition iparith.cc:5490
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:3980
static BOOLEAN jjHILBERT2(leftv res, leftv u, leftv v)
Definition iparith.cc:2406
static BOOLEAN jjFIND2(leftv res, leftv u, leftv v)
Definition iparith.cc:2292
static BOOLEAN jjCOEF_Id(leftv res, leftv u, leftv v)
Definition iparith.cc:1798
static BOOLEAN jjP2N(leftv res, leftv v)
Definition iparith.cc:4911
static BOOLEAN jjE(leftv res, leftv v)
Definition iparith.cc:4185
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:9330
static BOOLEAN jjSTD_HILB_WP(leftv res, leftv INPUT)
Definition iparith.cc:8830
static BOOLEAN jjLISTRING(leftv res, leftv v)
Definition iparith.cc:4624
static BOOLEAN jjCOEFFS2_KB(leftv res, leftv u, leftv v)
Definition iparith.cc:1816
#define SIMPL_NULL
Definition iparith.cc:3342
static BOOLEAN jjLIFTSTD_M(leftv res, leftv U)
Definition iparith.cc:8126
static BOOLEAN jjELIMIN_ALG(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6143
static BOOLEAN jjVAR1(leftv res, leftv v)
Definition iparith.cc:5456
static BOOLEAN jjLEADCOEF(leftv res, leftv v)
Definition iparith.cc:4573
static BOOLEAN jjVARSTR2(leftv res, leftv u, leftv v)
Definition iparith.cc:3655
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:6907
static BOOLEAN jjUMINUS_BI(leftv res, leftv u)
Definition iparith.cc:3795
int iiArithAddCmd(const char *szName, short nAlias, short nTokval, short nToktype, short nPos=-1)
Definition iparith.cc:10083
static BOOLEAN jjpLength(leftv res, leftv v)
Definition iparith.cc:5664
static BOOLEAN jjJET_P_P(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6338
static BOOLEAN jjLT_I(leftv res, leftv u, leftv v)
Definition iparith.cc:1216
static BOOLEAN jjIS_RINGVAR0(leftv res, leftv)
Definition iparith.cc:4484
static BOOLEAN jjEXTGCD_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:2004
static BOOLEAN jjBI2P(leftv res, leftv u)
Definition iparith.cc:3915
static BOOLEAN jjTWOSTD(leftv res, leftv a)
Definition iparith.cc:5325
static BOOLEAN jjGCD_I(leftv res, leftv u, leftv v)
Definition iparith.cc:2363
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:4246
static BOOLEAN jjREDUCE3_CID(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7173
static BOOLEAN jjFAREY_LI(leftv res, leftv u, leftv v)
Definition iparith.cc:10393
static BOOLEAN jjTRANSP_BIM(leftv res, leftv v)
Definition iparith.cc:5281
static BOOLEAN jjCOUNT_RES(leftv res, leftv v)
Definition iparith.cc:5742
#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:5727
static BOOLEAN jjKERNEL(leftv res, leftv u, leftv v)
Definition iparith.cc:2569
static BOOLEAN jjINTERSECT3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6310
static BOOLEAN jjBRACK_Ma(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:5844
sValCmdTab jjValCmdTab[]
Definition iparith.cc:129
static BOOLEAN jjMOD_N(leftv res, leftv u, leftv v)
Definition iparith.cc:2704
static BOOLEAN jjLOAD_E(leftv, leftv v, leftv u)
Definition iparith.cc:2629
static BOOLEAN jjNEWSTRUCT3(leftv, leftv u, leftv v, leftv w)
Definition iparith.cc:6644
static BOOLEAN jjHOMOG_P_W(leftv res, leftv u, leftv v, leftv)
Definition iparith.cc:6270
static BOOLEAN jjpHead(leftv res, leftv v)
Definition iparith.cc:5689
static BOOLEAN jjSUBST_Id(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6849
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:3985
struct sValCmdM * psValCmdM
Definition iparith.cc:186
static BOOLEAN jjDET_I(leftv res, leftv v)
Definition iparith.cc:4123
static BOOLEAN jjCOUNT_RG(leftv res, leftv v)
Definition iparith.cc:4002
static BOOLEAN jjSMATRIX_Mo(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7081
static BOOLEAN jjINTERSECT(leftv res, leftv u, leftv v)
Definition iparith.cc:2517
static BOOLEAN jjrVarStr(leftv res, leftv v)
Definition iparith.cc:5732
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:10142
static BOOLEAN jjSTRING_PL(leftv res, leftv v)
Definition iparith.cc:8570
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:3330
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:2734
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:2164
static BOOLEAN jjCALL3ARG(leftv res, leftv u)
Definition iparith.cc:7334
static BOOLEAN jjSTD_1(leftv res, leftv u, leftv v)
Definition iparith.cc:3482
static BOOLEAN jjUMINUS_N(leftv res, leftv u)
Definition iparith.cc:3807
static BOOLEAN jjNUMERATOR(leftv res, leftv v)
Return the numerator of the input number.
Definition iparith.cc:4073
static BOOLEAN jjORD(leftv res, leftv v)
Definition iparith.cc:4797
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:3802
static BOOLEAN jjPREIMAGE(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6654
static BOOLEAN jjBRACK_Ma_IV_IV(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6001
static BOOLEAN jjMRES_MAP(leftv res, leftv u, leftv v, leftv ma)
Definition iparith.cc:6561
static BOOLEAN jjPLUS_SM(leftv res, leftv u, leftv v)
Definition iparith.cc:835
BOOLEAN jjLOAD_TRY(const char *s)
Definition iparith.cc:5643
static BOOLEAN jjLIFT3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7094
static BOOLEAN jjENVELOPE(leftv res, leftv a)
Definition iparith.cc:5310
static BOOLEAN jjSetRing(leftv, leftv u)
Definition iparith.cc:3840
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:7866
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:2834
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:2556
static BOOLEAN jjPOWER_I(leftv res, leftv u, leftv v)
Definition iparith.cc:521
#define SIMPL_MULT
Definition iparith.cc:3340
static BOOLEAN jjRES(leftv res, leftv u, leftv v)
Definition iparith.cc:3156
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:4732
static BOOLEAN jjCOLS(leftv res, leftv v)
Definition iparith.cc:3946
static BOOLEAN jjPLUS_BIM(leftv res, leftv u, leftv v)
Definition iparith.cc:813
static BOOLEAN jjP2BI(leftv res, leftv v)
Definition iparith.cc:4843
static void WerrorS_dummy(const char *)
Definition iparith.cc:5639
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:5286
static BOOLEAN jjGT_N(leftv res, leftv u, leftv v)
Definition iparith.cc:1194
static BOOLEAN jjUNIVARIATE(leftv res, leftv v)
Definition iparith.cc:5451
static BOOLEAN jjMODULO4(leftv res, leftv u)
Definition iparith.cc:8267
static BOOLEAN jjHOMOG_ID_W(leftv res, leftv u, leftv v, leftv)
Definition iparith.cc:6252
static BOOLEAN jjWEDGE(leftv res, leftv u, leftv v)
Definition iparith.cc:3740
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:6160
static BOOLEAN jjLU_INVERSE(leftv res, leftv v)
Definition iparith.cc:7704
static BOOLEAN jjMODULO3S(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7030
static BOOLEAN jjBAREISS_BIM(leftv res, leftv v)
Definition iparith.cc:3887
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:3439
static BOOLEAN jjPFAC1(leftv res, leftv v)
Definition iparith.cc:4633
static BOOLEAN jjQRDS(leftv res, leftv INPUT)
Definition iparith.cc:8813
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:6230
static BOOLEAN jjCONTENT(leftv res, leftv v)
Definition iparith.cc:3961
static BOOLEAN jjDIFF_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:1919
static BOOLEAN jjSTD(leftv res, leftv v)
Definition iparith.cc:5145
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:6296
static BOOLEAN jjCOUNT_IV(leftv res, leftv v)
Definition iparith.cc:3997
static BOOLEAN jjFRES(leftv res, leftv u, leftv v)
Definition iparith.cc:2347
unsigned nCmdAllocated
number of commands-slots allocated
Definition iparith.cc:188
static BOOLEAN jjDUMMY(leftv res, leftv u)
Definition iparith.cc:3762
static BOOLEAN jjS2I(leftv res, leftv v)
Definition iparith.cc:5020
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:9127
static BOOLEAN jjBI2N(leftv res, leftv u)
Definition iparith.cc:3894
short alias
Definition gentable.cc:59
static BOOLEAN jjRIGHTSTD(leftv res, leftv v)
Definition iparith.cc:5344
BOOLEAN iiExprArithM(leftv res, leftv a, int op)
Definition iparith.cc:9631
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:9540
static BOOLEAN jjGETDUMP(leftv, leftv v)
Definition iparith.cc:4262
static BOOLEAN jjidFreeModule(leftv res, leftv v)
Definition iparith.cc:5674
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:2941
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:6728
static BOOLEAN jjRESERVEDNAME(leftv res, leftv v)
Definition iparith.cc:4927
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:3636
static BOOLEAN jjCOEFFS3_KB(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6110
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:9387
static BOOLEAN jjRMINUS(leftv res, leftv u, leftv v)
Definition iparith.cc:3311
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:6200
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:3455
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:5015
static BOOLEAN jjJanetBasis2(leftv res, leftv u, leftv v)
Definition iparith.cc:2535
static BOOLEAN jjLOAD1(leftv, leftv v)
Definition iparith.cc:4620
static BOOLEAN jjCOLON(leftv res, leftv u, leftv v)
Definition iparith.cc:319
const char * Tok2Cmdname(int tok)
Definition iparith.cc:9862
static BOOLEAN jjRPLUS(leftv res, leftv u, leftv v)
Definition iparith.cc:3317
static BOOLEAN jjKERNEL_SM(leftv res, leftv v)
Definition iparith.cc:4550
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:2461
static BOOLEAN jjrParStr(leftv res, leftv v)
Definition iparith.cc:5737
struct sValCmd2 * psValCmd2
Definition iparith.cc:184
static BOOLEAN jjDEG(leftv res, leftv v)
Definition iparith.cc:4016
static BOOLEAN jjFETCH_M(leftv res, leftv u)
Definition iparith.cc:7505
static BOOLEAN jjINDEX_V(leftv res, leftv u, leftv v)
Definition iparith.cc:1515
static BOOLEAN jjRINGLIST(leftv res, leftv v)
Definition iparith.cc:4970
static BOOLEAN jjidElem(leftv res, leftv v)
Definition iparith.cc:5669
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:2376
static BOOLEAN jjBI2IM(leftv res, leftv u)
Definition iparith.cc:3909
static BOOLEAN jjRANK2(leftv res, leftv u, leftv v)
Definition iparith.cc:3114
static BOOLEAN jjDEGREE(leftv res, leftv v)
Definition iparith.cc:4035
static BOOLEAN jjLIFTSTD_ALG(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7139
static BOOLEAN jjINDEPSET2(leftv res, leftv u, leftv v)
Definition iparith.cc:2510
static BOOLEAN jjWAITALL2(leftv res, leftv u, leftv v)
Definition iparith.cc:3692
static BOOLEAN jjOpenClose(leftv, leftv v)
Definition iparith.cc:4791
static BOOLEAN jjBRACK_S(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:5773
static BOOLEAN jjUMINUS_P(leftv res, leftv u)
Definition iparith.cc:3814
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:4283
static BOOLEAN jjNAMES(leftv res, leftv v)
Definition iparith.cc:4771
static BOOLEAN jjINDEX_P(leftv res, leftv u, leftv v)
Definition iparith.cc:1446
static BOOLEAN jjHIGHCORNER(leftv res, leftv v)
Definition iparith.cc:4276
static BOOLEAN jjEQUAL_Ma(leftv res, leftv u, leftv v)
Definition iparith.cc:1333
static BOOLEAN jjNAMES0(leftv res, leftv)
Definition iparith.cc:8334
#define SIMPL_NORMALIZE
Definition iparith.cc:3337
static BOOLEAN jjLOAD2(leftv, leftv, leftv v)
Definition iparith.cc:2625
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:3668
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:9861
static BOOLEAN jjPROC1(leftv res, leftv u)
Definition iparith.cc:3860
static BOOLEAN jjNOT(leftv res, leftv v)
Definition iparith.cc:4781
static BOOLEAN jjPARSTR1(leftv res, leftv v)
Definition iparith.cc:4825
static BOOLEAN jjSUBST_Id_N(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6903
static BOOLEAN jjJET4(leftv res, leftv u)
Definition iparith.cc:7959
static BOOLEAN jjOPPOSE(leftv res, leftv a, leftv b)
Definition iparith.cc:2982
static BOOLEAN jjMOD_P(leftv res, leftv u, leftv v)
Definition iparith.cc:2715
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:9200
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:2400
static BOOLEAN jjHOMOG1(leftv res, leftv v)
Definition iparith.cc:4353
static BOOLEAN jjDET(leftv res, leftv v)
Definition iparith.cc:4081
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:3991
static BOOLEAN jjPLUS_V(leftv res, leftv u, leftv v)
Definition iparith.cc:776
#define SIMPL_LMDIV
Definition iparith.cc:3338
int iiTokType(int op)
Definition iparith.cc:229
static BOOLEAN jjKoszul_Id(leftv res, leftv u, leftv v)
Definition iparith.cc:2577
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:10194
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:2483
static BOOLEAN jjSBA_2(leftv res, leftv v, leftv u, leftv t)
Definition iparith.cc:5119
static BOOLEAN jjINDEX_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1410
char si_char_2[2]
Definition iparith.cc:9860
unsigned nCmdUsed
number of commands used
Definition iparith.cc:187
static BOOLEAN jjRING_LIST(leftv res, leftv v)
Definition iparith.cc:4992
static BOOLEAN jjBRACK_SM(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:5873
static BOOLEAN jjSUBST_Test(leftv v, leftv w, int &ringvar, poly &monomexpr)
Definition iparith.cc:6775
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:2546
static BOOLEAN jjVARSTR1(leftv res, leftv v)
Definition iparith.cc:5473
char * iiArithGetCmd(int nPos)
Definition iparith.cc:10048
static BOOLEAN jjSTATUS_M(leftv res, leftv v)
Definition iparith.cc:8755
static BOOLEAN jjCALL1ARG(leftv res, leftv v)
Definition iparith.cc:7322
static BOOLEAN jjPRUNE_MAP(leftv res, leftv v, leftv ma)
Definition iparith.cc:3055
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:8216
static BOOLEAN jjPLUSMINUS_Gen(leftv res, leftv u, leftv v)
Definition iparith.cc:630
static BOOLEAN jjCALL2ARG(leftv res, leftv u)
Definition iparith.cc:7326
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:9837
static BOOLEAN jjSYZYGY(leftv res, leftv v)
Definition iparith.cc:5205
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:8042
static BOOLEAN jjSUBST_M(leftv res, leftv u)
Definition iparith.cc:8786
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:4651
static BOOLEAN jjPlural_num_mat(leftv res, leftv a, leftv b)
Definition iparith.cc:2854
static BOOLEAN jjIDEAL_PL(leftv res, leftv v)
Definition iparith.cc:7462
static BOOLEAN jjNVARS(leftv res, leftv v)
Definition iparith.cc:4786
static BOOLEAN jjERROR(leftv, leftv u)
Definition iparith.cc:1997
static BOOLEAN jjSTATUS2(leftv res, leftv u, leftv v)
Definition iparith.cc:3428
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:4985
BOOLEAN iiConvert(int inputType, int outputType, int index, leftv input, leftv output, const struct sConvertTypes *dConvertTypes)
Definition ipconv.cc:450
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:627
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition ipid.cc:256
VAR package basePack
Definition ipid.cc:56
VAR idhdl currRingHdl
Definition ipid.cc:57
VAR package currPack
Definition ipid.cc:55
lists ipNameList(idhdl root)
Definition ipid.cc:604
#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:2147
lists rDecompose_list_cf(const ring r)
Definition ipshell.cc:2108
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:6569
ring rInit(leftv pn, leftv rv, leftv ord)
Definition ipshell.cc:5621
leftv iiMap(map theMap, const char *what)
Definition ipshell.cc:614
int iiRegularity(lists L)
Definition ipshell.cc:1041
BOOLEAN rDecompose_CF(leftv res, const coeffs C)
Definition ipshell.cc:1937
void iiMakeResolv(resolvente r, int length, int rlen, char *name, int typ0, intvec **weights)
Definition ipshell.cc:850
void killlocals(int v)
Definition ipshell.cc:387
int exprlist_length(leftv v)
Definition ipshell.cc:551
BOOLEAN mpKoszul(leftv res, leftv c, leftv b, leftv id)
Definition ipshell.cc:3080
poly iiHighCorner(ideal I, int ak)
Definition ipshell.cc:1601
lists scIndIndset(ideal S, BOOLEAN all, ideal Q)
Definition ipshell.cc:1107
idhdl rFindHdl(ring r, idhdl n)
Definition ipshell.cc:1695
syStrategy syConvList(lists li)
Definition ipshell.cc:3244
void test_cmd(int i)
Definition ipshell.cc:513
ring rCompose(const lists L, const BOOLEAN check_comp, const long bitmask, const int isLetterplace)
Definition ipshell.cc:2776
const char * lastreserved
Definition ipshell.cc:83
lists syConvRes(syStrategy syzstr, BOOLEAN toDel, int add_row_shift)
Definition ipshell.cc:3172
void rSetHdl(idhdl h)
Definition ipshell.cc:5122
BOOLEAN iiExport(leftv v, int toLev)
Definition ipshell.cc:1506
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:147
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:136
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:124
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:325
long kHomModDeg(poly p, const ring r)
Definition kstd1.cc:2417
ideal kMin_std2(ideal F, ideal Q, tHomog h, intvec **w, ideal &M, bigintmat *hilb, int syzComp, int reduced)
Definition kstd1.cc:3064
ideal kInterRed(ideal F, const ideal Q)
Definition kstd1.cc:3797
ideal kStd2(ideal F, ideal Q, tHomog h, intvec **w, bigintmat *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
generic interface to GB/SB computations, large hilbert vectors
Definition kstd1.cc:2602
ideal kSba(ideal F, ideal Q, tHomog h, intvec **w, int sbaOrder, int arri, bigintmat *hilb, int syzComp, int newIdeal, intvec *vw)
Definition kstd1.cc:2663
VAR intvec * kHomW
Definition kstd1.cc:2405
VAR intvec * kModW
Definition kstd1.cc:2405
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition kstd1.cc:3224
EXTERN_VAR int Kstd1_deg
Definition kstd1.h:70
ideal rightgb(ideal F, const ideal Q)
Definition kstd2.cc:4958
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:403
ideal idSubstPoly(ideal id, int n, poly e)
Definition maps_ip.cc:425
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:386
poly pSubstPar(poly p, int par, poly image)
Definition maps_ip.cc:266
BOOLEAN mp_IsDiagUnit(matrix U, const ring R)
Definition matpol.cc:810
matrix mp_Wedge(matrix a, int ar, const ring R)
Definition matpol.cc:1745
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:1827
ideal sm_Add(ideal a, ideal b, const ring R)
Definition matpol.cc:1867
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:2108
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:2163
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:1877
ideal sm_Mult(ideal a, ideal b, const ring R)
Definition matpol.cc:1887
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:2139
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:637
BOOLEAN sm_Equal(ideal a, ideal b, const ring R)
Definition matpol.cc:1999
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:656
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:389
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:4674
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:3729
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:4815
void p_Normalize(poly p, const ring r)
Definition p_polys.cc:3894
int p_MaxExpPerVar(poly p, int i, const ring r)
max exponent of variable x_i in p
Definition p_polys.cc:5101
int p_Compare(const poly a, const poly b, const ring R)
Definition p_polys.cc:5005
poly p_Series(int n, poly p, poly u, intvec *w, const ring R)
Definition p_polys.cc:4607
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:3653
void p_SetModDeg(intvec *w, ring r)
Definition p_polys.cc:3753
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:3717
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:1109
static int pLength(poly a)
Definition p_polys.h:190
static long p_MinComp(poly p, ring lmRing, ring tailRing)
Definition p_polys.h:315
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition p_polys.h:1162
static long p_Totaldegree(poly p, const ring r)
Definition p_polys.h:1523
void rChangeCurrRing(ring r)
Definition polys.cc:16
VAR coeffs coeffs_BIGINT
Definition polys.cc:14
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:177
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:383
Compatibility layer for legacy polynomial operations (over currRing)
#define pAdd(p, q)
Definition polys.h:204
static long pTotaldegree(poly p)
Definition polys.h:283
#define pDelete(p_ptr)
Definition polys.h:187
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL
Definition polys.h:68
#define pSetm(p)
Definition polys.h:272
#define pIsConstant(p)
like above, except that Comp must be 0
Definition polys.h:239
#define pSplit(p, r)
Definition polys.h:266
#define pNeg(p)
Definition polys.h:199
#define pGetComp(p)
Component.
Definition polys.h:38
#define pDiff(a, b)
Definition polys.h:297
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
Definition polys.h:32
void pNorm(poly p)
Definition polys.h:363
#define pNSet(n)
Definition polys.h:314
#define pVar(m)
Definition polys.h:381
#define pJet(p, m)
Definition polys.h:368
#define pSub(a, b)
Definition polys.h:288
#define ppMult_qq(p, q)
Definition polys.h:209
#define ppJetW(p, m, iv)
Definition polys.h:369
#define pMaxComp(p)
Definition polys.h:300
#define pLmInit(p)
like pInit, except that expvector is initialized to that of p, p must be != NULL
Definition polys.h:65
#define pIsUnit(p)
return true if the Lm is a constant <>0
Definition polys.h:241
#define pPower(p, q)
Definition polys.h:205
#define pSetComp(p, v)
Definition polys.h:39
#define pLmDelete(p)
assume p != NULL, deletes Lm(p)->coef and Lm(p)
Definition polys.h:77
#define pMult(p, q)
Definition polys.h:208
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:71
#define pSubst(p, n, e)
Definition polys.h:366
#define pSeries(n, p, u, w)
Definition polys.h:372
#define pGetExp(p, i)
Exponent.
Definition polys.h:42
#define pNormalize(p)
Definition polys.h:318
#define pInit()
allocates a new monomial and initializes everything to 0
Definition polys.h:62
#define pEqualPolys(p1, p2)
Definition polys.h:400
#define pSetExp(p, i, v)
Definition polys.h:43
#define pLmCmp(p, q)
returns 0|1|-1 if p=q|p>q|p<q w.r.t monomial ordering
Definition polys.h:106
#define pCopy(p)
return a copy of the poly
Definition polys.h:186
#define pLmFreeAndNext(p)
assumes p != NULL, deletes p, returns pNext(p)
Definition polys.h:75
#define pOne()
Definition polys.h:316
#define pIsUnivariate(p)
Definition polys.h:250
#define pISet(i)
Definition polys.h:313
#define pWTotaldegree(p)
Definition polys.h:284
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:1407
int r_IsRingVar(const char *n, char **names, int N)
Definition ring.cc:213
int rChar(ring r)
Definition ring.cc:718
ring rMinusVar(const ring r, char *v)
undo rPlusVar
Definition ring.cc:6024
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:1804
char * rParStr(ring r)
Definition ring.cc:654
char * rCharStr(const ring r)
TODO: make it a virtual method of coeffs, together with: Decompose & Compose, rParameter & rPar.
Definition ring.cc:652
ring rOpposite(ring src)
Definition ring.cc:5425
char * rOrdStr(ring r)
Definition ring.cc:526
void rDelete(ring r)
unconditionally deletes fields in r
Definition ring.cc:454
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:628
ring rPlusVar(const ring r, char *v, int left)
K[x],"y" -> K[x,y] resp. K[y,x].
Definition ring.cc:5942
ring rEnvelope(ring R)
Definition ring.cc:5819
int n_IsParam(const number m, const ring r)
TODO: rewrite somehow...
Definition ring.cc:5921
ring rCopy(ring r)
Definition ring.cc:1736
static BOOLEAN rField_is_Zp_a(const ring r)
Definition ring.h:535
static BOOLEAN rField_is_Z(const ring r)
Definition ring.h:515
static BOOLEAN rField_is_Zp(const ring r)
Definition ring.h:506
static BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition ring.h:769
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition ring.h:406
long(* pFDegProc)(poly p, ring r)
Definition ring.h:39
static ring rIncRefCnt(ring r)
Definition ring.h:849
static BOOLEAN rField_is_Domain(const ring r)
Definition ring.h:493
long(* pLDegProc)(poly p, int *length, ring r)
Definition ring.h:38
static int rPar(const ring r)
(r->cf->P)
Definition ring.h:605
static BOOLEAN rIsLPRing(const ring r)
Definition ring.h:417
@ ringorder_lp
Definition ring.h:78
@ ringorder_dp
Definition ring.h:79
static BOOLEAN rField_is_Q(const ring r)
Definition ring.h:512
static char const ** rParameter(const ring r)
(r->cf->parameter)
Definition ring.h:631
static BOOLEAN rField_is_numeric(const ring r)
Definition ring.h:521
static BOOLEAN rField_is_GF(const ring r)
Definition ring.h:527
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition ring.h:598
static BOOLEAN rHasMixedOrdering(const ring r)
Definition ring.h:770
#define rField_is_Ring(R)
Definition ring.h:491
idrec * idhdl
Definition ring.h:22
void sBucket_Add_p(sBucket_pt bucket, poly p, int length)
adds poly p to bucket destroys p!
Definition sbuckets.cc: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:53
tHomog
Definition structs.h:31
@ isHomog
Definition structs.h:33
@ testHomog
Definition structs.h:34
@ isNotHomog
Definition structs.h:32
EXTERN_VAR omBin char_ptr_bin
Definition structs.h:73
#define loop
Definition structs.h:71
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