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