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 ALLOW_NC ALLOW_LP|ALLOW_PLURAL
108
109#define ALLOW_ZZ (ALLOW_RING|NO_ZERODIVISOR)
110
111
112// bit 4 for warning, if used at toplevel
113#define WARN_RING 16
114// bit 5: do no try automatic conversions
115#define NO_CONVERSION 32
116
117static BOOLEAN check_valid(const int p, const int op);
118
119#define bit31 SIZEOF_LONG*8-1
120
121/*=============== types =====================*/
123{
124 short cmd;
125 short start;
126};
127
129
130struct _scmdnames
131{
132 char *name;
133 short alias;
134 short tokval;
135 short toktype;
136};
137typedef struct _scmdnames cmdnames;
138
139struct sValCmd1
140{
142 short cmd;
143 short res;
144 short arg;
145 short valid_for;
146};
147
149struct sValCmd2
150{
152 short cmd;
153 short res;
154 short arg1;
155 short arg2;
156 short valid_for;
157};
158
160struct sValCmd3
161{
163 short cmd;
164 short res;
165 short arg1;
166 short arg2;
167 short arg3;
168 short valid_for;
169};
170struct sValCmdM
171{
173 short cmd;
174 short res;
175 short number_of_args; /* -1: any, -2: any >0, .. */
176 short valid_for;
177};
178
179typedef struct
180{
181 cmdnames *sCmds; /**< array of existing commands */
186 unsigned nCmdUsed; /**< number of commands used */
187 unsigned nCmdAllocated; /**< number of commands-slots allocated */
188 unsigned nLastIdentifier; /**< valid identifiers are slot 1..nLastIdentifier */
189} SArithBase;
190
191/*---------------------------------------------------------------------*
192 * File scope Variables (Variables share by several functions in
193 * the same file )
194 *
195 *---------------------------------------------------------------------*/
196STATIC_VAR SArithBase sArithBase; /**< Base entry for arithmetic */
197
198/*---------------------------------------------------------------------*
199 * Extern Functions declarations
200 *
201 *---------------------------------------------------------------------*/
202static int _gentable_sort_cmds(const void *a, const void *b);
203extern int iiArithRemoveCmd(char *szName);
204extern int iiArithAddCmd(const char *szName, short nAlias, short nTokval,
205 short nToktype, short nPos=-1);
206
207/*============= proc =======================*/
208static int iiTabIndex(const jjValCmdTab dArithTab, const int len, const int op);
209static Subexpr jjMakeSub(leftv e);
210
211/*============= vars ======================*/
214
215#define ii_div_by_0 "div. by 0"
216
217VAR int iiOp; /* the current operation*/
218
219/*=================== simple helpers =================*/
220static int iin_Int(number &n,coeffs cf)
221{
222 long l=n_Int(n,cf);
223 int i=(int)l;
224 if ((long)i==l) return l;
225 return 0;
226}
227
228int iiTokType(int op)
229{
230 for (unsigned i=0;i<sArithBase.nCmdUsed;i++)
231 {
232 if (sArithBase.sCmds[i].tokval==op)
233 return sArithBase.sCmds[i].toktype;
234 }
235 return 0;
236}
237
238/*=================== operations with 2 args.: static proc =================*/
239/* must be ordered: first operations for chars (infix ops),
240 * then alphabetically */
241
243{
244 bigintmat* aa= (bigintmat *)u->Data();
245 long bb = (long)(v->Data());
246 if (errorreported) return TRUE;
248 switch (iiOp)
249 {
250 case '+': cc=bimAdd(aa,bb); break;
251 case '-': cc=bimSub(aa,bb); break;
252 case '*': cc=bimMult(aa,bb); break;
253 }
254 res->data=(char *)cc;
255 return cc==NULL;
256}
258{
259 return jjOP_BIM_I(res, v, u);
260}
262{
263 bigintmat* aa= (bigintmat *)u->Data();
264 number bb = (number)(v->Data());
265 if (errorreported) return TRUE;
267 switch (iiOp)
268 {
269 case '*': cc=bimMult(aa,bb,coeffs_BIGINT); break;
270 }
271 res->data=(char *)cc;
272 return cc==NULL;
273}
275{
276 return jjOP_BIM_BI(res, v, u);
277}
279{
281 int bb = (int)(long)(v->Data());
282 if (errorreported) return TRUE;
283 switch (iiOp)
284 {
285 case '+': (*aa) += bb; break;
286 case '-': (*aa) -= bb; break;
287 case '*': (*aa) *= bb; break;
288 case '/':
289 case INTDIV_CMD: (*aa) /= bb; break;
290 case '%': (*aa) %= bb; break;
291 }
292 res->data=(char *)aa;
293 return FALSE;
294}
296{
297 return jjOP_IV_I(res,v,u);
298}
300{
302 int bb = (int)(long)(v->Data());
303 int i=si_min(aa->rows(),aa->cols());
304 switch (iiOp)
305 {
306 case '+': for (;i>0;i--) IMATELEM(*aa,i,i) += bb;
307 break;
308 case '-': for (;i>0;i--) IMATELEM(*aa,i,i) -= bb;
309 break;
310 }
311 res->data=(char *)aa;
312 return FALSE;
313}
315{
316 return jjOP_IM_I(res,v,u);
317}
319{
320 int l=(int)(long)v->Data();
321 if (l>=0)
322 {
323 int d=(int)(long)u->Data();
324 intvec *vv=new intvec(l);
325 int i;
326 for(i=l-1;i>=0;i--) { (*vv)[i]=d; }
327 res->data=(char *)vv;
328 }
329 return (l<0);
330}
332{
333 res->data=(char *)new intvec((int)(long)u->Data(),(int)(long)v->Data());
334 return FALSE;
335}
336static void jjEQUAL_REST(leftv res,leftv u,leftv v);
338{
339 intvec* a = (intvec * )(u->Data());
340 intvec* b = (intvec * )(v->Data());
341 int r=a->compare(b);
342 switch (iiOp)
343 {
344 case '<':
345 res->data = (char *) (r<0);
346 break;
347 case '>':
348 res->data = (char *) (r>0);
349 break;
350 case LE:
351 res->data = (char *) (r<=0);
352 break;
353 case GE:
354 res->data = (char *) (r>=0);
355 break;
356 case EQUAL_EQUAL:
357 case NOTEQUAL: /* negation handled by jjEQUAL_REST */
358 res->data = (char *) (r==0);
359 break;
360 }
361 jjEQUAL_REST(res,u,v);
362 if(r==-2) { WerrorS("size incompatible"); return TRUE; }
363 return FALSE;
364}
366{
367 bigintmat* a = (bigintmat * )(u->Data());
368 bigintmat* b = (bigintmat * )(v->Data());
369 int r=a->compare(b);
370 switch (iiOp)
371 {
372 #if 0
373 case '<':
374 res->data = (char *) (r<0);
375 break;
376 case '>':
377 res->data = (char *) (r>0);
378 break;
379 case LE:
380 res->data = (char *) (r<=0);
381 break;
382 case GE:
383 res->data = (char *) (r>=0);
384 break;
385 #endif
386 case EQUAL_EQUAL:
387 case NOTEQUAL: /* negation handled by jjEQUAL_REST */
388 res->data = (char *) (r==0);
389 break;
390 }
391 jjEQUAL_REST(res,u,v);
392 if(r==-2) { WerrorS("size incompatible"); return TRUE; }
393 return FALSE;
394}
396{
397 intvec* a = (intvec * )(u->Data());
398 int b = (int)(long)(v->Data());
399 int r=a->compare(b);
400 switch (iiOp)
401 {
402 case '<':
403 res->data = (char *) (r<0);
404 break;
405 case '>':
406 res->data = (char *) (r>0);
407 break;
408 case LE:
409 res->data = (char *) (r<=0);
410 break;
411 case GE:
412 res->data = (char *) (r>=0);
413 break;
414 case EQUAL_EQUAL:
415 case NOTEQUAL: /* negation handled by jjEQUAL_REST */
416 res->data = (char *) (r==0);
417 break;
418 }
419 jjEQUAL_REST(res,u,v);
420 return FALSE;
421}
423{
424 //Print("in: >>%s<<\n",my_yylinebuf);
425 matrix a=(matrix)u->Data();
426 matrix b=(matrix)v->Data();
427 int r=mp_Compare(a,b,currRing);
428 switch (iiOp)
429 {
430 case '<':
431 res->data = (char *) (long)(r < 0);
432 break;
433 case '>':
434 res->data = (char *) (long)(r > 0);
435 break;
436 case LE:
437 res->data = (char *) (long)(r <= 0);
438 break;
439 case GE:
440 res->data = (char *) (long)(r >= 0);
441 break;
442 case EQUAL_EQUAL:
443 case NOTEQUAL: /* negation handled by jjEQUAL_REST */
444 res->data = (char *)(long) (r == 0);
445 break;
446 }
447 jjEQUAL_REST(res,u,v);
448 return FALSE;
449}
451{
452 poly p=(poly)u->Data();
453 poly q=(poly)v->Data();
454 int r=p_Compare(p,q,currRing);
455 switch (iiOp)
456 {
457 case '<':
458 res->data = (char *) (r < 0);
459 break;
460 case '>':
461 res->data = (char *) (r > 0);
462 break;
463 case LE:
464 res->data = (char *) (r <= 0);
465 break;
466 case GE:
467 res->data = (char *) (r >= 0);
468 break;
469 //case EQUAL_EQUAL:
470 //case NOTEQUAL: /* negation handled by jjEQUAL_REST */
471 // res->data = (char *) (r == 0);
472 // break;
473 }
474 jjEQUAL_REST(res,u,v);
475 return FALSE;
476}
478{
479 char* a = (char * )(u->Data());
480 char* b = (char * )(v->Data());
481 int result = strcmp(a,b);
482 switch (iiOp)
483 {
484 case '<':
485 res->data = (char *) (result < 0);
486 break;
487 case '>':
488 res->data = (char *) (result > 0);
489 break;
490 case LE:
491 res->data = (char *) (result <= 0);
492 break;
493 case GE:
494 res->data = (char *) (result >= 0);
495 break;
496 case EQUAL_EQUAL:
497 case NOTEQUAL: /* negation handled by jjEQUAL_REST */
498 res->data = (char *) (result == 0);
499 break;
500 }
501 jjEQUAL_REST(res,u,v);
502 return FALSE;
503}
505{
506 if (u->Next()!=NULL)
507 {
508 u=u->next;
509 res->next = (leftv)omAllocBin(sleftv_bin);
510 return iiExprArith2(res->next,u,iiOp,v);
511 }
512 else if (v->Next()!=NULL)
513 {
514 v=v->next;
515 res->next = (leftv)omAllocBin(sleftv_bin);
516 return iiExprArith2(res->next,u,iiOp,v);
517 }
518 return FALSE;
519}
521{
522 long b=(long)u->Data();
523 long e=(long)v->Data();
524 long rc = 1;
525 BOOLEAN overflow=FALSE;
526 if (e >= 0)
527 {
528 if (b==0)
529 {
530 rc=(e==0);
531 }
532 else if ((e==0)||(b==1))
533 {
534 rc= 1;
535 }
536 else if (b== -1)
537 {
538 if (e&1) rc= -1;
539 else rc= 1;
540 }
541 else
542 {
543 long oldrc;
544 while ((e--)!=0)
545 {
546 oldrc=rc;
547 rc *= b;
548 if (!overflow)
549 {
550 if(rc/b!=oldrc) overflow=TRUE;
551 }
552 }
553 if (overflow)
554 WarnS("int overflow(^), result may be wrong");
555 }
556 res->data = (char *)rc;
557 if (u!=NULL) return jjOP_REST(res,u,v);
558 return FALSE;
559 }
560 else
561 {
562 WerrorS("exponent must be non-negative");
563 return TRUE;
564 }
565}
567{
568 int e=(int)(long)v->Data();
569 number n=(number)u->Data();
570 if (e>=0)
571 {
572 n_Power(n,e,(number*)&res->data,coeffs_BIGINT);
573 }
574 else
575 {
576 WerrorS("exponent must be non-negative");
577 return TRUE;
578 }
579 if (u!=NULL) return jjOP_REST(res,u,v);
580 return FALSE;
581}
583{
584 int e=(int)(long)v->Data();
585 number n=(number)u->Data();
586 int d=0;
587 if (e<0)
588 {
589 n=nInvers(n);
590 e=-e;
591 d=1;
592 }
593 number r;
594 nPower(n,e,(number*)&r);
595 res->data=(char*)r;
596 if (d) nDelete(&n);
597 if (u!=NULL) return jjOP_REST(res,u,v);
598 return FALSE;
599}
601{
602 int v_i=(int)(long)v->Data();
603 if (v_i<0)
604 {
605 WerrorS("exponent must be non-negative");
606 return TRUE;
607 }
608 poly u_p=(poly)u->CopyD(POLY_CMD);
609 if ((u_p!=NULL)
610 && (!rIsLPRing(currRing))
611 && ((v_i!=0) &&
612 ((long)pTotaldegree(u_p) > (signed long)currRing->bitmask / (signed long)v_i/2)))
613 {
614 Werror("OVERFLOW in power(d=%ld, e=%d, max=%ld)",
615 pTotaldegree(u_p),v_i,currRing->bitmask/2);
616 pDelete(&u_p);
617 return TRUE;
618 }
619 res->data = (char *)pPower(u_p,v_i);
620 if (u!=NULL) return jjOP_REST(res,u,v);
621 return errorreported; /* pPower may set errorreported via Werror */
622}
624{
625 res->data = (char *)id_Power((ideal)(u->Data()),(int)(long)(v->Data()), currRing);
626 if (u!=NULL) return jjOP_REST(res,u,v);
627 return FALSE;
628}
630{
631 u=u->next;
632 v=v->next;
633 if (u==NULL)
634 {
635 if (v==NULL) return FALSE; /* u==NULL, v==NULL */
636 if (iiOp=='-') /* u==NULL, v<>NULL, iiOp=='-'*/
637 {
638 do
639 {
640 if (res->next==NULL)
642 leftv tmp_v=v->next;
643 v->next=NULL;
644 BOOLEAN b=iiExprArith1(res->next,v,'-');
645 v->next=tmp_v;
646 if (b)
647 return TRUE;
648 v=tmp_v;
649 res=res->next;
650 } while (v!=NULL);
651 return FALSE;
652 }
653 loop /* u==NULL, v<>NULL, iiOp=='+' */
654 {
656 res=res->next;
657 res->data = v->CopyD();
658 res->rtyp = v->Typ();
659 v=v->next;
660 if (v==NULL) return FALSE;
661 }
662 }
663 if (v!=NULL) /* u<>NULL, v<>NULL */
664 {
665 do
666 {
668 leftv tmp_u=u->next; u->next=NULL;
670 BOOLEAN b=iiExprArith2(res->next,u,iiOp,v);
671 u->next=tmp_u;
672 v->next=tmp_v;
673 if (b)
674 return TRUE;
675 u=tmp_u;
676 v=tmp_v;
677 res=res->next;
678 } while ((u!=NULL) && (v!=NULL));
679 return FALSE;
680 }
681 loop /* u<>NULL, v==NULL */
682 {
684 res=res->next;
685 res->data = u->CopyD();
686 res->rtyp = u->Typ();
687 u=u->next;
688 if (u==NULL) return FALSE;
689 }
690}
692{
693 switch(u->Typ())
694 {
695 case 0:
696 {
697 int name_err=0;
698 if(isupper(u->name[0]))
699 {
700 const char *c=u->name+1;
701 while((*c!='\0')&&(islower(*c)||(isdigit(*c))||(*c=='_'))) c++;
702 if (*c!='\0')
703 name_err=1;
704 else
705 {
706 Print("%s of type 'ANY'. Trying load.\n", u->name);
707 if(iiTryLoadLib(u, u->name))
708 {
709 Werror("'%s' no such package", u->name);
710 return TRUE;
711 }
712 syMake(u,u->name,NULL);
713 }
714 }
715 else name_err=1;
716 if(name_err)
717 { Werror("'%s' is an invalid package name",u->name);return TRUE;}
718 // and now, after the loading: use next case !!! no break !!!
719 }
720 case PACKAGE_CMD:
721 {
722 package pa=(package)u->Data();
723 if (u->rtyp==IDHDL) pa=IDPACKAGE((idhdl)u->data);
724 if((!pa->loaded)
725 && (pa->language > LANG_TOP))
726 {
727 Werror("'%s' not loaded", u->name);
728 return TRUE;
729 }
730 if(v->rtyp == IDHDL)
731 {
732 v->name = omStrDup(v->name);
733 }
734 else if (v->rtyp!=0)
735 {
736 WerrorS("reserved name with ::");
737 return TRUE;
738 }
739 v->req_packhdl=pa;
740 syMake(v, v->name, pa);
741 memcpy(res, v, sizeof(sleftv));
742 v->Init();
743 }
744 break;
745 case DEF_CMD:
746 break;
747 default:
748 WerrorS("<package>::<id> expected");
749 return TRUE;
750 }
751 return FALSE;
752}
754{
755 unsigned long a=(unsigned long)u->Data();
756 unsigned long b=(unsigned long)v->Data();
757 unsigned long c=a+b;
758 res->data = (char *)((long)c);
759 if (((Sy_bitL(bit31)&a)==(Sy_bitL(bit31)&b))&&((Sy_bitL(bit31)&a)!=(Sy_bitL(bit31)&c)))
760 {
761 WarnS("int overflow(+), result may be wrong");
762 }
763 return jjPLUSMINUS_Gen(res,u,v);
764}
766{
767 res->data = (char *)(n_Add((number)u->Data(), (number)v->Data(),coeffs_BIGINT));
768 return jjPLUSMINUS_Gen(res,u,v);
769}
771{
772 res->data = (char *)(nAdd((number)u->Data(), (number)v->Data()));
773 return jjPLUSMINUS_Gen(res,u,v);
774}
776{
777 res->data = (char *)(pAdd((poly)u->CopyD(POLY_CMD) , (poly)v->CopyD(POLY_CMD)));
778 return jjPLUSMINUS_Gen(res,u,v);
779}
781{
782 //res->data = (char *)(pAdd((poly)u->CopyD(POLY_CMD) , (poly)v->CopyD(POLY_CMD)));
784 poly p=(poly)u->CopyD(POLY_CMD);
785 int l=pLength(p);
787 p= (poly)v->CopyD(POLY_CMD);
788 l=pLength(p);
790 res->data=(void*)b;
791 return jjPLUSMINUS_Gen(res,u,v);
792}
794{
796 poly p= (poly)v->CopyD(POLY_CMD);
797 int l=pLength(p);
799 res->data=(void*)b;
800 return jjPLUSMINUS_Gen(res,u,v);
801}
803{
804 res->data = (char *)ivAdd((intvec*)(u->Data()), (intvec*)(v->Data()));
805 if (res->data==NULL)
806 {
807 WerrorS("intmat size not compatible");
808 return TRUE;
809 }
810 return jjPLUSMINUS_Gen(res,u,v);
811}
813{
814 res->data = (char *)bimAdd((bigintmat*)(u->Data()), (bigintmat*)(v->Data()));
815 if (res->data==NULL)
816 {
817 WerrorS("bigintmat/cmatrix not compatible");
818 return TRUE;
819 }
820 return jjPLUSMINUS_Gen(res,u,v);
821}
823{
824 matrix A=(matrix)u->Data(); matrix B=(matrix)v->Data();
825 res->data = (char *)(mp_Add(A , B, currRing));
826 if (res->data==NULL)
827 {
828 Werror("matrix size not compatible(%dx%d, %dx%d)",
830 return TRUE;
831 }
832 return jjPLUSMINUS_Gen(res,u,v);
833}
835{
836 ideal A=(ideal)u->Data(); ideal B=(ideal)v->Data();
837 res->data = (char *)(sm_Add(A , B, currRing));
838 if (res->data==NULL)
839 {
840 Werror("matrix size not compatible(%dx%d, %dx%d)",
841 (int)A->rank,IDELEMS(A),(int)B->rank,IDELEMS(B));
842 return TRUE;
843 }
844 return jjPLUSMINUS_Gen(res,u,v);
845}
847{
848 matrix m=(matrix)u->Data();
849 matrix p= mp_InitP(m->nrows,m->ncols,(poly)(v->CopyD(POLY_CMD)),currRing);
850 if (iiOp=='+')
851 res->data = (char *)mp_Add(m , p,currRing);
852 else
853 res->data = (char *)mp_Sub(m , p,currRing);
854 idDelete((ideal *)&p);
855 return jjPLUSMINUS_Gen(res,u,v);
856}
858{
859 return jjPLUS_MA_P(res,v,u);
860}
862{
863 char* a = (char * )(u->Data());
864 char* b = (char * )(v->Data());
865 char* r = (char * )omAlloc(strlen(a) + strlen(b) + 1);
866 strcpy(r,a);
867 strcat(r,b);
868 res->data=r;
869 return jjPLUSMINUS_Gen(res,u,v);
870}
872{
873 res->data = (char *)idAdd((ideal)u->Data(),(ideal)v->Data());
874 return jjPLUSMINUS_Gen(res,u,v);
875}
877{
878 void *ap=u->Data(); void *bp=v->Data();
879 long aa=(long)ap;
880 long bb=(long)bp;
881 long cc=aa-bb;
882 unsigned long a=(unsigned long)ap;
883 unsigned long b=(unsigned long)bp;
884 unsigned long c=a-b;
885 if (((Sy_bitL(bit31)&a)!=(Sy_bitL(bit31)&b))&&((Sy_bitL(bit31)&a)!=(Sy_bitL(bit31)&c)))
886 {
887 WarnS("int overflow(-), result may be wrong");
888 }
889 res->data = (char *)cc;
890 return jjPLUSMINUS_Gen(res,u,v);
891}
893{
894 res->data = (char *)(n_Sub((number)u->Data(), (number)v->Data(),coeffs_BIGINT));
895 return jjPLUSMINUS_Gen(res,u,v);
896}
898{
899 res->data = (char *)(nSub((number)u->Data(), (number)v->Data()));
900 return jjPLUSMINUS_Gen(res,u,v);
901}
903{
904 res->data = (char *)(pSub((poly)u->CopyD(POLY_CMD) , (poly)v->CopyD(POLY_CMD)));
905 return jjPLUSMINUS_Gen(res,u,v);
906}
908{
910 poly p= (poly)v->CopyD(POLY_CMD);
911 int l=pLength(p);
912 p=p_Neg(p,currRing);
914 res->data=(void*)b;
915 return jjPLUSMINUS_Gen(res,u,v);
916}
918{
920 poly p=(poly)u->CopyD(POLY_CMD);
921 int l=pLength(p);
923 p= (poly)v->CopyD(POLY_CMD);
924 p=p_Neg(p,currRing);
925 l=pLength(p);
927 res->data=(void*)b;
928 return jjPLUSMINUS_Gen(res,u,v);
929}
931{
932 res->data = (char *)ivSub((intvec*)(u->Data()), (intvec*)(v->Data()));
933 if (res->data==NULL)
934 {
935 WerrorS("intmat size not compatible");
936 return TRUE;
937 }
938 return jjPLUSMINUS_Gen(res,u,v);
939}
941{
942 res->data = (char *)bimSub((bigintmat*)(u->Data()), (bigintmat*)(v->Data()));
943 if (res->data==NULL)
944 {
945 WerrorS("bigintmat/cmatrix not compatible");
946 return TRUE;
947 }
948 return jjPLUSMINUS_Gen(res,u,v);
949}
951{
952 matrix A=(matrix)u->Data(); matrix B=(matrix)v->Data();
953 res->data = (char *)(mp_Sub(A , B, currRing));
954 if (res->data==NULL)
955 {
956 Werror("matrix size not compatible(%dx%d, %dx%d)",
958 return TRUE;
959 }
960 return jjPLUSMINUS_Gen(res,u,v);
961 return FALSE;
962}
964{
965 ideal A=(ideal)u->Data(); ideal B=(ideal)v->Data();
966 res->data = (char *)(sm_Sub(A , B, currRing));
967 if (res->data==NULL)
968 {
969 Werror("matrix size not compatible(%dx%d, %dx%d)",
970 (int)A->rank,IDELEMS(A),(int)B->rank,IDELEMS(B));
971 return TRUE;
972 }
973 return jjPLUSMINUS_Gen(res,u,v);
974 return FALSE;
975}
977{
978 long a=(long)u->Data();
979 long b=(long)v->Data();
980 long c=a * b;
981 if ((a!=0)&&(c/a!=b))
982 WarnS("int overflow(*), result may be wrong");
983 res->data = (char *)c;
984 if ((u->Next()!=NULL) || (v->Next()!=NULL))
985 return jjOP_REST(res,u,v);
986 return FALSE;
987}
989{
990 res->data = (char *)(n_Mult( (number)u->Data(), (number)v->Data(),coeffs_BIGINT));
991 if ((v->next!=NULL) || (u->next!=NULL))
992 return jjOP_REST(res,u,v);
993 return FALSE;
994}
996{
997 res->data = (char *)(nMult( (number)u->Data(), (number)v->Data()));
998 number n=(number)res->data;
999 nNormalize(n);
1000 res->data=(char *)n;
1001 if ((v->next!=NULL) || (u->next!=NULL))
1002 return jjOP_REST(res,u,v);
1003 return FALSE;
1004}
1006{
1007 poly a;
1008 poly b;
1009 if (v->next==NULL)
1010 {
1011 if (u->next==NULL)
1012 {
1013 a=(poly)u->Data(); // works also for VECTOR_CMD
1014 b=(poly)v->Data(); // works also for VECTOR_CMD
1015 if (!rIsLPRing(currRing)
1016 && (a!=NULL) && (b!=NULL)
1017 && ((long)pTotaldegree(a)>si_max((long)rVar(currRing),(long)currRing->bitmask/2)-(long)pTotaldegree(b)))
1018 {
1019 Warn("possible OVERFLOW in mult(d=%ld, d=%ld, max=%ld)",
1020 pTotaldegree(a),pTotaldegree(b),currRing->bitmask/2);
1021 }
1022 res->data = (char *)(pp_Mult_qq( a, b, currRing));
1023 return FALSE;
1024 }
1025 // u->next exists: copy v
1026 a=(poly)u->CopyD(POLY_CMD); // works also for VECTOR_CMD
1027 b=pCopy((poly)v->Data());
1028 if (!rIsLPRing(currRing)
1029 && (a!=NULL) && (b!=NULL)
1030 && (pTotaldegree(a)+pTotaldegree(b)>si_max((long)rVar(currRing),(long)currRing->bitmask/2)))
1031 {
1032 Warn("possible OVERFLOW in mult(d=%ld, d=%ld, max=%ld)",
1033 pTotaldegree(a),pTotaldegree(b),currRing->bitmask/2);
1034 }
1035 res->data = (char *)(pMult( a, b));
1036 return jjOP_REST(res,u,v);
1037 }
1038 // v->next exists: copy u
1039 a=pCopy((poly)u->Data());
1040 b=(poly)v->CopyD(POLY_CMD); // works also for VECTOR_CMD
1041 if ((a!=NULL) && (b!=NULL)
1042 && ((unsigned long)(pTotaldegree(a)+pTotaldegree(b))>=currRing->bitmask/2))
1043 {
1044 pDelete(&a);
1045 pDelete(&b);
1046 WerrorS("OVERFLOW");
1047 return TRUE;
1048 }
1049 res->data = (char *)(pMult( a, b));
1050 return jjOP_REST(res,u,v);
1051}
1053{
1054 res->data = (char *)idMult((ideal)u->Data(),(ideal)v->Data());
1055 if ((v->next!=NULL) || (u->next!=NULL))
1056 return jjOP_REST(res,u,v);
1057 return FALSE;
1058}
1060{
1061 res->data = (char *)ivMult((intvec*)(u->Data()), (intvec*)(v->Data()));
1062 if (res->data==NULL)
1063 {
1064 WerrorS("intmat size not compatible");
1065 return TRUE;
1066 }
1067 if ((v->next!=NULL) || (u->next!=NULL))
1068 return jjOP_REST(res,u,v);
1069 return FALSE;
1070}
1072{
1073 res->data = (char *)bimMult((bigintmat*)(u->Data()), (bigintmat*)(v->Data()));
1074 if (res->data==NULL)
1075 {
1076 WerrorS("bigintmat/cmatrix not compatible");
1077 return TRUE;
1078 }
1079 if ((v->next!=NULL) || (u->next!=NULL))
1080 return jjOP_REST(res,u,v);
1081 return FALSE;
1082}
1084{
1086 if (nMap==NULL) return TRUE;
1087 number n=nMap((number)v->Data(),coeffs_BIGINT,currRing->cf);
1088 poly p=pNSet(n);
1090 res->data = (char *)I;
1091 return FALSE;
1092}
1094{
1095 return jjTIMES_MA_BI1(res,v,u);
1096}
1098{
1099 poly p=(poly)v->CopyD(POLY_CMD);
1100 int r=pMaxComp(p);/* recompute the rank for the case ideal*vector*/
1102 if (r>0) I->rank=r;
1103 res->data = (char *)I;
1104 return FALSE;
1105}
1107{
1108 poly p=(poly)u->CopyD(POLY_CMD);
1109 int r=pMaxComp(p);/* recompute the rank for the case ideal*vector*/
1111 if (r>0) I->rank=r;
1112 res->data = (char *)I;
1113 return FALSE;
1114}
1116{
1117 number n=(number)v->CopyD(NUMBER_CMD);
1118 poly p=pNSet(n);
1119 res->data = (char *)mp_MultP((matrix)u->CopyD(MATRIX_CMD),p,currRing);
1120 return FALSE;
1121}
1123{
1124 return jjTIMES_MA_N1(res,v,u);
1125}
1127{
1128 res->data = (char *)mp_MultI((matrix)u->CopyD(MATRIX_CMD),(long)v->Data(),currRing);
1129 return FALSE;
1130}
1132{
1133 return jjTIMES_MA_I1(res,v,u);
1134}
1136{
1137 matrix A=(matrix)u->Data(); matrix B=(matrix)v->Data();
1138 res->data = (char *)mp_Mult(A,B,currRing);
1139 if (res->data==NULL)
1140 {
1141 Werror("matrix size not compatible(%dx%d, %dx%d) in *",
1143 return TRUE;
1144 }
1145 if ((v->next!=NULL) || (u->next!=NULL))
1146 return jjOP_REST(res,u,v);
1147 return FALSE;
1148}
1150{
1151 ideal A=(ideal)u->Data(); ideal B=(ideal)v->Data();
1152 res->data = (char *)sm_Mult(A,B,currRing);
1153 if (res->data==NULL)
1154 {
1155 Werror("matrix size not compatible(%dx%d, %dx%d) in *",
1156 (int)A->rank,IDELEMS(A),(int)B->rank,IDELEMS(B));
1157 return TRUE;
1158 }
1159 if ((v->next!=NULL) || (u->next!=NULL))
1160 return jjOP_REST(res,u,v);
1161 return FALSE;
1162}
1164{
1165 number h=n_Sub((number)u->Data(),(number)v->Data(),coeffs_BIGINT);
1166 res->data = (char *) (n_GreaterZero(h,coeffs_BIGINT)||(n_IsZero(h,coeffs_BIGINT)));
1168 return FALSE;
1169}
1171{
1172 res->data = (char *)(long)((int)((long)u->Data()) >= (int)((long)v->Data()));
1173 return FALSE;
1174}
1176{
1177 res->data = (char *)(long) (nGreater((number)u->Data(),(number)v->Data())
1178 || nEqual((number)u->Data(),(number)v->Data()));
1179 return FALSE;
1180}
1182{
1183 number h=n_Sub((number)u->Data(),(number)v->Data(),coeffs_BIGINT);
1184 res->data = (char *)(long) (n_GreaterZero(h,coeffs_BIGINT)&&(!n_IsZero(h,coeffs_BIGINT)));
1186 return FALSE;
1187}
1189{
1190 res->data = (char *)(long)((int)((long)u->Data()) > (int)((long)v->Data()));
1191 return FALSE;
1192}
1194{
1195 res->data = (char *)(long)(nGreater((number)u->Data(),(number)v->Data()));
1196 return FALSE;
1197}
1199{
1200 return jjGE_BI(res,v,u);
1201}
1203{
1204 res->data = (char *)(long)((int)((long)u->Data()) <= (int)((long)v->Data()));
1205 return FALSE;
1206}
1208{
1209 return jjGE_N(res,v,u);
1210}
1212{
1213 return jjGT_BI(res,v,u);
1214}
1216{
1217 res->data = (char *)(long)((int)((long)u->Data()) < (int)((long)v->Data()));
1218 return FALSE;
1219}
1221{
1222 return jjGT_N(res,v,u);
1223}
1225{
1226 if (iiOp=='/') Warn("int division with `/`: use `div` instead in line >>%s<<",my_yylinebuf);
1227 long a= (long)u->Data();
1228 long b= (long)v->Data();
1229 if (b==0)
1230 {
1232 return TRUE;
1233 }
1234 long c=a%b;
1235 long r=0;
1236 switch (iiOp)
1237 {
1238 case '%':
1239 r=c; break;
1240 case '/':
1241 case INTDIV_CMD:
1242 r=((a-c) /b); break;
1243 }
1244 res->data=(void *)r;
1245 return FALSE;
1246}
1248{
1249 number q=(number)v->Data();
1250 if (n_IsZero(q,coeffs_BIGINT))
1251 {
1253 return TRUE;
1254 }
1255 q = n_Div((number)u->Data(),q,coeffs_BIGINT);
1257 res->data = (char *)q;
1258 return FALSE;
1259}
1261{
1262 number q=(number)v->Data();
1263 if (nIsZero(q))
1264 {
1266 return TRUE;
1267 }
1268 q = nDiv((number)u->Data(),q);
1269 nNormalize(q);
1270 res->data = (char *)q;
1271 return FALSE;
1272}
1274{
1275 poly q=(poly)v->Data();
1276 poly p=(poly)(u->Data());
1277 if (q!=NULL)
1278 {
1279 res->data=(void*)(pp_Divide(p /*(poly)(u->Data())*/ ,
1280 q /*(poly)(v->Data())*/ ,currRing));
1281 if (res->data!=NULL) pNormalize((poly)res->data);
1282 return errorreported; /*there may be errors in p_Divide: div. ny 0, etc.*/
1283 }
1284 else
1285 {
1286 WerrorS("div. by 0");
1287 return TRUE;
1288 }
1289
1290}
1292{
1293 poly q=(poly)v->Data();
1294 if (q==NULL)
1295 {
1297 return TRUE;
1298 }
1299 matrix m=(matrix)(u->Data());
1300 int r=m->rows();
1301 int c=m->cols();
1302 matrix mm=mpNew(r,c);
1303 unsigned i,j;
1304 for(i=r;i>0;i--)
1305 {
1306 for(j=c;j>0;j--)
1307 {
1308 if (pNext(q)!=NULL)
1309 {
1311 q /*(poly)(v->Data())*/, currRing );
1312 }
1313 else
1315 }
1316 }
1317 res->data=(char *)mm;
1318 return FALSE;
1319}
1321{
1322 res->data = (char *)((long)n_Equal((number)u->Data(),(number)v->Data(),coeffs_BIGINT));
1323 jjEQUAL_REST(res,u,v);
1324 return FALSE;
1325}
1327{
1328 res->data = (char *)((int)((long)u->Data()) == (int)((long)v->Data()));
1329 jjEQUAL_REST(res,u,v);
1330 return FALSE;
1331}
1333{
1334 res->data = (char *)((long)mp_Equal((matrix)u->Data(),(matrix)v->Data(),currRing));
1335 jjEQUAL_REST(res,u,v);
1336 return FALSE;
1337}
1339{
1340 res->data = (char *)((long)sm_Equal((ideal)u->Data(),(ideal)v->Data(),currRing));
1341 jjEQUAL_REST(res,u,v);
1342 return FALSE;
1343}
1345{
1346 res->data = (char *)(long)(u->Data()==v->Data());
1347 jjEQUAL_REST(res,u,v);
1348 return FALSE;
1349}
1351{
1352 res->data = (char *)((long)nEqual((number)u->Data(),(number)v->Data()));
1353 jjEQUAL_REST(res,u,v);
1354 return FALSE;
1355}
1357{
1358 poly p=(poly)u->Data();
1359 poly q=(poly)v->Data();
1360 res->data = (char *) ((long)pEqualPolys(p,q));
1361 jjEQUAL_REST(res,u,v);
1362 return FALSE;
1363}
1365{
1366 if ((res->data) && (u->next!=NULL) && (v->next!=NULL))
1367 {
1368 int save_iiOp=iiOp;
1369 if (iiOp==NOTEQUAL)
1371 else
1374 }
1375 if (iiOp==NOTEQUAL) res->data=(char *)(!(long)res->data);
1376}
1378{
1379 res->data = (char *)((long)u->Data() && (long)v->Data());
1380 return FALSE;
1381}
1383{
1384 res->data = (char *)((long)u->Data() || (long)v->Data());
1385 return FALSE;
1386}
1388{
1389 res->rtyp=u->rtyp; u->rtyp=0;
1390 res->data=u->data; u->data=NULL;
1391 res->name=u->name; u->name=NULL;
1392 res->e=u->e; u->e=NULL;
1393 if (res->e==NULL) res->e=jjMakeSub(v);
1394 else
1395 {
1396 Subexpr sh=res->e;
1397 while (sh->next != NULL) sh=sh->next;
1398 sh->next=jjMakeSub(v);
1399 }
1400 if (u->next!=NULL)
1401 {
1404 res->next=rn;
1405 return bo;
1406 }
1407 return FALSE;
1408}
1410{
1411 if ((u->rtyp!=IDHDL)||(u->e!=NULL))
1412 {
1413 WerrorS("indexed object must have a name");
1414 return TRUE;
1415 }
1416 intvec * iv=(intvec *)v->Data();
1417 leftv p=NULL;
1418 int i;
1419 sleftv t;
1420 t.Init();
1421 t.rtyp=INT_CMD;
1422 for (i=0;i<iv->length(); i++)
1423 {
1424 t.data=(char *)((long)(*iv)[i]);
1425 if (p==NULL)
1426 {
1427 p=res;
1428 }
1429 else
1430 {
1431 p->next=(leftv)omAlloc0Bin(sleftv_bin);
1432 p=p->next;
1433 }
1434 p->rtyp=IDHDL;
1435 p->data=u->data;
1436 p->name=u->name;
1437 p->flag=u->flag;
1438 p->e=jjMakeSub(&t);
1439 }
1440 u->rtyp=0;
1441 u->data=NULL;
1442 u->name=NULL;
1443 return FALSE;
1444}
1446{
1447 poly p=(poly)u->Data();
1448 long i=(long)v->Data();
1449 long j=0;
1450 while (p!=NULL)
1451 {
1452 j++;
1453 if (j==i)
1454 {
1455 res->data=(char *)pHead(p);
1456 return FALSE;
1457 }
1458 pIter(p);
1459 }
1460 return FALSE;
1461}
1463{
1466 int l; poly p,pp;
1467 sBucketDestroyAdd(b, &pp, &l);
1468 long i=(long)v->Data();
1469 long j=0;
1470 p=pp;
1471 while (p!=NULL)
1472 {
1473 j++;
1474 if (j==i)
1475 {
1476 res->data=(char *)pHead(p);
1478 return FALSE;
1479 }
1480 pIter(p);
1481 }
1483 return FALSE;
1484}
1486{
1487 poly p=(poly)u->Data();
1488 poly r=NULL;
1489 intvec *iv=(intvec *)v->CopyD(INTVEC_CMD);
1490 int i;
1491 int sum=0;
1492 for(i=iv->length()-1;i>=0;i--)
1493 sum+=(*iv)[i];
1494 int j=0;
1495 while ((p!=NULL) && (sum>0))
1496 {
1497 j++;
1498 for(i=iv->length()-1;i>=0;i--)
1499 {
1500 if (j==(*iv)[i])
1501 {
1502 r=pAdd(r,pHead(p));
1503 sum-=j;
1504 (*iv)[i]=0;
1505 break;
1506 }
1507 }
1508 pIter(p);
1509 }
1510 delete iv;
1511 res->data=(char *)r;
1512 return FALSE;
1513}
1515{
1516 poly p=(poly)u->Data();
1517 int i=(int)(long)v->Data();
1518 res->data=(char *)p_Vec2Poly(p,i,currRing);
1519 return FALSE;
1520}
1522{
1523 poly p=(poly)u->CopyD(VECTOR_CMD);
1524 if (p!=NULL)
1525 {
1526 poly r=pOne();
1527 poly hp=r;
1528 intvec *iv=(intvec *)v->Data();
1529 int i;
1530 loop
1531 {
1532 for(i=0;i<iv->length();i++)
1533 {
1534 if (((int)pGetComp(p))==(*iv)[i])
1535 {
1536 poly h;
1537 pSplit(p,&h);
1538 pNext(hp)=p;
1539 p=h;
1540 pIter(hp);
1541 break;
1542 }
1543 }
1544 if (p==NULL) break;
1545 if (i==iv->length())
1546 {
1547 pLmDelete(&p);
1548 if (p==NULL) break;
1549 }
1550 }
1551 pLmDelete(&r);
1552 res->data=(char *)r;
1553 }
1554 return FALSE;
1555}
1558{
1559 if(u->name==NULL) return TRUE;
1560 long slen = strlen(u->name) + 14;
1561 char *nn = (char*) omAlloc(slen);
1562 snprintf(nn,slen,"%s(%d)",u->name,(int)(long)v->Data());
1563 char *n=omStrDup(nn);
1565 syMake(res,n);
1566 if (u->next!=NULL) return jjKLAMMER_rest(res,u->next,v);
1567 return FALSE;
1568}
1570{
1571 if(u->name==NULL) return TRUE;
1572 intvec * iv=(intvec *)v->Data();
1573 leftv p=NULL;
1574 int i;
1575 long slen = strlen(u->name) + 14;
1576 char *n = (char*) omAlloc(slen);
1577
1578 for (i=0;i<iv->length(); i++)
1579 {
1580 if (p==NULL)
1581 {
1582 p=res;
1583 }
1584 else
1585 {
1586 p->next=(leftv)omAlloc0Bin(sleftv_bin);
1587 p=p->next;
1588 }
1589 snprintf(n,slen,"%s(%d)",u->name,(*iv)[i]);
1590 syMake(p,omStrDup(n));
1591 }
1592 omFreeSize(n, slen);
1593 if (u->next!=NULL) return jjKLAMMER_rest(res,u->next,v);
1594 return FALSE;
1595}
1597{
1599 BOOLEAN b;
1600 if (v->Typ()==INTVEC_CMD)
1601 b=jjKLAMMER_IV(tmp,u,v);
1602 else
1603 b=jjKLAMMER(tmp,u,v);
1604 if (b)
1605 {
1607 return TRUE;
1608 }
1609 leftv h=res;
1610 while (h->next!=NULL) h=h->next;
1611 h->next=tmp;
1612 return FALSE;
1613}
1615{
1616 void *d;
1617 Subexpr e;
1618 int typ;
1619 BOOLEAN t=FALSE;
1621 if ((u->rtyp!=IDHDL)||(u->e!=NULL))
1622 {
1623 tmp_proc=(idhdl)omAlloc0(sizeof(idrec));
1624 tmp_proc->id="_auto";
1625 tmp_proc->typ=PROC_CMD;
1626 tmp_proc->data.pinf=(procinfo *)u->Data();
1627 tmp_proc->ref=1;
1628 d=u->data; u->data=(void *)tmp_proc;
1629 e=u->e; u->e=NULL;
1630 t=TRUE;
1631 typ=u->rtyp; u->rtyp=IDHDL;
1632 }
1633 BOOLEAN sl;
1634 if (u->req_packhdl==currPack)
1635 sl = iiMake_proc((idhdl)u->data,NULL,v);
1636 else
1637 sl = iiMake_proc((idhdl)u->data,u->req_packhdl,v);
1638 if (t)
1639 {
1640 u->rtyp=typ;
1641 u->data=d;
1642 u->e=e;
1643 omFreeSize(tmp_proc,sizeof(idrec));
1644 }
1645 if (sl) return TRUE;
1646 memcpy(res,&iiRETURNEXPR,sizeof(sleftv));
1648 return FALSE;
1649}
1651{
1652 //Print("try to map %s with %s\n",$3.Name(),$1.Name());
1653 if ((v->e==NULL)&&(v->name!=NULL)&&(v->next==NULL))
1654 {
1655 map m=(map)u->Data();
1656 leftv sl=iiMap(m,v->name);
1657 if (sl!=NULL)
1658 {
1659 memcpy(res,sl,sizeof(sleftv));
1661 return FALSE;
1662 }
1663 }
1664 else
1665 {
1666 Werror("%s(<name>) expected",u->Name());
1667 }
1668 return TRUE; /*sl==NULL or Werror*/
1669}
1671{
1672 u->next=(leftv)omAlloc(sizeof(sleftv));
1673 memcpy(u->next,v,sizeof(sleftv));
1674 v->Init();
1675 BOOLEAN bo=iiExprArithM(res,u,'[');
1676 u->next=NULL;
1677 return bo;
1678}
1680{
1681 intvec *c=(intvec*)u->Data();
1682 intvec* p=(intvec*)v->Data();
1683 int rl=p->length();
1684 number *x=(number *)omAlloc(rl*sizeof(number));
1685 number *q=(number *)omAlloc(rl*sizeof(number));
1686 int i;
1687 for(i=rl-1;i>=0;i--)
1688 {
1689 q[i]=n_Init((*p)[i], coeffs_BIGINT);
1690 x[i]=n_Init((*c)[i], coeffs_BIGINT);
1691 }
1692 CFArray iv(rl);
1694 for(i=rl-1;i>=0;i--)
1695 {
1696 n_Delete(&(q[i]),coeffs_BIGINT);
1698 }
1699 omFree(x); omFree(q);
1700 res->data=(char *)n;
1701 return FALSE;
1702}
1703#if 0
1705{
1706 lists c=(lists)u->CopyD(); // list of poly
1707 intvec* p=(intvec*)v->Data();
1708 int rl=p->length();
1709 poly r=NULL,h, result=NULL;
1710 number *x=(number *)omAlloc(rl*sizeof(number));
1711 number *q=(number *)omAlloc(rl*sizeof(number));
1712 int i;
1713 for(i=rl-1;i>=0;i--)
1714 {
1715 q[i]=nlInit((*p)[i]);
1716 }
1717 loop
1718 {
1719 for(i=rl-1;i>=0;i--)
1720 {
1721 if (c->m[i].Typ()!=POLY_CMD)
1722 {
1723 Werror("poly expected at pos %d",i+1);
1724 for(i=rl-1;i>=0;i--)
1725 {
1726 nlDelete(&(q[i]),currRing);
1727 }
1728 omFree(x); omFree(q); // delete c
1729 return TRUE;
1730 }
1731 h=((poly)c->m[i].Data());
1732 if (r==NULL) r=h;
1733 else if (pLmCmp(r,h)==-1) r=h;
1734 }
1735 if (r==NULL) break;
1736 for(i=rl-1;i>=0;i--)
1737 {
1738 h=((poly)c->m[i].Data());
1739 if (pLmCmp(r,h)==0)
1740 {
1741 x[i]=pGetCoeff(h);
1743 c->m[i].data=(char*)h;
1744 }
1745 else
1746 x[i]=nlInit(0);
1747 }
1749 for(i=rl-1;i>=0;i--)
1750 {
1751 nlDelete(&(x[i]),currRing);
1752 }
1753 h=pHead(r);
1754 pSetCoeff(h,n);
1756 }
1757 for(i=rl-1;i>=0;i--)
1758 {
1759 nlDelete(&(q[i]),currRing);
1760 }
1761 omFree(x); omFree(q);
1762 res->data=(char *)result;
1763 return FALSE;
1764}
1765#endif
1767{
1768 poly p=(poly)u->CopyD();
1769 long s=(long)v->Data();
1770 if (s+p_MinComp(p,currRing)<=0)
1771 { p_Delete(&p,currRing);return TRUE;}
1772 p_Shift(&p,s,currRing);
1773 res->data=p;
1774 return FALSE;
1775}
1777{
1778 ideal M=(ideal)u->CopyD();
1779 int s=(int)(long)v->Data();
1780 for(int i=IDELEMS(M)-1; i>=0;i--)
1781 {
1782 if (s+p_MinComp(M->m[i],currRing)<=0)
1783 { id_Delete(&M,currRing);return TRUE;}
1784 }
1786 res->data=M;
1787 return FALSE;
1788}
1791{
1792 poly p=(poly)v->Data();
1793 if ((p==NULL)||(pNext(p)!=NULL)) return TRUE;
1794 res->data=(char *)mp_CoeffProc((poly)u->Data(),p /*(poly)v->Data()*/,currRing);
1795 return FALSE;
1796}
1798{
1799 poly p=(poly)v->Data();
1800 if ((p==NULL)||(pNext(p)!=NULL)) return TRUE;
1801 res->data=(char *)mp_CoeffProcId((ideal)u->Data(),p /*(poly)v->Data()*/,currRing);
1802 return FALSE;
1803}
1805{
1806 int i=pVar((poly)v->Data());
1807 if (i==0)
1808 {
1809 WerrorS("ringvar expected");
1810 return TRUE;
1811 }
1812 res->data=(char *)mp_Coeffs((ideal)u->CopyD(),i,currRing);
1813 return FALSE;
1814}
1816{
1817 poly p = pInit();
1818 int i;
1819 for (i=1; i<=currRing->N; i++)
1820 {
1821 pSetExp(p, i, 1);
1822 }
1823 pSetm(p);
1824 res->data = (void*)idCoeffOfKBase((ideal)(u->Data()),
1825 (ideal)(v->Data()), p);
1826 pLmFree(&p);
1827 return FALSE;
1828}
1830{
1831 res->data=(char *)idDiffOp((ideal)u->Data(),(ideal)v->Data(),FALSE);
1832 return FALSE;
1833}
1835{
1836 int *iv=iv2array((intvec *)v->Data(),currRing);
1837 ideal I=(ideal)u->Data();
1838 int d=-1;
1839 int i;
1840 for(i=IDELEMS(I);i>=0;i--) d=si_max(d,(int)p_DegW(I->m[i],iv,currRing));
1841 omFreeSize( (ADDRESS)iv, (rVar(currRing)+1)*sizeof(int) );
1842 res->data = (char *)((long)d);
1843 return FALSE;
1844}
1846{
1847 poly p=(poly)u->Data();
1848 if (p!=NULL)
1849 {
1850 int *iv=iv2array((intvec *)v->Data(),currRing);
1851 const long d = p_DegW(p,iv,currRing);
1852 omFreeSize( (ADDRESS)iv, (rVar(currRing)+1)*sizeof(int) );
1853 res->data = (char *)(d);
1854 }
1855 else
1856 res->data=(char *)(long)(-1);
1857 return FALSE;
1858}
1860{
1861 int pos=(int)(long)v->Data();
1862 intvec *iv=(intvec*)u->Data();
1863 res->data=(void*)iv->delete_pos(pos-1);
1864 return res->data==NULL;
1865}
1867{
1868 int pos=(int)(long)v->Data();
1869 ideal I=(ideal)u->Data();
1870 res->data=(void*)id_Delete_Pos(I,pos-1,currRing);
1871 return res->data==NULL;
1872}
1874{
1875 intvec *iv=(intvec*)v->Data();
1876 ideal I=(ideal)u->Data();
1877 ideal tmp1=NULL;
1878 ideal tmp2;
1879 for(int i=iv->length()-1;i>=0;i--)
1880 {
1881 int pos= (*iv)[i];
1883 if (tmp1==NULL) /* first entry */
1884 { tmp1=I; }
1885 else
1886 { id_Delete(&I,currRing); }
1887 I=tmp2;
1888 if (I==NULL) break;
1889 }
1890 res->data=(void*)I;
1891 return res->data==NULL;
1892}
1894{
1895 matrix m=(matrix)u->Data();
1896 DetVariant d=mp_GetAlgorithmDet((char*)v->Data());
1897 res ->data = mp_Det(m,currRing,d);
1898 return FALSE;
1899}
1901{
1902 DetVariant d=mp_GetAlgorithmDet((char*)v->Data());
1903 ideal m=(ideal)u->Data();
1904 res ->data = sm_Det(m,currRing,d);
1905 return FALSE;
1906}
1908{
1909 int i=pVar((poly)v->Data());
1910 if (i==0)
1911 {
1912 WerrorS("ringvar expected");
1913 return TRUE;
1914 }
1915 res->data=(char *)pDiff((poly)(u->Data()),i);
1916 return FALSE;
1917}
1919{
1920 int i=pVar((poly)v->Data());
1921 if (i==0)
1922 {
1923 WerrorS("ringvar expected");
1924 return TRUE;
1925 }
1926 res->data=(char *)idDiff((matrix)(u->Data()),i);
1927 return FALSE;
1928}
1930{
1931 res->data=(char *)idDiffOp((ideal)u->Data(),(ideal)v->Data());
1932 return FALSE;
1933}
1935{
1938 {
1939 Warn("dim(%s,...) may be wrong because the mixed monomial ordering",v->Name());
1940 }
1941 if(currRing->qideal==NULL)
1942 res->data = (char *)((long)scDimIntRing((ideal)(v->Data()),(ideal)w->Data()));
1943 else
1944 {
1945 ideal q=idSimpleAdd(currRing->qideal,(ideal)w->Data());
1946 res->data = (char *)((long)scDimIntRing((ideal)(v->Data()),q));
1947 idDelete(&q);
1948 }
1949 return FALSE;
1950}
1952{
1953 ideal vi=(ideal)v->Data();
1954 int vl= IDELEMS(vi);
1955 ideal ui=(ideal)u->Data();
1956 unsigned ul= IDELEMS(ui);
1957 ideal R; matrix U;
1959 if (m==NULL) return TRUE;
1960 // now make sure that all matrices have the correct size:
1962 assume (MATCOLS(U) == (int)ul);
1964 L->Init(3);
1965 L->m[0].rtyp=MATRIX_CMD; L->m[0].data=(void *)T;
1966 L->m[1].rtyp=u->Typ(); L->m[1].data=(void *)R;
1967 L->m[2].rtyp=MATRIX_CMD; L->m[2].data=(void *)U;
1968 res->data=(char *)L;
1969 return FALSE;
1970}
1972{
1973 res->data=(char *)idElimination((ideal)u->Data(),(poly)v->Data());
1974 //setFlag(res,FLAG_STD);
1975 return v->next!=NULL; //do not allow next like in eliminate(I,a(1..4))
1976}
1978{
1979 poly p=pOne();
1980 intvec *iv=(intvec*)v->Data();
1981 for(int i=iv->length()-1; i>=0; i--)
1982 {
1983 pSetExp(p,(*iv)[i],1);
1984 }
1985 pSetm(p);
1986 res->data=(char *)idElimination((ideal)u->Data(),p);
1987 pLmDelete(&p);
1988 //setFlag(res,FLAG_STD);
1989 return FALSE;
1990}
1992{
1993 //Print("exportto %s -> %s\n",v->Name(),u->Name() );
1994 return iiExport(v,0,IDPACKAGE((idhdl)u->data));
1995}
1997{
1998 WerrorS((char *)u->Data());
1999 EXTERN_VAR int inerror;
2000 inerror=3;
2001 return TRUE;
2002}
2004{
2005 number uu=(number)u->Data();number vv=(number)v->Data();
2007 number a,b;
2009 L->Init(3);
2010 L->m[0].rtyp=BIGINT_CMD; L->m[0].data=(void *)p0;
2011 L->m[1].rtyp=BIGINT_CMD; L->m[1].data=(void *)a;
2012 L->m[2].rtyp=BIGINT_CMD; L->m[2].data=(void *)b;
2013 res->rtyp=LIST_CMD;
2014 res->data=(char *)L;
2015 return FALSE;
2016}
2018{
2019 int uu=(int)(long)u->Data();int vv=(int)(long)v->Data();
2020 int p0=ABS(uu),p1=ABS(vv);
2021 int f0 = 1, f1 = 0, g0 = 0, g1 = 1, q, r;
2022
2023 while ( p1!=0 )
2024 {
2025 q=p0 / p1;
2026 r=p0 % p1;
2027 p0 = p1; p1 = r;
2028 r = g0 - g1 * q;
2029 g0 = g1; g1 = r;
2030 r = f0 - f1 * q;
2031 f0 = f1; f1 = r;
2032 }
2033 int a = f0;
2034 int b = g0;
2035 if ( uu /*(int)(long)u->Data()*/ < 0 ) a=-a;
2036 if ( vv /*(int)(long)v->Data()*/ < 0 ) b=-b;
2038 L->Init(3);
2039 L->m[0].rtyp=INT_CMD; L->m[0].data=(void *)(long)p0;
2040 L->m[1].rtyp=INT_CMD; L->m[1].data=(void *)(long)a;
2041 L->m[2].rtyp=INT_CMD; L->m[2].data=(void *)(long)b;
2042 res->data=(char *)L;
2043 return FALSE;
2044}
2046{
2047 poly r,pa,pb;
2048 BOOLEAN ret=singclap_extgcd((poly)u->Data(),(poly)v->Data(),r,pa,pb,currRing);
2049 if (ret) return TRUE;
2051 L->Init(3);
2052 res->data=(char *)L;
2053 L->m[0].data=(void *)r;
2054 L->m[0].rtyp=POLY_CMD;
2055 L->m[1].data=(void *)pa;
2056 L->m[1].rtyp=POLY_CMD;
2057 L->m[2].data=(void *)pb;
2058 L->m[2].rtyp=POLY_CMD;
2059 return FALSE;
2060}
2063{
2064 intvec *v=NULL;
2065 int sw=(int)(long)dummy->Data();
2066 int fac_sw=sw;
2067 if ((sw<0)||(sw>2)) fac_sw=1;
2069 ideal f=singclap_factorize((poly)(u->CopyD()), &v, fac_sw,currRing);
2070 if (f==NULL)
2071 return TRUE;
2072 switch(sw)
2073 {
2074 case 0:
2075 case 2:
2076 {
2078 l->Init(2);
2079 l->m[0].rtyp=IDEAL_CMD;
2080 l->m[0].data=(void *)f;
2081 l->m[1].rtyp=INTVEC_CMD;
2082 l->m[1].data=(void *)v;
2083 res->data=(void *)l;
2084 res->rtyp=LIST_CMD;
2085 return FALSE;
2086 }
2087 case 1:
2088 res->data=(void *)f;
2089 return FALSE;
2090 case 3:
2091 {
2092 poly p=f->m[0];
2093 int i=IDELEMS(f);
2094 f->m[0]=NULL;
2095 while(i>1)
2096 {
2097 i--;
2098 p=pMult(p,f->m[i]);
2099 f->m[i]=NULL;
2100 }
2101 res->data=(void *)p;
2102 res->rtyp=POLY_CMD;
2103 }
2104 return FALSE;
2105 }
2106 WerrorS("invalid switch");
2107 return TRUE;
2108}
2110{
2111 ideal_list p,h;
2112 h=kStdfac((ideal)v->Data(),NULL,testHomog,NULL,(ideal)w->Data());
2113 p=h;
2114 int l=0;
2115 while (p!=NULL) { p=p->next;l++; }
2117 L->Init(l);
2118 l=0;
2119 while(h!=NULL)
2120 {
2121 L->m[l].data=(char *)h->d;
2122 L->m[l].rtyp=IDEAL_CMD;
2123 p=h->next;
2124 omFreeSize(h,sizeof(*h));
2125 h=p;
2126 l++;
2127 }
2128 res->data=(void *)L;
2129 return FALSE;
2130}
2132{
2133 if (rField_is_Q(currRing))
2134 {
2135 number uu=(number)u->Data();
2136 number vv=(number)v->Data();
2137 res->data=(char *)n_Farey(uu,vv,currRing->cf);
2138 return FALSE;
2139 }
2140 else return TRUE;
2141}
2143{
2144 ideal uu=(ideal)u->Data();
2145 number vv=(number)v->Data();
2146 //timespec buf1,buf2;
2147 //clock_gettime(CLOCK_THREAD_CPUTIME_ID,&buf1);
2148 #if 1
2149 #ifdef HAVE_VSPACE
2151 if ((cpus>1) && (rField_is_Q(currRing)))
2152 res->data=(void*)id_Farey_0(uu,vv,currRing);
2153 else
2154 #endif
2155 #endif
2156 res->data=(void*)id_Farey(uu,vv,currRing);
2157 //clock_gettime(CLOCK_THREAD_CPUTIME_ID,&buf2);
2158 //const unsigned long SEC = 1000L*1000L*1000L;
2159 //all_farey+=((buf2.tv_sec-buf1.tv_sec)*SEC+
2160 // buf2.tv_nsec-buf1.tv_nsec);
2161 //farey_cnt++;
2162 return FALSE;
2163}
2164static BOOLEAN jjFAREY_LI(leftv res, leftv u, leftv v);
2166{
2167 ring r=(ring)u->Data();
2168 idhdl w;
2169 int op=iiOp;
2170 nMapFunc nMap;
2171
2172 if ((w=r->idroot->get(v->Name(),myynest))!=NULL)
2173 {
2174 int *perm=NULL;
2175 int *par_perm=NULL;
2176 int par_perm_size=0;
2177 BOOLEAN bo;
2178 nMap=n_SetMap(r->cf,currRing->cf);
2179 if (nMap==NULL)
2180 {
2181 // Allow imap/fetch to be make an exception only for:
2182 if (nCoeff_is_Extension(r->cf) && // Q(a..) -> Q(a..) || Q || Zp || Zp(a)
2183 ((n_SetMap(r->cf->extRing->cf,currRing->cf)!=NULL)
2184 || (nCoeff_is_Extension(currRing->cf) && (n_SetMap(r->cf->extRing->cf,currRing->cf->extRing->cf)!=NULL))))
2185 {
2187 }
2188 else
2189 {
2190 goto err_fetch;
2191 }
2192 }
2193 if (
2194 (iiOp!=FETCH_CMD) || (r->N!=currRing->N) || (rPar(r)!=rPar(currRing))
2197#endif
2198 )
2199 {
2200 perm=(int *)omAlloc0((r->N+1)*sizeof(int));
2201 if (par_perm_size!=0)
2202 par_perm=(int *)omAlloc0(par_perm_size*sizeof(int));
2203 op=IMAP_CMD;
2204 if (iiOp==IMAP_CMD)
2205 {
2206 int r_par=0;
2207 char ** r_par_names=NULL;
2208 if (r->cf->extRing!=NULL)
2209 {
2210 r_par=r->cf->extRing->N;
2211 r_par_names=r->cf->extRing->names;
2212 }
2213 int c_par=0;
2214 char ** c_par_names=NULL;
2215 if (currRing->cf->extRing!=NULL)
2216 {
2217 c_par=currRing->cf->extRing->N;
2218 c_par_names=currRing->cf->extRing->names;
2219 }
2220 if (!rIsLPRing(r))
2221 {
2222 maFindPerm(r->names, r->N, r_par_names, r_par,
2224 perm,par_perm, currRing->cf->type);
2225 }
2226 #ifdef HAVE_SHIFTBBA
2227 else
2228 {
2229 maFindPermLP(r->names, r->N, r_par_names, r_par,
2231 perm,par_perm, currRing->cf->type,r->isLPring);
2232 }
2233 #endif
2234 }
2235 else
2236 {
2237#ifdef HAVE_SHIFTBBA
2238 if (rIsLPRing(currRing))
2239 {
2240 maFetchPermLP(r, currRing, perm);
2241 }
2242 else
2243#endif
2244 {
2245 unsigned i;
2246 if (par_perm_size!=0)
2247 for(i=si_min(rPar(r),rPar(currRing));i>0;i--) par_perm[i-1]=-i;
2248 for(i=si_min(r->N,currRing->N);i>0;i--) perm[i]=i;
2249 }
2250 }
2251 }
2252 if ((iiOp==FETCH_CMD) && (BVERBOSE(V_IMAP)))
2253 {
2254 unsigned i;
2255 for(i=0;i<(unsigned)si_min(r->N,currRing->N);i++)
2256 {
2257 Print("// var nr %d: %s -> %s\n",i,r->names[i],currRing->names[i]);
2258 }
2259 for(i=0;i<(unsigned)si_min(rPar(r),rPar(currRing));i++) // possibly empty loop
2260 {
2261 Print("// par nr %d: %s -> %s\n",
2263 }
2264 }
2265 if (IDTYP(w)==ALIAS_CMD) w=(idhdl)IDDATA(w);
2266 sleftv tmpW;
2267 tmpW.Init();
2268 tmpW.rtyp=IDTYP(w);
2269 tmpW.data=IDDATA(w);
2270 if ((bo=maApplyFetch(op,NULL,res,&tmpW, r,
2272 {
2273 Werror("cannot map %s of type %s(%d)",v->name, Tok2Cmdname(w->typ),w->typ);
2274 }
2275 if (perm!=NULL)
2276 omFreeSize((ADDRESS)perm,(r->N+1)*sizeof(int));
2277 if (par_perm!=NULL)
2279 return bo;
2280 }
2281 else
2282 {
2283 Werror("identifier %s not found in %s",v->Fullname(),u->Fullname());
2284 }
2285 return TRUE;
2286err_fetch:
2287 char *s1=nCoeffString(r->cf);
2288 char *s2=nCoeffString(currRing->cf);
2289 Werror("no identity map from %s (%s -> %s)",u->Fullname(),s1,s2);
2290 omFree(s2); omFree(s1);
2291 return TRUE;
2292}
2294{
2295 /*4
2296 * look for the substring what in the string where
2297 * return the position of the first char of what in where
2298 * or 0
2299 */
2300 char *where=(char *)u->Data();
2301 char *what=(char *)v->Data();
2302 char *found = strstr(where,what);
2303 if (found != NULL)
2304 {
2305 res->data=(char *)((found-where)+1);
2306 }
2307 /*else res->data=NULL;*/
2308 return FALSE;
2309}
2310
2312{
2313 assumeStdFlag(u);
2314 ideal id = (ideal)u->Data();
2315 int max_length = (int)(long)v->Data();
2316 if (max_length < 0)
2317 {
2318 WerrorS("length for fres must not be negative");
2319 return TRUE;
2320 }
2321 if (max_length == 0)
2322 {
2323 max_length = currRing->N+1;
2324 if (currRing->qideal != NULL)
2325 {
2326 Warn("full resolution in a qring may be infinite, "
2327 "setting max length to %d", max_length);
2328 }
2329 }
2330 char *method = (char *)w->Data();
2331 /* For the moment, only "complete" (default), "frame", or "extended frame"
2332 * are allowed. Another useful option would be "linear strand".
2333 */
2334 if (strcmp(method, "complete") != 0
2335 && strcmp(method, "frame") != 0
2336 && strcmp(method, "extended frame") != 0
2337 && strcmp(method, "single module") != 0)
2338 {
2339 WerrorS("wrong optional argument for fres");
2340 return TRUE;
2341 }
2343 assume(r->fullres != NULL);
2344 res->data = (void *)r;
2345 return FALSE;
2346}
2347
2349{
2351 w->rtyp = STRING_CMD;
2352 w->data = (char *)"complete"; // default
2353 BOOLEAN RES = jjFRES3(res, u, v, w);
2355 return RES;
2356}
2357
2359{
2360 res->data=(char *)fractalWalkProc(u,v);
2361 setFlag( res, FLAG_STD );
2362 return FALSE;
2363}
2365{
2366 int uu=(int)(long)u->Data();int vv=(int)(long)v->Data();
2367 int p0=ABS(uu),p1=ABS(vv);
2368 int r;
2369 while ( p1!=0 )
2370 {
2371 r=p0 % p1;
2372 p0 = p1; p1 = r;
2373 }
2374 res->data=(char *)(long)p0;
2375 return FALSE;
2376}
2378{
2379 number n1 = (number) u->Data();
2380 number n2 = (number) v->Data();
2381 res->data = n_Gcd(n1,n2,coeffs_BIGINT);
2382 return FALSE;
2383}
2385{
2386 number a=(number) u->Data();
2387 number b=(number) v->Data();
2388 if (nIsZero(a))
2389 {
2390 if (nIsZero(b)) res->data=(char *)nInit(1);
2391 else res->data=(char *)nCopy(b);
2392 }
2393 else
2394 {
2395 if (nIsZero(b)) res->data=(char *)nCopy(a);
2396 //else res->data=(char *)n_Gcd(a, b, currRing->cf);
2397 else res->data=(char *)n_SubringGcd(a, b, currRing->cf);
2398 }
2399 return FALSE;
2400}
2402{
2403 res->data=(void *)singclap_gcd((poly)(u->CopyD(POLY_CMD)),
2404 (poly)(v->CopyD(POLY_CMD)),currRing);
2405 return FALSE;
2406}
2408{
2409 if (rField_is_Z(currRing))
2410 {
2411 PrintS("// NOTE: computation of Hilbert series etc. is being\n");
2412 PrintS("// performed for generic fibre, that is, over Q\n");
2413 }
2414 assumeStdFlag(u);
2415 intvec *module_w=(intvec*)atGet(u,"isHomog",INTVEC_CMD);
2416#if 1
2417 switch((int)(long)v->Data())
2418 {
2419 case 1:
2421 return FALSE;
2422 case 2:
2424 return FALSE;
2425 }
2426#else
2427 intvec *iv=hFirstSeries((ideal)u->Data(),module_w,currRing->qideal);
2428 if (errorreported) return TRUE;
2429
2430 switch((int)(long)v->Data())
2431 {
2432 case 1:
2433 res->data=(void *)iv;
2434 return FALSE;
2435 case 2:
2436 res->data=(void *)hSecondSeries(iv);
2437 delete iv;
2438 return FALSE;
2439 }
2440 delete iv;
2441#endif
2443 return TRUE;
2444}
2446{
2447 int i=pVar((poly)v->Data());
2448 if (i==0)
2449 {
2450 WerrorS("ringvar expected");
2451 return TRUE;
2452 }
2453 poly p=pOne(); pSetExp(p,i,1); pSetm(p);
2454 int d=pWTotaldegree(p);
2455 pLmDelete(p);
2456 if (d==1)
2457 res->data = (char *)p_Homogen((poly)u->Data(), i, currRing);
2458 else
2459 WerrorS("variable must have weight 1");
2460 return (d!=1);
2461}
2463{
2464 int i=pVar((poly)v->Data());
2465 if (i==0)
2466 {
2467 WerrorS("ringvar expected");
2468 return TRUE;
2469 }
2470 pFDegProc deg;
2471 if (currRing->pLexOrder && (currRing->order[0]==ringorder_lp))
2472 deg=p_Totaldegree;
2473 else
2474 deg=currRing->pFDeg;
2475 poly p=pOne(); pSetExp(p,i,1); pSetm(p);
2476 int d=deg(p,currRing);
2477 pLmDelete(p);
2478 if (d==1)
2479 res->data = (char *)id_Homogen((ideal)u->Data(), i, currRing);
2480 else
2481 WerrorS("variable must have weight 1");
2482 return (d!=1);
2483}
2485{
2486 intvec *w=new intvec(rVar(currRing));
2487 intvec *vw=(intvec*)u->Data();
2488 ideal v_id=(ideal)v->Data();
2491 BOOLEAN save_pLexOrder=currRing->pLexOrder;
2492 currRing->pLexOrder=FALSE;
2493 kHomW=vw;
2494 kModW=w;
2496 res->data=(void *)(long)idHomModule(v_id,currRing->qideal,&w);
2497 currRing->pLexOrder=save_pLexOrder;
2498 kHomW=NULL;
2499 kModW=NULL;
2501 if (w!=NULL) delete w;
2502 return FALSE;
2503}
2505{
2506 intvec *vw=(intvec*)u->Data();
2507 ideal v_id=(ideal)v->Data();
2508 res->data=(void *)(long)id_HomIdealW(v_id,currRing->qideal,vw,currRing);
2509 return FALSE;
2510}
2512{
2513 assumeStdFlag(u);
2514 res->data=(void *)scIndIndset((ideal)(u->Data()),(int)(long)(v->Data()),
2515 currRing->qideal);
2516 return FALSE;
2517}
2519{
2520 res->data=(char *)idSect((ideal)u->Data(),(ideal)v->Data());
2522 return FALSE;
2523}
2525{
2526 const lists L = (lists)l->Data();
2527 const int n = L->nr; assume (n >= 0);
2528 std::vector<ideal> V(n + 1);
2529
2530 for(int i = n; i >= 0; i--) V[i] = (ideal)(L->m[i].Data());
2531
2532 res->data=interpolation(V, (intvec*)v->Data());
2534 return errorreported;
2535}
2537{
2538 extern BOOLEAN jjStdJanetBasis(leftv res, leftv v,int flag);
2539 return jjStdJanetBasis(res,u,(int)(long)v->Data());
2540}
2541
2543{
2544 extern BOOLEAN jjStdJanetBasis(leftv res, leftv v,int flag);
2545 return jjStdJanetBasis(res,v,0);
2546}
2548{
2549 res->data = (char *)pJet((poly)u->CopyD(), (int)(long)v->Data());
2550 return FALSE;
2551}
2553{
2554 res->data = (char *)id_Jet((ideal)u->Data(),(int)(long)v->Data(),currRing);
2555 return FALSE;
2556}
2558{
2559 assumeStdFlag(u);
2560 intvec *w_u=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
2561 res->data = (char *)scKBase((int)(long)v->Data(),
2562 (ideal)(u->Data()),currRing->qideal, w_u);
2563 if (w_u!=NULL)
2564 {
2565 atSet(res,omStrDup("isHomog"),ivCopy(w_u),INTVEC_CMD);
2566 }
2567 return FALSE;
2568}
2571{
2572 return jjPREIMAGE(res,u,v,NULL);
2573}
2575{
2576 return mpKoszul(res, u,v,NULL);
2577}
2579{
2580 sleftv h;
2581 h.Init();
2582 h.rtyp=INT_CMD;
2583 h.data=(void *)(long)IDELEMS((ideal)v->Data());
2584 return mpKoszul(res, u, &h, v);
2585}
2587{
2588 int ul= IDELEMS((ideal)u->Data());
2589 int vl= IDELEMS((ideal)v->Data());
2590#ifdef HAVE_SHIFTBBA
2591 if (rIsLPRing(currRing))
2592 {
2593 if (currRing->LPncGenCount < ul)
2594 {
2595 Werror("At least %d ncgen variables are needed for this computation.", ul);
2596 return TRUE;
2597 }
2598 }
2599#endif
2600 ideal m = idLift((ideal)u->Data(),(ideal)v->Data(),NULL,FALSE,
2601 hasFlag(u,FLAG_STD));
2602 if (m==NULL) return TRUE;
2603 res->data = (char *)id_Module2formatedMatrix(m,ul,vl,currRing);
2604 return FALSE;
2605}
2607{
2608 if ((v->rtyp!=IDHDL)||(v->e!=NULL)) return TRUE;
2609 idhdl h=(idhdl)v->data;
2610#ifdef HAVE_SHIFTBBA
2611 if (rIsLPRing(currRing))
2612 {
2613 if (currRing->LPncGenCount < IDELEMS((ideal)u->Data()))
2614 {
2615 Werror("At least %d ncgen variables are needed for this computation.", IDELEMS((ideal)u->Data()));
2616 return TRUE;
2617 }
2618 }
2619#endif
2620 // CopyD for IDEAL_CMD and MODUL_CMD are identical:
2621 res->data = (char *)idLiftStd((ideal)u->Data(),
2622 &(h->data.umatrix),testHomog);
2623 setFlag(res,FLAG_STD); v->flag=0;
2624 return FALSE;
2625}
2626static BOOLEAN jjLOAD2(leftv /*res*/, leftv/* LIB */ , leftv v)
2627{
2628 return jjLOAD((char*)v->Data(),TRUE);
2629}
2630static BOOLEAN jjLOAD_E(leftv /*res*/, leftv v, leftv u)
2631{
2632 char * s=(char *)u->Data();
2633 if(strcmp(s, "with")==0)
2634 return jjLOAD((char*)v->Data(), TRUE);
2635 if (strcmp(s,"try")==0)
2636 return jjLOAD_TRY((char*)v->Data());
2637 WerrorS("invalid second argument");
2638 WerrorS("load(\"libname\" [,option]);");
2639 return TRUE;
2640}
2642{
2643 intvec *w_u=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
2645 if (w_u!=NULL)
2646 {
2647 //PrintS("modulo: wu:");w_u->show(INTVEC_CMD);PrintLn();
2648 w_u=ivCopy(w_u);
2649 hom=isHomog;
2650 }
2651 //else PrintS("modulo: wu:none\n");
2652 intvec *w_v=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
2653 if (w_v!=NULL)
2654 {
2655 //PrintS("modulo: wv:");w_v->show(INTVEC_CMD);PrintLn();
2656 w_v=ivCopy(w_v);
2657 hom=isHomog;
2658 }
2659 //else PrintS("modulo: wv:none\n");
2660 if ((w_u!=NULL) && (w_v==NULL))
2661 w_v=ivCopy(w_u);
2662 if ((w_v!=NULL) && (w_u==NULL))
2663 w_u=ivCopy(w_v);
2664 ideal u_id=(ideal)u->Data();
2665 ideal v_id=(ideal)v->Data();
2666 if (w_u!=NULL)
2667 {
2668 if ((*w_u).compare((w_v))!=0)
2669 {
2670 WarnS("incompatible weights");
2671 delete w_u; w_u=NULL;
2672 hom=testHomog;
2673 }
2674 else
2675 {
2676 if ((!idTestHomModule(u_id,currRing->qideal,w_v))
2677 || (!idTestHomModule(v_id,currRing->qideal,w_v)))
2678 {
2679 WarnS("wrong weights");
2680 delete w_u; w_u=NULL;
2681 hom=testHomog;
2682 }
2683 }
2684 }
2685 res->data = (char *)idModulo(u_id,v_id ,hom,&w_u);
2686 if (w_u!=NULL)
2687 {
2688 atSet(res,omStrDup("isHomog"),w_u,INTVEC_CMD);
2689 }
2690 delete w_v;
2691 //if (TEST_OPT_RETURN_SB) setFlag(res,FLAG_STD);
2692 return FALSE;
2693}
2695{
2696 number q=(number)v->Data();
2697 if (n_IsZero(q,coeffs_BIGINT))
2698 {
2700 return TRUE;
2701 }
2702 res->data =(char *) n_IntMod((number)u->Data(),q,coeffs_BIGINT);
2703 return FALSE;
2704}
2706{
2707 number q=(number)v->Data();
2708 if (nIsZero(q))
2709 {
2711 return TRUE;
2712 }
2713 res->data =(char *) n_IntMod((number)u->Data(),q,currRing->cf);
2714 return FALSE;
2715}
2717{
2718 poly q=(poly)v->Data();
2719 if (q==NULL)
2720 {
2722 return TRUE;
2723 }
2724 poly p=(poly)(u->Data());
2725 if (p==NULL)
2726 {
2727 res->data=NULL;
2728 return FALSE;
2729 }
2730 res->data=(void*)(singclap_pmod(p /*(poly)(u->Data())*/ ,
2731 q /*(poly)(v->Data())*/ ,currRing));
2732 return FALSE;
2733}
2736{
2737 return jjMONITOR2(res,v,NULL);
2738}
2740{
2741#if 0
2742 char *opt=(char *)v->Data();
2743 int mode=0;
2744 while(*opt!='\0')
2745 {
2746 if (*opt=='i') mode |= SI_PROT_I;
2747 else if (*opt=='o') mode |= SI_PROT_O;
2748 opt++;
2749 }
2750 monitor((char *)(u->Data()),mode);
2751#else
2752 si_link l=(si_link)u->Data();
2753 if (slOpen(l,SI_LINK_WRITE,u)) return TRUE;
2754 if(strcmp(l->m->type,"ASCII")!=0)
2755 {
2756 Werror("ASCII link required, not `%s`",l->m->type);
2757 slClose(l);
2758 return TRUE;
2759 }
2760 SI_LINK_SET_CLOSE_P(l); // febase handles the FILE*
2761 if ( l->name[0]!='\0') // "" is the stop condition
2762 {
2763 const char *opt;
2764 int mode=0;
2765 if (v==NULL) opt=(const char*)"i";
2766 else opt=(const char *)v->Data();
2767 while(*opt!='\0')
2768 {
2769 if (*opt=='i') mode |= SI_PROT_I;
2770 else if (*opt=='o') mode |= SI_PROT_O;
2771 opt++;
2772 }
2773 monitor((FILE *)l->data,mode);
2774 }
2775 else
2776 monitor(NULL,0);
2777 return FALSE;
2778#endif
2779}
2781{
2782 intvec *iv=(intvec *)v->Data();
2783 poly p=pOne();
2784 int e;
2785 BOOLEAN err=FALSE;
2786 for(unsigned i=si_min(currRing->N,iv->length()); i>0; i--)
2787 {
2788 e=(*iv)[i-1];
2789 if (e>=0) pSetExp(p,i,e);
2790 else err=TRUE;
2791 }
2792 if (iv->length()==(currRing->N+1))
2793 {
2794 res->rtyp=VECTOR_CMD;
2795 e=(*iv)[currRing->N];
2796 if (e>=0) pSetComp(p,e);
2797 else err=TRUE;
2798 }
2799 pSetm(p);
2800 res->data=(char*)p;
2801 if(err) { pDelete(&p); WerrorS("no negative exponent allowed"); }
2802 return err;
2803}
2805{
2806 // u: the name of the new type
2807 // v: the elements
2808 const char *s=(const char *)u->Data();
2810 if (strlen(s)>=2)
2811 {
2812 d=newstructFromString((const char *)v->Data());
2813 if (d!=NULL) newstruct_setup(s,d);
2814 }
2815 else WerrorS("name of newstruct must be longer than 1 character");
2816 return d==NULL;
2817}
2819{
2820 idhdl h=(idhdl)u->data;
2821 int i=(int)(long)v->Data();
2822 int p=0;
2823 if ((0<i)
2824 && (rParameter(IDRING(h))!=NULL)
2825 && (i<=(p=rPar(IDRING(h)))))
2826 res->data=omStrDup(rParameter(IDRING(h))[i-1]);
2827 else
2828 {
2829 Werror("par number %d out of range 1..%d",i,p);
2830 return TRUE;
2831 }
2832 return FALSE;
2833}
2834#ifdef HAVE_PLURAL
2836{
2837 if( currRing->qideal != NULL )
2838 {
2839 WerrorS("basering must NOT be a qring!");
2840 return TRUE;
2841 }
2842
2843 if (iiOp==NCALGEBRA_CMD)
2844 {
2845 return nc_CallPlural(NULL,NULL,(poly)a->Data(),(poly)b->Data(),currRing,false,true,false,currRing);
2846 }
2847 else
2848 {
2849 ring r=rCopy(currRing);
2850 BOOLEAN result=nc_CallPlural(NULL,NULL,(poly)a->Data(),(poly)b->Data(),r,false,true,false,currRing);
2851 res->data=r;
2852 return result;
2853 }
2854}
2856{
2857 if( currRing->qideal != NULL )
2858 {
2859 WerrorS("basering must NOT be a qring!");
2860 return TRUE;
2861 }
2862
2863 if (iiOp==NCALGEBRA_CMD)
2864 {
2865 return nc_CallPlural(NULL,(matrix)b->Data(),(poly)a->Data(),NULL,currRing,false,true,false,currRing);
2866 }
2867 else
2868 {
2869 ring r=rCopy(currRing);
2870 BOOLEAN result=nc_CallPlural(NULL,(matrix)b->Data(),(poly)a->Data(),NULL,r,false,true,false,currRing);
2871 res->data=r;
2872 return result;
2873 }
2874}
2876{
2877 if( currRing->qideal != NULL )
2878 {
2879 WerrorS("basering must NOT be a qring!");
2880 return TRUE;
2881 }
2882
2883 if (iiOp==NCALGEBRA_CMD)
2884 {
2885 return nc_CallPlural((matrix)a->Data(),NULL,NULL,(poly)b->Data(),currRing,false,true,false,currRing);
2886 }
2887 else
2888 {
2889 ring r=rCopy(currRing);
2890 BOOLEAN result=nc_CallPlural((matrix)a->Data(),NULL,NULL,(poly)b->Data(),r,false,true,false,currRing);
2891 res->data=r;
2892 return result;
2893 }
2894}
2896{
2897 if( currRing->qideal != NULL )
2898 {
2899 WerrorS("basering must NOT be a qring!");
2900 return TRUE;
2901 }
2902
2903 if (iiOp==NCALGEBRA_CMD)
2904 {
2905 return nc_CallPlural((matrix)a->Data(),(matrix)b->Data(),NULL,NULL,currRing,false,true,false,currRing);
2906 }
2907 else
2908 {
2909 ring r=rCopy(currRing);
2910 BOOLEAN result=nc_CallPlural((matrix)a->Data(),(matrix)b->Data(),NULL,NULL,r,false,true,false,currRing);
2911 res->data=r;
2912 return result;
2913 }
2914}
2916{
2917 res->data=NULL;
2918
2920 {
2921 const poly q = (poly)b->Data();
2922
2923 if( q != NULL )
2924 {
2925 if( (poly)a->Data() != NULL )
2926 {
2928 {
2929 poly p = (poly)a->CopyD(POLY_CMD); // p = copy!
2930 res->data = nc_p_Bracket_qq(p,q, currRing); // p will be destroyed!
2931 }
2932 else if (rIsLPRing(currRing))
2933 {
2934 const poly p = (poly)a->Data();
2935 res->data = pAdd(ppMult_qq(p,q), pNeg(ppMult_qq(q,p)));
2936 }
2937 }
2938 }
2939 }
2940 return FALSE;
2941}
2943{
2944 res->data=NULL;
2945
2947 {
2948 const poly q = (poly)b->Data();
2949 if(q != NULL)
2950 {
2951 if((poly)a->Data() != NULL)
2952 {
2953 const poly p = (poly)a->Data();
2954 int k=(int)(long)c->Data();
2955 if (k > 0)
2956 {
2957 poly qq = pCopy(q);
2958 for (int i = 0; i < k; i++)
2959 {
2960 poly qq_ref = qq;
2961 if (rIsLPRing(currRing))
2962 {
2964 }
2965 else if (rIsPluralRing(currRing))
2966 {
2968 }
2969 pDelete(&qq_ref);
2970 if (qq == NULL) break;
2971 }
2972 res->data = qq;
2973 }
2974 else
2975 {
2976 Werror("invalid number of iterations");
2977 }
2978 }
2979 }
2980 }
2981 return FALSE;
2982}
2984{
2985 /* number, poly, vector, ideal, module, matrix */
2986 ring r = (ring)a->Data();
2987 if (r == currRing)
2988 {
2989 res->data = b->Data();
2990 res->rtyp = b->rtyp;
2991 return FALSE;
2992 }
2993 if (!rIsLikeOpposite(currRing, r))
2994 {
2995 Werror("%s is not an opposite ring to current ring",a->Fullname());
2996 return TRUE;
2997 }
2998 idhdl w;
2999 if( ((w=r->idroot->get(b->Name(),myynest))!=NULL) && (b->e==NULL))
3000 {
3001 int argtype = IDTYP(w);
3002 switch (argtype)
3003 {
3004 case NUMBER_CMD:
3005 {
3006 /* since basefields are equal, we can apply nCopy */
3007 res->data = nCopy((number)IDDATA(w));
3008 res->rtyp = argtype;
3009 break;
3010 }
3011 case POLY_CMD:
3012 case VECTOR_CMD:
3013 {
3014 poly q = (poly)IDDATA(w);
3015 res->data = pOppose(r,q,currRing);
3016 res->rtyp = argtype;
3017 break;
3018 }
3019 case IDEAL_CMD:
3020 case MODUL_CMD:
3021 {
3022 ideal Q = (ideal)IDDATA(w);
3023 res->data = idOppose(r,Q,currRing);
3024 res->rtyp = argtype;
3025 break;
3026 }
3027 case MATRIX_CMD:
3028 {
3029 ring save = currRing;
3030 rChangeCurrRing(r);
3031 matrix m = (matrix)IDDATA(w);
3034 ideal S = idOppose(r,Q,currRing);
3035 id_Delete(&Q, r);
3036 res->data = id_Module2Matrix(S,currRing);
3037 res->rtyp = argtype;
3038 break;
3039 }
3040 default:
3041 {
3042 WerrorS("unsupported type in oppose");
3043 return TRUE;
3044 }
3045 }
3046 }
3047 else
3048 {
3049 Werror("identifier %s not found in %s",b->Fullname(),a->Fullname());
3050 return TRUE;
3051 }
3052 return FALSE;
3053}
3054#endif /* HAVE_PLURAL */
3055
3057{
3058 if (ma->Typ()!=SMATRIX_CMD)
3059 {
3060 WerrorS("expected prune_map(`module`,`smatrix`)`");
3061 return TRUE;
3062 }
3063
3064 intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
3065 ideal v_id=(ideal)v->Data();
3066 if (w!=NULL)
3067 {
3068 if (!idTestHomModule(v_id,currRing->qideal,w))
3069 {
3070 WarnS("wrong weights");
3071 w=NULL;
3072 // and continue at the non-homog case below
3073 }
3074 else
3075 {
3076 w=ivCopy(w);
3077 intvec **ww=&w;
3078 ideal mat;
3079 int *g=(int*)omAlloc(v_id->rank*sizeof(int));
3080 res->data = (char *)idMinEmbedding_with_map_v(v_id,ww,mat,g);
3081 atSet(res,omStrDup("isHomog"),*ww,INTVEC_CMD);
3082 idhdl h=(idhdl)ma->data;
3083 idDelete(&IDIDEAL(h));
3084 IDIDEAL(h)=mat;
3085 for(int i=0;i<v_id->rank;i++) Print("v[%d]:%d ",i+1,g[i]); PrintLn();
3086 omFreeSize(g,v_id->rank*sizeof(int));
3087 return FALSE;
3088 }
3089 }
3090 ideal mat;
3091 int *g=(int*)omAlloc(v_id->rank*sizeof(int));
3092 res->data = (char *)idMinEmbedding_with_map_v(v_id,NULL,mat,g);
3093 for(int i=0;i<v_id->rank;i++) Print("v[%d]:%d ",i+1,g[i]); PrintLn();
3094 omFreeSize(g,v_id->rank*sizeof(int));
3095 idhdl h=(idhdl)ma->data;
3096 idDelete(&IDIDEAL(h));
3097 IDIDEAL(h)=mat;
3098 return FALSE;
3099}
3101{
3102 res->data = (char *)idQuot((ideal)u->Data(),(ideal)v->Data(),
3103 hasFlag(u,FLAG_STD),u->Typ()==v->Typ());
3104 //if (TEST_OPT_RETURN_SB) setFlag(res,FLAG_STD);
3105 return FALSE;
3106}
3108{
3109 int i=(int)(long)u->Data();
3110 int j=(int)(long)v->Data();
3111 if (j-i <0) {WerrorS("invalid range for random"); return TRUE;}
3112 res->data =(char *)(long)((i > j) ? i : (siRand() % (j-i+1)) + i);
3113 return FALSE;
3114}
3116{
3117 matrix m =(matrix)u->Data();
3118 int isRowEchelon = (int)(long)v->Data();
3119 if (isRowEchelon != 1) isRowEchelon = 0;
3120 int rank = luRank(m, isRowEchelon);
3121 res->data =(char *)(long)rank;
3122 return FALSE;
3123}
3125{
3126 si_link l=(si_link)u->Data();
3127 leftv r=slRead(l,v);
3128 if (r==NULL)
3129 {
3130 const char *s;
3131 if ((l!=NULL)&&(l->name!=NULL)) s=l->name;
3132 else s=sNoName_fe;
3133 Werror("cannot read from `%s`",s);
3134 return TRUE;
3135 }
3136 memcpy(res,r,sizeof(sleftv));
3138 return FALSE;
3139}
3141{
3142 ideal vi=(ideal)v->Data();
3143 if (currRing->qideal!=NULL || vi->ncols>1 || rIsPluralRing(currRing))
3145 res->data = (char *)kNF(vi,currRing->qideal,(poly)u->Data());
3146 return FALSE;
3147}
3149{
3150 ideal ui=(ideal)u->Data();
3151 ideal vi=(ideal)v->Data();
3152 if (currRing->qideal!=NULL || vi->ncols>1 || rIsPluralRing(currRing))
3154 res->data = (char *)kNF(vi,currRing->qideal,ui);
3155 return FALSE;
3156}
3158{
3159 int maxl=(int)(long)v->Data();
3160 if (maxl<0)
3161 {
3162 WerrorS("length for res must not be negative");
3163 return TRUE;
3164 }
3165 syStrategy r;
3166 intvec *weights=NULL;
3167 int wmaxl=maxl;
3168 ideal u_id=(ideal)u->Data();
3169
3170 maxl--;
3171 if (/*(*/ maxl==-1 /*)*/) /*&& (iiOp!=MRES_CMD)*/
3172 {
3173 maxl = currRing->N-1+2*(iiOp==MRES_CMD);
3174 if (currRing->qideal!=NULL)
3175 {
3176 Warn(
3177 "full resolution in a qring may be infinite, setting max length to %d",
3178 maxl+1);
3179 }
3180 }
3181 weights=(intvec*)atGet(u,"isHomog",INTVEC_CMD);
3182 if (weights!=NULL)
3183 {
3184 if (!idTestHomModule(u_id,currRing->qideal,weights))
3185 {
3186 WarnS("wrong weights given:");weights->show();PrintLn();
3187 weights=NULL;
3188 }
3189 }
3190 intvec *ww=NULL;
3191 int add_row_shift=0;
3192 if (weights!=NULL)
3193 {
3194 ww=ivCopy(weights);
3195 add_row_shift = ww->min_in();
3196 (*ww) -= add_row_shift;
3197 }
3198 unsigned save_opt=si_opt_1;
3200 if ((iiOp == RES_CMD) || (iiOp == MRES_CMD))
3201 {
3202 if (iiOp==MRES_CMD) u_id=(ideal)u->CopyD();
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 }
10195 /* else ALLOW_RING */
10196 else if (((p & ZERODIVISOR_MASK)==NO_ZERODIVISOR)
10198 {
10199 WerrorS("domain required as coeffients");
10200 return TRUE;
10201 }
10202 /* else ALLOW_ZERODIVISOR */
10203 else if(((p & WARN_RING)==WARN_RING)&&(myynest==0))
10204 {
10205 WarnS("considering the image in Q[...]");
10206 }
10207 }
10208 return FALSE;
10209}
10210// --------------------------------------------------------------------
10212{
10213 if ((currRing!=NULL)
10215 && (!rField_is_Z(currRing)))
10216 {
10217 WerrorS("not implemented for rings with rings as coeffients (except ZZ)");
10218 return TRUE;
10219 }
10220 coeffs cf;
10221 lists c=(lists)u->CopyD(); // list of ideal or bigint/int
10222 int rl=c->nr+1;
10223 int return_type=c->m[0].Typ();
10224 if ((return_type!=IDEAL_CMD)
10228 && (return_type!=POLY_CMD))
10229 {
10231 ||(return_type==INT_CMD))
10233 else if (return_type==LIST_CMD)
10234 {
10235 // create a tmp list of the correct size
10237 res_l->Init(rl /*c->nr+1*/);
10240 for (unsigned i=0;i<=(unsigned)c->nr;i++)
10241 {
10242 sleftv tmp;
10243 tmp.Copy(v);
10245 if (bo) { Werror("chinrem failed for list entry %d",i+1); break;}
10246 }
10247 c->Clean();
10248 res->data=res_l;
10249 res->rtyp=LIST_CMD;
10250 return bo;
10251 }
10252 else
10253 {
10254 c->Clean();
10255 WerrorS("poly/ideal/module/matrix/list expected");
10256 return TRUE;
10257 }
10258 }
10261 else
10262 {
10263 cf=currRing->cf;
10264 if (nCoeff_is_Extension(cf) && (cf->extRing!=NULL))
10265 cf=cf->extRing->cf;
10266 }
10267 lists pl=NULL;
10268 intvec *p=NULL;
10269 if (v->Typ()==LIST_CMD)
10270 {
10271 pl=(lists)v->Data();
10272 if (pl->nr!=rl-1)
10273 {
10274 Werror("wromg number of primes (%d:%d) for chinrem",pl->nr+1,rl);
10275 return TRUE;
10276 }
10277 }
10278 else
10279 {
10280 p=(intvec*)v->Data();
10281 if (p->length()!=rl)
10282 {
10283 Werror("wromg number of primes (%d:%d) for chinrem",p->length(),rl);
10284 return TRUE;
10285 }
10286 }
10287 ideal result;
10288 ideal *x=(ideal *)omAlloc(rl*sizeof(ideal));
10289 number *xx=NULL;
10291 int i;
10293 {
10294 for(i=rl-1;i>=0;i--)
10295 {
10296 if (c->m[i].Typ()!=return_type)
10297 {
10298 Werror("%s expected at pos %d",Tok2Cmdname(return_type),i+1);
10299 omFree(x); // delete c
10300 return TRUE;
10301 }
10302 if (return_type==POLY_CMD)
10303 {
10304 x[i]=idInit(1,1);
10305 x[i]->m[0]=(poly)c->m[i].CopyD();
10306 }
10307 else
10308 {
10309 x[i]=(ideal)c->m[i].CopyD();
10310 }
10311 //c->m[i].Init();
10312 }
10313 }
10314 else
10315 {
10316 if (nMap==NULL)
10317 {
10318 Werror("not implemented: map bigint -> %s", nCoeffName(cf));
10319 return TRUE;
10320 }
10321 xx=(number *)omAlloc(rl*sizeof(number));
10322 for(i=rl-1;i>=0;i--)
10323 {
10324 if (c->m[i].Typ()==INT_CMD)
10325 {
10326 xx[i]=n_Init(((int)(long)c->m[i].Data()),cf);
10327 }
10328 else if (c->m[i].Typ()==BIGINT_CMD)
10329 {
10330 xx[i]=nMap((number)c->m[i].Data(),coeffs_BIGINT,cf);
10331 }
10332 else
10333 {
10334 Werror("bigint expected at pos %d",i+1);
10335 omFree(x); // delete c
10336 omFree(xx); // delete c
10337 return TRUE;
10338 }
10339 }
10340 }
10341 number *q=(number *)omAlloc(rl*sizeof(number));
10342 if (p!=NULL)
10343 {
10344 for(i=rl-1;i>=0;i--)
10345 {
10346 q[i]=n_Init((*p)[i], cf);
10347 }
10348 }
10349 else
10350 {
10351 for(i=rl-1;i>=0;i--)
10352 {
10353 if (pl->m[i].Typ()==INT_CMD)
10354 {
10355 q[i]=n_Init((int)(long)pl->m[i].Data(),cf);
10356 }
10357 else if (pl->m[i].Typ()==BIGINT_CMD)
10358 {
10359 q[i]=nMap((number)(pl->m[i].Data()),coeffs_BIGINT,cf);
10360 }
10361 else
10362 {
10363 Werror("bigint expected at pos %d",i+1);
10364 for(i++;i<rl;i++)
10365 {
10366 n_Delete(&(q[i]),cf);
10367 }
10368 omFree(x); // delete c
10369 omFree(q); // delete pl
10370 if (xx!=NULL) omFree(xx); // delete c
10371 return TRUE;
10372 }
10373 }
10374 }
10376 {
10377 CFArray i_v(rl);
10379 res->data=(char *)n;
10380 }
10381 else
10382 {
10383 #if 0
10384 #ifdef HAVE_VSPACE
10386 if ((cpus>1) && (rField_is_Q(currRing)))
10387 result=id_ChineseRemainder_0(x,q,rl,currRing); // deletes also x
10388 else
10389 #endif
10390 #endif
10391 result=id_ChineseRemainder(x,q,rl,currRing); // deletes also x
10392 c->Clean();
10393 if ((return_type==POLY_CMD) &&(result!=NULL))
10394 {
10395 res->data=(char *)result->m[0];
10396 result->m[0]=NULL;
10397 idDelete(&result);
10398 }
10399 else
10400 res->data=(char *)result;
10401 }
10402 for(i=rl-1;i>=0;i--)
10403 {
10404 n_Delete(&(q[i]),cf);
10405 }
10406 omFree(q);
10407 res->rtyp=return_type;
10408 return result==NULL;
10409}
10411{
10412 lists c=(lists)u->CopyD();
10414 res_l->Init(c->nr+1);
10417 for (unsigned i=0;i<=(unsigned)c->nr;i++)
10418 {
10419 sleftv tmp;
10420 tmp.Copy(v);
10422 if (bo) { Werror("farey failed for list entry %d",i+1); break;}
10423 }
10424 c->Clean();
10425 res->data=res_l;
10426 return bo;
10427}
10428// --------------------------------------------------------------------
10429static int jjCOMPARE_ALL(const void * aa, const void * bb)
10430{
10431 leftv a=(leftv)aa;
10432 int at=a->Typ();
10433 leftv b=(leftv)bb;
10434 int bt=b->Typ();
10435 if (at < bt) return -1;
10436 if (at > bt) return 1;
10438 sleftv tmp;
10439 tmp.Init();
10440 iiOp='<';
10442 if (bo)
10443 {
10444 Werror(" no `<` for %s",Tok2Cmdname(at));
10445 unsigned long ad=(unsigned long)a->Data();
10446 unsigned long bd=(unsigned long)b->Data();
10447 if (ad<bd) return -1;
10448 else if (ad==bd) return 0;
10449 else return 1;
10450 }
10451 else if (tmp.data==NULL) /* not < */
10452 {
10456 if (bo)
10457 {
10458 Werror(" no `==` for %s",Tok2Cmdname(at));
10459 unsigned long ad=(unsigned long)a->Data();
10460 unsigned long bd=(unsigned long)b->Data();
10461 if (ad<bd) return -1;
10462 else if (ad==bd) return 0;
10463 else return 1;
10464 }
10465 else if (tmp.data==NULL) /* not <,== */ return 1;
10466 else return 0;
10467 }
10468 else return -1;
10469}
10471{
10472 lists l=(lists)arg->Data();
10473 if (l->nr>0)
10474 {
10475 qsort(l->m,l->nr+1,sizeof(sleftv),jjCOMPARE_ALL);
10476 }
10477 return FALSE;
10478}
10480{
10481 lists l=(lists)arg->Data();
10482 if (l->nr>0)
10483 {
10484 qsort(l->m,l->nr+1,sizeof(sleftv),jjCOMPARE_ALL);
10485 int i, j, len;
10486 len=l->nr;
10487 i=0;
10488 while(i<len)
10489 {
10490 if(jjCOMPARE_ALL(&(l->m[i]),&(l->m[i+1]))==0)
10491 {
10492 l->m[i].CleanUp();
10493 for(j=i; j<len;j++) l->m[j]=l->m[j+1];
10494 memset(&(l->m[len]),0,sizeof(sleftv));
10495 l->m[len].rtyp=DEF_CMD;
10496 len--;
10497 }
10498 else
10499 i++;
10500 }
10501 //Print("new len:%d\n",len);
10502 }
10503 return FALSE;
10504}
ideal getMinorIdealCache(const matrix mat, const int minorSize, const int k, const ideal iSB, const int cacheStrategy, const int cacheN, const int cacheW, const bool allDifferent)
Returns the specified set of minors (= subdeterminantes) of the given matrix.
ideal getMinorIdeal(const matrix mat, const int minorSize, const int k, const char *algorithm, const ideal iSB, const bool allDifferent)
Returns the specified set of minors (= subdeterminantes) of the given matrix.
ideal getMinorIdealHeuristic(const matrix mat, const int minorSize, const int k, const ideal iSB, const bool allDifferent)
Returns the specified set of minors (= subdeterminantes) of the given matrix.
void atSet(idhdl root, char *name, void *data, int typ)
Definition attrib.cc:153
void * atGet(idhdl root, const char *name, int t, void *defaultReturnValue)
Definition attrib.cc:132
#define atKill(H, A)
Definition attrib.h:49
static int ABS(int v)
Definition auxiliary.h:112
static int si_max(const int a, const int b)
Definition auxiliary.h:124
int BOOLEAN
Definition auxiliary.h:87
#define TRUE
Definition auxiliary.h:100
#define FALSE
Definition auxiliary.h:96
static int si_min(const int a, const int b)
Definition auxiliary.h:125
intvec * bim2iv(bigintmat *b)
Definition bigintmat.cc:339
bigintmat * bimMult(bigintmat *a, bigintmat *b)
Definition bigintmat.cc:253
bigintmat * bimSub(bigintmat *a, bigintmat *b)
Definition bigintmat.cc:216
bigintmat * bimAdd(bigintmat *a, bigintmat *b)
Matrix-Add/-Sub/-Mult so oder mit operator+/-/* ? @Note: NULL as a result means an error (non-compati...
Definition bigintmat.cc:180
#define BIMATELEM(M, I, J)
Definition bigintmat.h:133
struct blackbox_list * getBlackboxTypes()
return array of all define types.
Definition blackbox.cc:245
const char * getBlackboxName(const int t)
return the name to the type given by t (r/o)
Definition blackbox.cc:213
blackbox * getBlackboxStuff(const int t)
return the structure to the type given by t
Definition blackbox.cc:17
int blackboxIsCmd(const char *n, int &tok)
used by scanner: returns ROOT_DECL for known types (and the type number in tok)
Definition blackbox.cc:219
void printBlackboxTypes()
list all defined type (for debugging)
Definition blackbox.cc:236
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:1798
int singclap_det_i(intvec *m, const ring)
Definition clapsing.cc:1780
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:959
@ n_algExt
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic
Definition coeffs.h:35
static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
in Z: return the gcd of 'a' and 'b' in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ,...
Definition coeffs.h:665
static FORCE_INLINE char * nCoeffString(const coeffs cf)
TODO: make it a virtual method of coeffs, together with: Decompose & Compose, rParameter & rPar.
Definition coeffs.h:952
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff 'n' is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2),...
Definition coeffs.h:498
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
Definition coeffs.h:701
static FORCE_INLINE number n_InpNeg(number n, const coeffs r)
in-place negation of n MUST BE USED: n = n_InpNeg(n) (no copy is returned)
Definition coeffs.h:558
static FORCE_INLINE void n_Power(number a, int b, number *res, const coeffs r)
fill res with the power a^b
Definition coeffs.h:633
static FORCE_INLINE number n_Farey(number a, number b, const coeffs r)
Definition coeffs.h:760
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of 'a' and 'b', i.e., a/b; raises an error if 'b' is not invertible in r exceptio...
Definition coeffs.h:616
static FORCE_INLINE number n_RePart(number i, const coeffs cf)
Definition coeffs.h:783
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition coeffs.h:468
static FORCE_INLINE int n_Size(number n, const coeffs r)
return a non-negative measure for the complexity of n; return 0 only when n represents zero; (used fo...
Definition coeffs.h:571
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of 'a' and 'b', i.e., a-b
Definition coeffs.h:656
static FORCE_INLINE number n_ChineseRemainderSym(number *a, number *b, int rl, BOOLEAN sym, CFArray &inv_cache, const coeffs r)
Definition coeffs.h:757
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition coeffs.h:459
static FORCE_INLINE char * nCoeffName(const coeffs cf)
Definition coeffs.h:956
static FORCE_INLINE number n_ExtGcd(number a, number b, number *s, number *t, const coeffs r)
beware that ExtGCD is only relevant for a few chosen coeff. domains and may perform something unexpec...
Definition coeffs.h:672
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition coeffs.h:539
static FORCE_INLINE number n_IntMod(number a, number b, const coeffs r)
for r a field, return n_Init(0,r) always: n_Div(a,b,r)*b+n_IntMod(a,b,r)==a n_IntMod(a,...
Definition coeffs.h:629
static FORCE_INLINE BOOLEAN n_Equal(number a, number b, const coeffs r)
TRUE iff 'a' and 'b' represent the same number; they may have different representations.
Definition coeffs.h:464
static FORCE_INLINE number n_GetNumerator(number &n, const coeffs r)
return the numerator of n (if elements of r are by nature not fractional, result is n)
Definition coeffs.h:609
static FORCE_INLINE number n_SubringGcd(number a, number b, const coeffs r)
Definition coeffs.h:667
static FORCE_INLINE number n_ImPart(number i, const coeffs cf)
Definition coeffs.h:786
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition coeffs.h:80
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition coeffs.h:579
static FORCE_INLINE BOOLEAN nCoeff_is_transExt(const coeffs r)
TRUE iff r represents a transcendental extension field.
Definition coeffs.h:911
static BOOLEAN pa(leftv res, leftv args)
Definition cohomo.cc:3770
static BOOLEAN pb(leftv res, leftv args)
Definition cohomo.cc:3796
#define Print
Definition emacs.cc:80
#define Warn
Definition emacs.cc:77
#define WarnS
Definition emacs.cc:78
return result
const CanonicalForm int s
Definition facAbsFact.cc:51
CanonicalForm res
Definition facAbsFact.cc:60
const CanonicalForm & w
Definition facAbsFact.cc:51
b *CanonicalForm B
Definition facBivar.cc:52
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
bool found
CFList tmp1
Definition facFqBivar.cc:75
CFList tmp2
Definition facFqBivar.cc:75
int j
Definition facHensel.cc:110
‘factory.h’ is the user interface to Factory.
VAR void(* WerrorS_callback)(const char *s)
Definition feFopen.cc:21
FILE * feFopen(const char *path, const char *mode, char *where, short useWerror, short path_only)
Definition feFopen.cc:47
VAR short errorreported
Definition feFopen.cc:23
void WerrorS(const char *s)
Definition feFopen.cc:24
static void * feOptValue(feOptIndex opt)
Definition feOpt.h:40
VAR char my_yylinebuf[80]
Definition febase.cc:44
VAR int myynest
Definition febase.cc:41
void monitor(void *F, int mode)
Definition febase.cc:68
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:124
int iiTestConvert(int inputType, int outputType)
Definition gentable.cc:296
const char * iiTwoOps(int t)
Definition gentable.cc:256
#define jjWRONG2
Definition gentable.cc:123
#define jjWRONG
Definition gentable.cc:122
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:1420
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:2087
int lp_gkDim(const ideal _G)
Definition hdegree.cc:1833
int scMultInt(ideal S, ideal Q)
Definition hdegree.cc:901
poly hFirstSeries0m(ideal A, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const ring Qt)
Definition hilb.cc:2080
poly hFirstSeries0p(ideal A, ideal Q, intvec *wdegree, const ring src, const ring Qt)
Definition hilb.cc:2037
intvec * hSecondSeries(intvec *hseries1)
Definition hilb.cc:707
intvec * hFirstSeries(ideal A, intvec *module_w, ideal Q, intvec *wdegree)
Definition hilb.cc:2167
bigintmat * hFirstSeries0b(ideal I, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const coeffs biv_cf)
Definition hilb.cc:2672
bigintmat * hSecondSeries0b(ideal I, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const coeffs biv_cf)
Definition hilb.cc:2694
void scDegree(ideal S, intvec *modulweight, ideal Q)
Definition hilb.cc:2710
void hLookSeries(ideal S, intvec *modulweight, ideal Q, intvec *wdegree)
Definition hilb.cc:873
GbVariant syGetAlgorithm(char *n, const ring r, const ideal)
Definition ideals.cc:3642
matrix idCoeffOfKBase(ideal arg, ideal kbase, poly how)
Definition ideals.cc:2629
void idLiftW(ideal P, ideal Q, int n, matrix &T, ideal &R, int *w)
Definition ideals.cc:1336
ideal idSyzygies(ideal h1, tHomog h, intvec **w, BOOLEAN setSyzComp, BOOLEAN setRegularity, int *deg, GbVariant alg)
Definition ideals.cc:830
matrix idDiff(matrix i, int k)
Definition ideals.cc:2146
BOOLEAN idTestHomModule(ideal m, ideal Q, intvec *w)
Definition ideals.cc:2077
ideal idLiftStd(ideal h1, matrix *T, tHomog hi, ideal *S, GbVariant alg, ideal h11)
Definition ideals.cc:976
ideal idQuot(ideal h1, ideal h2, BOOLEAN h1IsStb, BOOLEAN resultIsIdeal)
Definition ideals.cc:1506
ideal idSeries(int n, ideal M, matrix U, intvec *w)
Definition ideals.cc:2129
ideal idMinEmbedding_with_map_v(ideal arg, intvec **w, ideal &trans, int *g)
Definition ideals.cc:2835
matrix idDiffOp(ideal I, ideal J, BOOLEAN multiply)
Definition ideals.cc:2159
ideal idElimination(ideal h1, poly delVar, intvec *hilb, GbVariant alg)
Definition ideals.cc:1605
ideal idSect(ideal h1, ideal h2, GbVariant alg)
Definition ideals.cc:315
ideal idMultSect(resolvente arg, int length, GbVariant alg)
Definition ideals.cc:471
ideal idLift(ideal mod, ideal submod, ideal *rest, BOOLEAN goodShape, BOOLEAN isSB, BOOLEAN divide, matrix *unit, GbVariant alg)
represents the generators of submod in terms of the generators of mod (Matrix(SM)*U-Matrix(rest)) = M...
Definition ideals.cc:1105
ideal idModulo(ideal h2, ideal h1, tHomog hom, intvec **w, matrix *T, GbVariant alg)
Definition ideals.cc:2422
ideal idMinBase(ideal h1, ideal *SB)
Definition ideals.cc:51
ideal id_Farey(ideal x, number N, const ring r)
Definition ideals.cc:3064
ideal idMinEmbedding(ideal arg, BOOLEAN inPlace, intvec **w)
Definition ideals.cc:2814
GbVariant
Definition ideals.h:119
@ GbDefault
Definition ideals.h:120
#define idDelete(H)
delete an ideal
Definition ideals.h:29
#define idSimpleAdd(A, B)
Definition ideals.h:42
#define idIsConstant(I)
Definition ideals.h:40
ideal id_Copy(ideal h1, const ring r)
copy an ideal
static BOOLEAN idIsZeroDim(ideal i)
Definition ideals.h:179
static BOOLEAN idHomModule(ideal m, ideal Q, intvec **w)
Definition ideals.h:96
#define idTest(id)
Definition ideals.h:47
static BOOLEAN idHomIdeal(ideal id, ideal Q=NULL)
Definition ideals.h:91
static ideal idMult(ideal h1, ideal h2)
hh := h1 * h2
Definition ideals.h:84
ideal idCopy(ideal A)
Definition ideals.h:60
ideal idAdd(ideal h1, ideal h2)
h1 + h2
Definition ideals.h:68
#define idMaxIdeal(D)
initialise the maximal ideal (at 0)
Definition ideals.h:33
ideal * resolvente
Definition ideals.h:18
static intvec * idSort(ideal id, BOOLEAN nolex=TRUE)
Definition ideals.h:187
ideal interpolation(const std::vector< ideal > &L, intvec *v)
EXTERN_VAR int inerror
static BOOLEAN length(leftv result, leftv arg)
Definition interval.cc:257
intvec * ivSub(intvec *a, intvec *b)
Definition intvec.cc:297
int ivTrace(intvec *o)
Definition intvec.cc:339
intvec * ivAdd(intvec *a, intvec *b)
Definition intvec.cc:249
intvec * ivMult(intvec *a, intvec *b)
Definition intvec.cc:349
intvec * ivTranp(intvec *o)
Definition intvec.cc:327
intvec * ivCopy(const intvec *o)
Definition intvec.h:145
#define ivTest(v)
Definition intvec.h:169
#define IMATELEM(M, I, J)
Definition intvec.h:85
static BOOLEAN jjUMINUS_MA(leftv res, leftv u)
Definition iparith.cc:3827
static BOOLEAN jjOP_BIM_I(leftv res, leftv u, leftv v)
Definition iparith.cc:242
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:1521
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:3100
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:1097
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:278
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:2045
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:331
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:1093
static BOOLEAN jjMAP(leftv res, leftv u, leftv v)
Definition iparith.cc:1650
static BOOLEAN jjGT_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:1181
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:125
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:314
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:2606
static BOOLEAN jjNULL(leftv, leftv)
Definition iparith.cc:3777
static BOOLEAN jjNEWSTRUCT2(leftv, leftv u, leftv v)
Definition iparith.cc:2804
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:2739
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:2915
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:132
static BOOLEAN jjMULT(leftv res, leftv v)
Definition iparith.cc:4734
static BOOLEAN jjHOMOG1_WI(leftv res, leftv v, leftv u)
Definition iparith.cc:2504
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:3107
static BOOLEAN jjIDEAL_Ma(leftv res, leftv v)
Definition iparith.cc:4411
static BOOLEAN jjDIVISION(leftv res, leftv u, leftv v)
Definition iparith.cc:1951
static BOOLEAN jjOP_I_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:295
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:1320
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:907
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:2586
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:1122
static BOOLEAN jjDIM_R(leftv res, leftv v)
Definition iparith.cc:5755
BOOLEAN jjSORTLIST(leftv, leftv arg)
Definition iparith.cc:10470
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:10429
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:2875
static BOOLEAN jjTIMES_SM(leftv res, leftv u, leftv v)
Definition iparith.cc:1149
static BOOLEAN jjMOD_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:2694
BOOLEAN jjUNIQLIST(leftv, leftv arg)
Definition iparith.cc:10479
static BOOLEAN jjTIMES_MA_I2(leftv res, leftv u, leftv v)
Definition iparith.cc:1131
static BOOLEAN jjSTATUS2L(leftv res, leftv u, leftv v)
Definition iparith.cc:3435
BOOLEAN(* proc3)(leftv, leftv, leftv, leftv)
Definition iparith.cc:159
static BOOLEAN jjGT_I(leftv res, leftv u, leftv v)
Definition iparith.cc:1188
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:1326
static BOOLEAN jjTIMES_MA_P2(leftv res, leftv u, leftv v)
Definition iparith.cc:1106
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:822
short tokval
Definition gentable.cc:58
static BOOLEAN jjMINUS_V(leftv res, leftv u, leftv v)
Definition iparith.cc:902
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:1052
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:1220
static BOOLEAN jjMINUS_MA(leftv res, leftv u, leftv v)
Definition iparith.cc:950
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:2017
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:1866
static BOOLEAN jjLE_N(leftv res, leftv u, leftv v)
Definition iparith.cc:1207
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:477
#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:1382
static BOOLEAN jjTIMES_MA_I1(leftv res, leftv u, leftv v)
Definition iparith.cc:1126
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:1115
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:119
short cmd
Definition iparith.cc:124
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:940
static BOOLEAN jjnInt(leftv res, leftv u)
Definition iparith.cc:5765
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:897
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:2780
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:1845
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:930
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:2445
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:184
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:1198
static BOOLEAN jjPLUS_B_P(leftv res, leftv u, leftv v)
Definition iparith.cc:793
static BOOLEAN jjPlural_mat_mat(leftv res, leftv a, leftv b)
Definition iparith.cc:2895
static BOOLEAN jjIDEAL_Map(leftv res, leftv v)
Definition iparith.cc:4420
static BOOLEAN jjPARSTR2(leftv res, leftv u, leftv v)
Definition iparith.cc:2818
BOOLEAN(* proc2)(leftv, leftv, leftv)
Definition iparith.cc:148
static BOOLEAN jjKoszul(leftv res, leftv u, leftv v)
Definition iparith.cc:2574
static BOOLEAN jjTIMES_N(leftv res, leftv u, leftv v)
Definition iparith.cc:995
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:1135
static BOOLEAN jjTIMES_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1059
#define NO_CONVERSION
Definition iparith.cc:115
static BOOLEAN jjPLUS_I(leftv res, leftv u, leftv v)
Definition iparith.cc:753
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:3148
static BOOLEAN jjCOEF(leftv res, leftv u, leftv v)
Definition iparith.cc:1790
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:504
static BOOLEAN jjEXECUTE(leftv, leftv v)
Definition iparith.cc:4205
static BOOLEAN jjDEG_M_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1834
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:802
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:1175
static BOOLEAN jjEQUAL_SM(leftv res, leftv u, leftv v)
Definition iparith.cc:1338
static BOOLEAN jjINTERPOLATION(leftv res, leftv l, leftv v)
Definition iparith.cc:2524
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:3140
static BOOLEAN jjDIV_Ma(leftv res, leftv u, leftv v)
Definition iparith.cc:1291
static BOOLEAN jjFRES3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:2311
static BOOLEAN jjMODULO(leftv res, leftv u, leftv v)
Definition iparith.cc:2641
static BOOLEAN jjCOMPARE_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:337
STATIC_VAR int WerrorS_dummy_cnt
Definition iparith.cc:5646
static BOOLEAN jjREAD2(leftv res, leftv u, leftv v)
Definition iparith.cc:3124
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:181
static BOOLEAN jjFAREY_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:2142
static BOOLEAN jjPLUS_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:871
static BOOLEAN jjGCD_N(leftv res, leftv u, leftv v)
Definition iparith.cc:2384
static BOOLEAN jjELIMIN(leftv res, leftv u, leftv v)
Definition iparith.cc:1971
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:1679
static BOOLEAN jjROWS(leftv res, leftv v)
Definition iparith.cc:5007
static BOOLEAN jjJET_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:2552
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:299
static BOOLEAN jjJanetBasis(leftv res, leftv v)
Definition iparith.cc:2542
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:2358
static BOOLEAN jjTEST(leftv, leftv v)
Definition iparith.cc:8626
static BOOLEAN jjDIFF_ID_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:1929
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:2061
static BOOLEAN jjDIVISION4(leftv res, leftv v)
Definition iparith.cc:7383
unsigned nLastIdentifier
valid identifiers are slot 1..nLastIdentifier
Definition iparith.cc:188
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:1670
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:257
static BOOLEAN jjCOUNT_N(leftv res, leftv v)
Definition iparith.cc:3988
static BOOLEAN jjHILBERT2(leftv res, leftv u, leftv v)
Definition iparith.cc:2407
static BOOLEAN jjFIND2(leftv res, leftv u, leftv v)
Definition iparith.cc:2293
static BOOLEAN jjCOEF_Id(leftv res, leftv u, leftv v)
Definition iparith.cc:1797
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:623
static BOOLEAN jjTIMES_MA_BI1(leftv res, leftv u, leftv v)
Definition iparith.cc:1083
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:1815
#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:770
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:1215
static BOOLEAN jjIS_RINGVAR0(leftv res, leftv)
Definition iparith.cc:4492
static BOOLEAN jjEXTGCD_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:2003
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:2364
static BOOLEAN jjCONTRACT(leftv res, leftv u, leftv v)
Definition iparith.cc:1829
short toktype
Definition gentable.cc:59
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:10410
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:215
static BOOLEAN jjDelete_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1859
static BOOLEAN jjGE_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:1163
static BOOLEAN jjrOrdStr(leftv res, leftv v)
Definition iparith.cc:5735
static BOOLEAN jjKERNEL(leftv res, leftv u, leftv v)
Definition iparith.cc:2570
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:128
static BOOLEAN jjMOD_N(leftv res, leftv u, leftv v)
Definition iparith.cc:2705
static BOOLEAN jjLOAD_E(leftv, leftv v, leftv u)
Definition iparith.cc:2630
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:1344
static BOOLEAN jjCOUNT_L(leftv res, leftv v)
Definition iparith.cc:3993
struct sValCmdM * psValCmdM
Definition iparith.cc:185
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:2518
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:274
static BOOLEAN jjDIFF_P(leftv res, leftv u, leftv v)
Definition iparith.cc:1907
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:917
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:1387
static BOOLEAN jjPOWER_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:566
static BOOLEAN jjMONITOR1(leftv res, leftv v)
Definition iparith.cc:2735
static BOOLEAN jjKLAMMER_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1569
static BOOLEAN jjFETCH(leftv res, leftv u, leftv v)
Definition iparith.cc:2165
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:1005
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:834
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:217
static BOOLEAN jjMINUS_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:892
static BOOLEAN jjTIMES_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:988
static BOOLEAN jjFACSTD2(leftv res, leftv v, leftv w)
Definition iparith.cc:2109
static BOOLEAN jjINTVEC_PL(leftv res, leftv v)
Definition iparith.cc:7887
STATIC_VAR SArithBase sArithBase
Base entry for arithmetic.
Definition iparith.cc:196
static BOOLEAN jjEXPORTTO(leftv, leftv u, leftv v)
Definition iparith.cc:1991
static BOOLEAN jjPlural_num_poly(leftv res, leftv a, leftv b)
Definition iparith.cc:2835
static BOOLEAN jjDIV_P(leftv res, leftv u, leftv v)
Definition iparith.cc:1273
static BOOLEAN jjKBASE2(leftv res, leftv u, leftv v)
Definition iparith.cc:2557
#define WARN_RING
Definition iparith.cc:113
static BOOLEAN jjPOWER_I(leftv res, leftv u, leftv v)
Definition iparith.cc:520
#define SIMPL_MULT
Definition iparith.cc:3342
static BOOLEAN jjRES(leftv res, leftv u, leftv v)
Definition iparith.cc:3157
static int iin_Int(number &n, coeffs cf)
Definition iparith.cc:220
static BOOLEAN jjPLUS_P_MA(leftv res, leftv u, leftv v)
Definition iparith.cc:857
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:812
#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:1170
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:1193
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:213
static BOOLEAN jjCOMPARE_P(leftv res, leftv u, leftv v)
Definition iparith.cc:450
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:846
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:1977
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:1918
static BOOLEAN jjSTD(leftv res, leftv v)
Definition iparith.cc:5153
static BOOLEAN jjTIMES_BIM(leftv res, leftv u, leftv v)
Definition iparith.cc:1071
EXTERN_VAR int cmdtok
Definition iparith.cc:212
static BOOLEAN jjTIMES_I(leftv res, leftv u, leftv v)
Definition iparith.cc:976
static BOOLEAN jjDIV_N(leftv res, leftv u, leftv v)
Definition iparith.cc:1260
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:2348
unsigned nCmdAllocated
number of commands-slots allocated
Definition iparith.cc:187
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:1557
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:57
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:422
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:2131
static BOOLEAN jjBRACKET_REC(leftv res, leftv a, leftv b, leftv c)
Definition iparith.cc:2942
static BOOLEAN jjCOMPARE_IV_I(leftv res, leftv u, leftv v)
Definition iparith.cc:395
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:182
static BOOLEAN jjDIVMOD_I(leftv res, leftv u, leftv v)
Definition iparith.cc:1224
static BOOLEAN jjLE_I(leftv res, leftv u, leftv v)
Definition iparith.cc:1202
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:1614
static BOOLEAN jjPLUS_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:765
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:1893
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:1377
static BOOLEAN jjINDEX_P_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1485
static BOOLEAN jjRPAR(leftv res, leftv v)
Definition iparith.cc:5023
static BOOLEAN jjJanetBasis2(leftv res, leftv u, leftv v)
Definition iparith.cc:2536
static BOOLEAN jjLOAD1(leftv, leftv v)
Definition iparith.cc:4628
static BOOLEAN jjCOLON(leftv res, leftv u, leftv v)
Definition iparith.cc:318
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:691
long all_farey
Definition iparith.cc:8
static BOOLEAN jjFAC_P2(leftv res, leftv u, leftv dummy)
Definition iparith.cc:2062
static BOOLEAN jjHOMOG_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:2462
static BOOLEAN jjrParStr(leftv res, leftv v)
Definition iparith.cc:5745
struct sValCmd2 * psValCmd2
Definition iparith.cc:183
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:1514
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:1934
static BOOLEAN jjOP_BIM_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:261
static BOOLEAN jjGCD_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:2377
static BOOLEAN jjBI2IM(leftv res, leftv u)
Definition iparith.cc:3917
static BOOLEAN jjRANK2(leftv res, leftv u, leftv v)
Definition iparith.cc:3115
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:2511
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:963
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:1445
static BOOLEAN jjHIGHCORNER(leftv res, leftv v)
Definition iparith.cc:4284
static BOOLEAN jjEQUAL_Ma(leftv res, leftv u, leftv v)
Definition iparith.cc:1332
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:2626
static BOOLEAN jjALIGN_M(leftv res, leftv u, leftv v)
Definition iparith.cc:1776
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:1247
static BOOLEAN jjCOMPARE_BIM(leftv res, leftv u, leftv v)
Definition iparith.cc:365
static BOOLEAN jjEQUAL_N(leftv res, leftv u, leftv v)
Definition iparith.cc:1350
static BOOLEAN jjDelete_ID_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1873
static BOOLEAN jjDET2_S(leftv res, leftv u, leftv v)
Definition iparith.cc:1900
static BOOLEAN jjCOEFFS_Id(leftv res, leftv u, leftv v)
Definition iparith.cc:1804
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:2983
static BOOLEAN jjMOD_P(leftv res, leftv u, leftv v)
Definition iparith.cc:2716
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:780
static BOOLEAN jjGCD_P(leftv res, leftv u, leftv v)
Definition iparith.cc:2401
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:1364
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:775
#define SIMPL_LMDIV
Definition iparith.cc:3340
int iiTokType(int op)
Definition iparith.cc:228
static BOOLEAN jjKoszul_Id(leftv res, leftv u, leftv v)
Definition iparith.cc:2578
static BOOLEAN jjKLAMMER_rest(leftv res, leftv u, leftv v)
Definition iparith.cc:1596
static BOOLEAN jjCHINREM_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:10211
static BOOLEAN jjPLUS_S(leftv res, leftv u, leftv v)
Definition iparith.cc:861
static BOOLEAN jjHOMOG1_W(leftv res, leftv v, leftv u)
Definition iparith.cc:2484
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:1409
char si_char_2[2]
Definition iparith.cc:9882
unsigned nCmdUsed
number of commands used
Definition iparith.cc:186
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:876
static BOOLEAN jjJET_P(leftv res, leftv u, leftv v)
Definition iparith.cc:2547
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:3056
static BOOLEAN jjLT_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:1211
static BOOLEAN jjPOWER_P(leftv res, leftv u, leftv v)
Definition iparith.cc:600
#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:629
static BOOLEAN jjCALL2ARG(leftv res, leftv u)
Definition iparith.cc:7346
static BOOLEAN jjINDEX_PBu(leftv res, leftv u, leftv v)
Definition iparith.cc:1462
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:582
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:1356
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:2855
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:1996
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:1766
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:1320
VAR omBin sip_command_bin
Definition ipid.cc:45
lists ipNameListLev(idhdl root, int lev)
Definition ipid.cc:629
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition ipid.cc:258
VAR package basePack
Definition ipid.cc:58
VAR idhdl currRingHdl
Definition ipid.cc:59
VAR package currPack
Definition ipid.cc:57
lists ipNameList(idhdl root)
Definition ipid.cc:606
VAR coeffs coeffs_BIGINT
Definition ipid.cc:50
#define IDMAP(a)
Definition ipid.h:135
#define IDMATRIX(a)
Definition ipid.h:134
EXTERN_VAR omBin sleftv_bin
Definition ipid.h:145
ip_command * command
Definition ipid.h:23
#define IDDATA(a)
Definition ipid.h:126
#define hasFlag(A, F)
Definition ipid.h:112
#define setFlag(A, F)
Definition ipid.h:113
#define IDIDEAL(a)
Definition ipid.h:133
#define IDPOLY(a)
Definition ipid.h:130
#define IDID(a)
Definition ipid.h:122
#define IDROOT
Definition ipid.h:19
#define IDINT(a)
Definition ipid.h:125
#define FLAG_TWOSTD
Definition ipid.h:107
BOOLEAN load_builtin(const char *newlib, BOOLEAN autoexport, SModulFunc_t init)
Definition iplib.cc:1303
#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:982
char * iiConvName(const char *libname)
Definition iplib.cc:1438
BOOLEAN iiGetLibStatus(const char *lib)
Definition iplib.cc:77
BOOLEAN iiMake_proc(idhdl pn, package pack, leftv args)
Definition iplib.cc:512
BOOLEAN iiTryLoadLib(leftv v, const char *id)
Definition iplib.cc:831
BOOLEAN load_modules(const char *newlib, char *fullname, BOOLEAN autoexport)
Definition iplib.cc:1293
INST_VAR sleftv iiRETURNEXPR
Definition iplib.cc:482
SModulFunc_t iiGetBuiltinModInit(const char *libname)
Definition iplib.cc:815
lists rDecompose(const ring r)
Definition ipshell.cc:2151
lists rDecompose_list_cf(const ring r)
Definition ipshell.cc:2112
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:6565
ring rInit(leftv pn, leftv rv, leftv ord)
Definition ipshell.cc:5620
leftv iiMap(map theMap, const char *what)
Definition ipshell.cc:613
int iiRegularity(lists L)
Definition ipshell.cc:1036
BOOLEAN rDecompose_CF(leftv res, const coeffs C)
Definition ipshell.cc:1941
void iiMakeResolv(resolvente r, int length, int rlen, char *name, int typ0, intvec **weights)
Definition ipshell.cc:845
void killlocals(int v)
Definition ipshell.cc:386
int exprlist_length(leftv v)
Definition ipshell.cc:550
BOOLEAN mpKoszul(leftv res, leftv c, leftv b, leftv id)
Definition ipshell.cc:3086
poly iiHighCorner(ideal I, int ak)
Definition ipshell.cc:1605
lists scIndIndset(ideal S, BOOLEAN all, ideal Q)
Definition ipshell.cc:1102
idhdl rFindHdl(ring r, idhdl n)
Definition ipshell.cc:1699
syStrategy syConvList(lists li)
Definition ipshell.cc:3249
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:2780
const char * lastreserved
Definition ipshell.cc:82
lists syConvRes(syStrategy syzstr, BOOLEAN toDel, int add_row_shift)
Definition ipshell.cc:3177
void rSetHdl(idhdl h)
Definition ipshell.cc:5121
BOOLEAN iiExport(leftv v, int toLev)
Definition ipshell.cc:1510
const struct sValCmd1 dArith1[]
Definition table.h:37
short arg
Definition gentable.cc:78
short res
Definition gentable.cc:68
BOOLEAN(* proc3)(leftv, leftv, leftv, leftv)
Definition ipshell.h:145
proc3 p
Definition iparith.cc:162
short arg1
Definition gentable.cc:69
proc1 p
Definition iparith.cc:141
const struct sValCmd2 dArith2[]
Definition table.h:324
short number_of_args
Definition gentable.cc:96
short valid_for
Definition gentable.cc:97
BOOLEAN(* proc2)(leftv, leftv, leftv)
Definition ipshell.h:134
BOOLEAN setOption(leftv res, leftv v)
Definition misc_ip.cc:568
short cmd
Definition gentable.cc:84
short cmd
Definition gentable.cc:67
short valid_for
Definition gentable.cc:89
short cmd
Definition gentable.cc:76
short valid_for
Definition gentable.cc:71
short res
Definition gentable.cc:95
short res
Definition gentable.cc:85
short arg1
Definition gentable.cc:86
proc1 p
Definition iparith.cc:172
short arg2
Definition gentable.cc:87
BOOLEAN(* proc1)(leftv, leftv)
Definition ipshell.h:122
const struct sValCmdM dArithM[]
Definition table.h:936
short valid_for
Definition gentable.cc:79
short arg3
Definition gentable.cc:88
proc2 p
Definition iparith.cc:151
short res
Definition gentable.cc:77
short arg2
Definition gentable.cc:70
const struct sValCmd3 dArith3[]
Definition table.h:800
short cmd
Definition gentable.cc:94
STATIC_VAR jList * T
Definition janet.cc:30
STATIC_VAR Poly * h
Definition janet.cc:971
ListNode * next
Definition janet.h:31
ideal id_Farey_0(ideal x, number N, const ring r)
Definition kChinese.cc:298
ideal id_ChineseRemainder_0(ideal *xx, number *q, int rl, const ring r)
Definition kChinese.cc:196
long kHomModDeg(poly p, const ring r)
Definition kstd1.cc:2424
ideal kMin_std(ideal F, ideal Q, tHomog h, intvec **w, ideal &M, intvec *hilb, int syzComp, int reduced)
Definition kstd1.cc:3074
ideal kInterRed(ideal F, const ideal Q)
Definition kstd1.cc:3806
VAR intvec * kHomW
Definition kstd1.cc:2412
VAR intvec * kModW
Definition kstd1.cc:2412
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition kstd1.cc:3225
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:2673
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:2471
EXTERN_VAR int Kstd1_deg
Definition kstd1.h:50
ideal rightgb(ideal F, const ideal Q)
Definition kstd2.cc:4938
poly redNF(poly h, int &max_ind, int nonorm, kStrategy strat)
Definition kstd2.cc:2302
ideal_list kStdfac(ideal F, ideal Q, tHomog h, intvec **w, ideal D)
Definition kstdfac.cc:798
char * showOption()
Definition misc_ip.cc:709
VAR idhdl h0
Definition libparse.cc:1143
VAR char libnamebuf[1024]
Definition libparse.cc:1098
static bool rIsSCA(const ring r)
Definition nc.h:190
ideal idOppose(ring Rop_src, ideal I, const ring Rop_dst)
opposes a module I from Rop to currRing(dst)
poly pOppose(ring Rop_src, poly p, const ring Rop_dst)
opposes a vector p from Rop to currRing (dst!)
BOOLEAN rIsLikeOpposite(ring rBase, ring rCandidate)
checks whether rings rBase and rCandidate could be opposite to each other returns TRUE if it is so
BOOLEAN nc_CallPlural(matrix cc, matrix dd, poly cn, poly dn, ring r, bool bSetupQuotient, bool bCopyInput, bool bBeQuiet, ring curr, bool dummy_ring=false)
returns TRUE if there were errors analyze inputs, check them for consistency detects nc_type,...
poly nc_p_Bracket_qq(poly p, const poly q, const ring r)
returns [p,q], destroys p
int luRank(const matrix aMat, const bool isRowEchelon, const ring R)
Computes the rank of a given (m x n)-matrix.
bool luInverseFromLUDecomp(const matrix pMat, const matrix lMat, const matrix uMat, matrix &iMat, const ring R)
This code computes the inverse by inverting lMat and uMat, and then performing two matrix multiplicat...
void henselFactors(const int xIndex, const int yIndex, const poly h, const poly f0, const poly g0, const int d, poly &f, poly &g)
Computes a factorization of a polynomial h(x, y) in K[[x]][y] up to a certain degree in x,...
bool luInverse(const matrix aMat, matrix &iMat, const ring R)
This code first computes the LU-decomposition of aMat, and then calls the method for inverting a matr...
void luDecomp(const matrix aMat, matrix &pMat, matrix &lMat, matrix &uMat, const ring R)
LU-decomposition of a given (m x n)-matrix.
bool luSolveViaLUDecomp(const matrix pMat, const matrix lMat, const matrix uMat, const matrix bVec, matrix &xVec, matrix &H)
Solves the linear system A * x = b, where A is an (m x n)-matrix which is given by its LU-decompositi...
lists qrDoubleShift(const matrix A, const number tol1, const number tol2, const number tol3, const ring r=currRing)
Computes all eigenvalues of a given real quadratic matrix with multiplicites.
VAR omBin slists_bin
Definition lists.cc:23
int lSize(lists L)
Definition lists.cc:25
BOOLEAN jjANY2LIST(leftv res, leftv v, int cnt)
LINLINE void nlDelete(number *a, const coeffs r)
Definition longrat.cc:2658
LINLINE number nlInit(long i, const coeffs r)
Definition longrat.cc:2598
void maFetchPermLP(const ring preimage_r, const ring dst_r, int *perm)
Definition maps.cc:306
void maFindPerm(char const *const *const preim_names, int preim_n, char const *const *const preim_par, int preim_p, char const *const *const names, int n, char const *const *const par, int nop, int *perm, int *par_perm, n_coeffType ch)
Definition maps.cc:163
void maFindPermLP(char const *const *const preim_names, int preim_n, char const *const *const preim_par, int preim_p, char const *const *const names, int n, char const *const *const par, int nop, int *perm, int *par_perm, n_coeffType ch, int lV)
Definition maps.cc:231
poly pSubstPoly(poly p, int var, poly image)
Definition maps_ip.cc:402
ideal idSubstPoly(ideal id, int n, poly e)
Definition maps_ip.cc:424
BOOLEAN maApplyFetch(int what, map theMap, leftv res, leftv w, ring preimage_r, int *perm, int *par_perm, int P, nMapFunc nMap)
Definition maps_ip.cc:45
ideal idSubstPar(ideal id, int n, poly e)
Definition maps_ip.cc:385
poly pSubstPar(poly p, int par, poly image)
Definition maps_ip.cc:265
BOOLEAN mp_IsDiagUnit(matrix U, const ring R)
Definition matpol.cc:809
matrix mp_Wedge(matrix a, int ar, const ring R)
Definition matpol.cc:1744
matrix mp_Transp(matrix a, const ring R)
Definition matpol.cc:247
ideal sm_Tensor(ideal A, ideal B, const ring r)
Definition matpol.cc:1824
ideal sm_Add(ideal a, ideal b, const ring R)
Definition matpol.cc:1864
matrix mp_CoeffProc(poly f, poly vars, const ring R)
Definition matpol.cc:392
matrix pMultMp(poly p, matrix a, const ring R)
Definition matpol.cc:158
void mp_Monomials(matrix c, int r, int var, matrix m, const ring R)
Definition matpol.cc:355
DetVariant mp_GetAlgorithmDet(matrix m, const ring r)
Definition matpol.cc:2105
matrix mp_CoeffProcId(ideal I, poly vars, const ring R)
Definition matpol.cc:469
poly sm_Det(ideal a, const ring r, DetVariant d)
Definition matpol.cc:2160
matrix mp_MultI(matrix a, long f, const ring R)
c = f*a
Definition matpol.cc:128
ideal sm_Sub(ideal a, ideal b, const ring R)
Definition matpol.cc:1874
ideal sm_Mult(ideal a, ideal b, const ring R)
Definition matpol.cc:1884
matrix mp_Sub(matrix a, matrix b, const ring R)
Definition matpol.cc:189
poly mp_Det(matrix a, const ring r, DetVariant d)
Definition matpol.cc:2136
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition matpol.cc:37
int mp_Compare(matrix a, matrix b, const ring R)
Definition matpol.cc:636
BOOLEAN sm_Equal(ideal a, ideal b, const ring R)
Definition matpol.cc:1996
matrix mp_Mult(matrix a, matrix b, const ring R)
Definition matpol.cc:206
BOOLEAN mp_Equal(matrix a, matrix b, const ring R)
Definition matpol.cc:655
matrix mp_Coeffs(ideal I, int var, const ring R)
corresponds to Maple's coeffs: var has to be the number of a variable
Definition matpol.cc:306
void mp_Coef2(poly v, poly mon, matrix *c, matrix *m, const ring R)
corresponds to Macauley's coef: the exponent vector of vars has to contain the variables,...
Definition matpol.cc:574
matrix mp_MultP(matrix a, poly p, const ring R)
multiply a matrix 'a' by a poly 'p', destroy the args
Definition matpol.cc:141
matrix mp_Copy(matrix a, const ring r)
copies matrix a (from ring r to r)
Definition matpol.cc:57
matrix mp_Add(matrix a, matrix b, const ring R)
Definition matpol.cc:172
matrix mp_InitP(int r, int c, poly p, const ring R)
make it a p * unit matrix
Definition matpol.cc:106
poly mp_Trace(matrix a, const ring R)
Definition matpol.cc:268
#define MATELEM(mat, i, j)
1-based access to matrix
Definition matpol.h:29
ip_smatrix * matrix
Definition matpol.h:43
#define MATROWS(i)
Definition matpol.h:26
#define MATCOLS(i)
Definition matpol.h:27
DetVariant
Definition matpol.h:35
lists primeFactorisation(const number n, const int pBound)
Factorises a given bigint number n into its prime factors less than or equal to a given bound,...
Definition misc_ip.cc:357
This file provides miscellaneous functionality.
#define TIMER_RESOLUTION
Definition mod2.h:35
#define assume(x)
Definition mod2.h:387
lib_types type_of_LIB(const char *newlib, char *libnamebuf)
Definition mod_lib.cc:27
lib_types
Definition mod_raw.h:16
@ LT_MACH_O
Definition mod_raw.h:16
@ LT_HPUX
Definition mod_raw.h:16
@ LT_SINGULAR
Definition mod_raw.h:16
@ LT_BUILTIN
Definition mod_raw.h:16
@ LT_ELF
Definition mod_raw.h:16
@ LT_NONE
Definition mod_raw.h:16
@ LT_NOTFOUND
Definition mod_raw.h:16
#define pIter(p)
Definition monomials.h:37
#define pNext(p)
Definition monomials.h:36
#define pSetCoeff0(p, n)
Definition monomials.h:59
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition monomials.h:44
BOOLEAN nuLagSolve(leftv res, leftv arg1, leftv arg2, leftv arg3)
find the (complex) roots an univariate polynomial Determines the roots of an univariate polynomial us...
Definition ipshell.cc:4673
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:87
#define OPT_SB_1
Definition options.h:95
#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:113
#define TEST_OPT_RETURN_SB
Definition options.h:112
#define TEST_OPT_PROT
Definition options.h:103
#define V_IMAP
Definition options.h:53
#define V_DEG_STOP
Definition options.h:72
#define V_SHOW_USE
Definition options.h:52
static int index(p_Length length, p_Ord ord)
void pRestoreDegProcs(ring r, pFDegProc old_FDeg, pLDegProc old_lDeg)
Definition p_polys.cc:3670
poly p_Homogen(poly p, int varnum, const ring r)
Definition p_polys.cc:3274
poly pp_DivideM(poly a, poly b, const ring r)
Definition p_polys.cc:1637
void p_Shift(poly *p, int i, const ring r)
shifts components of the vector p by i
Definition p_polys.cc:4755
void p_Normalize(poly p, const ring r)
Definition p_polys.cc:3834
int p_MaxExpPerVar(poly p, int i, const ring r)
max exponent of variable x_i in p
Definition p_polys.cc:5041
int p_Compare(const poly a, const poly b, const ring R)
Definition p_polys.cc:4945
poly p_Series(int n, poly p, poly u, intvec *w, const ring R)
Definition p_polys.cc:4547
long p_DegW(poly p, const int *w, const ring R)
Definition p_polys.cc:691
poly p_Cleardenom(poly p, const ring r)
Definition p_polys.cc:2849
poly p_Vec2Poly(poly v, int k, const ring r)
Definition p_polys.cc:3594
void p_SetModDeg(intvec *w, ring r)
Definition p_polys.cc:3694
poly p_One(const ring r)
Definition p_polys.cc:1314
void pSetDegProcs(ring r, pFDegProc new_FDeg, pLDegProc new_lDeg)
Definition p_polys.cc:3658
long p_Deg(poly a, const ring r)
Definition p_polys.cc:586
static poly p_Neg(poly p, const ring r)
Definition p_polys.h:1107
static int pLength(poly a)
Definition p_polys.h:190
static long p_MinComp(poly p, ring lmRing, ring tailRing)
Definition p_polys.h:313
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:901
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition p_polys.h:1160
static long p_Totaldegree(poly p, const ring r)
Definition p_polys.h:1521
void rChangeCurrRing(ring r)
Definition polys.cc:15
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
poly pp_Divide(poly p, poly q, const ring r)
polynomial division a/b, ignoring the rest via singclap_pdivide resp. idLift does not destroy a,...
Definition polys.cc:174
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:380
Compatibility layer for legacy polynomial operations (over currRing)
#define pAdd(p, q)
Definition polys.h:203
static long pTotaldegree(poly p)
Definition polys.h:282
#define pDelete(p_ptr)
Definition polys.h:186
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL
Definition polys.h:67
#define pSetm(p)
Definition polys.h:271
#define pIsConstant(p)
like above, except that Comp must be 0
Definition polys.h:238
#define pSplit(p, r)
Definition polys.h:265
#define pNeg(p)
Definition polys.h:198
#define pGetComp(p)
Component.
Definition polys.h:37
#define pDiff(a, b)
Definition polys.h:296
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
Definition polys.h:31
void pNorm(poly p)
Definition polys.h:362
#define pNSet(n)
Definition polys.h:313
#define pVar(m)
Definition polys.h:380
#define pJet(p, m)
Definition polys.h:367
#define pSub(a, b)
Definition polys.h:287
#define ppMult_qq(p, q)
Definition polys.h:208
#define ppJetW(p, m, iv)
Definition polys.h:368
#define pMaxComp(p)
Definition polys.h:299
#define pLmInit(p)
like pInit, except that expvector is initialized to that of p, p must be != NULL
Definition polys.h:64
#define pIsUnit(p)
return true if the Lm is a constant <>0
Definition polys.h:240
#define pPower(p, q)
Definition polys.h:204
#define pSetComp(p, v)
Definition polys.h:38
#define pLmDelete(p)
assume p != NULL, deletes Lm(p)->coef and Lm(p)
Definition polys.h:76
#define pMult(p, q)
Definition polys.h:207
static void pLmFree(poly p)
frees the space of the monomial m, assumes m != NULL coef is not freed, m is not advanced
Definition polys.h:70
#define pSubst(p, n, e)
Definition polys.h:365
#define pSeries(n, p, u, w)
Definition polys.h:371
#define pGetExp(p, i)
Exponent.
Definition polys.h:41
#define pNormalize(p)
Definition polys.h:317
#define pInit()
allocates a new monomial and initializes everything to 0
Definition polys.h:61
#define pEqualPolys(p1, p2)
Definition polys.h:399
#define pSetExp(p, i, v)
Definition polys.h:42
#define pLmCmp(p, q)
returns 0|1|-1 if p=q|p>q|p<q w.r.t monomial ordering
Definition polys.h:105
#define pCopy(p)
return a copy of the poly
Definition polys.h:185
#define pLmFreeAndNext(p)
assumes p != NULL, deletes p, returns pNext(p)
Definition polys.h:74
#define pOne()
Definition polys.h:315
#define pIsUnivariate(p)
Definition polys.h:249
#define pISet(i)
Definition polys.h:312
#define pWTotaldegree(p)
Definition polys.h:283
ideal maGetPreimage(ring theImageRing, map theMap, ideal id, const ring dst_r)
Definition preimage.cc:57
int IsPrime(int p)
Definition prime.cc:61
void SPrintStart()
Definition reporter.cc:246
const char feNotImplemented[]
Definition reporter.cc:54
void PrintS(const char *s)
Definition reporter.cc:284
char * SPrintEnd()
Definition reporter.cc:273
void PrintLn()
Definition reporter.cc:310
void Werror(const char *fmt,...)
Definition reporter.cc:189
EXTERN_VAR int traceit
Definition reporter.h:24
#define TRACE_CALL
Definition reporter.h:44
#define SI_PROT_O
Definition reporter.h:54
#define SI_PROT_I
Definition reporter.h:53
#define mflush()
Definition reporter.h:58
int rSum(ring r1, ring r2, ring &sum)
Definition ring.cc:1405
int r_IsRingVar(const char *n, char **names, int N)
Definition ring.cc:213
int rChar(ring r)
Definition ring.cc:716
ring rMinusVar(const ring r, char *v)
undo rPlusVar
Definition ring.cc:5963
BOOLEAN rSamePolyRep(ring r1, ring r2)
returns TRUE, if r1 and r2 represents the monomials in the same way FALSE, otherwise this is an analo...
Definition ring.cc:1802
char * rParStr(ring r)
Definition ring.cc:652
char * rCharStr(const ring r)
TODO: make it a virtual method of coeffs, together with: Decompose & Compose, rParameter & rPar.
Definition ring.cc:650
ring rOpposite(ring src)
Definition ring.cc:5364
char * rOrdStr(ring r)
Definition ring.cc:524
void rDelete(ring r)
unconditionally deletes fields in r
Definition ring.cc:452
ring rDefault(const coeffs cf, int N, char **n, int ord_size, rRingOrder_t *ord, int *block0, int *block1, int **wvhdl, unsigned long bitmask)
Definition ring.cc:103
char * rVarStr(ring r)
Definition ring.cc:626
ring rPlusVar(const ring r, char *v, int left)
K[x],"y" -> K[x,y] resp. K[y,x].
Definition ring.cc:5881
ring rEnvelope(ring R)
Definition ring.cc:5758
int n_IsParam(const number m, const ring r)
TODO: rewrite somehow...
Definition ring.cc:5860
ring rCopy(ring r)
Definition ring.cc:1734
static BOOLEAN rField_is_Zp_a(const ring r)
Definition ring.h:534
static BOOLEAN rField_is_Z(const ring r)
Definition ring.h:514
static BOOLEAN rField_is_Zp(const ring r)
Definition ring.h:505
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition ring.h:405
long(* pFDegProc)(poly p, ring r)
Definition ring.h:38
static ring rIncRefCnt(ring r)
Definition ring.h:846
static BOOLEAN rField_is_Domain(const ring r)
Definition ring.h:492
long(* pLDegProc)(poly p, int *length, ring r)
Definition ring.h:37
static int rPar(const ring r)
(r->cf->P)
Definition ring.h:604
static BOOLEAN rIsLPRing(const ring r)
Definition ring.h:416
@ ringorder_lp
Definition ring.h:77
@ ringorder_dp
Definition ring.h:78
static BOOLEAN rField_is_Q(const ring r)
Definition ring.h:511
static char const ** rParameter(const ring r)
(r->cf->parameter)
Definition ring.h:630
static BOOLEAN rField_is_numeric(const ring r)
Definition ring.h:520
BOOLEAN rHasMixedOrdering(const ring r)
Definition ring.h:768
static BOOLEAN rField_is_GF(const ring r)
Definition ring.h:526
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition ring.h:597
BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition ring.h:767
#define rField_is_Ring(R)
Definition ring.h:490
idrec * idhdl
Definition ring.h:21
void sBucket_Add_p(sBucket_pt bucket, poly p, int length)
adds poly p to bucket destroys p!
Definition sbuckets.cc:203
void sBucketCanonicalize(sBucket_pt bucket)
Definition sbuckets.cc:401
sBucket_pt sBucketCreate(const ring r)
Definition sbuckets.cc:96
poly sBucketPeek(sBucket_pt b)
Definition sbuckets.cc:455
sBucket * sBucket_pt
Definition sbuckets.h:16
void sBucketDestroyAdd(sBucket_pt bucket, poly *p, int *length)
Definition sbuckets.h:68
BOOLEAN sdb_set_breakpoint(const char *pp, int given_lineno)
Definition sdb.cc:64
void sdb_show_bp()
Definition sdb.cc:57
ideal id_Vec2Ideal(poly vec, const ring R)
ideal idInit(int idsize, int rank)
initialise an ideal / module
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
void id_Norm(ideal id, const ring r)
ideal id = (id[i]), result is leadcoeff(id[i]) = 1
BOOLEAN id_HomModuleW(ideal id, ideal Q, const intvec *w, const intvec *module_w, const ring r)
void id_Normalize(ideal I, const ring r)
normialize all polys in id
ideal id_Transp(ideal a, const ring rRing)
transpose a module
ideal id_FreeModule(int i, const ring r)
the free module of rank i
ideal id_Homogen(ideal h, int varnum, const ring r)
ideal id_Power(ideal given, int exp, const ring r)
matrix id_Module2Matrix(ideal mod, const ring R)
ideal id_Head(ideal h, const ring r)
returns the ideals of initial terms
BOOLEAN id_HomIdealW(ideal id, ideal Q, const intvec *w, const ring r)
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
void id_DelDiv(ideal id, const ring r)
delete id[j], if LT(j) == coeff*mon*LT(i) and vice versa, i.e., delete id[i], if LT(i) == coeff*mon*L...
void id_DelMultiples(ideal id, const ring r)
ideal id = (id[i]), c any unit if id[i] = c*id[j] then id[j] is deleted for j > i
matrix id_Module2formatedMatrix(ideal mod, int rows, int cols, const ring R)
ideal id_Matrix2Module(matrix mat, const ring R)
converts mat to module, destroys mat
ideal id_ResizeModule(ideal mod, int rows, int cols, const ring R)
ideal id_Delete_Pos(const ideal I, const int p, const ring r)
void id_DelEquals(ideal id, const ring r)
ideal id = (id[i]) if id[i] = id[j] then id[j] is deleted for j > i
ideal id_Jet(const ideal i, int d, const ring R)
void id_DelLmEquals(ideal id, const ring r)
Delete id[j], if Lm(j) == Lm(i) and both LC(j), LC(i) are units and j > i.
ideal id_JetW(const ideal i, int d, intvec *iv, const ring R)
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
void id_Shift(ideal M, int s, const ring r)
ideal id_ChineseRemainder(ideal *xx, number *q, int rl, const ring r)
ideal id_Subst(ideal id, int n, poly e, const ring r)
#define IDELEMS(i)
static int idElem(const ideal F)
number of non-zero polys in F
int siRand()
Definition sirandom.c:42
#define R
Definition sirandom.c:27
#define A
Definition sirandom.c:24
#define M
Definition sirandom.c:25
#define Q
Definition sirandom.c:26
void sm_CallBareiss(ideal I, int x, int y, ideal &M, intvec **iv, const ring R)
Definition sparsmat.cc:347
ideal sm_CallSolv(ideal I, const ring R)
Definition sparsmat.cc:2316
sleftv * leftv
Definition structs.h:57
tHomog
Definition structs.h:35
@ isHomog
Definition structs.h:37
@ testHomog
Definition structs.h:38
@ isNotHomog
Definition structs.h:36
#define BITSET
Definition structs.h:16
EXTERN_VAR omBin char_ptr_bin
Definition structs.h:77
#define loop
Definition structs.h:75
VAR omBin sSubexpr_bin
Definition subexpr.cc:40
void syMake(leftv v, const char *id, package pa)
Definition subexpr.cc:1613
INST_VAR sleftv sLastPrinted
Definition subexpr.cc:46
VAR BOOLEAN siq
Definition subexpr.cc:48
BOOLEAN assumeStdFlag(leftv h)
Definition subexpr.cc:1587
@ LANG_SINGULAR
Definition subexpr.h:22
@ LANG_MIX
Definition subexpr.h:22
@ LANG_C
Definition subexpr.h:22
@ LANG_TOP
Definition subexpr.h:22
resolvente syResolvente(ideal arg, int maxlength, int *length, intvec ***weights, BOOLEAN minim)
Definition syz.cc:401
syStrategy syMres_with_map(ideal arg, int maxlength, intvec *w, ideal &trans)
Definition syz.cc:1176
syStrategy syResolution(ideal arg, int maxlength, intvec *w, BOOLEAN minim)
Definition syz.cc:626
ideal syMinBase(ideal arg)
Definition syz.cc:1017
syStrategy syHilb(ideal arg, int *length)
Definition syz2.cc:950
resolvente sySchreyerResolvente(ideal arg, int maxlength, int *length, BOOLEAN isMonomial=FALSE, BOOLEAN notReplace=FALSE)
Definition syz0.cc:855
syStrategy sySchreyer(ideal arg, int maxlength)
Definition syz0.cc:1018
ring syRing
Definition syz.h:56
int syDim(syStrategy syzstr)
Definition syz1.cc:1850
syStrategy syMinimize(syStrategy syzstr)
Definition syz1.cc:2393
syStrategy syCopy(syStrategy syzstr)
Definition syz1.cc:1885
resolvente minres
Definition syz.h:58
syStrategy syKosz(ideal arg, int *length)
Definition syz3.cc:1766
int sySize(syStrategy syzstr)
Definition syz1.cc:1830
short list_length
Definition syz.h:62
resolvente res
Definition syz.h:47
resolvente fullres
Definition syz.h:57
intvec ** weights
Definition syz.h:45
resolvente orderedRes
Definition syz.h:48
SRes resPairs
Definition syz.h:49
syStrategy syFrank(const ideal arg, const int length, const char *method, const bool use_cache=true, const bool use_tensor_trick=false)
Definition syz4.cc:792
syStrategy syLaScala3(ideal arg, int *length)
Definition syz1.cc:2432
int name
New type name for int.
ideal t_rep_gb(const ring r, ideal arg_I, int syz_comp, BOOLEAN F4_mode)
Definition tgb.cc:3581
int getRTimer()
Definition timer.cc:150
#define IDHDL
Definition tok.h:31
@ NCALGEBRA_CMD
Definition tok.h:138
@ ALIAS_CMD
Definition tok.h:34
@ BIGINT_CMD
Definition tok.h:38
@ CRING_CMD
Definition tok.h:56
@ LIST_CMD
Definition tok.h:118
@ INTVEC_CMD
Definition tok.h:101
@ PACKAGE_CMD
Definition tok.h:150
@ DEF_CMD
Definition tok.h:58
@ LRES_CMD
Definition tok.h:120
@ SUBST_CMD
Definition tok.h:188
@ HRES_CMD
Definition tok.h:91
@ KRES_CMD
Definition tok.h:109
@ OPEN_CMD
Definition tok.h:145
@ CNUMBER_CMD
Definition tok.h:47
@ LINK_CMD
Definition tok.h:117
@ STD_CMD
Definition tok.h:186
@ CHINREM_CMD
Definition tok.h:45
@ MRES_CMD
Definition tok.h:131
@ STRING_CMD
Definition tok.h:187
@ SRES_CMD
Definition tok.h:184
@ INTDIV_CMD
Definition tok.h:97
@ INT_CMD
Definition tok.h:96
@ KERNEL_CMD
Definition tok.h:107
@ FAREY_CMD
Definition tok.h:77
@ MAX_TOK
Definition tok.h:220
@ RES_CMD
Definition tok.h:169
#define NONE
Definition tok.h:223
#define COMMAND
Definition tok.h:29
#define UNKNOWN
Definition tok.h:224
#define ANY_TYPE
Definition tok.h:30
number ntDiff(number a, number d, const coeffs cf)
Definition transext.cc:897
ideal fractalWalkProc(leftv first, leftv second)
Definition walk_ip.cc:161
ideal walkProc(leftv first, leftv second)
Definition walk_ip.cc:55
int * iv2array(intvec *iv, const ring R)
Definition weight.cc:200
BOOLEAN jjStdJanetBasis(leftv res, leftv v, int flag)
flag: 0: JB, 1: SB
Definition wrapper.cc:50
#define omPrintStats(F)
Definition xalloc.h:231
#define omPrintInfo(F)
Definition xalloc.h:232
#define omPrintBinStats(F)
Definition xalloc.h:233
#define omUpdateInfo()
Definition xalloc.h:230