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