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);
6231 if (errorreported) return TRUE;
6232
6233 switch((int)(long)v->Data())
6234 {
6235 case 1:
6236 res->data=(void *)iv;
6237 return FALSE;
6238 case 2:
6239 res->data=(void *)hSecondSeries(iv);
6240 delete iv;
6241 return FALSE;
6242 }
6243 delete iv;
6245 return TRUE;
6246}
6248{
6249 if (rField_is_Z(currRing))
6250 {
6251 PrintS("// NOTE: computation of Hilbert series etc. is being\n");
6252 PrintS("// performed for generic fibre, that is, over Q\n");
6253 }
6254 assumeStdFlag(u);
6255 ring Qt =(ring)v->Data();
6256 char *name=(char*)w->Data();
6257 poly h;
6258 if (u->Typ()==IDEAL_CMD)
6260 else
6261 {
6262 intvec *module_w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
6264 }
6266 IDPOLY(hh)=h;
6267 return FALSE;
6268}
6270{
6271 PrintS("TODO\n");
6272 int i=pVar((poly)v->Data());
6273 if (i==0)
6274 {
6275 WerrorS("ringvar expected");
6276 return TRUE;
6277 }
6278 poly p=pOne(); pSetExp(p,i,1); pSetm(p);
6279 int d=pWTotaldegree(p);
6280 pLmDelete(p);
6281 if (d==1)
6282 res->data = (char *)id_Homogen((ideal)u->Data(), i, currRing);
6283 else
6284 WerrorS("variable must have weight 1");
6285 return (d!=1);
6286}
6288{
6289 PrintS("TODO\n");
6290 int i=pVar((poly)v->Data());
6291 if (i==0)
6292 {
6293 WerrorS("ringvar expected");
6294 return TRUE;
6295 }
6296 poly p=pOne(); pSetExp(p,i,1); pSetm(p);
6297 int d=pWTotaldegree(p);
6298 pLmDelete(p);
6299 if (d==1)
6300 res->data = (char *)p_Homogen((poly)u->Data(), i, currRing);
6301 else
6302 WerrorS("variable must have weight 1");
6303 return (d!=1);
6304}
6306{
6307 intvec *w=(intvec *)v3->Data();
6308 intvec *vw=(intvec*)v2->Data();
6309 ideal v_id=(ideal)v1->Data();
6310 res->data=(void *)(long)id_HomModuleW(v_id,currRing->qideal,vw,w,currRing);
6311 return FALSE;
6312}
6314{
6315 intvec* im= new intvec((int)(long)v->Data(),(int)(long)w->Data(), 0);
6316 intvec* arg = (intvec*) u->Data();
6317 int i, n = si_min(im->cols()*im->rows(), arg->cols()*arg->rows());
6318
6319 for (i=0; i<n; i++)
6320 {
6321 (*im)[i] = (*arg)[i];
6322 }
6323
6324 res->data = (char *)im;
6325 return FALSE;
6326}
6328{
6329 ideal I1=(ideal)u->Data();
6330 ideal I2=(ideal)v->Data();
6331 ideal I3=(ideal)w->Data();
6332 resolvente r=(resolvente)omAlloc0(3*sizeof(ideal));
6333 r[0]=I1;
6334 r[1]=I2;
6335 r[2]=I3;
6336 res->data=(char *)idMultSect(r,3);
6337 omFreeSize((ADDRESS)r,3*sizeof(ideal));
6338 return FALSE;
6339}
6341{
6342 ideal I=(ideal)u->Data();
6343 GbVariant alg=syGetAlgorithm((char*)w->Data(),currRing,I);
6344 res->data=(char *)idSect(I,(ideal)v->Data(),alg);
6346 return FALSE;
6347}
6349{
6350 int *iw=iv2array((intvec *)w->Data(),currRing);
6351 res->data = (char *)ppJetW((poly)u->Data(),(int)(long)v->Data(),iw);
6352 omFreeSize( (ADDRESS)iw, (rVar(currRing)+1)*sizeof(int) );
6353 return FALSE;
6354}
6356{
6357 if (!pIsUnit((poly)v->Data()))
6358 {
6359 WerrorS("2nd argument must be a unit");
6360 return TRUE;
6361 }
6362 res->data = (char *)p_Series((int)(long)w->Data(),(poly)u->CopyD(),(poly)v->CopyD(),NULL,currRing);
6363 return FALSE;
6364}
6366{
6367 res->data = (char *)id_JetW((ideal)u->Data(),(int)(long)v->Data(),
6368 (intvec *)w->Data(),currRing);
6369 return FALSE;
6370}
6372{
6373 if (!mp_IsDiagUnit((matrix)v->Data(), currRing))
6374 {
6375 WerrorS("2nd argument must be a diagonal matrix of units");
6376 return TRUE;
6377 }
6378 res->data = (char *)idSeries((int)(long)w->Data(),(ideal)u->CopyD(),
6379 (matrix)v->CopyD());
6380 return FALSE;
6381}
6383{
6384 /* Here's the use pattern for the minor command:
6385 minor ( matrix_expression m, int_expression minorSize,
6386 optional ideal_expression IasSB, optional int_expression k,
6387 optional string_expression algorithm,
6388 optional int_expression cachedMinors,
6389 optional int_expression cachedMonomials )
6390 This method here assumes that there are at least two arguments.
6391 - If IasSB is present, it must be a std basis. All minors will be
6392 reduced w.r.t. IasSB.
6393 - If k is absent, all non-zero minors will be computed.
6394 If k is present and k > 0, the first k non-zero minors will be
6395 computed.
6396 If k is present and k < 0, the first |k| minors (some of which
6397 may be zero) will be computed.
6398 If k is present and k = 0, an error is reported.
6399 - If algorithm is absent, all the following arguments must be absent too.
6400 In this case, a heuristic picks the best-suited algorithm (among
6401 Bareiss, Laplace, and Laplace with caching).
6402 If algorithm is present, it must be one of "Bareiss", "bareiss",
6403 "Laplace", "laplace", "Cache", "cache". In the cases "Cache" and
6404 "cache" two more arguments may be given, determining how many entries
6405 the cache may have at most, and how many cached monomials there are at
6406 most. (Cached monomials are counted over all cached polynomials.)
6407 If these two additional arguments are not provided, 200 and 100000
6408 will be used as defaults.
6409 */
6410 matrix m;
6411 leftv u=v->next;
6412 v->next=NULL;
6413 int v_typ=v->Typ();
6414 if (v_typ==MATRIX_CMD)
6415 {
6416 m = (matrix)v->Data();
6417 }
6418 else
6419 {
6420 if (v_typ==0)
6421 {
6422 Werror("`%s` is undefined",v->Fullname());
6423 return TRUE;
6424 }
6425 // try to convert to MATRIX:
6427 BOOLEAN bo;
6428 sleftv tmp;
6429 if (ii>0) bo=iiConvert(v_typ,MATRIX_CMD,ii,v,&tmp);
6430 else bo=TRUE;
6431 if (bo)
6432 {
6433 Werror("cannot convert %s to matrix",Tok2Cmdname(v_typ));
6434 return TRUE;
6435 }
6436 m=(matrix)tmp.data;
6437 }
6438 const int mk = (int)(long)u->Data();
6439 bool noIdeal = true; bool noK = true; bool noAlgorithm = true;
6440 bool noCacheMinors = true; bool noCacheMonomials = true;
6441 ideal IasSB; int k; char* algorithm; int cacheMinors; int cacheMonomials;
6442
6443 /* here come the different cases of correct argument sets */
6444 if ((u->next != NULL) && (u->next->Typ() == IDEAL_CMD))
6445 {
6446 IasSB = (ideal)u->next->Data();
6447 noIdeal = false;
6448 if ((u->next->next != NULL) && (u->next->next->Typ() == INT_CMD))
6449 {
6450 k = (int)(long)u->next->next->Data();
6451 noK = false;
6452 if ((u->next->next->next != NULL) &&
6453 (u->next->next->next->Typ() == STRING_CMD))
6454 {
6455 algorithm = (char*)u->next->next->next->Data();
6456 noAlgorithm = false;
6457 if ((u->next->next->next->next != NULL) &&
6458 (u->next->next->next->next->Typ() == INT_CMD))
6459 {
6460 cacheMinors = (int)(long)u->next->next->next->next->Data();
6461 noCacheMinors = false;
6462 if ((u->next->next->next->next->next != NULL) &&
6463 (u->next->next->next->next->next->Typ() == INT_CMD))
6464 {
6466 (int)(long)u->next->next->next->next->next->Data();
6467 noCacheMonomials = false;
6468 }
6469 }
6470 }
6471 }
6472 }
6473 else if ((u->next != NULL) && (u->next->Typ() == INT_CMD))
6474 {
6475 k = (int)(long)u->next->Data();
6476 noK = false;
6477 if ((u->next->next != NULL) && (u->next->next->Typ() == STRING_CMD))
6478 {
6479 algorithm = (char*)u->next->next->Data();
6480 noAlgorithm = false;
6481 if ((u->next->next->next != NULL) &&
6482 (u->next->next->next->Typ() == INT_CMD))
6483 {
6484 cacheMinors = (int)(long)u->next->next->next->Data();
6485 noCacheMinors = false;
6486 if ((u->next->next->next->next != NULL) &&
6487 (u->next->next->next->next->Typ() == INT_CMD))
6488 {
6489 cacheMonomials = (int)(long)u->next->next->next->next->Data();
6490 noCacheMonomials = false;
6491 }
6492 }
6493 }
6494 }
6495 else if ((u->next != NULL) && (u->next->Typ() == STRING_CMD))
6496 {
6497 algorithm = (char*)u->next->Data();
6498 noAlgorithm = false;
6499 if ((u->next->next != NULL) && (u->next->next->Typ() == INT_CMD))
6500 {
6501 cacheMinors = (int)(long)u->next->next->Data();
6502 noCacheMinors = false;
6503 if ((u->next->next->next != NULL) &&
6504 (u->next->next->next->Typ() == INT_CMD))
6505 {
6506 cacheMonomials = (int)(long)u->next->next->next->Data();
6507 noCacheMonomials = false;
6508 }
6509 }
6510 }
6511
6512 /* upper case conversion for the algorithm if present */
6513 if (!noAlgorithm)
6514 {
6515 if (strcmp(algorithm, "bareiss") == 0)
6516 algorithm = (char*)"Bareiss";
6517 if (strcmp(algorithm, "laplace") == 0)
6518 algorithm = (char*)"Laplace";
6519 if (strcmp(algorithm, "cache") == 0)
6520 algorithm = (char*)"Cache";
6521 }
6522
6523 v->next=u;
6524 /* here come some tests */
6525 if (!noIdeal)
6526 {
6527 assumeStdFlag(u->next);
6528 }
6529 if ((!noK) && (k == 0))
6530 {
6531 WerrorS("Provided number of minors to be computed is zero.");
6532 return TRUE;
6533 }
6534 if ((!noAlgorithm) && (strcmp(algorithm, "Bareiss") != 0)
6535 && (strcmp(algorithm, "Laplace") != 0)
6536 && (strcmp(algorithm, "Cache") != 0))
6537 {
6538 WerrorS("Expected as algorithm one of 'B/bareiss', 'L/laplace', or 'C/cache'.");
6539 return TRUE;
6540 }
6541 if ((!noAlgorithm) && (strcmp(algorithm, "Bareiss") == 0)
6543 {
6544 Werror("Bareiss algorithm not defined over coefficient rings %s",
6545 "with zero divisors.");
6546 return TRUE;
6547 }
6548 if ((mk < 1) || (mk > m->rows()) || (mk > m->cols()))
6549 {
6550 ideal I=idInit(1,1);
6551 if (mk<1) I->m[0]=p_One(currRing);
6552 //Werror("invalid size of minors: %d (matrix is (%d x %d))", mk,
6553 // m->rows(), m->cols());
6554 res->data=(void*)I;
6555 return FALSE;
6556 }
6557 if ((!noAlgorithm) && (strcmp(algorithm, "Cache") == 0)
6559 {
6560 cacheMinors = 200;
6561 cacheMonomials = 100000;
6562 }
6563
6564 /* here come the actual procedure calls */
6565 if (noAlgorithm)
6566 res->data = getMinorIdealHeuristic(m, mk, (noK ? 0 : k),
6567 (noIdeal ? 0 : IasSB), false);
6568 else if (strcmp(algorithm, "Cache") == 0)
6569 res->data = getMinorIdealCache(m, mk, (noK ? 0 : k),
6570 (noIdeal ? 0 : IasSB), 3, cacheMinors,
6571 cacheMonomials, false);
6572 else
6573 res->data = getMinorIdeal(m, mk, (noK ? 0 : k), algorithm,
6574 (noIdeal ? 0 : IasSB), false);
6575 if (v_typ!=MATRIX_CMD) idDelete((ideal *)&m);
6576 return FALSE;
6577}
6579{
6580 if ((ma->rtyp!=IDHDL)||(ma->e!=NULL))
6581 {
6582 WerrorS("3rd argument must have a name");
6583 return TRUE;
6584 }
6585 int maxl=(int)(long)v->Data();
6586 if (maxl<0)
6587 {
6588 WerrorS("length for res must not be negative");
6589 return TRUE;
6590 }
6591 syStrategy r;
6592 intvec *weights=NULL;
6593 int wmaxl=maxl;
6594 ideal u_id=(ideal)u->Data();
6595
6596 maxl--;
6597 if (/*(*/ maxl==-1 /*)*/)
6598 {
6599 maxl = currRing->N-1+2;
6600 if (currRing->qideal!=NULL)
6601 {
6602 Warn(
6603 "full resolution in a qring may be infinite, setting max length to %d",
6604 maxl+1);
6605 }
6606 }
6607 weights=(intvec*)atGet(u,"isHomog",INTVEC_CMD);
6608 if (weights!=NULL)
6609 {
6610 if (!idTestHomModule(u_id,currRing->qideal,weights))
6611 {
6612 WarnS("wrong weights given:");weights->show();PrintLn();
6613 weights=NULL;
6614 }
6615 }
6616 intvec *ww=NULL;
6617 int add_row_shift=0;
6618 if (weights!=NULL)
6619 {
6620 ww=ivCopy(weights);
6621 add_row_shift = ww->min_in();
6622 (*ww) -= add_row_shift;
6623 }
6624 unsigned save_opt=si_opt_1;
6626 u_id=(ideal)u->CopyD();
6627 ideal mat;
6629 idhdl h=(idhdl)ma->data;
6630 idDelete(&IDIDEAL(h));
6631 IDIDEAL(h)=mat;
6632 if (r->list_length>wmaxl)
6633 {
6634 for(int i=wmaxl-1;i>=r->list_length;i--)
6635 {
6636 if (r->fullres[i]!=NULL) id_Delete(&r->fullres[i],currRing);
6637 if (r->minres[i]!=NULL) id_Delete(&r->minres[i],currRing);
6638 }
6639 }
6640 r->list_length=wmaxl;
6641 res->data=(void *)r;
6642 if ((weights!=NULL) && (ww!=NULL)) { delete ww; ww=NULL; }
6643 if ((r->weights!=NULL) && (r->weights[0]!=NULL))
6644 {
6645 ww=ivCopy(r->weights[0]);
6646 if (weights!=NULL) (*ww) += add_row_shift;
6647 atSet(res,omStrDup("isHomog"),ww,INTVEC_CMD);
6648 }
6649 else
6650 {
6651 if (weights!=NULL)
6652 {
6653 atSet(res,omStrDup("isHomog"),ivCopy(weights),INTVEC_CMD);
6654 }
6655 }
6656 assume( (r->syRing != NULL) == (r->resPairs != NULL) );
6657 assume( (r->minres != NULL) || (r->fullres != NULL) );
6659 return FALSE;
6660}
6662{
6663 // u: the name of the new type
6664 // v: the parent type
6665 // w: the elements
6666 newstruct_desc d=newstructChildFromString((const char *)v->Data(),
6667 (const char *)w->Data());
6668 if (d!=NULL) newstruct_setup((const char *)u->Data(),d);
6669 return (d==NULL);
6670}
6672{
6673 // handles preimage(r,phi,i) and kernel(r,phi)
6674 idhdl h;
6675 ring rr;
6676 map mapping;
6678
6679 if ((v->name==NULL) || (!kernel_cmd && (w->name==NULL)))
6680 {
6681 WerrorS("2nd/3rd arguments must have names");
6682 return TRUE;
6683 }
6684 rr=(ring)u->Data();
6685 const char *ring_name=u->Name();
6686 if ((h=rr->idroot->get(v->name,myynest))!=NULL)
6687 {
6688 if (h->typ==MAP_CMD)
6689 {
6690 mapping=IDMAP(h);
6691 idhdl preim_ring=IDROOT->get(mapping->preimage,myynest);
6692 if ((preim_ring==NULL)
6693 || (IDRING(preim_ring)!=currRing))
6694 {
6695 Werror("preimage ring `%s` is not the basering",mapping->preimage);
6696 return TRUE;
6697 }
6698 }
6699 else if (h->typ==IDEAL_CMD)
6700 {
6701 mapping=IDMAP(h);
6702 }
6703 else
6704 {
6705 Werror("`%s` is no map nor ideal",IDID(h));
6706 return TRUE;
6707 }
6708 }
6709 else
6710 {
6711 Werror("`%s` is not defined in `%s`",v->name,ring_name);
6712 return TRUE;
6713 }
6714 ideal image;
6715 if (kernel_cmd) image=idInit(1,1);
6716 else
6717 {
6718 if ((h=rr->idroot->get(w->name,myynest))!=NULL)
6719 {
6720 if (h->typ==IDEAL_CMD)
6721 {
6722 image=IDIDEAL(h);
6723 }
6724 else
6725 {
6726 Werror("`%s` is no ideal",IDID(h));
6727 return TRUE;
6728 }
6729 }
6730 else
6731 {
6732 Werror("`%s` is not defined in `%s`",w->name,ring_name);
6733 return TRUE;
6734 }
6735 }
6736 if (((currRing->qideal!=NULL) && (rHasLocalOrMixedOrdering(currRing)))
6737 || ((rr->qideal!=NULL) && (rHasLocalOrMixedOrdering(rr))))
6738 {
6739 WarnS("preimage in local qring may be wrong: use Ring::preimageLoc instead");
6740 }
6741 res->data=(char *)maGetPreimage(rr,mapping,image,currRing);
6742 if (kernel_cmd) idDelete(&image);
6743 return (res->data==NULL/* is of type ideal, should not be NULL*/);
6744}
6746{
6747 int di, k;
6748 int i=(int)(long)u->Data();
6749 int r=(int)(long)v->Data();
6750 int c=(int)(long)w->Data();
6751 if ((r<=0) || (c<=0)) return TRUE;
6752 intvec *iv = new intvec(r, c, 0);
6753 if (iv->rows()==0)
6754 {
6755 delete iv;
6756 return TRUE;
6757 }
6758 if (i!=0)
6759 {
6760 if (i<0) i = -i;
6761 di = 2 * i + 1;
6762 for (k=0; k<iv->length(); k++)
6763 {
6764 (*iv)[k] = ((siRand() % di) - i);
6765 }
6766 }
6767 res->data = (char *)iv;
6768 return FALSE;
6769}
6770#ifdef SINGULAR_4_2
6772// <coeff>, par1, par2 -> number2
6773{
6774 coeffs cf=(coeffs)u->Data();
6775 if ((cf==NULL) ||(cf->cfRandom==NULL))
6776 {
6777 Werror("no random function defined for coeff %d",cf->type);
6778 return TRUE;
6779 }
6780 else
6781 {
6782 number n= n_Random(siRand,(number)v->Data(),(number)w->Data(),cf);
6783 number2 nn=(number2)omAlloc(sizeof(*nn));
6784 nn->cf=cf;
6785 nn->n=n;
6786 res->data=nn;
6787 return FALSE;
6788 }
6789 return TRUE;
6790}
6791#endif
6793 int &ringvar, poly &monomexpr)
6794{
6795 monomexpr=(poly)w->Data();
6796 poly p=(poly)v->Data();
6797#if 0
6798 if (pLength(monomexpr)>1)
6799 {
6800 Werror("`%s` substitutes a ringvar only by a term",
6802 return TRUE;
6803 }
6804#endif
6805 if ((ringvar=pVar(p))==0)
6806 {
6807 if ((p!=NULL) && (currRing->cf->extRing!=NULL))
6808 {
6809 number n = pGetCoeff(p);
6811 }
6812 if(ringvar==0)
6813 {
6814 WerrorS("ringvar/par expected");
6815 return TRUE;
6816 }
6817 }
6818 return FALSE;
6819}
6821{
6822 // generic conversion from polyBucket to poly:
6823 // force this to be the first try everytime
6824 poly p; int l;
6825 sBucket_pt bu=(sBucket_pt)w->CopyD();
6827 sleftv tmpw;
6828 tmpw.Init();
6829 tmpw.rtyp=POLY_CMD;
6830 tmpw.data=p;
6831 return iiExprArith3(res, iiOp, u, v, &tmpw);
6832}
6834{
6835 int ringvar;
6836 poly monomexpr;
6838 if (nok) return TRUE;
6839 poly p=(poly)u->Data();
6840 if (ringvar>0)
6841 {
6843 if (!rIsLPRing(currRing) &&
6844 (monomexpr!=NULL) && (p!=NULL) && (mm!=0) &&
6845 ((unsigned long)pTotaldegree(monomexpr) > (currRing->bitmask / (unsigned long)mm/2)))
6846 {
6847 Warn("possible OVERFLOW in subst, max exponent is %ld, substituting deg %d by deg %d",currRing->bitmask/2, pTotaldegree(monomexpr), mm);
6848 //return TRUE;
6849 }
6850 if ((monomexpr==NULL)||(pNext(monomexpr)==NULL))
6851 res->data = pSubst((poly)u->CopyD(res->rtyp),ringvar,monomexpr);
6852 else
6854 }
6855 else
6856 {
6857 if (rIsLPRing(currRing))
6858 {
6859 WerrorS("Substituting parameters not implemented for Letterplace rings.");
6860 return TRUE;
6861 }
6863 }
6864 return FALSE;
6865}
6867{
6868 int ringvar;
6869 poly monomexpr;
6871 if (nok) return TRUE;
6872 ideal id=(ideal)u->Data();
6873 if (ringvar>0)
6874 {
6875 BOOLEAN overflow=FALSE;
6876 if (!rIsLPRing(currRing) && (monomexpr!=NULL))
6877 {
6879 for(int i=IDELEMS(id)-1;i>=0;i--)
6880 {
6881 poly p=id->m[i];
6883 if ((p!=NULL) && (mm!=0) &&
6884 ((unsigned long)deg_monexp > (currRing->bitmask / (unsigned long)mm/2)))
6885 {
6886 overflow=TRUE;
6887 break;
6888 }
6889 }
6890 }
6891 if (overflow)
6892 Warn("possible OVERFLOW in subst, max exponent is %ld",currRing->bitmask/2);
6893 if ((monomexpr==NULL)||(pNext(monomexpr)==NULL))
6894 {
6895 if (res->rtyp==MATRIX_CMD) id=(ideal)mp_Copy((matrix)id,currRing);
6896 else id=id_Copy(id,currRing);
6897 res->data = id_Subst(id, ringvar, monomexpr, currRing);
6898 }
6899 else
6900 res->data = idSubstPoly(id,ringvar,monomexpr);
6901 }
6902 else
6903 {
6904 if (rIsLPRing(currRing))
6905 {
6906 WerrorS("Substituting parameters not implemented for Letterplace rings.");
6907 return TRUE;
6908 }
6909 res->data = idSubstPar(id,-ringvar,monomexpr);
6910 }
6911 return FALSE;
6912}
6913// we do not want to have jjSUBST_Id_X inlined:
6915 int input_type);
6917{
6918 return jjSUBST_Id_X(res,u,v,w,INT_CMD);
6919}
6921{
6922 return jjSUBST_Id_X(res,u,v,w,NUMBER_CMD);
6923}
6925{
6926 sleftv tmp;
6927 tmp.Init();
6928 // do not check the result, conversion from int/number to poly works always
6931 tmp.CleanUp();
6932 return b;
6933}
6935{
6936 int mi=(int)(long)v->Data();
6937 int ni=(int)(long)w->Data();
6938 if ((mi<1)||(ni<1))
6939 {
6940 Werror("converting ideal to matrix: dimensions must be positive(%dx%d)",mi,ni);
6941 return TRUE;
6942 }
6943 matrix m=mpNew(mi,ni);
6945 int i=si_min(IDELEMS(I),mi*ni);
6946 //for(i=i-1;i>=0;i--)
6947 //{
6948 // m->m[i]=I->m[i];
6949 // I->m[i]=NULL;
6950 //}
6951 memcpy(m->m,I->m,i*sizeof(poly));
6952 memset(I->m,0,i*sizeof(poly));
6954 res->data = (char *)m;
6955 return FALSE;
6956}
6958{
6959 int mi=(int)(long)v->Data();
6960 int ni=(int)(long)w->Data();
6961 if ((mi<0)||(ni<1))
6962 {
6963 Werror("converting module to matrix: dimensions must be positive(%dx%d)",mi,ni);
6964 return TRUE;
6965 }
6966 res->data = (char *)id_Module2formatedMatrix((ideal)u->CopyD(MODUL_CMD),
6967 mi,ni,currRing);
6968 return FALSE;
6969}
6971{
6972 int mi=(int)(long)v->Data();
6973 int ni=(int)(long)w->Data();
6974 if ((mi<1)||(ni<1))
6975 {
6976 Werror("converting matrix to matrix: dimensions must be positive(%dx%d)",mi,ni);
6977 return TRUE;
6978 }
6979 matrix m=mpNew(mi,ni);
6981 int r=si_min(MATROWS(I),mi);
6982 int c=si_min(MATCOLS(I),ni);
6983 int i,j;
6984 for(i=r;i>0;i--)
6985 {
6986 for(j=c;j>0;j--)
6987 {
6988 MATELEM(m,i,j)=MATELEM(I,i,j);
6989 MATELEM(I,i,j)=NULL;
6990 }
6991 }
6993 res->data = (char *)m;
6994 return FALSE;
6995}
6997{
6998 if (w->rtyp!=IDHDL) return TRUE; /* idhdhl required */
6999 intvec *w_u=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
7001 if (w_u!=NULL)
7002 {
7003 w_u=ivCopy(w_u);
7004 hom=isHomog;
7005 }
7006 intvec *w_v=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
7007 if (w_v!=NULL)
7008 {
7009 w_v=ivCopy(w_v);
7010 hom=isHomog;
7011 }
7012 if ((w_u!=NULL) && (w_v==NULL))
7013 w_v=ivCopy(w_u);
7014 if ((w_v!=NULL) && (w_u==NULL))
7015 w_u=ivCopy(w_v);
7016 ideal u_id=(ideal)u->Data();
7017 ideal v_id=(ideal)v->Data();
7018 if (w_u!=NULL)
7019 {
7020 if ((*w_u).compare((w_v))!=0)
7021 {
7022 WarnS("incompatible weights");
7023 delete w_u; w_u=NULL;
7024 hom=testHomog;
7025 }
7026 else
7027 {
7028 if ((!idTestHomModule(u_id,currRing->qideal,w_v))
7029 || (!idTestHomModule(v_id,currRing->qideal,w_v)))
7030 {
7031 WarnS("wrong weights");
7032 delete w_u; w_u=NULL;
7033 hom=testHomog;
7034 }
7035 }
7036 }
7037 idhdl h=(idhdl)w->data;
7038 res->data = (char *)idModulo(u_id,v_id ,hom,&w_u, &(h->data.umatrix));
7039 if (w_u!=NULL)
7040 {
7041 atSet(res,omStrDup("isHomog"),w_u,INTVEC_CMD);
7042 }
7043 delete w_v;
7044 //if (TEST_OPT_RETURN_SB) setFlag(res,FLAG_STD);
7045 return FALSE;
7046}
7048{
7049 if (w->rtyp!=IDHDL) return TRUE; /* idhdhl required */
7050 intvec *w_u=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
7052 if (w_u!=NULL)
7053 {
7054 w_u=ivCopy(w_u);
7055 hom=isHomog;
7056 }
7057 intvec *w_v=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
7058 if (w_v!=NULL)
7059 {
7060 w_v=ivCopy(w_v);
7061 hom=isHomog;
7062 }
7063 if ((w_u!=NULL) && (w_v==NULL))
7064 w_v=ivCopy(w_u);
7065 if ((w_v!=NULL) && (w_u==NULL))
7066 w_u=ivCopy(w_v);
7067 ideal u_id=(ideal)u->Data();
7068 GbVariant alg=syGetAlgorithm((char*)w->Data(),currRing,u_id);
7069 ideal v_id=(ideal)v->Data();
7070 if (w_u!=NULL)
7071 {
7072 if ((*w_u).compare((w_v))!=0)
7073 {
7074 WarnS("incompatible weights");
7075 delete w_u; w_u=NULL;
7076 hom=testHomog;
7077 }
7078 else
7079 {
7080 if ((!idTestHomModule(u_id,currRing->qideal,w_v))
7081 || (!idTestHomModule(v_id,currRing->qideal,w_v)))
7082 {
7083 WarnS("wrong weights");
7084 delete w_u; w_u=NULL;
7085 hom=testHomog;
7086 }
7087 }
7088 }
7089 res->data = (char *)idModulo(u_id,v_id ,hom,&w_u, NULL,alg);
7090 if (w_u!=NULL)
7091 {
7092 atSet(res,omStrDup("isHomog"),w_u,INTVEC_CMD);
7093 }
7094 delete w_v;
7095 //if (TEST_OPT_RETURN_SB) setFlag(res,FLAG_STD);
7096 return FALSE;
7097}
7099{
7100 int mi=(int)(long)v->Data();
7101 int ni=(int)(long)w->Data();
7102 if ((mi<0)||(ni<1))
7103 {
7104 Werror("converting to smatrix: dimensions must be positive(%dx%d)",mi,ni);
7105 return TRUE;
7106 }
7107 res->data = (char *)id_ResizeModule((ideal)u->CopyD(),
7108 mi,ni,currRing);
7109 return FALSE;
7110}
7112{
7113 if (w->rtyp!=IDHDL) return TRUE;
7114 int ul= IDELEMS((ideal)u->Data());
7115 int vl= IDELEMS((ideal)v->Data());
7116#ifdef HAVE_SHIFTBBA
7117 if (rIsLPRing(currRing))
7118 {
7119 if (currRing->LPncGenCount < ul)
7120 {
7121 Werror("At least %d ncgen variables are needed for this computation.", ul);
7122 return TRUE;
7123 }
7124 }
7125#endif
7126 ideal m
7127 = idLift((ideal)u->Data(),(ideal)v->Data(),NULL,FALSE,hasFlag(u,FLAG_STD),
7128 FALSE, (matrix *)(&(IDMATRIX((idhdl)(w->data)))));
7129 if (m==NULL) return TRUE;
7130 res->data = (char *)id_Module2formatedMatrix(m,ul,vl,currRing);
7131 return FALSE;
7132}
7134{
7135 if ((v->rtyp!=IDHDL)||(v->e!=NULL)) return TRUE;
7136 if ((w->rtyp!=IDHDL)||(w->e!=NULL)) return TRUE;
7137 idhdl hv=(idhdl)v->data;
7138 idhdl hw=(idhdl)w->data;
7139#ifdef HAVE_SHIFTBBA
7140 if (rIsLPRing(currRing))
7141 {
7142 if (currRing->LPncGenCount < IDELEMS((ideal)u->Data()))
7143 {
7144 Werror("At least %d ncgen variables are needed for this computation.", IDELEMS((ideal)u->Data()));
7145 return TRUE;
7146 }
7147 }
7148#endif
7149 // CopyD for IDEAL_CMD and MODUL_CMD are identical:
7150 res->data = (char *)idLiftStd((ideal)u->Data(),
7151 &(hv->data.umatrix),testHomog,
7152 &(hw->data.uideal));
7153 setFlag(res,FLAG_STD); v->flag=0; w->flag=0;
7154 return FALSE;
7155}
7157{
7158 if ((v->rtyp!=IDHDL)||(v->e!=NULL)) return TRUE;
7159 idhdl hv=(idhdl)v->data;
7160 GbVariant alg=syGetAlgorithm((char*)w->Data(),currRing,(ideal)u->Data());
7161#ifdef HAVE_SHIFTBBA
7162 if (rIsLPRing(currRing))
7163 {
7164 if (currRing->LPncGenCount < IDELEMS((ideal)u->Data()))
7165 {
7166 Werror("At least %d ncgen variables are needed for this computation.", IDELEMS((ideal)u->Data()));
7167 return TRUE;
7168 }
7169 }
7170#endif
7171 // CopyD for IDEAL_CMD and MODUL_CMD are identical:
7172 res->data = (char *)idLiftStd((ideal)u->Data(),
7173 &(hv->data.umatrix),testHomog,
7174 NULL,alg);
7175 setFlag(res,FLAG_STD); v->flag=0;
7176 return FALSE;
7177}
7179{
7181 if (!idIsZeroDim((ideal)v->Data()))
7182 {
7183 Werror("`%s` must be 0-dimensional",v->Name());
7184 return TRUE;
7185 }
7186 res->data = (char *)redNF((ideal)v->CopyD(),(poly)u->CopyD(),
7187 (poly)w->CopyD());
7188 return FALSE;
7189}
7191{
7193 if (!idIsZeroDim((ideal)v->Data()))
7194 {
7195 Werror("`%s` must be 0-dimensional",v->Name());
7196 return TRUE;
7197 }
7198 res->data = (char *)redNF((ideal)v->CopyD(),(ideal)u->CopyD(),
7199 (matrix)w->CopyD());
7200 return FALSE;
7201}
7203{
7205 res->data = (char *)kNF((ideal)v->Data(),currRing->qideal,(poly)u->Data(),
7206 0,(int)(long)w->Data());
7207 return FALSE;
7208}
7210{
7212 res->data = (char *)kNF((ideal)v->Data(),currRing->qideal,(ideal)u->Data(),
7213 0,(int)(long)w->Data());
7214 return FALSE;
7215}
7216#ifdef OLD_RES
7218{
7219 int maxl=(int)v->Data();
7220 ideal u_id=(ideal)u->Data();
7221 int l=0;
7222 resolvente r;
7223 intvec **weights=NULL;
7224 int wmaxl=maxl;
7225 maxl--;
7226 unsigned save_opt=si_opt_1;
7228 if ((maxl==-1) && (iiOp!=MRES_CMD))
7229 maxl = currRing->N-1;
7230 if ((iiOp == RES_CMD) || (iiOp == MRES_CMD))
7231 {
7232 intvec * iv=(intvec*)atGet(u,"isHomog",INTVEC_CMD);
7233 if (iv!=NULL)
7234 {
7235 l=1;
7236 if (!idTestHomModule(u_id,currRing->qideal,iv))
7237 {
7238 WarnS("wrong weights");
7239 iv=NULL;
7240 }
7241 else
7242 {
7243 weights = (intvec**)omAlloc0Bin(char_ptr_bin);
7244 weights[0] = ivCopy(iv);
7245 }
7246 }
7247 r=syResolvente(u_id,maxl,&l, &weights, iiOp==MRES_CMD);
7248 }
7249 else
7250 r=sySchreyerResolvente((ideal)u->Data(),maxl+1,&l);
7251 if (r==NULL) return TRUE;
7252 int t3=u->Typ();
7253 iiMakeResolv(r,l,wmaxl,w->name,t3,weights);
7255 return FALSE;
7256}
7257#endif
7259{
7260 res->data=(void *)rInit(u,v,w);
7261 return (res->data==NULL);
7262}
7264{
7265 int yes;
7266 jjSTATUS2(res, u, v);
7267 yes = (strcmp((char *) res->data, (char *) w->Data()) == 0);
7268 omFreeBinAddr((ADDRESS) res->data);
7269 res->data = (void *)(long)yes;
7270 return FALSE;
7271}
7273{
7274 intvec *vw=(intvec *)w->Data(); // weights of vars
7275 if (vw->length()!=currRing->N)
7276 {
7277 Werror("%d weights for %d variables",vw->length(),currRing->N);
7278 return TRUE;
7279 }
7280 ideal result;
7281 intvec *ww=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
7283 ideal u_id=(ideal)(u->Data());
7284 if (ww!=NULL)
7285 {
7286 if (!idTestHomModule(u_id,currRing->qideal,ww))
7287 {
7288 WarnS("wrong weights");
7289 ww=NULL;
7290 }
7291 else
7292 {
7293 ww=ivCopy(ww);
7294 hom=isHomog;
7295 }
7296 }
7297 bigintmat *vv=(bigintmat*)v->Data();
7298 intvec* vvv=new intvec(1,vv->cols());
7299 for(int i=0;i<vv->cols();i++)
7300 {
7301 (*vvv)[i]=n_Int(BIMATELEM(*vv,1,i+1),coeffs_BIGINT);
7302 }
7304 currRing->qideal,
7305 hom,
7306 &ww, // module weights
7307 vvv, // hilbert series
7308 0,0, // syzComp, newIdeal
7309 vw); // weights of vars
7311 delete vvv;
7312 res->data = (char *)result;
7314 if (ww!=NULL) atSet(res,omStrDup("isHomog"),ww,INTVEC_CMD);
7315 return FALSE;
7316}
7317
7318/*=================== operations with many arg.: static proc =================*/
7319/* must be ordered: first operations for chars (infix ops),
7320 * then alphabetically */
7322{
7323#ifdef HAVE_SDB
7324 sdb_show_bp();
7325#endif
7326 return FALSE;
7327}
7329{
7330#ifdef HAVE_SDB
7331 if(v->Typ()==PROC_CMD)
7332 {
7333 int lineno=0;
7334 if((v->next!=NULL) && (v->next->Typ()==INT_CMD))
7335 {
7336 lineno=(int)(long)v->next->Data();
7337 }
7338 return sdb_set_breakpoint(v->Name(),lineno);
7339 }
7340 return TRUE;
7341#else
7342 return FALSE;
7343#endif
7344}
7346{
7347 return iiExprArith1(res,v,iiOp);
7348}
7350{
7351 leftv v=u->next;
7352 u->next=NULL;
7353 BOOLEAN b=iiExprArith2(res,u,iiOp,v, (iiOp > 255));
7354 u->next=v;
7355 return b;
7356}
7358{
7359 leftv v = u->next;
7360 leftv w = v->next;
7361 u->next = NULL;
7362 v->next = NULL;
7363 BOOLEAN b = iiExprArith3(res, iiOp, u, v, w);
7364 u->next = v;
7365 v->next = w;
7366 return b;
7367}
7368
7370{
7371 const short t[]={4,VECTOR_CMD,POLY_CMD,MATRIX_CMD,MATRIX_CMD};
7372 if (iiCheckTypes(v,t,1))
7373 {
7374 idhdl c=(idhdl)v->next->next->data;
7375 if (v->next->next->next->rtyp!=IDHDL) return TRUE;
7376 idhdl m=(idhdl)v->next->next->next->data;
7377 idDelete((ideal *)&(c->data.uideal));
7378 idDelete((ideal *)&(m->data.uideal));
7379 mp_Coef2((poly)v->Data(),(poly)v->next->Data(),
7380 (matrix *)&(c->data.umatrix),(matrix *)&(m->data.umatrix),currRing);
7381 return FALSE;
7382 }
7383 return TRUE;
7384}
7385
7387{ // may have 3 or 4 arguments
7388 leftv v1=v;
7389 leftv v2=v1->next;
7390 leftv v3=v2->next;
7391 leftv v4=v3->next;
7393
7394 int i1=iiTestConvert(v1->Typ(),MODUL_CMD);
7395 int i2=iiTestConvert(v2->Typ(),MODUL_CMD);
7396
7397 if((i1==0)||(i2==0)
7398 ||(v3->Typ()!=INT_CMD)||((v4!=NULL)&&(v4->Typ()!=INTVEC_CMD)))
7399 {
7400 WarnS("<module>,<module>,<int>[,<intvec>] expected!");
7401 return TRUE;
7402 }
7403
7404 sleftv w1,w2;
7405 iiConvert(v1->Typ(),MODUL_CMD,i1,v1,&w1);
7406 iiConvert(v2->Typ(),MODUL_CMD,i2,v2,&w2);
7407 ideal P=(ideal)w1.Data();
7408 ideal Q=(ideal)w2.Data();
7409
7410 int n=(int)(long)v3->Data();
7411 int *w=NULL;
7412 if(v4!=NULL)
7413 {
7414 w = iv2array((intvec *)v4->Data(),currRing);
7415 int * w0 = w + 1;
7416 int i = currRing->N;
7417 while( (i > 0) && ((*w0) > 0) )
7418 {
7419 w0++;
7420 i--;
7421 }
7422 if(i>0)
7423 WarnS("not all weights are positive!");
7424 }
7425
7426 matrix T;
7427 ideal R;
7428 idLiftW(P,Q,n,T,R,w);
7429
7430 w1.CleanUp();
7431 w2.CleanUp();
7432 if(w!=NULL)
7433 omFreeSize( (ADDRESS)w, (rVar(currRing)+1)*sizeof(int) );
7434
7436 L->Init(2);
7437 L->m[1].rtyp=v1->Typ();
7438 if(v1->Typ()==POLY_CMD||v1->Typ()==VECTOR_CMD)
7439 {
7440 if(v1->Typ()==POLY_CMD)
7441 p_Shift(&R->m[0],-1,currRing);
7442 L->m[1].data=(void *)R->m[0];
7443 R->m[0]=NULL;
7444 idDelete(&R);
7445 }
7446 else if(v1->Typ()==IDEAL_CMD||v1->Typ()==MATRIX_CMD)
7447 L->m[1].data=(void *)id_Module2Matrix(R,currRing);
7448 else
7449 {
7450 L->m[1].rtyp=MODUL_CMD;
7451 L->m[1].data=(void *)R;
7452 }
7453 L->m[0].rtyp=MATRIX_CMD;
7454 L->m[0].data=(char *)T;
7455
7456 res->data=L;
7457
7458 return FALSE;
7459}
7460
7461//BOOLEAN jjDISPATCH(leftv res, leftv v)
7462//{
7463// WerrorS("`dispatch`: not implemented");
7464// return TRUE;
7465//}
7466
7467//static BOOLEAN jjEXPORTTO_M(leftv res, leftv u)
7468//{
7469// int l=u->listLength();
7470// if (l<2) return TRUE;
7471// BOOLEAN b;
7472// leftv v=u->next;
7473// leftv zz=v;
7474// leftv z=zz;
7475// u->next=NULL;
7476// do
7477// {
7478// leftv z=z->next;
7479// b=iiExprArith2(res,u,iiOp,z, (iiOp > 255));
7480// if (b) break;
7481// } while (z!=NULL);
7482// u->next=zz;
7483// return b;
7484//}
7486{
7487 int s=1;
7488 leftv h=v;
7489 if (h!=NULL) s=exprlist_length(h);
7490 ideal id=idInit(s,1);
7491 int rank=1;
7492 int i=0;
7493 poly p;
7494 int dest_type=POLY_CMD;
7496 while (h!=NULL)
7497 {
7498 // use standard type conversions to poly/vector
7499 int ri;
7500 int ht=h->Typ();
7501 if (ht==dest_type)
7502 {
7503 p=(poly)h->CopyD();
7504 if (p!=NULL) rank=si_max(rank,(int)pMaxComp(p));
7505 }
7506 else if ((ri=iiTestConvert(ht,dest_type,dConvertTypes))!=0)
7507 {
7508 sleftv tmp;
7509 leftv hnext=h->next;
7510 h->next=NULL;
7512 h->next=hnext;
7513 p=(poly)tmp.data;
7514 if (p!=NULL) rank=si_max(rank,(int)pMaxComp(p));
7515 }
7516 else
7517 {
7518 idDelete(&id);
7519 return TRUE;
7520 }
7521 id->m[i]=p;
7522 i++;
7523 h=h->next;
7524 }
7525 id->rank=rank;
7526 res->data=(char *)id;
7527 return FALSE;
7528}
7530{
7531 ring r=(ring)u->Data();
7532 leftv v=u->next;
7535 if ((perm_var_l->Typ()!=INTVEC_CMD)
7536 ||((perm_par_l!=NULL)&&(perm_par_l->Typ()!=INTVEC_CMD))
7537 ||(u->Typ()!=RING_CMD))
7538 {
7539 WerrorS("fetch(<ring>,<name>[,<intvec>[,<intvec>])");
7540 return TRUE;
7541 }
7544 if (perm_par_l!=NULL)
7545 perm_par_v=(intvec*)perm_par_l->Data();
7546 idhdl w;
7547 nMapFunc nMap;
7548
7549 if ((w=r->idroot->get(v->Name(),myynest))!=NULL)
7550 {
7551 int *perm=NULL;
7552 int *par_perm=NULL;
7553 int par_perm_size=0;
7554 BOOLEAN bo;
7555 if ((nMap=n_SetMap(r->cf,currRing->cf))==NULL)
7556 {
7557 // Allow imap/fetch to be make an exception only for:
7558 if (nCoeff_is_Extension(r->cf) && // Q(a..) -> Q(a..) || Q || Zp || Zp(a)
7559 ((n_SetMap(r->cf->extRing->cf,currRing->cf)!=NULL)
7560 || (nCoeff_is_Extension(currRing->cf) && (n_SetMap(r->cf->extRing->cf,currRing->cf->extRing->cf)!=NULL))))
7561 {
7563 }
7564 else
7565 {
7566 goto err_fetch;
7567 }
7568 }
7569 else
7571 perm=(int *)omAlloc0((rVar(r)+1)*sizeof(int));
7572 if (par_perm_size!=0)
7573 par_perm=(int *)omAlloc0(par_perm_size*sizeof(int));
7574 int i;
7575 if (perm_par_l==NULL)
7576 {
7577 if (par_perm_size!=0)
7578 for(i=si_min(rPar(r),rPar(currRing))-1;i>=0;i--) par_perm[i]=-(i+1);
7579 }
7580 else
7581 {
7582 if (par_perm_size==0) WarnS("source ring has no parameters");
7583 else
7584 {
7585 for(i=rPar(r)-1;i>=0;i--)
7586 {
7587 if (i<perm_par_v->length()) par_perm[i]=(*perm_par_v)[i];
7588 if ((par_perm[i]<-rPar(currRing))
7589 || (par_perm[i]>rVar(currRing)))
7590 {
7591 Warn("invalid entry for par %d: %d\n",i,par_perm[i]);
7592 par_perm[i]=0;
7593 }
7594 }
7595 }
7596 }
7597 for(i=rVar(r)-1;i>=0;i--)
7598 {
7599 if (i<perm_var_v->length()) perm[i+1]=(*perm_var_v)[i];
7600 if ((perm[i]<-rPar(currRing))
7601 || (perm[i]>rVar(currRing)))
7602 {
7603 Warn("invalid entry for var %d: %d\n",i,perm[i]);
7604 perm[i]=0;
7605 }
7606 }
7607 if (BVERBOSE(V_IMAP))
7608 {
7609 for(i=1;i<=si_min(rVar(r),rVar(currRing));i++)
7610 {
7611 if (perm[i]>0)
7612 Print("// var nr %d: %s -> var %s\n",i,r->names[i-1],currRing->names[perm[i]-1]);
7613 else if (perm[i]<0)
7614 Print("// var nr %d: %s -> par %s\n",i,r->names[i-1],rParameter(currRing)[-perm[i]-1]);
7615 }
7616 for(i=1;i<=si_min(rPar(r),rPar(currRing));i++) // possibly empty loop
7617 {
7618 if (par_perm[i-1]<0)
7619 Print("// par nr %d: %s -> par %s\n",
7620 i,rParameter(r)[i-1],rParameter(currRing)[-par_perm[i-1]-1]);
7621 else if (par_perm[i-1]>0)
7622 Print("// par nr %d: %s -> var %s\n",
7623 i,rParameter(r)[i-1],currRing->names[par_perm[i-1]-1]);
7624 }
7625 }
7626 if (IDTYP(w)==ALIAS_CMD) w=(idhdl)IDDATA(w);
7627 sleftv tmpW;
7628 tmpW.Init();
7629 tmpW.rtyp=IDTYP(w);
7630 tmpW.data=IDDATA(w);
7633 {
7634 Werror("cannot map %s of type %s(%d)",v->name, Tok2Cmdname(w->typ),w->typ);
7635 }
7636 if (perm!=NULL)
7637 omFreeSize((ADDRESS)perm,(rVar(r)+1)*sizeof(int));
7638 if (par_perm!=NULL)
7640 return bo;
7641 }
7642 else
7643 {
7644 Werror("identifier %s not found in %s",v->Fullname(),u->Fullname());
7645 }
7646 return TRUE;
7647err_fetch:
7648 char *s1=nCoeffString(r->cf);
7649 char *s2=nCoeffString(currRing->cf);
7650 Werror("no identity map from %s (%s -> %s)",u->Fullname(),s1,s2);
7652 return TRUE;
7653}
7655{
7656 leftv h=v;
7657 int l=v->listLength();
7658 resolvente r=(resolvente)omAlloc0(l*sizeof(ideal));
7659 BOOLEAN *copied=(BOOLEAN *)omAlloc0(l*sizeof(BOOLEAN));
7660 int t=0;
7661 // try to convert to IDEAL_CMD
7662 while (h!=NULL)
7663 {
7664 if (iiTestConvert(h->Typ(),IDEAL_CMD)!=0)
7665 {
7666 t=IDEAL_CMD;
7667 }
7668 else break;
7669 h=h->next;
7670 }
7671 // if failure, try MODUL_CMD
7672 if (t==0)
7673 {
7674 h=v;
7675 while (h!=NULL)
7676 {
7677 if (iiTestConvert(h->Typ(),MODUL_CMD)!=0)
7678 {
7679 t=MODUL_CMD;
7680 }
7681 else break;
7682 h=h->next;
7683 }
7684 }
7685 // check for success in converting
7686 if (t==0)
7687 {
7688 WerrorS("cannot convert to ideal or module");
7689 return TRUE;
7690 }
7691 // call idMultSect
7692 h=v;
7693 int i=0;
7694 sleftv tmp;
7695 while (h!=NULL)
7696 {
7697 if (h->Typ()==t)
7698 {
7699 r[i]=(ideal)h->Data(); /*no copy*/
7700 h=h->next;
7701 }
7702 else if(iiConvert(h->Typ(),t,iiTestConvert(h->Typ(),t),h,&tmp))
7703 {
7704 omFreeSize((ADDRESS)copied,l*sizeof(BOOLEAN));
7705 omFreeSize((ADDRESS)r,l*sizeof(ideal));
7706 Werror("cannot convert arg. %d to %s",i+1,Tok2Cmdname(t));
7707 return TRUE;
7708 }
7709 else
7710 {
7711 r[i]=(ideal)tmp.Data(); /*now it's a copy*/
7712 copied[i]=TRUE;
7713 h=tmp.next;
7714 }
7715 i++;
7716 }
7717 res->rtyp=t;
7718 res->data=(char *)idMultSect(r,i);
7719 while(i>0)
7720 {
7721 i--;
7722 if (copied[i]) idDelete(&(r[i]));
7723 }
7724 omFreeSize((ADDRESS)copied,l*sizeof(BOOLEAN));
7725 omFreeSize((ADDRESS)r,l*sizeof(ideal));
7726 return FALSE;
7727}
7729{
7730 /* computation of the inverse of a quadratic matrix A
7731 using the L-U-decomposition of A;
7732 There are two valid parametrisations:
7733 1) exactly one argument which is just the matrix A,
7734 2) exactly three arguments P, L, U which already
7735 realise the L-U-decomposition of A, that is,
7736 P * A = L * U, and P, L, and U satisfy the
7737 properties decribed in method 'jjLU_DECOMP';
7738 see there;
7739 If A is invertible, the list [1, A^(-1)] is returned,
7740 otherwise the list [0] is returned. Thus, the user may
7741 inspect the first entry of the returned list to see
7742 whether A is invertible. */
7743 matrix iMat; int invertible;
7744 const short t1[]={1,MATRIX_CMD};
7745 const short t2[]={3,MATRIX_CMD,MATRIX_CMD,MATRIX_CMD};
7746 if (iiCheckTypes(v,t1))
7747 {
7748 matrix aMat = (matrix)v->Data();
7749 int rr = aMat->rows();
7750 int cc = aMat->cols();
7751 if (rr != cc)
7752 {
7753 Werror("given matrix (%d x %d) is not quadratic, hence not invertible", rr, cc);
7754 return TRUE;
7755 }
7756 if (!idIsConstant((ideal)aMat))
7757 {
7758 WerrorS("matrix must be constant");
7759 return TRUE;
7760 }
7762 }
7763 else if (iiCheckTypes(v,t2))
7764 {
7765 matrix pMat = (matrix)v->Data();
7766 matrix lMat = (matrix)v->next->Data();
7767 matrix uMat = (matrix)v->next->next->Data();
7768 int rr = uMat->rows();
7769 int cc = uMat->cols();
7770 if (rr != cc)
7771 {
7772 Werror("third matrix (%d x %d) is not quadratic, hence not invertible",
7773 rr, cc);
7774 return TRUE;
7775 }
7776 if (!idIsConstant((ideal)pMat)
7777 || (!idIsConstant((ideal)lMat))
7778 || (!idIsConstant((ideal)uMat))
7779 )
7780 {
7781 WerrorS("matricesx must be constant");
7782 return TRUE;
7783 }
7785 }
7786 else
7787 {
7788 Werror("expected either one or three matrices");
7789 return TRUE;
7790 }
7791
7792 /* build the return structure; a list with either one or two entries */
7794 if (invertible)
7795 {
7796 ll->Init(2);
7797 ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)invertible;
7798 ll->m[1].rtyp=MATRIX_CMD; ll->m[1].data=(void *)iMat;
7799 }
7800 else
7801 {
7802 ll->Init(1);
7803 ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)invertible;
7804 }
7805
7806 res->data=(char*)ll;
7807 return FALSE;
7808}
7810{
7811 /* for solving a linear equation system A * x = b, via the
7812 given LU-decomposition of the matrix A;
7813 There is one valid parametrisation:
7814 1) exactly four arguments P, L, U, b;
7815 P, L, and U realise the L-U-decomposition of A, that is,
7816 P * A = L * U, and P, L, and U satisfy the
7817 properties decribed in method 'jjLU_DECOMP';
7818 see there;
7819 b is the right-hand side vector of the equation system;
7820 The method will return a list of either 1 entry or three entries:
7821 1) [0] if there is no solution to the system;
7822 2) [1, x, H] if there is at least one solution;
7823 x is any solution of the given linear system,
7824 H is the matrix with column vectors spanning the homogeneous
7825 solution space.
7826 The method produces an error if matrix and vector sizes do not fit. */
7827 const short t[]={4,MATRIX_CMD,MATRIX_CMD,MATRIX_CMD,MATRIX_CMD};
7828 if (!iiCheckTypes(v,t))
7829 {
7830 WerrorS("expected exactly three matrices and one vector as input");
7831 return TRUE;
7832 }
7833 matrix pMat = (matrix)v->Data();
7834 matrix lMat = (matrix)v->next->Data();
7835 matrix uMat = (matrix)v->next->next->Data();
7836 matrix bVec = (matrix)v->next->next->next->Data();
7838 if (pMat->rows() != pMat->cols())
7839 {
7840 Werror("first matrix (%d x %d) is not quadratic",
7841 pMat->rows(), pMat->cols());
7842 return TRUE;
7843 }
7844 if (lMat->rows() != lMat->cols())
7845 {
7846 Werror("second matrix (%d x %d) is not quadratic",
7847 lMat->rows(), lMat->cols());
7848 return TRUE;
7849 }
7850 if (lMat->rows() != uMat->rows())
7851 {
7852 Werror("second matrix (%d x %d) and third matrix (%d x %d) do not fit",
7853 lMat->rows(), lMat->cols(), uMat->rows(), uMat->cols());
7854 return TRUE;
7855 }
7856 if (uMat->rows() != bVec->rows())
7857 {
7858 Werror("third matrix (%d x %d) and vector (%d x 1) do not fit",
7859 uMat->rows(), uMat->cols(), bVec->rows());
7860 return TRUE;
7861 }
7862 if (!idIsConstant((ideal)pMat)
7863 ||(!idIsConstant((ideal)lMat))
7864 ||(!idIsConstant((ideal)uMat))
7865 )
7866 {
7867 WerrorS("matrices must be constant");
7868 return TRUE;
7869 }
7871
7872 /* build the return structure; a list with either one or three entries */
7874 if (solvable)
7875 {
7876 ll->Init(3);
7877 ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)solvable;
7878 ll->m[1].rtyp=MATRIX_CMD; ll->m[1].data=(void *)xVec;
7879 ll->m[2].rtyp=MATRIX_CMD; ll->m[2].data=(void *)homogSolSpace;
7880 }
7881 else
7882 {
7883 ll->Init(1);
7884 ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)solvable;
7885 }
7886
7887 res->data=(char*)ll;
7888 return FALSE;
7889}
7891{
7892 int i=0;
7893 leftv h=v;
7894 if (h!=NULL) i=exprlist_length(h);
7895 intvec *iv=new intvec(i);
7896 i=0;
7897 while (h!=NULL)
7898 {
7899 if(h->Typ()==INT_CMD)
7900 {
7901 (*iv)[i]=(int)(long)h->Data();
7902 }
7903 else if (h->Typ()==INTVEC_CMD)
7904 {
7905 intvec *ivv=(intvec*)h->Data();
7906 for(int j=0;j<ivv->length();j++,i++)
7907 {
7908 (*iv)[i]=(*ivv)[j];
7909 }
7910 i--;
7911 }
7912 else
7913 {
7914 delete iv;
7915 return TRUE;
7916 }
7917 i++;
7918 h=h->next;
7919 }
7920 res->data=(char *)iv;
7921 return FALSE;
7922}
7924{
7925 leftv h=v;
7926 int l=0;
7927 while (h!=NULL)
7928 {
7929 if(h->Typ()==INT_CMD) l++;
7930 else if (h->Typ()==BIGINT_CMD) l++;
7931 else if (h->Typ()==INTVEC_CMD)
7932 {
7933 intvec *ivv=(intvec*)h->Data();
7934 l+=ivv->rows();
7935 }
7936 else if (h->Typ()==BIGINTVEC_CMD)
7937 {
7938 bigintmat *ivv=(bigintmat *)h->Data();
7939 l+=ivv->rows();
7940 }
7941 else return TRUE;
7942 h=h->next;
7943 }
7944 bigintmat *bim=new bigintmat(1,l,coeffs_BIGINT);
7945 h=v;
7946 int i=0;
7947 while (h!=NULL)
7948 {
7949 if(h->Typ()==INT_CMD)
7950 {
7951 number tp = n_Init((long)(h->Data()), coeffs_BIGINT);
7952 bim->set(i++, tp);
7954 }
7955 else if (h->Typ()==INTVEC_CMD)
7956 {
7957 intvec *ivv=(intvec*)h->Data();
7958 for(int j=0;j<ivv->length();j++)
7959 {
7960 number tp = n_Init((long)(*ivv)[j], coeffs_BIGINT);
7961 bim->set(i++, tp);
7963 }
7964 }
7965 else if(h->Typ()==BIGINT_CMD)
7966 {
7967 number tp = (number)h->Data();
7968 bim->set(i++, tp);
7969 }
7970 else if(h->Typ()==BIGINTVEC_CMD)
7971 {
7972 bigintmat *b=(bigintmat*)h->Data();
7973 for(int j=0;j<b->cols();j++)
7974 {
7975 number tp=BIMATELEM((*b),1,j);
7976 bim->set(i++, tp);
7977 }
7978 }
7979 h=h->next;
7980 }
7981 res->data=(char *)bim;
7982 return FALSE;
7983}
7985{
7986 const short t1[]={4,POLY_CMD,POLY_CMD,POLY_CMD,INTVEC_CMD};
7987 const short t2[]={4,VECTOR_CMD,POLY_CMD,POLY_CMD,INTVEC_CMD};
7988 const short t3[]={4,IDEAL_CMD,MATRIX_CMD,INT_CMD,INTVEC_CMD};
7989 const short t4[]={4,MODUL_CMD,MATRIX_CMD,INT_CMD,INTVEC_CMD};
7990 leftv u1=u;
7991 leftv u2=u1->next;
7992 leftv u3=u2->next;
7993 leftv u4=u3->next;
7994 if (iiCheckTypes(u,t1)||iiCheckTypes(u,t2))
7995 {
7996 if(!pIsUnit((poly)u2->Data()))
7997 {
7998 WerrorS("2nd argument must be a unit");
7999 return TRUE;
8000 }
8001 res->rtyp=u1->Typ();
8002 res->data=(char*)pSeries((int)(long)u3->Data(),pCopy((poly)u1->Data()),
8003 pCopy((poly)u2->Data()),(intvec*)u4->Data());
8004 return FALSE;
8005 }
8006 else
8007 if (iiCheckTypes(u,t3)||iiCheckTypes(u,t4))
8008 {
8009 if(!mp_IsDiagUnit((matrix)u2->Data(), currRing))
8010 {
8011 WerrorS("2nd argument must be a diagonal matrix of units");
8012 return TRUE;
8013 }
8014 res->rtyp=u1->Typ();
8015 res->data=(char*)idSeries(
8016 (int)(long)u3->Data(),
8017 idCopy((ideal)u1->Data()),
8018 mp_Copy((matrix)u2->Data(), currRing),
8019 (intvec*)u4->Data()
8020 );
8021 return FALSE;
8022 }
8023 else
8024 {
8025 Werror("%s(`poly`,`poly`,`int`,`intvec`) exppected",
8026 Tok2Cmdname(iiOp));
8027 return TRUE;
8028 }
8029}
8030#if 0
8032{
8033 int ut=u->Typ();
8034 leftv v=u->next; u->next=NULL;
8035 leftv w=v->next; v->next=NULL;
8036 if ((ut!=CRING_CMD)&&(ut!=RING_CMD))
8037 {
8038 BOOLEAN bo=TRUE;
8039 if (w==NULL)
8040 {
8041 bo=iiExprArith2(res,u,'[',v);
8042 }
8043 else if (w->next==NULL)
8044 {
8045 bo=iiExprArith3(res,'[',u,v,w);
8046 }
8047 v->next=w;
8048 u->next=v;
8049 return bo;
8050 }
8051 v->next=w;
8052 u->next=v;
8053 #ifdef SINGULAR_4_1
8054 // construct new rings:
8055 while (u!=NULL)
8056 {
8057 Print("name: %s,\n",u->Name());
8058 u=u->next;
8059 }
8060 #else
8061 res->Init();
8062 res->rtyp=NONE;
8063 return TRUE;
8064 #endif
8065}
8066#endif
8068{
8070 && ((strcmp(u->Name(),"real")==0) || (strcmp(u->Name(),"complex")==0)))
8071 {
8072 memcpy(res,u,sizeof(sleftv));
8073 u->Init();
8074 return FALSE;
8075 }
8076 leftv v=u->next;
8077 BOOLEAN b;
8078 if(v==NULL) // p()
8080 else if ((v->next==NULL) // p(1)
8081 || (u->Typ()!=UNKNOWN)) // p(1,2), p proc or map
8082 {
8083 u->next=NULL;
8084 b=iiExprArith2(res,u,iiOp,v);
8085 u->next=v;
8086 }
8087 else // p(1,2), p undefined
8088 {
8089 if (v->Typ()!=INT_CMD)
8090 {
8091 Werror("`%s` undefined or `int` expected while building `%s(`",u->name,u->name);
8092 return TRUE;
8093 }
8094 int l=u->listLength();
8095 size_t len=strlen(u->name) + 12*l;
8096 char * nn = (char *)omAlloc(len);
8097 snprintf(nn,len,"%s(%d",u->name,(int)(long)v->Data());
8098 char *s=nn;
8099 do
8100 {
8101 while (*s!='\0') s++;
8102 v=v->next;
8103 if (v->Typ()!=INT_CMD)
8104 {
8105 Werror("`%s` undefined or `int` expected while building `%s(`",u->name,u->name);
8106 omFree((ADDRESS)nn);
8107 return TRUE;
8108 }
8109 snprintf(s,len-(nn-s),",%d",(int)(long)v->Data());
8110 } while (v->next!=NULL);
8111 while (*s!='\0') s++;
8112 nn=strcat(nn,")");
8113 char *n=omStrDup(nn);
8114 omFree((ADDRESS)nn);
8115 syMake(res,n);
8116 b=FALSE;
8117 }
8118 return b;
8119}
8121{
8122 const short t1[]={4,IDEAL_CMD,IDEAL_CMD,MATRIX_CMD,STRING_CMD};
8123 const short t2[]={4,MODUL_CMD,MODUL_CMD,MATRIX_CMD,STRING_CMD};
8124 leftv u=U;
8125 leftv v=u->next;
8126 leftv w=v->next;
8127 leftv u4=w->next;
8128 if (w->rtyp!=IDHDL) return TRUE;
8129 if (iiCheckTypes(U,t1)||iiCheckTypes(U,t2))
8130 {
8131 // see jjLIFT3
8132 ideal I=(ideal)u->Data();
8133 int ul= IDELEMS(I /*(ideal)u->Data()*/);
8134 int vl= IDELEMS((ideal)v->Data());
8135 GbVariant alg=syGetAlgorithm((char*)u4->Data(),currRing,I);
8136 ideal m
8137 = idLift(I,(ideal)v->Data(),NULL,FALSE,hasFlag(u,FLAG_STD),
8138 FALSE, (matrix *)(&(IDMATRIX((idhdl)(w->data)))),alg);
8139 if (m==NULL) return TRUE;
8140 res->data = (char *)id_Module2formatedMatrix(m,ul,vl,currRing);
8141 return FALSE;
8142 }
8143 else
8144 {
8145 Werror("%s(`ideal`,`ideal`,`matrix`,`string`)\n"
8146 "or (`module`,`module`,`matrix`,`string`) expected",
8147 Tok2Cmdname(iiOp));
8148 return TRUE;
8149 }
8150}
8152{
8153 // we have 4 or 5 arguments
8154 leftv u=U;
8155 leftv v=u->next;
8156 leftv u3=v->next;
8157 leftv u4=u3->next;
8158 leftv u5=u4->next; // might be NULL
8159
8160 ideal *syz=NULL;
8162 ideal h11=NULL;
8163
8164 if(u5==NULL)
8165 {
8166 // test all three possibilities for 4 arguments
8167 const short t1[]={4,IDEAL_CMD,MATRIX_CMD,MODUL_CMD,STRING_CMD};
8168 const short t2[]={4,MODUL_CMD,MATRIX_CMD,MODUL_CMD,STRING_CMD};
8169 const short t3[]={4,IDEAL_CMD,MATRIX_CMD,MODUL_CMD,IDEAL_CMD};
8170 const short t4[]={4,MODUL_CMD,MATRIX_CMD,MODUL_CMD,MODUL_CMD};
8171 const short t5[]={4,IDEAL_CMD,MATRIX_CMD,STRING_CMD,IDEAL_CMD};
8172 const short t6[]={4,MODUL_CMD,MATRIX_CMD,STRING_CMD,MODUL_CMD};
8173
8174 if(iiCheckTypes(U,t1)||iiCheckTypes(U,t2))
8175 {
8176 if ((u3->rtyp!=IDHDL)||(u3->e!=NULL)) return TRUE;
8177 idhdl hw=(idhdl)u3->data;
8178 syz=&(hw->data.uideal);
8179 alg=syGetAlgorithm((char*)u4->Data(),currRing,(ideal)u->Data());
8180 }
8181 else if(iiCheckTypes(U,t3)||iiCheckTypes(U,t4))
8182 {
8183 if ((u3->rtyp!=IDHDL)||(u3->e!=NULL)) return TRUE;
8184 idhdl hw=(idhdl)u3->data;
8185 syz=&(hw->data.uideal);
8186 h11=(ideal)u4->Data();
8187 }
8188 else if(iiCheckTypes(U,t5)||iiCheckTypes(U,t6))
8189 {
8190 alg=syGetAlgorithm((char*)u3->Data(),currRing,(ideal)u->Data());
8191 h11=(ideal)u4->Data();
8192 }
8193 else
8194 {
8195 Werror("%s(`ideal/module`,`matrix`[,`module`][,`string`][,`ideal/module`]) expected",Tok2Cmdname(iiOp));
8196 return TRUE;
8197 }
8198 }
8199 else
8200 {
8201 // we have 5 arguments
8202 const short t1[]={5,IDEAL_CMD,MATRIX_CMD,MODUL_CMD,STRING_CMD,IDEAL_CMD};
8203 const short t2[]={5,MODUL_CMD,MATRIX_CMD,MODUL_CMD,STRING_CMD,MODUL_CMD};
8204 if(iiCheckTypes(U,t1)||iiCheckTypes(U,t2))
8205 {
8206 idhdl hw=(idhdl)u3->data;
8207 syz=&(hw->data.uideal);
8208 alg=syGetAlgorithm((char*)u4->Data(),currRing,(ideal)u->Data());
8209 h11=(ideal)u5->Data();
8210 }
8211 else
8212 {
8213 Werror("%s(`ideal/module`,`matrix`[,`module`][,`string`][,`ideal/module`]) expected",Tok2Cmdname(iiOp));
8214 return TRUE;
8215 }
8216 }
8217
8218#ifdef HAVE_SHIFTBBA
8219 if (rIsLPRing(currRing))
8220 {
8221 if (currRing->LPncGenCount < IDELEMS((ideal)u->Data()))
8222 {
8223 Werror("At least %d ncgen variables are needed for this computation.", IDELEMS((ideal)u->Data()));
8224 return TRUE;
8225 }
8226 }
8227#endif
8228
8229 if ((v->rtyp!=IDHDL)||(v->e!=NULL)) return TRUE;
8230 idhdl hv=(idhdl)v->data;
8231 // CopyD for IDEAL_CMD and MODUL_CMD are identical:
8232 res->rtyp = u->Typ();
8233 res->data = (char *)idLiftStd((ideal)u->Data(),
8234 &(hv->data.umatrix),testHomog,
8235 syz,alg,h11);
8236 setFlag(res,FLAG_STD); v->flag=0;
8237 if(syz!=NULL)
8238 u3->flag=0;
8239 return FALSE;
8240}
8242{
8243 int sl=0;
8244 if (v!=NULL) sl = v->listLength();
8245 lists L;
8246 if((sl==1)&&(v->Typ()==RESOLUTION_CMD))
8247 {
8248 int add_row_shift = 0;
8249 intvec *weights=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
8250 if (weights!=NULL) add_row_shift=weights->min_in();
8252 }
8253 else
8254 {
8256 leftv h=NULL;
8257 int i;
8258 int rt;
8259
8260 L->Init(sl);
8261 for (i=0;i<sl;i++)
8262 {
8263 if (h!=NULL)
8264 { /* e.g. not in the first step:
8265 * h is the pointer to the old sleftv,
8266 * v is the pointer to the next sleftv
8267 * (in this moment) */
8268 h->next=v;
8269 }
8270 h=v;
8271 v=v->next;
8272 h->next=NULL;
8273 rt=h->Typ();
8274 if (rt==0)
8275 {
8276 L->Clean();
8277 Werror("`%s` is undefined",h->Fullname());
8278 return TRUE;
8279 }
8280 if (rt==RING_CMD)
8281 {
8282 L->m[i].rtyp=rt;
8283 L->m[i].data=rIncRefCnt(((ring)h->Data()));
8284 }
8285 else
8286 L->m[i].Copy(h);
8287 }
8288 }
8289 res->data=(char *)L;
8290 return FALSE;
8291}
8293{
8294 leftv v=u->next;
8295 leftv w=v->next;
8296 leftv u4=w->next;
8297 GbVariant alg;
8298 ideal u_id,v_id;
8299 // we have 4 arguments
8300 const short t1[]={4,IDEAL_CMD,IDEAL_CMD,MATRIX_CMD,STRING_CMD};
8301 const short t2[]={4,MODUL_CMD,MODUL_CMD,MATRIX_CMD,STRING_CMD};
8302 if(iiCheckTypes(u,t1)||iiCheckTypes(u,t2)||(w->rtyp!=IDHDL))
8303 {
8304 u_id=(ideal)u->Data();
8305 v_id=(ideal)v->Data();
8306 alg=syGetAlgorithm((char*)u4->Data(),currRing,u_id);
8307 }
8308 else
8309 {
8310 Werror("%s(`ideal/module`,`ideal/module`[,`matrix`][,`string`]) expected",Tok2Cmdname(iiOp));
8311 return TRUE;
8312 }
8313 intvec *w_u=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
8315 if (w_u!=NULL)
8316 {
8317 w_u=ivCopy(w_u);
8318 hom=isHomog;
8319 }
8320 intvec *w_v=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
8321 if (w_v!=NULL)
8322 {
8323 w_v=ivCopy(w_v);
8324 hom=isHomog;
8325 }
8326 if ((w_u!=NULL) && (w_v==NULL))
8327 w_v=ivCopy(w_u);
8328 if ((w_v!=NULL) && (w_u==NULL))
8329 w_u=ivCopy(w_v);
8330 if (w_u!=NULL)
8331 {
8332 if ((*w_u).compare((w_v))!=0)
8333 {
8334 WarnS("incompatible weights");
8335 delete w_u; w_u=NULL;
8336 hom=testHomog;
8337 }
8338 else
8339 {
8340 if ((!idTestHomModule(u_id,currRing->qideal,w_v))
8341 || (!idTestHomModule(v_id,currRing->qideal,w_v)))
8342 {
8343 WarnS("wrong weights");
8344 delete w_u; w_u=NULL;
8345 hom=testHomog;
8346 }
8347 }
8348 }
8349 idhdl h=(idhdl)w->data;
8350 res->data = (char *)idModulo(u_id,v_id ,hom,&w_u, &(h->data.umatrix),alg);
8351 if (w_u!=NULL)
8352 {
8353 atSet(res,omStrDup("isHomog"),w_u,INTVEC_CMD);
8354 }
8355 delete w_v;
8356 //if (TEST_OPT_RETURN_SB) setFlag(res,FLAG_STD);
8357 return FALSE;
8358}
8360{
8361 res->data=(void *)ipNameList(IDROOT);
8362 return FALSE;
8363}
8365{
8366 if(v==NULL)
8367 {
8368 res->data=(char *)showOption();
8369 return FALSE;
8370 }
8371 res->rtyp=NONE;
8372 return setOption(res,v);
8373}
8375{
8376 leftv u1=u;
8377 leftv u2=u1->next;
8378 leftv u3=u2->next;
8379 leftv u4=u3->next;
8380 int u1t=u1->Typ(); if (u1t==BUCKET_CMD) u1t=POLY_CMD;
8381 int u2t=u2->Typ(); if (u2t==BUCKET_CMD) u2t=POLY_CMD;
8382 if((u3->Typ()==INT_CMD)&&(u4->Typ()==INTVEC_CMD))
8383 {
8384 int save_d=Kstd1_deg;
8385 Kstd1_deg=(int)(long)u3->Data();
8386 kModW=(intvec *)u4->Data();
8387 BITSET save2;
8390 u2->next=NULL;
8391 BOOLEAN r=jjCALL2ARG(res,u);
8392 kModW=NULL;
8395 u->next->next=u3;
8396 return r;
8397 }
8398 else
8399 if((u1t==IDEAL_CMD)&&(u2t==MATRIX_CMD)&&(u3->Typ()==IDEAL_CMD)&&
8400 (u4->Typ()==INT_CMD))
8401 {
8403 if(!mp_IsDiagUnit((matrix)u2->Data(), currRing))
8404 {
8405 WerrorS("2nd argument must be a diagonal matrix of units");
8406 return TRUE;
8407 }
8408 res->data=(char*)redNF(
8409 idCopy((ideal)u3->Data()),
8410 idCopy((ideal)u1->Data()),
8411 mp_Copy((matrix)u2->Data(), currRing),
8412 (int)(long)u4->Data()
8413 );
8414 return FALSE;
8415 }
8416 else
8417 if((u1t==POLY_CMD)&&(u2t==POLY_CMD)&&(u3->Typ()==IDEAL_CMD)&&
8418 (u4->Typ()==INT_CMD))
8419 {
8420 poly u1p;
8421 if (u1->Typ()==BUCKET_CMD) u1p=sBucketPeek((sBucket_pt)u1->Data());
8422 else u1p=(poly)u1->Data();
8423 poly u2p;
8424 if (u2->Typ()==BUCKET_CMD) u2p=sBucketPeek((sBucket_pt)u2->Data());
8425 else u2p=(poly)u2->Data();
8427 if(!pIsUnit(u2p))
8428 {
8429 WerrorS("2nd argument must be a unit");
8430 return TRUE;
8431 }
8432 res->rtyp=POLY_CMD;
8433 res->data=(char*)redNF((ideal)u3->CopyD(),pCopy(u1p),
8434 pCopy(u2p),(int)(long)u4->Data());
8435 return FALSE;
8436 }
8437 else
8438 {
8439 Werror("%s(`poly`,`ideal`,`int`,`intvec`) expected",Tok2Cmdname(iiOp));
8440 Werror("%s(`ideal`,`matrix`,`ideal`,`int`) expected",Tok2Cmdname(iiOp));
8441 Werror("%s(`poly`,`poly`,`ideal`,`int`) expected",Tok2Cmdname(iiOp));
8442 return TRUE;
8443 }
8444}
8446{
8447 leftv u1=u;
8448 leftv u2=u1->next;
8449 leftv u3=u2->next;
8450 leftv u4=u3->next;
8451 leftv u5=u4->next;
8452 if((u1->Typ()==IDEAL_CMD)&&(u2->Typ()==MATRIX_CMD)&&(u3->Typ()==IDEAL_CMD)&&
8453 (u4->Typ()==INT_CMD)&&(u5->Typ()==INTVEC_CMD))
8454 {
8456 if(!mp_IsDiagUnit((matrix)u2->Data(), currRing))
8457 {
8458 WerrorS("2nd argument must be a diagonal matrix of units");
8459 return TRUE;
8460 }
8461 res->data=(char*)redNF(
8462 idCopy((ideal)u3->Data()),
8463 idCopy((ideal)u1->Data()),
8464 mp_Copy((matrix)u2->Data(),currRing),
8465 (int)(long)u4->Data(),
8466 (intvec*)u5->Data()
8467 );
8468 return FALSE;
8469 }
8470 else
8471 if((u1->Typ()==POLY_CMD)&&(u2->Typ()==POLY_CMD)&&(u3->Typ()==IDEAL_CMD)&&
8472 (u4->Typ()==INT_CMD)&&(u5->Typ()==INTVEC_CMD))
8473 {
8475 if(!pIsUnit((poly)u2->Data()))
8476 {
8477 WerrorS("2nd argument must be a unit");
8478 return TRUE;
8479 }
8480 res->rtyp=POLY_CMD;
8481 res->data=(char*)redNF(idCopy((ideal)u3->Data()),pCopy((poly)u1->Data()),
8482 pCopy((poly)u2->Data()),
8483 (int)(long)u4->Data(),(intvec*)u5->Data());
8484 return FALSE;
8485 }
8486 else
8487 {
8488 Werror("%s(`ideal`,`ideal`,`matrix`,`int`,`intvec`) exppected",
8489 Tok2Cmdname(iiOp));
8490 return TRUE;
8491 }
8492}
8494{
8495 unsigned i=1;
8496 unsigned nCount = (sArithBase.nCmdUsed-1)/3;
8497 if((3*nCount)<sArithBase.nCmdUsed) nCount++;
8498 //Print("CMDS: %d/%d\n", sArithBase.nCmdUsed,
8499 // sArithBase.nCmdAllocated);
8500 for(i=0; i<nCount; i++)
8501 {
8502 Print("%-20s",sArithBase.sCmds[i+1].name);
8504 Print("%-20s",sArithBase.sCmds[i+1+nCount].name);
8505 if(i+1+2*nCount<sArithBase.nCmdUsed)
8506 Print("%-20s",sArithBase.sCmds[i+1+2*nCount].name);
8507 //if ((i%3)==1) PrintLn();
8508 PrintLn();
8509 }
8510 PrintLn();
8512 return FALSE;
8513}
8514
8516{
8517 int l = 0;
8518 int k = 0;
8520 struct blackbox_list *bb_list = NULL;
8521 unsigned nCount = (sArithBase.nCmdUsed-1) / 3;
8522
8523 if ((3*nCount) < sArithBase.nCmdUsed)
8524 {
8525 nCount++;
8526 }
8528 // count the number of entries;
8529 for (unsigned i=0; i<nCount; i++)
8530 {
8531 l++;
8532 if (i + 1 + nCount < sArithBase.nCmdUsed)
8533 {
8534 l++;
8535 }
8536 if(i+1+2*nCount<sArithBase.nCmdUsed)
8537 {
8538 l++;
8539 }
8540 }
8541 for (int i = 0; i < bb_list->count; i++)
8542 {
8543 if (bb_list->list[i] != NULL)
8544 {
8545 l++;
8546 }
8547 }
8548 // initiate list
8549 L->Init(l);
8550 k = 0;
8551 for (unsigned i=0; i<nCount; i++)
8552 {
8553 L->m[k].rtyp = STRING_CMD;
8554 L->m[k].data = omStrDup(sArithBase.sCmds[i+1].name);
8555 k++;
8556 // Print("%-20s", sArithBase.sCmds[i+1].name);
8557 if (i + 1 + nCount < sArithBase.nCmdUsed)
8558 {
8559 L->m[k].rtyp = STRING_CMD;
8560 L->m[k].data = omStrDup(sArithBase.sCmds[i+1+nCount].name);
8561 k++;
8562 // Print("%-20s", sArithBase.sCmds[i+1 + nCount].name);
8563 }
8564 if(i+1+2*nCount<sArithBase.nCmdUsed)
8565 {
8566 L->m[k].rtyp = STRING_CMD;
8567 L->m[k].data = omStrDup(sArithBase.sCmds[i+1+2*nCount].name);
8568 k++;
8569 // Print("%-20s", sArithBase.sCmds[i+1+2*nCount].name);
8570 }
8571 // PrintLn();
8572 }
8573
8574 // assign blackbox types
8575 for (int i = 0; i < bb_list->count; i++)
8576 {
8577 if (bb_list->list[i] != NULL)
8578 {
8579 L->m[k].rtyp = STRING_CMD;
8580 // already used strdup in getBlackBoxTypes
8581 L->m[k].data = bb_list->list[i];
8582 k++;
8583 }
8584 }
8585 // free the struct (not the list entries itself, which were allocated
8586 // by strdup)
8587 omfree(bb_list->list);
8588 omfree(bb_list);
8589
8590 // pass the resultant list to the res datastructure
8591 res->data=(void *)L;
8592
8593 return FALSE;
8594}
8596{
8597 if (v == NULL)
8598 {
8599 res->data = omStrDup("");
8600 return FALSE;
8601 }
8602 int n = v->listLength();
8603 if (n == 1)
8604 {
8605 res->data = v->String();
8606 return FALSE;
8607 }
8608
8609 char** slist = (char**) omAlloc(n*sizeof(char*));
8610 int i, j;
8611
8612 for (i=0, j=0; i<n; i++, v = v ->next)
8613 {
8614 slist[i] = v->String();
8615 assume(slist[i] != NULL);
8616 j+=strlen(slist[i]);
8617 }
8618 char* s = (char*) omAlloc((j+1)*sizeof(char));
8619 *s='\0';
8620 for (i=0;i<n;i++)
8621 {
8622 strcat(s, slist[i]);
8623 omFree(slist[i]);
8624 }
8625 omFreeSize(slist, n*sizeof(char*));
8626 res->data = s;
8627 return FALSE;
8628}
8630{
8631 do
8632 {
8633 if (v->Typ()!=INT_CMD)
8634 return TRUE;
8635 test_cmd((int)(long)v->Data());
8636 v=v->next;
8637 }
8638 while (v!=NULL);
8639 return FALSE;
8640}
8641
8642#if defined(__alpha) && !defined(linux)
8643extern "C"
8644{
8645 void usleep(unsigned long usec);
8646};
8647#endif
8649{
8650 /* compute two factors of h(x,y) modulo x^(d+1) in K[[x]][y],
8651 see a detailed documentation in /kernel/linear_algebra/linearAlgebra.h
8652
8653 valid argument lists:
8654 - (poly h, int d),
8655 - (poly h, int d, poly f0, poly g0), optional: factors of h(0,y),
8656 - (poly h, int d, int xIndex, int yIndex), optional: indices of vars x & y
8657 in list of ring vars,
8658 - (poly h, int d, poly f0, poly g0, int xIndex, int yIndec),
8659 optional: all 4 optional args
8660 (The defaults are xIndex = 1, yIndex = 2, f0 and g0 polynomials as found
8661 by singclap_factorize and h(0, y)
8662 has exactly two distinct monic factors [possibly with exponent > 1].)
8663 result:
8664 - list with the two factors f and g such that
8665 h(x,y) = f(x,y)*g(x,y) mod x^(d+1) */
8666
8667 poly h = NULL;
8668 int d = 1;
8669 poly f0 = NULL;
8670 poly g0 = NULL;
8671 int xIndex = 1; /* default index if none provided */
8672 int yIndex = 2; /* default index if none provided */
8673
8674 leftv u = v; int factorsGiven = 0;
8675 if ((u == NULL) || (u->Typ() != POLY_CMD))
8676 {
8677 WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
8678 return TRUE;
8679 }
8680 else h = (poly)u->Data();
8681 u = u->next;
8682 if ((u == NULL) || (u->Typ() != INT_CMD))
8683 {
8684 WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
8685 return TRUE;
8686 }
8687 else d = (int)(long)u->Data();
8688 u = u->next;
8689 if ((u != NULL) && (u->Typ() == POLY_CMD))
8690 {
8691 if ((u->next == NULL) || (u->next->Typ() != POLY_CMD))
8692 {
8693 WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
8694 return TRUE;
8695 }
8696 else
8697 {
8698 f0 = (poly)u->Data();
8699 g0 = (poly)u->next->Data();
8700 factorsGiven = 1;
8701 u = u->next->next;
8702 }
8703 }
8704 if ((u != NULL) && (u->Typ() == INT_CMD))
8705 {
8706 if ((u->next == NULL) || (u->next->Typ() != INT_CMD))
8707 {
8708 WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
8709 return TRUE;
8710 }
8711 else
8712 {
8713 xIndex = (int)(long)u->Data();
8714 yIndex = (int)(long)u->next->Data();
8715 u = u->next->next;
8716 }
8717 }
8718 if (u != NULL)
8719 {
8720 WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
8721 return TRUE;
8722 }
8723
8724 /* checks for provided arguments */
8726 {
8727 WerrorS("expected non-constant polynomial argument(s)");
8728 return TRUE;
8729 }
8730 int n = rVar(currRing);
8731 if ((xIndex < 1) || (n < xIndex))
8732 {
8733 Werror("index for variable x (%d) out of range [1..%d]", xIndex, n);
8734 return TRUE;
8735 }
8736 if ((yIndex < 1) || (n < yIndex))
8737 {
8738 Werror("index for variable y (%d) out of range [1..%d]", yIndex, n);
8739 return TRUE;
8740 }
8741 if (xIndex == yIndex)
8742 {
8743 WerrorS("expected distinct indices for variables x and y");
8744 return TRUE;
8745 }
8746
8747 /* computation of f0 and g0 if missing */
8748 if (factorsGiven == 0)
8749 {
8750 poly h0 = pSubst(pCopy(h), xIndex, NULL);
8751 intvec* v = NULL;
8753
8754 ivTest(v);
8755
8756 if (i == NULL) return TRUE;
8757
8758 idTest(i);
8759
8760 if ((v->rows() != 3) || ((*v)[0] =! 1) || (!nIsOne(pGetCoeff(i->m[0]))))
8761 {
8762 WerrorS("expected h(0,y) to have exactly two distinct monic factors");
8763 return TRUE;
8764 }
8765 f0 = pPower(pCopy(i->m[1]), (*v)[1]);
8766 g0 = pPower(pCopy(i->m[2]), (*v)[2]);
8767 idDelete(&i);
8768 }
8769
8770 poly f; poly g;
8771 henselFactors(xIndex, yIndex, h, f0, g0, d, f, g);
8773 L->Init(2);
8774 L->m[0].rtyp = POLY_CMD; L->m[0].data=(void*)f;
8775 L->m[1].rtyp = POLY_CMD; L->m[1].data=(void*)g;
8776 res->rtyp = LIST_CMD;
8777 res->data = (char*)L;
8778 return FALSE;
8779}
8781{
8782 if ((v->Typ() != LINK_CMD) ||
8783 (v->next->Typ() != STRING_CMD) ||
8784 (v->next->next->Typ() != STRING_CMD) ||
8785 (v->next->next->next->Typ() != INT_CMD))
8786 return TRUE;
8787 jjSTATUS3(res, v, v->next, v->next->next);
8788#if defined(HAVE_USLEEP)
8789 if (((long) res->data) == 0L)
8790 {
8791 int i_s = (int)(long) v->next->next->next->Data();
8792 if (i_s > 0)
8793 {
8794 usleep((int)(long) v->next->next->next->Data());
8795 jjSTATUS3(res, v, v->next, v->next->next);
8796 }
8797 }
8798#elif defined(HAVE_SLEEP)
8799 if (((int) res->data) == 0)
8800 {
8801 int i_s = (int) v->next->next->next->Data();
8802 if (i_s > 0)
8803 {
8804 si_sleep((is - 1)/1000000 + 1);
8805 jjSTATUS3(res, v, v->next, v->next->next);
8806 }
8807 }
8808#endif
8809 return FALSE;
8810}
8812{
8813 leftv v = u->next; // number of args > 0
8814 if (v==NULL) return TRUE;
8815 leftv w = v->next;
8816 if (w==NULL) return TRUE;
8817 leftv rest = w->next;
8818
8819 u->next = NULL;
8820 v->next = NULL;
8821 w->next = NULL;
8822 BOOLEAN b = iiExprArith3(res, iiOp, u, v, w);
8823 if ((rest!=NULL) && (!b))
8824 {
8825 leftv tmp_next=res->next;
8826 res->next=rest;
8828 tmp_res.Init();
8830 memcpy(res,&tmp_res,sizeof(tmp_res));
8831 res->next=tmp_next;
8832 }
8833 u->next = v;
8834 v->next = w;
8835 // rest was w->next, but is already cleaned
8836 return b;
8837}
8839{
8840 if ((INPUT->Typ() != MATRIX_CMD) ||
8841 (INPUT->next->Typ() != NUMBER_CMD) ||
8842 (INPUT->next->next->Typ() != NUMBER_CMD) ||
8843 (INPUT->next->next->next->Typ() != NUMBER_CMD))
8844 {
8845 WerrorS("expected (matrix, number, number, number) as arguments");
8846 return TRUE;
8847 }
8848 leftv u = INPUT; leftv v = u->next; leftv w = v->next; leftv x = w->next;
8849 res->data = (char *)qrDoubleShift((matrix)(u->Data()),
8850 (number)(v->Data()),
8851 (number)(w->Data()),
8852 (number)(x->Data()));
8853 return FALSE;
8854}
8856{ ideal result;
8857 leftv u = INPUT; /* an ideal, weighted homogeneous and standard */
8858 leftv v = u->next; /* one additional polynomial or ideal */
8859 leftv h = v->next; /* Hilbert vector */
8860 leftv w = h->next; /* weight vector */
8861 assumeStdFlag(u);
8862 ideal i1=(ideal)(u->Data());
8863 ideal i0;
8864 if (((u->Typ()!=IDEAL_CMD)&&(u->Typ()!=MODUL_CMD))
8865 || (h->Typ()!=INTVEC_CMD)
8866 || (w->Typ()!=INTVEC_CMD))
8867 {
8868 WerrorS("expected `std(`ideal/module`,`poly/vector`,`intvec`,`intvec`)");
8869 return TRUE;
8870 }
8871 intvec *vw=(intvec *)w->Data(); // weights of vars
8872 /* merging std_hilb_w and std_1 */
8873 if (vw->length()!=currRing->N)
8874 {
8875 Werror("%d weights for %d variables",vw->length(),currRing->N);
8876 return TRUE;
8877 }
8878 int r=v->Typ();
8880 if ((r==POLY_CMD) ||(r==VECTOR_CMD))
8881 {
8882 i0=idInit(1,i1->rank);
8883 i0->m[0]=(poly)v->Data();
8885 }
8886 else if (r==IDEAL_CMD)/* IDEAL */
8887 {
8888 i0=(ideal)v->Data();
8889 }
8890 else
8891 {
8892 WerrorS("expected `std(`ideal/module`,`poly/vector`,`intvec`,`intvec`)");
8893 return TRUE;
8894 }
8895 int ii0=idElem(i0);
8896 i1 = idSimpleAdd(i1,i0);
8897 if (cleanup_i0)
8898 {
8899 memset(i0->m,0,sizeof(poly)*IDELEMS(i0));
8900 idDelete(&i0);
8901 }
8902 intvec *ww=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
8904 /* u_id from jjSTD_W is now i1 as in jjSTD_1 */
8905 if (ww!=NULL)
8906 {
8907 if (!idTestHomModule(i1,currRing->qideal,ww))
8908 {
8909 WarnS("wrong weights");
8910 ww=NULL;
8911 }
8912 else
8913 {
8914 ww=ivCopy(ww);
8915 hom=isHomog;
8916 }
8917 }
8918 BITSET save1;
8921 result=kStd(i1,
8922 currRing->qideal,
8923 hom,
8924 &ww, // module weights
8925 (intvec *)h->Data(), // hilbert series
8926 0, // syzComp, whatever it is...
8927 IDELEMS(i1)-ii0, // new ideal
8928 vw); // weights of vars
8930 idDelete(&i1);
8932 res->data = (char *)result;
8934 if (ww!=NULL) atSet(res,omStrDup("isHomog"),ww,INTVEC_CMD);
8935 return FALSE;
8936}
8937
8939{
8940 //Print("construct ring\n");
8941 if (a->Typ()!=CRING_CMD)
8942 {
8943 WerrorS("expected `cring` [ `id` ... ]");
8944 return TRUE;
8945 }
8946 assume(a->next!=NULL);
8947 leftv names=a->next;
8948 int N=names->listLength();
8949 char **n=(char**)omAlloc0(N*sizeof(char*));
8950 for(int i=0; i<N;i++,names=names->next)
8951 {
8952 n[i]=(char *)names->Name();
8953 }
8954 coeffs cf=(coeffs)a->CopyD();
8955 res->data=rDefault(cf,N,n, ringorder_dp);
8956 omFreeSize(n,N*sizeof(char*));
8957 return FALSE;
8958}
8959
8961{
8962 assume( e->Typ()==INT_CMD );
8964 r->start =(int)(long)e->Data();
8965 return r;
8966}
8968{
8969 int c=(int)(long)u->Data();
8970 switch(c)
8971 {
8972 case 0:{
8973 PrintS("delete all variables\n");
8974 killlocals(0);
8975 WerrorS("restarting...");
8976 break;
8977 };
8978 default: WerrorS("not implemented");
8979 }
8980 return FALSE;
8981}
8982#define D(A) (A)
8983#define NULL_VAL NULL
8984#define IPARITH
8985#include "table.h"
8986
8987#include "iparith.inc"
8988
8989/*=================== operations with 2 args. ============================*/
8990/* must be ordered: first operations for chars (infix ops),
8991 * then alphabetically */
8992
8995 const struct sValCmd2* dA2,
8996 int at, int bt,
8997 const struct sConvertTypes *dConvertTypes)
8998{
9000
9001 if (!errorreported)
9002 {
9003 int i=0;
9004 iiOp=op;
9005 while (dA2[i].cmd==op)
9006 {
9007 if ((at==dA2[i].arg1)
9008 && (bt==dA2[i].arg2))
9009 {
9010 res->rtyp=dA2[i].res;
9011 if (currRing!=NULL)
9012 {
9013 if (check_valid(dA2[i].valid_for,op)) break;
9014 }
9015 else
9016 {
9017 if (RingDependend(dA2[i].res))
9018 {
9019 WerrorS("no ring active (3)");
9020 break;
9021 }
9022 }
9023 if (traceit&TRACE_CALL)
9024 Print("call %s(%s,%s)\n",iiTwoOps(op),Tok2Cmdname(at),Tok2Cmdname(bt));
9025 if ((call_failed=dA2[i].p(res,a,b)))
9026 {
9027 break;// leave loop, goto error handling
9028 }
9029 a->CleanUp();
9030 b->CleanUp();
9031 //Print("op: %d,result typ:%d\n",op,res->rtyp);
9032 return FALSE;
9033 }
9034 i++;
9035 }
9036 // implicite type conversion ----------------------------------------------
9037 if (dA2[i].cmd!=op)
9038 {
9039 int ai,bi;
9043 i=0; /*iiTabIndex(dArithTab2,JJTAB2LEN,op);*/
9044 //Print("op: %c, type: %s %s\n",op,Tok2Cmdname(at),Tok2Cmdname(bt));
9045 while (dA2[i].cmd==op)
9046 {
9047 //Print("test %s %s\n",Tok2Cmdname(dA2[i].arg1),Tok2Cmdname(dA2[i].arg2));
9048 if ((dA2[i].valid_for & NO_CONVERSION)==0)
9049 {
9050 if ((ai=iiTestConvert(at,dA2[i].arg1,dConvertTypes))!=0)
9051 {
9052 if ((bi=iiTestConvert(bt,dA2[i].arg2,dConvertTypes))!=0)
9053 {
9054 res->rtyp=dA2[i].res;
9055 if (currRing!=NULL)
9056 {
9057 if (check_valid(dA2[i].valid_for,op)) break;
9058 }
9059 else
9060 {
9061 if (RingDependend(dA2[i].res))
9062 {
9063 WerrorS("no ring active (4)");
9064 break;
9065 }
9066 }
9067 if (traceit&TRACE_CALL)
9068 Print("call %s(%s,%s)\n",iiTwoOps(op),
9069 Tok2Cmdname(dA2[i].arg1),Tok2Cmdname(dA2[i].arg2));
9070 failed= ((iiConvert(at,dA2[i].arg1,ai,a,an))
9071 || (iiConvert(bt,dA2[i].arg2,bi,b,bn))
9072 || (call_failed=dA2[i].p(res,an,bn)));
9073 // everything done, clean up temp. variables
9074 if (failed)
9075 {
9076 // leave loop, goto error handling
9077 break;
9078 }
9079 else
9080 {
9081 // everything ok, clean up and return
9082 an->CleanUp();
9083 bn->CleanUp();
9086 return FALSE;
9087 }
9088 }
9089 }
9090 }
9091 i++;
9092 }
9093 an->CleanUp();
9094 bn->CleanUp();
9097 }
9098 // error handling ---------------------------------------------------
9099 const char *s=NULL;
9100 if (!errorreported)
9101 {
9102 if ((at==0) && (a->Fullname()!=sNoName_fe))
9103 {
9104 s=a->Fullname();
9105 }
9106 else if ((bt==0) && (b->Fullname()!=sNoName_fe))
9107 {
9108 s=b->Fullname();
9109 }
9110 if (s!=NULL)
9111 Werror("`%s` is not defined",s);
9112 else
9113 {
9114 i=0; /*iiTabIndex(dArithTab2,JJTAB2LEN,op);*/
9115 s = iiTwoOps(op);
9116 if (proccall)
9117 {
9118 Werror("%s(`%s`,`%s`) failed"
9120 }
9121 else
9122 {
9123 Werror("`%s` %s `%s` failed"
9125 }
9126 if ((!call_failed) && BVERBOSE(V_SHOW_USE))
9127 {
9128 while (dA2[i].cmd==op)
9129 {
9130 if(((at==dA2[i].arg1)||(bt==dA2[i].arg2))
9131 && (dA2[i].res!=0)
9132 && (dA2[i].p!=jjWRONG2))
9133 {
9134 if (proccall)
9135 Werror("expected %s(`%s`,`%s`)"
9136 ,s,Tok2Cmdname(dA2[i].arg1),Tok2Cmdname(dA2[i].arg2));
9137 else
9138 Werror("expected `%s` %s `%s`"
9139 ,Tok2Cmdname(dA2[i].arg1),s,Tok2Cmdname(dA2[i].arg2));
9140 }
9141 i++;
9142 }
9143 }
9144 }
9145 }
9146 a->CleanUp();
9147 b->CleanUp();
9148 res->rtyp = UNKNOWN;
9149 }
9150 return TRUE;
9151}
9153 const struct sValCmd2* dA2,
9154 int at,
9155 const struct sConvertTypes *dConvertTypes)
9156{
9157 res->Init();
9158 leftv b=a->next;
9159 a->next=NULL;
9160 int bt=b->Typ();
9162 a->next=b;
9163 a->CleanUp(); // to clean up the chain, content already done in iiExprArith2TabIntern
9164 return bo;
9165}
9167{
9168 res->Init();
9169
9170 if (!errorreported)
9171 {
9172#ifdef SIQ
9173 if (siq>0)
9174 {
9175 //Print("siq:%d\n",siq);
9177 memcpy(&d->arg1,a,sizeof(sleftv));
9178 a->Init();
9179 memcpy(&d->arg2,b,sizeof(sleftv));
9180 b->Init();
9181 d->argc=2;
9182 d->op=op;
9183 res->data=(char *)d;
9184 res->rtyp=COMMAND;
9185 return FALSE;
9186 }
9187#endif
9188 int at=a->Typ();
9189 int bt=b->Typ();
9190 // handling bb-objects ----------------------------------------------------
9191 if (at>MAX_TOK)
9192 {
9194 if (bb!=NULL)
9195 {
9196 if(!bb->blackbox_Op2(op,res,a,b)) return FALSE;
9197 // if not defined, try generic (attrib, ..)
9198 }
9199 else
9200 return TRUE;
9201 }
9202 else if ((bt>MAX_TOK)&&(op!='('))
9203 {
9205 if (bb!=NULL)
9206 {
9207 if(!bb->blackbox_Op2(op,res,a,b)) return FALSE;
9208 // if not defined, try generic (attrib, ..)
9209 }
9210 else
9211 return TRUE;
9212 }
9215 }
9216 a->CleanUp();
9217 b->CleanUp();
9218 return TRUE;
9219}
9220
9221/*==================== operations with 1 arg. ===============================*/
9222/* must be ordered: first operations for chars (infix ops),
9223 * then alphabetically */
9224
9225BOOLEAN iiExprArith1Tab(leftv res, leftv a, int op, const struct sValCmd1* dA1, int at, const struct sConvertTypes *dConvertTypes)
9226{
9227 res->Init();
9229
9230 if (!errorreported)
9231 {
9233 iiOp=op;
9234 int i = 0;
9235 while (dA1[i].cmd==op)
9236 {
9237 if (at==dA1[i].arg)
9238 {
9239 if (currRing!=NULL)
9240 {
9241 if (check_valid(dA1[i].valid_for,op)) break;
9242 }
9243 else
9244 {
9245 if (RingDependend(dA1[i].res))
9246 {
9247 WerrorS("no ring active (5)");
9248 break;
9249 }
9250 }
9251 if (traceit&TRACE_CALL)
9252 Print("call %s(%s)\n",iiTwoOps(op),Tok2Cmdname(at));
9253 res->rtyp=dA1[i].res;
9254 if ((call_failed=dA1[i].p(res,a)))
9255 {
9256 break;// leave loop, goto error handling
9257 }
9258 if (a->Next()!=NULL)
9259 {
9261 failed=iiExprArith1(res->next,a->next,op);
9262 }
9263 a->CleanUp();
9264 return failed;
9265 }
9266 i++;
9267 }
9268 // implicite type conversion --------------------------------------------
9269 if (dA1[i].cmd!=op)
9270 {
9272 i=0;
9273 //Print("fuer %c , typ: %s\n",op,Tok2Cmdname(at));
9274 while (dA1[i].cmd==op)
9275 {
9276 int ai;
9277 //Print("test %s\n",Tok2Cmdname(dA1[i].arg));
9278 if ((dA1[i].valid_for & NO_CONVERSION)==0)
9279 {
9280 if ((ai=iiTestConvert(at,dA1[i].arg,dConvertTypes))!=0)
9281 {
9282 if (currRing!=NULL)
9283 {
9284 if (check_valid(dA1[i].valid_for,op)) break;
9285 }
9286 else
9287 {
9288 if (RingDependend(dA1[i].res))
9289 {
9290 WerrorS("no ring active (6)");
9291 break;
9292 }
9293 }
9294 if (traceit&TRACE_CALL)
9295 Print("call %s(%s)\n",iiTwoOps(op),Tok2Cmdname(dA1[i].arg));
9296 res->rtyp=dA1[i].res;
9298 || (call_failed=dA1[i].p(res,an)));
9299 // everything done, clean up temp. variables
9300 if (failed)
9301 {
9302 // leave loop, goto error handling
9303 break;
9304 }
9305 else
9306 {
9307 if (an->Next() != NULL)
9308 {
9309 res->next = (leftv)omAllocBin(sleftv_bin);
9310 failed=iiExprArith1(res->next,an->next,op);
9311 }
9312 // everything ok, clean up and return
9313 an->CleanUp();
9315 return failed;
9316 }
9317 }
9318 }
9319 i++;
9320 }
9321 an->CleanUp();
9323 }
9324 // error handling
9325 if (!errorreported)
9326 {
9327 if ((at==0) && (a->Fullname()!=sNoName_fe))
9328 {
9329 Werror("`%s` is not defined",a->Fullname());
9330 }
9331 else
9332 {
9333 i=0;
9334 const char *s = iiTwoOps(op);
9335 Werror("%s(`%s`) failed"
9336 ,s,Tok2Cmdname(at));
9337 if ((!call_failed) && BVERBOSE(V_SHOW_USE))
9338 {
9339 while (dA1[i].cmd==op)
9340 {
9341 if ((dA1[i].res!=0)
9342 && (dA1[i].p!=jjWRONG))
9343 Werror("expected %s(`%s`)"
9344 ,s,Tok2Cmdname(dA1[i].arg));
9345 i++;
9346 }
9347 }
9348 }
9349 }
9350 res->rtyp = UNKNOWN;
9351 }
9352 a->CleanUp();
9353 return TRUE;
9354}
9356{
9357 if (!errorreported)
9358 {
9359 res->Init();
9360#ifdef SIQ
9361 if (siq>0)
9362 {
9363 //Print("siq:%d\n",siq);
9365 memcpy(&d->arg1,a,sizeof(sleftv));
9366 a->Init();
9367 d->op=op;
9368 d->argc=1;
9369 res->data=(char *)d;
9370 res->rtyp=COMMAND;
9371 return FALSE;
9372 }
9373#endif
9374 int at=a->Typ();
9375 // handling bb-objects ----------------------------------------------------
9376 if(op>MAX_TOK) // explicit type conversion to bb
9377 {
9379 if (bb!=NULL)
9380 {
9381 res->rtyp=op;
9382 res->data=bb->blackbox_Init(bb);
9383 return bb->blackbox_Assign(res,a);
9384 }
9385 else
9386 return TRUE;
9387 }
9388 else if (at>MAX_TOK) // argument is of bb-type
9389 {
9391 if (bb!=NULL)
9392 {
9393 if(!bb->blackbox_Op1(op,res,a)) return FALSE;
9394 // if not defined, try generic routines (attrib, defined,..)
9395 }
9396 else
9397 return TRUE;
9398 }
9399 if (errorreported) return TRUE;
9400
9403 }
9404 a->CleanUp();
9405 return TRUE;
9406}
9407
9408/*=================== operations with 3 args. ============================*/
9409/* must be ordered: first operations for chars (infix ops),
9410 * then alphabetically */
9411
9413 const struct sValCmd3* dA3, int at, int bt, int ct,
9414 const struct sConvertTypes *dConvertTypes)
9415{
9417
9418 assume(dA3[0].cmd==op);
9419
9420 if (!errorreported)
9421 {
9422 int i=0;
9423 iiOp=op;
9424 while (dA3[i].cmd==op)
9425 {
9426 if ((at==dA3[i].arg1)
9427 && (bt==dA3[i].arg2)
9428 && (ct==dA3[i].arg3))
9429 {
9430 res->rtyp=dA3[i].res;
9431 if (currRing!=NULL)
9432 {
9433 if (check_valid(dA3[i].valid_for,op)) break;
9434 }
9435 if (traceit&TRACE_CALL)
9436 Print("call %s(%s,%s,%s)\n",
9438 if ((call_failed=dA3[i].p(res,a,b,c)))
9439 {
9440 break;// leave loop, goto error handling
9441 }
9442 a->CleanUp();
9443 b->CleanUp();
9444 c->CleanUp();
9445 return FALSE;
9446 }
9447 i++;
9448 }
9449 // implicite type conversion ----------------------------------------------
9450 if (dA3[i].cmd!=op)
9451 {
9452 int ai,bi,ci;
9457 i=0;
9458 //while ((dA3[i].cmd!=op)&&(dA3[i].cmd!=0)) i++;
9459 while (dA3[i].cmd==op)
9460 {
9461 if ((dA3[i].valid_for & NO_CONVERSION)==0)
9462 {
9463 if ((ai=iiTestConvert(at,dA3[i].arg1,dConvertTypes))!=0)
9464 {
9465 if ((bi=iiTestConvert(bt,dA3[i].arg2,dConvertTypes))!=0)
9466 {
9467 if ((ci=iiTestConvert(ct,dA3[i].arg3,dConvertTypes))!=0)
9468 {
9469 res->rtyp=dA3[i].res;
9470 if (currRing!=NULL)
9471 {
9472 if (check_valid(dA3[i].valid_for,op)) break;
9473 }
9474 if (traceit&TRACE_CALL)
9475 Print("call %s(%s,%s,%s)\n",
9476 iiTwoOps(op),Tok2Cmdname(dA3[i].arg1),
9477 Tok2Cmdname(dA3[i].arg2),Tok2Cmdname(dA3[i].arg3));
9478 failed= ((iiConvert(at,dA3[i].arg1,ai,a,an,dConvertTypes))
9479 || (iiConvert(bt,dA3[i].arg2,bi,b,bn,dConvertTypes))
9480 || (iiConvert(ct,dA3[i].arg3,ci,c,cn,dConvertTypes))
9481 || (call_failed=dA3[i].p(res,an,bn,cn)));
9482 // everything done, clean up temp. variables
9483 if (failed)
9484 {
9485 // leave loop, goto error handling
9486 break;
9487 }
9488 else
9489 {
9490 // everything ok, clean up and return
9491 an->CleanUp();
9492 bn->CleanUp();
9493 cn->CleanUp();
9497 //Print("op: %d,result typ:%d\n",op,res->rtyp);
9498 return FALSE;
9499 }
9500 }
9501 }
9502 }
9503 }
9504 i++;
9505 }
9506 an->CleanUp();
9507 bn->CleanUp();
9508 cn->CleanUp();
9512 }
9513 // error handling ---------------------------------------------------
9514 if (!errorreported)
9515 {
9516 const char *s=NULL;
9517 if ((at==0) && (a->Fullname()!=sNoName_fe))
9518 {
9519 s=a->Fullname();
9520 }
9521 else if ((bt==0) && (b->Fullname()!=sNoName_fe))
9522 {
9523 s=b->Fullname();
9524 }
9525 else if ((ct==0) && (c->Fullname()!=sNoName_fe))
9526 {
9527 s=c->Fullname();
9528 }
9529 if (s!=NULL)
9530 Werror("`%s` is not defined",s);
9531 else
9532 {
9533 i=0;
9534 //while ((dA3[i].cmd!=op)&&(dA3[i].cmd!=0)) i++;
9535 const char *s = iiTwoOps(op);
9536 Werror("%s(`%s`,`%s`,`%s`) failed"
9538 if ((!call_failed) && BVERBOSE(V_SHOW_USE))
9539 {
9540 while (dA3[i].cmd==op)
9541 {
9542 if(((at==dA3[i].arg1)
9543 ||(bt==dA3[i].arg2)
9544 ||(ct==dA3[i].arg3))
9545 && (dA3[i].res!=0))
9546 {
9547 Werror("expected %s(`%s`,`%s`,`%s`)"
9548 ,s,Tok2Cmdname(dA3[i].arg1)
9549 ,Tok2Cmdname(dA3[i].arg2)
9550 ,Tok2Cmdname(dA3[i].arg3));
9551 }
9552 i++;
9553 }
9554 }
9555 }
9556 }
9557 res->rtyp = UNKNOWN;
9558 }
9559 a->CleanUp();
9560 b->CleanUp();
9561 c->CleanUp();
9562 //Print("op: %d,result typ:%d\n",op,res->rtyp);
9563 return TRUE;
9564}
9566{
9567 res->Init();
9568
9569 if (!errorreported)
9570 {
9571#ifdef SIQ
9572 if (siq>0)
9573 {
9574 //Print("siq:%d\n",siq);
9576 memcpy(&d->arg1,a,sizeof(sleftv));
9577 a->Init();
9578 memcpy(&d->arg2,b,sizeof(sleftv));
9579 b->Init();
9580 memcpy(&d->arg3,c,sizeof(sleftv));
9581 c->Init();
9582 d->op=op;
9583 d->argc=3;
9584 res->data=(char *)d;
9585 res->rtyp=COMMAND;
9586 return FALSE;
9587 }
9588#endif
9589 int at=a->Typ();
9590 // handling bb-objects ----------------------------------------------
9591 if (at>MAX_TOK)
9592 {
9594 if (bb!=NULL)
9595 {
9596 if(!bb->blackbox_Op3(op,res,a,b,c)) return FALSE;
9597 // otherwise, try defaul (attrib,..)
9598 }
9599 else
9600 return TRUE;
9601 if (errorreported) return TRUE;
9602 }
9603 int bt=b->Typ();
9604 int ct=c->Typ();
9605
9606 iiOp=op;
9607 int i=0;
9608 while ((dArith3[i].cmd!=op)&&(dArith3[i].cmd!=0)) i++;
9610 }
9611 a->CleanUp();
9612 b->CleanUp();
9613 c->CleanUp();
9614 //Print("op: %d,result typ:%d\n",op,res->rtyp);
9615 return TRUE;
9616}
9618 const struct sValCmd3* dA3,
9619 int at,
9620 const struct sConvertTypes *dConvertTypes)
9621{
9622 res->Init();
9623 leftv b=a->next;
9624 a->next=NULL;
9625 int bt=b->Typ();
9626 leftv c=b->next;
9627 b->next=NULL;
9628 int ct=c->Typ();
9630 b->next=c;
9631 a->next=b;
9632 a->CleanUp(); // to cleanup the chain, content already done
9633 return bo;
9634}
9635/*==================== operations with many arg. ===============================*/
9636/* must be ordered: first operations for chars (infix ops),
9637 * then alphabetically */
9638
9639#if 0 // unused
9640static BOOLEAN jjANY2LIST(leftv res, leftv v, int cnt)
9641{
9642 // cnt = 0: all
9643 // cnt = 1: only first one
9644 leftv next;
9646 if(v==NULL) return failed;
9647 res->rtyp = LIST_CMD;
9648 if(cnt) v->next = NULL;
9649 next = v->next; // saving next-pointer
9650 failed = jjLIST_PL(res, v);
9651 v->next = next; // writeback next-pointer
9652 return failed;
9653}
9654#endif
9655
9657{
9658 res->Init();
9659
9660 if (!errorreported)
9661 {
9662#ifdef SIQ
9663 if (siq>0)
9664 {
9665 //Print("siq:%d\n",siq);
9667 d->op=op;
9668 res->data=(char *)d;
9669 if (a!=NULL)
9670 {
9671 d->argc=a->listLength();
9672 // else : d->argc=0;
9673 memcpy(&d->arg1,a,sizeof(sleftv));
9674 switch(d->argc)
9675 {
9676 case 3:
9677 memcpy(&d->arg3,a->next->next,sizeof(sleftv));
9678 a->next->next->Init(); /* no break */
9679 case 2:
9680 memcpy(&d->arg2,a->next,sizeof(sleftv));
9681 a->next->Init();
9682 a->next->next=d->arg2.next;
9683 d->arg2.next=NULL; /* no break */
9684 case 1:
9685 a->Init();
9686 a->next=d->arg1.next;
9687 d->arg1.next=NULL;
9688 }
9689 if (d->argc>3) a->next=NULL;
9690 a->name=NULL;
9691 a->rtyp=0;
9692 a->data=NULL;
9693 a->e=NULL;
9694 a->attribute=NULL;
9695 a->CleanUp();
9696 }
9697 res->rtyp=COMMAND;
9698 return FALSE;
9699 }
9700#endif
9701 if ((a!=NULL) && (a->Typ()>MAX_TOK))
9702 {
9704 if (bb!=NULL)
9705 {
9706 if(!bb->blackbox_OpM(op,res,a)) return FALSE;
9707 // otherwise, try default
9708 }
9709 else
9710 return TRUE;
9711 if (errorreported) return TRUE;
9712 }
9713 int args=0;
9714 if (a!=NULL) args=a->listLength();
9715
9716 iiOp=op;
9717 int i=0;
9718 while ((dArithM[i].cmd!=op)&&(dArithM[i].cmd!=0)) i++;
9719 while (dArithM[i].cmd==op)
9720 {
9721 if ((args==dArithM[i].number_of_args)
9722 || (dArithM[i].number_of_args==-1)
9723 || ((dArithM[i].number_of_args==-2)&&(args>0)))
9724 {
9725 res->rtyp=dArithM[i].res;
9726 if (currRing!=NULL)
9727 {
9728 if (check_valid(dArithM[i].valid_for,op)) break;
9729 }
9730 if (traceit&TRACE_CALL)
9731 Print("call %s(... (%d args))\n", iiTwoOps(op),args);
9732 if (dArithM[i].p(res,a))
9733 {
9734 break;// leave loop, goto error handling
9735 }
9736 if (a!=NULL) a->CleanUp();
9737 //Print("op: %d,result typ:%d\n",op,res->rtyp);
9738 return FALSE;
9739 }
9740 i++;
9741 }
9742 // error handling
9743 if (!errorreported)
9744 {
9745 if ((args>0) && (a->rtyp==0) && (a->Name()!=sNoName_fe))
9746 {
9747 Werror("`%s` is not defined",a->Fullname());
9748 }
9749 else
9750 {
9751 const char *s = iiTwoOps(op);
9752 Werror("%s(...) failed",s);
9753 }
9754 }
9755 res->rtyp = UNKNOWN;
9756 }
9757 if (a!=NULL) a->CleanUp();
9758 //Print("op: %d,result typ:%d\n",op,res->rtyp);
9759 return TRUE;
9760}
9761
9762/*=================== general utilities ============================*/
9763int IsCmd(const char *n, int & tok)
9764{
9765 int i;
9766 int an=1;
9768
9769 loop
9770 //for(an=0; an<sArithBase.nCmdUsed; )
9771 {
9772 if(an>=en-1)
9773 {
9774 if (strcmp(n, sArithBase.sCmds[an].name) == 0)
9775 {
9776 i=an;
9777 break;
9778 }
9779 else if ((an!=en) && (strcmp(n, sArithBase.sCmds[en].name) == 0))
9780 {
9781 i=en;
9782 break;
9783 }
9784 else
9785 {
9786 // -- blackbox extensions:
9787 // return 0;
9788 return blackboxIsCmd(n,tok);
9789 }
9790 }
9791 i=(an+en)/2;
9792 if (*n < *(sArithBase.sCmds[i].name))
9793 {
9794 en=i-1;
9795 }
9796 else if (*n > *(sArithBase.sCmds[i].name))
9797 {
9798 an=i+1;
9799 }
9800 else
9801 {
9802 int v=strcmp(n,sArithBase.sCmds[i].name);
9803 if(v<0)
9804 {
9805 en=i-1;
9806 }
9807 else if(v>0)
9808 {
9809 an=i+1;
9810 }
9811 else /*v==0*/
9812 {
9813 break;
9814 }
9815 }
9816 }
9818 tok=sArithBase.sCmds[i].tokval;
9819 if(sArithBase.sCmds[i].alias==2)
9820 {
9821 Warn("outdated identifier `%s` used - please change your code",
9822 sArithBase.sCmds[i].name);
9823 sArithBase.sCmds[i].alias=1;
9824 }
9825 #if 0
9826 if (currRingHdl==NULL)
9827 {
9828 #ifdef SIQ
9829 if (siq<=0)
9830 {
9831 #endif
9832 if ((tok>=BEGIN_RING) && (tok<=END_RING))
9833 {
9834 WerrorS("no ring active");
9835 return 0;
9836 }
9837 #ifdef SIQ
9838 }
9839 #endif
9840 }
9841 #endif
9842 if (!expected_parms)
9843 {
9844 switch (tok)
9845 {
9846 case IDEAL_CMD:
9847 case INT_CMD:
9848 case INTVEC_CMD:
9849 case MAP_CMD:
9850 case MATRIX_CMD:
9851 case MODUL_CMD:
9852 case POLY_CMD:
9853 case PROC_CMD:
9854 case RING_CMD:
9855 case STRING_CMD:
9856 cmdtok = tok;
9857 break;
9858 }
9859 }
9860 return sArithBase.sCmds[i].toktype;
9861}
9862static int iiTabIndex(const jjValCmdTab dArithTab, const int len, const int op)
9863{
9864 // user defined types are not in the pre-computed table:
9865 if (op>MAX_TOK) return 0;
9866
9867 int a=0;
9868 int e=len;
9869 int p=len/2;
9870 do
9871 {
9872 if (op==dArithTab[p].cmd) return dArithTab[p].start;
9873 if (op<dArithTab[p].cmd) e=p-1;
9874 else a = p+1;
9875 p=a+(e-a)/2;
9876 }
9877 while ( a <= e);
9878
9879 // catch missing a cmd:
9880 // may be missing as a op for blackbox, if the first operand is "undef" instead of bb
9881 // Print("op %d (%c) unknown",op,op);
9882 return 0;
9883}
9884
9885typedef char si_char_2[2];
9887const char * Tok2Cmdname(int tok)
9888{
9889 if (tok <= 0)
9890 {
9891 return sArithBase.sCmds[0].name;
9892 }
9893 if (tok==ANY_TYPE) return "any_type";
9894 if (tok==COMMAND) return "command";
9895 if (tok==NONE) return "nothing";
9896 if (tok < 128)
9897 {
9899 return Tok2Cmdname_buf;
9900 }
9901 //if (tok==IFBREAK) return "if_break";
9902 //if (tok==VECTOR_FROM_POLYS) return "vector_from_polys";
9903 //if (tok==ORDER_VECTOR) return "ordering";
9904 //if (tok==REF_VAR) return "ref";
9905 //if (tok==OBJECT) return "object";
9906 //if (tok==PRINT_EXPR) return "print_expr";
9907 if (tok==IDHDL) return "identifier";
9908 if (tok>MAX_TOK) return getBlackboxName(tok);
9909 unsigned i;
9910 for(i=0; i<sArithBase.nCmdUsed; i++)
9911 //while (sArithBase.sCmds[i].tokval!=0)
9912 {
9913 if ((sArithBase.sCmds[i].tokval == tok)&&
9914 (sArithBase.sCmds[i].alias==0))
9915 {
9916 return sArithBase.sCmds[i].name;
9917 }
9918 }
9919 // try gain for alias/old names:
9920 for(i=0; i<sArithBase.nCmdUsed; i++)
9921 {
9922 if (sArithBase.sCmds[i].tokval == tok)
9923 {
9924 return sArithBase.sCmds[i].name;
9925 }
9926 }
9927 return sArithBase.sCmds[0].name;
9928}
9929
9930
9931/*---------------------------------------------------------------------*/
9932/**
9933 * @brief compares to entry of cmdsname-list
9934
9935 @param[in] a
9936 @param[in] b
9937
9938 @return <ReturnValue>
9939**/
9940/*---------------------------------------------------------------------*/
9941static int _gentable_sort_cmds( const void *a, const void *b )
9942{
9943 cmdnames *pCmdL = (cmdnames*)a;
9944 cmdnames *pCmdR = (cmdnames*)b;
9945
9946 if(a==NULL || b==NULL) return 0;
9947
9948 /* empty entries goes to the end of the list for later reuse */
9949 if(pCmdL->name==NULL) return 1;
9950 if(pCmdR->name==NULL) return -1;
9951
9952 /* $INVALID$ must come first */
9953 if(strcmp(pCmdL->name, "$INVALID$")==0) return -1;
9954 if(strcmp(pCmdR->name, "$INVALID$")==0) return 1;
9955
9956 /* tokval=-1 are reserved names at the end */
9957 if (pCmdL->tokval==-1)
9958 {
9959 if (pCmdR->tokval==-1)
9960 return strcmp(pCmdL->name, pCmdR->name);
9961 /* pCmdL->tokval==-1, pCmdL goes at the end */
9962 return 1;
9963 }
9964 /* pCmdR->tokval==-1, pCmdR goes at the end */
9965 if(pCmdR->tokval==-1) return -1;
9966
9967 return strcmp(pCmdL->name, pCmdR->name);
9968}
9969
9970/*---------------------------------------------------------------------*/
9971/**
9972 * @brief initialisation of arithmetic structured data
9973
9974 @retval 0 on success
9975
9976**/
9977/*---------------------------------------------------------------------*/
9979{
9980 //printf("iiInitArithmetic()\n");
9981 memset(&sArithBase, 0, sizeof(sArithBase));
9982 iiInitCmdName();
9983 /* fix last-identifier */
9984#if 0
9985 /* we expect that gentable allready did every thing */
9988 if(sArithBase.sCmds[sArithBase.nLastIdentifier].tokval>=0) break;
9989 }
9990#endif
9991 //Print("L=%d\n", sArithBase.nLastIdentifier);
9992
9993 //iiArithAddCmd(szName, nAlias, nTokval, nToktype);
9994 //iiArithAddCmd("mygcd", 1, GCD_CMD, CMD_2);
9995
9996 //iiArithAddCmd("Top", 0,-1,0);
9997
9998
9999 //for(i=0; i<sArithBase.nCmdUsed; i++) {
10000 // printf("CMD[%03d] %s, %d, %d, %d\n", i,
10001 // sArithBase.sCmds[i].name,
10002 // sArithBase.sCmds[i].alias,
10003 // sArithBase.sCmds[i].tokval,
10004 // sArithBase.sCmds[i].toktype);
10005 //}
10006 //iiArithRemoveCmd("Top");
10007 //iiArithAddCmd("mygcd", 2, GCD_CMD, CMD_2);
10008 //iiArithRemoveCmd("mygcd");
10009 //iiArithAddCmd("kkk", 1, 1234, CMD_1);
10010 return 0;
10011}
10012
10013int iiArithFindCmd(const char *szName)
10014{
10015 int an=0;
10016 int i = 0,v = 0;
10018
10019 loop
10020 //for(an=0; an<sArithBase.nCmdUsed; )
10021 {
10022 if(an>=en-1)
10023 {
10024 if (strcmp(szName, sArithBase.sCmds[an].name) == 0)
10025 {
10026 //Print("RET-an=%d %s\n", an, sArithBase.sCmds[an].name);
10027 return an;
10028 }
10029 else if (strcmp(szName, sArithBase.sCmds[en].name) == 0)
10030 {
10031 //Print("RET-en=%d %s\n", en, sArithBase.sCmds[en].name);
10032 return en;
10033 }
10034 else
10035 {
10036 //Print("RET- 1\n");
10037 return -1;
10038 }
10039 }
10040 i=(an+en)/2;
10041 if (*szName < *(sArithBase.sCmds[i].name))
10042 {
10043 en=i-1;
10044 }
10045 else if (*szName > *(sArithBase.sCmds[i].name))
10046 {
10047 an=i+1;
10048 }
10049 else
10050 {
10052 if(v<0)
10053 {
10054 en=i-1;
10055 }
10056 else if(v>0)
10057 {
10058 an=i+1;
10059 }
10060 else /*v==0*/
10061 {
10062 //Print("RET-i=%d %s\n", i, sArithBase.sCmds[i].name);
10063 return i;
10064 }
10065 }
10066 }
10067 //if(i>=0 && i<sArithBase.nCmdUsed)
10068 // return i;
10069 //PrintS("RET-2\n");
10070 return -2;
10071}
10072
10074{
10075 if(nPos<0) return NULL;
10076 if(nPos<(int)sArithBase.nCmdUsed)
10077 return sArithBase.sCmds[nPos].name;
10078 return NULL;
10079}
10080
10081int iiArithRemoveCmd(const char *szName)
10082{
10083 int nIndex;
10084 if(szName==NULL) return -1;
10085
10088 {
10089 Print("'%s' not found (%d)\n", szName, nIndex);
10090 return -1;
10091 }
10097
10098 /* fix last-identifier */
10101 {
10102 if(sArithBase.sCmds[sArithBase.nLastIdentifier].tokval>=0) break;
10103 }
10104 //Print("L=%d\n", sArithBase.nLastIdentifier);
10105 return 0;
10106}
10107
10109 const char *szName,
10110 short nAlias,
10111 short nTokval,
10112 short nToktype,
10113 short nPos
10114 )
10115{
10116 //printf("AddCmd(%s, %d, %d, %d, %d)\n", szName, nAlias,
10117 // nTokval, nToktype, nPos);
10118 if(nPos>=0)
10119 {
10120 // no checks: we rely on a correct generated code in iparith.inc
10121 assume((unsigned)nPos < sArithBase.nCmdAllocated);
10122 assume(szName!=NULL);
10124 sArithBase.sCmds[nPos].alias = nAlias;
10125 sArithBase.sCmds[nPos].tokval = nTokval;
10126 sArithBase.sCmds[nPos].toktype = nToktype;
10128 //if(nTokval>0) sArithBase.nLastIdentifier++;
10129 }
10130 else
10131 {
10132 if(szName==NULL) return -1;
10134 if(nIndex>=0)
10135 {
10136 Print("'%s' already exists at %d\n", szName, nIndex);
10137 return -1;
10138 }
10139
10141 {
10142 /* needs to create new slots */
10143 unsigned long nSize = (sArithBase.nCmdAllocated+1)*sizeof(cmdnames);
10145 if(sArithBase.sCmds==NULL) return -1;
10147 }
10148 /* still free slots available */
10154
10159 {
10160 if(sArithBase.sCmds[sArithBase.nLastIdentifier].tokval>=0) break;
10161 }
10162 //Print("L=%d\n", sArithBase.nLastIdentifier);
10163 }
10164 return 0;
10165}
10166
10167static BOOLEAN check_valid(const int p, const int op)
10168{
10170 {
10171 if ((p & NC_MASK)==NO_NC)
10172 {
10173 WerrorS("not implemented for non-commutative rings");
10174 return TRUE;
10175 }
10176 else if ((p & NC_MASK)==COMM_PLURAL)
10177 {
10178 Warn("assume commutative subalgebra for cmd `%s` in >>%s<<",Tok2Cmdname(op),my_yylinebuf);
10179 return FALSE;
10180 }
10181 /* else, ALLOW_PLURAL */
10182 }
10183 else if (rIsLPRing(currRing))
10184 {
10185 if ((p & ALLOW_LP)==0)
10186 {
10187 Werror("`%s` not implemented for letterplace rings in >>%s<<",Tok2Cmdname(op),my_yylinebuf);
10188 return TRUE;
10189 }
10190 }
10192 {
10193 if ((p & RING_MASK)==0 /*NO_RING*/)
10194 {
10195 WerrorS("not implemented for rings with rings as coeffients");
10196 return TRUE;
10197 }
10198 /* else ALLOW_RING */
10199 else if (((p & ZERODIVISOR_MASK)==NO_ZERODIVISOR)
10201 {
10202 WerrorS("domain required as coeffients");
10203 return TRUE;
10204 }
10205 /* else ALLOW_ZERODIVISOR */
10206 else if(((p & WARN_RING)==WARN_RING)&&(myynest==0))
10207 {
10208 WarnS("considering the image in Q[...]");
10209 }
10210 }
10211 return FALSE;
10212}
10213// --------------------------------------------------------------------
10215{
10216 if ((currRing!=NULL)
10218 && (!rField_is_Z(currRing)))
10219 {
10220 WerrorS("not implemented for rings with rings as coeffients (except ZZ)");
10221 return TRUE;
10222 }
10223 coeffs cf;
10224 lists c=(lists)u->CopyD(); // list of ideal or bigint/int
10225 int rl=c->nr+1;
10226 int return_type=c->m[0].Typ();
10227 if ((return_type!=IDEAL_CMD)
10231 && (return_type!=POLY_CMD))
10232 {
10234 ||(return_type==INT_CMD))
10236 else if (return_type==LIST_CMD)
10237 {
10238 // create a tmp list of the correct size
10240 res_l->Init(rl /*c->nr+1*/);
10243 for (unsigned i=0;i<=(unsigned)c->nr;i++)
10244 {
10245 sleftv tmp;
10246 tmp.Copy(v);
10248 if (bo) { Werror("chinrem failed for list entry %d",i+1); break;}
10249 }
10250 c->Clean();
10251 res->data=res_l;
10252 res->rtyp=LIST_CMD;
10253 return bo;
10254 }
10255 else
10256 {
10257 c->Clean();
10258 WerrorS("poly/ideal/module/matrix/list expected");
10259 return TRUE;
10260 }
10261 }
10264 else
10265 {
10266 cf=currRing->cf;
10267 if (nCoeff_is_Extension(cf) && (cf->extRing!=NULL))
10268 cf=cf->extRing->cf;
10269 }
10270 lists pl=NULL;
10271 intvec *p=NULL;
10272 if (v->Typ()==LIST_CMD)
10273 {
10274 pl=(lists)v->Data();
10275 if (pl->nr!=rl-1)
10276 {
10277 WerrorS("wromg number of primes");
10278 return TRUE;
10279 }
10280 }
10281 else
10282 {
10283 p=(intvec*)v->Data();
10284 if (p->length()!=rl)
10285 {
10286 WerrorS("wromg number of primes");
10287 return TRUE;
10288 }
10289 }
10290 ideal result;
10291 ideal *x=(ideal *)omAlloc(rl*sizeof(ideal));
10292 number *xx=NULL;
10294 int i;
10296 {
10297 for(i=rl-1;i>=0;i--)
10298 {
10299 if (c->m[i].Typ()!=return_type)
10300 {
10301 Werror("%s expected at pos %d",Tok2Cmdname(return_type),i+1);
10302 omFree(x); // delete c
10303 return TRUE;
10304 }
10305 if (return_type==POLY_CMD)
10306 {
10307 x[i]=idInit(1,1);
10308 x[i]->m[0]=(poly)c->m[i].CopyD();
10309 }
10310 else
10311 {
10312 x[i]=(ideal)c->m[i].CopyD();
10313 }
10314 //c->m[i].Init();
10315 }
10316 }
10317 else
10318 {
10319 if (nMap==NULL)
10320 {
10321 Werror("not implemented: map bigint -> %s", nCoeffName(cf));
10322 return TRUE;
10323 }
10324 xx=(number *)omAlloc(rl*sizeof(number));
10325 for(i=rl-1;i>=0;i--)
10326 {
10327 if (c->m[i].Typ()==INT_CMD)
10328 {
10329 xx[i]=n_Init(((int)(long)c->m[i].Data()),cf);
10330 }
10331 else if (c->m[i].Typ()==BIGINT_CMD)
10332 {
10333 xx[i]=nMap((number)c->m[i].Data(),coeffs_BIGINT,cf);
10334 }
10335 else
10336 {
10337 Werror("bigint expected at pos %d",i+1);
10338 omFree(x); // delete c
10339 omFree(xx); // delete c
10340 return TRUE;
10341 }
10342 }
10343 }
10344 number *q=(number *)omAlloc(rl*sizeof(number));
10345 if (p!=NULL)
10346 {
10347 for(i=rl-1;i>=0;i--)
10348 {
10349 q[i]=n_Init((*p)[i], cf);
10350 }
10351 }
10352 else
10353 {
10354 for(i=rl-1;i>=0;i--)
10355 {
10356 if (pl->m[i].Typ()==INT_CMD)
10357 {
10358 q[i]=n_Init((int)(long)pl->m[i].Data(),cf);
10359 }
10360 else if (pl->m[i].Typ()==BIGINT_CMD)
10361 {
10362 q[i]=nMap((number)(pl->m[i].Data()),coeffs_BIGINT,cf);
10363 }
10364 else
10365 {
10366 Werror("bigint expected at pos %d",i+1);
10367 for(i++;i<rl;i++)
10368 {
10369 n_Delete(&(q[i]),cf);
10370 }
10371 omFree(x); // delete c
10372 omFree(q); // delete pl
10373 if (xx!=NULL) omFree(xx); // delete c
10374 return TRUE;
10375 }
10376 }
10377 }
10379 {
10380 CFArray i_v(rl);
10382 res->data=(char *)n;
10383 }
10384 else
10385 {
10386 #if 0
10387 #ifdef HAVE_VSPACE
10389 if ((cpus>1) && (rField_is_Q(currRing)))
10390 result=id_ChineseRemainder_0(x,q,rl,currRing); // deletes also x
10391 else
10392 #endif
10393 #endif
10394 result=id_ChineseRemainder(x,q,rl,currRing); // deletes also x
10395 c->Clean();
10396 if ((return_type==POLY_CMD) &&(result!=NULL))
10397 {
10398 res->data=(char *)result->m[0];
10399 result->m[0]=NULL;
10400 idDelete(&result);
10401 }
10402 else
10403 res->data=(char *)result;
10404 }
10405 for(i=rl-1;i>=0;i--)
10406 {
10407 n_Delete(&(q[i]),cf);
10408 }
10409 omFree(q);
10410 res->rtyp=return_type;
10411 return result==NULL;
10412}
10414{
10415 lists c=(lists)u->CopyD();
10417 res_l->Init(c->nr+1);
10420 for (unsigned i=0;i<=(unsigned)c->nr;i++)
10421 {
10422 sleftv tmp;
10423 tmp.Copy(v);
10425 if (bo) { Werror("farey failed for list entry %d",i+1); break;}
10426 }
10427 c->Clean();
10428 res->data=res_l;
10429 return bo;
10430}
10431// --------------------------------------------------------------------
10432static int jjCOMPARE_ALL(const void * aa, const void * bb)
10433{
10434 leftv a=(leftv)aa;
10435 int at=a->Typ();
10436 leftv b=(leftv)bb;
10437 int bt=b->Typ();
10438 if (at < bt) return -1;
10439 if (at > bt) return 1;
10441 sleftv tmp;
10442 tmp.Init();
10443 iiOp='<';
10445 if (bo)
10446 {
10447 Werror(" no `<` for %s",Tok2Cmdname(at));
10448 unsigned long ad=(unsigned long)a->Data();
10449 unsigned long bd=(unsigned long)b->Data();
10450 if (ad<bd) return -1;
10451 else if (ad==bd) return 0;
10452 else return 1;
10453 }
10454 else if (tmp.data==NULL) /* not < */
10455 {
10459 if (bo)
10460 {
10461 Werror(" no `==` for %s",Tok2Cmdname(at));
10462 unsigned long ad=(unsigned long)a->Data();
10463 unsigned long bd=(unsigned long)b->Data();
10464 if (ad<bd) return -1;
10465 else if (ad==bd) return 0;
10466 else return 1;
10467 }
10468 else if (tmp.data==NULL) /* not <,== */ return 1;
10469 else return 0;
10470 }
10471 else return -1;
10472}
10474{
10475 lists l=(lists)arg->Data();
10476 if (l->nr>0)
10477 {
10478 qsort(l->m,l->nr+1,sizeof(sleftv),jjCOMPARE_ALL);
10479 }
10480 return FALSE;
10481}
10483{
10484 lists l=(lists)arg->Data();
10485 if (l->nr>0)
10486 {
10487 qsort(l->m,l->nr+1,sizeof(sleftv),jjCOMPARE_ALL);
10488 int i, j, len;
10489 len=l->nr;
10490 i=0;
10491 while(i<len)
10492 {
10493 if(jjCOMPARE_ALL(&(l->m[i]),&(l->m[i+1]))==0)
10494 {
10495 l->m[i].CleanUp();
10496 for(j=i; j<len;j++) l->m[j]=l->m[j+1];
10497 memset(&(l->m[len]),0,sizeof(sleftv));
10498 l->m[len].rtyp=DEF_CMD;
10499 len--;
10500 }
10501 else
10502 i++;
10503 }
10504 //Print("new len:%d\n",len);
10505 }
10506 return FALSE;
10507}
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
char name(const Variable &v)
Definition factory.h:189
VAR void(* WerrorS_callback)(const char *s)
Definition feFopen.cc:21
FILE * feFopen(const char *path, const char *mode, char *where, short useWerror, short path_only)
Definition feFopen.cc:47
VAR short errorreported
Definition feFopen.cc:23
void WerrorS(const char *s)
Definition feFopen.cc:24
static void * feOptValue(feOptIndex opt)
Definition feOpt.h:40
VAR char my_yylinebuf[80]
Definition febase.cc:44
VAR int myynest
Definition febase.cc:41
void monitor(void *F, int mode)
Definition febase.cc:68
void newBuffer(char *s, feBufferTypes t, procinfo *pi, int lineno)
Definition fevoices.cc:166
const char sNoName_fe[]
Definition fevoices.cc:57
@ BT_execute
Definition fevoices.h:23
This file is work in progress and currently not part of the official Singular.
matrix singflint_kernel(matrix m, const ring R)
#define jjWRONG3
Definition gentable.cc: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:9941
BOOLEAN jjWAITALL1(leftv res, leftv u)
Definition iparith.cc:5540
static BOOLEAN jjRESTART(leftv, leftv u)
Definition iparith.cc:8967
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:6957
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:8515
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:8364
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:8445
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:6916
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:10013
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:7809
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:6820
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:10473
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:7209
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:10432
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:10482
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:7272
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:6996
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:6365
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:8648
static BOOLEAN jjMATRIX_Id(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6934
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:6833
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:9978
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:7133
static BOOLEAN jjBAREISS3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6079
static BOOLEAN jjRESERVED0(leftv, leftv)
Definition iparith.cc:8493
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:8120
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:7328
static BOOLEAN jjJET_ID_M(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6371
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:6305
static BOOLEAN jjMINUS_N(leftv res, leftv u, leftv v)
Definition iparith.cc:897
static BOOLEAN jjBREAK0(leftv, leftv)
Definition iparith.cc:7321
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:9166
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:7369
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:6970
static BOOLEAN jjidMaxIdeal(leftv res, leftv v)
Definition iparith.cc:4394
static BOOLEAN jjMINOR_M(leftv res, leftv v)
Definition iparith.cc:6382
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:7178
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:7654
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:6340
static BOOLEAN jjRES3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7217
static BOOLEAN jjBIGINTVEC_PL(leftv res, leftv v)
Definition iparith.cc:7923
static BOOLEAN jjJET_P_IV(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6348
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:9617
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:7263
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:7258
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:7202
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:8960
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:8993
int IsCmd(const char *n, int &tok)
Definition iparith.cc:9763
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:8938
static BOOLEAN jjREDUCE4(leftv res, leftv u)
Definition iparith.cc:8374
static BOOLEAN jjFWALK(leftv res, leftv u, leftv v)
Definition iparith.cc:2358
static BOOLEAN jjTEST(leftv, leftv v)
Definition iparith.cc:8629
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:7386
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:9355
static BOOLEAN jjSTD_HILB_WP(leftv res, leftv INPUT)
Definition iparith.cc:8855
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:8151
#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:6924
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:10108
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:6355
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:7190
static BOOLEAN jjFAREY_LI(leftv res, leftv u, leftv v)
Definition iparith.cc:10413
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:6327
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:6661
static BOOLEAN jjHOMOG_P_W(leftv res, leftv u, leftv v, leftv)
Definition iparith.cc:6287
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:6866
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:7098
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:10167
static BOOLEAN jjSTRING_PL(leftv res, leftv v)
Definition iparith.cc:8595
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:7357
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:6671
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:6578
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:7111
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:7890
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:8292
static BOOLEAN jjHOMOG_ID_W(leftv res, leftv u, leftv v, leftv)
Definition iparith.cc:6269
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:7728
static BOOLEAN jjMODULO3S(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7047
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:8838
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:6247
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:6313
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:9152
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:9656
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:9565
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:6745
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:9412
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:9887
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:7529
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:7156
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:8359
#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:9886
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:6920
static BOOLEAN jjJET4(leftv res, leftv u)
Definition iparith.cc:7984
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:9225
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:10214
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:9885
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:6792
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:10073
static BOOLEAN jjSTATUS_M(leftv res, leftv v)
Definition iparith.cc:8780
static BOOLEAN jjCALL1ARG(leftv res, leftv v)
Definition iparith.cc:7345
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:8241
static BOOLEAN jjPLUSMINUS_Gen(leftv res, leftv u, leftv v)
Definition iparith.cc:629
static BOOLEAN jjCALL2ARG(leftv res, leftv u)
Definition iparith.cc:7349
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:9862
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:8067
static BOOLEAN jjSUBST_M(leftv res, leftv u)
Definition iparith.cc:8811
#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:7485
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:652
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition ipid.cc:281
VAR package basePack
Definition ipid.cc:58
VAR idhdl currRingHdl
Definition ipid.cc:59
VAR package currPack
Definition ipid.cc:57
lists ipNameList(idhdl root)
Definition ipid.cc:629
VAR coeffs coeffs_BIGINT
Definition ipid.cc:50
#define IDMAP(a)
Definition ipid.h:135
#define IDMATRIX(a)
Definition ipid.h:134
EXTERN_VAR omBin sleftv_bin
Definition ipid.h:145
ip_command * command
Definition ipid.h:23
#define IDDATA(a)
Definition ipid.h:126
#define hasFlag(A, F)
Definition ipid.h:112
#define setFlag(A, F)
Definition ipid.h:113
#define IDIDEAL(a)
Definition ipid.h:133
#define IDPOLY(a)
Definition ipid.h:130
#define IDID(a)
Definition ipid.h:122
#define IDROOT
Definition ipid.h:19
#define IDINT(a)
Definition ipid.h:125
#define FLAG_TWOSTD
Definition ipid.h:107
BOOLEAN load_builtin(const char *newlib, BOOLEAN autoexport, SModulFunc_t init)
Definition iplib.cc: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:2152
lists rDecompose_list_cf(const ring r)
Definition ipshell.cc:2113
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:6567
ring rInit(leftv pn, leftv rv, leftv ord)
Definition ipshell.cc:5621
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:1942
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:3087
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:1700
syStrategy syConvList(lists li)
Definition ipshell.cc:3250
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:2781
const char * lastreserved
Definition ipshell.cc:82
lists syConvRes(syStrategy syzstr, BOOLEAN toDel, int add_row_shift)
Definition ipshell.cc:3178
void rSetHdl(idhdl h)
Definition ipshell.cc:5122
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:3073
ideal kInterRed(ideal F, const ideal Q)
Definition kstd1.cc:3805
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:3224
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:2672
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:2657
LINLINE number nlInit(long i, const coeffs r)
Definition longrat.cc:2597
void maFetchPermLP(const ring preimage_r, const ring dst_r, int *perm)
Definition maps.cc:306
void maFindPerm(char const *const *const preim_names, int preim_n, char const *const *const preim_par, int preim_p, char const *const *const names, int n, char const *const *const par, int nop, int *perm, int *par_perm, n_coeffType ch)
Definition maps.cc:163
void maFindPermLP(char const *const *const preim_names, int preim_n, char const *const *const preim_par, int preim_p, char const *const *const names, int n, char const *const *const par, int nop, int *perm, int *par_perm, n_coeffType ch, int lV)
Definition maps.cc:231
poly pSubstPoly(poly p, int var, poly image)
Definition maps_ip.cc:402
ideal idSubstPoly(ideal id, int n, poly e)
Definition maps_ip.cc:424
BOOLEAN maApplyFetch(int what, map theMap, leftv res, leftv w, ring preimage_r, int *perm, int *par_perm, int P, nMapFunc nMap)
Definition maps_ip.cc:45
ideal idSubstPar(ideal id, int n, poly e)
Definition maps_ip.cc:385
poly pSubstPar(poly p, int par, poly image)
Definition maps_ip.cc:265
BOOLEAN mp_IsDiagUnit(matrix U, const ring R)
Definition matpol.cc: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:4674
slists * lists
The main handler for Singular numbers which are suitable for Singular polynomials.
Definition ap.h:40
ideal twostd(ideal I)
Compute two-sided GB:
Definition nc.cc:18
void newstruct_setup(const char *n, newstruct_desc d)
Definition newstruct.cc:688
newstruct_desc newstructChildFromString(const char *parent, const char *s)
Definition newstruct.cc:799
newstruct_desc newstructFromString(const char *s)
Definition newstruct.cc:792
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:1151
static long p_Totaldegree(poly p, const ring r)
Definition p_polys.h:1507
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:1404
int r_IsRingVar(const char *n, char **names, int N)
Definition ring.cc:213
int rChar(ring r)
Definition ring.cc:715
ring rMinusVar(const ring r, char *v)
undo rPlusVar
Definition ring.cc:5964
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:1801
char * rParStr(ring r)
Definition ring.cc:651
char * rCharStr(const ring r)
TODO: make it a virtual method of coeffs, together with: Decompose & Compose, rParameter & rPar.
Definition ring.cc:649
ring rOpposite(ring src)
Definition ring.cc:5365
char * rOrdStr(ring r)
Definition ring.cc:523
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:625
ring rPlusVar(const ring r, char *v, int left)
K[x],"y" -> K[x,y] resp. K[y,x].
Definition ring.cc:5882
ring rEnvelope(ring R)
Definition ring.cc:5759
int n_IsParam(const number m, const ring r)
TODO: rewrite somehow...
Definition ring.cc:5861
ring rCopy(ring r)
Definition ring.cc:1733
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
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:170
#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