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#include "Singular/htable.h"
75
76#include "Singular/fglm.h"
77
78#include "Singular/blackbox.h"
79#include "Singular/newstruct.h"
80#include "Singular/ipshell.h"
81//#include "kernel/mpr_inout.h"
82#include "reporter/si_signals.h"
83
84#include <ctype.h>
85
86// defaults for all commands: NO_NC | NO_RING | ALLOW_ZERODIVISOR
87
88#ifdef HAVE_PLURAL
90 #include "kernel/GBEngine/nc.h"
91 #include "polys/nc/nc.h"
92 #include "polys/nc/sca.h"
93 #define NC_MASK (3+64)
94#else /* HAVE_PLURAL */
95 #define NC_MASK 0
96#endif /* HAVE_PLURAL */
97
98#define RING_MASK 4
99#define ZERODIVISOR_MASK 8
100#define ALLOW_PLURAL 1
101#define NO_NC 0
102#define COMM_PLURAL 2
103#define ALLOW_RING 4
104#define NO_RING 0
105#define NO_ZERODIVISOR 8
106#define ALLOW_ZERODIVISOR 0
107#define ALLOW_LP 64
108#define NO_LRING 128
109#define ALLOW_NC ALLOW_LP|ALLOW_PLURAL
110
111#define ALLOW_ZZ (ALLOW_RING|NO_ZERODIVISOR)
112
113
114// bit 4 for warning, if used at toplevel
115#define WARN_RING 16
116// bit 5: do no try automatic conversions
117#define NO_CONVERSION 32
118
119static BOOLEAN check_valid(const int p, const int op);
120
121#define bit31 SIZEOF_LONG*8-1
122
123/*=============== types =====================*/
125{
126 short cmd;
127 short start;
128};
129
131
132struct _scmdnames
133{
134 char *name;
135 short alias;
136 short tokval;
137 short toktype;
138};
139typedef struct _scmdnames cmdnames;
140
141struct sValCmd1
142{
144 short cmd;
145 short res;
146 short arg;
147 short valid_for;
148};
149
151struct sValCmd2
152{
154 short cmd;
155 short res;
156 short arg1;
157 short arg2;
158 short valid_for;
159};
160
162struct sValCmd3
163{
165 short cmd;
166 short res;
167 short arg1;
168 short arg2;
169 short arg3;
170 short valid_for;
171};
172struct sValCmdM
173{
175 short cmd;
176 short res;
177 short number_of_args; /* -1: any, -2: any >0, .. */
178 short valid_for;
179};
180
181typedef struct
182{
183 cmdnames *sCmds; /**< array of existing commands */
188 unsigned nCmdUsed; /**< number of commands used */
189 unsigned nCmdAllocated; /**< number of commands-slots allocated */
190 unsigned nLastIdentifier; /**< valid identifiers are slot 1..nLastIdentifier */
191} SArithBase;
192
193/*---------------------------------------------------------------------*
194 * File scope Variables (Variables share by several functions in
195 * the same file )
196 *
197 *---------------------------------------------------------------------*/
198STATIC_VAR SArithBase sArithBase; /**< Base entry for arithmetic */
199
200/*---------------------------------------------------------------------*
201 * Extern Functions declarations
202 *
203 *---------------------------------------------------------------------*/
204static int _gentable_sort_cmds(const void *a, const void *b);
205extern int iiArithRemoveCmd(char *szName);
206extern int iiArithAddCmd(const char *szName, short nAlias, short nTokval,
207 short nToktype, short nPos=-1);
208
209/*============= proc =======================*/
210static int iiTabIndex(const jjValCmdTab dArithTab, const int len, const int op);
211static Subexpr jjMakeSub(leftv e);
212
213/*============= vars ======================*/
216
217#define ii_div_by_0 "div. by 0"
218
219VAR int iiOp; /* the current operation*/
220
221/*=================== simple helpers =================*/
222static int iin_Int(number &n,coeffs cf)
223{
224 long l=n_Int(n,cf);
225 int i=(int)l;
226 if ((long)i==l) return l;
227 return 0;
228}
229
230int iiTokType(int op)
231{
232 for (unsigned i=0;i<sArithBase.nCmdUsed;i++)
233 {
234 if (sArithBase.sCmds[i].tokval==op)
235 return sArithBase.sCmds[i].toktype;
236 }
237 return 0;
238}
239
240/*=================== operations with 2 args.: static proc =================*/
241/* must be ordered: first operations for chars (infix ops),
242 * then alphabetically */
243
245{
246 bigintmat* aa= (bigintmat *)u->Data();
247 long bb = (long)(v->Data());
248 if (errorreported) return TRUE;
249 bigintmat *cc=NULL;
250 switch (iiOp)
251 {
252 case '+': cc=bimAdd(aa,bb); break;
253 case '-': cc=bimSub(aa,bb); break;
254 case '*': cc=bimMult(aa,bb); break;
255 }
256 res->data=(char *)cc;
257 return cc==NULL;
258}
260{
261 return jjOP_BIM_I(res, v, u);
262}
264{
265 bigintmat* aa= (bigintmat *)u->Data();
266 number bb = (number)(v->Data());
267 if (errorreported) return TRUE;
268 bigintmat *cc=NULL;
269 switch (iiOp)
270 {
271 case '*': cc=bimMult(aa,bb,coeffs_BIGINT); break;
272 }
273 res->data=(char *)cc;
274 return cc==NULL;
275}
277{
278 return jjOP_BIM_BI(res, v, u);
279}
281{
282 intvec* aa= (intvec *)u->CopyD(INTVEC_CMD);
283 int bb = (int)(long)(v->Data());
284 if (errorreported) return TRUE;
285 switch (iiOp)
286 {
287 case '+': (*aa) += bb; break;
288 case '-': (*aa) -= bb; break;
289 case '*': (*aa) *= bb; break;
290 case '/':
291 case INTDIV_CMD: (*aa) /= bb; break;
292 case '%': (*aa) %= bb; break;
293 }
294 res->data=(char *)aa;
295 return FALSE;
296}
298{
299 return jjOP_IV_I(res,v,u);
300}
302{
303 intvec* aa= (intvec *)u->CopyD(INTVEC_CMD);
304 int bb = (int)(long)(v->Data());
305 int i=si_min(aa->rows(),aa->cols());
306 switch (iiOp)
307 {
308 case '+': for (;i>0;i--) IMATELEM(*aa,i,i) += bb;
309 break;
310 case '-': for (;i>0;i--) IMATELEM(*aa,i,i) -= bb;
311 break;
312 }
313 res->data=(char *)aa;
314 return FALSE;
315}
317{
318 return jjOP_IM_I(res,v,u);
319}
321{
322 int l=(int)(long)v->Data();
323 if (l>=0)
324 {
325 int d=(int)(long)u->Data();
326 intvec *vv=new intvec(l);
327 int i;
328 for(i=l-1;i>=0;i--) { (*vv)[i]=d; }
329 res->data=(char *)vv;
330 }
331 return (l<0);
332}
334{
335 res->data=(char *)new intvec((int)(long)u->Data(),(int)(long)v->Data());
336 return FALSE;
337}
338static void jjEQUAL_REST(leftv res,leftv u,leftv v);
340{
341 intvec* a = (intvec * )(u->Data());
342 intvec* b = (intvec * )(v->Data());
343 int r=a->compare(b);
344 switch (iiOp)
345 {
346 case '<':
347 res->data = (char *) (r<0);
348 break;
349 case '>':
350 res->data = (char *) (r>0);
351 break;
352 case LE:
353 res->data = (char *) (r<=0);
354 break;
355 case GE:
356 res->data = (char *) (r>=0);
357 break;
358 case EQUAL_EQUAL:
359 case NOTEQUAL: /* negation handled by jjEQUAL_REST */
360 res->data = (char *) (r==0);
361 break;
362 }
363 jjEQUAL_REST(res,u,v);
364 if(r==-2) { WerrorS("size incompatible"); return TRUE; }
365 return FALSE;
366}
368{
369 bigintmat* a = (bigintmat * )(u->Data());
370 bigintmat* b = (bigintmat * )(v->Data());
371 int r=a->compare(b);
372 switch (iiOp)
373 {
374 #if 0
375 case '<':
376 res->data = (char *) (r<0);
377 break;
378 case '>':
379 res->data = (char *) (r>0);
380 break;
381 case LE:
382 res->data = (char *) (r<=0);
383 break;
384 case GE:
385 res->data = (char *) (r>=0);
386 break;
387 #endif
388 case EQUAL_EQUAL:
389 case NOTEQUAL: /* negation handled by jjEQUAL_REST */
390 res->data = (char *) (r==0);
391 break;
392 }
393 jjEQUAL_REST(res,u,v);
394 if(r==-2) { WerrorS("size incompatible"); return TRUE; }
395 return FALSE;
396}
398{
399 intvec* a = (intvec * )(u->Data());
400 int b = (int)(long)(v->Data());
401 int r=a->compare(b);
402 switch (iiOp)
403 {
404 case '<':
405 res->data = (char *) (r<0);
406 break;
407 case '>':
408 res->data = (char *) (r>0);
409 break;
410 case LE:
411 res->data = (char *) (r<=0);
412 break;
413 case GE:
414 res->data = (char *) (r>=0);
415 break;
416 case EQUAL_EQUAL:
417 case NOTEQUAL: /* negation handled by jjEQUAL_REST */
418 res->data = (char *) (r==0);
419 break;
420 }
421 jjEQUAL_REST(res,u,v);
422 return FALSE;
423}
425{
426 //Print("in: >>%s<<\n",my_yylinebuf);
427 matrix a=(matrix)u->Data();
428 matrix b=(matrix)v->Data();
429 int r=mp_Compare(a,b,currRing);
430 switch (iiOp)
431 {
432 case '<':
433 res->data = (char *) (long)(r < 0);
434 break;
435 case '>':
436 res->data = (char *) (long)(r > 0);
437 break;
438 case LE:
439 res->data = (char *) (long)(r <= 0);
440 break;
441 case GE:
442 res->data = (char *) (long)(r >= 0);
443 break;
444 case EQUAL_EQUAL:
445 case NOTEQUAL: /* negation handled by jjEQUAL_REST */
446 res->data = (char *)(long) (r == 0);
447 break;
448 }
449 jjEQUAL_REST(res,u,v);
450 return FALSE;
451}
453{
454 poly p=(poly)u->Data();
455 poly q=(poly)v->Data();
456 int r=p_Compare(p,q,currRing);
457 switch (iiOp)
458 {
459 case '<':
460 res->data = (char *) (r < 0);
461 break;
462 case '>':
463 res->data = (char *) (r > 0);
464 break;
465 case LE:
466 res->data = (char *) (r <= 0);
467 break;
468 case GE:
469 res->data = (char *) (r >= 0);
470 break;
471 //case EQUAL_EQUAL:
472 //case NOTEQUAL: /* negation handled by jjEQUAL_REST */
473 // res->data = (char *) (r == 0);
474 // break;
475 }
476 jjEQUAL_REST(res,u,v);
477 return FALSE;
478}
480{
481 char* a = (char * )(u->Data());
482 char* b = (char * )(v->Data());
483 int result = strcmp(a,b);
484 switch (iiOp)
485 {
486 case '<':
487 res->data = (char *) (result < 0);
488 break;
489 case '>':
490 res->data = (char *) (result > 0);
491 break;
492 case LE:
493 res->data = (char *) (result <= 0);
494 break;
495 case GE:
496 res->data = (char *) (result >= 0);
497 break;
498 case EQUAL_EQUAL:
499 case NOTEQUAL: /* negation handled by jjEQUAL_REST */
500 res->data = (char *) (result == 0);
501 break;
502 }
503 jjEQUAL_REST(res,u,v);
504 return FALSE;
505}
507{
508 if (u->Next()!=NULL)
509 {
510 u=u->next;
511 res->next = (leftv)omAllocBin(sleftv_bin);
512 return iiExprArith2(res->next,u,iiOp,v);
513 }
514 else if (v->Next()!=NULL)
515 {
516 v=v->next;
517 res->next = (leftv)omAllocBin(sleftv_bin);
518 return iiExprArith2(res->next,u,iiOp,v);
519 }
520 return FALSE;
521}
523{
524 long b=(long)u->Data();
525 long e=(long)v->Data();
526 long rc = 1;
527 BOOLEAN overflow=FALSE;
528 if (e >= 0)
529 {
530 if (b==0)
531 {
532 rc=(e==0);
533 }
534 else if ((e==0)||(b==1))
535 {
536 rc= 1;
537 }
538 else if (b== -1)
539 {
540 if (e&1) rc= -1;
541 else rc= 1;
542 }
543 else
544 {
545 long oldrc;
546 while ((e--)!=0)
547 {
548 oldrc=rc;
549 rc *= b;
550 if (!overflow)
551 {
552 if(rc/b!=oldrc) overflow=TRUE;
553 }
554 }
555 if (overflow)
556 WarnS("int overflow(^), result may be wrong");
557 }
558 res->data = (char *)rc;
559 if (u!=NULL) return jjOP_REST(res,u,v);
560 return FALSE;
561 }
562 else
563 {
564 WerrorS("exponent must be non-negative");
565 return TRUE;
566 }
567}
569{
570 int e=(int)(long)v->Data();
571 number n=(number)u->Data();
572 if (e>=0)
573 {
574 n_Power(n,e,(number*)&res->data,coeffs_BIGINT);
575 }
576 else
577 {
578 WerrorS("exponent must be non-negative");
579 return TRUE;
580 }
581 if (u!=NULL) return jjOP_REST(res,u,v);
582 return FALSE;
583}
585{
586 int e=(int)(long)v->Data();
587 number n=(number)u->Data();
588 int d=0;
589 if (e<0)
590 {
591 n=nInvers(n);
592 e=-e;
593 d=1;
594 }
595 number r;
596 nPower(n,e,(number*)&r);
597 res->data=(char*)r;
598 if (d) nDelete(&n);
599 if (u!=NULL) return jjOP_REST(res,u,v);
600 return FALSE;
601}
603{
604 int v_i=(int)(long)v->Data();
605 if (v_i<0)
606 {
607 WerrorS("exponent must be non-negative");
608 return TRUE;
609 }
610 poly u_p=(poly)u->CopyD(POLY_CMD);
611 if ((u_p!=NULL)
612 && (!rIsLPRing(currRing))
613 && ((v_i!=0) &&
614 ((long)pTotaldegree(u_p) > (signed long)currRing->bitmask / (signed long)v_i/2)))
615 {
616 Werror("OVERFLOW in power(d=%ld, e=%d, max=%ld)",
617 pTotaldegree(u_p),v_i,currRing->bitmask/2);
618 pDelete(&u_p);
619 return TRUE;
620 }
621 res->data = (char *)pPower(u_p,v_i);
622 if (u!=NULL) return jjOP_REST(res,u,v);
623 return errorreported; /* pPower may set errorreported via Werror */
624}
626{
627 res->data = (char *)id_Power((ideal)(u->Data()),(int)(long)(v->Data()), currRing);
628 if (u!=NULL) return jjOP_REST(res,u,v);
629 return FALSE;
630}
632{
633 u=u->next;
634 v=v->next;
635 if (u==NULL)
636 {
637 if (v==NULL) return FALSE; /* u==NULL, v==NULL */
638 if (iiOp=='-') /* u==NULL, v<>NULL, iiOp=='-'*/
639 {
640 do
641 {
642 if (res->next==NULL)
644 leftv tmp_v=v->next;
645 v->next=NULL;
646 BOOLEAN b=iiExprArith1(res->next,v,'-');
647 v->next=tmp_v;
648 if (b)
649 return TRUE;
650 v=tmp_v;
651 res=res->next;
652 } while (v!=NULL);
653 return FALSE;
654 }
655 loop /* u==NULL, v<>NULL, iiOp=='+' */
656 {
658 res=res->next;
659 res->data = v->CopyD();
660 res->rtyp = v->Typ();
661 v=v->next;
662 if (v==NULL) return FALSE;
663 }
664 }
665 if (v!=NULL) /* u<>NULL, v<>NULL */
666 {
667 do
668 {
670 leftv tmp_u=u->next; u->next=NULL;
671 leftv tmp_v=v->next; v->next=NULL;
672 BOOLEAN b=iiExprArith2(res->next,u,iiOp,v);
673 u->next=tmp_u;
674 v->next=tmp_v;
675 if (b)
676 return TRUE;
677 u=tmp_u;
678 v=tmp_v;
679 res=res->next;
680 } while ((u!=NULL) && (v!=NULL));
681 return FALSE;
682 }
683 loop /* u<>NULL, v==NULL */
684 {
686 res=res->next;
687 res->data = u->CopyD();
688 res->rtyp = u->Typ();
689 u=u->next;
690 if (u==NULL) return FALSE;
691 }
692}
694{
695 switch(u->Typ())
696 {
697 case 0:
698 {
699 int name_err=0;
700 if(isupper(u->name[0]))
701 {
702 const char *c=u->name+1;
703 while((*c!='\0')&&(islower(*c)||(isdigit(*c))||(*c=='_'))) c++;
704 if (*c!='\0')
705 name_err=1;
706 else
707 {
708 Print("%s of type 'ANY'. Trying load.\n", u->name);
709 if(iiTryLoadLib(u, u->name))
710 {
711 Werror("'%s' no such package", u->name);
712 return TRUE;
713 }
714 syMake(u,u->name,NULL);
715 }
716 }
717 else name_err=1;
718 if(name_err)
719 { Werror("'%s' is an invalid package name",u->name);return TRUE;}
720 // and now, after the loading: use next case !!! no break !!!
721 }
722 case PACKAGE_CMD:
723 {
724 package pa=(package)u->Data();
725 if (u->rtyp==IDHDL) pa=IDPACKAGE((idhdl)u->data);
726 if((!pa->loaded)
727 && (pa->language > LANG_TOP))
728 {
729 Werror("'%s' not loaded", u->name);
730 return TRUE;
731 }
732 if(v->rtyp == IDHDL)
733 {
734 v->name = omStrDup(v->name);
735 }
736 else if (v->rtyp!=0)
737 {
738 WerrorS("reserved name with ::");
739 return TRUE;
740 }
741 v->req_packhdl=pa;
742 syMake(v, v->name, pa);
743 memcpy(res, v, sizeof(sleftv));
744 v->Init();
745 }
746 break;
747 case DEF_CMD:
748 break;
749 default:
750 WerrorS("<package>::<id> expected");
751 return TRUE;
752 }
753 return FALSE;
754}
756{
757 unsigned long a=(unsigned long)u->Data();
758 unsigned long b=(unsigned long)v->Data();
759 unsigned long c=a+b;
760 res->data = (char *)((long)c);
761 if (((Sy_bitL(bit31)&a)==(Sy_bitL(bit31)&b))&&((Sy_bitL(bit31)&a)!=(Sy_bitL(bit31)&c)))
762 {
763 WarnS("int overflow(+), result may be wrong");
764 }
765 return jjPLUSMINUS_Gen(res,u,v);
766}
768{
769 res->data = (char *)(n_Add((number)u->Data(), (number)v->Data(),coeffs_BIGINT));
770 return jjPLUSMINUS_Gen(res,u,v);
771}
773{
774 res->data = (char *)(nAdd((number)u->Data(), (number)v->Data()));
775 return jjPLUSMINUS_Gen(res,u,v);
776}
778{
779 res->data = (char *)(pAdd((poly)u->CopyD(POLY_CMD) , (poly)v->CopyD(POLY_CMD)));
780 return jjPLUSMINUS_Gen(res,u,v);
781}
783{
784 //res->data = (char *)(pAdd((poly)u->CopyD(POLY_CMD) , (poly)v->CopyD(POLY_CMD)));
786 poly p=(poly)u->CopyD(POLY_CMD);
787 int l=pLength(p);
789 p= (poly)v->CopyD(POLY_CMD);
790 l=pLength(p);
792 res->data=(void*)b;
793 return jjPLUSMINUS_Gen(res,u,v);
794}
796{
798 poly p= (poly)v->CopyD(POLY_CMD);
799 int l=pLength(p);
801 res->data=(void*)b;
802 return jjPLUSMINUS_Gen(res,u,v);
803}
805{
806 res->data = (char *)ivAdd((intvec*)(u->Data()), (intvec*)(v->Data()));
807 if (res->data==NULL)
808 {
809 WerrorS("intmat size not compatible");
810 return TRUE;
811 }
812 return jjPLUSMINUS_Gen(res,u,v);
813}
815{
816 res->data = (char *)bimAdd((bigintmat*)(u->Data()), (bigintmat*)(v->Data()));
817 if (res->data==NULL)
818 {
819 WerrorS("bigintmat/cmatrix not compatible");
820 return TRUE;
821 }
822 return jjPLUSMINUS_Gen(res,u,v);
823}
825{
826 matrix A=(matrix)u->Data(); matrix B=(matrix)v->Data();
827 res->data = (char *)(mp_Add(A , B, currRing));
828 if (res->data==NULL)
829 {
830 Werror("matrix size not compatible(%dx%d, %dx%d)",
832 return TRUE;
833 }
834 return jjPLUSMINUS_Gen(res,u,v);
835}
837{
838 ideal A=(ideal)u->Data(); ideal B=(ideal)v->Data();
839 res->data = (char *)(sm_Add(A , B, currRing));
840 if (res->data==NULL)
841 {
842 Werror("matrix size not compatible(%dx%d, %dx%d)",
843 (int)A->rank,IDELEMS(A),(int)B->rank,IDELEMS(B));
844 return TRUE;
845 }
846 return jjPLUSMINUS_Gen(res,u,v);
847}
849{
850 matrix m=(matrix)u->Data();
851 matrix p= mp_InitP(m->nrows,m->ncols,(poly)(v->CopyD(POLY_CMD)),currRing);
852 if (iiOp=='+')
853 res->data = (char *)mp_Add(m , p,currRing);
854 else
855 res->data = (char *)mp_Sub(m , p,currRing);
856 idDelete((ideal *)&p);
857 return jjPLUSMINUS_Gen(res,u,v);
858}
860{
861 return jjPLUS_MA_P(res,v,u);
862}
864{
865 char* a = (char * )(u->Data());
866 char* b = (char * )(v->Data());
867 char* r = (char * )omAlloc(strlen(a) + strlen(b) + 1);
868 strcpy(r,a);
869 strcat(r,b);
870 res->data=r;
871 return jjPLUSMINUS_Gen(res,u,v);
872}
874{
875 res->data = (char *)idAdd((ideal)u->Data(),(ideal)v->Data());
876 return jjPLUSMINUS_Gen(res,u,v);
877}
879{
880 void *ap=u->Data(); void *bp=v->Data();
881 long aa=(long)ap;
882 long bb=(long)bp;
883 long cc=aa-bb;
884 unsigned long a=(unsigned long)ap;
885 unsigned long b=(unsigned long)bp;
886 unsigned long c=a-b;
887 if (((Sy_bitL(bit31)&a)!=(Sy_bitL(bit31)&b))&&((Sy_bitL(bit31)&a)!=(Sy_bitL(bit31)&c)))
888 {
889 WarnS("int overflow(-), result may be wrong");
890 }
891 res->data = (char *)cc;
892 return jjPLUSMINUS_Gen(res,u,v);
893}
895{
896 res->data = (char *)(n_Sub((number)u->Data(), (number)v->Data(),coeffs_BIGINT));
897 return jjPLUSMINUS_Gen(res,u,v);
898}
900{
901 res->data = (char *)(nSub((number)u->Data(), (number)v->Data()));
902 return jjPLUSMINUS_Gen(res,u,v);
903}
905{
906 res->data = (char *)(pSub((poly)u->CopyD(POLY_CMD) , (poly)v->CopyD(POLY_CMD)));
907 return jjPLUSMINUS_Gen(res,u,v);
908}
910{
912 poly p= (poly)v->CopyD(POLY_CMD);
913 int l=pLength(p);
914 p=p_Neg(p,currRing);
916 res->data=(void*)b;
917 return jjPLUSMINUS_Gen(res,u,v);
918}
920{
922 poly p=(poly)u->CopyD(POLY_CMD);
923 int l=pLength(p);
925 p= (poly)v->CopyD(POLY_CMD);
926 p=p_Neg(p,currRing);
927 l=pLength(p);
929 res->data=(void*)b;
930 return jjPLUSMINUS_Gen(res,u,v);
931}
933{
934 res->data = (char *)ivSub((intvec*)(u->Data()), (intvec*)(v->Data()));
935 if (res->data==NULL)
936 {
937 WerrorS("intmat size not compatible");
938 return TRUE;
939 }
940 return jjPLUSMINUS_Gen(res,u,v);
941}
943{
944 res->data = (char *)bimSub((bigintmat*)(u->Data()), (bigintmat*)(v->Data()));
945 if (res->data==NULL)
946 {
947 WerrorS("bigintmat/cmatrix not compatible");
948 return TRUE;
949 }
950 return jjPLUSMINUS_Gen(res,u,v);
951}
953{
954 matrix A=(matrix)u->Data(); matrix B=(matrix)v->Data();
955 res->data = (char *)(mp_Sub(A , B, currRing));
956 if (res->data==NULL)
957 {
958 Werror("matrix size not compatible(%dx%d, %dx%d)",
960 return TRUE;
961 }
962 return jjPLUSMINUS_Gen(res,u,v);
963 return FALSE;
964}
966{
967 ideal A=(ideal)u->Data(); ideal B=(ideal)v->Data();
968 res->data = (char *)(sm_Sub(A , B, currRing));
969 if (res->data==NULL)
970 {
971 Werror("matrix size not compatible(%dx%d, %dx%d)",
972 (int)A->rank,IDELEMS(A),(int)B->rank,IDELEMS(B));
973 return TRUE;
974 }
975 return jjPLUSMINUS_Gen(res,u,v);
976 return FALSE;
977}
979{
980 long a=(long)u->Data();
981 long b=(long)v->Data();
982 long c=(long)((unsigned long)a * (unsigned long)b);
983 // unsigned long has no overflow
984 if ((a!=0)&&(c/a!=b))
985 WarnS("int overflow(*), result may be wrong");
986 res->data = (char *)c;
987 if ((u->Next()!=NULL) || (v->Next()!=NULL))
988 return jjOP_REST(res,u,v);
989 return FALSE;
990}
992{
993 res->data = (char *)(n_Mult( (number)u->Data(), (number)v->Data(),coeffs_BIGINT));
994 if ((v->next!=NULL) || (u->next!=NULL))
995 return jjOP_REST(res,u,v);
996 return FALSE;
997}
999{
1000 res->data = (char *)(nMult( (number)u->Data(), (number)v->Data()));
1001 number n=(number)res->data;
1002 nNormalize(n);
1003 res->data=(char *)n;
1004 if ((v->next!=NULL) || (u->next!=NULL))
1005 return jjOP_REST(res,u,v);
1006 return FALSE;
1007}
1009{
1010 poly a;
1011 poly b;
1012 if (v->next==NULL)
1013 {
1014 if (u->next==NULL)
1015 {
1016 a=(poly)u->Data(); // works also for VECTOR_CMD
1017 b=(poly)v->Data(); // works also for VECTOR_CMD
1018 if (!rIsLPRing(currRing)
1019 && (a!=NULL) && (b!=NULL)
1020 && ((long)pTotaldegree(a)>si_max((long)rVar(currRing),(long)currRing->bitmask/2)-(long)pTotaldegree(b)))
1021 {
1022 Warn("possible OVERFLOW in mult(d=%ld, d=%ld, max=%ld)",
1023 pTotaldegree(a),pTotaldegree(b),currRing->bitmask/2);
1024 }
1025 res->data = (char *)(pp_Mult_qq( a, b, currRing));
1026 return FALSE;
1027 }
1028 // u->next exists: copy v
1029 a=(poly)u->CopyD(POLY_CMD); // works also for VECTOR_CMD
1030 b=pCopy((poly)v->Data());
1031 if (!rIsLPRing(currRing)
1032 && (a!=NULL) && (b!=NULL)
1033 && (pTotaldegree(a)+pTotaldegree(b)>si_max((long)rVar(currRing),(long)currRing->bitmask/2)))
1034 {
1035 Warn("possible OVERFLOW in mult(d=%ld, d=%ld, max=%ld)",
1036 pTotaldegree(a),pTotaldegree(b),currRing->bitmask/2);
1037 }
1038 res->data = (char *)(pMult( a, b));
1039 return jjOP_REST(res,u,v);
1040 }
1041 // v->next exists: copy u
1042 a=pCopy((poly)u->Data());
1043 b=(poly)v->CopyD(POLY_CMD); // works also for VECTOR_CMD
1044 if ((a!=NULL) && (b!=NULL)
1045 && ((unsigned long)(pTotaldegree(a)+pTotaldegree(b))>=currRing->bitmask/2))
1046 {
1047 pDelete(&a);
1048 pDelete(&b);
1049 WerrorS("OVERFLOW");
1050 return TRUE;
1051 }
1052 res->data = (char *)(pMult( a, b));
1053 return jjOP_REST(res,u,v);
1054}
1056{
1057 res->data = (char *)idMult((ideal)u->Data(),(ideal)v->Data());
1058 if ((v->next!=NULL) || (u->next!=NULL))
1059 return jjOP_REST(res,u,v);
1060 return FALSE;
1061}
1063{
1064 res->data = (char *)ivMult((intvec*)(u->Data()), (intvec*)(v->Data()));
1065 if (res->data==NULL)
1066 {
1067 WerrorS("intmat size not compatible");
1068 return TRUE;
1069 }
1070 if ((v->next!=NULL) || (u->next!=NULL))
1071 return jjOP_REST(res,u,v);
1072 return FALSE;
1073}
1075{
1076 res->data = (char *)bimMult((bigintmat*)(u->Data()), (bigintmat*)(v->Data()));
1077 if (res->data==NULL)
1078 {
1079 WerrorS("bigintmat/cmatrix not compatible");
1080 return TRUE;
1081 }
1082 if ((v->next!=NULL) || (u->next!=NULL))
1083 return jjOP_REST(res,u,v);
1084 return FALSE;
1085}
1087{
1089 if (nMap==NULL) return TRUE;
1090 number n=nMap((number)v->Data(),coeffs_BIGINT,currRing->cf);
1091 poly p=pNSet(n);
1092 ideal I= (ideal)mp_MultP((matrix)u->CopyD(MATRIX_CMD),p,currRing);
1093 res->data = (char *)I;
1094 return FALSE;
1095}
1097{
1098 return jjTIMES_MA_BI1(res,v,u);
1099}
1101{
1102 poly p=(poly)v->CopyD(POLY_CMD);
1103 int r=pMaxComp(p);/* recompute the rank for the case ideal*vector*/
1104 ideal I= (ideal)mp_MultP((matrix)u->CopyD(MATRIX_CMD),p,currRing);
1105 if (r>0) I->rank=r;
1106 res->data = (char *)I;
1107 return FALSE;
1108}
1110{
1111 poly p=(poly)u->CopyD(POLY_CMD);
1112 int r=pMaxComp(p);/* recompute the rank for the case ideal*vector*/
1113 ideal I= (ideal)pMultMp(p,(matrix)v->CopyD(MATRIX_CMD),currRing);
1114 if (r>0) I->rank=r;
1115 res->data = (char *)I;
1116 return FALSE;
1117}
1119{
1120 number n=(number)v->CopyD(NUMBER_CMD);
1121 poly p=pNSet(n);
1122 res->data = (char *)mp_MultP((matrix)u->CopyD(MATRIX_CMD),p,currRing);
1123 return FALSE;
1124}
1126{
1127 return jjTIMES_MA_N1(res,v,u);
1128}
1130{
1131 res->data = (char *)mp_MultI((matrix)u->CopyD(MATRIX_CMD),(long)v->Data(),currRing);
1132 return FALSE;
1133}
1135{
1136 return jjTIMES_MA_I1(res,v,u);
1137}
1139{
1140 matrix A=(matrix)u->Data(); matrix B=(matrix)v->Data();
1141 res->data = (char *)mp_Mult(A,B,currRing);
1142 if (res->data==NULL)
1143 {
1144 Werror("matrix size not compatible(%dx%d, %dx%d) in *",
1146 return TRUE;
1147 }
1148 if ((v->next!=NULL) || (u->next!=NULL))
1149 return jjOP_REST(res,u,v);
1150 return FALSE;
1151}
1153{
1154 ideal A=(ideal)u->Data(); ideal B=(ideal)v->Data();
1155 res->data = (char *)sm_Mult(A,B,currRing);
1156 if (res->data==NULL)
1157 {
1158 Werror("matrix size not compatible(%dx%d, %dx%d) in *",
1159 (int)A->rank,IDELEMS(A),(int)B->rank,IDELEMS(B));
1160 return TRUE;
1161 }
1162 if ((v->next!=NULL) || (u->next!=NULL))
1163 return jjOP_REST(res,u,v);
1164 return FALSE;
1165}
1167{
1168 number h=n_Sub((number)u->Data(),(number)v->Data(),coeffs_BIGINT);
1169 res->data = (char *) (n_GreaterZero(h,coeffs_BIGINT)||(n_IsZero(h,coeffs_BIGINT)));
1171 return FALSE;
1172}
1174{
1175 res->data = (char *)(long)((int)((long)u->Data()) >= (int)((long)v->Data()));
1176 return FALSE;
1177}
1179{
1180 res->data = (char *)(long) (nGreater((number)u->Data(),(number)v->Data())
1181 || nEqual((number)u->Data(),(number)v->Data()));
1182 return FALSE;
1183}
1185{
1186 number h=n_Sub((number)u->Data(),(number)v->Data(),coeffs_BIGINT);
1187 res->data = (char *)(long) (n_GreaterZero(h,coeffs_BIGINT)&&(!n_IsZero(h,coeffs_BIGINT)));
1189 return FALSE;
1190}
1192{
1193 res->data = (char *)(long)((int)((long)u->Data()) > (int)((long)v->Data()));
1194 return FALSE;
1195}
1197{
1198 res->data = (char *)(long)(nGreater((number)u->Data(),(number)v->Data()));
1199 return FALSE;
1200}
1202{
1203 return jjGE_BI(res,v,u);
1204}
1206{
1207 res->data = (char *)(long)((int)((long)u->Data()) <= (int)((long)v->Data()));
1208 return FALSE;
1209}
1211{
1212 return jjGE_N(res,v,u);
1213}
1215{
1216 return jjGT_BI(res,v,u);
1217}
1219{
1220 res->data = (char *)(long)((int)((long)u->Data()) < (int)((long)v->Data()));
1221 return FALSE;
1222}
1224{
1225 return jjGT_N(res,v,u);
1226}
1228{
1229 if (iiOp=='/') Warn("int division with `/`: use `div` instead in line >>%s<<",my_yylinebuf);
1230 long a= (long)u->Data();
1231 long b= (long)v->Data();
1232 if (b==0)
1233 {
1235 return TRUE;
1236 }
1237 long c=a%b;
1238 long r=0;
1239 switch (iiOp)
1240 {
1241 case '%':
1242 r=c; break;
1243 case '/':
1244 case INTDIV_CMD:
1245 r=((a-c) /b); break;
1246 }
1247 res->data=(void *)r;
1248 return FALSE;
1249}
1251{
1252 number q=(number)v->Data();
1253 if (n_IsZero(q,coeffs_BIGINT))
1254 {
1256 return TRUE;
1257 }
1258 q = n_Div((number)u->Data(),q,coeffs_BIGINT);
1260 res->data = (char *)q;
1261 return FALSE;
1262}
1264{
1265 number q=(number)v->Data();
1266 if (nIsZero(q))
1267 {
1269 return TRUE;
1270 }
1271 q = nDiv((number)u->Data(),q);
1272 nNormalize(q);
1273 res->data = (char *)q;
1274 return FALSE;
1275}
1277{
1278 poly q=(poly)v->Data();
1279 poly p=(poly)(u->Data());
1280 if (q!=NULL)
1281 {
1282 res->data=(void*)(pp_Divide(p /*(poly)(u->Data())*/ ,
1283 q /*(poly)(v->Data())*/ ,currRing));
1284 if (res->data!=NULL) pNormalize((poly)res->data);
1285 return errorreported; /*there may be errors in p_Divide: div. ny 0, etc.*/
1286 }
1287 else
1288 {
1289 WerrorS("div. by 0");
1290 return TRUE;
1291 }
1292
1293}
1295{
1296 poly q=(poly)v->Data();
1297 if (q==NULL)
1298 {
1300 return TRUE;
1301 }
1302 matrix m=(matrix)(u->Data());
1303 int r=m->rows();
1304 int c=m->cols();
1305 matrix mm=mpNew(r,c);
1306 unsigned i,j;
1307 for(i=r;i>0;i--)
1308 {
1309 for(j=c;j>0;j--)
1310 {
1311 if (pNext(q)!=NULL)
1312 {
1314 q /*(poly)(v->Data())*/, currRing );
1315 }
1316 else
1317 MATELEM(mm,i,j) = pp_DivideM(MATELEM(m,i,j),q,currRing);
1318 }
1319 }
1320 res->data=(char *)mm;
1321 return FALSE;
1322}
1324{
1325 res->data = (char *)((long)n_Equal((number)u->Data(),(number)v->Data(),coeffs_BIGINT));
1326 jjEQUAL_REST(res,u,v);
1327 return FALSE;
1328}
1330{
1331 res->data = (char *)((int)((long)u->Data()) == (int)((long)v->Data()));
1332 jjEQUAL_REST(res,u,v);
1333 return FALSE;
1334}
1336{
1337 res->data = (char *)((long)mp_Equal((matrix)u->Data(),(matrix)v->Data(),currRing));
1338 jjEQUAL_REST(res,u,v);
1339 return FALSE;
1340}
1342{
1343 res->data = (char *)((long)sm_Equal((ideal)u->Data(),(ideal)v->Data(),currRing));
1344 jjEQUAL_REST(res,u,v);
1345 return FALSE;
1346}
1348{
1349 res->data = (char *)(long)(u->Data()==v->Data());
1350 jjEQUAL_REST(res,u,v);
1351 return FALSE;
1352}
1354{
1355 res->data = (char *)((long)nEqual((number)u->Data(),(number)v->Data()));
1356 jjEQUAL_REST(res,u,v);
1357 return FALSE;
1358}
1360{
1361 poly p=(poly)u->Data();
1362 poly q=(poly)v->Data();
1363 res->data = (char *) ((long)pEqualPolys(p,q));
1364 jjEQUAL_REST(res,u,v);
1365 return FALSE;
1366}
1368{
1369 if ((res->data) && (u->next!=NULL) && (v->next!=NULL))
1370 {
1371 int save_iiOp=iiOp;
1372 if (iiOp==NOTEQUAL)
1373 iiExprArith2(res,u->next,EQUAL_EQUAL,v->next);
1374 else
1375 iiExprArith2(res,u->next,iiOp,v->next);
1376 iiOp=save_iiOp;
1377 }
1378 if (iiOp==NOTEQUAL) res->data=(char *)(!(long)res->data);
1379}
1381{
1382 res->data = (char *)((long)u->Data() && (long)v->Data());
1383 return FALSE;
1384}
1386{
1387 res->data = (char *)((long)u->Data() || (long)v->Data());
1388 return FALSE;
1389}
1391{
1392 res->rtyp=u->rtyp; u->rtyp=0;
1393 res->data=u->data; u->data=NULL;
1394 res->name=u->name; u->name=NULL;
1395 res->e=u->e; u->e=NULL;
1396 if (res->e==NULL) res->e=jjMakeSub(v);
1397 else
1398 {
1399 Subexpr sh=res->e;
1400 while (sh->next != NULL) sh=sh->next;
1401 sh->next=jjMakeSub(v);
1402 }
1403 if (u->next!=NULL)
1404 {
1406 BOOLEAN bo=iiExprArith2(rn,u->next,iiOp,v);
1407 res->next=rn;
1408 return bo;
1409 }
1410 return FALSE;
1411}
1413{
1414 if ((u->rtyp!=IDHDL)||(u->e!=NULL))
1415 {
1416 WerrorS("indexed object must have a name");
1417 return TRUE;
1418 }
1419 intvec * iv=(intvec *)v->Data();
1420 leftv p=NULL;
1421 int i;
1422 sleftv t;
1423 t.Init();
1424 t.rtyp=INT_CMD;
1425 for (i=0;i<iv->length(); i++)
1426 {
1427 t.data=(char *)((long)(*iv)[i]);
1428 if (p==NULL)
1429 {
1430 p=res;
1431 }
1432 else
1433 {
1434 p->next=(leftv)omAlloc0Bin(sleftv_bin);
1435 p=p->next;
1436 }
1437 p->rtyp=IDHDL;
1438 p->data=u->data;
1439 p->name=u->name;
1440 p->flag=u->flag;
1441 p->e=jjMakeSub(&t);
1442 }
1443 u->rtyp=0;
1444 u->data=NULL;
1445 u->name=NULL;
1446 return FALSE;
1447}
1449{
1450 poly p=(poly)u->Data();
1451 long i=(long)v->Data();
1452 long j=0;
1453 while (p!=NULL)
1454 {
1455 j++;
1456 if (j==i)
1457 {
1458 res->data=(char *)pHead(p);
1459 return FALSE;
1460 }
1461 pIter(p);
1462 }
1463 return FALSE;
1464}
1466{
1469 int l; poly p,pp;
1470 sBucketDestroyAdd(b, &pp, &l);
1471 long i=(long)v->Data();
1472 long j=0;
1473 p=pp;
1474 while (p!=NULL)
1475 {
1476 j++;
1477 if (j==i)
1478 {
1479 res->data=(char *)pHead(p);
1481 return FALSE;
1482 }
1483 pIter(p);
1484 }
1486 return FALSE;
1487}
1489{
1490 poly p=(poly)u->Data();
1491 poly r=NULL;
1492 intvec *iv=(intvec *)v->CopyD(INTVEC_CMD);
1493 int i;
1494 int sum=0;
1495 for(i=iv->length()-1;i>=0;i--)
1496 sum+=(*iv)[i];
1497 int j=0;
1498 while ((p!=NULL) && (sum>0))
1499 {
1500 j++;
1501 for(i=iv->length()-1;i>=0;i--)
1502 {
1503 if (j==(*iv)[i])
1504 {
1505 r=pAdd(r,pHead(p));
1506 sum-=j;
1507 (*iv)[i]=0;
1508 break;
1509 }
1510 }
1511 pIter(p);
1512 }
1513 delete iv;
1514 res->data=(char *)r;
1515 return FALSE;
1516}
1518{
1519 poly p=(poly)u->Data();
1520 int i=(int)(long)v->Data();
1521 res->data=(char *)p_Vec2Poly(p,i,currRing);
1522 return FALSE;
1523}
1525{
1526 poly p=(poly)u->CopyD(VECTOR_CMD);
1527 if (p!=NULL)
1528 {
1529 poly r=pOne();
1530 poly hp=r;
1531 intvec *iv=(intvec *)v->Data();
1532 int i;
1533 loop
1534 {
1535 for(i=0;i<iv->length();i++)
1536 {
1537 if (((int)pGetComp(p))==(*iv)[i])
1538 {
1539 poly h;
1540 pSplit(p,&h);
1541 pNext(hp)=p;
1542 p=h;
1543 pIter(hp);
1544 break;
1545 }
1546 }
1547 if (p==NULL) break;
1548 if (i==iv->length())
1549 {
1550 pLmDelete(&p);
1551 if (p==NULL) break;
1552 }
1553 }
1554 pLmDelete(&r);
1555 res->data=(char *)r;
1556 }
1557 return FALSE;
1558}
1561{
1562 if(u->name==NULL) return TRUE;
1563 long slen = strlen(u->name) + 14;
1564 char *nn = (char*) omAlloc(slen);
1565 snprintf(nn,slen,"%s(%d)",u->name,(int)(long)v->Data());
1566 char *n=omStrDup(nn);
1567 omFreeSize((ADDRESS)nn,slen);
1568 syMake(res,n);
1569 if (u->next!=NULL) return jjKLAMMER_rest(res,u->next,v);
1570 return FALSE;
1571}
1573{
1574 if(u->name==NULL) return TRUE;
1575 intvec * iv=(intvec *)v->Data();
1576 leftv p=NULL;
1577 int i;
1578 long slen = strlen(u->name) + 14;
1579 char *n = (char*) omAlloc(slen);
1580
1581 for (i=0;i<iv->length(); i++)
1582 {
1583 if (p==NULL)
1584 {
1585 p=res;
1586 }
1587 else
1588 {
1589 p->next=(leftv)omAlloc0Bin(sleftv_bin);
1590 p=p->next;
1591 }
1592 snprintf(n,slen,"%s(%d)",u->name,(*iv)[i]);
1593 syMake(p,omStrDup(n));
1594 }
1595 omFreeSize(n, slen);
1596 if (u->next!=NULL) return jjKLAMMER_rest(res,u->next,v);
1597 return FALSE;
1598}
1600{
1602 BOOLEAN b;
1603 if (v->Typ()==INTVEC_CMD)
1604 b=jjKLAMMER_IV(tmp,u,v);
1605 else
1606 b=jjKLAMMER(tmp,u,v);
1607 if (b)
1608 {
1609 omFreeBin(tmp,sleftv_bin);
1610 return TRUE;
1611 }
1612 leftv h=res;
1613 while (h->next!=NULL) h=h->next;
1614 h->next=tmp;
1615 return FALSE;
1616}
1618{
1619 void *d;
1620 Subexpr e;
1621 int typ;
1622 BOOLEAN t=FALSE;
1623 idhdl tmp_proc=NULL;
1624 if ((u->rtyp!=IDHDL)||(u->e!=NULL))
1625 {
1626 tmp_proc=(idhdl)omAlloc0(sizeof(idrec));
1627 tmp_proc->id="_auto";
1628 tmp_proc->typ=PROC_CMD;
1629 tmp_proc->data.pinf=(procinfo *)u->Data();
1630 tmp_proc->ref=1;
1631 d=u->data; u->data=(void *)tmp_proc;
1632 e=u->e; u->e=NULL;
1633 t=TRUE;
1634 typ=u->rtyp; u->rtyp=IDHDL;
1635 }
1636 BOOLEAN sl;
1637 if (u->req_packhdl==currPack)
1638 sl = iiMake_proc((idhdl)u->data,NULL,v);
1639 else
1640 sl = iiMake_proc((idhdl)u->data,u->req_packhdl,v);
1641 if (t)
1642 {
1643 u->rtyp=typ;
1644 u->data=d;
1645 u->e=e;
1646 omFreeSize(tmp_proc,sizeof(idrec));
1647 }
1648 if (sl) return TRUE;
1649 memcpy(res,&iiRETURNEXPR,sizeof(sleftv));
1650 iiRETURNEXPR.Init();
1651 return FALSE;
1652}
1654{
1655 //Print("try to map %s with %s\n",$3.Name(),$1.Name());
1656 if ((v->e==NULL)&&(v->name!=NULL)&&(v->next==NULL))
1657 {
1658 map m=(map)u->Data();
1659 leftv sl=iiMap(m,v->name);
1660 if (sl!=NULL)
1661 {
1662 memcpy(res,sl,sizeof(sleftv));
1664 return FALSE;
1665 }
1666 }
1667 else
1668 {
1669 Werror("%s(<name>) expected",u->Name());
1670 }
1671 return TRUE; /*sl==NULL or Werror*/
1672}
1674{
1675 u->next=(leftv)omAlloc(sizeof(sleftv));
1676 memcpy(u->next,v,sizeof(sleftv));
1677 v->Init();
1678 BOOLEAN bo=iiExprArithM(res,u,'[');
1679 u->next=NULL;
1680 return bo;
1681}
1683{
1684 intvec *c=(intvec*)u->Data();
1685 intvec* p=(intvec*)v->Data();
1686 int rl=p->length();
1687 number *x=(number *)omAlloc(rl*sizeof(number));
1688 number *q=(number *)omAlloc(rl*sizeof(number));
1689 int i;
1690 for(i=rl-1;i>=0;i--)
1691 {
1692 q[i]=n_Init((*p)[i], coeffs_BIGINT);
1693 x[i]=n_Init((*c)[i], coeffs_BIGINT);
1694 }
1695 CFArray iv(rl);
1696 number n=n_ChineseRemainderSym(x,q,rl,FALSE,iv,coeffs_BIGINT);
1697 for(i=rl-1;i>=0;i--)
1698 {
1699 n_Delete(&(q[i]),coeffs_BIGINT);
1701 }
1702 omFree(x); omFree(q);
1703 res->data=(char *)n;
1704 return FALSE;
1705}
1706#if 0
1707static BOOLEAN jjCHINREM_P(leftv res, leftv u, leftv v)
1708{
1709 lists c=(lists)u->CopyD(); // list of poly
1710 intvec* p=(intvec*)v->Data();
1711 int rl=p->length();
1712 poly r=NULL,h, result=NULL;
1713 number *x=(number *)omAlloc(rl*sizeof(number));
1714 number *q=(number *)omAlloc(rl*sizeof(number));
1715 int i;
1716 for(i=rl-1;i>=0;i--)
1717 {
1718 q[i]=nlInit((*p)[i]);
1719 }
1720 loop
1721 {
1722 for(i=rl-1;i>=0;i--)
1723 {
1724 if (c->m[i].Typ()!=POLY_CMD)
1725 {
1726 Werror("poly expected at pos %d",i+1);
1727 for(i=rl-1;i>=0;i--)
1728 {
1729 nlDelete(&(q[i]),currRing);
1730 }
1731 omFree(x); omFree(q); // delete c
1732 return TRUE;
1733 }
1734 h=((poly)c->m[i].Data());
1735 if (r==NULL) r=h;
1736 else if (pLmCmp(r,h)==-1) r=h;
1737 }
1738 if (r==NULL) break;
1739 for(i=rl-1;i>=0;i--)
1740 {
1741 h=((poly)c->m[i].Data());
1742 if (pLmCmp(r,h)==0)
1743 {
1744 x[i]=pGetCoeff(h);
1746 c->m[i].data=(char*)h;
1747 }
1748 else
1749 x[i]=nlInit(0);
1750 }
1751 number n=n_ChineseRemainder(x,q,rl,currRing->cf);
1752 for(i=rl-1;i>=0;i--)
1753 {
1754 nlDelete(&(x[i]),currRing);
1755 }
1756 h=pHead(r);
1757 pSetCoeff(h,n);
1759 }
1760 for(i=rl-1;i>=0;i--)
1761 {
1762 nlDelete(&(q[i]),currRing);
1763 }
1764 omFree(x); omFree(q);
1765 res->data=(char *)result;
1766 return FALSE;
1767}
1768#endif
1770{
1771 poly p=(poly)u->CopyD();
1772 long s=(long)v->Data();
1773 if (s+p_MinComp(p,currRing)<=0)
1774 { p_Delete(&p,currRing);return TRUE;}
1775 p_Shift(&p,s,currRing);
1776 res->data=p;
1777 return FALSE;
1778}
1780{
1781 ideal M=(ideal)u->CopyD();
1782 int s=(int)(long)v->Data();
1783 for(int i=IDELEMS(M)-1; i>=0;i--)
1784 {
1785 if (s+p_MinComp(M->m[i],currRing)<=0)
1786 { id_Delete(&M,currRing);return TRUE;}
1787 }
1789 res->data=M;
1790 return FALSE;
1791}
1794{
1795 poly p=(poly)v->Data();
1796 if ((p==NULL)||(pNext(p)!=NULL)) return TRUE;
1797 res->data=(char *)mp_CoeffProc((poly)u->Data(),p /*(poly)v->Data()*/,currRing);
1798 return FALSE;
1799}
1801{
1802 poly p=(poly)v->Data();
1803 if ((p==NULL)||(pNext(p)!=NULL)) return TRUE;
1804 res->data=(char *)mp_CoeffProcId((ideal)u->Data(),p /*(poly)v->Data()*/,currRing);
1805 return FALSE;
1806}
1808{
1809 int i=pVar((poly)v->Data());
1810 if (i==0)
1811 {
1812 WerrorS("ringvar expected");
1813 return TRUE;
1814 }
1815 res->data=(char *)mp_Coeffs((ideal)u->CopyD(),i,currRing);
1816 return FALSE;
1817}
1819{
1820 poly p = pInit();
1821 int i;
1822 for (i=1; i<=currRing->N; i++)
1823 {
1824 pSetExp(p, i, 1);
1825 }
1826 pSetm(p);
1827 res->data = (void*)idCoeffOfKBase((ideal)(u->Data()),
1828 (ideal)(v->Data()), p);
1829 pLmFree(&p);
1830 return FALSE;
1831}
1833{
1834 res->data=(char *)idDiffOp((ideal)u->Data(),(ideal)v->Data(),FALSE);
1835 return FALSE;
1836}
1838{
1839 int *iv=iv2array((intvec *)v->Data(),currRing);
1840 ideal I=(ideal)u->Data();
1841 int d=-1;
1842 int i;
1843 for(i=IDELEMS(I);i>=0;i--) d=si_max(d,(int)p_DegW(I->m[i],iv,currRing));
1844 omFreeSize( (ADDRESS)iv, (rVar(currRing)+1)*sizeof(int) );
1845 res->data = (char *)((long)d);
1846 return FALSE;
1847}
1849{
1850 poly p=(poly)u->Data();
1851 if (p!=NULL)
1852 {
1853 int *iv=iv2array((intvec *)v->Data(),currRing);
1854 const long d = p_DegW(p,iv,currRing);
1855 omFreeSize( (ADDRESS)iv, (rVar(currRing)+1)*sizeof(int) );
1856 res->data = (char *)(d);
1857 }
1858 else
1859 res->data=(char *)(long)(-1);
1860 return FALSE;
1861}
1863{
1864 int pos=(int)(long)v->Data();
1865 intvec *iv=(intvec*)u->Data();
1866 res->data=(void*)iv->delete_pos(pos-1);
1867 return res->data==NULL;
1868}
1870{
1871 int pos=(int)(long)v->Data();
1872 ideal I=(ideal)u->Data();
1873 res->data=(void*)id_Delete_Pos(I,pos-1,currRing);
1874 return res->data==NULL;
1875}
1877{
1878 intvec *iv=(intvec*)v->Data();
1879 ideal I=(ideal)u->Data();
1880 ideal tmp1=NULL;
1881 ideal tmp2;
1882 for(int i=iv->length()-1;i>=0;i--)
1883 {
1884 int pos= (*iv)[i];
1885 tmp2=id_Delete_Pos(I,pos-1,currRing);
1886 if (tmp1==NULL) /* first entry */
1887 { tmp1=I; }
1888 else
1889 { id_Delete(&I,currRing); }
1890 I=tmp2;
1891 if (I==NULL) break;
1892 }
1893 res->data=(void*)I;
1894 return res->data==NULL;
1895}
1897{
1898 matrix m=(matrix)u->Data();
1899 DetVariant d=mp_GetAlgorithmDet((char*)v->Data());
1900 res ->data = mp_Det(m,currRing,d);
1901 return FALSE;
1902}
1904{
1905 DetVariant d=mp_GetAlgorithmDet((char*)v->Data());
1906 ideal m=(ideal)u->Data();
1907 res ->data = sm_Det(m,currRing,d);
1908 return FALSE;
1909}
1911{
1912 int i=pVar((poly)v->Data());
1913 if (i==0)
1914 {
1915 WerrorS("ringvar expected");
1916 return TRUE;
1917 }
1918 res->data=(char *)pDiff((poly)(u->Data()),i);
1919 return FALSE;
1920}
1922{
1923 int i=pVar((poly)v->Data());
1924 if (i==0)
1925 {
1926 WerrorS("ringvar expected");
1927 return TRUE;
1928 }
1929 res->data=(char *)idDiff((matrix)(u->Data()),i);
1930 return FALSE;
1931}
1933{
1934 res->data=(char *)idDiffOp((ideal)u->Data(),(ideal)v->Data());
1935 return FALSE;
1936}
1938{
1941 {
1942 Warn("dim(%s,...) may be wrong because the mixed monomial ordering",v->Name());
1943 }
1944 if(currRing->qideal==NULL)
1945 res->data = (char *)((long)scDimIntRing((ideal)(v->Data()),(ideal)w->Data()));
1946 else
1947 {
1948 ideal q=idSimpleAdd(currRing->qideal,(ideal)w->Data());
1949 res->data = (char *)((long)scDimIntRing((ideal)(v->Data()),q));
1950 idDelete(&q);
1951 }
1952 return FALSE;
1953}
1955{
1956 ideal vi=(ideal)v->Data();
1957 int vl= IDELEMS(vi);
1958 ideal ui=(ideal)u->Data();
1959 unsigned ul= IDELEMS(ui);
1960 ideal R; matrix U;
1961 ideal m = idLift(vi,ui,&R, FALSE,hasFlag(v,FLAG_STD),TRUE,&U);
1962 if (m==NULL) return TRUE;
1963 // now make sure that all matrices have the correct size:
1965 assume (MATCOLS(U) == (int)ul);
1967 L->Init(3);
1968 L->m[0].rtyp=MATRIX_CMD; L->m[0].data=(void *)T;
1969 L->m[1].rtyp=u->Typ(); L->m[1].data=(void *)R;
1970 L->m[2].rtyp=MATRIX_CMD; L->m[2].data=(void *)U;
1971 res->data=(char *)L;
1972 return FALSE;
1973}
1975{
1976 res->data=(char *)idElimination((ideal)u->Data(),(poly)v->Data());
1977 //setFlag(res,FLAG_STD);
1978 return v->next!=NULL; //do not allow next like in eliminate(I,a(1..4))
1979}
1981{
1982 poly p=pOne();
1983 intvec *iv=(intvec*)v->Data();
1984 for(int i=iv->length()-1; i>=0; i--)
1985 {
1986 pSetExp(p,(*iv)[i],1);
1987 }
1988 pSetm(p);
1989 res->data=(char *)idElimination((ideal)u->Data(),p);
1990 pLmDelete(&p);
1991 //setFlag(res,FLAG_STD);
1992 return FALSE;
1993}
1995{
1996 //Print("exportto %s -> %s\n",v->Name(),u->Name() );
1997 return iiExport(v,0,IDPACKAGE((idhdl)u->data));
1998}
2000{
2001 WerrorS((char *)u->Data());
2002 EXTERN_VAR int inerror;
2003 inerror=3;
2004 return TRUE;
2005}
2007{
2008 number uu=(number)u->Data();number vv=(number)v->Data();
2010 number a,b;
2011 number p0=n_ExtGcd(uu,vv,&a,&b,coeffs_BIGINT);
2012 L->Init(3);
2013 L->m[0].rtyp=BIGINT_CMD; L->m[0].data=(void *)p0;
2014 L->m[1].rtyp=BIGINT_CMD; L->m[1].data=(void *)a;
2015 L->m[2].rtyp=BIGINT_CMD; L->m[2].data=(void *)b;
2016 res->rtyp=LIST_CMD;
2017 res->data=(char *)L;
2018 return FALSE;
2019}
2021{
2022 int uu=(int)(long)u->Data();int vv=(int)(long)v->Data();
2023 int p0=ABS(uu),p1=ABS(vv);
2024 int f0 = 1, f1 = 0, g0 = 0, g1 = 1, q, r;
2025
2026 while ( p1!=0 )
2027 {
2028 q=p0 / p1;
2029 r=p0 % p1;
2030 p0 = p1; p1 = r;
2031 r = g0 - g1 * q;
2032 g0 = g1; g1 = r;
2033 r = f0 - f1 * q;
2034 f0 = f1; f1 = r;
2035 }
2036 int a = f0;
2037 int b = g0;
2038 if ( uu /*(int)(long)u->Data()*/ < 0 ) a=-a;
2039 if ( vv /*(int)(long)v->Data()*/ < 0 ) b=-b;
2041 L->Init(3);
2042 L->m[0].rtyp=INT_CMD; L->m[0].data=(void *)(long)p0;
2043 L->m[1].rtyp=INT_CMD; L->m[1].data=(void *)(long)a;
2044 L->m[2].rtyp=INT_CMD; L->m[2].data=(void *)(long)b;
2045 res->data=(char *)L;
2046 return FALSE;
2047}
2049{
2050 poly r,pa,pb;
2051 BOOLEAN ret=singclap_extgcd((poly)u->Data(),(poly)v->Data(),r,pa,pb,currRing);
2052 if (ret) return TRUE;
2054 L->Init(3);
2055 res->data=(char *)L;
2056 L->m[0].data=(void *)r;
2057 L->m[0].rtyp=POLY_CMD;
2058 L->m[1].data=(void *)pa;
2059 L->m[1].rtyp=POLY_CMD;
2060 L->m[2].data=(void *)pb;
2061 L->m[2].rtyp=POLY_CMD;
2062 return FALSE;
2063}
2066{
2067 intvec *v=NULL;
2068 int sw=(int)(long)dummy->Data();
2069 int fac_sw=sw;
2070 if ((sw<0)||(sw>2)) fac_sw=1;
2072 ideal f=singclap_factorize((poly)(u->CopyD()), &v, fac_sw,currRing);
2073 if (f==NULL)
2074 return TRUE;
2075 switch(sw)
2076 {
2077 case 0:
2078 case 2:
2079 {
2081 l->Init(2);
2082 l->m[0].rtyp=IDEAL_CMD;
2083 l->m[0].data=(void *)f;
2084 l->m[1].rtyp=INTVEC_CMD;
2085 l->m[1].data=(void *)v;
2086 res->data=(void *)l;
2087 res->rtyp=LIST_CMD;
2088 return FALSE;
2089 }
2090 case 1:
2091 res->data=(void *)f;
2092 return FALSE;
2093 case 3:
2094 {
2095 poly p=f->m[0];
2096 int i=IDELEMS(f);
2097 f->m[0]=NULL;
2098 while(i>1)
2099 {
2100 i--;
2101 p=pMult(p,f->m[i]);
2102 f->m[i]=NULL;
2103 }
2104 res->data=(void *)p;
2105 res->rtyp=POLY_CMD;
2106 }
2107 return FALSE;
2108 }
2109 WerrorS("invalid switch");
2110 return TRUE;
2111}
2113{
2114 ideal_list p,h;
2115 h=kStdfac((ideal)v->Data(),NULL,testHomog,NULL,(ideal)w->Data());
2116 p=h;
2117 int l=0;
2118 while (p!=NULL) { p=p->next;l++; }
2120 L->Init(l);
2121 l=0;
2122 while(h!=NULL)
2123 {
2124 L->m[l].data=(char *)h->d;
2125 L->m[l].rtyp=IDEAL_CMD;
2126 p=h->next;
2127 omFreeSize(h,sizeof(*h));
2128 h=p;
2129 l++;
2130 }
2131 res->data=(void *)L;
2132 return FALSE;
2133}
2135{
2136 if (rField_is_Q(currRing))
2137 {
2138 number uu=(number)u->Data();
2139 number vv=(number)v->Data();
2140 res->data=(char *)n_Farey(uu,vv,currRing->cf);
2141 return FALSE;
2142 }
2143 else return TRUE;
2144}
2146{
2147 ideal uu=(ideal)u->Data();
2148 number vv=(number)v->Data();
2149 //timespec buf1,buf2;
2150 //clock_gettime(CLOCK_THREAD_CPUTIME_ID,&buf1);
2151 #ifdef HAVE_VSPACE
2152 int cpus = (long) feOptValue(FE_OPT_CPUS);
2153 if ((cpus>1) && (rField_is_Q(currRing)))
2154 res->data=(void*)id_Farey_0(uu,vv,currRing);
2155 else
2156 #endif
2157 res->data=(void*)id_Farey(uu,vv,currRing);
2158 //clock_gettime(CLOCK_THREAD_CPUTIME_ID,&buf2);
2159 //const unsigned long SEC = 1000L*1000L*1000L;
2160 //all_farey+=((buf2.tv_sec-buf1.tv_sec)*SEC+
2161 // buf2.tv_nsec-buf1.tv_nsec);
2162 //farey_cnt++;
2163 return FALSE;
2164}
2165static BOOLEAN jjFAREY_LI(leftv res, leftv u, leftv v);
2167{
2168 ring r=(ring)u->Data();
2169 idhdl w;
2170 int op=iiOp;
2171 nMapFunc nMap;
2172
2173 if ((w=r->idroot->get(v->Name(),myynest))!=NULL)
2174 {
2175 int *perm=NULL;
2176 int *par_perm=NULL;
2177 int par_perm_size=0;
2178 BOOLEAN bo;
2179 nMap=n_SetMap(r->cf,currRing->cf);
2180 if (nMap==NULL)
2181 {
2182 // Allow imap/fetch to be make an exception only for:
2183 if (nCoeff_is_Extension(r->cf) && // Q(a..) -> Q(a..) || Q || Zp || Zp(a)
2184 ((n_SetMap(r->cf->extRing->cf,currRing->cf)!=NULL)
2185 || (nCoeff_is_Extension(currRing->cf) && (n_SetMap(r->cf->extRing->cf,currRing->cf->extRing->cf)!=NULL))))
2186 {
2187 par_perm_size=rPar(r);
2188 }
2189 else
2190 {
2191 goto err_fetch;
2192 }
2193 }
2194 if (
2195 (iiOp!=FETCH_CMD) || (r->N!=currRing->N) || (rPar(r)!=rPar(currRing))
2196#ifdef HAVE_SHIFTBBA
2198#endif
2199 )
2200 {
2201 perm=(int *)omAlloc0((r->N+1)*sizeof(int));
2202 if (par_perm_size!=0)
2203 par_perm=(int *)omAlloc0(par_perm_size*sizeof(int));
2204 op=IMAP_CMD;
2205 if (iiOp==IMAP_CMD)
2206 {
2207 int r_par=0;
2208 char ** r_par_names=NULL;
2209 if (r->cf->extRing!=NULL)
2210 {
2211 r_par=r->cf->extRing->N;
2212 r_par_names=r->cf->extRing->names;
2213 }
2214 int c_par=0;
2215 char ** c_par_names=NULL;
2216 if (currRing->cf->extRing!=NULL)
2217 {
2218 c_par=currRing->cf->extRing->N;
2219 c_par_names=currRing->cf->extRing->names;
2220 }
2221 if (!rIsLPRing(r))
2222 {
2223 maFindPerm(r->names, r->N, r_par_names, r_par,
2224 currRing->names,currRing->N,c_par_names, c_par,
2225 perm,par_perm, currRing->cf->type);
2226 }
2227 #ifdef HAVE_SHIFTBBA
2228 else
2229 {
2230 maFindPermLP(r->names, r->N, r_par_names, r_par,
2231 currRing->names,currRing->N,c_par_names, c_par,
2232 perm,par_perm, currRing->cf->type,r->isLPring);
2233 }
2234 #endif
2235 }
2236 else
2237 {
2238#ifdef HAVE_SHIFTBBA
2239 if (rIsLPRing(currRing))
2240 {
2241 maFetchPermLP(r, currRing, perm);
2242 }
2243 else
2244#endif
2245 {
2246 unsigned i;
2247 if (par_perm_size!=0)
2248 for(i=si_min(rPar(r),rPar(currRing));i>0;i--) par_perm[i-1]=-i;
2249 for(i=si_min(r->N,currRing->N);i>0;i--) perm[i]=i;
2250 }
2251 }
2252 }
2253 if ((iiOp==FETCH_CMD) && (BVERBOSE(V_IMAP)))
2254 {
2255 unsigned i;
2256 for(i=0;i<(unsigned)si_min(r->N,currRing->N);i++)
2257 {
2258 Print("// var nr %d: %s -> %s\n",i,r->names[i],currRing->names[i]);
2259 }
2260 for(i=0;i<(unsigned)si_min(rPar(r),rPar(currRing));i++) // possibly empty loop
2261 {
2262 Print("// par nr %d: %s -> %s\n",
2264 }
2265 }
2266 if (IDTYP(w)==ALIAS_CMD) w=(idhdl)IDDATA(w);
2267 sleftv tmpW;
2268 tmpW.Init();
2269 tmpW.rtyp=IDTYP(w);
2270 tmpW.data=IDDATA(w);
2271 if ((bo=maApplyFetch(op,NULL,res,&tmpW, r,
2272 perm,par_perm,par_perm_size,nMap)))
2273 {
2274 Werror("cannot map %s of type %s(%d)",v->name, Tok2Cmdname(w->typ),w->typ);
2275 }
2276 if (perm!=NULL)
2277 omFreeSize((ADDRESS)perm,(r->N+1)*sizeof(int));
2278 if (par_perm!=NULL)
2279 omFreeSize((ADDRESS)par_perm,par_perm_size*sizeof(int));
2280 return bo;
2281 }
2282 else
2283 {
2284 Werror("identifier %s not found in %s",v->Fullname(),u->Fullname());
2285 }
2286 return TRUE;
2287err_fetch:
2288 char *s1=nCoeffString(r->cf);
2289 char *s2=nCoeffString(currRing->cf);
2290 Werror("no identity map from %s (%s -> %s)",u->Fullname(),s1,s2);
2291 omFree(s2); omFree(s1);
2292 return TRUE;
2293}
2295{
2296 /*4
2297 * look for the substring what in the string where
2298 * return the position of the first char of what in where
2299 * or 0
2300 */
2301 char *where=(char *)u->Data();
2302 char *what=(char *)v->Data();
2303 char *found = strstr(where,what);
2304 if (found != NULL)
2305 {
2306 res->data=(char *)((found-where)+1);
2307 }
2308 /*else res->data=NULL;*/
2309 return FALSE;
2310}
2311
2313{
2314 assumeStdFlag(u);
2315 ideal id = (ideal)u->Data();
2316 int max_length = (int)(long)v->Data();
2317 if (max_length < 0)
2318 {
2319 WerrorS("length for fres must not be negative");
2320 return TRUE;
2321 }
2322 if (max_length == 0)
2323 {
2324 max_length = currRing->N+4;
2325 if (currRing->qideal != NULL)
2326 {
2327 max_length = currRing->N+1;
2328 Warn("full resolution in a qring may be infinite, "
2329 "setting max length to %d", max_length);
2330 }
2331 }
2332 char *method = (char *)w->Data();
2333 /* For the moment, only "complete" (default), "frame", or "extended frame"
2334 * are allowed. Another useful option would be "linear strand".
2335 */
2336 if (strcmp(method, "complete") != 0
2337 && strcmp(method, "frame") != 0
2338 && strcmp(method, "extended frame") != 0
2339 && strcmp(method, "single module") != 0)
2340 {
2341 WerrorS("wrong optional argument for fres");
2342 return TRUE;
2343 }
2344 syStrategy r = syFrank(id, max_length, method);
2345 assume(r->fullres != NULL);
2346 syFix(r);
2347 res->data = (void *)r;
2348 return FALSE;
2349}
2350
2352{
2354 w->rtyp = STRING_CMD;
2355 w->data = (char *)"complete"; // default
2356 BOOLEAN RES = jjFRES3(res, u, v, w);
2358 return RES;
2359}
2360
2362{
2363 res->data=(char *)fractalWalkProc(u,v);
2364 setFlag( res, FLAG_STD );
2365 return FALSE;
2366}
2368{
2369 int uu=(int)(long)u->Data();int vv=(int)(long)v->Data();
2370 int p0=ABS(uu),p1=ABS(vv);
2371 int r;
2372 while ( p1!=0 )
2373 {
2374 r=p0 % p1;
2375 p0 = p1; p1 = r;
2376 }
2377 res->data=(char *)(long)p0;
2378 return FALSE;
2379}
2381{
2382 number n1 = (number) u->Data();
2383 number n2 = (number) v->Data();
2384 res->data = n_Gcd(n1,n2,coeffs_BIGINT);
2385 return FALSE;
2386}
2388{
2389 number a=(number) u->Data();
2390 number b=(number) v->Data();
2391 if (nIsZero(a))
2392 {
2393 if (nIsZero(b)) res->data=(char *)nInit(1);
2394 else res->data=(char *)nCopy(b);
2395 }
2396 else
2397 {
2398 if (nIsZero(b)) res->data=(char *)nCopy(a);
2399 //else res->data=(char *)n_Gcd(a, b, currRing->cf);
2400 else res->data=(char *)n_SubringGcd(a, b, currRing->cf);
2401 }
2402 return FALSE;
2403}
2405{
2406 res->data=(void *)singclap_gcd((poly)(u->CopyD(POLY_CMD)),
2407 (poly)(v->CopyD(POLY_CMD)),currRing);
2408 return FALSE;
2409}
2411{
2412 if (rField_is_Z(currRing))
2413 {
2414 PrintS("// NOTE: computation of Hilbert series etc. is being\n");
2415 PrintS("// performed for generic fibre, that is, over Q\n");
2416 }
2417 assumeStdFlag(u);
2418 intvec *module_w=(intvec*)atGet(u,"isHomog",INTVEC_CMD);
2419#if 1
2420 switch((int)(long)v->Data())
2421 {
2422 case 1:
2423 res->data=(void *)hFirstSeries0b((ideal)u->Data(),currRing->qideal,NULL,module_w,currRing,coeffs_BIGINT);
2424 return FALSE;
2425 case 2:
2426 res->data=(void *)hSecondSeries0b((ideal)u->Data(),currRing->qideal,NULL,module_w,currRing,coeffs_BIGINT);
2427 return FALSE;
2428 }
2429#else
2430 intvec *iv=hFirstSeries((ideal)u->Data(),module_w,currRing->qideal);
2431 if (errorreported) return TRUE;
2432
2433 switch((int)(long)v->Data())
2434 {
2435 case 1:
2436 res->data=(void *)iv;
2437 return FALSE;
2438 case 2:
2439 res->data=(void *)hSecondSeries(iv);
2440 delete iv;
2441 return FALSE;
2442 }
2443 delete iv;
2444#endif
2446 return TRUE;
2447}
2449{
2450 int i=pVar((poly)v->Data());
2451 if (i==0)
2452 {
2453 WerrorS("ringvar expected");
2454 return TRUE;
2455 }
2456 poly p=pOne(); pSetExp(p,i,1); pSetm(p);
2457 int d=pWTotaldegree(p);
2458 pLmDelete(p);
2459 if (d==1)
2460 res->data = (char *)p_Homogen((poly)u->Data(), i, currRing);
2461 else
2462 WerrorS("variable must have weight 1");
2463 return (d!=1);
2464}
2466{
2467 int i=pVar((poly)v->Data());
2468 if (i==0)
2469 {
2470 WerrorS("ringvar expected");
2471 return TRUE;
2472 }
2473 pFDegProc deg;
2474 if (currRing->pLexOrder && (currRing->order[0]==ringorder_lp))
2475 deg=p_Totaldegree;
2476 else
2477 deg=currRing->pFDeg;
2478 poly p=pOne(); pSetExp(p,i,1); pSetm(p);
2479 int d=deg(p,currRing);
2480 pLmDelete(p);
2481 if (d==1)
2482 res->data = (char *)id_Homogen((ideal)u->Data(), i, currRing);
2483 else
2484 WerrorS("variable must have weight 1");
2485 return (d!=1);
2486}
2488{
2489 intvec *w=new intvec(rVar(currRing));
2490 intvec *vw=(intvec*)u->Data();
2491 ideal v_id=(ideal)v->Data();
2492 pFDegProc save_FDeg=currRing->pFDeg;
2493 pLDegProc save_LDeg=currRing->pLDeg;
2494 BOOLEAN save_pLexOrder=currRing->pLexOrder;
2495 currRing->pLexOrder=FALSE;
2496 kHomW=vw;
2497 kModW=w;
2499 res->data=(void *)(long)idHomModule(v_id,currRing->qideal,&w);
2500 currRing->pLexOrder=save_pLexOrder;
2501 kHomW=NULL;
2502 kModW=NULL;
2503 pRestoreDegProcs(currRing,save_FDeg,save_LDeg);
2504 if (w!=NULL) delete w;
2505 return FALSE;
2506}
2508{
2509 intvec *vw=(intvec*)u->Data();
2510 ideal v_id=(ideal)v->Data();
2511 res->data=(void *)(long)id_HomIdealW(v_id,currRing->qideal,vw,currRing);
2512 return FALSE;
2513}
2515{
2516 assumeStdFlag(u);
2517 res->data=(void *)scIndIndset((ideal)(u->Data()),(int)(long)(v->Data()),
2518 currRing->qideal);
2519 return FALSE;
2520}
2522{
2523 res->data=(char *)idSect((ideal)u->Data(),(ideal)v->Data());
2525 return FALSE;
2526}
2528{
2529 const lists L = (lists)l->Data();
2530 const int n = L->nr; assume (n >= 0);
2531 std::vector<ideal> V(n + 1);
2532
2533 for(int i = n; i >= 0; i--) V[i] = (ideal)(L->m[i].Data());
2534
2535 res->data=interpolation(V, (intvec*)v->Data());
2537 return errorreported;
2538}
2540{
2541 extern BOOLEAN jjStdJanetBasis(leftv res, leftv v,int flag);
2542 return jjStdJanetBasis(res,u,(int)(long)v->Data());
2543}
2544
2546{
2547 extern BOOLEAN jjStdJanetBasis(leftv res, leftv v,int flag);
2548 return jjStdJanetBasis(res,v,0);
2549}
2551{
2552 res->data = (char *)pJet((poly)u->CopyD(), (int)(long)v->Data());
2553 return FALSE;
2554}
2556{
2557 res->data = (char *)id_Jet((ideal)u->Data(),(int)(long)v->Data(),currRing);
2558 return FALSE;
2559}
2561{
2562 assumeStdFlag(u);
2563 intvec *w_u=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
2564 res->data = (char *)scKBase((int)(long)v->Data(),
2565 (ideal)(u->Data()),currRing->qideal, w_u);
2566 if (w_u!=NULL)
2567 {
2568 atSet(res,omStrDup("isHomog"),ivCopy(w_u),INTVEC_CMD);
2569 }
2570 return FALSE;
2571}
2574{
2575 return jjPREIMAGE(res,u,v,NULL);
2576}
2578{
2579 return mpKoszul(res, u,v,NULL);
2580}
2582{
2583 sleftv h;
2584 h.Init();
2585 h.rtyp=INT_CMD;
2586 h.data=(void *)(long)IDELEMS((ideal)v->Data());
2587 return mpKoszul(res, u, &h, v);
2588}
2590{
2591 int ul= IDELEMS((ideal)u->Data());
2592 int vl= IDELEMS((ideal)v->Data());
2593#ifdef HAVE_SHIFTBBA
2594 if (rIsLPRing(currRing))
2595 {
2596 if (currRing->LPncGenCount < ul)
2597 {
2598 Werror("At least %d ncgen variables are needed for this computation.", ul);
2599 return TRUE;
2600 }
2601 }
2602#endif
2603 ideal m = idLift((ideal)u->Data(),(ideal)v->Data(),NULL,FALSE,
2604 hasFlag(u,FLAG_STD));
2605 if ((m==NULL)||(errorreported)) return TRUE;
2606 res->data = (char *)id_Module2formatedMatrix(m,ul,vl,currRing);
2607 return FALSE;
2608}
2610{
2611 if ((v->rtyp!=IDHDL)||(v->e!=NULL)) return TRUE;
2612 idhdl h=(idhdl)v->data;
2613#ifdef HAVE_SHIFTBBA
2614 if (rIsLPRing(currRing))
2615 {
2616 if (currRing->LPncGenCount < IDELEMS((ideal)u->Data()))
2617 {
2618 Werror("At least %d ncgen variables are needed for this computation.", IDELEMS((ideal)u->Data()));
2619 return TRUE;
2620 }
2621 }
2622#endif
2623 // CopyD for IDEAL_CMD and MODUL_CMD are identical:
2624 res->data = (char *)idLiftStd((ideal)u->Data(),
2625 &(h->data.umatrix),testHomog);
2626 setFlag(res,FLAG_STD); v->flag=0;
2627 return FALSE;
2628}
2629static BOOLEAN jjLOAD2(leftv /*res*/, leftv/* LIB */ , leftv v)
2630{
2631 return jjLOAD((char*)v->Data(),TRUE);
2632}
2633static BOOLEAN jjLOAD_E(leftv /*res*/, leftv v, leftv u)
2634{
2635 char * s=(char *)u->Data();
2636 if(strcmp(s, "with")==0)
2637 return jjLOAD((char*)v->Data(), TRUE);
2638 if (strcmp(s,"try")==0)
2639 return jjLOAD_TRY((char*)v->Data());
2640 WerrorS("invalid second argument");
2641 WerrorS("load(\"libname\" [,option]);");
2642 return TRUE;
2643}
2645{
2646 intvec *w_u=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
2647 tHomog hom=testHomog;
2648 if (w_u!=NULL)
2649 {
2650 //PrintS("modulo: wu:");w_u->show(INTVEC_CMD);PrintLn();
2651 w_u=ivCopy(w_u);
2652 hom=isHomog;
2653 }
2654 //else PrintS("modulo: wu:none\n");
2655 intvec *w_v=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
2656 if (w_v!=NULL)
2657 {
2658 //PrintS("modulo: wv:");w_v->show(INTVEC_CMD);PrintLn();
2659 w_v=ivCopy(w_v);
2660 hom=isHomog;
2661 }
2662 //else PrintS("modulo: wv:none\n");
2663 if ((w_u!=NULL) && (w_v==NULL))
2664 w_v=ivCopy(w_u);
2665 if ((w_v!=NULL) && (w_u==NULL))
2666 w_u=ivCopy(w_v);
2667 ideal u_id=(ideal)u->Data();
2668 ideal v_id=(ideal)v->Data();
2669 if (w_u!=NULL)
2670 {
2671 if ((*w_u).compare((w_v))!=0)
2672 {
2673 WarnS("incompatible weights");
2674 delete w_u; w_u=NULL;
2675 hom=testHomog;
2676 }
2677 else
2678 {
2679 if ((!idTestHomModule(u_id,currRing->qideal,w_v))
2680 || (!idTestHomModule(v_id,currRing->qideal,w_v)))
2681 {
2682 WarnS("wrong weights");
2683 delete w_u; w_u=NULL;
2684 hom=testHomog;
2685 }
2686 }
2687 }
2688 res->data = (char *)idModulo(u_id,v_id ,hom,&w_u);
2689 if (w_u!=NULL)
2690 {
2691 atSet(res,omStrDup("isHomog"),w_u,INTVEC_CMD);
2692 }
2693 delete w_v;
2694 //if (TEST_OPT_RETURN_SB) setFlag(res,FLAG_STD);
2695 return FALSE;
2696}
2698{
2699 number q=(number)v->Data();
2700 if (n_IsZero(q,coeffs_BIGINT))
2701 {
2703 return TRUE;
2704 }
2705 res->data =(char *) n_IntMod((number)u->Data(),q,coeffs_BIGINT);
2706 return FALSE;
2707}
2709{
2710 number q=(number)v->Data();
2711 if (nIsZero(q))
2712 {
2714 return TRUE;
2715 }
2716 res->data =(char *) n_IntMod((number)u->Data(),q,currRing->cf);
2717 return FALSE;
2718}
2720{
2721 poly q=(poly)v->Data();
2722 if (q==NULL)
2723 {
2725 return TRUE;
2726 }
2727 poly p=(poly)(u->Data());
2728 if (p==NULL)
2729 {
2730 res->data=NULL;
2731 return FALSE;
2732 }
2733 res->data=(void*)(singclap_pmod(p /*(poly)(u->Data())*/ ,
2734 q /*(poly)(v->Data())*/ ,currRing));
2735 return FALSE;
2736}
2739{
2740 return jjMONITOR2(res,v,NULL);
2741}
2743{
2744#if 0
2745 char *opt=(char *)v->Data();
2746 int mode=0;
2747 while(*opt!='\0')
2748 {
2749 if (*opt=='i') mode |= SI_PROT_I;
2750 else if (*opt=='o') mode |= SI_PROT_O;
2751 opt++;
2752 }
2753 monitor((char *)(u->Data()),mode);
2754#else
2755 si_link l=(si_link)u->Data();
2756 if (slOpen(l,SI_LINK_WRITE,u)) return TRUE;
2757 if(strcmp(l->m->type,"ASCII")!=0)
2758 {
2759 Werror("ASCII link required, not `%s`",l->m->type);
2760 slClose(l);
2761 return TRUE;
2762 }
2763 SI_LINK_SET_CLOSE_P(l); // febase handles the FILE*
2764 if ( l->name[0]!='\0') // "" is the stop condition
2765 {
2766 const char *opt;
2767 int mode=0;
2768 if (v==NULL) opt=(const char*)"i";
2769 else opt=(const char *)v->Data();
2770 while(*opt!='\0')
2771 {
2772 if (*opt=='i') mode |= SI_PROT_I;
2773 else if (*opt=='o') mode |= SI_PROT_O;
2774 opt++;
2775 }
2776 monitor((FILE *)l->data,mode);
2777 }
2778 else
2779 monitor(NULL,0);
2780 return FALSE;
2781#endif
2782}
2784{
2785 intvec *iv=(intvec *)v->Data();
2786 poly p=pOne();
2787 int e;
2788 BOOLEAN err=FALSE;
2789 for(unsigned i=si_min(currRing->N,iv->length()); i>0; i--)
2790 {
2791 e=(*iv)[i-1];
2792 if (e>=0) pSetExp(p,i,e);
2793 else err=TRUE;
2794 }
2795 if (iv->length()==(currRing->N+1))
2796 {
2797 res->rtyp=VECTOR_CMD;
2798 e=(*iv)[currRing->N];
2799 if (e>=0) pSetComp(p,e);
2800 else err=TRUE;
2801 }
2802 pSetm(p);
2803 res->data=(char*)p;
2804 if(err) { pDelete(&p); WerrorS("no negative exponent allowed"); }
2805 return err;
2806}
2808{
2809 // u: the name of the new type
2810 // v: the elements
2811 const char *s=(const char *)u->Data();
2812 newstruct_desc d=NULL;
2813 if (strlen(s)>=2)
2814 {
2815 d=newstructFromString((const char *)v->Data());
2816 if (d!=NULL) newstruct_setup(s,d);
2817 }
2818 else WerrorS("name of newstruct must be longer than 1 character");
2819 return d==NULL;
2820}
2822{
2823 idhdl h=(idhdl)u->data;
2824 int i=(int)(long)v->Data();
2825 int p=0;
2826 if ((0<i)
2827 && (rParameter(IDRING(h))!=NULL)
2828 && (i<=(p=rPar(IDRING(h)))))
2829 res->data=omStrDup(rParameter(IDRING(h))[i-1]);
2830 else
2831 {
2832 Werror("par number %d out of range 1..%d",i,p);
2833 return TRUE;
2834 }
2835 return FALSE;
2836}
2837#ifdef HAVE_PLURAL
2839{
2840 if( currRing->qideal != NULL )
2841 {
2842 WerrorS("basering must NOT be a qring!");
2843 return TRUE;
2844 }
2845
2846 if (iiOp==NCALGEBRA_CMD)
2847 {
2848 return nc_CallPlural(NULL,NULL,(poly)a->Data(),(poly)b->Data(),currRing,false,true,false,currRing);
2849 }
2850 else
2851 {
2852 ring r=rCopy(currRing);
2853 BOOLEAN result=nc_CallPlural(NULL,NULL,(poly)a->Data(),(poly)b->Data(),r,false,true,false,currRing);
2854 res->data=r;
2855 return result;
2856 }
2857}
2859{
2860 if( currRing->qideal != NULL )
2861 {
2862 WerrorS("basering must NOT be a qring!");
2863 return TRUE;
2864 }
2865
2866 if (iiOp==NCALGEBRA_CMD)
2867 {
2868 return nc_CallPlural(NULL,(matrix)b->Data(),(poly)a->Data(),NULL,currRing,false,true,false,currRing);
2869 }
2870 else
2871 {
2872 ring r=rCopy(currRing);
2873 BOOLEAN result=nc_CallPlural(NULL,(matrix)b->Data(),(poly)a->Data(),NULL,r,false,true,false,currRing);
2874 res->data=r;
2875 return result;
2876 }
2877}
2879{
2880 if( currRing->qideal != NULL )
2881 {
2882 WerrorS("basering must NOT be a qring!");
2883 return TRUE;
2884 }
2885
2886 if (iiOp==NCALGEBRA_CMD)
2887 {
2888 return nc_CallPlural((matrix)a->Data(),NULL,NULL,(poly)b->Data(),currRing,false,true,false,currRing);
2889 }
2890 else
2891 {
2892 ring r=rCopy(currRing);
2893 BOOLEAN result=nc_CallPlural((matrix)a->Data(),NULL,NULL,(poly)b->Data(),r,false,true,false,currRing);
2894 res->data=r;
2895 return result;
2896 }
2897}
2899{
2900 if( currRing->qideal != NULL )
2901 {
2902 WerrorS("basering must NOT be a qring!");
2903 return TRUE;
2904 }
2905
2906 if (iiOp==NCALGEBRA_CMD)
2907 {
2908 return nc_CallPlural((matrix)a->Data(),(matrix)b->Data(),NULL,NULL,currRing,false,true,false,currRing);
2909 }
2910 else
2911 {
2912 ring r=rCopy(currRing);
2913 BOOLEAN result=nc_CallPlural((matrix)a->Data(),(matrix)b->Data(),NULL,NULL,r,false,true,false,currRing);
2914 res->data=r;
2915 return result;
2916 }
2917}
2919{
2920 res->data=NULL;
2921
2923 {
2924 const poly q = (poly)b->Data();
2925
2926 if( q != NULL )
2927 {
2928 if( (poly)a->Data() != NULL )
2929 {
2931 {
2932 poly p = (poly)a->CopyD(POLY_CMD); // p = copy!
2933 res->data = nc_p_Bracket_qq(p,q, currRing); // p will be destroyed!
2934 }
2935 else if (rIsLPRing(currRing))
2936 {
2937 const poly p = (poly)a->Data();
2938 res->data = pAdd(ppMult_qq(p,q), pNeg(ppMult_qq(q,p)));
2939 }
2940 }
2941 }
2942 }
2943 return FALSE;
2944}
2946{
2947 res->data=NULL;
2948
2950 {
2951 const poly q = (poly)b->Data();
2952 if(q != NULL)
2953 {
2954 if((poly)a->Data() != NULL)
2955 {
2956 const poly p = (poly)a->Data();
2957 int k=(int)(long)c->Data();
2958 if (k > 0)
2959 {
2960 poly qq = pCopy(q);
2961 for (int i = 0; i < k; i++)
2962 {
2963 poly qq_ref = qq;
2964 if (rIsLPRing(currRing))
2965 {
2966 qq = pAdd(ppMult_qq(p,qq), pNeg(ppMult_qq(qq,p)));
2967 }
2968 else if (rIsPluralRing(currRing))
2969 {
2970 qq = nc_p_Bracket_qq(pCopy(p), qq, currRing);
2971 }
2972 pDelete(&qq_ref);
2973 if (qq == NULL) break;
2974 }
2975 res->data = qq;
2976 }
2977 else
2978 {
2979 Werror("invalid number of iterations");
2980 }
2981 }
2982 }
2983 }
2984 return FALSE;
2985}
2987{
2988 /* number, poly, vector, ideal, module, matrix */
2989 ring r = (ring)a->Data();
2990 if (r == currRing)
2991 {
2992 res->data = b->Data();
2993 res->rtyp = b->rtyp;
2994 return FALSE;
2995 }
2996 if (!rIsLikeOpposite(currRing, r))
2997 {
2998 Werror("%s is not an opposite ring to current ring",a->Fullname());
2999 return TRUE;
3000 }
3001 idhdl w;
3002 if( ((w=r->idroot->get(b->Name(),myynest))!=NULL) && (b->e==NULL))
3003 {
3004 int argtype = IDTYP(w);
3005 switch (argtype)
3006 {
3007 case NUMBER_CMD:
3008 {
3009 /* since basefields are equal, we can apply nCopy */
3010 res->data = nCopy((number)IDDATA(w));
3011 res->rtyp = argtype;
3012 break;
3013 }
3014 case POLY_CMD:
3015 case VECTOR_CMD:
3016 {
3017 poly q = (poly)IDDATA(w);
3018 res->data = pOppose(r,q,currRing);
3019 res->rtyp = argtype;
3020 break;
3021 }
3022 case IDEAL_CMD:
3023 case MODUL_CMD:
3024 {
3025 ideal Q = (ideal)IDDATA(w);
3026 res->data = idOppose(r,Q,currRing);
3027 res->rtyp = argtype;
3028 break;
3029 }
3030 case MATRIX_CMD:
3031 {
3032 ring save = currRing;
3033 rChangeCurrRing(r);
3034 matrix m = (matrix)IDDATA(w);
3036 rChangeCurrRing(save);
3037 ideal S = idOppose(r,Q,currRing);
3038 id_Delete(&Q, r);
3039 res->data = id_Module2Matrix(S,currRing);
3040 res->rtyp = argtype;
3041 break;
3042 }
3043 default:
3044 {
3045 WerrorS("unsupported type in oppose");
3046 return TRUE;
3047 }
3048 }
3049 }
3050 else
3051 {
3052 Werror("identifier %s not found in %s",b->Fullname(),a->Fullname());
3053 return TRUE;
3054 }
3055 return FALSE;
3056}
3057#endif /* HAVE_PLURAL */
3058
3060{
3061 if (ma->Typ()!=SMATRIX_CMD)
3062 {
3063 WerrorS("expected prune_map(`module`,`smatrix`)`");
3064 return TRUE;
3065 }
3066
3067 intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
3068 ideal v_id=(ideal)v->Data();
3069 if (w!=NULL)
3070 {
3071 if (!idTestHomModule(v_id,currRing->qideal,w))
3072 {
3073 WarnS("wrong weights");
3074 w=NULL;
3075 // and continue at the non-homog case below
3076 }
3077 else
3078 {
3079 w=ivCopy(w);
3080 intvec **ww=&w;
3081 ideal mat;
3082 int *g=(int*)omAlloc(v_id->rank*sizeof(int));
3083 res->data = (char *)idMinEmbedding_with_map_v(v_id,ww,mat,g);
3084 atSet(res,omStrDup("isHomog"),*ww,INTVEC_CMD);
3085 idhdl h=(idhdl)ma->data;
3086 idDelete(&IDIDEAL(h));
3087 IDIDEAL(h)=mat;
3088 for(int i=0;i<v_id->rank;i++) Print("v[%d]:%d ",i+1,g[i]);
3089 PrintLn();
3090 omFreeSize(g,v_id->rank*sizeof(int));
3091 return FALSE;
3092 }
3093 }
3094 ideal mat;
3095 int *g=(int*)omAlloc(v_id->rank*sizeof(int));
3096 res->data = (char *)idMinEmbedding_with_map_v(v_id,NULL,mat,g);
3097 for(int i=0;i<v_id->rank;i++) Print("v[%d]:%d ",i+1,g[i]);
3098 PrintLn();
3099 omFreeSize(g,v_id->rank*sizeof(int));
3100 idhdl h=(idhdl)ma->data;
3101 idDelete(&IDIDEAL(h));
3102 IDIDEAL(h)=mat;
3103 return FALSE;
3104}
3106{
3107 res->data = (char *)idQuot((ideal)u->Data(),(ideal)v->Data(),
3108 hasFlag(u,FLAG_STD),u->Typ()==v->Typ());
3109 //if (TEST_OPT_RETURN_SB) setFlag(res,FLAG_STD);
3110 return FALSE;
3111}
3113{
3114 int i=(int)(long)u->Data();
3115 int j=(int)(long)v->Data();
3116 if (j-i <0) {WerrorS("invalid range for random"); return TRUE;}
3117 res->data =(char *)(long)((i > j) ? i : (siRand() % (j-i+1)) + i);
3118 return FALSE;
3119}
3121{
3122 matrix m =(matrix)u->Data();
3123 int isRowEchelon = (int)(long)v->Data();
3124 if (isRowEchelon != 1) isRowEchelon = 0;
3125 int rank = luRank(m, isRowEchelon);
3126 res->data =(char *)(long)rank;
3127 return FALSE;
3128}
3130{
3131 si_link l=(si_link)u->Data();
3132 leftv r=slRead(l,v);
3133 if (r==NULL)
3134 {
3135 const char *s;
3136 if ((l!=NULL)&&(l->name!=NULL)) s=l->name;
3137 else s=sNoName_fe;
3138 Werror("cannot read from `%s`",s);
3139 return TRUE;
3140 }
3141 memcpy(res,r,sizeof(sleftv));
3143 return FALSE;
3144}
3146{
3147 ideal vi=(ideal)v->Data();
3148 if (currRing->qideal!=NULL || vi->ncols>1 || rIsPluralRing(currRing))
3150 res->data = (char *)kNF(vi,currRing->qideal,(poly)u->Data());
3151 return FALSE;
3152}
3154{
3155 ideal ui=(ideal)u->Data();
3156 ideal vi=(ideal)v->Data();
3157 if (currRing->qideal!=NULL || vi->ncols>1 || rIsPluralRing(currRing))
3159 res->data = (char *)kNF(vi,currRing->qideal,ui);
3160 return FALSE;
3161}
3163{
3164// handles hres,kres,lres,mres,nres,sres
3165 int maxl=(int)(long)v->Data();
3166 if (maxl<0)
3167 {
3168 WerrorS("length for res must not be negative");
3169 return TRUE;
3170 }
3171 BOOLEAN complete=(maxl==0) && (currRing->qideal==NULL);
3172 syStrategy r;
3173 intvec *weights=NULL;
3174 int wmaxl=maxl;
3175 ideal u_id=(ideal)u->Data();
3176
3177 maxl--;
3178 if (maxl==-1)
3179 {
3180 if ((iiOp!=MRES_CMD) && (iiOp!=RES_CMD)&&(iiOp!=SRES_CMD))
3181 maxl = currRing->N;
3182 if (currRing->qideal!=NULL)
3183 {
3184 maxl = currRing->N-1+2*(iiOp==MRES_CMD);
3185 Warn(
3186 "full resolution in a qring may be infinite, setting max length to %d",
3187 maxl+1);
3188 }
3189 }
3190 weights=(intvec*)atGet(u,"isHomog",INTVEC_CMD);
3191 if (weights!=NULL)
3192 {
3193 if (!idTestHomModule(u_id,currRing->qideal,weights))
3194 {
3195 WarnS("wrong weights given:");weights->show();PrintLn();
3196 weights=NULL;
3197 }
3198 }
3199 intvec *ww=NULL;
3200 int add_row_shift=0;
3201 if (weights!=NULL)
3202 {
3203 ww=ivCopy(weights);
3204 add_row_shift = ww->min_in();
3205 (*ww) -= add_row_shift;
3206 }
3207 unsigned save_opt=si_opt_1;
3209 if ((iiOp == RES_CMD) || (iiOp == MRES_CMD))
3210 {
3211 r=syResolution(u_id,maxl, ww, iiOp==MRES_CMD);
3212 }
3213 else if (iiOp==SRES_CMD)
3214 // r=sySchreyerResolvente(u_id,maxl+1,&l);
3215 r=sySchreyer(u_id,maxl+1);
3216 else if (iiOp == LRES_CMD)
3217 {
3218 int dummy;
3219 if((currRing->qideal!=NULL)||
3220 (!idHomIdeal (u_id,NULL)))
3221 {
3222 WerrorS("`lres` not implemented for inhomogeneous input or qring");
3223 return TRUE;
3224 }
3225 if(currRing->N == 1)
3226 WarnS("the current implementation of `lres` may not work in the case of a single variable");
3227 r=syLaScala3(u_id,&dummy);
3228 }
3229 else if (iiOp == KRES_CMD)
3230 {
3231 int dummy;
3232 if((currRing->qideal!=NULL)||
3233 (!idHomIdeal (u_id,NULL)))
3234 {
3235 WerrorS
3236 ("`kres` not implemented for inhomogeneous input or qring");
3237 return TRUE;
3238 }
3239 r=syKosz(u_id,&dummy);
3240 }
3241 else
3242 { // HRES
3243 int dummy;
3244 if((currRing->qideal!=NULL)||
3245 (!idHomIdeal (u_id,NULL)))
3246 {
3247 WerrorS
3248 ("`hres` not implemented for inhomogeneous input or qring");
3249 return TRUE;
3250 }
3251 ideal u_id_copy=idCopy(u_id);
3252 idSkipZeroes(u_id_copy);
3253 r=syHilb(u_id_copy,&dummy);
3254 idDelete(&u_id_copy);
3255 }
3256 if (r==NULL) return TRUE;
3257 if (wmaxl>0)
3258 {
3259 if (r->list_length>wmaxl)
3260 {
3261 for(int i=wmaxl-1;i<=r->list_length;i++)
3262 {
3263 if (r->fullres[i]!=NULL) id_Delete(&r->fullres[i],currRing);
3264 if (r->minres[i]!=NULL) id_Delete(&r->minres[i],currRing);
3265 }
3266 }
3267 r->list_length=wmaxl;
3268 }
3269 res->data=(void *)r;
3270 if ((weights!=NULL) && (ww!=NULL)) { delete ww; ww=NULL; }
3271 if ((r->weights!=NULL) && (r->weights[0]!=NULL))
3272 {
3273 ww=ivCopy(r->weights[0]);
3274 if (weights!=NULL) (*ww) += add_row_shift;
3275 atSet(res,omStrDup("isHomog"),ww,INTVEC_CMD);
3276 }
3277 else
3278 {
3279 if (weights!=NULL)
3280 {
3281 atSet(res,omStrDup("isHomog"),ivCopy(weights),INTVEC_CMD);
3282 }
3283 }
3284
3285 // test the La Scala case' output
3286 assume( ((iiOp == LRES_CMD) || (iiOp == HRES_CMD)) == (r->syRing != NULL) );
3287 assume( (r->syRing != NULL) == (r->resPairs != NULL) );
3288
3289 if(iiOp != HRES_CMD)
3290 assume( (r->minres != NULL) || (r->fullres != NULL) ); // is wrong for HRES_CMD...
3291 else
3292 assume( (r->orderedRes != NULL) || (r->res != NULL) ); // analog for hres...
3293
3294 if(complete) syFix(r);
3295 si_opt_1=save_opt;
3296 return FALSE;
3297}
3299{
3300 number n1; int i;
3301
3302 if ((u->Typ() == BIGINT_CMD) ||
3303 ((u->Typ() == NUMBER_CMD) && rField_is_Q(currRing)))
3304 {
3305 n1 = (number)u->CopyD();
3306 }
3307 else if (u->Typ() == INT_CMD)
3308 {
3309 i = (int)(long)u->Data();
3310 n1 = n_Init(i, coeffs_BIGINT);
3311 }
3312 else
3313 {
3314 return TRUE;
3315 }
3316
3317 i = (int)(long)v->Data();
3318
3319 lists l = primeFactorisation(n1, i);
3320 n_Delete(&n1, coeffs_BIGINT);
3321 res->data = (char*)l;
3322 return FALSE;
3323}
3325{
3326 ring r=rMinusVar((ring)u->Data(),(char*)v->Data());
3327 res->data = (char *)r;
3328 return r==NULL;
3329}
3331{
3332 int left;
3333 if (u->Typ()==RING_CMD) left=0;
3334 else
3335 {
3336 leftv h=u;u=v;v=h;
3337 left=1;
3338 }
3339 ring r=rPlusVar((ring)u->Data(),(char*)v->Data(),left);
3340 res->data = (char *)r;
3341 return r==NULL;
3342}
3344{
3345 ring r;
3346 int i=rSum((ring)u->Data(),(ring)v->Data(),r);
3347 res->data = (char *)r;
3348 return (i==-1);
3349}
3350#define SIMPL_NORMALIZE 64
3351#define SIMPL_LMDIV 32
3352#define SIMPL_LMEQ 16
3353#define SIMPL_MULT 8
3354#define SIMPL_EQU 4
3355#define SIMPL_NULL 2
3356#define SIMPL_NORM 1
3358{
3359 int sw = (int)(long)v->Data();
3360 // CopyD for IDEAL_CMD and MODUL_CMD are identical:
3361 ideal id = (ideal)u->CopyD(IDEAL_CMD);
3362 if (sw & SIMPL_LMDIV)
3363 {
3364 id_DelDiv(id,currRing);
3365 }
3366 if (sw & SIMPL_LMEQ)
3367 {
3369 }
3370 if (sw & SIMPL_MULT)
3371 {
3373 }
3374 else if(sw & SIMPL_EQU)
3375 {
3377 }
3378 if (sw & SIMPL_NULL)
3379 {
3380 idSkipZeroes(id);
3381 }
3382 if (sw & SIMPL_NORM)
3383 {
3384 id_Norm(id,currRing);
3385 }
3386 if (sw & SIMPL_NORMALIZE)
3387 {
3389 }
3390 res->data = (char * )id;
3391 return FALSE;
3392}
3395{
3396 intvec *v=NULL;
3397 int sw=(int)(long)dummy->Data();
3398 int fac_sw=sw;
3399 if (sw<0) fac_sw=1;
3401 ideal f=singclap_sqrfree((poly)(u->CopyD()), &v, fac_sw, currRing);
3402 if (f==NULL)
3403 return TRUE;
3404 switch(sw)
3405 {
3406 case 0:
3407 case 2:
3408 {
3410 l->Init(2);
3411 l->m[0].rtyp=IDEAL_CMD;
3412 l->m[0].data=(void *)f;
3413 l->m[1].rtyp=INTVEC_CMD;
3414 l->m[1].data=(void *)v;
3415 res->data=(void *)l;
3416 res->rtyp=LIST_CMD;
3417 return FALSE;
3418 }
3419 case 1:
3420 res->data=(void *)f;
3421 return FALSE;
3422 case 3:
3423 {
3424 poly p=f->m[0];
3425 int i=IDELEMS(f);
3426 f->m[0]=NULL;
3427 while(i>1)
3428 {
3429 i--;
3430 p=pMult(p,f->m[i]);
3431 f->m[i]=NULL;
3432 }
3433 res->data=(void *)p;
3434 res->rtyp=POLY_CMD;
3435 }
3436 return FALSE;
3437 }
3438 WerrorS("invalid switch");
3439 return FALSE;
3440}
3442{
3443 res->data = omStrDup(slStatus((si_link) u->Data(), (char *) v->Data()));
3444 return FALSE;
3445}
3447{
3448 res->data = (void *)(long)slStatusSsiL((lists) u->Data(), (int)(long) v->Data());
3449 //return (res->data== (void*)(long)-2);
3450 return FALSE;
3451}
3453{
3454 int sw = (int)(long)v->Data();
3455 // CopyD for POLY_CMD and VECTOR_CMD are identical:
3456 poly p = (poly)u->CopyD(POLY_CMD);
3457 if (sw & SIMPL_NORM)
3458 {
3459 pNorm(p);
3460 }
3461 if (sw & SIMPL_NORMALIZE)
3462 {
3464 }
3465 res->data = (char * )p;
3466 return FALSE;
3467}
3469{
3470 ideal result;
3471 intvec *w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
3472 tHomog hom=testHomog;
3473 ideal u_id=(ideal)(u->Data());
3474 if (w!=NULL)
3475 {
3476 if (!idTestHomModule(u_id,currRing->qideal,w))
3477 {
3478 WarnS("wrong weights:");w->show();PrintLn();
3479 w=NULL;
3480 }
3481 else
3482 {
3483 w=ivCopy(w);
3484 hom=isHomog;
3485 }
3486 }
3487 bigintmat *vv=(bigintmat*)v->Data();
3488 result=kStd2(u_id,currRing->qideal,hom,&w,vv);
3489 if (errorreported) return TRUE;
3491 res->data = (char *)result;
3493 if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
3494 return FALSE;
3495}
3497{
3498 ideal result;
3499 assumeStdFlag(u);
3500 ideal i1=(ideal)(u->Data());
3501 int ii1=idElem(i1); /* size of i1 */
3502 ideal i0;
3503 int r=v->Typ();
3504 BITSET save1;
3505 SI_SAVE_OPT1(save1);
3506 intvec *w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
3507 tHomog hom=testHomog;
3508 if ((/*v->Typ()*/r==POLY_CMD) ||(r==VECTOR_CMD))
3509 {
3510 poly p=(poly)v->Data();
3511 i0=idInit(1,i1->rank);
3512 i0->m[0]=p;
3513 i1=idSimpleAdd(i1,i0); //
3514 i0->m[0]=NULL;
3515 idDelete(&i0);
3516
3517 if (w!=NULL)
3518 {
3519 if (!idTestHomModule(i1,currRing->qideal,w))
3520 {
3521 // no warnung: this is legal, if i in std(i,p)
3522 // is homogeneous, but p not
3523 w=NULL;
3524 }
3525 else
3526 {
3527 w=ivCopy(w);
3528 hom=isHomog;
3529 }
3530 }
3532 /* ii1 appears to be the position of the first element of il that
3533 does not belong to the old SB ideal */
3534 result=kStd2(i1,currRing->qideal,hom,&w,(bigintmat*)NULL,0,ii1);
3535 }
3536 else /*IDEAL/MODULE*/
3537 {
3538 i0=(ideal)v->CopyD();
3539 i1=idSimpleAdd(i1,i0); //
3540 memset(i0->m,0,sizeof(poly)*IDELEMS(i0));
3541 idDelete(&i0);
3542
3543 if (w!=NULL)
3544 {
3545 if (!idTestHomModule(i1,currRing->qideal,w))
3546 {
3547 // no warnung: this is legal, if i in std(i,p)
3548 // is homogeneous, but p not
3549 w=NULL;
3550 hom=isNotHomog;
3551 }
3552 else
3553 {
3554 w=ivCopy(w);
3555 hom=isHomog;
3556 }
3557 }
3559 /* ii1 appears to be the position of the first element of i1 that
3560 does not belong to the old SB ideal */
3561 result=kStd2(i1,currRing->qideal,hom,&w,(bigintmat*)NULL,0,ii1);
3562 }
3563 SI_RESTORE_OPT1(save1);
3564 idDelete(&i1);
3565 if (errorreported) return TRUE;
3567 if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
3568 res->data = (char *)result;
3570 return FALSE;
3571}
3573{
3574 // see jjSYZYGY
3575 intvec *ww=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
3576 intvec *w=NULL;
3577 tHomog hom=testHomog;
3578 ideal I=(ideal)u->Data();
3579 GbVariant alg=syGetAlgorithm((char*)v->Data(),currRing,I);
3580 if (ww!=NULL)
3581 {
3582 if (idTestHomModule(I,currRing->qideal,ww))
3583 {
3584 w=ivCopy(ww);
3585 int add_row_shift=w->min_in();
3586 (*w)-=add_row_shift;
3587 hom=isHomog;
3588 }
3589 else
3590 {
3591 //WarnS("wrong weights");
3592 delete ww; ww=NULL;
3593 hom=testHomog;
3594 }
3595 }
3596 else
3597 {
3598 if (u->Typ()==IDEAL_CMD)
3599 if (idHomIdeal(I,currRing->qideal))
3600 hom=isHomog;
3601 }
3602 ideal S=idSyzygies(I,hom,&w,TRUE,FALSE,NULL,alg);
3603 if (w!=NULL) delete w;
3604 res->data = (char *)S;
3605 if (hom==isHomog)
3606 {
3607 int vl=S->rank;
3608 intvec *vv=new intvec(vl);
3609 if ((u->Typ()==IDEAL_CMD)||(ww==NULL))
3610 {
3611 for(int i=0;i<vl;i++)
3612 {
3613 if (I->m[i]!=NULL)
3614 (*vv)[i]=p_Deg(I->m[i],currRing);
3615 }
3616 }
3617 else
3618 {
3619 p_SetModDeg(ww, currRing);
3620 for(int i=0;i<vl;i++)
3621 {
3622 if (I->m[i]!=NULL)
3623 (*vv)[i]=currRing->pFDeg(I->m[i],currRing);
3624 }
3626 }
3627 if (idTestHomModule(S,currRing->qideal,vv))
3628 atSet(res,omStrDup("isHomog"),vv,INTVEC_CMD);
3629 else
3630 delete vv;
3631 }
3633 return FALSE;
3634}
3635#ifdef HTABLE
3636static BOOLEAN jjTABLE_GET(leftv res, leftv u, leftv v)
3637{
3638 stablerec* t=(stablerec*)u->Data();
3639 leftv r=t_findTabelVal(t,(char*)v->Data());
3640 if (r!=NULL) res->Copy(r);
3641 return (r==NULL);
3642}
3643#endif
3645{
3646 ideal A=(ideal)u->Data();
3647 ideal B=(ideal)v->Data();
3648 res->data = (char *)sm_Tensor(A,B,currRing);
3649 return FALSE;
3650}
3652{
3653 sleftv tmp_u,tmp_v,tmp_res;
3657 tmp_res.Init();
3658 tmp_res.rtyp=SMATRIX_CMD;
3659 BOOLEAN bo=jjTENSOR(&tmp_res,&tmp_u,&tmp_v);
3660 if (!bo)
3661 {
3664 }
3665 tmp_u.CleanUp();
3666 tmp_v.CleanUp();
3667 tmp_res.CleanUp();
3668 return bo;
3669}
3671{
3672 idhdl h=(idhdl)u->data;
3673 int i=(int)(long)v->Data();
3674 if ((0<i) && (i<=IDRING(h)->N))
3675 res->data=omStrDup(IDRING(h)->names[i-1]);
3676 else
3677 {
3678 Werror("var number %d out of range 1..%d",i,IDRING(h)->N);
3679 return TRUE;
3680 }
3681 return FALSE;
3682}
3684{
3685// input: u: a list with links of type
3686// ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
3687// v: timeout for select in milliseconds
3688// or 0 for polling
3689// returns: ERROR (via Werror): timeout negative
3690// -1: the read state of all links is eof
3691// 0: timeout (or polling): none ready
3692// i>0: (at least) L[i] is ready
3693 lists L = (lists)u->Data();
3694 int t = (int)(long)v->Data();
3695 if(t < 0)
3696 {
3697 t= -1;
3698 }
3699 int i = slStatusSsiL(L, t);
3700 if(i == -2) /* error */
3701 {
3702 return TRUE;
3703 }
3704 res->data = (void*)(long)i;
3705 return FALSE;
3706}
3708{
3709// input: u: a list with links of type
3710// ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
3711// v: timeout for select in milliseconds
3712// or 0 for polling
3713// or -1 for infinite
3714// returns: ERROR (via Werror): timeout negative
3715// -1: the read state of all links is eof or error
3716// 0: timeout (or polling): none ready
3717// 1: all links are ready
3718// (caution: at least one is ready, but some maybe dead)
3719 lists L = (lists)u->Data();
3720 BOOLEAN* ignore=(BOOLEAN*)omAlloc0((L->nr+1)*sizeof(BOOLEAN));
3721 int timeout = (int)(long)v->Data();
3722 if(timeout < 0)
3723 {
3724 timeout=-1;
3725 }
3726 int t = getRTimer()/TIMER_RESOLUTION; // in seconds
3727 int i;
3728 int ret = -1;
3729 for(unsigned nfinished = 0; nfinished <= ((unsigned)L->nr); nfinished++)
3730 {
3731 i = slStatusSsiL(L, timeout, ignore);
3732 if(i > 0) /* L[i] is ready */
3733 {
3734 ret = 1;
3735 ignore[i-1]=TRUE;
3736 timeout = si_max(0,timeout - 1000*(getRTimer()/TIMER_RESOLUTION - t));
3737 }
3738 else /* terminate the for loop */
3739 {
3740 omFreeSize(ignore,(L->nr+1)*sizeof(BOOLEAN));
3741 if(i == -2) /* error */
3742 {
3743 return TRUE;
3744 }
3745 if(i == 0) /* timeout */
3746 {
3747 ret = 0;
3748 }
3749 break;
3750 }
3751 }
3752 res->data = (void*)(long)ret;
3753 return FALSE;
3754}
3756{
3757 res->data = (char *)mp_Wedge((matrix)u->Data(),(int)(long)v->Data(),currRing);
3758 return FALSE;
3759}
3761{
3762 return TRUE;
3763}
3765{
3766 return TRUE;
3767}
3769{
3770 return TRUE;
3771}
3772
3773/*=================== operations with 1 arg.: static proc =================*/
3774/* must be ordered: first operations for chars (infix ops),
3775 * then alphabetically */
3776
3778{
3779// res->data = (char *)u->CopyD();
3780// also copy attributes:
3781 res->Copy(u);
3782 return FALSE;
3783}
3785{
3786 return FALSE;
3787}
3788//static BOOLEAN jjPLUSPLUS(leftv res, leftv u)
3789//{
3790// res->data = (char *)((int)(long)u->Data()+1);
3791// return FALSE;
3792//}
3793//static BOOLEAN jjMINUSMINUS(leftv res, leftv u)
3794//{
3795// res->data = (char *)((int)(long)u->Data()-1);
3796// return FALSE;
3797//}
3799{
3800 if (IDTYP((idhdl)u->data)==INT_CMD)
3801 {
3802 int i=IDINT((idhdl)u->data);
3803 if (iiOp==PLUSPLUS) i++;
3804 else i--;
3805 IDDATA((idhdl)u->data)=(char *)(long)i;
3806 return FALSE;
3807 }
3808 return TRUE;
3809}
3811{
3812 number n=(number)u->CopyD(BIGINT_CMD);
3814 res->data = (char *)n;
3815 return FALSE;
3816}
3818{
3819 res->data = (char *)(-(long)u->Data());
3820 return FALSE;
3821}
3823{
3824 number n=(number)u->CopyD(NUMBER_CMD);
3825 n=nInpNeg(n);
3826 res->data = (char *)n;
3827 return FALSE;
3828}
3830{
3831 res->data = (char *)pNeg((poly)u->CopyD(POLY_CMD));
3832 return FALSE;
3833}
3835{
3836 poly m1=pISet(-1);
3837 res->data = (char *)mp_MultP((matrix)u->CopyD(MATRIX_CMD),m1,currRing);
3838 return FALSE;
3839}
3841{
3842 intvec *iv=(intvec *)u->CopyD(INTVEC_CMD);
3843 (*iv)*=(-1);
3844 res->data = (char *)iv;
3845 return FALSE;
3846}
3848{
3850 (*bim)*=(-1);
3851 res->data = (char *)bim;
3852 return FALSE;
3853}
3854// dummy for python_module.so and similiar
3856{
3857 if (u->rtyp==IDHDL) rSetHdl((idhdl)u->data);
3858 else
3859 {
3860 ring r=(ring)u->Data();
3861 idhdl h=rFindHdl(r,NULL);
3862 if (h==NULL)
3863 {
3864 char name_buffer[100];
3865 STATIC_VAR int ending=1000000;
3866 ending++;
3867 snprintf(name_buffer,100, "PYTHON_RING_VAR%d",ending);
3868 h=enterid(name_buffer,0,RING_CMD,&IDROOT);
3869 IDRING(h)=rIncRefCnt(r);
3870 }
3871 rSetHdl(h);
3872 }
3873 return FALSE;
3874}
3876{
3877 return jjPROC(res,u,NULL);
3878}
3880{
3881 //matrix m=(matrix)v->Data();
3882 //lists l=mpBareiss(m,FALSE);
3883 intvec *iv;
3884 ideal m;
3885 sm_CallBareiss((ideal)v->Data(),0,0,m,&iv, currRing);
3887 l->Init(2);
3888 l->m[0].rtyp=MODUL_CMD;
3889 l->m[1].rtyp=INTVEC_CMD;
3890 l->m[0].data=(void *)m;
3891 l->m[1].data=(void *)iv;
3892 res->data = (char *)l;
3893 return FALSE;
3894}
3895//static BOOLEAN jjBAREISS_IM(leftv res, leftv v)
3896//{
3897// intvec *m=(intvec *)v->CopyD(INTMAT_CMD);
3898// ivTriangMat(m);
3899// res->data = (char *)m;
3900// return FALSE;
3901//}
3903{
3904 bigintmat *b=(bigintmat*)v->CopyD(BIGINTMAT_CMD);
3905 b->hnf();
3906 res->data=(char*)b;
3907 return FALSE;
3908}
3910{
3911 BOOLEAN bo=FALSE;
3912 number n=(number)u->CopyD();
3914 if (nMap!=NULL)
3915 res->data=nMap(n,coeffs_BIGINT,currRing->cf);
3916 else
3917 {
3918 Werror("cannot convert bigint to cring %s", nCoeffName(currRing->cf));
3919 bo=TRUE;
3920 }
3922 return bo;
3923}
3925{
3926 bigintmat *b=(bigintmat*)u->Data();
3927 res->data=(void *)bim2iv(b);
3928 return FALSE;
3929}
3931{
3932 sleftv tmp;
3933 BOOLEAN bo=jjBI2N(&tmp,u);
3934 if (!bo)
3935 {
3936 number n=(number) tmp.data;
3937 if (nIsZero(n)) { res->data=NULL;nDelete(&n); }
3938 else
3939 {
3940 res->data=(void *)pNSet(n);
3941 }
3942 }
3943 return bo;
3944}
3946{
3947 return iiExprArithM(res,u,iiOp);
3948}
3950{
3951 res->data = (char *)(long)rChar((ring)v->Data());
3952 return FALSE;
3953}
3955{
3956 ring r=(ring)v->Data();
3957 r->cf->ref++;
3958 res->data = (char *)r->cf;
3959 return FALSE;
3960}
3962{
3963 res->data = (char *)(long)MATCOLS((matrix)(v->Data()));
3964 return FALSE;
3965}
3967{
3968 res->data = (char *)(long)((bigintmat*)(v->Data()))->cols();
3969 return FALSE;
3970}
3972{
3973 res->data = (char *)(long)((intvec*)(v->Data()))->cols();
3974 return FALSE;
3975}
3977{
3978 // CopyD for POLY_CMD and VECTOR_CMD are identical:
3979 poly p=(poly)v->CopyD(POLY_CMD);
3980 if (p!=NULL) p_Cleardenom(p, currRing);
3981 res->data = (char *)p;
3982 return FALSE;
3983}
3985{
3986 res->data = (char *)(long)n_Size((number)v->Data(),coeffs_BIGINT);
3987 return FALSE;
3988}
3990{
3991 bigintmat* aa= (bigintmat *)v->Data();
3992 res->data = (char *)(long)(aa->rows()*aa->cols());
3993 return FALSE;
3994}
3996{
3997 res->data = (char *)(long)nSize((number)v->Data());
3998 return FALSE;
3999}
4001{
4002 lists l=(lists)v->Data();
4003 res->data = (char *)(long)(lSize(l)+1);
4004 return FALSE;
4005}
4007{
4008 matrix m=(matrix)v->Data();
4009 res->data = (char *)(long)(MATROWS(m)*MATCOLS(m));
4010 return FALSE;
4011}
4013{
4014 res->data = (char *)(long)((intvec*)(v->Data()))->length();
4015 return FALSE;
4016}
4018{
4019 ring r=(ring)v->Data();
4020 int elems=-1;
4021 if (rField_is_Zp(r)) elems=r->cf->ch;
4022 else if (rField_is_GF(r)) elems=r->cf->m_nfCharQ;
4023 else if (rField_is_Zp_a(r) && (r->cf->type==n_algExt))
4024 {
4025 extern int ipower ( int b, int n ); /* factory/cf_util */
4026 elems=ipower(r->cf->ch,r->cf->extRing->pFDeg(r->cf->extRing->qideal->m[0],r->cf->extRing));
4027 }
4028 res->data = (char *)(long)elems;
4029 return FALSE;
4030}
4032{
4033 int dummy;
4034 poly p=(poly)v->Data();
4035 if (p!=NULL) res->data = (char *)currRing->pLDeg(p,&dummy,currRing);
4036 else res->data=(char *)-1;
4037 return FALSE;
4038}
4040{
4041 ideal I=(ideal)u->Data();
4042 int d=-1;
4043 int dummy;
4044 int i;
4045 for(i=IDELEMS(I)-1;i>=0;i--)
4046 if (I->m[i]!=NULL) d=si_max(d,(int)currRing->pLDeg(I->m[i],&dummy,currRing));
4047 res->data = (char *)(long)d;
4048 return FALSE;
4049}
4051{
4052 SPrintStart();
4053 if (rField_is_Z(currRing))
4054 {
4055 PrintS("// NOTE: computation of degree is being performed for\n");
4056 PrintS("// generic fibre, that is, over Q\n");
4057 }
4059 intvec *module_w=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
4060 scDegree((ideal)v->Data(),module_w,currRing->qideal);
4061 char *s=SPrintEnd();
4062 int l=strlen(s)-1;
4063 s[l]='\0';
4064 res->data=(void*)s;
4065 return FALSE;
4066}
4068{
4069 if ((v->rtyp==IDHDL)
4070 && ((myynest==IDLEV((idhdl)v->data))||(0==IDLEV((idhdl)v->data))))
4071 {
4072 res->data=(void *)(long)(IDLEV((idhdl)v->data)+1);
4073 }
4074 else if (v->rtyp!=0) res->data=(void *)(-1);
4075 return FALSE;
4076}
4077
4078/// Return the denominator of the input number
4080{
4081 number n = reinterpret_cast<number>(v->CopyD());
4082 res->data = reinterpret_cast<void*>(n_GetDenom(n, currRing->cf));
4083 n_Delete(&n,currRing->cf);
4084 return FALSE;
4085}
4086
4087/// Return the numerator of the input number
4089{
4090 number n = reinterpret_cast<number>(v->CopyD());
4091 res->data = reinterpret_cast<void*>(n_GetNumerator(n, currRing->cf));
4092 n_Delete(&n,currRing->cf);
4093 return FALSE;
4094}
4095
4097{
4098 matrix m=(matrix)v->Data();
4099 res ->data = mp_Det(m,currRing);
4100 return FALSE;
4101}
4103{
4104 bigintmat * m=(bigintmat*)v->Data();
4105 int i,j;
4106 i=m->rows();j=m->cols();
4107 if(i==j)
4108 res->data = (char *)(long)singclap_det_bi(m,coeffs_BIGINT);
4109 else
4110 {
4111 Werror("det of %d x %d bigintmat",i,j);
4112 return TRUE;
4113 }
4114 return FALSE;
4115}
4116#ifdef SINGULAR_4_2
4117static BOOLEAN jjDET_N2(leftv res, leftv v)
4118{
4119 bigintmat * m=(bigintmat*)v->Data();
4120 number2 r=(number2)omAlloc0(sizeof(*r));
4121 int i,j;
4122 i=m->rows();j=m->cols();
4123 if(i==j)
4124 {
4125 r->n=m->det();
4126 r->cf=m->basecoeffs();
4127 }
4128 else
4129 {
4130 omFreeSize(r,sizeof(*r));
4131 Werror("det of %d x %d cmatrix",i,j);
4132 return TRUE;
4133 }
4134 res->data=(void*)r;
4135 return FALSE;
4136}
4137#endif
4139{
4140 intvec * m=(intvec*)v->Data();
4141 int i,j;
4142 i=m->rows();j=m->cols();
4143 if(i==j)
4144 res->data = (char *)(long)singclap_det_i(m,currRing);
4145 else
4146 {
4147 Werror("det of %d x %d intmat",i,j);
4148 return TRUE;
4149 }
4150 return FALSE;
4151}
4153{
4154 ideal I=(ideal)v->Data();
4155 res->data=(char*)sm_Det(I,currRing);
4156 return FALSE;
4157}
4159{
4161#ifdef HAVE_SHIFTBBA
4162 if (rIsLPRing(currRing))
4163 {
4165 {
4166 WerrorS("`dim` is not implemented for letterplace rings over rings");
4167 return TRUE;
4168 }
4169 if (currRing->qideal != NULL)
4170 {
4171 WerrorS("qring not supported by `dim` for letterplace rings at the moment");
4172 return TRUE;
4173 }
4174 int gkDim = lp_gkDim((ideal)(v->Data()));
4175 res->data = (char *)(long)gkDim;
4176 return (gkDim == -2);
4177 }
4178#endif
4180 {
4181 Warn("dim(%s) may be wrong because the mixed monomial ordering",v->Name());
4182 }
4183 res->data = (char *)(long)scDimIntRing((ideal)(v->Data()),currRing->qideal);
4184 return FALSE;
4185}
4187{
4188 si_link l = (si_link)v->Data();
4189 if (slDump(l))
4190 {
4191 const char *s;
4192 if ((l!=NULL)&&(l->name!=NULL)) s=l->name;
4193 else s=sNoName_fe;
4194 Werror("cannot dump to `%s`",s);
4195 return TRUE;
4196 }
4197 else
4198 return FALSE;
4199}
4201{
4202 res->data = (char *)pOne();
4203 int co=(int)(long)v->Data();
4204 if (co>0)
4205 {
4206 pSetComp((poly)res->data,co);
4207 pSetm((poly)res->data);
4208 }
4209 else WerrorS("argument of gen must be positive");
4210 return (co<=0);
4211}
4213{
4214 char * d = (char *)v->Data();
4215 char * s = (char *)omAlloc(strlen(d) + 13);
4216 strcpy( s, (char *)d);
4217 strcat( s, "\n;RETURN();\n");
4219 return yyparse();
4220}
4222{
4224 if (currRing->cf->convSingNFactoryN!=ndConvSingNFactoryN) /* conversion to factory*/
4225 {
4226 ideal_list p,h;
4227 h=kStdfac((ideal)v->Data(),NULL,testHomog,NULL);
4228 if (h==NULL)
4229 {
4230 L->Init(1);
4231 L->m[0].data=(char *)idInit(1);
4232 L->m[0].rtyp=IDEAL_CMD;
4233 }
4234 else
4235 {
4236 p=h;
4237 int l=0;
4238 while (p!=NULL) { p=p->next;l++; }
4239 L->Init(l);
4240 l=0;
4241 while(h!=NULL)
4242 {
4243 L->m[l].data=(char *)h->d;
4244 L->m[l].rtyp=IDEAL_CMD;
4245 p=h->next;
4246 omFreeSize(h,sizeof(*h));
4247 h=p;
4248 l++;
4249 }
4250 }
4251 }
4252 else
4253 {
4254 WarnS("no factorization implemented");
4255 L->Init(1);
4256 iiExprArith1(&(L->m[0]),v,STD_CMD);
4257 }
4258 res->data=(void *)L;
4259 return FALSE;
4260}
4262{
4263 intvec *v=NULL;
4265 ideal f=singclap_factorize((poly)(u->CopyD()), &v, 0,currRing);
4266 if (f==NULL) return TRUE;
4267 ivTest(v);
4269 l->Init(2);
4270 l->m[0].rtyp=IDEAL_CMD;
4271 l->m[0].data=(void *)f;
4272 l->m[1].rtyp=INTVEC_CMD;
4273 l->m[1].data=(void *)v;
4274 res->data=(void *)l;
4275 return FALSE;
4276}
4278{
4279 si_link l = (si_link)v->Data();
4280 if (slGetDump(l))
4281 {
4282 const char *s;
4283 if ((l!=NULL)&&(l->name!=NULL)) s=l->name;
4284 else s=sNoName_fe;
4285 Werror("cannot get dump from `%s`",s);
4286 return TRUE;
4287 }
4288 else
4289 return FALSE;
4290}
4292{
4294 ideal I=(ideal)v->Data();
4295 res->data=(void *)iiHighCorner(I,0);
4296 return FALSE;
4297}
4299{
4301 intvec *w=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
4302 BOOLEAN delete_w=FALSE;
4303 ideal I=(ideal)v->Data();
4304 int i;
4305 poly p=NULL,po=NULL;
4306 int rk=id_RankFreeModule(I,currRing);
4307 if (w==NULL)
4308 {
4309 w = new intvec(rk);
4310 delete_w=TRUE;
4311 }
4312 for(i=rk;i>0;i--)
4313 {
4314 p=iiHighCorner(I,i);
4315 if (p==NULL)
4316 {
4317 WerrorS("module must be zero-dimensional");
4318 if (delete_w) delete w;
4319 return TRUE;
4320 }
4321 if (po==NULL)
4322 {
4323 po=p;
4324 }
4325 else
4326 {
4327 // now po!=NULL, p!=NULL
4328 int d=(currRing->pFDeg(po,currRing)-(*w)[pGetComp(po)-1] - currRing->pFDeg(p,currRing)+(*w)[i-1]);
4329 if (d==0)
4330 d=pLmCmp(po,p);
4331 if (d > 0)
4332 {
4333 pDelete(&p);
4334 }
4335 else // (d < 0)
4336 {
4337 pDelete(&po); po=p;
4338 }
4339 }
4340 }
4341 if (delete_w) delete w;
4342 res->data=(void *)po;
4343 return FALSE;
4344}
4346{
4347 if (rField_is_Z(currRing))
4348 {
4349 PrintS("// NOTE: computation of Hilbert series etc. is being\n");
4350 PrintS("// performed for generic fibre, that is, over Q\n");
4351 }
4353 intvec *module_w=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
4354 //scHilbertPoly((ideal)v->Data(),currRing->qideal);
4355 hLookSeries((ideal)v->Data(),module_w,currRing->qideal);
4356 return FALSE;
4357}
4359{
4360 if (rField_is_Z(currRing))
4361 {
4362 PrintS("// NOTE: computation of Hilbert series etc. is being\n");
4363 PrintS("// performed for generic fibre, that is, over Q\n");
4364 }
4365 res->data=(void *)hSecondSeries((intvec *)v->Data());
4366 return FALSE;
4367}
4369{
4370 intvec *w=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
4371 ideal v_id=(ideal)v->Data();
4372 if (w==NULL)
4373 {
4374 res->data=(void *)(long)idHomModule(v_id,currRing->qideal,&w);
4375 if (res->data!=NULL)
4376 {
4377 if (v->rtyp==IDHDL)
4378 {
4379 char *s_isHomog=omStrDup("isHomog");
4380 if (v->e==NULL)
4381 atSet((idhdl)(v->data),s_isHomog,w,INTVEC_CMD);
4382 else
4383 atSet((idhdl)(v->LData()),s_isHomog,w,INTVEC_CMD);
4384 }
4385 else if (w!=NULL) delete w;
4386 } // if res->data==NULL then w==NULL
4387 }
4388 else
4389 {
4390 res->data=(void *)(long)idTestHomModule(v_id,currRing->qideal,w);
4391 if((res->data==NULL) && (v->rtyp==IDHDL))
4392 {
4393 if (v->e==NULL)
4394 atKill((idhdl)(v->data),"isHomog");
4395 else
4396 atKill((idhdl)(v->LData()),"isHomog");
4397 }
4398 }
4399 return FALSE;
4400}
4402{
4403#ifdef HAVE_SHIFTBBA
4404 if (rIsLPRing(currRing))
4405 {
4406 int deg = (int)(long)v->Data();
4407 if (deg > currRing->N/currRing->isLPring)
4408 {
4409 WerrorS("degree bound of Letterplace ring is to small");
4410 return TRUE;
4411 }
4412 }
4413#endif
4414 res->data = (char *)idMaxIdeal((int)(long)v->Data());
4416 return FALSE;
4417}
4419{
4420 matrix mat=(matrix)v->CopyD(MATRIX_CMD);
4421 IDELEMS((ideal)mat)=MATCOLS(mat)*MATROWS(mat);
4422 MATROWS(mat)=1;
4423 mat->rank=1;
4424 res->data=(char *)mat;
4425 return FALSE;
4426}
4428{
4429 map m=(map)v->CopyD(MAP_CMD);
4430 omFreeBinAddr((ADDRESS)m->preimage);
4431 m->preimage=NULL;
4432 ideal I=(ideal)m;
4433 I->rank=1;
4434 res->data=(char *)I;
4435 return FALSE;
4436}
4438{
4439 if (currRing!=NULL)
4440 {
4441 ring q=(ring)v->Data();
4442 if (rSamePolyRep(currRing, q))
4443 {
4444 if (q->qideal==NULL)
4445 res->data=(char *)idInit(1,1);
4446 else
4447 res->data=(char *)idCopy(q->qideal);
4448 return FALSE;
4449 }
4450 }
4451 WerrorS("can only get ideal from identical qring");
4452 return TRUE;
4453}
4455{
4456 intvec *iv = (intvec *)v->CopyD(INTMAT_CMD);
4457 iv->makeVector();
4458 res->data = iv;
4459 return FALSE;
4460}
4462{
4463 res->data = (char *)n_ImPart((number)v->Data(),currRing->cf);
4464 return FALSE;
4465}
4467{
4469 res->data=(void *)scIndIntvec((ideal)(v->Data()),currRing->qideal);
4470 return FALSE;
4471}
4473{
4474 ideal result=kInterRed((ideal)(v->Data()), currRing->qideal);
4475 if (TEST_OPT_PROT) { PrintLn(); mflush(); }
4476 res->data = result;
4477 return FALSE;
4478}
4480{
4481 bigintmat* aa= (bigintmat *)v->Data();
4482 int l=aa->cols();
4483 intvec *iv=new intvec(l);
4484 for(int i=0;i<l;i++) (*iv)[i]=iin_Int(BIMATELEM((*aa),1,i+1),coeffs_BIGINT);
4485 res->data = (void*)iv;
4486 return FALSE;
4487}
4489{
4490 res->data = (char *)(long)pVar((poly)v->Data());
4491 return FALSE;
4492}
4494{
4495 res->data = (char *)(long)(r_IsRingVar((char *)v->Data(), currRing->names,
4496 currRing->N)+1);
4497 return FALSE;
4498}
4500{
4501 res->data = (char *)0;
4502 return FALSE;
4503}
4505{
4506 ideal i=idInit(currRing->N,1);
4507 int k;
4508 poly p=(poly)(v->Data());
4509 for (k=currRing->N;k>0;k--)
4510 {
4511 i->m[k-1]=pDiff(p,k);
4512 }
4513 res->data = (char *)i;
4514 return FALSE;
4515}
4517{
4518 if (!nCoeff_is_transExt(currRing->cf))
4519 {
4520 WerrorS("differentiation not defined in the coefficient ring");
4521 return TRUE;
4522 }
4523 number n = (number) u->Data();
4524 number k = (number) v->Data();
4525 res->data = ntDiff(n,k,currRing->cf);
4526 return FALSE;
4527}
4528/*2
4529 * compute Jacobi matrix of a module/matrix
4530 * Jacobi(M) := ( diff(Mt,var(1))|, ... ,| diff(Mt,var(currRing->N)) ),
4531 * where Mt := transpose(M)
4532 * Note that this is consistent with the current conventions for jacob in Singular,
4533 * whereas M2 computes its transposed.
4534 */
4536{
4537 ideal id = (ideal)a->Data();
4538 id = id_Transp(id,currRing);
4539 int W = IDELEMS(id);
4540
4541 ideal result = idInit(W * currRing->N, id->rank);
4542 poly *p = result->m;
4543
4544 for( int v = 1; v <= currRing->N; v++ )
4545 {
4546 poly* q = id->m;
4547 for( int i = 0; i < W; i++, p++, q++ )
4548 *p = pDiff( *q, v );
4549 }
4550 idDelete(&id);
4551
4552 res->data = (char *)result;
4553 return FALSE;
4554}
4555
4557{
4558#ifdef HAVE_FLINT
4559 res->data = (char *)singflint_kernel((matrix)(v->Data()),currRing);
4560 return res->data==NULL;
4561#else
4562 return TRUE;
4563#endif
4564}
4566{
4567#ifdef HAVE_FLINT
4568 res->data = (char *)singflint_kernel((ideal)(v->Data()),currRing);
4569 return res->data==NULL;
4570#else
4571 return TRUE;
4572#endif
4573}
4575{
4577 res->data = (char *)scKBase(-1,(ideal)(v->Data()),currRing->qideal);
4578 return FALSE;
4579}
4581{
4582 res->data=(char *)syConvList((lists)v->Data());
4583 if (res->data != NULL)
4584 return FALSE;
4585 else
4586 return TRUE;
4587}
4589{
4590 poly p=(poly)v->Data();
4591 if (p==NULL)
4592 {
4593 res->data=(char *)nInit(0);
4594 }
4595 else
4596 {
4598 res->data=(char *)nCopy(pGetCoeff(p));
4599 }
4600 return FALSE;
4601}
4603{
4604 poly p=(poly)v->Data();
4605 int s=currRing->N;
4606 if (v->Typ()==VECTOR_CMD) s++;
4607 intvec *iv=new intvec(s);
4608 if (p!=NULL)
4609 {
4610 for(int i = currRing->N;i;i--)
4611 {
4612 (*iv)[i-1]=pGetExp(p,i);
4613 }
4614 if (s!=currRing->N)
4615 (*iv)[currRing->N]=pGetComp(p);
4616 }
4617 res->data=(char *)iv;
4618 return FALSE;
4619}
4621{
4622 poly p=(poly)v->Data();
4623 if (p == NULL)
4624 {
4625 res->data = (char*) NULL;
4626 }
4627 else
4628 {
4629 poly lm = pLmInit(p);
4630 pSetCoeff0(lm, nInit(1));
4631 res->data = (char*) lm;
4632 }
4633 return FALSE;
4634}
4635static BOOLEAN jjLOAD1(leftv /*res*/, leftv v)
4636{
4637 return jjLOAD((char*)v->Data(),FALSE);
4638}
4640{
4641 lists l=(lists)v->Data();
4642 long mm=(long)atGet(v,"maxExp",INT_CMD);
4643 int isLetterplace=(int)(long)atGet(v,"isLetterplaceRing",INT_CMD);
4644 ring r=rCompose(l,TRUE,mm,isLetterplace);
4645 res->data=(char *)r;
4646 return (r==NULL);
4647}
4649{
4650 /* call method jjPFAC2 with second argument = 0 (meaning that no
4651 valid bound for the prime factors has been given) */
4652 sleftv tmp;
4653 tmp.Init();
4654 tmp.rtyp = INT_CMD;
4655 return jjPFAC2(res, v, &tmp);
4656}
4658{
4659 sleftv a2,a3;
4660 a2.Init();
4661 a3.Init();
4662 a2.rtyp=INT_CMD; a2.data=(void*)10;
4663 a3.rtyp=INT_CMD; a3.data=(void*)1;
4664 return nuLagSolve(res,v,&a2,&a3);
4665}
4667{
4668 /* computes the LU-decomposition of a matrix M;
4669 i.e., M = P * L * U, where
4670 - P is a row permutation matrix,
4671 - L is in lower triangular form,
4672 - U is in upper row echelon form
4673 Then, we also have P * M = L * U.
4674 A list [P, L, U] is returned. */
4675 matrix mat = (matrix)v->Data();
4676 if (!idIsConstant((ideal)mat))
4677 {
4678 WerrorS("matrix must be constant");
4679 return TRUE;
4680 }
4681 matrix pMat;
4682 matrix lMat;
4683 matrix uMat;
4684
4685 luDecomp(mat, pMat, lMat, uMat);
4686
4688 ll->Init(3);
4689 ll->m[0].rtyp=MATRIX_CMD; ll->m[0].data=(void *)pMat;
4690 ll->m[1].rtyp=MATRIX_CMD; ll->m[1].data=(void *)lMat;
4691 ll->m[2].rtyp=MATRIX_CMD; ll->m[2].data=(void *)uMat;
4692 res->data=(char*)ll;
4693
4694 return FALSE;
4695}
4697{
4698 // clean out "_":
4699 sLastPrinted.CleanUp();
4700 // collect all info:
4701 omUpdateInfo();
4702 switch(((int)(long)v->Data()))
4703 {
4704 #ifdef HAVE_OMALLOC
4705 case 0:
4706 res->data=(char *)n_Init(om_Info.UsedBytes,coeffs_BIGINT);
4707 break;
4708 case 1:
4709 res->data = (char *)n_Init(om_Info.CurrentBytesSystem,coeffs_BIGINT);
4710 break;
4711 case 2:
4712 res->data = (char *)n_Init(om_Info.MaxBytesSystem,coeffs_BIGINT);
4713 break;
4714 #endif
4715 default:
4716 omPrintStats(stdout);
4717 omPrintInfo(stdout);
4718 omPrintBinStats(stdout);
4719 res->data = (char *)0;
4720 res->rtyp = NONE;
4721 }
4722 return FALSE;
4723}
4724//static BOOLEAN jjMONITOR1(leftv res, leftv v)
4725//{
4726// return jjMONITOR2(res,v,NULL);
4727//}
4729{
4730 int t=v->Typ();
4731 ideal r,m;
4732 r=kMin_std2((ideal)v->Data(),currRing->qideal,testHomog,NULL,m,NULL);
4734 l->Init(2);
4735 l->m[0].rtyp=t;
4736 l->m[0].data=(char *)r;
4737 setFlag(&(l->m[0]),FLAG_STD);
4738 l->m[1].rtyp=t;
4739 l->m[1].data=(char *)m;
4740 res->data=(char *)l;
4741 return FALSE;
4742}
4744{
4746 res->data = (char *)(long)scMultInt((ideal)(v->Data()),currRing->qideal);
4747 return FALSE;
4748}
4750{
4751 intvec *weights=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
4752
4753 syStrategy tmp=syCopy((syStrategy)v->Data());
4754 tmp = syMinimize(tmp); // enrich itself!
4755
4756 res->data=(char *)tmp;
4757
4758 if (weights!=NULL)
4759 atSet(res, omStrDup("isHomog"),ivCopy(weights),INTVEC_CMD);
4760
4761 return FALSE;
4762}
4764{
4765 number n,i; i=(number)v->Data();
4767 if (nMap!=NULL)
4768 n=nMap(i,currRing->cf,coeffs_BIGINT);
4769 else goto err;
4770 res->data=(void *)n;
4771 return FALSE;
4772err:
4773 WerrorS("cannot convert to bigint"); return TRUE;
4774}
4776{
4777 if ((v->rtyp==IDHDL)||(v->rtyp==ALIAS_CMD))
4778 res->data=omStrDup(v->name);
4779 else if (v->name==NULL)
4780 res->data=omStrDup("");
4781 else
4782 {
4783 res->data = (char *)v->name;
4784 v->name=NULL;
4785 }
4786 return FALSE;
4787}
4789{
4790 res->data=ipNameList(((ring)v->Data())->idroot);
4791 return FALSE;
4792}
4794{
4795 res->data=ipNameListLev((IDROOT),(int)(long)v->Data());
4796 return FALSE;
4797}
4799{
4800 res->data=(char*)(long)((long)v->Data()==0 ? 1 : 0);
4801 return FALSE;
4802}
4804{
4805 res->data = (char *)(long)(((ring)(v->Data()))->N);
4806 return FALSE;
4807}
4809{
4810 si_link l=(si_link)v->Data();
4811 if (iiOp==OPEN_CMD) return slOpen(l, SI_LINK_OPEN,v);
4812 else { slPrepClose(l); return slClose(l);}
4813}
4815{
4816 poly p=(poly)v->Data();
4817 res->data=(char *)( p==NULL ? -1 : currRing->pFDeg(p,currRing) );
4818 return FALSE;
4819}
4821{
4822 int i=(int)(long)v->Data();
4823 int p=0;
4824 p=rPar(currRing);
4825 if ((0<i) && (i<=p))
4826 {
4827 res->data=(char *)n_Param(i,currRing);
4828 }
4829 else
4830 {
4831 Werror("par number %d out of range 1..%d",i,p);
4832 return TRUE;
4833 }
4834 return FALSE;
4835}
4837{
4838 number nn=(number)v->Data();
4839 res->data = (char *)(long)n_ParDeg(nn, currRing->cf);
4840 return FALSE;
4841}
4843{
4844 if (currRing==NULL)
4845 {
4846 WerrorS("no ring active (1)");
4847 return TRUE;
4848 }
4849 int i=(int)(long)v->Data();
4850 int p=0;
4851 if ((0<i) && (rParameter(currRing)!=NULL) && (i<=(p=rPar(currRing))))
4852 res->data=omStrDup(rParameter(currRing)[i-1]);
4853 else
4854 {
4855 Werror("par number %d out of range 1..%d",i,p);
4856 return TRUE;
4857 }
4858 return FALSE;
4859}
4861{
4862 poly p=(poly)v->Data();
4863 if (p==NULL) { res->data=(char *)n_Init(0,coeffs_BIGINT); return FALSE; }
4864 if ((pNext(p)!=NULL)|| (!pIsConstant(p)))
4865 {
4866 WerrorS("poly must be constant");
4867 return TRUE;
4868 }
4869 number i=pGetCoeff(p);
4870 number n;
4872 if (nMap!=NULL)
4873 n=nMap(i,currRing->cf,coeffs_BIGINT);
4874 else goto err;
4875 res->data=(void *)n;
4876 return FALSE;
4877err:
4878 WerrorS("cannot convert to bigint"); return TRUE;
4879}
4881{
4882 poly p=(poly)v->Data();
4883 if (p==NULL) { /*res->data=(char *)0;*/ return FALSE; }
4884 if ((pNext(p)!=NULL)|| (!pIsConstant(p)))
4885 {
4886 WerrorS("poly must be constant");
4887 return TRUE;
4888 }
4889 res->data = (char *)(long)iin_Int(pGetCoeff(p),currRing->cf);
4890 return FALSE;
4891}
4893{
4894 map mapping=(map)v->Data();
4895 syMake(res,omStrDup(mapping->preimage));
4896 return FALSE;
4897}
4899{
4900 int i = IsPrime((int)(long)(v->Data()));
4901 res->data = (char *)(long)(i > 1 ? i : 2);
4902 return FALSE;
4903}
4905{
4906 intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
4907 ideal v_id=(ideal)v->Data();
4908 if (w!=NULL)
4909 {
4910 if (!idTestHomModule(v_id,currRing->qideal,w))
4911 {
4912 WarnS("wrong weights");
4913 w=NULL;
4914 // and continue at the non-homog case below
4915 }
4916 else
4917 {
4918 w=ivCopy(w);
4919 intvec **ww=&w;
4920 res->data = (char *)idMinEmbedding(v_id,FALSE,ww);
4921 atSet(res,omStrDup("isHomog"),*ww,INTVEC_CMD);
4922 return FALSE;
4923 }
4924 }
4925 res->data = (char *)idMinEmbedding(v_id);
4926 return FALSE;
4927}
4929{
4930 number n;
4931 poly p;
4932 if (((p=(poly)v->Data())!=NULL)
4933 && (pIsConstant(p)))
4934 {
4935 n=nCopy(pGetCoeff(p));
4936 }
4937 else
4938 {
4939 n=nInit(0);
4940 }
4941 res->data = (char *)n;
4942 return FALSE;
4943}
4945{
4946 char *s= (char *)v->Data();
4947 // try system keywords
4948 for(unsigned i=0; i<sArithBase.nCmdUsed; i++)
4949 {
4950 //Print("test %d, >>%s<<, tab:>>%s<<\n",i,s,sArithBase.sCmds[i].name);
4951 if (strcmp(s, sArithBase.sCmds[i].name) == 0)
4952 {
4953 res->data = (char *)1;
4954 return FALSE;
4955 }
4956 }
4957 // try blackbox names
4958 int id;
4959 blackboxIsCmd(s,id);
4960 if (id>0)
4961 {
4962 res->data = (char *)1;
4963 }
4964 return FALSE;
4965}
4967{
4968 matrix m =(matrix)v->Data();
4969 int rank = luRank(m, 0);
4970 res->data =(char *)(long)rank;
4971 return FALSE;
4972}
4974{
4975 return jjREAD2(res,v,NULL);
4976}
4978{
4979 res->data = (char *)(long)iiRegularity((lists)v->Data());
4980 return FALSE;
4981}
4983{
4984 res->data = (char *)n_RePart((number)v->Data(),currRing->cf);
4985 return FALSE;
4986}
4988{
4989 ring r=(ring)v->Data();
4990 if (r!=NULL)
4991 {
4992 res->data = (char *)rDecompose((ring)v->Data());
4993 if (res->data!=NULL)
4994 {
4995 long mm=r->wanted_maxExp;
4996 if (mm!=0) atSet(res,omStrDup("maxExp"),(void*)mm,INT_CMD);
4997 return FALSE;
4998 }
4999 }
5000 return TRUE;
5001}
5003{
5004 coeffs r=(coeffs)v->Data();
5005 if (r!=NULL)
5006 return rDecompose_CF(res,r);
5007 return TRUE;
5008}
5010{
5011 ring r=(ring)v->Data();
5012 if (r!=NULL)
5013 res->data = (char *)rDecompose_list_cf((ring)v->Data());
5014 return (r==NULL)||(res->data==NULL);
5015}
5017{
5018 ideal i = (ideal)v->Data();
5019 res->data = (char *)i->rank;
5020 return FALSE;
5021}
5023{
5024 res->data = (char *)(long)((bigintmat*)(v->Data()))->rows();
5025 return FALSE;
5026}
5028{
5029 res->data = (char *)(long)((intvec*)(v->Data()))->rows();
5030 return FALSE;
5031}
5033{
5034 res->data = (char *)(long)rPar(((ring)v->Data()));
5035 return FALSE;
5036}
5038{
5039 res->data = (char *)(long)atoi((char*)v->Data());
5040 return FALSE;
5041}
5043{
5044 const bool bIsSCA = rIsSCA(currRing);
5045
5046 if ((currRing->qideal!=NULL) && !bIsSCA)
5047 {
5048 WerrorS("qring not supported by slimgb at the moment");
5049 return TRUE;
5050 }
5052 {
5053 WerrorS("ordering must be global for slimgb");
5054 return TRUE;
5055 }
5057 WarnS("groebner base computations with inexact coefficients can not be trusted due to rounding errors");
5058 intvec *w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
5059 // tHomog hom=testHomog;
5060 ideal u_id=(ideal)u->Data();
5061 if (w!=NULL)
5062 {
5063 if (!idTestHomModule(u_id,currRing->qideal,w))
5064 {
5065 WarnS("wrong weights");
5066 w=NULL;
5067 }
5068 else
5069 {
5070 w=ivCopy(w);
5071 // hom=isHomog;
5072 }
5073 }
5074
5075 assume(u_id->rank>=id_RankFreeModule(u_id, currRing));
5076 res->data=(char *)t_rep_gb(currRing,
5077 u_id,u_id->rank);
5078 //res->data=(char *)t_rep_gb(currRing, u_id);
5079
5081 if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
5082 return FALSE;
5083}
5085{
5086 ideal result;
5087 ideal v_id=(ideal)v->Data();
5088 intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
5089 tHomog hom=testHomog;
5090 if (w!=NULL)
5091 {
5092 if (!idTestHomModule(v_id,currRing->qideal,w))
5093 {
5094 WarnS("wrong weights");
5095 w=NULL;
5096 }
5097 else
5098 {
5099 hom=isHomog;
5100 w=ivCopy(w);
5101 }
5102 }
5103 result=kSba(v_id,currRing->qideal,hom,&w,1,0,NULL);
5104 if (errorreported) return TRUE;
5106 res->data = (char *)result;
5108 if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
5109 return FALSE;
5110}
5112{
5113 ideal result;
5114 ideal v_id=(ideal)v->Data();
5115 intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
5116 tHomog hom=testHomog;
5117 if (w!=NULL)
5118 {
5119 if (!idTestHomModule(v_id,currRing->qideal,w))
5120 {
5121 WarnS("wrong weights");
5122 w=NULL;
5123 }
5124 else
5125 {
5126 hom=isHomog;
5127 w=ivCopy(w);
5128 }
5129 }
5130 result=kSba(v_id,currRing->qideal,hom,&w,(int)(long)u->Data(),0,NULL);
5131 if (errorreported) return TRUE;
5133 res->data = (char *)result;
5135 if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
5136 return FALSE;
5137}
5139{
5140 ideal result;
5141 ideal v_id=(ideal)v->Data();
5142 intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
5143 tHomog hom=testHomog;
5144 if (w!=NULL)
5145 {
5146 if (!idTestHomModule(v_id,currRing->qideal,w))
5147 {
5148 WarnS("wrong weights");
5149 w=NULL;
5150 }
5151 else
5152 {
5153 hom=isHomog;
5154 w=ivCopy(w);
5155 }
5156 }
5157 result=kSba(v_id,currRing->qideal,hom,&w,(int)(long)u->Data(),(int)(long)t->Data(),NULL);
5158 if (errorreported) return TRUE;
5160 res->data = (char *)result;
5162 if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
5163 return FALSE;
5164}
5166{
5168 WarnS("groebner base computations with inexact coefficients can not be trusted due to rounding errors");
5169 ideal result;
5170 ideal v_id=(ideal)v->Data();
5171 intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
5172 tHomog hom=testHomog;
5173 if (w!=NULL)
5174 {
5175 if (!idTestHomModule(v_id,currRing->qideal,w))
5176 {
5177 WarnS("wrong weights");
5178 w=NULL;
5179 }
5180 else
5181 {
5182 hom=isHomog;
5183 w=ivCopy(w);
5184 }
5185 }
5186 result=kStd2(v_id,currRing->qideal,hom,&w,(bigintmat*)NULL);
5187 if (errorreported) return TRUE;
5189 res->data = (char *)result;
5191 if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD);
5192 return FALSE;
5193}
5195{
5196 res->data = (char *)idSort((ideal)v->Data());
5197 return FALSE;
5198}
5200{
5202 intvec *v=NULL;
5203 ideal f=singclap_sqrfree((poly)(u->CopyD()), &v, 0, currRing);
5204 if (f==NULL) return TRUE;
5205 ivTest(v);
5207 l->Init(2);
5208 l->m[0].rtyp=IDEAL_CMD;
5209 l->m[0].data=(void *)f;
5210 l->m[1].rtyp=INTVEC_CMD;
5211 l->m[1].data=(void *)v;
5212 res->data=(void *)l;
5213 return FALSE;
5214}
5215#if 0
5217{
5218 intvec *w=NULL;
5219 res->data = (char *)idSyzygies((ideal)v->Data(),testHomog,&w);
5220 if (w!=NULL) delete w;
5222 return FALSE;
5223}
5224#else
5225// activate, if idSyz handle module weights correctly !
5227{
5228 ideal v_id=(ideal)v->Data();
5229#ifdef HAVE_SHIFTBBA
5230 if (rIsLPRing(currRing))
5231 {
5232 if (currRing->LPncGenCount < IDELEMS(v_id))
5233 {
5234 Werror("At least %d ncgen variables are needed for this computation.", IDELEMS(v_id));
5235 return TRUE;
5236 }
5237 }
5238#endif
5239 intvec *ww=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
5240 intvec *w=NULL;
5241 tHomog hom=testHomog;
5242 if (ww!=NULL)
5243 {
5244 if (idTestHomModule(v_id,currRing->qideal,ww))
5245 {
5246 w=ivCopy(ww);
5247 int add_row_shift=w->min_in();
5248 (*w)-=add_row_shift;
5249 hom=isHomog;
5250 }
5251 else
5252 {
5253 //WarnS("wrong weights");
5254 delete ww; ww=NULL;
5255 hom=testHomog;
5256 }
5257 }
5258 else
5259 {
5260 if (v->Typ()==IDEAL_CMD)
5261 if (idHomIdeal(v_id,currRing->qideal))
5262 hom=isHomog;
5263 }
5264 ideal S=idSyzygies(v_id,hom,&w);
5265 res->data = (char *)S;
5266 if (hom==isHomog)
5267 {
5268 int vl=S->rank;
5269 intvec *vv=new intvec(vl);
5270 if ((v->Typ()==IDEAL_CMD)||(ww==NULL))
5271 {
5272 for(int i=0;i<vl;i++)
5273 {
5274 if (v_id->m[i]!=NULL)
5275 (*vv)[i]=p_Deg(v_id->m[i],currRing);
5276 }
5277 }
5278 else
5279 {
5280 p_SetModDeg(ww, currRing);
5281 for(int i=0;i<vl;i++)
5282 {
5283 if (v_id->m[i]!=NULL)
5284 (*vv)[i]=currRing->pFDeg(v_id->m[i],currRing);
5285 }
5287 }
5288 if (idTestHomModule(S,currRing->qideal,vv))
5289 atSet(res,omStrDup("isHomog"),vv,INTVEC_CMD);
5290 else
5291 delete vv;
5292 }
5293 if (w!=NULL) delete w;
5294 return FALSE;
5295}
5296#endif
5298{
5299 res->data = (char *)(long)ivTrace((intvec*)(v->Data()));
5300 return FALSE;
5301}
5303{
5304 res->data = (char *)(((bigintmat*)(v->Data()))->transpose());
5305 return FALSE;
5306}
5308{
5309 res->data = (char *)ivTranp((intvec*)(v->Data()));
5310 return FALSE;
5311}
5313{
5314#ifdef HAVE_PLURAL
5315 ring r = (ring)a->Data();
5316 //if (rIsPluralRing(r))
5317 if (r->OrdSgn==1)
5318 {
5319 res->data = rOpposite(r);
5320 }
5321 else
5322 {
5323 WarnS("opposite only for global orderings");
5324 res->data = rCopy(r);
5325 }
5326 return FALSE;
5327#else
5328 return TRUE;
5329#endif
5330}
5332{
5333#ifdef HAVE_PLURAL
5334 ring r = (ring)a->Data();
5335 if (rIsPluralRing(r))
5336 {
5337 ring s = rEnvelope(r);
5338 res->data = s;
5339 }
5340 else res->data = rCopy(r);
5341 return FALSE;
5342#else
5343 return TRUE;
5344#endif
5345}
5347{
5348#ifdef HAVE_PLURAL
5349 ideal result;
5350 ideal v_id=(ideal)a->Data();
5352 result=(ideal)twostd(v_id);
5353 else /*commutative or shiftalgebra*/
5354 {
5355 return jjSTD(res,a);
5356 }
5357 res->data = (char *)result;
5360 return FALSE;
5361#else
5362 return TRUE;
5363#endif
5364}
5366{
5367#if defined(HAVE_SHIFTBBA) || defined(HAVE_PLURAL)// do not place above jjSTD in this file because we need to reference it
5368 if (rIsLPRing(currRing))
5369 {
5371 WarnS("groebner base computations with inexact coefficients can not be trusted due to rounding errors");
5372 ideal result;
5373 ideal v_id=(ideal)v->Data();
5374 /* intvec *w=(intvec *)atGet(v,"isHomog",INTVEC_CMD); */
5375 /* tHomog hom=testHomog; */
5376 /* if (w!=NULL) */
5377 /* { */
5378 /* if (!idTestHomModule(v_id,currRing->qideal,w)) */
5379 /* { */
5380 /* WarnS("wrong weights"); */
5381 /* w=NULL; */
5382 /* } */
5383 /* else */
5384 /* { */
5385 /* hom=isHomog; */
5386 /* w=ivCopy(w); */
5387 /* } */
5388 /* } */
5389 /* result=kStd2(v_id,currRing->qideal,hom,&w); */
5390 result = rightgb(v_id, currRing->qideal);
5391 if (errorreported) return TRUE;
5393 res->data = (char *)result;
5395 /* if (w!=NULL) atSet(res,omStrDup("isHomog"),w,INTVEC_CMD); */
5396 return FALSE;
5397 }
5398 else if (rIsPluralRing(currRing))
5399 {
5400 ideal I=(ideal)v->Data();
5401
5402 ring A = currRing;
5403 ring Aopp = rOpposite(A);
5404 currRing = Aopp;
5405 ideal Iopp = idOppose(A, I, Aopp);
5406 ideal Jopp = kStd2(Iopp,currRing->qideal,testHomog,NULL,(bigintmat*)NULL);
5407 if (errorreported) return TRUE;
5408 currRing = A;
5409 ideal J = idOppose(Aopp, Jopp, A);
5410
5411 id_Delete(&Iopp, Aopp);
5412 id_Delete(&Jopp, Aopp);
5413 rDelete(Aopp);
5414
5415 idSkipZeroes(J);
5416 res->data = (char *)J;
5418 return FALSE;
5419 }
5420 else
5421 {
5422 return jjSTD(res, v);
5423 }
5424#else
5425 return TRUE;
5426#endif
5427}
5429{
5430 int t=(int)(long)v->data;
5431 switch (t)
5432 {
5433 case CRING_CMD:
5434 case INT_CMD:
5435 case POLY_CMD:
5436 case VECTOR_CMD:
5437 case STRING_CMD:
5438 case INTVEC_CMD:
5439 case IDEAL_CMD:
5440 case MATRIX_CMD:
5441 case MODUL_CMD:
5442 case MAP_CMD:
5443 case PROC_CMD:
5444 case RING_CMD:
5445 case SMATRIX_CMD:
5446 //case QRING_CMD:
5447 case INTMAT_CMD:
5448 case BIGINTMAT_CMD:
5449 case BIGINTVEC_CMD:
5450 case NUMBER_CMD:
5451 #ifdef SINGULAR_4_2
5452 case CNUMBER_CMD:
5453 #endif
5454 case BIGINT_CMD:
5455 case BUCKET_CMD:
5456 case LIST_CMD:
5457 case PACKAGE_CMD:
5458 case LINK_CMD:
5459 case RESOLUTION_CMD:
5460 #ifdef HTABLE
5461 case HTABLE_CMD:
5462 #endif
5463 res->data=omStrDup(Tok2Cmdname(t)); break;
5464 case DEF_CMD:
5465 case NONE: res->data=omStrDup("none"); break;
5466 default:
5467 {
5468 if (t>MAX_TOK)
5469 res->data=omStrDup(getBlackboxName(t));
5470 else
5471 res->data=omStrDup("?unknown type?");
5472 break;
5473 }
5474 }
5475 return FALSE;
5476}
5478{
5479 res->data=(char *)(long)pIsUnivariate((poly)v->Data());
5480 return FALSE;
5481}
5483{
5484 int i=(int)(long)v->Data();
5485 if ((0<i) && (i<=currRing->N))
5486 {
5487 poly p=pOne();
5488 pSetExp(p,i,1);
5489 pSetm(p);
5490 res->data=(char *)p;
5491 }
5492 else
5493 {
5494 Werror("var number %d out of range 1..%d",i,currRing->N);
5495 return TRUE;
5496 }
5497 return FALSE;
5498}
5500{
5501 if (currRing==NULL)
5502 {
5503 WerrorS("no ring active (2)");
5504 return TRUE;
5505 }
5506 int i=(int)(long)v->Data();
5507 if ((0<i) && (i<=currRing->N))
5508 res->data=omStrDup(currRing->names[i-1]);
5509 else
5510 {
5511 Werror("var number %d out of range 1..%d",i,currRing->N);
5512 return TRUE;
5513 }
5514 return FALSE;
5515}
5517{
5519#ifdef HAVE_SHIFTBBA
5520 if (rIsLPRing(currRing))
5521 {
5523 {
5524 WerrorS("`vdim` is not implemented for letterplace rings over rings");
5525 return TRUE;
5526 }
5527 if (currRing->qideal != NULL)
5528 {
5529 WerrorS("qring not supported by `vdim` for letterplace rings at the moment");
5530 return TRUE;
5531 }
5532 int kDim = lp_kDim((ideal)(v->Data()));
5533 res->data = (char *)(long)kDim;
5534 return (kDim == -2);
5535 }
5536#endif
5537 long l=scMult0Int((ideal)v->Data(),currRing->qideal);
5538 if (l<-1L)
5539 WerrorS("int overflow in vdim");
5540 res->data = (char *)l;
5541 return FALSE;
5542}
5544{
5545// input: u: a list with links of type
5546// ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
5547// returns: -1: the read state of all links is eof or error
5548// i>0: (at least) u[i] is ready
5549 lists L = (lists)u->Data();
5550 int i = slStatusSsiL(L, -1);
5551 if(i == -2) /* error */
5552 {
5553 return TRUE;
5554 }
5555 res->data = (void*)(long)i;
5556 return FALSE;
5557}
5559{
5560// input: u: a list with links of type
5561// ssi-fork, ssi-tcp, MPtcp-fork or MPtcp-launch
5562// returns: -1: the read state of all links is eof or error
5563// 1: all links are ready
5564// (caution: at least one is ready, but some maybe dead)
5565 lists L = (lists)u->Data();
5566 int i;
5567 int j = -1;
5568 BOOLEAN* ignore=(BOOLEAN*)omAlloc0((L->nr+1)*sizeof(BOOLEAN));
5569 for(int nfinished = 0; nfinished <= L->nr; nfinished++)
5570 {
5571 i = slStatusSsiL(L, -1, ignore);
5572 if(i == -2) /* error */
5573 {
5574 omFreeSize(ignore,(L->nr+1)*sizeof(BOOLEAN));
5575 return TRUE;
5576 }
5577 if((i == -1)||(j==0))
5578 {
5579 j=-1;
5580 break;
5581 }
5582 if (i>0)
5583 {
5584 j=1;
5585 ignore[i-1]=TRUE;
5586 }
5587 }
5588 omFreeSize(ignore,(L->nr+1)*sizeof(BOOLEAN));
5589 res->data = (void*)(long)j;
5590 return FALSE;
5591}
5592
5593BOOLEAN jjLOAD(const char *s, BOOLEAN autoexport)
5594{
5595 char libnamebuf[1024];
5597
5598#ifdef HAVE_DYNAMIC_LOADING
5599 extern BOOLEAN load_modules(const char *newlib, char *fullpath, BOOLEAN autoexport);
5600#endif /* HAVE_DYNAMIC_LOADING */
5601 switch(LT)
5602 {
5603 default:
5604 case LT_NONE:
5605 Werror("%s: unknown type", s);
5606 break;
5607 case LT_NOTFOUND:
5608 Werror("cannot open %s", s);
5609 break;
5610
5611 case LT_SINGULAR:
5612 {
5613 char *plib = iiConvName(s);
5614 idhdl pl = IDROOT->get_level(plib,0);
5615 if (pl==NULL)
5616 {
5617 pl = enterid( plib,0, PACKAGE_CMD, &(basePack->idroot), TRUE );
5618 IDPACKAGE(pl)->language = LANG_SINGULAR;
5619 IDPACKAGE(pl)->libname=omStrDup(s);
5620 }
5621 else if (IDTYP(pl)!=PACKAGE_CMD)
5622 {
5623 Werror("can not create package `%s`",plib);
5624 omFreeBinAddr(plib);
5625 return TRUE;
5626 }
5627 else /* package */
5628 {
5629 package pa=IDPACKAGE(pl);
5630 if ((pa->language==LANG_C)
5631 || (pa->language==LANG_MIX))
5632 {
5633 Werror("can not create package `%s` - binaries exists",plib);
5634 omFreeBinAddr(plib);
5635 return TRUE;
5636 }
5637 }
5638 omFreeBinAddr(plib);
5639 package savepack=currPack;
5640 currPack=IDPACKAGE(pl);
5641 IDPACKAGE(pl)->loaded=TRUE;
5642 char libnamebuf[1024];
5643 FILE * fp = feFopen( s, "r", libnamebuf, TRUE );
5644 BOOLEAN bo=iiLoadLIB(fp, libnamebuf, s, pl, autoexport, TRUE);
5645 currPack=savepack;
5646 IDPACKAGE(pl)->loaded=(!bo);
5647 return bo;
5648 }
5649 case LT_BUILTIN:
5650 SModulFunc_t iiGetBuiltinModInit(const char*);
5651 return load_builtin(s,autoexport, iiGetBuiltinModInit(s));
5652 case LT_MACH_O:
5653 case LT_ELF:
5654 case LT_HPUX:
5655#ifdef HAVE_DYNAMIC_LOADING
5656 return load_modules(s, libnamebuf, autoexport);
5657#else /* HAVE_DYNAMIC_LOADING */
5658 WerrorS("Dynamic modules are not supported by this version of Singular");
5659 break;
5660#endif /* HAVE_DYNAMIC_LOADING */
5661 }
5662 return TRUE;
5663}
5665static void WerrorS_dummy(const char *)
5666{
5668}
5670{
5671 if (!iiGetLibStatus(s))
5672 {
5673 void (*WerrorS_save)(const char *s) = WerrorS_callback;
5676 BOOLEAN bo=jjLOAD(s,TRUE);
5677 if (TEST_OPT_PROT && (bo || (WerrorS_dummy_cnt>0)))
5678 Print("loading of >%s< failed\n",s);
5679 WerrorS_callback=WerrorS_save;
5680 errorreported=0;
5681 }
5682 return FALSE;
5683}
5684
5686{
5687 res->data = (char *)strlen((char *)v->Data());
5688 return FALSE;
5689}
5691{
5692 res->data = (char *)(long)pLength((poly)v->Data());
5693 return FALSE;
5694}
5696{
5697 res->data = (char *)(long)idElem((ideal)v->Data());
5698 return FALSE;
5699}
5701{
5702 res->data = (char *)id_FreeModule((int)(long)v->Data(), currRing);
5703 return FALSE;
5704}
5706{
5707 res->data = (char *)id_Vec2Ideal((poly)v->Data(), currRing);
5708 return FALSE;
5709}
5711{
5712 res->data = rCharStr((ring)v->Data());
5713 return FALSE;
5714}
5716{
5717 res->data = (char *)pHead((poly)v->Data());
5718 return FALSE;
5719}
5721{
5722 res->data = (char *)id_Head((ideal)v->Data(),currRing);
5724 return FALSE;
5725}
5727{
5728 res->data = (char *)idMinBase((ideal)v->Data());
5729 return FALSE;
5730}
5731#if 0 // unused
5732static BOOLEAN jjsyMinBase(leftv res, leftv v)
5733{
5734 res->data = (char *)syMinBase((ideal)v->Data());
5735 return FALSE;
5736}
5737#endif
5739{
5740 res->data = (char *)pMaxComp((poly)v->Data());
5741 return FALSE;
5742}
5744{
5745 res->data = (char *)mp_Trace((matrix)v->Data(),currRing);
5746 return FALSE;
5747}
5749{
5750 res->data = (char *)mp_Transp((matrix)v->Data(),currRing);
5751 return FALSE;
5752}
5754{
5755 res->data = rOrdStr((ring)v->Data());
5756 return FALSE;
5757}
5759{
5760 res->data = rVarStr((ring)v->Data());
5761 return FALSE;
5762}
5764{
5765 res->data = rParStr((ring)v->Data());
5766 return FALSE;
5767}
5769{
5770 res->data=(char *)(long)sySize((syStrategy)v->Data());
5771 return FALSE;
5772}
5774{
5775 res->data = (char *)(long)syDim((syStrategy)v->Data());
5776 return FALSE;
5777}
5779{
5780 res->data = (char *)id_Transp((ideal)v->Data(),currRing);
5781 return FALSE;
5782}
5784{
5785 number n=(number)u->CopyD(); // n_Int may call n_Normalize
5786 res->data=(char *)(long)iin_Int(n,currRing->cf);
5787 n_Delete(&n,currRing->cf);
5788 return FALSE;
5789}
5791{
5792 number n=(number)u->Data();
5793 res->data=(char *)(long)iin_Int(n,coeffs_BIGINT );
5794 return FALSE;
5795}
5796/*=================== operations with 3 args.: static proc =================*/
5797/* must be ordered: first operations for chars (infix ops),
5798 * then alphabetically */
5800{
5801 char *s= (char *)u->Data();
5802 int r = (int)(long)v->Data();
5803 int c = (int)(long)w->Data();
5804 int l = strlen(s);
5805
5806 if ( (r<1) || (r>l) || (c<0) )
5807 {
5808 Werror("wrong range[%d,%d] in string %s",r,c,u->Fullname());
5809 return TRUE;
5810 }
5811 res->data = (char *)omAlloc((long)(c+1));
5812 snprintf((char *)res->data,c+1,"%-*.*s",c,c,s+r-1);
5813 return FALSE;
5814}
5816{
5817 intvec *iv = (intvec *)u->Data();
5818 int r = (int)(long)v->Data();
5819 int c = (int)(long)w->Data();
5820 if ((r<1)||(r>iv->rows())||(c<1)||(c>iv->cols()))
5821 {
5822 Werror("wrong range[%d,%d] in intmat %s(%d x %d)",
5823 r,c,u->Fullname(),iv->rows(),iv->cols());
5824 return TRUE;
5825 }
5826 res->data=u->data; u->data=NULL;
5827 res->rtyp=u->rtyp; u->rtyp=0;
5828 res->name=u->name; u->name=NULL;
5829 Subexpr e=jjMakeSub(v);
5830 e->next=jjMakeSub(w);
5831 if (u->e==NULL) res->e=e;
5832 else
5833 {
5834 Subexpr h=u->e;
5835 while (h->next!=NULL) h=h->next;
5836 h->next=e;
5837 res->e=u->e;
5838 u->e=NULL;
5839 }
5840 return FALSE;
5841}
5843{
5844 bigintmat *bim = (bigintmat *)u->Data();
5845 int r = (int)(long)v->Data();
5846 int c = (int)(long)w->Data();
5847 if ((r<1)||(r>bim->rows())||(c<1)||(c>bim->cols()))
5848 {
5849 Werror("wrong range[%d,%d] in bigintmat %s(%d x %d)",
5850 r,c,u->Fullname(),bim->rows(),bim->cols());
5851 return TRUE;
5852 }
5853 res->data=u->data; u->data=NULL;
5854 res->rtyp=u->rtyp; u->rtyp=0;
5855 res->name=u->name; u->name=NULL;
5856 Subexpr e=jjMakeSub(v);
5857 e->next=jjMakeSub(w);
5858 if (u->e==NULL)
5859 res->e=e;
5860 else
5861 {
5862 Subexpr h=u->e;
5863 while (h->next!=NULL) h=h->next;
5864 h->next=e;
5865 res->e=u->e;
5866 u->e=NULL;
5867 }
5868 return FALSE;
5869}
5871{
5872 matrix m= (matrix)u->Data();
5873 int r = (int)(long)v->Data();
5874 int c = (int)(long)w->Data();
5875 //Print("gen. elem %d, %d\n",r,c);
5876 if ((r<1)||(r>MATROWS(m))||(c<1)||(c>MATCOLS(m)))
5877 {
5878 Werror("wrong range[%d,%d] in matrix %s(%d x %d)",r,c,u->Fullname(),
5879 MATROWS(m),MATCOLS(m));
5880 return TRUE;
5881 }
5882 res->data=u->data; u->data=NULL;
5883 res->rtyp=u->rtyp; u->rtyp=0;
5884 res->name=u->name; u->name=NULL;
5885 Subexpr e=jjMakeSub(v);
5886 e->next=jjMakeSub(w);
5887 if (u->e==NULL)
5888 res->e=e;
5889 else
5890 {
5891 Subexpr h=u->e;
5892 while (h->next!=NULL) h=h->next;
5893 h->next=e;
5894 res->e=u->e;
5895 u->e=NULL;
5896 }
5897 return FALSE;
5898}
5900{
5901 ideal m= (ideal)u->Data();
5902 int r = (int)(long)v->Data();
5903 int c = (int)(long)w->Data();
5904 //Print("gen. elem %d, %d\n",r,c);
5905 if ((r<1)||(r>m->rank)||(c<1)||(c>IDELEMS(m)))
5906 {
5907 Werror("wrong range[%d,%d] in matrix %s(%d x %d)",r,c,u->Fullname(),
5908 (int)m->rank,IDELEMS(m));
5909 return TRUE;
5910 }
5911 res->data=u->data; u->data=NULL;
5912 res->rtyp=u->rtyp; u->rtyp=0;
5913 res->name=u->name; u->name=NULL;
5914 Subexpr e=jjMakeSub(v);
5915 e->next=jjMakeSub(w);
5916 if (u->e==NULL)
5917 res->e=e;
5918 else
5919 {
5920 Subexpr h=u->e;
5921 while (h->next!=NULL) h=h->next;
5922 h->next=e;
5923 res->e=u->e;
5924 u->e=NULL;
5925 }
5926 return FALSE;
5927}
5929{
5930 if ((u->rtyp!=IDHDL)||(u->e!=NULL))
5931 {
5932 WerrorS("cannot build expression lists from unnamed objects");
5933 return TRUE;
5934 }
5935
5936 leftv p=NULL;
5937 intvec *iv=(intvec *)w->Data();
5938 int l;
5939 BOOLEAN nok;
5940 sleftv ut;
5941 memcpy(&ut,u,sizeof(ut));
5942 sleftv t;
5943 t.Init();
5944 t.rtyp=INT_CMD;
5945 for (l=0;l< iv->length(); l++)
5946 {
5947 t.data=(char *)(long)((*iv)[l]);
5948 if (p==NULL)
5949 {
5950 p=res;
5951 }
5952 else
5953 {
5954 p->next=(leftv)omAlloc0Bin(sleftv_bin);
5955 p=p->next;
5956 }
5957 memcpy(u,&ut,sizeof(ut));
5958 if (u->Typ() == MATRIX_CMD)
5959 nok=jjBRACK_Ma(p,u,v,&t);
5960 else if (u->Typ() == BIGINTMAT_CMD)
5961 nok=jjBRACK_Bim(p,u,v,&t);
5962 else /* INTMAT_CMD */
5963 nok=jjBRACK_Im(p,u,v,&t);
5964 if (nok)
5965 {
5966 while (res->next!=NULL)
5967 {
5968 p=res->next->next;
5970 // res->e aufraeumen !!!!
5971 res->next=p;
5972 }
5973 return TRUE;
5974 }
5975 }
5976 return FALSE;
5977}
5979{
5980 if ((u->rtyp!=IDHDL)||(u->e!=NULL))
5981 {
5982 WerrorS("cannot build expression lists from unnamed objects");
5983 return TRUE;
5984 }
5985 leftv p=NULL;
5986 intvec *iv=(intvec *)v->Data();
5987 int l;
5988 BOOLEAN nok;
5989 sleftv ut;
5990 memcpy(&ut,u,sizeof(ut));
5991 sleftv t;
5992 t.Init();
5993 t.rtyp=INT_CMD;
5994 for (l=0;l< iv->length(); l++)
5995 {
5996 t.data=(char *)(long)((*iv)[l]);
5997 if (p==NULL)
5998 {
5999 p=res;
6000 }
6001 else
6002 {
6003 p->next=(leftv)omAlloc0Bin(sleftv_bin);
6004 p=p->next;
6005 }
6006 memcpy(u,&ut,sizeof(ut));
6007 if (u->Typ() == MATRIX_CMD)
6008 nok=jjBRACK_Ma(p,u,&t,w);
6009 else if (u->Typ() == BIGINTMAT_CMD)
6010 nok=jjBRACK_Bim(p,u,&t,w);
6011 else /* INTMAT_CMD */
6012 nok=jjBRACK_Im(p,u,&t,w);
6013 if (nok)
6014 {
6015 while (res->next!=NULL)
6016 {
6017 p=res->next->next;
6019 // res->e aufraeumen !!
6020 res->next=p;
6021 }
6022 return TRUE;
6023 }
6024 }
6025 return FALSE;
6026}
6028{
6029 if ((u->rtyp!=IDHDL)||(u->e!=NULL))
6030 {
6031 WerrorS("cannot build expression lists from unnamed objects");
6032 return TRUE;
6033 }
6034 leftv p=NULL;
6035 intvec *vv=(intvec *)v->Data();
6036 intvec *wv=(intvec *)w->Data();
6037 int vl;
6038 int wl;
6039 BOOLEAN nok;
6040
6041 sleftv t1,t2,ut;
6042 memcpy(&ut,u,sizeof(ut));
6043 t1.Init();
6044 t1.rtyp=INT_CMD;
6045 t2.Init();
6046 t2.rtyp=INT_CMD;
6047 for (vl=0;vl< vv->length(); vl++)
6048 {
6049 t1.data=(char *)(long)((*vv)[vl]);
6050 for (wl=0;wl< wv->length(); wl++)
6051 {
6052 t2.data=(char *)(long)((*wv)[wl]);
6053 if (p==NULL)
6054 {
6055 p=res;
6056 }
6057 else
6058 {
6059 p->next=(leftv)omAlloc0Bin(sleftv_bin);
6060 p=p->next;
6061 }
6062 memcpy(u,&ut,sizeof(ut));
6063 if (u->Typ() == MATRIX_CMD)
6064 nok=jjBRACK_Ma(p,u,&t1,&t2);
6065 else if (u->Typ() == BIGINTMAT_CMD)
6066 nok=jjBRACK_Bim(p,u,&t1,&t2);
6067 else /* INTMAT_CMD */
6068 nok=jjBRACK_Im(p,u,&t1,&t2);
6069 if (nok)
6070 {
6071 res->CleanUp();
6072 return TRUE;
6073 }
6074 }
6075 }
6076 return FALSE;
6077}
6079{
6080 v->next=(leftv)omAllocBin(sleftv_bin);
6081 memcpy(v->next,w,sizeof(sleftv));
6082 w->Init();
6083 return jjPROC(res,u,v);
6084}
6086{
6087 u->next=(leftv)omAlloc(sizeof(sleftv));
6088 memcpy(u->next,v,sizeof(sleftv));
6089 v->Init();
6090 u->next->next=(leftv)omAlloc(sizeof(sleftv));
6091 memcpy(u->next->next,w,sizeof(sleftv));
6092 w->Init();
6093 BOOLEAN bo=iiExprArithM(res,u,'[');
6094 u->next=NULL;
6095 return bo;
6096}
6098{
6099 intvec *iv;
6100 ideal m;
6102 int k=(int)(long)w->Data();
6103 if (k>=0)
6104 {
6105 sm_CallBareiss((ideal)u->Data(),(int)(long)v->Data(),(int)(long)w->Data(),m,&iv, currRing);
6106 l->Init(2);
6107 l->m[0].rtyp=MODUL_CMD;
6108 l->m[1].rtyp=INTVEC_CMD;
6109 l->m[0].data=(void *)m;
6110 l->m[1].data=(void *)iv;
6111 }
6112 else
6113 {
6114 m=sm_CallSolv((ideal)u->Data(), currRing);
6115 l->Init(1);
6116 l->m[0].rtyp=IDEAL_CMD;
6117 l->m[0].data=(void *)m;
6118 }
6119 res->data = (char *)l;
6120 return FALSE;
6121}
6123{
6124 if ((w->rtyp!=IDHDL)||(w->e!=NULL))
6125 {
6126 WerrorS("3rd argument must be a name of a matrix");
6127 return TRUE;
6128 }
6129 ideal i=(ideal)u->Data();
6130 int rank=(int)i->rank;
6131 BOOLEAN r=jjCOEFFS_Id(res,u,v);
6132 if (r) return TRUE;
6133 mp_Monomials((matrix)res->data, rank, pVar((poly)v->Data()),(matrix)w->Data(),currRing);
6134 return FALSE;
6135}
6137{
6138 res->data=(void*)idCoeffOfKBase((ideal)(u->Data()),
6139 (ideal)(v->Data()),(poly)(w->Data()));
6140 return FALSE;
6141}
6143{
6144 if ((w->rtyp!=IDHDL)||(w->e!=NULL))
6145 {
6146 WerrorS("3rd argument must be a name of a matrix");
6147 return TRUE;
6148 }
6149 // CopyD for POLY_CMD and VECTOR_CMD are identical:
6150 poly p=(poly)u->CopyD(POLY_CMD);
6151 ideal i=idInit(1,1);
6152 i->m[0]=p;
6153 sleftv t;
6154 t.Init();
6155 t.data=(char *)i;
6156 t.rtyp=IDEAL_CMD;
6157 int rank=1;
6158 if (u->Typ()==VECTOR_CMD)
6159 {
6160 i->rank=rank=pMaxComp(p);
6161 t.rtyp=MODUL_CMD;
6162 }
6163 BOOLEAN r=jjCOEFFS_Id(res,&t,v);
6164 t.CleanUp();
6165 if (r) return TRUE;
6166 mp_Monomials((matrix)res->data, rank, pVar((poly)v->Data()),(matrix)w->Data(),currRing);
6167 return FALSE;
6168}
6170{
6171 ideal I=(ideal)u->Data();
6172 GbVariant alg=syGetAlgorithm((char*)w->Data(),currRing,I);
6173 res->data=(char *)idElimination(I,(poly)v->Data(),NULL,alg);
6174 //setFlag(res,FLAG_STD);
6175 return v->next!=NULL; //do not allow next like in eliminate(I,a(1..4))
6176}
6178{
6179 bigintmat *ww=(bigintmat*)w->Data();
6180
6181 res->data=(char *)idElimination2((ideal)u->Data(),(poly)v->Data(),
6182 ww);
6183 //setFlag(res,FLAG_STD);
6184 return FALSE;
6185}
6187{
6188 /*4
6189 * look for the substring what in the string where
6190 * starting at position n
6191 * return the position of the first char of what in where
6192 * or 0
6193 */
6194 int n=(int)(long)w->Data();
6195 char *where=(char *)u->Data();
6196 char *what=(char *)v->Data();
6197 char *found;
6198 if ((1>n)||(n>(int)strlen(where)))
6199 {
6200 Werror("start position %d out of range",n);
6201 return TRUE;
6202 }
6203 found = strchr(where+n-1,*what);
6204 if (*(what+1)!='\0')
6205 {
6206 while((found !=NULL) && (strncmp(found+1,what+1,strlen(what+1))!=0))
6207 {
6208 found=strchr(found+1,*what);
6209 }
6210 }
6211 if (found != NULL)
6212 {
6213 res->data=(char *)((found-where)+1);
6214 }
6215 return FALSE;
6216}
6218{
6219 if ((int)(long)w->Data()==0)
6220 res->data=(char *)walkProc(u,v);
6221 else
6222 res->data=(char *)fractalWalkProc(u,v);
6223 setFlag( res, FLAG_STD );
6224 return FALSE;
6225}
6227{
6228 intvec *wdegree=(intvec*)w->Data();
6229 if (wdegree->length()!=currRing->N)
6230 {
6231 Werror("weight vector must have size %d, not %d",
6232 currRing->N,wdegree->length());
6233 return TRUE;
6234 }
6235 if (rField_is_Z(currRing))
6236 {
6237 PrintS("// NOTE: computation of Hilbert series etc. is being\n");
6238 PrintS("// performed for generic fibre, that is, over Q\n");
6239 }
6240 assumeStdFlag(u);
6241 intvec *module_w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
6242 if (errorreported) return TRUE;
6243
6244 switch((int)(long)v->Data())
6245 {
6246 case 1:
6247 res->data=(void *)hFirstSeries0b((ideal)u->Data(),currRing->qideal,wdegree,module_w,currRing,coeffs_BIGINT);
6248 return FALSE;
6249 case 2:
6250 res->data=(void *)hSecondSeries0b((ideal)u->Data(),currRing->qideal,wdegree,module_w,currRing,coeffs_BIGINT);
6251 return FALSE;
6252 }
6254 return TRUE;
6255}
6257{
6258 if (rField_is_Z(currRing))
6259 {
6260 PrintS("// NOTE: computation of Hilbert series etc. is being\n");
6261 PrintS("// performed for generic fibre, that is, over Q\n");
6262 }
6263 assumeStdFlag(u);
6264 ring Qt =(ring)v->Data();
6265 char *name=(char*)w->Data();
6266 poly h;
6267 if (u->Typ()==IDEAL_CMD)
6268 h=hFirstSeries0p((ideal)u->Data(),currRing->qideal,NULL,currRing,Qt);
6269 else
6270 {
6271 intvec *module_w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
6272 h=hFirstSeries0m((ideal)u->Data(),currRing->qideal,NULL,module_w,currRing,Qt);
6273 }
6274 idhdl hh=enterid(name,myynest,POLY_CMD,&(Qt->idroot),FALSE,FALSE);
6275 IDPOLY(hh)=h;
6276 return FALSE;
6277}
6279{
6280 PrintS("TODO\n");
6281 int i=pVar((poly)v->Data());
6282 if (i==0)
6283 {
6284 WerrorS("ringvar expected");
6285 return TRUE;
6286 }
6287 poly p=pOne(); pSetExp(p,i,1); pSetm(p);
6288 int d=pWTotaldegree(p);
6289 pLmDelete(p);
6290 if (d==1)
6291 res->data = (char *)id_Homogen((ideal)u->Data(), i, currRing);
6292 else
6293 WerrorS("variable must have weight 1");
6294 return (d!=1);
6295}
6297{
6298 PrintS("TODO\n");
6299 int i=pVar((poly)v->Data());
6300 if (i==0)
6301 {
6302 WerrorS("ringvar expected");
6303 return TRUE;
6304 }
6305 poly p=pOne(); pSetExp(p,i,1); pSetm(p);
6306 int d=pWTotaldegree(p);
6307 pLmDelete(p);
6308 if (d==1)
6309 res->data = (char *)p_Homogen((poly)u->Data(), i, currRing);
6310 else
6311 WerrorS("variable must have weight 1");
6312 return (d!=1);
6313}
6315{
6316 intvec *w=(intvec *)v3->Data();
6317 intvec *vw=(intvec*)v2->Data();
6318 ideal v_id=(ideal)v1->Data();
6319 res->data=(void *)(long)id_HomModuleW(v_id,currRing->qideal,vw,w,currRing);
6320 return FALSE;
6321}
6323{
6324 intvec* im= new intvec((int)(long)v->Data(),(int)(long)w->Data(), 0);
6325 intvec* arg = (intvec*) u->Data();
6326 int i, n = si_min(im->cols()*im->rows(), arg->cols()*arg->rows());
6327
6328 for (i=0; i<n; i++)
6329 {
6330 (*im)[i] = (*arg)[i];
6331 }
6332
6333 res->data = (char *)im;
6334 return FALSE;
6335}
6337{
6338 ideal I1=(ideal)u->Data();
6339 ideal I2=(ideal)v->Data();
6340 ideal I3=(ideal)w->Data();
6341 resolvente r=(resolvente)omAlloc0(3*sizeof(ideal));
6342 r[0]=I1;
6343 r[1]=I2;
6344 r[2]=I3;
6345 res->data=(char *)idMultSect(r,3);
6346 omFreeSize((ADDRESS)r,3*sizeof(ideal));
6347 return FALSE;
6348}
6350{
6351 ideal I=(ideal)u->Data();
6352 GbVariant alg=syGetAlgorithm((char*)w->Data(),currRing,I);
6353 res->data=(char *)idSect(I,(ideal)v->Data(),alg);
6355 return FALSE;
6356}
6358{
6359 int *iw=iv2array((intvec *)w->Data(),currRing);
6360 res->data = (char *)ppJetW((poly)u->Data(),(int)(long)v->Data(),iw);
6361 omFreeSize( (ADDRESS)iw, (rVar(currRing)+1)*sizeof(int) );
6362 return FALSE;
6363}
6365{
6366 if (!pIsUnit((poly)v->Data()))
6367 {
6368 WerrorS("2nd argument must be a unit");
6369 return TRUE;
6370 }
6371 res->data = (char *)p_Series((int)(long)w->Data(),(poly)u->CopyD(),(poly)v->CopyD(),NULL,currRing);
6372 return FALSE;
6373}
6375{
6376 res->data = (char *)id_JetW((ideal)u->Data(),(int)(long)v->Data(),
6377 (intvec *)w->Data(),currRing);
6378 return FALSE;
6379}
6381{
6382 if (!mp_IsDiagUnit((matrix)v->Data(), currRing))
6383 {
6384 WerrorS("2nd argument must be a diagonal matrix of units");
6385 return TRUE;
6386 }
6387 res->data = (char *)idSeries((int)(long)w->Data(),(ideal)u->CopyD(),
6388 (matrix)v->CopyD());
6389 return FALSE;
6390}
6392{
6393 /* Here's the use pattern for the minor command:
6394 minor ( matrix_expression m, int_expression minorSize,
6395 optional ideal_expression IasSB, optional int_expression k,
6396 optional string_expression algorithm,
6397 optional int_expression cachedMinors,
6398 optional int_expression cachedMonomials )
6399 This method here assumes that there are at least two arguments.
6400 - If IasSB is present, it must be a std basis. All minors will be
6401 reduced w.r.t. IasSB.
6402 - If k is absent, all non-zero minors will be computed.
6403 If k is present and k > 0, the first k non-zero minors will be
6404 computed.
6405 If k is present and k < 0, the first |k| minors (some of which
6406 may be zero) will be computed.
6407 If k is present and k = 0, an error is reported.
6408 - If algorithm is absent, all the following arguments must be absent too.
6409 In this case, a heuristic picks the best-suited algorithm (among
6410 Bareiss, Laplace, and Laplace with caching).
6411 If algorithm is present, it must be one of "Bareiss", "bareiss",
6412 "Laplace", "laplace", "Cache", "cache". In the cases "Cache" and
6413 "cache" two more arguments may be given, determining how many entries
6414 the cache may have at most, and how many cached monomials there are at
6415 most. (Cached monomials are counted over all cached polynomials.)
6416 If these two additional arguments are not provided, 200 and 100000
6417 will be used as defaults.
6418 */
6419 matrix m;
6420 leftv u=v->next;
6421 v->next=NULL;
6422 int v_typ=v->Typ();
6423 if (v_typ==MATRIX_CMD)
6424 {
6425 m = (matrix)v->Data();
6426 }
6427 else
6428 {
6429 if (v_typ==0)
6430 {
6431 Werror("`%s` is undefined",v->Fullname());
6432 return TRUE;
6433 }
6434 // try to convert to MATRIX:
6435 int ii=iiTestConvert(v_typ,MATRIX_CMD);
6436 BOOLEAN bo;
6437 sleftv tmp;
6438 if (ii>0) bo=iiConvert(v_typ,MATRIX_CMD,ii,v,&tmp);
6439 else bo=TRUE;
6440 if (bo)
6441 {
6442 Werror("cannot convert %s to matrix",Tok2Cmdname(v_typ));
6443 return TRUE;
6444 }
6445 m=(matrix)tmp.data;
6446 }
6447 const int mk = (int)(long)u->Data();
6448 bool noIdeal = true; bool noK = true; bool noAlgorithm = true;
6449 bool noCacheMinors = true; bool noCacheMonomials = true;
6450 ideal IasSB; int k=0; char* algorithm; int cacheMinors; int cacheMonomials;
6451
6452 /* here come the different cases of correct argument sets */
6453 if ((u->next != NULL) && (u->next->Typ() == IDEAL_CMD))
6454 {
6455 IasSB = (ideal)u->next->Data();
6456 noIdeal = false;
6457 if ((u->next->next != NULL) && (u->next->next->Typ() == INT_CMD))
6458 {
6459 k = (int)(long)u->next->next->Data();
6460 noK = false;
6461 if ((u->next->next->next != NULL) &&
6462 (u->next->next->next->Typ() == STRING_CMD))
6463 {
6464 algorithm = (char*)u->next->next->next->Data();
6465 noAlgorithm = false;
6466 if ((u->next->next->next->next != NULL) &&
6467 (u->next->next->next->next->Typ() == INT_CMD))
6468 {
6469 cacheMinors = (int)(long)u->next->next->next->next->Data();
6470 noCacheMinors = false;
6471 if ((u->next->next->next->next->next != NULL) &&
6472 (u->next->next->next->next->next->Typ() == INT_CMD))
6473 {
6474 cacheMonomials =
6475 (int)(long)u->next->next->next->next->next->Data();
6476 noCacheMonomials = false;
6477 }
6478 }
6479 }
6480 }
6481 }
6482 else if ((u->next != NULL) && (u->next->Typ() == INT_CMD))
6483 {
6484 k = (int)(long)u->next->Data();
6485 noK = false;
6486 if ((u->next->next != NULL) && (u->next->next->Typ() == STRING_CMD))
6487 {
6488 algorithm = (char*)u->next->next->Data();
6489 noAlgorithm = false;
6490 if ((u->next->next->next != NULL) &&
6491 (u->next->next->next->Typ() == INT_CMD))
6492 {
6493 cacheMinors = (int)(long)u->next->next->next->Data();
6494 noCacheMinors = false;
6495 if ((u->next->next->next->next != NULL) &&
6496 (u->next->next->next->next->Typ() == INT_CMD))
6497 {
6498 cacheMonomials = (int)(long)u->next->next->next->next->Data();
6499 noCacheMonomials = false;
6500 }
6501 }
6502 }
6503 }
6504 else if ((u->next != NULL) && (u->next->Typ() == STRING_CMD))
6505 {
6506 algorithm = (char*)u->next->Data();
6507 noAlgorithm = false;
6508 if ((u->next->next != NULL) && (u->next->next->Typ() == INT_CMD))
6509 {
6510 cacheMinors = (int)(long)u->next->next->Data();
6511 noCacheMinors = false;
6512 if ((u->next->next->next != NULL) &&
6513 (u->next->next->next->Typ() == INT_CMD))
6514 {
6515 cacheMonomials = (int)(long)u->next->next->next->Data();
6516 noCacheMonomials = false;
6517 }
6518 }
6519 }
6520
6521 /* upper case conversion for the algorithm if present */
6522 if (!noAlgorithm)
6523 {
6524 if (strcmp(algorithm, "bareiss") == 0)
6525 algorithm = (char*)"Bareiss";
6526 if (strcmp(algorithm, "laplace") == 0)
6527 algorithm = (char*)"Laplace";
6528 if (strcmp(algorithm, "cache") == 0)
6529 algorithm = (char*)"Cache";
6530 }
6531
6532 v->next=u;
6533 /* here come some tests */
6534 if (!noIdeal)
6535 {
6536 assumeStdFlag(u->next);
6537 }
6538 if ((!noK) && (k == 0))
6539 {
6540 WerrorS("Provided number of minors to be computed is zero.");
6541 return TRUE;
6542 }
6543 if ((!noAlgorithm) && (strcmp(algorithm, "Bareiss") != 0)
6544 && (strcmp(algorithm, "Laplace") != 0)
6545 && (strcmp(algorithm, "Cache") != 0))
6546 {
6547 WerrorS("Expected as algorithm one of 'B/bareiss', 'L/laplace', or 'C/cache'.");
6548 return TRUE;
6549 }
6550 if ((!noAlgorithm) && (strcmp(algorithm, "Bareiss") == 0)
6552 {
6553 Werror("Bareiss algorithm not defined over coefficient rings %s",
6554 "with zero divisors.");
6555 return TRUE;
6556 }
6557 if ((mk < 1) || (mk > m->rows()) || (mk > m->cols()))
6558 {
6559 ideal I=idInit(1,1);
6560 if (mk<1) I->m[0]=p_One(currRing);
6561 //Werror("invalid size of minors: %d (matrix is (%d x %d))", mk,
6562 // m->rows(), m->cols());
6563 res->data=(void*)I;
6564 return FALSE;
6565 }
6566 if ((!noAlgorithm) && (strcmp(algorithm, "Cache") == 0)
6567 && (noCacheMinors || noCacheMonomials))
6568 {
6569 cacheMinors = 200;
6570 cacheMonomials = 100000;
6571 }
6572
6573 /* here come the actual procedure calls */
6574 if (noAlgorithm)
6575 res->data = getMinorIdealHeuristic(m, mk, (noK ? 0 : k),
6576 (noIdeal ? 0 : IasSB), false);
6577 else if (strcmp(algorithm, "Cache") == 0)
6578 res->data = getMinorIdealCache(m, mk, (noK ? 0 : k),
6579 (noIdeal ? 0 : IasSB), 3, cacheMinors,
6580 cacheMonomials, false);
6581 else
6582 res->data = getMinorIdeal(m, mk, (noK ? 0 : k), algorithm,
6583 (noIdeal ? 0 : IasSB), false);
6584 if (v_typ!=MATRIX_CMD) idDelete((ideal *)&m);
6585 return FALSE;
6586}
6588{
6589 if ((ma->rtyp!=IDHDL)||(ma->e!=NULL))
6590 {
6591 WerrorS("3rd argument must have a name");
6592 return TRUE;
6593 }
6594 int maxl=(int)(long)v->Data();
6595 if (maxl<0)
6596 {
6597 WerrorS("length for res must not be negative");
6598 return TRUE;
6599 }
6600 syStrategy r;
6601 intvec *weights=NULL;
6602 int wmaxl=maxl;
6603 ideal u_id=(ideal)u->Data();
6604
6605 maxl--;
6606 if (/*(*/ maxl==-1 /*)*/)
6607 {
6608 maxl = currRing->N-1+2;
6609 if (currRing->qideal!=NULL)
6610 {
6611 Warn(
6612 "full resolution in a qring may be infinite, setting max length to %d",
6613 maxl+1);
6614 }
6615 }
6616 weights=(intvec*)atGet(u,"isHomog",INTVEC_CMD);
6617 if (weights!=NULL)
6618 {
6619 if (!idTestHomModule(u_id,currRing->qideal,weights))
6620 {
6621 WarnS("wrong weights given:");weights->show();PrintLn();
6622 weights=NULL;
6623 }
6624 }
6625 intvec *ww=NULL;
6626 int add_row_shift=0;
6627 if (weights!=NULL)
6628 {
6629 ww=ivCopy(weights);
6630 add_row_shift = ww->min_in();
6631 (*ww) -= add_row_shift;
6632 }
6633 unsigned save_opt=si_opt_1;
6635 u_id=(ideal)u->CopyD();
6636 ideal mat;
6637 r=syMres_with_map(u_id,maxl,ww,mat);
6638 idhdl h=(idhdl)ma->data;
6639 idDelete(&IDIDEAL(h));
6640 IDIDEAL(h)=mat;
6641 if (r->list_length>wmaxl)
6642 {
6643 for(int i=wmaxl-1;i>=r->list_length;i--)
6644 {
6645 if (r->fullres[i]!=NULL) id_Delete(&r->fullres[i],currRing);
6646 if (r->minres[i]!=NULL) id_Delete(&r->minres[i],currRing);
6647 }
6648 }
6649 r->list_length=wmaxl;
6650 res->data=(void *)r;
6651 if ((weights!=NULL) && (ww!=NULL)) { delete ww; ww=NULL; }
6652 if ((r->weights!=NULL) && (r->weights[0]!=NULL))
6653 {
6654 ww=ivCopy(r->weights[0]);
6655 if (weights!=NULL) (*ww) += add_row_shift;
6656 atSet(res,omStrDup("isHomog"),ww,INTVEC_CMD);
6657 }
6658 else
6659 {
6660 if (weights!=NULL)
6661 {
6662 atSet(res,omStrDup("isHomog"),ivCopy(weights),INTVEC_CMD);
6663 }
6664 }
6665 assume( (r->syRing != NULL) == (r->resPairs != NULL) );
6666 assume( (r->minres != NULL) || (r->fullres != NULL) );
6667 si_opt_1=save_opt;
6668 return FALSE;
6669}
6671{
6672 // u: the name of the new type
6673 // v: the parent type
6674 // w: the elements
6675 newstruct_desc d=newstructChildFromString((const char *)v->Data(),
6676 (const char *)w->Data());
6677 if (d!=NULL) newstruct_setup((const char *)u->Data(),d);
6678 return (d==NULL);
6679}
6681{
6682 // handles preimage(r,phi,i) and kernel(r,phi)
6683 idhdl h;
6684 ring rr;
6685 map mapping;
6686 BOOLEAN kernel_cmd= (iiOp==KERNEL_CMD);
6687
6688 if ((v->name==NULL) || (!kernel_cmd && (w->name==NULL)))
6689 {
6690 WerrorS("2nd/3rd arguments must have names");
6691 return TRUE;
6692 }
6693 rr=(ring)u->Data();
6694 const char *ring_name=u->Name();
6695 if ((h=rr->idroot->get(v->name,myynest))!=NULL)
6696 {
6697 if (h->typ==MAP_CMD)
6698 {
6699 mapping=IDMAP(h);
6700 idhdl preim_ring=IDROOT->get(mapping->preimage,myynest);
6701 if ((preim_ring==NULL)
6702 || (IDRING(preim_ring)!=currRing))
6703 {
6704 Werror("preimage ring `%s` is not the basering",mapping->preimage);
6705 return TRUE;
6706 }
6707 }
6708 else if (h->typ==IDEAL_CMD)
6709 {
6710 mapping=IDMAP(h);
6711 }
6712 else
6713 {
6714 Werror("`%s` is no map nor ideal",IDID(h));
6715 return TRUE;
6716 }
6717 }
6718 else
6719 {
6720 Werror("`%s` is not defined in `%s`",v->name,ring_name);
6721 return TRUE;
6722 }
6723 ideal image;
6724 if (kernel_cmd) image=idInit(1,1);
6725 else
6726 {
6727 if ((h=rr->idroot->get(w->name,myynest))!=NULL)
6728 {
6729 if (h->typ==IDEAL_CMD)
6730 {
6731 image=IDIDEAL(h);
6732 }
6733 else
6734 {
6735 Werror("`%s` is no ideal",IDID(h));
6736 return TRUE;
6737 }
6738 }
6739 else
6740 {
6741 Werror("`%s` is not defined in `%s`",w->name,ring_name);
6742 return TRUE;
6743 }
6744 }
6745 if (((currRing->qideal!=NULL) && (rHasLocalOrMixedOrdering(currRing)))
6746 || ((rr->qideal!=NULL) && (rHasLocalOrMixedOrdering(rr))))
6747 {
6748 WarnS("preimage in local qring may be wrong: use Ring::preimageLoc instead");
6749 }
6750 res->data=(char *)maGetPreimage(rr,mapping,image,currRing);
6751 if (kernel_cmd) idDelete(&image);
6752 return (res->data==NULL/* is of type ideal, should not be NULL*/);
6753}
6754#ifdef HTABLE
6755static BOOLEAN jjTABLE_ADD(leftv res, leftv u, leftv v, leftv w)
6756{
6757 stablerec* lt=(stablerec*)u->Data();
6758 char *key=(char*)v->CopyD();
6759 t_addTable(lt,key,w);
6760 return FALSE;
6761}
6762#endif
6764{
6765 int di, k;
6766 int i=(int)(long)u->Data();
6767 int r=(int)(long)v->Data();
6768 int c=(int)(long)w->Data();
6769 if ((r<=0) || (c<=0)) return TRUE;
6770 intvec *iv = new intvec(r, c, 0);
6771 if (iv->rows()==0)
6772 {
6773 delete iv;
6774 return TRUE;
6775 }
6776 if (i!=0)
6777 {
6778 if (i<0) i = -i;
6779 di = 2 * i + 1;
6780 for (k=0; k<iv->length(); k++)
6781 {
6782 (*iv)[k] = ((siRand() % di) - i);
6783 }
6784 }
6785 res->data = (char *)iv;
6786 return FALSE;
6787}
6788#ifdef SINGULAR_4_2
6789static BOOLEAN jjRANDOM_CF(leftv res, leftv u, leftv v, leftv w)
6790// <coeff>, par1, par2 -> number2
6791{
6792 coeffs cf=(coeffs)u->Data();
6793 if ((cf==NULL) ||(cf->cfRandom==NULL))
6794 {
6795 Werror("no random function defined for coeff %d",cf->type);
6796 return TRUE;
6797 }
6798 else
6799 {
6800 number n= n_Random(siRand,(number)v->Data(),(number)w->Data(),cf);
6801 number2 nn=(number2)omAlloc(sizeof(*nn));
6802 nn->cf=cf;
6803 nn->n=n;
6804 res->data=nn;
6805 return FALSE;
6806 }
6807 return TRUE;
6808}
6809#endif
6811 int &ringvar, poly &monomexpr)
6812{
6813 monomexpr=(poly)w->Data();
6814 poly p=(poly)v->Data();
6815#if 0
6816 if (pLength(monomexpr)>1)
6817 {
6818 Werror("`%s` substitutes a ringvar only by a term",
6820 return TRUE;
6821 }
6822#endif
6823 if ((ringvar=pVar(p))==0)
6824 {
6825 if ((p!=NULL) && (currRing->cf->extRing!=NULL))
6826 {
6827 number n = pGetCoeff(p);
6828 ringvar= -n_IsParam(n, currRing);
6829 }
6830 if(ringvar==0)
6831 {
6832 WerrorS("ringvar/par expected");
6833 return TRUE;
6834 }
6835 }
6836 return FALSE;
6837}
6839{
6840 // generic conversion from polyBucket to poly:
6841 // force this to be the first try everytime
6842 poly p; int l;
6843 sBucket_pt bu=(sBucket_pt)w->CopyD();
6844 sBucketDestroyAdd(bu,&p,&l);
6845 sleftv tmpw;
6846 tmpw.Init();
6847 tmpw.rtyp=POLY_CMD;
6848 tmpw.data=p;
6849 return iiExprArith3(res, iiOp, u, v, &tmpw);
6850}
6852{
6853 int ringvar;
6854 poly monomexpr;
6855 BOOLEAN nok=jjSUBST_Test(v,w,ringvar,monomexpr);
6856 if (nok) return TRUE;
6857 poly p=(poly)u->Data();
6858 if (ringvar>0)
6859 {
6860 int mm=p_MaxExpPerVar(p,ringvar,currRing);
6861 if (!rIsLPRing(currRing) &&
6862 (monomexpr!=NULL) && (p!=NULL) && (mm!=0) &&
6863 ((unsigned long)pTotaldegree(monomexpr) > (currRing->bitmask / (unsigned long)mm/2)))
6864 {
6865 Warn("possible OVERFLOW in subst, max exponent is %ld, substituting deg %d by deg %d",currRing->bitmask/2, pTotaldegree(monomexpr), mm);
6866 //return TRUE;
6867 }
6868 if ((monomexpr==NULL)||(pNext(monomexpr)==NULL))
6869 res->data = pSubst((poly)u->CopyD(res->rtyp),ringvar,monomexpr);
6870 else
6871 res->data= pSubstPoly(p,ringvar,monomexpr);
6872 }
6873 else
6874 {
6875 if (rIsLPRing(currRing))
6876 {
6877 WerrorS("Substituting parameters not implemented for Letterplace rings.");
6878 return TRUE;
6879 }
6880 res->data=pSubstPar(p,-ringvar,monomexpr);
6881 }
6882 return FALSE;
6883}
6885{
6886 int ringvar;
6887 poly monomexpr;
6888 BOOLEAN nok=jjSUBST_Test(v,w,ringvar,monomexpr);
6889 if (nok) return TRUE;
6890 ideal id=(ideal)u->Data();
6891 if (ringvar>0)
6892 {
6893 BOOLEAN overflow=FALSE;
6894 if (!rIsLPRing(currRing) && (monomexpr!=NULL))
6895 {
6896 long deg_monexp=pTotaldegree(monomexpr);
6897 for(int i=IDELEMS(id)-1;i>=0;i--)
6898 {
6899 poly p=id->m[i];
6900 int mm=p_MaxExpPerVar(p,ringvar,currRing);
6901 if ((p!=NULL) && (mm!=0) &&
6902 ((unsigned long)deg_monexp > (currRing->bitmask / (unsigned long)mm/2)))
6903 {
6904 overflow=TRUE;
6905 break;
6906 }
6907 }
6908 }
6909 if (overflow)
6910 Warn("possible OVERFLOW in subst, max exponent is %ld",currRing->bitmask/2);
6911 if ((monomexpr==NULL)||(pNext(monomexpr)==NULL))
6912 {
6913 if (res->rtyp==MATRIX_CMD) id=(ideal)mp_Copy((matrix)id,currRing);
6914 else id=id_Copy(id,currRing);
6915 res->data = id_Subst(id, ringvar, monomexpr, currRing);
6916 }
6917 else
6918 res->data = idSubstPoly(id,ringvar,monomexpr);
6919 }
6920 else
6921 {
6922 if (rIsLPRing(currRing))
6923 {
6924 WerrorS("Substituting parameters not implemented for Letterplace rings.");
6925 return TRUE;
6926 }
6927 res->data = idSubstPar(id,-ringvar,monomexpr);
6928 }
6929 return FALSE;
6930}
6931// we do not want to have jjSUBST_Id_X inlined:
6933 int input_type);
6935{
6936 return jjSUBST_Id_X(res,u,v,w,INT_CMD);
6937}
6939{
6940 return jjSUBST_Id_X(res,u,v,w,NUMBER_CMD);
6941}
6942static BOOLEAN jjSUBST_Id_X(leftv res, leftv u, leftv v,leftv w, int input_type)
6943{
6944 sleftv tmp;
6945 tmp.Init();
6946 // do not check the result, conversion from int/number to poly works always
6947 iiConvert(input_type,POLY_CMD,iiTestConvert(input_type,POLY_CMD),w,&tmp);
6948 BOOLEAN b=jjSUBST_Id(res,u,v,&tmp);
6949 tmp.CleanUp();
6950 return b;
6951}
6953{
6954 int mi=(int)(long)v->Data();
6955 int ni=(int)(long)w->Data();
6956 if ((mi<1)||(ni<1))
6957 {
6958 Werror("converting ideal to matrix: dimensions must be positive(%dx%d)",mi,ni);
6959 return TRUE;
6960 }
6961 matrix m=mpNew(mi,ni);
6962 ideal I=(ideal)u->CopyD(IDEAL_CMD);
6963 int i=si_min(IDELEMS(I),mi*ni);
6964 //for(i=i-1;i>=0;i--)
6965 //{
6966 // m->m[i]=I->m[i];
6967 // I->m[i]=NULL;
6968 //}
6969 memcpy(m->m,I->m,i*sizeof(poly));
6970 memset(I->m,0,i*sizeof(poly));
6971 id_Delete(&I,currRing);
6972 res->data = (char *)m;
6973 return FALSE;
6974}
6976{
6977 int mi=(int)(long)v->Data();
6978 int ni=(int)(long)w->Data();
6979 if ((mi<0)||(ni<1))
6980 {
6981 Werror("converting module to matrix: dimensions must be positive(%dx%d)",mi,ni);
6982 return TRUE;
6983 }
6984 res->data = (char *)id_Module2formatedMatrix((ideal)u->CopyD(MODUL_CMD),
6985 mi,ni,currRing);
6986 return FALSE;
6987}
6989{
6990 int mi=(int)(long)v->Data();
6991 int ni=(int)(long)w->Data();
6992 if ((mi<1)||(ni<1))
6993 {
6994 Werror("converting matrix to matrix: dimensions must be positive(%dx%d)",mi,ni);
6995 return TRUE;
6996 }
6997 matrix m=mpNew(mi,ni);
6999 int r=si_min(MATROWS(I),mi);
7000 int c=si_min(MATCOLS(I),ni);
7001 int i,j;
7002 for(i=r;i>0;i--)
7003 {
7004 for(j=c;j>0;j--)
7005 {
7006 MATELEM(m,i,j)=MATELEM(I,i,j);
7007 MATELEM(I,i,j)=NULL;
7008 }
7009 }
7010 id_Delete((ideal *)&I,currRing);
7011 res->data = (char *)m;
7012 return FALSE;
7013}
7015{
7016 if (w->rtyp!=IDHDL) return TRUE; /* idhdhl required */
7017 intvec *w_u=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
7018 tHomog hom=testHomog;
7019 if (w_u!=NULL)
7020 {
7021 w_u=ivCopy(w_u);
7022 hom=isHomog;
7023 }
7024 intvec *w_v=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
7025 if (w_v!=NULL)
7026 {
7027 w_v=ivCopy(w_v);
7028 hom=isHomog;
7029 }
7030 if ((w_u!=NULL) && (w_v==NULL))
7031 w_v=ivCopy(w_u);
7032 if ((w_v!=NULL) && (w_u==NULL))
7033 w_u=ivCopy(w_v);
7034 ideal u_id=(ideal)u->Data();
7035 ideal v_id=(ideal)v->Data();
7036 if (w_u!=NULL)
7037 {
7038 if ((*w_u).compare((w_v))!=0)
7039 {
7040 WarnS("incompatible weights");
7041 delete w_u; w_u=NULL;
7042 hom=testHomog;
7043 }
7044 else
7045 {
7046 if ((!idTestHomModule(u_id,currRing->qideal,w_v))
7047 || (!idTestHomModule(v_id,currRing->qideal,w_v)))
7048 {
7049 WarnS("wrong weights");
7050 delete w_u; w_u=NULL;
7051 hom=testHomog;
7052 }
7053 }
7054 }
7055 idhdl h=(idhdl)w->data;
7056 res->data = (char *)idModulo(u_id,v_id ,hom,&w_u, &(h->data.umatrix));
7057 if (w_u!=NULL)
7058 {
7059 atSet(res,omStrDup("isHomog"),w_u,INTVEC_CMD);
7060 }
7061 delete w_v;
7062 //if (TEST_OPT_RETURN_SB) setFlag(res,FLAG_STD);
7063 return FALSE;
7064}
7066{
7067 if (w->rtyp!=IDHDL) return TRUE; /* idhdhl required */
7068 intvec *w_u=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
7069 tHomog hom=testHomog;
7070 if (w_u!=NULL)
7071 {
7072 w_u=ivCopy(w_u);
7073 hom=isHomog;
7074 }
7075 intvec *w_v=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
7076 if (w_v!=NULL)
7077 {
7078 w_v=ivCopy(w_v);
7079 hom=isHomog;
7080 }
7081 if ((w_u!=NULL) && (w_v==NULL))
7082 w_v=ivCopy(w_u);
7083 if ((w_v!=NULL) && (w_u==NULL))
7084 w_u=ivCopy(w_v);
7085 ideal u_id=(ideal)u->Data();
7086 GbVariant alg=syGetAlgorithm((char*)w->Data(),currRing,u_id);
7087 ideal v_id=(ideal)v->Data();
7088 if (w_u!=NULL)
7089 {
7090 if ((*w_u).compare((w_v))!=0)
7091 {
7092 WarnS("incompatible weights");
7093 delete w_u; w_u=NULL;
7094 hom=testHomog;
7095 }
7096 else
7097 {
7098 if ((!idTestHomModule(u_id,currRing->qideal,w_v))
7099 || (!idTestHomModule(v_id,currRing->qideal,w_v)))
7100 {
7101 WarnS("wrong weights");
7102 delete w_u; w_u=NULL;
7103 hom=testHomog;
7104 }
7105 }
7106 }
7107 res->data = (char *)idModulo(u_id,v_id ,hom,&w_u, NULL,alg);
7108 if (w_u!=NULL)
7109 {
7110 atSet(res,omStrDup("isHomog"),w_u,INTVEC_CMD);
7111 }
7112 delete w_v;
7113 //if (TEST_OPT_RETURN_SB) setFlag(res,FLAG_STD);
7114 return FALSE;
7115}
7117{
7118 int mi=(int)(long)v->Data();
7119 int ni=(int)(long)w->Data();
7120 if ((mi<0)||(ni<1))
7121 {
7122 Werror("converting to smatrix: dimensions must be positive(%dx%d)",mi,ni);
7123 return TRUE;
7124 }
7125 res->data = (char *)id_ResizeModule((ideal)u->CopyD(),
7126 mi,ni,currRing);
7127 return FALSE;
7128}
7130{
7131 if (w->rtyp!=IDHDL) return TRUE;
7132 int ul= IDELEMS((ideal)u->Data());
7133 int vl= IDELEMS((ideal)v->Data());
7134#ifdef HAVE_SHIFTBBA
7135 if (rIsLPRing(currRing))
7136 {
7137 if (currRing->LPncGenCount < ul)
7138 {
7139 Werror("At least %d ncgen variables are needed for this computation.", ul);
7140 return TRUE;
7141 }
7142 }
7143#endif
7144 ideal m
7145 = idLift((ideal)u->Data(),(ideal)v->Data(),NULL,FALSE,hasFlag(u,FLAG_STD),
7146 FALSE, (matrix *)(&(IDMATRIX((idhdl)(w->data)))));
7147 if (m==NULL) return TRUE;
7148 res->data = (char *)id_Module2formatedMatrix(m,ul,vl,currRing);
7149 return FALSE;
7150}
7152{
7153 if ((v->rtyp!=IDHDL)||(v->e!=NULL)) return TRUE;
7154 if ((w->rtyp!=IDHDL)||(w->e!=NULL)) return TRUE;
7155 idhdl hv=(idhdl)v->data;
7156 idhdl hw=(idhdl)w->data;
7157#ifdef HAVE_SHIFTBBA
7158 if (rIsLPRing(currRing))
7159 {
7160 if (currRing->LPncGenCount < IDELEMS((ideal)u->Data()))
7161 {
7162 Werror("At least %d ncgen variables are needed for this computation.", IDELEMS((ideal)u->Data()));
7163 return TRUE;
7164 }
7165 }
7166#endif
7167 // CopyD for IDEAL_CMD and MODUL_CMD are identical:
7168 res->data = (char *)idLiftStd((ideal)u->Data(),
7169 &(hv->data.umatrix),testHomog,
7170 &(hw->data.uideal));
7171 setFlag(res,FLAG_STD); v->flag=0; w->flag=0;
7172 return FALSE;
7173}
7175{
7176 if ((v->rtyp!=IDHDL)||(v->e!=NULL)) return TRUE;
7177 idhdl hv=(idhdl)v->data;
7178 GbVariant alg=syGetAlgorithm((char*)w->Data(),currRing,(ideal)u->Data());
7179#ifdef HAVE_SHIFTBBA
7180 if (rIsLPRing(currRing))
7181 {
7182 if (currRing->LPncGenCount < IDELEMS((ideal)u->Data()))
7183 {
7184 Werror("At least %d ncgen variables are needed for this computation.", IDELEMS((ideal)u->Data()));
7185 return TRUE;
7186 }
7187 }
7188#endif
7189 // CopyD for IDEAL_CMD and MODUL_CMD are identical:
7190 res->data = (char *)idLiftStd((ideal)u->Data(),
7191 &(hv->data.umatrix),testHomog,
7192 NULL,alg);
7193 setFlag(res,FLAG_STD); v->flag=0;
7194 return FALSE;
7195}
7197{
7199 if (!idIsZeroDim((ideal)v->Data()))
7200 {
7201 Werror("`%s` must be 0-dimensional",v->Name());
7202 return TRUE;
7203 }
7204 res->data = (char *)redNF((ideal)v->CopyD(),(poly)u->CopyD(),
7205 (poly)w->CopyD());
7206 return FALSE;
7207}
7209{
7211 if (!idIsZeroDim((ideal)v->Data()))
7212 {
7213 Werror("`%s` must be 0-dimensional",v->Name());
7214 return TRUE;
7215 }
7216 res->data = (char *)redNF((ideal)v->CopyD(),(ideal)u->CopyD(),
7217 (matrix)w->CopyD());
7218 return FALSE;
7219}
7221{
7223 res->data = (char *)kNF((ideal)v->Data(),currRing->qideal,(poly)u->Data(),
7224 0,(int)(long)w->Data());
7225 return FALSE;
7226}
7228{
7230 res->data = (char *)kNF((ideal)v->Data(),currRing->qideal,(ideal)u->Data(),
7231 0,(int)(long)w->Data());
7232 return FALSE;
7233}
7234#ifdef OLD_RES
7236{
7237 int maxl=(int)v->Data();
7238 ideal u_id=(ideal)u->Data();
7239 int l=0;
7240 resolvente r;
7241 intvec **weights=NULL;
7242 int wmaxl=maxl;
7243 maxl--;
7244 unsigned save_opt=si_opt_1;
7246 if ((maxl==-1) && (iiOp!=MRES_CMD))
7247 maxl = currRing->N-1;
7248 if ((iiOp == RES_CMD) || (iiOp == MRES_CMD))
7249 {
7250 intvec * iv=(intvec*)atGet(u,"isHomog",INTVEC_CMD);
7251 if (iv!=NULL)
7252 {
7253 l=1;
7254 if (!idTestHomModule(u_id,currRing->qideal,iv))
7255 {
7256 WarnS("wrong weights");
7257 iv=NULL;
7258 }
7259 else
7260 {
7261 weights = (intvec**)omAlloc0Bin(char_ptr_bin);
7262 weights[0] = ivCopy(iv);
7263 }
7264 }
7265 r=syResolvente(u_id,maxl,&l, &weights, iiOp==MRES_CMD);
7266 }
7267 else
7268 r=sySchreyerResolvente((ideal)u->Data(),maxl+1,&l);
7269 if (r==NULL) return TRUE;
7270 int t3=u->Typ();
7271 iiMakeResolv(r,l,wmaxl,w->name,t3,weights);
7272 si_opt_1=save_opt;
7273 return FALSE;
7274}
7275#endif
7277{
7278 res->data=(void *)rInit(u,v,w);
7279 return (res->data==NULL);
7280}
7282{
7283 int yes;
7284 jjSTATUS2(res, u, v);
7285 yes = (strcmp((char *) res->data, (char *) w->Data()) == 0);
7286 omFreeBinAddr((ADDRESS) res->data);
7287 res->data = (void *)(long)yes;
7288 return FALSE;
7289}
7291{
7292 intvec *vw=(intvec *)w->Data(); // weights of vars
7293 if (vw->length()!=currRing->N)
7294 {
7295 Werror("%d weights for %d variables",vw->length(),currRing->N);
7296 return TRUE;
7297 }
7298 ideal result;
7299 intvec *ww=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
7300 tHomog hom=testHomog;
7301 ideal u_id=(ideal)(u->Data());
7302 if (ww!=NULL)
7303 {
7304 if (!idTestHomModule(u_id,currRing->qideal,ww))
7305 {
7306 WarnS("wrong weights");
7307 ww=NULL;
7308 }
7309 else
7310 {
7311 ww=ivCopy(ww);
7312 hom=isHomog;
7313 }
7314 }
7315 bigintmat *vv=(bigintmat*)v->Data();
7316 result=kStd2(u_id,
7317 currRing->qideal,
7318 hom,
7319 &ww, // module weights
7320 vv, // hilbert series
7321 0,0, // syzComp, newIdeal
7322 vw); // weights of vars
7323 if (errorreported) return TRUE;
7325 res->data = (char *)result;
7327 if (ww!=NULL) atSet(res,omStrDup("isHomog"),ww,INTVEC_CMD);
7328 return FALSE;
7329}
7330
7331/*=================== operations with many arg.: static proc =================*/
7332/* must be ordered: first operations for chars (infix ops),
7333 * then alphabetically */
7335{
7336#ifdef HAVE_SDB
7337 sdb_show_bp();
7338#endif
7339 return FALSE;
7340}
7342{
7343#ifdef HAVE_SDB
7344 if(v->Typ()==PROC_CMD)
7345 {
7346 int lineno=0;
7347 if((v->next!=NULL) && (v->next->Typ()==INT_CMD))
7348 {
7349 lineno=(int)(long)v->next->Data();
7350 }
7351 return sdb_set_breakpoint(v->Name(),lineno);
7352 }
7353 return TRUE;
7354#else
7355 return FALSE;
7356#endif
7357}
7359{
7360 return iiExprArith1(res,v,iiOp);
7361}
7363{
7364 leftv v=u->next;
7365 u->next=NULL;
7366 BOOLEAN b=iiExprArith2(res,u,iiOp,v, (iiOp > 255));
7367 u->next=v;
7368 return b;
7369}
7371{
7372 leftv v = u->next;
7373 leftv w = v->next;
7374 u->next = NULL;
7375 v->next = NULL;
7376 BOOLEAN b = iiExprArith3(res, iiOp, u, v, w);
7377 u->next = v;
7378 v->next = w;
7379 return b;
7380}
7381
7383{
7384 const short t[]={4,VECTOR_CMD,POLY_CMD,MATRIX_CMD,MATRIX_CMD};
7385 if (iiCheckTypes(v,t,1))
7386 {
7387 idhdl c=(idhdl)v->next->next->data;
7388 if (v->next->next->next->rtyp!=IDHDL) return TRUE;
7389 idhdl m=(idhdl)v->next->next->next->data;
7390 idDelete((ideal *)&(c->data.uideal));
7391 idDelete((ideal *)&(m->data.uideal));
7392 mp_Coef2((poly)v->Data(),(poly)v->next->Data(),
7393 (matrix *)&(c->data.umatrix),(matrix *)&(m->data.umatrix),currRing);
7394 return FALSE;
7395 }
7396 return TRUE;
7397}
7398
7400{ // may have 3 or 4 arguments
7401 leftv v1=v;
7402 leftv v2=v1->next;
7403 leftv v3=v2->next;
7404 leftv v4=v3->next;
7405 assumeStdFlag(v2);
7406
7407 int i1=iiTestConvert(v1->Typ(),MODUL_CMD);
7408 int i2=iiTestConvert(v2->Typ(),MODUL_CMD);
7409
7410 if((i1==0)||(i2==0)
7411 ||(v3->Typ()!=INT_CMD)||((v4!=NULL)&&(v4->Typ()!=INTVEC_CMD)))
7412 {
7413 WarnS("<module>,<module>,<int>[,<intvec>] expected!");
7414 return TRUE;
7415 }
7416
7417 sleftv w1,w2;
7418 iiConvert(v1->Typ(),MODUL_CMD,i1,v1,&w1);
7419 iiConvert(v2->Typ(),MODUL_CMD,i2,v2,&w2);
7420 ideal P=(ideal)w1.Data();
7421 ideal Q=(ideal)w2.Data();
7422
7423 int n=(int)(long)v3->Data();
7424 int *w=NULL;
7425 if(v4!=NULL)
7426 {
7427 w = iv2array((intvec *)v4->Data(),currRing);
7428 int * w0 = w + 1;
7429 int i = currRing->N;
7430 while( (i > 0) && ((*w0) > 0) )
7431 {
7432 w0++;
7433 i--;
7434 }
7435 if(i>0)
7436 WarnS("not all weights are positive!");
7437 }
7438
7439 matrix T;
7440 ideal R;
7441 idLiftW(P,Q,n,T,R,w);
7442
7443 w1.CleanUp();
7444 w2.CleanUp();
7445 if(w!=NULL)
7446 omFreeSize( (ADDRESS)w, (rVar(currRing)+1)*sizeof(int) );
7447
7449 L->Init(2);
7450 L->m[1].rtyp=v1->Typ();
7451 if(v1->Typ()==POLY_CMD||v1->Typ()==VECTOR_CMD)
7452 {
7453 if(v1->Typ()==POLY_CMD)
7454 p_Shift(&R->m[0],-1,currRing);
7455 L->m[1].data=(void *)R->m[0];
7456 R->m[0]=NULL;
7457 idDelete(&R);
7458 }
7459 else if(v1->Typ()==IDEAL_CMD||v1->Typ()==MATRIX_CMD)
7460 L->m[1].data=(void *)id_Module2Matrix(R,currRing);
7461 else
7462 {
7463 L->m[1].rtyp=MODUL_CMD;
7464 L->m[1].data=(void *)R;
7465 }
7466 L->m[0].rtyp=MATRIX_CMD;
7467 L->m[0].data=(char *)T;
7468
7469 res->data=L;
7470
7471 return FALSE;
7472}
7473
7474//BOOLEAN jjDISPATCH(leftv res, leftv v)
7475//{
7476// WerrorS("`dispatch`: not implemented");
7477// return TRUE;
7478//}
7479
7480//static BOOLEAN jjEXPORTTO_M(leftv res, leftv u)
7481//{
7482// int l=u->listLength();
7483// if (l<2) return TRUE;
7484// BOOLEAN b;
7485// leftv v=u->next;
7486// leftv zz=v;
7487// leftv z=zz;
7488// u->next=NULL;
7489// do
7490// {
7491// leftv z=z->next;
7492// b=iiExprArith2(res,u,iiOp,z, (iiOp > 255));
7493// if (b) break;
7494// } while (z!=NULL);
7495// u->next=zz;
7496// return b;
7497//}
7499{
7500 leftv h=v;
7501 int s=exprlist_length(h);
7502 ideal id=idInit(s,1);
7503 int rank=1;
7504 int i=0;
7505 poly p;
7506 int dest_type=POLY_CMD;
7507 if (iiOp==MODUL_CMD) dest_type=VECTOR_CMD;
7508 while (h!=NULL)
7509 {
7510 // use standard type conversions to poly/vector
7511 int ri;
7512 int ht=h->Typ();
7513 if (ht==dest_type)
7514 {
7515 p=(poly)h->CopyD();
7516 if (p!=NULL) rank=si_max(rank,(int)pMaxComp(p));
7517 }
7518 else if ((ri=iiTestConvert(ht,dest_type,dConvertTypes))!=0)
7519 {
7520 sleftv tmp;
7521 leftv hnext=h->next;
7522 h->next=NULL;
7523 iiConvert(ht,dest_type,ri,h,&tmp,dConvertTypes);
7524 h->next=hnext;
7525 p=(poly)tmp.data;
7526 if (p!=NULL) rank=si_max(rank,(int)pMaxComp(p));
7527 }
7528 else
7529 {
7530 idDelete(&id);
7531 return TRUE;
7532 }
7533 id->m[i]=p;
7534 i++;
7535 h=h->next;
7536 }
7537 id->rank=rank;
7538 res->data=(char *)id;
7539 return FALSE;
7540}
7542{
7543 ring r=(ring)u->Data();
7544 leftv v=u->next;
7545 leftv perm_var_l=v->next;
7546 leftv perm_par_l=v->next->next;
7547 if ((perm_var_l->Typ()!=INTVEC_CMD)
7548 ||((perm_par_l!=NULL)&&(perm_par_l->Typ()!=INTVEC_CMD))
7549 ||(u->Typ()!=RING_CMD))
7550 {
7551 WerrorS("fetch(<ring>,<name>[,<intvec>[,<intvec>])");
7552 return TRUE;
7553 }
7554 intvec *perm_var_v=(intvec*)perm_var_l->Data();
7555 intvec *perm_par_v=NULL;
7556 if (perm_par_l!=NULL)
7557 perm_par_v=(intvec*)perm_par_l->Data();
7558 idhdl w;
7559 nMapFunc nMap;
7560
7561 if ((w=r->idroot->get(v->Name(),myynest))!=NULL)
7562 {
7563 int *perm=NULL;
7564 int *par_perm=NULL;
7565 int par_perm_size=0;
7566 BOOLEAN bo;
7567 if ((nMap=n_SetMap(r->cf,currRing->cf))==NULL)
7568 {
7569 // Allow imap/fetch to be make an exception only for:
7570 if (nCoeff_is_Extension(r->cf) && // Q(a..) -> Q(a..) || Q || Zp || Zp(a)
7571 ((n_SetMap(r->cf->extRing->cf,currRing->cf)!=NULL)
7572 || (nCoeff_is_Extension(currRing->cf) && (n_SetMap(r->cf->extRing->cf,currRing->cf->extRing->cf)!=NULL))))
7573 {
7574 par_perm_size=rPar(r);
7575 }
7576 else
7577 {
7578 goto err_fetch;
7579 }
7580 }
7581 else
7582 par_perm_size=rPar(r);
7583 perm=(int *)omAlloc0((rVar(r)+1)*sizeof(int));
7584 if (par_perm_size!=0)
7585 par_perm=(int *)omAlloc0(par_perm_size*sizeof(int));
7586 int i;
7587 if (perm_par_l==NULL)
7588 {
7589 if (par_perm_size!=0)
7590 for(i=si_min(rPar(r),rPar(currRing))-1;i>=0;i--) par_perm[i]=-(i+1);
7591 }
7592 else
7593 {
7594 if (par_perm_size==0) WarnS("source ring has no parameters");
7595 else
7596 {
7597 for(i=rPar(r)-1;i>=0;i--)
7598 {
7599 if (i<perm_par_v->length()) par_perm[i]=(*perm_par_v)[i];
7600 if ((par_perm[i]<-rPar(currRing))
7601 || (par_perm[i]>rVar(currRing)))
7602 {
7603 Warn("invalid entry for par %d: %d\n",i,par_perm[i]);
7604 par_perm[i]=0;
7605 }
7606 }
7607 }
7608 }
7609 for(i=rVar(r)-1;i>=0;i--)
7610 {
7611 if (i<perm_var_v->length()) perm[i+1]=(*perm_var_v)[i];
7612 if ((perm[i]<-rPar(currRing))
7613 || (perm[i]>rVar(currRing)))
7614 {
7615 Warn("invalid entry for var %d: %d\n",i,perm[i]);
7616 perm[i]=0;
7617 }
7618 }
7619 if (BVERBOSE(V_IMAP))
7620 {
7621 for(i=1;i<=si_min(rVar(r),rVar(currRing));i++)
7622 {
7623 if (perm[i]>0)
7624 Print("// var nr %d: %s -> var %s\n",i,r->names[i-1],currRing->names[perm[i]-1]);
7625 else if (perm[i]<0)
7626 Print("// var nr %d: %s -> par %s\n",i,r->names[i-1],rParameter(currRing)[-perm[i]-1]);
7627 }
7628 for(i=1;i<=si_min(rPar(r),rPar(currRing));i++) // possibly empty loop
7629 {
7630 if (par_perm[i-1]<0)
7631 Print("// par nr %d: %s -> par %s\n",
7632 i,rParameter(r)[i-1],rParameter(currRing)[-par_perm[i-1]-1]);
7633 else if (par_perm[i-1]>0)
7634 Print("// par nr %d: %s -> var %s\n",
7635 i,rParameter(r)[i-1],currRing->names[par_perm[i-1]-1]);
7636 }
7637 }
7638 if (IDTYP(w)==ALIAS_CMD) w=(idhdl)IDDATA(w);
7639 sleftv tmpW;
7640 tmpW.Init();
7641 tmpW.rtyp=IDTYP(w);
7642 tmpW.data=IDDATA(w);
7643 if ((bo=maApplyFetch(IMAP_CMD,NULL,res,&tmpW, r,
7644 perm,par_perm,par_perm_size,nMap)))
7645 {
7646 Werror("cannot map %s of type %s(%d)",v->name, Tok2Cmdname(w->typ),w->typ);
7647 }
7648 if (perm!=NULL)
7649 omFreeSize((ADDRESS)perm,(rVar(r)+1)*sizeof(int));
7650 if (par_perm!=NULL)
7651 omFreeSize((ADDRESS)par_perm,par_perm_size*sizeof(int));
7652 return bo;
7653 }
7654 else
7655 {
7656 Werror("identifier %s not found in %s",v->Fullname(),u->Fullname());
7657 }
7658 return TRUE;
7659err_fetch:
7660 char *s1=nCoeffString(r->cf);
7661 char *s2=nCoeffString(currRing->cf);
7662 Werror("no identity map from %s (%s -> %s)",u->Fullname(),s1,s2);
7664 return TRUE;
7665}
7667{
7668 leftv h=v;
7669 int l=v->listLength();
7670 resolvente r=(resolvente)omAlloc0(l*sizeof(ideal));
7671 BOOLEAN *copied=(BOOLEAN *)omAlloc0(l*sizeof(BOOLEAN));
7672 int t=0;
7673 // try to convert to IDEAL_CMD
7674 while (h!=NULL)
7675 {
7676 if (iiTestConvert(h->Typ(),IDEAL_CMD)!=0)
7677 {
7678 t=IDEAL_CMD;
7679 }
7680 else break;
7681 h=h->next;
7682 }
7683 // if failure, try MODUL_CMD
7684 if (t==0)
7685 {
7686 h=v;
7687 while (h!=NULL)
7688 {
7689 if (iiTestConvert(h->Typ(),MODUL_CMD)!=0)
7690 {
7691 t=MODUL_CMD;
7692 }
7693 else break;
7694 h=h->next;
7695 }
7696 }
7697 // check for success in converting
7698 if (t==0)
7699 {
7700 WerrorS("cannot convert to ideal or module");
7701 return TRUE;
7702 }
7703 // call idMultSect
7704 h=v;
7705 int i=0;
7706 sleftv tmp;
7707 while (h!=NULL)
7708 {
7709 if (h->Typ()==t)
7710 {
7711 r[i]=(ideal)h->Data(); /*no copy*/
7712 h=h->next;
7713 }
7714 else if(iiConvert(h->Typ(),t,iiTestConvert(h->Typ(),t),h,&tmp))
7715 {
7716 omFreeSize((ADDRESS)copied,l*sizeof(BOOLEAN));
7717 omFreeSize((ADDRESS)r,l*sizeof(ideal));
7718 Werror("cannot convert arg. %d to %s",i+1,Tok2Cmdname(t));
7719 return TRUE;
7720 }
7721 else
7722 {
7723 r[i]=(ideal)tmp.Data(); /*now it's a copy*/
7724 copied[i]=TRUE;
7725 h=tmp.next;
7726 }
7727 i++;
7728 }
7729 res->rtyp=t;
7730 res->data=(char *)idMultSect(r,i);
7731 while(i>0)
7732 {
7733 i--;
7734 if (copied[i]) idDelete(&(r[i]));
7735 }
7736 omFreeSize((ADDRESS)copied,l*sizeof(BOOLEAN));
7737 omFreeSize((ADDRESS)r,l*sizeof(ideal));
7738 return FALSE;
7739}
7741{
7742 /* computation of the inverse of a quadratic matrix A
7743 using the L-U-decomposition of A;
7744 There are two valid parametrisations:
7745 1) exactly one argument which is just the matrix A,
7746 2) exactly three arguments P, L, U which already
7747 realise the L-U-decomposition of A, that is,
7748 P * A = L * U, and P, L, and U satisfy the
7749 properties decribed in method 'jjLU_DECOMP';
7750 see there;
7751 If A is invertible, the list [1, A^(-1)] is returned,
7752 otherwise the list [0] is returned. Thus, the user may
7753 inspect the first entry of the returned list to see
7754 whether A is invertible. */
7755 matrix iMat; int invertible;
7756 const short t1[]={1,MATRIX_CMD};
7757 const short t2[]={3,MATRIX_CMD,MATRIX_CMD,MATRIX_CMD};
7758 if (iiCheckTypes(v,t1))
7759 {
7760 matrix aMat = (matrix)v->Data();
7761 int rr = aMat->rows();
7762 int cc = aMat->cols();
7763 if (rr != cc)
7764 {
7765 Werror("given matrix (%d x %d) is not quadratic, hence not invertible", rr, cc);
7766 return TRUE;
7767 }
7768 if (!idIsConstant((ideal)aMat))
7769 {
7770 WerrorS("matrix must be constant");
7771 return TRUE;
7772 }
7773 invertible = luInverse(aMat, iMat);
7774 }
7775 else if (iiCheckTypes(v,t2))
7776 {
7777 matrix pMat = (matrix)v->Data();
7778 matrix lMat = (matrix)v->next->Data();
7779 matrix uMat = (matrix)v->next->next->Data();
7780 int rr = uMat->rows();
7781 int cc = uMat->cols();
7782 if (rr != cc)
7783 {
7784 Werror("third matrix (%d x %d) is not quadratic, hence not invertible",
7785 rr, cc);
7786 return TRUE;
7787 }
7788 if (!idIsConstant((ideal)pMat)
7789 || (!idIsConstant((ideal)lMat))
7790 || (!idIsConstant((ideal)uMat))
7791 )
7792 {
7793 WerrorS("matricesx must be constant");
7794 return TRUE;
7795 }
7796 invertible = luInverseFromLUDecomp(pMat, lMat, uMat, iMat);
7797 }
7798 else
7799 {
7800 Werror("expected either one or three matrices");
7801 return TRUE;
7802 }
7803
7804 /* build the return structure; a list with either one or two entries */
7806 if (invertible)
7807 {
7808 ll->Init(2);
7809 ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)invertible;
7810 ll->m[1].rtyp=MATRIX_CMD; ll->m[1].data=(void *)iMat;
7811 }
7812 else
7813 {
7814 ll->Init(1);
7815 ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)invertible;
7816 }
7817
7818 res->data=(char*)ll;
7819 return FALSE;
7820}
7822{
7823 /* for solving a linear equation system A * x = b, via the
7824 given LU-decomposition of the matrix A;
7825 There is one valid parametrisation:
7826 1) exactly four arguments P, L, U, b;
7827 P, L, and U realise the L-U-decomposition of A, that is,
7828 P * A = L * U, and P, L, and U satisfy the
7829 properties decribed in method 'jjLU_DECOMP';
7830 see there;
7831 b is the right-hand side vector of the equation system;
7832 The method will return a list of either 1 entry or three entries:
7833 1) [0] if there is no solution to the system;
7834 2) [1, x, H] if there is at least one solution;
7835 x is any solution of the given linear system,
7836 H is the matrix with column vectors spanning the homogeneous
7837 solution space.
7838 The method produces an error if matrix and vector sizes do not fit. */
7839 const short t[]={4,MATRIX_CMD,MATRIX_CMD,MATRIX_CMD,MATRIX_CMD};
7840 if (!iiCheckTypes(v,t))
7841 {
7842 WerrorS("expected exactly three matrices and one vector as input");
7843 return TRUE;
7844 }
7845 matrix pMat = (matrix)v->Data();
7846 matrix lMat = (matrix)v->next->Data();
7847 matrix uMat = (matrix)v->next->next->Data();
7848 matrix bVec = (matrix)v->next->next->next->Data();
7849 matrix xVec; int solvable; matrix homogSolSpace;
7850 if (pMat->rows() != pMat->cols())
7851 {
7852 Werror("first matrix (%d x %d) is not quadratic",
7853 pMat->rows(), pMat->cols());
7854 return TRUE;
7855 }
7856 if (lMat->rows() != lMat->cols())
7857 {
7858 Werror("second matrix (%d x %d) is not quadratic",
7859 lMat->rows(), lMat->cols());
7860 return TRUE;
7861 }
7862 if (lMat->rows() != uMat->rows())
7863 {
7864 Werror("second matrix (%d x %d) and third matrix (%d x %d) do not fit",
7865 lMat->rows(), lMat->cols(), uMat->rows(), uMat->cols());
7866 return TRUE;
7867 }
7868 if (uMat->rows() != bVec->rows())
7869 {
7870 Werror("third matrix (%d x %d) and vector (%d x 1) do not fit",
7871 uMat->rows(), uMat->cols(), bVec->rows());
7872 return TRUE;
7873 }
7874 if (!idIsConstant((ideal)pMat)
7875 ||(!idIsConstant((ideal)lMat))
7876 ||(!idIsConstant((ideal)uMat))
7877 )
7878 {
7879 WerrorS("matrices must be constant");
7880 return TRUE;
7881 }
7882 solvable = luSolveViaLUDecomp(pMat, lMat, uMat, bVec, xVec, homogSolSpace);
7883
7884 /* build the return structure; a list with either one or three entries */
7886 if (solvable)
7887 {
7888 ll->Init(3);
7889 ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)solvable;
7890 ll->m[1].rtyp=MATRIX_CMD; ll->m[1].data=(void *)xVec;
7891 ll->m[2].rtyp=MATRIX_CMD; ll->m[2].data=(void *)homogSolSpace;
7892 }
7893 else
7894 {
7895 ll->Init(1);
7896 ll->m[0].rtyp=INT_CMD; ll->m[0].data=(void *)(long)solvable;
7897 }
7898
7899 res->data=(char*)ll;
7900 return FALSE;
7901}
7903{
7904 leftv h=v;
7905 int i=exprlist_length(h);
7906 intvec *iv=new intvec(i);
7907 i=0;
7908 while (h!=NULL)
7909 {
7910 if(h->Typ()==INT_CMD)
7911 {
7912 (*iv)[i]=(int)(long)h->Data();
7913 }
7914 else if (h->Typ()==INTVEC_CMD)
7915 {
7916 intvec *ivv=(intvec*)h->Data();
7917 for(int j=0;j<ivv->length();j++,i++)
7918 {
7919 (*iv)[i]=(*ivv)[j];
7920 }
7921 i--;
7922 }
7923 else
7924 {
7925 delete iv;
7926 return TRUE;
7927 }
7928 i++;
7929 h=h->next;
7930 }
7931 res->data=(char *)iv;
7932 return FALSE;
7933}
7935{
7936 leftv h=v;
7937 int l=0;
7938 while (h!=NULL)
7939 {
7940 if(h->Typ()==INT_CMD) l++;
7941 else if (h->Typ()==BIGINT_CMD) l++;
7942 else if (h->Typ()==INTVEC_CMD)
7943 {
7944 intvec *ivv=(intvec*)h->Data();
7945 l+=ivv->rows();
7946 }
7947 else if (h->Typ()==BIGINTVEC_CMD)
7948 {
7949 bigintmat *ivv=(bigintmat *)h->Data();
7950 l+=ivv->rows();
7951 }
7952 else return TRUE;
7953 h=h->next;
7954 }
7955 bigintmat *bim=new bigintmat(1,l,coeffs_BIGINT);
7956 h=v;
7957 int i=0;
7958 while (h!=NULL)
7959 {
7960 if(h->Typ()==INT_CMD)
7961 {
7962 number tp = n_Init((long)(h->Data()), coeffs_BIGINT);
7963 bim->set(i++, tp);
7964 n_Delete(&tp, coeffs_BIGINT);
7965 }
7966 else if (h->Typ()==INTVEC_CMD)
7967 {
7968 intvec *ivv=(intvec*)h->Data();
7969 for(int j=0;j<ivv->length();j++)
7970 {
7971 number tp = n_Init((long)(*ivv)[j], coeffs_BIGINT);
7972 bim->set(i++, tp);
7973 n_Delete(&tp, coeffs_BIGINT);
7974 }
7975 }
7976 else if(h->Typ()==BIGINT_CMD)
7977 {
7978 number tp = (number)h->Data();
7979 bim->set(i++, tp);
7980 }
7981 else if(h->Typ()==BIGINTVEC_CMD)
7982 {
7983 bigintmat *b=(bigintmat*)h->Data();
7984 for(int j=0;j<b->cols();j++)
7985 {
7986 number tp=BIMATELEM((*b),1,j);
7987 bim->set(i++, tp);
7988 }
7989 }
7990 h=h->next;
7991 }
7992 res->data=(char *)bim;
7993 return FALSE;
7994}
7996{
7997 const short t1[]={4,POLY_CMD,POLY_CMD,POLY_CMD,INTVEC_CMD};
7998 const short t2[]={4,VECTOR_CMD,POLY_CMD,POLY_CMD,INTVEC_CMD};
7999 const short t3[]={4,IDEAL_CMD,MATRIX_CMD,INT_CMD,INTVEC_CMD};
8000 const short t4[]={4,MODUL_CMD,MATRIX_CMD,INT_CMD,INTVEC_CMD};
8001 leftv u1=u;
8002 leftv u2=u1->next;
8003 leftv u3=u2->next;
8004 leftv u4=u3->next;
8005 if (iiCheckTypes(u,t1)||iiCheckTypes(u,t2))
8006 {
8007 if(!pIsUnit((poly)u2->Data()))
8008 {
8009 WerrorS("2nd argument must be a unit");
8010 return TRUE;
8011 }
8012 res->rtyp=u1->Typ();
8013 res->data=(char*)pSeries((int)(long)u3->Data(),pCopy((poly)u1->Data()),
8014 pCopy((poly)u2->Data()),(intvec*)u4->Data());
8015 return FALSE;
8016 }
8017 else
8018 if (iiCheckTypes(u,t3)||iiCheckTypes(u,t4))
8019 {
8020 if(!mp_IsDiagUnit((matrix)u2->Data(), currRing))
8021 {
8022 WerrorS("2nd argument must be a diagonal matrix of units");
8023 return TRUE;
8024 }
8025 res->rtyp=u1->Typ();
8026 res->data=(char*)idSeries(
8027 (int)(long)u3->Data(),
8028 idCopy((ideal)u1->Data()),
8029 mp_Copy((matrix)u2->Data(), currRing),
8030 (intvec*)u4->Data()
8031 );
8032 return FALSE;
8033 }
8034 else
8035 {
8036 Werror("%s(`poly`,`poly`,`int`,`intvec`) exppected",
8037 Tok2Cmdname(iiOp));
8038 return TRUE;
8039 }
8040}
8041#if 0
8042static BOOLEAN jjBRACKET_PL(leftv res, leftv u)
8043{
8044 int ut=u->Typ();
8045 leftv v=u->next; u->next=NULL;
8046 leftv w=v->next; v->next=NULL;
8047 if ((ut!=CRING_CMD)&&(ut!=RING_CMD))
8048 {
8049 BOOLEAN bo=TRUE;
8050 if (w==NULL)
8051 {
8052 bo=iiExprArith2(res,u,'[',v);
8053 }
8054 else if (w->next==NULL)
8055 {
8056 bo=iiExprArith3(res,'[',u,v,w);
8057 }
8058 v->next=w;
8059 u->next=v;
8060 return bo;
8061 }
8062 v->next=w;
8063 u->next=v;
8064 #ifdef SINGULAR_4_1
8065 // construct new rings:
8066 while (u!=NULL)
8067 {
8068 Print("name: %s,\n",u->Name());
8069 u=u->next;
8070 }
8071 #else
8072 res->Init();
8073 res->rtyp=NONE;
8074 return TRUE;
8075 #endif
8076}
8077#endif
8079{
8081 && ((strcmp(u->Name(),"real")==0) || (strcmp(u->Name(),"complex")==0)))
8082 {
8083 memcpy(res,u,sizeof(sleftv));
8084 u->Init();
8085 return FALSE;
8086 }
8087 leftv v=u->next;
8088 BOOLEAN b;
8089 if(v==NULL) // p()
8091 else if ((v->next==NULL) // p(1)
8092 || (u->Typ()!=UNKNOWN)) // p(1,2), p proc or map
8093 {
8094 u->next=NULL;
8095 b=iiExprArith2(res,u,iiOp,v);
8096 u->next=v;
8097 }
8098 else // p(1,2), p undefined
8099 {
8100 if (v->Typ()!=INT_CMD)
8101 {
8102 Werror("`%s` undefined or `int` expected while building `%s(`",u->name,u->name);
8103 return TRUE;
8104 }
8105 int l=u->listLength();
8106 size_t len=strlen(u->name) + 12*l;
8107 char * nn = (char *)omAlloc(len);
8108 snprintf(nn,len,"%s(%d",u->name,(int)(long)v->Data());
8109 char *s=nn;
8110 do
8111 {
8112 while (*s!='\0') s++;
8113 v=v->next;
8114 if (v->Typ()!=INT_CMD)
8115 {
8116 Werror("`%s` undefined or `int` expected while building `%s(`",u->name,u->name);
8117 omFree((ADDRESS)nn);
8118 return TRUE;
8119 }
8120 snprintf(s,len-(nn-s),",%d",(int)(long)v->Data());
8121 } while (v->next!=NULL);
8122 while (*s!='\0') s++;
8123 nn=strcat(nn,")");
8124 char *n=omStrDup(nn);
8125 omFree((ADDRESS)nn);
8126 syMake(res,n);
8127 b=FALSE;
8128 }
8129 return b;
8130}
8132{
8133 const short t1[]={4,IDEAL_CMD,IDEAL_CMD,MATRIX_CMD,STRING_CMD};
8134 const short t2[]={4,MODUL_CMD,MODUL_CMD,MATRIX_CMD,STRING_CMD};
8135 leftv u=U;
8136 leftv v=u->next;
8137 leftv w=v->next;
8138 leftv u4=w->next;
8139 if (w->rtyp!=IDHDL) return TRUE;
8140 if (iiCheckTypes(U,t1)||iiCheckTypes(U,t2))
8141 {
8142 // see jjLIFT3
8143 ideal I=(ideal)u->Data();
8144 int ul= IDELEMS(I /*(ideal)u->Data()*/);
8145 int vl= IDELEMS((ideal)v->Data());
8146 GbVariant alg=syGetAlgorithm((char*)u4->Data(),currRing,I);
8147 ideal m
8148 = idLift(I,(ideal)v->Data(),NULL,FALSE,hasFlag(u,FLAG_STD),
8149 FALSE, (matrix *)(&(IDMATRIX((idhdl)(w->data)))),alg);
8150 if (m==NULL) return TRUE;
8151 res->data = (char *)id_Module2formatedMatrix(m,ul,vl,currRing);
8152 return FALSE;
8153 }
8154 else
8155 {
8156 Werror("%s(`ideal`,`ideal`,`matrix`,`string`)\n"
8157 "or (`module`,`module`,`matrix`,`string`) expected",
8158 Tok2Cmdname(iiOp));
8159 return TRUE;
8160 }
8161}
8163{
8164 // we have 4 or 5 arguments
8165 leftv u=U;
8166 leftv v=u->next;
8167 leftv u3=v->next;
8168 leftv u4=u3->next;
8169 leftv u5=u4->next; // might be NULL
8170
8171 ideal *syz=NULL;
8172 GbVariant alg=GbDefault;
8173 ideal h11=NULL;
8174
8175 if(u5==NULL)
8176 {
8177 // test all three possibilities for 4 arguments
8178 const short t1[]={4,IDEAL_CMD,MATRIX_CMD,MODUL_CMD,STRING_CMD};
8179 const short t2[]={4,MODUL_CMD,MATRIX_CMD,MODUL_CMD,STRING_CMD};
8180 const short t3[]={4,IDEAL_CMD,MATRIX_CMD,MODUL_CMD,IDEAL_CMD};
8181 const short t4[]={4,MODUL_CMD,MATRIX_CMD,MODUL_CMD,MODUL_CMD};
8182 const short t5[]={4,IDEAL_CMD,MATRIX_CMD,STRING_CMD,IDEAL_CMD};
8183 const short t6[]={4,MODUL_CMD,MATRIX_CMD,STRING_CMD,MODUL_CMD};
8184
8185 if(iiCheckTypes(U,t1)||iiCheckTypes(U,t2))
8186 {
8187 if ((u3->rtyp!=IDHDL)||(u3->e!=NULL)) return TRUE;
8188 idhdl hw=(idhdl)u3->data;
8189 syz=&(hw->data.uideal);
8190 alg=syGetAlgorithm((char*)u4->Data(),currRing,(ideal)u->Data());
8191 }
8192 else if(iiCheckTypes(U,t3)||iiCheckTypes(U,t4))
8193 {
8194 if ((u3->rtyp!=IDHDL)||(u3->e!=NULL)) return TRUE;
8195 idhdl hw=(idhdl)u3->data;
8196 syz=&(hw->data.uideal);
8197 h11=(ideal)u4->Data();
8198 }
8199 else if(iiCheckTypes(U,t5)||iiCheckTypes(U,t6))
8200 {
8201 alg=syGetAlgorithm((char*)u3->Data(),currRing,(ideal)u->Data());
8202 h11=(ideal)u4->Data();
8203 }
8204 else
8205 {
8206 Werror("%s(`ideal/module`,`matrix`[,`module`][,`string`][,`ideal/module`]) expected",Tok2Cmdname(iiOp));
8207 return TRUE;
8208 }
8209 }
8210 else
8211 {
8212 // we have 5 arguments
8213 const short t1[]={5,IDEAL_CMD,MATRIX_CMD,MODUL_CMD,STRING_CMD,IDEAL_CMD};
8214 const short t2[]={5,MODUL_CMD,MATRIX_CMD,MODUL_CMD,STRING_CMD,MODUL_CMD};
8215 if(iiCheckTypes(U,t1)||iiCheckTypes(U,t2))
8216 {
8217 idhdl hw=(idhdl)u3->data;
8218 syz=&(hw->data.uideal);
8219 alg=syGetAlgorithm((char*)u4->Data(),currRing,(ideal)u->Data());
8220 h11=(ideal)u5->Data();
8221 }
8222 else
8223 {
8224 Werror("%s(`ideal/module`,`matrix`[,`module`][,`string`][,`ideal/module`]) expected",Tok2Cmdname(iiOp));
8225 return TRUE;
8226 }
8227 }
8228
8229#ifdef HAVE_SHIFTBBA
8230 if (rIsLPRing(currRing))
8231 {
8232 if (currRing->LPncGenCount < IDELEMS((ideal)u->Data()))
8233 {
8234 Werror("At least %d ncgen variables are needed for this computation.", IDELEMS((ideal)u->Data()));
8235 return TRUE;
8236 }
8237 }
8238#endif
8239
8240 if ((v->rtyp!=IDHDL)||(v->e!=NULL)) return TRUE;
8241 idhdl hv=(idhdl)v->data;
8242 // CopyD for IDEAL_CMD and MODUL_CMD are identical:
8243 res->rtyp = u->Typ();
8244 res->data = (char *)idLiftStd((ideal)u->Data(),
8245 &(hv->data.umatrix),testHomog,
8246 syz,alg,h11);
8247 setFlag(res,FLAG_STD); v->flag=0;
8248 if(syz!=NULL)
8249 u3->flag=0;
8250 return FALSE;
8251}
8253{
8254 int sl=0;
8255 if (v!=NULL) sl = v->listLength();
8256 lists L;
8257 if((sl==1)&&(v->Typ()==RESOLUTION_CMD))
8258 {
8259 int add_row_shift = 0;
8260 intvec *weights=(intvec*)atGet(v,"isHomog",INTVEC_CMD);
8261 if (weights!=NULL) add_row_shift=weights->min_in();
8262 L=syConvRes((syStrategy)v->Data(),FALSE,add_row_shift);
8263 }
8264 else
8265 {
8267 leftv h=NULL;
8268 int i;
8269 int rt;
8270
8271 L->Init(sl);
8272 for (i=0;i<sl;i++)
8273 {
8274 if (h!=NULL)
8275 { /* e.g. not in the first step:
8276 * h is the pointer to the old sleftv,
8277 * v is the pointer to the next sleftv
8278 * (in this moment) */
8279 h->next=v;
8280 }
8281 h=v;
8282 v=v->next;
8283 h->next=NULL;
8284 rt=h->Typ();
8285 if (rt==0)
8286 {
8287 L->Clean();
8288 Werror("`%s` is undefined",h->Fullname());
8289 return TRUE;
8290 }
8291 if (rt==RING_CMD)
8292 {
8293 L->m[i].rtyp=rt;
8294 L->m[i].data=rIncRefCnt(((ring)h->Data()));
8295 }
8296 else
8297 L->m[i].Copy(h);
8298 }
8299 }
8300 res->data=(char *)L;
8301 return FALSE;
8302}
8304{
8305 leftv v=u->next;
8306 leftv w=v->next;
8307 leftv u4=w->next;
8308 GbVariant alg;
8309 ideal u_id,v_id;
8310 // we have 4 arguments
8311 const short t1[]={4,IDEAL_CMD,IDEAL_CMD,MATRIX_CMD,STRING_CMD};
8312 const short t2[]={4,MODUL_CMD,MODUL_CMD,MATRIX_CMD,STRING_CMD};
8313 if(iiCheckTypes(u,t1)||iiCheckTypes(u,t2)||(w->rtyp!=IDHDL))
8314 {
8315 u_id=(ideal)u->Data();
8316 v_id=(ideal)v->Data();
8317 alg=syGetAlgorithm((char*)u4->Data(),currRing,u_id);
8318 }
8319 else
8320 {
8321 Werror("%s(`ideal/module`,`ideal/module`[,`matrix`][,`string`]) expected",Tok2Cmdname(iiOp));
8322 return TRUE;
8323 }
8324 intvec *w_u=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
8325 tHomog hom=testHomog;
8326 if (w_u!=NULL)
8327 {
8328 w_u=ivCopy(w_u);
8329 hom=isHomog;
8330 }
8331 intvec *w_v=(intvec *)atGet(v,"isHomog",INTVEC_CMD);
8332 if (w_v!=NULL)
8333 {
8334 w_v=ivCopy(w_v);
8335 hom=isHomog;
8336 }
8337 if ((w_u!=NULL) && (w_v==NULL))
8338 w_v=ivCopy(w_u);
8339 if ((w_v!=NULL) && (w_u==NULL))
8340 w_u=ivCopy(w_v);
8341 if (w_u!=NULL)
8342 {
8343 if ((*w_u).compare((w_v))!=0)
8344 {
8345 WarnS("incompatible weights");
8346 delete w_u; w_u=NULL;
8347 hom=testHomog;
8348 }
8349 else
8350 {
8351 if ((!idTestHomModule(u_id,currRing->qideal,w_v))
8352 || (!idTestHomModule(v_id,currRing->qideal,w_v)))
8353 {
8354 WarnS("wrong weights");
8355 delete w_u; w_u=NULL;
8356 hom=testHomog;
8357 }
8358 }
8359 }
8360 idhdl h=(idhdl)w->data;
8361 res->data = (char *)idModulo(u_id,v_id ,hom,&w_u, &(h->data.umatrix),alg);
8362 if (w_u!=NULL)
8363 {
8364 atSet(res,omStrDup("isHomog"),w_u,INTVEC_CMD);
8365 }
8366 delete w_v;
8367 //if (TEST_OPT_RETURN_SB) setFlag(res,FLAG_STD);
8368 return FALSE;
8369}
8371{
8372 res->data=(void *)ipNameList(IDROOT);
8373 return FALSE;
8374}
8376{
8377 if(v==NULL)
8378 {
8379 res->data=(char *)showOption();
8380 return FALSE;
8381 }
8382 res->rtyp=NONE;
8383 return setOption(res,v);
8384}
8386{
8387 leftv u1=u;
8388 leftv u2=u1->next;
8389 leftv u3=u2->next;
8390 leftv u4=u3->next;
8391 int u1t=u1->Typ(); if (u1t==BUCKET_CMD) u1t=POLY_CMD;
8392 int u2t=u2->Typ(); if (u2t==BUCKET_CMD) u2t=POLY_CMD;
8393 if((u3->Typ()==INT_CMD)&&(u4->Typ()==INTVEC_CMD))
8394 {
8395 int save_d=Kstd1_deg;
8396 Kstd1_deg=(int)(long)u3->Data();
8397 kModW=(intvec *)u4->Data();
8398 BITSET save2;
8399 SI_SAVE_OPT2(save2);
8401 u2->next=NULL;
8402 BOOLEAN r=jjCALL2ARG(res,u);
8403 kModW=NULL;
8404 Kstd1_deg=save_d;
8405 SI_RESTORE_OPT2(save2);
8406 u->next->next=u3;
8407 return r;
8408 }
8409 else
8410 if((u1t==IDEAL_CMD)&&(u2t==MATRIX_CMD)&&(u3->Typ()==IDEAL_CMD)&&
8411 (u4->Typ()==INT_CMD))
8412 {
8413 assumeStdFlag(u3);
8414 if(!mp_IsDiagUnit((matrix)u2->Data(), currRing))
8415 {
8416 WerrorS("2nd argument must be a diagonal matrix of units");
8417 return TRUE;
8418 }
8419 res->data=(char*)redNF(
8420 idCopy((ideal)u3->Data()),
8421 idCopy((ideal)u1->Data()),
8422 mp_Copy((matrix)u2->Data(), currRing),
8423 (int)(long)u4->Data()
8424 );
8425 return FALSE;
8426 }
8427 else
8428 if((u1t==POLY_CMD)&&(u2t==POLY_CMD)&&(u3->Typ()==IDEAL_CMD)&&
8429 (u4->Typ()==INT_CMD))
8430 {
8431 poly u1p;
8432 if (u1->Typ()==BUCKET_CMD) u1p=sBucketPeek((sBucket_pt)u1->Data());
8433 else u1p=(poly)u1->Data();
8434 poly u2p;
8435 if (u2->Typ()==BUCKET_CMD) u2p=sBucketPeek((sBucket_pt)u2->Data());
8436 else u2p=(poly)u2->Data();
8437 assumeStdFlag(u3);
8438 if(!pIsUnit(u2p))
8439 {
8440 WerrorS("2nd argument must be a unit");
8441 return TRUE;
8442 }
8443 res->rtyp=POLY_CMD;
8444 res->data=(char*)redNF((ideal)u3->CopyD(),pCopy(u1p),
8445 pCopy(u2p),(int)(long)u4->Data());
8446 return FALSE;
8447 }
8448 else
8449 {
8450 Werror("%s(`poly`,`ideal`,`int`,`intvec`) expected",Tok2Cmdname(iiOp));
8451 Werror("%s(`ideal`,`matrix`,`ideal`,`int`) expected",Tok2Cmdname(iiOp));
8452 Werror("%s(`poly`,`poly`,`ideal`,`int`) expected",Tok2Cmdname(iiOp));
8453 return TRUE;
8454 }
8455}
8457{
8458 leftv u1=u;
8459 leftv u2=u1->next;
8460 leftv u3=u2->next;
8461 leftv u4=u3->next;
8462 leftv u5=u4->next;
8463 if((u1->Typ()==IDEAL_CMD)&&(u2->Typ()==MATRIX_CMD)&&(u3->Typ()==IDEAL_CMD)&&
8464 (u4->Typ()==INT_CMD)&&(u5->Typ()==INTVEC_CMD))
8465 {
8466 assumeStdFlag(u3);
8467 if(!mp_IsDiagUnit((matrix)u2->Data(), currRing))
8468 {
8469 WerrorS("2nd argument must be a diagonal matrix of units");
8470 return TRUE;
8471 }
8472 res->data=(char*)redNF(
8473 idCopy((ideal)u3->Data()),
8474 idCopy((ideal)u1->Data()),
8475 mp_Copy((matrix)u2->Data(),currRing),
8476 (int)(long)u4->Data(),
8477 (intvec*)u5->Data()
8478 );
8479 return FALSE;
8480 }
8481 else
8482 if((u1->Typ()==POLY_CMD)&&(u2->Typ()==POLY_CMD)&&(u3->Typ()==IDEAL_CMD)&&
8483 (u4->Typ()==INT_CMD)&&(u5->Typ()==INTVEC_CMD))
8484 {
8485 assumeStdFlag(u3);
8486 if(!pIsUnit((poly)u2->Data()))
8487 {
8488 WerrorS("2nd argument must be a unit");
8489 return TRUE;
8490 }
8491 res->rtyp=POLY_CMD;
8492 res->data=(char*)redNF(idCopy((ideal)u3->Data()),pCopy((poly)u1->Data()),
8493 pCopy((poly)u2->Data()),
8494 (int)(long)u4->Data(),(intvec*)u5->Data());
8495 return FALSE;
8496 }
8497 else
8498 {
8499 Werror("%s(`ideal`,`ideal`,`matrix`,`int`,`intvec`) exppected",
8500 Tok2Cmdname(iiOp));
8501 return TRUE;
8502 }
8503}
8505{
8506 unsigned i=1;
8507 unsigned nCount = (sArithBase.nCmdUsed-1)/3;
8508 if((3*nCount)<sArithBase.nCmdUsed) nCount++;
8509 //Print("CMDS: %d/%d\n", sArithBase.nCmdUsed,
8510 // sArithBase.nCmdAllocated);
8511 for(i=0; i<nCount; i++)
8512 {
8513 Print("%-20s",sArithBase.sCmds[i+1].name);
8514 if(i+1+nCount<sArithBase.nCmdUsed)
8515 Print("%-20s",sArithBase.sCmds[i+1+nCount].name);
8516 if(i+1+2*nCount<sArithBase.nCmdUsed)
8517 Print("%-20s",sArithBase.sCmds[i+1+2*nCount].name);
8518 //if ((i%3)==1) PrintLn();
8519 PrintLn();
8520 }
8521 PrintLn();
8523 return FALSE;
8524}
8525
8527{
8528 int l = 0;
8529 int k = 0;
8531 struct blackbox_list *bb_list = NULL;
8532 unsigned nCount = (sArithBase.nCmdUsed-1) / 3;
8533
8534 if ((3*nCount) < sArithBase.nCmdUsed)
8535 {
8536 nCount++;
8537 }
8538 bb_list = getBlackboxTypes();
8539 // count the number of entries;
8540 for (unsigned i=0; i<nCount; i++)
8541 {
8542 l++;
8543 if (i + 1 + nCount < sArithBase.nCmdUsed)
8544 {
8545 l++;
8546 }
8547 if(i+1+2*nCount<sArithBase.nCmdUsed)
8548 {
8549 l++;
8550 }
8551 }
8552 for (int i = 0; i < bb_list->count; i++)
8553 {
8554 if (bb_list->list[i] != NULL)
8555 {
8556 l++;
8557 }
8558 }
8559 // initiate list
8560 L->Init(l);
8561 k = 0;
8562 for (unsigned i=0; i<nCount; i++)
8563 {
8564 L->m[k].rtyp = STRING_CMD;
8565 L->m[k].data = omStrDup(sArithBase.sCmds[i+1].name);
8566 k++;
8567 // Print("%-20s", sArithBase.sCmds[i+1].name);
8568 if (i + 1 + nCount < sArithBase.nCmdUsed)
8569 {
8570 L->m[k].rtyp = STRING_CMD;
8571 L->m[k].data = omStrDup(sArithBase.sCmds[i+1+nCount].name);
8572 k++;
8573 // Print("%-20s", sArithBase.sCmds[i+1 + nCount].name);
8574 }
8575 if(i+1+2*nCount<sArithBase.nCmdUsed)
8576 {
8577 L->m[k].rtyp = STRING_CMD;
8578 L->m[k].data = omStrDup(sArithBase.sCmds[i+1+2*nCount].name);
8579 k++;
8580 // Print("%-20s", sArithBase.sCmds[i+1+2*nCount].name);
8581 }
8582 // PrintLn();
8583 }
8584
8585 // assign blackbox types
8586 for (int i = 0; i < bb_list->count; i++)
8587 {
8588 if (bb_list->list[i] != NULL)
8589 {
8590 L->m[k].rtyp = STRING_CMD;
8591 // already used strdup in getBlackBoxTypes
8592 L->m[k].data = bb_list->list[i];
8593 k++;
8594 }
8595 }
8596 // free the struct (not the list entries itself, which were allocated
8597 // by strdup)
8598 omfree(bb_list->list);
8599 omfree(bb_list);
8600
8601 // pass the resultant list to the res datastructure
8602 res->data=(void *)L;
8603
8604 return FALSE;
8605}
8607{
8608 if (v == NULL)
8609 {
8610 res->data = omStrDup("");
8611 return FALSE;
8612 }
8613 int n = v->listLength();
8614 if (n == 1)
8615 {
8616 res->data = v->String();
8617 return FALSE;
8618 }
8619
8620 char** slist = (char**) omAlloc(n*sizeof(char*));
8621 int i, j;
8622
8623 for (i=0, j=0; i<n; i++, v = v ->next)
8624 {
8625 slist[i] = v->String();
8626 assume(slist[i] != NULL);
8627 j+=strlen(slist[i]);
8628 }
8629 char* s = (char*) omAlloc((j+1)*sizeof(char));
8630 *s='\0';
8631 for (i=0;i<n;i++)
8632 {
8633 strcat(s, slist[i]);
8634 omFree(slist[i]);
8635 }
8636 omFreeSize(slist, n*sizeof(char*));
8637 res->data = s;
8638 return FALSE;
8639}
8641{
8642 do
8643 {
8644 if (v->Typ()!=INT_CMD)
8645 return TRUE;
8646 test_cmd((int)(long)v->Data());
8647 v=v->next;
8648 }
8649 while (v!=NULL);
8650 return FALSE;
8651}
8652
8653#if defined(__alpha) && !defined(linux)
8654extern "C"
8655{
8656 void usleep(unsigned long usec);
8657};
8658#endif
8660{
8661 /* compute two factors of h(x,y) modulo x^(d+1) in K[[x]][y],
8662 see a detailed documentation in /kernel/linear_algebra/linearAlgebra.h
8663
8664 valid argument lists:
8665 - (poly h, int d),
8666 - (poly h, int d, poly f0, poly g0), optional: factors of h(0,y),
8667 - (poly h, int d, int xIndex, int yIndex), optional: indices of vars x & y
8668 in list of ring vars,
8669 - (poly h, int d, poly f0, poly g0, int xIndex, int yIndec),
8670 optional: all 4 optional args
8671 (The defaults are xIndex = 1, yIndex = 2, f0 and g0 polynomials as found
8672 by singclap_factorize and h(0, y)
8673 has exactly two distinct monic factors [possibly with exponent > 1].)
8674 result:
8675 - list with the two factors f and g such that
8676 h(x,y) = f(x,y)*g(x,y) mod x^(d+1) */
8677
8678 poly h = NULL;
8679 int d = 1;
8680 poly f0 = NULL;
8681 poly g0 = NULL;
8682 int xIndex = 1; /* default index if none provided */
8683 int yIndex = 2; /* default index if none provided */
8684
8685 leftv u = v; int factorsGiven = 0;
8686 if ((u == NULL) || (u->Typ() != POLY_CMD))
8687 {
8688 WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
8689 return TRUE;
8690 }
8691 else h = (poly)u->Data();
8692 u = u->next;
8693 if ((u == NULL) || (u->Typ() != INT_CMD))
8694 {
8695 WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
8696 return TRUE;
8697 }
8698 else d = (int)(long)u->Data();
8699 u = u->next;
8700 if ((u != NULL) && (u->Typ() == POLY_CMD))
8701 {
8702 if ((u->next == NULL) || (u->next->Typ() != POLY_CMD))
8703 {
8704 WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
8705 return TRUE;
8706 }
8707 else
8708 {
8709 f0 = (poly)u->Data();
8710 g0 = (poly)u->next->Data();
8711 factorsGiven = 1;
8712 u = u->next->next;
8713 }
8714 }
8715 if ((u != NULL) && (u->Typ() == INT_CMD))
8716 {
8717 if ((u->next == NULL) || (u->next->Typ() != INT_CMD))
8718 {
8719 WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
8720 return TRUE;
8721 }
8722 else
8723 {
8724 xIndex = (int)(long)u->Data();
8725 yIndex = (int)(long)u->next->Data();
8726 u = u->next->next;
8727 }
8728 }
8729 if (u != NULL)
8730 {
8731 WerrorS("expected arguments (poly, int [, poly, poly] [, int, int])");
8732 return TRUE;
8733 }
8734
8735 /* checks for provided arguments */
8736 if (pIsConstant(h) || (factorsGiven && (pIsConstant(f0) || pIsConstant(g0))))
8737 {
8738 WerrorS("expected non-constant polynomial argument(s)");
8739 return TRUE;
8740 }
8741 int n = rVar(currRing);
8742 if ((xIndex < 1) || (n < xIndex))
8743 {
8744 Werror("index for variable x (%d) out of range [1..%d]", xIndex, n);
8745 return TRUE;
8746 }
8747 if ((yIndex < 1) || (n < yIndex))
8748 {
8749 Werror("index for variable y (%d) out of range [1..%d]", yIndex, n);
8750 return TRUE;
8751 }
8752 if (xIndex == yIndex)
8753 {
8754 WerrorS("expected distinct indices for variables x and y");
8755 return TRUE;
8756 }
8757
8758 /* computation of f0 and g0 if missing */
8759 if (factorsGiven == 0)
8760 {
8761 poly h0 = pSubst(pCopy(h), xIndex, NULL);
8762 intvec* v = NULL;
8763 ideal i = singclap_factorize(h0, &v, 0,currRing);
8764
8765 ivTest(v);
8766
8767 if (i == NULL) return TRUE;
8768
8769 idTest(i);
8770
8771 if ((v->rows() != 3) || ((*v)[0] =! 1) || (!nIsOne(pGetCoeff(i->m[0]))))
8772 {
8773 WerrorS("expected h(0,y) to have exactly two distinct monic factors");
8774 return TRUE;
8775 }
8776 f0 = pPower(pCopy(i->m[1]), (*v)[1]);
8777 g0 = pPower(pCopy(i->m[2]), (*v)[2]);
8778 idDelete(&i);
8779 }
8780
8781 poly f; poly g;
8782 henselFactors(xIndex, yIndex, h, f0, g0, d, f, g);
8784 L->Init(2);
8785 L->m[0].rtyp = POLY_CMD; L->m[0].data=(void*)f;
8786 L->m[1].rtyp = POLY_CMD; L->m[1].data=(void*)g;
8787 res->rtyp = LIST_CMD;
8788 res->data = (char*)L;
8789 return FALSE;
8790}
8792{
8793 if ((v->Typ() != LINK_CMD) ||
8794 (v->next->Typ() != STRING_CMD) ||
8795 (v->next->next->Typ() != STRING_CMD) ||
8796 (v->next->next->next->Typ() != INT_CMD))
8797 return TRUE;
8798 jjSTATUS3(res, v, v->next, v->next->next);
8799#if defined(HAVE_USLEEP)
8800 if (((long) res->data) == 0L)
8801 {
8802 int i_s = (int)(long) v->next->next->next->Data();
8803 if (i_s > 0)
8804 {
8805 usleep((int)(long) v->next->next->next->Data());
8806 jjSTATUS3(res, v, v->next, v->next->next);
8807 }
8808 }
8809#elif defined(HAVE_SLEEP)
8810 if (((int) res->data) == 0)
8811 {
8812 int i_s = (int) v->next->next->next->Data();
8813 if (i_s > 0)
8814 {
8815 si_sleep((is - 1)/1000000 + 1);
8816 jjSTATUS3(res, v, v->next, v->next->next);
8817 }
8818 }
8819#endif
8820 return FALSE;
8821}
8823{
8824 leftv v = u->next; // number of args > 0
8825 if (v==NULL) return TRUE;
8826 leftv w = v->next;
8827 if (w==NULL) return TRUE;
8828 leftv rest = w->next;
8829
8830 u->next = NULL;
8831 v->next = NULL;
8832 w->next = NULL;
8833 BOOLEAN b = iiExprArith3(res, iiOp, u, v, w);
8834 if ((rest!=NULL) && (!b))
8835 {
8836 leftv tmp_next=res->next;
8837 res->next=rest;
8838 sleftv tmp_res;
8839 tmp_res.Init();
8840 b = iiExprArithM(&tmp_res,res,iiOp);
8841 memcpy(res,&tmp_res,sizeof(tmp_res));
8842 res->next=tmp_next;
8843 }
8844 u->next = v;
8845 v->next = w;
8846 // rest was w->next, but is already cleaned
8847 return b;
8848}
8850{
8851 if ((INPUT->Typ() != MATRIX_CMD) ||
8852 (INPUT->next->Typ() != NUMBER_CMD) ||
8853 (INPUT->next->next->Typ() != NUMBER_CMD) ||
8854 (INPUT->next->next->next->Typ() != NUMBER_CMD))
8855 {
8856 WerrorS("expected (matrix, number, number, number) as arguments");
8857 return TRUE;
8858 }
8859 leftv u = INPUT; leftv v = u->next; leftv w = v->next; leftv x = w->next;
8860 res->data = (char *)qrDoubleShift((matrix)(u->Data()),
8861 (number)(v->Data()),
8862 (number)(w->Data()),
8863 (number)(x->Data()));
8864 return FALSE;
8865}
8867{ ideal result;
8868 leftv u = INPUT; /* an ideal, weighted homogeneous and standard */
8869 leftv v = u->next; /* one additional polynomial or ideal */
8870 leftv h = v->next; /* Hilbert vector */
8871 leftv w = h->next; /* weight vector */
8872 assumeStdFlag(u);
8873 ideal i1=(ideal)(u->Data());
8874 ideal i0;
8875 if (((u->Typ()!=IDEAL_CMD)&&(u->Typ()!=MODUL_CMD))
8876 || (h->Typ()!=BIGINTVEC_CMD)
8877 || (w->Typ()!=INTVEC_CMD))
8878 {
8879 WerrorS("expected `std(`ideal/module`,`poly/vector`,`bigintvec`,`intvec`)");
8880 return TRUE;
8881 }
8882 intvec *vw=(intvec *)w->Data(); // weights of vars
8883 /* merging std_hilb_w and std_1 */
8884 if (vw->length()!=currRing->N)
8885 {
8886 Werror("%d weights for %d variables",vw->length(),currRing->N);
8887 return TRUE;
8888 }
8889 int r=v->Typ();
8890 BOOLEAN cleanup_i0=FALSE;
8891 if ((r==POLY_CMD) ||(r==VECTOR_CMD))
8892 {
8893 i0=idInit(1,i1->rank);
8894 i0->m[0]=(poly)v->Data();
8895 cleanup_i0=TRUE;
8896 }
8897 else if (r==IDEAL_CMD)/* IDEAL */
8898 {
8899 i0=(ideal)v->Data();
8900 }
8901 else
8902 {
8903 WerrorS("expected `std(`ideal/module`,`poly/vector`,`intvec`,`intvec`)");
8904 return TRUE;
8905 }
8906 int ii0=idElem(i0);
8907 i1 = idSimpleAdd(i1,i0);
8908 if (cleanup_i0)
8909 {
8910 memset(i0->m,0,sizeof(poly)*IDELEMS(i0));
8911 idDelete(&i0);
8912 }
8913 intvec *ww=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
8914 tHomog hom=testHomog;
8915 /* u_id from jjSTD_W is now i1 as in jjSTD_1 */
8916 if (ww!=NULL)
8917 {
8918 if (!idTestHomModule(i1,currRing->qideal,ww))
8919 {
8920 WarnS("wrong weights");
8921 ww=NULL;
8922 }
8923 else
8924 {
8925 ww=ivCopy(ww);
8926 hom=isHomog;
8927 }
8928 }
8929 BITSET save1;
8930 SI_SAVE_OPT1(save1);
8932 result=kStd2(i1,
8933 currRing->qideal,
8934 hom,
8935 &ww, // module weights
8936 (bigintmat *)h->Data(), // hilbert series
8937 0, // syzComp, whatever it is...
8938 IDELEMS(i1)-ii0, // new ideal
8939 vw); // weights of vars
8940 SI_RESTORE_OPT1(save1);
8941 if (errorreported) return TRUE;
8942 idDelete(&i1);
8944 res->data = (char *)result;
8946 if (ww!=NULL) atSet(res,omStrDup("isHomog"),ww,INTVEC_CMD);
8947 return FALSE;
8948}
8949
8951{
8952 //Print("construct ring\n");
8953 if (a->Typ()!=CRING_CMD)
8954 {
8955 WerrorS("expected `cring` [ `id` ... ]");
8956 return TRUE;
8957 }
8958 assume(a->next!=NULL);
8959 leftv names=a->next;
8960 int N=names->listLength();
8961 char **n=(char**)omAlloc0(N*sizeof(char*));
8962 for(int i=0; i<N;i++,names=names->next)
8963 {
8964 n[i]=(char *)names->Name();
8965 }
8966 coeffs cf=(coeffs)a->CopyD();
8967 res->data=rDefault(cf,N,n, ringorder_dp);
8968 omFreeSize(n,N*sizeof(char*));
8969 return FALSE;
8970}
8971
8972static Subexpr jjMakeSub(leftv e)
8973{
8974 assume( e->Typ()==INT_CMD );
8975 Subexpr r=(Subexpr)omAlloc0Bin(sSubexpr_bin);
8976 r->start =(int)(long)e->Data();
8977 return r;
8978}
8980{
8981 int c=(int)(long)u->Data();
8982 switch(c)
8983 {
8984 case 0:{
8985 PrintS("delete all variables\n");
8986 killlocals(0);
8987 WerrorS("restarting...");
8988 break;
8989 };
8990 default: WerrorS("not implemented");
8991 }
8992 return FALSE;
8993}
8994#define D(A) (A)
8995#define NULL_VAL NULL
8996#define IPARITH
8997#include "table.h"
8998
8999#include "iparith.inc"
9000
9001/*=================== operations with 2 args. ============================*/
9002/* must be ordered: first operations for chars (infix ops),
9003 * then alphabetically */
9004
9006 BOOLEAN proccall,
9007 const struct sValCmd2* dA2,
9008 int at, int bt,
9009 const struct sConvertTypes *dConvertTypes)
9010{
9011 BOOLEAN call_failed=FALSE;
9012
9013 if (!errorreported)
9014 {
9015 int i=0;
9016 iiOp=op;
9017 while (dA2[i].cmd==op)
9018 {
9019 if ((at==dA2[i].arg1)
9020 && (bt==dA2[i].arg2))
9021 {
9022 res->rtyp=dA2[i].res;
9023 if (currRing!=NULL)
9024 {
9025 if (check_valid(dA2[i].valid_for,op)) break;
9026 }
9027 else
9028 {
9029 if (RingDependend(dA2[i].res))
9030 {
9031 WerrorS("no ring active (3)");
9032 break;
9033 }
9034 }
9035 if (traceit&TRACE_CALL)
9036 Print("call %s(%s,%s)\n",iiTwoOps(op),Tok2Cmdname(at),Tok2Cmdname(bt));
9037 if ((call_failed=dA2[i].p(res,a,b)))
9038 {
9039 break;// leave loop, goto error handling
9040 }
9041 a->CleanUp();
9042 b->CleanUp();
9043 //Print("op: %d,result typ:%d\n",op,res->rtyp);
9044 return FALSE;
9045 }
9046 i++;
9047 }
9048 // implicite type conversion ----------------------------------------------
9049 if (dA2[i].cmd!=op)
9050 {
9051 int ai,bi;
9054 BOOLEAN failed=FALSE;
9055 i=0; /*iiTabIndex(dArithTab2,JJTAB2LEN,op);*/
9056 //Print("op: %c, type: %s %s\n",op,Tok2Cmdname(at),Tok2Cmdname(bt));
9057 while (dA2[i].cmd==op)
9058 {
9059 //Print("test %s %s\n",Tok2Cmdname(dA2[i].arg1),Tok2Cmdname(dA2[i].arg2));
9060 if ((dA2[i].valid_for & NO_CONVERSION)==0)
9061 {
9062 if ((ai=iiTestConvert(at,dA2[i].arg1,dConvertTypes))!=0)
9063 {
9064 if ((bi=iiTestConvert(bt,dA2[i].arg2,dConvertTypes))!=0)
9065 {
9066 res->rtyp=dA2[i].res;
9067 if (currRing!=NULL)
9068 {
9069 if (check_valid(dA2[i].valid_for,op)) break;
9070 }
9071 else
9072 {
9073 if (RingDependend(dA2[i].res))
9074 {
9075 WerrorS("no ring active (4)");
9076 break;
9077 }
9078 }
9079 if (traceit&TRACE_CALL)
9080 Print("call %s(%s,%s)\n",iiTwoOps(op),
9081 Tok2Cmdname(dA2[i].arg1),Tok2Cmdname(dA2[i].arg2));
9082 failed= ((iiConvert(at,dA2[i].arg1,ai,a,an))
9083 || (iiConvert(bt,dA2[i].arg2,bi,b,bn))
9084 || (call_failed=dA2[i].p(res,an,bn)));
9085 // everything done, clean up temp. variables
9086 if (failed)
9087 {
9088 // leave loop, goto error handling
9089 break;
9090 }
9091 else
9092 {
9093 // everything ok, clean up and return
9094 an->CleanUp();
9095 bn->CleanUp();
9098 return FALSE;
9099 }
9100 }
9101 }
9102 }
9103 i++;
9104 }
9105 an->CleanUp();
9106 bn->CleanUp();
9109 }
9110 // error handling ---------------------------------------------------
9111 const char *s=NULL;
9112 if (!errorreported)
9113 {
9114 if ((at==0) && (a->Fullname()!=sNoName_fe))
9115 {
9116 s=a->Fullname();
9117 }
9118 else if ((bt==0) && (b->Fullname()!=sNoName_fe))
9119 {
9120 s=b->Fullname();
9121 }
9122 if (s!=NULL)
9123 Werror("`%s` is not defined",s);
9124 else
9125 {
9126 i=0; /*iiTabIndex(dArithTab2,JJTAB2LEN,op);*/
9127 s = iiTwoOps(op);
9128 if (proccall)
9129 {
9130 Werror("%s(`%s`,`%s`) failed"
9131 ,s,Tok2Cmdname(at),Tok2Cmdname(bt));
9132 }
9133 else
9134 {
9135 Werror("`%s` %s `%s` failed"
9136 ,Tok2Cmdname(at),s,Tok2Cmdname(bt));
9137 }
9138 if ((!call_failed) && BVERBOSE(V_SHOW_USE))
9139 {
9140 while (dA2[i].cmd==op)
9141 {
9142 if(((at==dA2[i].arg1)||(bt==dA2[i].arg2))
9143 && (dA2[i].res!=0)
9144 && (dA2[i].p!=jjWRONG2))
9145 {
9146 if (proccall)
9147 Werror("expected %s(`%s`,`%s`)"
9148 ,s,Tok2Cmdname(dA2[i].arg1),Tok2Cmdname(dA2[i].arg2));
9149 else
9150 Werror("expected `%s` %s `%s`"
9151 ,Tok2Cmdname(dA2[i].arg1),s,Tok2Cmdname(dA2[i].arg2));
9152 }
9153 i++;
9154 }
9155 }
9156 }
9157 }
9158 a->CleanUp();
9159 b->CleanUp();
9160 res->rtyp = UNKNOWN;
9161 }
9162 return TRUE;
9163}
9165 const struct sValCmd2* dA2,
9166 int at,
9167 const struct sConvertTypes *dConvertTypes)
9168{
9169 res->Init();
9170 leftv b=a->next;
9171 a->next=NULL;
9172 int bt=b->Typ();
9174 a->next=b;
9175 a->CleanUp(); // to clean up the chain, content already done in iiExprArith2TabIntern
9176 return bo;
9177}
9179{
9180 res->Init();
9181
9182 if (!errorreported)
9183 {
9184#ifdef SIQ
9185 if (siq>0)
9186 {
9187 //Print("siq:%d\n",siq);
9189 memcpy(&d->arg1,a,sizeof(sleftv));
9190 a->Init();
9191 memcpy(&d->arg2,b,sizeof(sleftv));
9192 b->Init();
9193 d->argc=2;
9194 d->op=op;
9195 res->data=(char *)d;
9196 res->rtyp=COMMAND;
9197 return FALSE;
9198 }
9199#endif
9200 int at=a->Typ();
9201 int bt=b->Typ();
9202 // handling bb-objects ----------------------------------------------------
9203 if (at>MAX_TOK)
9204 {
9205 blackbox *bb=getBlackboxStuff(at);
9206 if (bb!=NULL)
9207 {
9208 if(!bb->blackbox_Op2(op,res,a,b)) return FALSE;
9209 // if not defined, try generic (attrib, ..)
9210 }
9211 else
9212 return TRUE;
9213 }
9214 else if ((bt>MAX_TOK)&&(op!='('))
9215 {
9216 blackbox *bb=getBlackboxStuff(bt);
9217 if (bb!=NULL)
9218 {
9219 if(!bb->blackbox_Op2(op,res,a,b)) return FALSE;
9220 // if not defined, try generic (attrib, ..)
9221 }
9222 else
9223 return TRUE;
9224 }
9225 int i=iiTabIndex(dArithTab2,JJTAB2LEN,op);
9226 return iiExprArith2TabIntern(res,a,op,b,proccall,dArith2+i,at,bt,dConvertTypes);
9227 }
9228 a->CleanUp();
9229 b->CleanUp();
9230 return TRUE;
9231}
9232
9233/*==================== operations with 1 arg. ===============================*/
9234/* must be ordered: first operations for chars (infix ops),
9235 * then alphabetically */
9236
9237BOOLEAN iiExprArith1Tab(leftv res, leftv a, int op, const struct sValCmd1* dA1, int at, const struct sConvertTypes *dConvertTypes)
9238{
9239 res->Init();
9240 BOOLEAN call_failed=FALSE;
9241
9242 if (!errorreported)
9243 {
9244 BOOLEAN failed=FALSE;
9245 iiOp=op;
9246 int i = 0;
9247 while (dA1[i].cmd==op)
9248 {
9249 if (at==dA1[i].arg)
9250 {
9251 if (currRing!=NULL)
9252 {
9253 if (check_valid(dA1[i].valid_for,op)) break;
9254 }
9255 else
9256 {
9257 if (RingDependend(dA1[i].res))
9258 {
9259 WerrorS("no ring active (5)");
9260 break;
9261 }
9262 }
9263 if (traceit&TRACE_CALL)
9264 Print("call %s(%s)\n",iiTwoOps(op),Tok2Cmdname(at));
9265 res->rtyp=dA1[i].res;
9266 if ((call_failed=dA1[i].p(res,a)))
9267 {
9268 break;// leave loop, goto error handling
9269 }
9270 if (a->Next()!=NULL)
9271 {
9273 failed=iiExprArith1(res->next,a->next,op);
9274 }
9275 a->CleanUp();
9276 return failed;
9277 }
9278 i++;
9279 }
9280 // implicite type conversion --------------------------------------------
9281 if (dA1[i].cmd!=op)
9282 {
9284 i=0;
9285 //Print("fuer %c , typ: %s\n",op,Tok2Cmdname(at));
9286 while (dA1[i].cmd==op)
9287 {
9288 int ai;
9289 //Print("test %s\n",Tok2Cmdname(dA1[i].arg));
9290 if ((dA1[i].valid_for & NO_CONVERSION)==0)
9291 {
9292 if ((ai=iiTestConvert(at,dA1[i].arg,dConvertTypes))!=0)
9293 {
9294 if (currRing!=NULL)
9295 {
9296 if (check_valid(dA1[i].valid_for,op)) break;
9297 }
9298 else
9299 {
9300 if (RingDependend(dA1[i].res))
9301 {
9302 WerrorS("no ring active (6)");
9303 break;
9304 }
9305 }
9306 if (traceit&TRACE_CALL)
9307 Print("call %s(%s)\n",iiTwoOps(op),Tok2Cmdname(dA1[i].arg));
9308 res->rtyp=dA1[i].res;
9309 failed= ((iiConvert(at,dA1[i].arg,ai,a,an,dConvertTypes))
9310 || (call_failed=dA1[i].p(res,an)));
9311 // everything done, clean up temp. variables
9312 if (failed)
9313 {
9314 // leave loop, goto error handling
9315 break;
9316 }
9317 else
9318 {
9319 if (an->Next() != NULL)
9320 {
9321 res->next = (leftv)omAllocBin(sleftv_bin);
9322 failed=iiExprArith1(res->next,an->next,op);
9323 }
9324 // everything ok, clean up and return
9325 an->CleanUp();
9327 return failed;
9328 }
9329 }
9330 }
9331 i++;
9332 }
9333 an->CleanUp();
9335 }
9336 // error handling
9337 if (!errorreported)
9338 {
9339 if ((at==0) && (a->Fullname()!=sNoName_fe))
9340 {
9341 Werror("`%s` is not defined",a->Fullname());
9342 }
9343 else
9344 {
9345 i=0;
9346 const char *s = iiTwoOps(op);
9347 Werror("%s(`%s`) failed"
9348 ,s,Tok2Cmdname(at));
9349 if ((!call_failed) && BVERBOSE(V_SHOW_USE))
9350 {
9351 while (dA1[i].cmd==op)
9352 {
9353 if ((dA1[i].res!=0)
9354 && (dA1[i].p!=jjWRONG))
9355 Werror("expected %s(`%s`)"
9356 ,s,Tok2Cmdname(dA1[i].arg));
9357 i++;
9358 }
9359 }
9360 }
9361 }
9362 res->rtyp = UNKNOWN;
9363 }
9364 a->CleanUp();
9365 return TRUE;
9366}
9368{
9369 if (!errorreported)
9370 {
9371 res->Init();
9372#ifdef SIQ
9373 if (siq>0)
9374 {
9375 //Print("siq:%d\n",siq);
9377 memcpy(&d->arg1,a,sizeof(sleftv));
9378 a->Init();
9379 d->op=op;
9380 d->argc=1;
9381 res->data=(char *)d;
9382 res->rtyp=COMMAND;
9383 return FALSE;
9384 }
9385#endif
9386 int at=a->Typ();
9387 // handling bb-objects ----------------------------------------------------
9388 if(op>MAX_TOK) // explicit type conversion to bb
9389 {
9390 blackbox *bb=getBlackboxStuff(op);
9391 if (bb!=NULL)
9392 {
9393 res->rtyp=op;
9394 res->data=bb->blackbox_Init(bb);
9395 return bb->blackbox_Assign(res,a);
9396 }
9397 else
9398 return TRUE;
9399 }
9400 else if (at>MAX_TOK) // argument is of bb-type
9401 {
9402 blackbox *bb=getBlackboxStuff(at);
9403 if (bb!=NULL)
9404 {
9405 if(!bb->blackbox_Op1(op,res,a)) return FALSE;
9406 // if not defined, try generic routines (attrib, defined,..)
9407 }
9408 else
9409 return TRUE;
9410 }
9411 if (errorreported) return TRUE;
9412
9413 int i=iiTabIndex(dArithTab1,JJTAB1LEN,op);
9414 return iiExprArith1Tab(res,a,op, dArith1+i,at,dConvertTypes);
9415 }
9416 a->CleanUp();
9417 return TRUE;
9418}
9419
9420/*=================== operations with 3 args. ============================*/
9421/* must be ordered: first operations for chars (infix ops),
9422 * then alphabetically */
9423
9425 const struct sValCmd3* dA3, int at, int bt, int ct,
9426 const struct sConvertTypes *dConvertTypes)
9427{
9428 BOOLEAN call_failed=FALSE;
9429
9430 assume(dA3[0].cmd==op);
9431
9432 if (!errorreported)
9433 {
9434 int i=0;
9435 iiOp=op;
9436 while (dA3[i].cmd==op)
9437 {
9438 if ((at==dA3[i].arg1)
9439 && (bt==dA3[i].arg2)
9440 && (ct==dA3[i].arg3))
9441 {
9442 res->rtyp=dA3[i].res;
9443 if (currRing!=NULL)
9444 {
9445 if (check_valid(dA3[i].valid_for,op)) break;
9446 }
9447 if (traceit&TRACE_CALL)
9448 Print("call %s(%s,%s,%s)\n",
9450 if ((call_failed=dA3[i].p(res,a,b,c)))
9451 {
9452 break;// leave loop, goto error handling
9453 }
9454 a->CleanUp();
9455 b->CleanUp();
9456 c->CleanUp();
9457 return FALSE;
9458 }
9459 i++;
9460 }
9461 // implicite type conversion ----------------------------------------------
9462 if (dA3[i].cmd!=op)
9463 {
9464 int ai,bi,ci;
9468 BOOLEAN failed=FALSE;
9469 i=0;
9470 //while ((dA3[i].cmd!=op)&&(dA3[i].cmd!=0)) i++;
9471 while (dA3[i].cmd==op)
9472 {
9473 if ((dA3[i].valid_for & NO_CONVERSION)==0)
9474 {
9475 if ((ai=iiTestConvert(at,dA3[i].arg1,dConvertTypes))!=0)
9476 {
9477 if ((bi=iiTestConvert(bt,dA3[i].arg2,dConvertTypes))!=0)
9478 {
9479 if ((ci=iiTestConvert(ct,dA3[i].arg3,dConvertTypes))!=0)
9480 {
9481 res->rtyp=dA3[i].res;
9482 if (currRing!=NULL)
9483 {
9484 if (check_valid(dA3[i].valid_for,op)) break;
9485 }
9486 if (traceit&TRACE_CALL)
9487 Print("call %s(%s,%s,%s)\n",
9488 iiTwoOps(op),Tok2Cmdname(dA3[i].arg1),
9489 Tok2Cmdname(dA3[i].arg2),Tok2Cmdname(dA3[i].arg3));
9490 failed= ((iiConvert(at,dA3[i].arg1,ai,a,an,dConvertTypes))
9491 || (iiConvert(bt,dA3[i].arg2,bi,b,bn,dConvertTypes))
9492 || (iiConvert(ct,dA3[i].arg3,ci,c,cn,dConvertTypes))
9493 || (call_failed=dA3[i].p(res,an,bn,cn)));
9494 // everything done, clean up temp. variables
9495 if (failed)
9496 {
9497 // leave loop, goto error handling
9498 break;
9499 }
9500 else
9501 {
9502 // everything ok, clean up and return
9503 an->CleanUp();
9504 bn->CleanUp();
9505 cn->CleanUp();
9509 //Print("op: %d,result typ:%d\n",op,res->rtyp);
9510 return FALSE;
9511 }
9512 }
9513 }
9514 }
9515 }
9516 i++;
9517 }
9518 an->CleanUp();
9519 bn->CleanUp();
9520 cn->CleanUp();
9524 }
9525 // error handling ---------------------------------------------------
9526 if (!errorreported)
9527 {
9528 const char *s=NULL;
9529 if ((at==0) && (a->Fullname()!=sNoName_fe))
9530 {
9531 s=a->Fullname();
9532 }
9533 else if ((bt==0) && (b->Fullname()!=sNoName_fe))
9534 {
9535 s=b->Fullname();
9536 }
9537 else if ((ct==0) && (c->Fullname()!=sNoName_fe))
9538 {
9539 s=c->Fullname();
9540 }
9541 if (s!=NULL)
9542 Werror("`%s` is not defined",s);
9543 else
9544 {
9545 i=0;
9546 //while ((dA3[i].cmd!=op)&&(dA3[i].cmd!=0)) i++;
9547 const char *s = iiTwoOps(op);
9548 Werror("%s(`%s`,`%s`,`%s`) failed"
9549 ,s,Tok2Cmdname(at),Tok2Cmdname(bt),Tok2Cmdname(ct));
9550 if ((!call_failed) && BVERBOSE(V_SHOW_USE))
9551 {
9552 while (dA3[i].cmd==op)
9553 {
9554 if(((at==dA3[i].arg1)
9555 ||(bt==dA3[i].arg2)
9556 ||(ct==dA3[i].arg3))
9557 && (dA3[i].res!=0))
9558 {
9559 Werror("expected %s(`%s`,`%s`,`%s`)"
9560 ,s,Tok2Cmdname(dA3[i].arg1)
9561 ,Tok2Cmdname(dA3[i].arg2)
9562 ,Tok2Cmdname(dA3[i].arg3));
9563 }
9564 i++;
9565 }
9566 }
9567 }
9568 }
9569 res->rtyp = UNKNOWN;
9570 }
9571 a->CleanUp();
9572 b->CleanUp();
9573 c->CleanUp();
9574 //Print("op: %d,result typ:%d\n",op,res->rtyp);
9575 return TRUE;
9576}
9578{
9579 res->Init();
9580
9581 if (!errorreported)
9582 {
9583#ifdef SIQ
9584 if (siq>0)
9585 {
9586 //Print("siq:%d\n",siq);
9588 memcpy(&d->arg1,a,sizeof(sleftv));
9589 a->Init();
9590 memcpy(&d->arg2,b,sizeof(sleftv));
9591 b->Init();
9592 memcpy(&d->arg3,c,sizeof(sleftv));
9593 c->Init();
9594 d->op=op;
9595 d->argc=3;
9596 res->data=(char *)d;
9597 res->rtyp=COMMAND;
9598 return FALSE;
9599 }
9600#endif
9601 int at=a->Typ();
9602 // handling bb-objects ----------------------------------------------
9603 if (at>MAX_TOK)
9604 {
9605 blackbox *bb=getBlackboxStuff(at);
9606 if (bb!=NULL)
9607 {
9608 if(!bb->blackbox_Op3(op,res,a,b,c)) return FALSE;
9609 // otherwise, try defaul (attrib,..)
9610 }
9611 else
9612 return TRUE;
9613 if (errorreported) return TRUE;
9614 }
9615 int bt=b->Typ();
9616 int ct=c->Typ();
9617
9618 iiOp=op;
9619 int i=0;
9620 while ((dArith3[i].cmd!=op)&&(dArith3[i].cmd!=0)) i++;
9621 return iiExprArith3TabIntern(res,op,a,b,c,dArith3+i,at,bt,ct,dConvertTypes);
9622 }
9623 a->CleanUp();
9624 b->CleanUp();
9625 c->CleanUp();
9626 //Print("op: %d,result typ:%d\n",op,res->rtyp);
9627 return TRUE;
9628}
9630 const struct sValCmd3* dA3,
9631 int at,
9632 const struct sConvertTypes *dConvertTypes)
9633{
9634 res->Init();
9635 leftv b=a->next;
9636 a->next=NULL;
9637 int bt=b->Typ();
9638 leftv c=b->next;
9639 b->next=NULL;
9640 int ct=c->Typ();
9641 BOOLEAN bo=iiExprArith3TabIntern(res,op,a,b,c,dA3,at,bt,ct,dConvertTypes);
9642 b->next=c;
9643 a->next=b;
9644 a->CleanUp(); // to cleanup the chain, content already done
9645 return bo;
9646}
9647/*==================== operations with many arg. ===============================*/
9648/* must be ordered: first operations for chars (infix ops),
9649 * then alphabetically */
9650
9651#if 0 // unused
9652static BOOLEAN jjANY2LIST(leftv res, leftv v, int cnt)
9653{
9654 // cnt = 0: all
9655 // cnt = 1: only first one
9656 leftv next;
9657 BOOLEAN failed = TRUE;
9658 if(v==NULL) return failed;
9659 res->rtyp = LIST_CMD;
9660 if(cnt) v->next = NULL;
9661 next = v->next; // saving next-pointer
9662 failed = jjLIST_PL(res, v);
9663 v->next = next; // writeback next-pointer
9664 return failed;
9665}
9666#endif
9667
9669{
9670 res->Init();
9671
9672 if (!errorreported)
9673 {
9674#ifdef SIQ
9675 if (siq>0)
9676 {
9677 //Print("siq:%d\n",siq);
9679 d->op=op;
9680 res->data=(char *)d;
9681 if (a!=NULL)
9682 {
9683 d->argc=a->listLength();
9684 // else : d->argc=0;
9685 memcpy(&d->arg1,a,sizeof(sleftv));
9686 switch(d->argc)
9687 {
9688 case 3:
9689 memcpy(&d->arg3,a->next->next,sizeof(sleftv));
9690 a->next->next->Init(); /* no break */
9691 case 2:
9692 memcpy(&d->arg2,a->next,sizeof(sleftv));
9693 a->next->Init();
9694 a->next->next=d->arg2.next;
9695 d->arg2.next=NULL; /* no break */
9696 case 1:
9697 a->Init();
9698 a->next=d->arg1.next;
9699 d->arg1.next=NULL;
9700 }
9701 if (d->argc>3) a->next=NULL;
9702 a->name=NULL;
9703 a->rtyp=0;
9704 a->data=NULL;
9705 a->e=NULL;
9706 a->attribute=NULL;
9707 a->CleanUp();
9708 }
9709 res->rtyp=COMMAND;
9710 return FALSE;
9711 }
9712#endif
9713 if ((a!=NULL) && (a->Typ()>MAX_TOK))
9714 {
9715 blackbox *bb=getBlackboxStuff(a->Typ());
9716 if (bb!=NULL)
9717 {
9718 if(!bb->blackbox_OpM(op,res,a)) return FALSE;
9719 // otherwise, try default
9720 }
9721 else
9722 return TRUE;
9723 if (errorreported) return TRUE;
9724 }
9725 int args=0;
9726 if (a!=NULL) args=a->listLength();
9727
9728 iiOp=op;
9729 int i=0;
9730 while ((dArithM[i].cmd!=op)&&(dArithM[i].cmd!=0)) i++;
9731 while (dArithM[i].cmd==op)
9732 {
9733 if ((args==dArithM[i].number_of_args)
9734 || (dArithM[i].number_of_args==-1)
9735 || ((dArithM[i].number_of_args==-2)&&(args>0)))
9736 {
9737 res->rtyp=dArithM[i].res;
9738 if (currRing!=NULL)
9739 {
9740 if (check_valid(dArithM[i].valid_for,op)) break;
9741 }
9742 if (traceit&TRACE_CALL)
9743 Print("call %s(... (%d args))\n", iiTwoOps(op),args);
9744 if (dArithM[i].p(res,a))
9745 {
9746 break;// leave loop, goto error handling
9747 }
9748 if (a!=NULL) a->CleanUp();
9749 //Print("op: %d,result typ:%d\n",op,res->rtyp);
9750 return FALSE;
9751 }
9752 i++;
9753 }
9754 // error handling
9755 if (!errorreported)
9756 {
9757 if ((args>0) && (a->rtyp==0) && (a->Name()!=sNoName_fe))
9758 {
9759 Werror("`%s` is not defined",a->Fullname());
9760 }
9761 else
9762 {
9763 const char *s = iiTwoOps(op);
9764 Werror("%s(...) failed",s);
9765 }
9766 }
9767 res->rtyp = UNKNOWN;
9768 }
9769 if (a!=NULL) a->CleanUp();
9770 //Print("op: %d,result typ:%d\n",op,res->rtyp);
9771 return TRUE;
9772}
9773
9774/*=================== general utilities ============================*/
9775int IsCmd(const char *n, int & tok)
9776{
9777 int i;
9778 int an=1;
9779 int en=sArithBase.nLastIdentifier;
9780
9781 loop
9782 //for(an=0; an<sArithBase.nCmdUsed; )
9783 {
9784 if(an>=en-1)
9785 {
9786 if (strcmp(n, sArithBase.sCmds[an].name) == 0)
9787 {
9788 i=an;
9789 break;
9790 }
9791 else if ((an!=en) && (strcmp(n, sArithBase.sCmds[en].name) == 0))
9792 {
9793 i=en;
9794 break;
9795 }
9796 else
9797 {
9798 // -- blackbox extensions:
9799 // return 0;
9800 return blackboxIsCmd(n,tok);
9801 }
9802 }
9803 i=(an+en)/2;
9804 if (*n < *(sArithBase.sCmds[i].name))
9805 {
9806 en=i-1;
9807 }
9808 else if (*n > *(sArithBase.sCmds[i].name))
9809 {
9810 an=i+1;
9811 }
9812 else
9813 {
9814 int v=strcmp(n,sArithBase.sCmds[i].name);
9815 if(v<0)
9816 {
9817 en=i-1;
9818 }
9819 else if(v>0)
9820 {
9821 an=i+1;
9822 }
9823 else /*v==0*/
9824 {
9825 break;
9826 }
9827 }
9828 }
9829 lastreserved=sArithBase.sCmds[i].name;
9830 tok=sArithBase.sCmds[i].tokval;
9831 if(sArithBase.sCmds[i].alias==2)
9832 {
9833 Warn("outdated identifier `%s` used - please change your code",
9834 sArithBase.sCmds[i].name);
9835 sArithBase.sCmds[i].alias=1;
9836 }
9837 #if 0
9838 if (currRingHdl==NULL)
9839 {
9840 #ifdef SIQ
9841 if (siq<=0)
9842 {
9843 #endif
9844 if ((tok>=BEGIN_RING) && (tok<=END_RING))
9845 {
9846 WerrorS("no ring active");
9847 return 0;
9848 }
9849 #ifdef SIQ
9850 }
9851 #endif
9852 }
9853 #endif
9854 if (!expected_parms)
9855 {
9856 switch (tok)
9857 {
9858 case IDEAL_CMD:
9859 case INT_CMD:
9860 case INTVEC_CMD:
9861 case MAP_CMD:
9862 case MATRIX_CMD:
9863 case MODUL_CMD:
9864 case POLY_CMD:
9865 case PROC_CMD:
9866 case RING_CMD:
9867 case STRING_CMD:
9868 cmdtok = tok;
9869 break;
9870 }
9871 }
9872 return sArithBase.sCmds[i].toktype;
9873}
9874static int iiTabIndex(const jjValCmdTab dArithTab, const int len, const int op)
9875{
9876 // user defined types are not in the pre-computed table:
9877 if (op>MAX_TOK) return 0;
9878
9879 int a=0;
9880 int e=len;
9881 int p=len/2;
9882 do
9883 {
9884 if (op==dArithTab[p].cmd) return dArithTab[p].start;
9885 if (op<dArithTab[p].cmd) e=p-1;
9886 else a = p+1;
9887 p=a+(e-a)/2;
9888 }
9889 while ( a <= e);
9890
9891 // catch missing a cmd:
9892 // may be missing as a op for blackbox, if the first operand is "undef" instead of bb
9893 // Print("op %d (%c) unknown",op,op);
9894 return 0;
9895}
9896
9897typedef char si_char_2[2];
9899const char * Tok2Cmdname(int tok)
9900{
9901 if (tok <= 0)
9902 {
9903 return sArithBase.sCmds[0].name;
9904 }
9905 if (tok==ANY_TYPE) return "any_type";
9906 if (tok==COMMAND) return "command";
9907 if (tok==NONE) return "nothing";
9908 if (tok < 128)
9909 {
9910 Tok2Cmdname_buf[0]=(char)tok;
9911 return Tok2Cmdname_buf;
9912 }
9913 //if (tok==IFBREAK) return "if_break";
9914 //if (tok==VECTOR_FROM_POLYS) return "vector_from_polys";
9915 //if (tok==ORDER_VECTOR) return "ordering";
9916 //if (tok==REF_VAR) return "ref";
9917 //if (tok==OBJECT) return "object";
9918 //if (tok==PRINT_EXPR) return "print_expr";
9919 if (tok==IDHDL) return "identifier";
9920 if (tok>MAX_TOK) return getBlackboxName(tok);
9921 unsigned i;
9922 for(i=0; i<sArithBase.nCmdUsed; i++)
9923 //while (sArithBase.sCmds[i].tokval!=0)
9924 {
9925 if ((sArithBase.sCmds[i].tokval == tok)&&
9926 (sArithBase.sCmds[i].alias==0))
9927 {
9928 return sArithBase.sCmds[i].name;
9929 }
9930 }
9931 // try gain for alias/old names:
9932 for(i=0; i<sArithBase.nCmdUsed; i++)
9933 {
9934 if (sArithBase.sCmds[i].tokval == tok)
9935 {
9936 return sArithBase.sCmds[i].name;
9937 }
9938 }
9939 return sArithBase.sCmds[0].name;
9940}
9941
9942
9943/*---------------------------------------------------------------------*/
9944/**
9945 * @brief compares to entry of cmdsname-list
9946
9947 @param[in] a
9948 @param[in] b
9949
9950 @return <ReturnValue>
9951**/
9952/*---------------------------------------------------------------------*/
9953static int _gentable_sort_cmds( const void *a, const void *b )
9954{
9955 cmdnames *pCmdL = (cmdnames*)a;
9956 cmdnames *pCmdR = (cmdnames*)b;
9957
9958 if(a==NULL || b==NULL) return 0;
9959
9960 /* empty entries goes to the end of the list for later reuse */
9961 if(pCmdL->name==NULL) return 1;
9962 if(pCmdR->name==NULL) return -1;
9963
9964 /* $INVALID$ must come first */
9965 if(strcmp(pCmdL->name, "$INVALID$")==0) return -1;
9966 if(strcmp(pCmdR->name, "$INVALID$")==0) return 1;
9967
9968 /* tokval=-1 are reserved names at the end */
9969 if (pCmdL->tokval==-1)
9970 {
9971 if (pCmdR->tokval==-1)
9972 return strcmp(pCmdL->name, pCmdR->name);
9973 /* pCmdL->tokval==-1, pCmdL goes at the end */
9974 return 1;
9975 }
9976 /* pCmdR->tokval==-1, pCmdR goes at the end */
9977 if(pCmdR->tokval==-1) return -1;
9978
9979 return strcmp(pCmdL->name, pCmdR->name);
9980}
9981
9982/*---------------------------------------------------------------------*/
9983/**
9984 * @brief initialisation of arithmetic structured data
9985
9986 @retval 0 on success
9987
9988**/
9989/*---------------------------------------------------------------------*/
9991{
9992 //printf("iiInitArithmetic()\n");
9993 memset(&sArithBase, 0, sizeof(sArithBase));
9994 iiInitCmdName();
9995 /* fix last-identifier */
9996#if 0
9997 /* we expect that gentable allready did every thing */
9998 for(sArithBase.nLastIdentifier=sArithBase.nCmdUsed-1;
9999 sArithBase.nLastIdentifier>0; sArithBase.nLastIdentifier--) {
10000 if(sArithBase.sCmds[sArithBase.nLastIdentifier].tokval>=0) break;
10001 }
10002#endif
10003 //Print("L=%d\n", sArithBase.nLastIdentifier);
10004
10005 //iiArithAddCmd(szName, nAlias, nTokval, nToktype);
10006 //iiArithAddCmd("mygcd", 1, GCD_CMD, CMD_2);
10007
10008 //iiArithAddCmd("Top", 0,-1,0);
10009
10010
10011 //for(i=0; i<sArithBase.nCmdUsed; i++) {
10012 // printf("CMD[%03d] %s, %d, %d, %d\n", i,
10013 // sArithBase.sCmds[i].name,
10014 // sArithBase.sCmds[i].alias,
10015 // sArithBase.sCmds[i].tokval,
10016 // sArithBase.sCmds[i].toktype);
10017 //}
10018 //iiArithRemoveCmd("Top");
10019 //iiArithAddCmd("mygcd", 2, GCD_CMD, CMD_2);
10020 //iiArithRemoveCmd("mygcd");
10021 //iiArithAddCmd("kkk", 1, 1234, CMD_1);
10022 return 0;
10023}
10024
10025int iiArithFindCmd(const char *szName)
10026{
10027 int an=0;
10028 int i = 0,v = 0;
10029 int en=sArithBase.nLastIdentifier;
10030
10031 loop
10032 //for(an=0; an<sArithBase.nCmdUsed; )
10033 {
10034 if(an>=en-1)
10035 {
10036 if (strcmp(szName, sArithBase.sCmds[an].name) == 0)
10037 {
10038 //Print("RET-an=%d %s\n", an, sArithBase.sCmds[an].name);
10039 return an;
10040 }
10041 else if (strcmp(szName, sArithBase.sCmds[en].name) == 0)
10042 {
10043 //Print("RET-en=%d %s\n", en, sArithBase.sCmds[en].name);
10044 return en;
10045 }
10046 else
10047 {
10048 //Print("RET- 1\n");
10049 return -1;
10050 }
10051 }
10052 i=(an+en)/2;
10053 if (*szName < *(sArithBase.sCmds[i].name))
10054 {
10055 en=i-1;
10056 }
10057 else if (*szName > *(sArithBase.sCmds[i].name))
10058 {
10059 an=i+1;
10060 }
10061 else
10062 {
10063 v=strcmp(szName,sArithBase.sCmds[i].name);
10064 if(v<0)
10065 {
10066 en=i-1;
10067 }
10068 else if(v>0)
10069 {
10070 an=i+1;
10071 }
10072 else /*v==0*/
10073 {
10074 //Print("RET-i=%d %s\n", i, sArithBase.sCmds[i].name);
10075 return i;
10076 }
10077 }
10078 }
10079 //if(i>=0 && i<sArithBase.nCmdUsed)
10080 // return i;
10081 //PrintS("RET-2\n");
10082 return -2;
10083}
10084
10085char *iiArithGetCmd( int nPos )
10086{
10087 if(nPos<0) return NULL;
10088 if(nPos<(int)sArithBase.nCmdUsed)
10089 return sArithBase.sCmds[nPos].name;
10090 return NULL;
10091}
10092
10093int iiArithRemoveCmd(const char *szName)
10094{
10095 int nIndex;
10096 if(szName==NULL) return -1;
10097
10098 nIndex = iiArithFindCmd(szName);
10099 if(nIndex<0 || nIndex>=(int)sArithBase.nCmdUsed)
10100 {
10101 Print("'%s' not found (%d)\n", szName, nIndex);
10102 return -1;
10103 }
10104 omFreeBinAddr(sArithBase.sCmds[nIndex].name);
10105 sArithBase.sCmds[nIndex].name=NULL;
10106 qsort(sArithBase.sCmds, sArithBase.nCmdUsed, sizeof(cmdnames),
10108 sArithBase.nCmdUsed--;
10109
10110 /* fix last-identifier */
10111 for(sArithBase.nLastIdentifier=sArithBase.nCmdUsed-1;
10112 sArithBase.nLastIdentifier>0; sArithBase.nLastIdentifier--)
10113 {
10114 if(sArithBase.sCmds[sArithBase.nLastIdentifier].tokval>=0) break;
10115 }
10116 //Print("L=%d\n", sArithBase.nLastIdentifier);
10117 return 0;
10118}
10119
10121 const char *szName,
10122 short nAlias,
10123 short nTokval,
10124 short nToktype,
10125 short nPos
10126 )
10127{
10128 //printf("AddCmd(%s, %d, %d, %d, %d)\n", szName, nAlias,
10129 // nTokval, nToktype, nPos);
10130 if(nPos>=0)
10131 {
10132 // no checks: we rely on a correct generated code in iparith.inc
10133 assume((unsigned)nPos < sArithBase.nCmdAllocated);
10134 assume(szName!=NULL);
10135 sArithBase.sCmds[nPos].name = omStrDup(szName);
10136 sArithBase.sCmds[nPos].alias = nAlias;
10137 sArithBase.sCmds[nPos].tokval = nTokval;
10138 sArithBase.sCmds[nPos].toktype = nToktype;
10139 sArithBase.nCmdUsed++;
10140 //if(nTokval>0) sArithBase.nLastIdentifier++;
10141 }
10142 else
10143 {
10144 if(szName==NULL) return -1;
10145 int nIndex = iiArithFindCmd(szName);
10146 if(nIndex>=0)
10147 {
10148 Print("'%s' already exists at %d\n", szName, nIndex);
10149 return -1;
10150 }
10151
10152 if(sArithBase.nCmdUsed>=sArithBase.nCmdAllocated)
10153 {
10154 /* needs to create new slots */
10155 unsigned long nSize = (sArithBase.nCmdAllocated+1)*sizeof(cmdnames);
10156 sArithBase.sCmds = (cmdnames *)omRealloc(sArithBase.sCmds, nSize);
10157 if(sArithBase.sCmds==NULL) return -1;
10158 sArithBase.nCmdAllocated++;
10159 }
10160 /* still free slots available */
10161 sArithBase.sCmds[sArithBase.nCmdUsed].name = omStrDup(szName);
10162 sArithBase.sCmds[sArithBase.nCmdUsed].alias = nAlias;
10163 sArithBase.sCmds[sArithBase.nCmdUsed].tokval = nTokval;
10164 sArithBase.sCmds[sArithBase.nCmdUsed].toktype = nToktype;
10165 sArithBase.nCmdUsed++;
10166
10167 qsort(sArithBase.sCmds, sArithBase.nCmdUsed, sizeof(cmdnames),
10169 for(sArithBase.nLastIdentifier=sArithBase.nCmdUsed-1;
10170 sArithBase.nLastIdentifier>0; sArithBase.nLastIdentifier--)
10171 {
10172 if(sArithBase.sCmds[sArithBase.nLastIdentifier].tokval>=0) break;
10173 }
10174 //Print("L=%d\n", sArithBase.nLastIdentifier);
10175 }
10176 return 0;
10177}
10178
10179static BOOLEAN check_valid(const int p, const int op)
10180{
10182 {
10183 if ((p & NC_MASK)==NO_NC)
10184 {
10185 WerrorS("not implemented for non-commutative rings");
10186 return TRUE;
10187 }
10188 else if ((p & NC_MASK)==COMM_PLURAL)
10189 {
10190 Warn("assume commutative subalgebra for cmd `%s` in >>%s<<",Tok2Cmdname(op),my_yylinebuf);
10191 return FALSE;
10192 }
10193 /* else, ALLOW_PLURAL */
10194 }
10195 else if (rIsLPRing(currRing))
10196 {
10197 if ((p & ALLOW_LP)==0)
10198 {
10199 Werror("`%s` not implemented for letterplace rings in >>%s<<",Tok2Cmdname(op),my_yylinebuf);
10200 return TRUE;
10201 }
10202 }
10204 {
10205 if ((p & RING_MASK)==0 /*NO_RING*/)
10206 {
10207 WerrorS("not implemented for rings with rings as coeffients");
10208 return TRUE;
10209 }
10211 {
10212 WerrorS("not implemented for rings with rings as coeffients and non-global orderings");
10213 return TRUE;
10214 }
10215 /* else ALLOW_RING */
10216 else if (((p & ZERODIVISOR_MASK)==NO_ZERODIVISOR)
10218 {
10219 WerrorS("domain required as coeffients");
10220 return TRUE;
10221 }
10222 /* else ALLOW_ZERODIVISOR */
10223 else if(((p & WARN_RING)==WARN_RING)&&(myynest==0))
10224 {
10225 WarnS("considering the image in Q[...]");
10226 }
10227 }
10228 return FALSE;
10229}
10230// --------------------------------------------------------------------
10232{
10233 if ((currRing!=NULL)
10235 && (!rField_is_Z(currRing)))
10236 {
10237 WerrorS("not implemented for rings with rings as coeffients (except ZZ)");
10238 return TRUE;
10239 }
10240 coeffs cf;
10241 lists c=(lists)u->CopyD(); // list of ideal or bigint/int
10242 int rl=c->nr+1;
10243 int return_type=c->m[0].Typ();
10244 if ((return_type!=IDEAL_CMD)
10245 && (return_type!=MODUL_CMD)
10246 && (return_type!=SMATRIX_CMD)
10247 && (return_type!=MATRIX_CMD)
10248 && (return_type!=POLY_CMD))
10249 {
10250 if((return_type==BIGINT_CMD)
10251 ||(return_type==INT_CMD))
10252 return_type=BIGINT_CMD;
10253 else if (return_type==LIST_CMD)
10254 {
10255 // create a tmp list of the correct size
10257 res_l->Init(rl /*c->nr+1*/);
10258 BOOLEAN bo=FALSE;
10259 int tab_pos=iiTabIndex(dArithTab2,JJTAB2LEN,CHINREM_CMD);
10260 for (unsigned i=0;i<=(unsigned)c->nr;i++)
10261 {
10262 sleftv tmp;
10263 tmp.Copy(v);
10264 bo=iiExprArith2TabIntern(&res_l->m[i],&c->m[i],CHINREM_CMD,&tmp,TRUE,dArith2+tab_pos,c->m[i].rtyp,tmp.rtyp,dConvertTypes);
10265 if (bo) { Werror("chinrem failed for list entry %d",i+1); break;}
10266 }
10267 c->Clean();
10268 res->data=res_l;
10269 res->rtyp=LIST_CMD;
10270 return bo;
10271 }
10272 else
10273 {
10274 c->Clean();
10275 WerrorS("poly/ideal/module/matrix/list expected");
10276 return TRUE;
10277 }
10278 }
10279 if (return_type==BIGINT_CMD)
10281 else
10282 {
10283 cf=currRing->cf;
10284 if (nCoeff_is_Extension(cf) && (cf->extRing!=NULL))
10285 cf=cf->extRing->cf;
10286 }
10287 lists pl=NULL;
10288 intvec *p=NULL;
10289 if (v->Typ()==LIST_CMD)
10290 {
10291 pl=(lists)v->Data();
10292 if (pl->nr!=rl-1)
10293 {
10294 Werror("wromg number of primes (%d:%d) for chinrem",pl->nr+1,rl);
10295 return TRUE;
10296 }
10297 }
10298 else
10299 {
10300 p=(intvec*)v->Data();
10301 if (p->length()!=rl)
10302 {
10303 Werror("wromg number of primes (%d:%d) for chinrem",p->length(),rl);
10304 return TRUE;
10305 }
10306 }
10307 ideal result;
10308 ideal *x=(ideal *)omAlloc(rl*sizeof(ideal));
10309 number *xx=NULL;
10311 int i;
10312 if (return_type!=BIGINT_CMD)
10313 {
10314 for(i=rl-1;i>=0;i--)
10315 {
10316 if (c->m[i].Typ()!=return_type)
10317 {
10318 Werror("%s expected at pos %d",Tok2Cmdname(return_type),i+1);
10319 omFree(x); // delete c
10320 return TRUE;
10321 }
10322 if (return_type==POLY_CMD)
10323 {
10324 x[i]=idInit(1,1);
10325 x[i]->m[0]=(poly)c->m[i].CopyD();
10326 }
10327 else
10328 {
10329 x[i]=(ideal)c->m[i].CopyD();
10330 }
10331 //c->m[i].Init();
10332 }
10333 }
10334 else
10335 {
10336 if (nMap==NULL)
10337 {
10338 Werror("not implemented: map bigint -> %s", nCoeffName(cf));
10339 return TRUE;
10340 }
10341 xx=(number *)omAlloc(rl*sizeof(number));
10342 for(i=rl-1;i>=0;i--)
10343 {
10344 if (c->m[i].Typ()==INT_CMD)
10345 {
10346 xx[i]=n_Init(((int)(long)c->m[i].Data()),cf);
10347 }
10348 else if (c->m[i].Typ()==BIGINT_CMD)
10349 {
10350 xx[i]=nMap((number)c->m[i].Data(),coeffs_BIGINT,cf);
10351 }
10352 else
10353 {
10354 Werror("bigint expected at pos %d",i+1);
10355 omFree(x); // delete c
10356 omFree(xx); // delete c
10357 return TRUE;
10358 }
10359 }
10360 }
10361 number *q=(number *)omAlloc(rl*sizeof(number));
10362 if (p!=NULL)
10363 {
10364 for(i=rl-1;i>=0;i--)
10365 {
10366 q[i]=n_Init((*p)[i], cf);
10367 }
10368 }
10369 else
10370 {
10371 for(i=rl-1;i>=0;i--)
10372 {
10373 if (pl->m[i].Typ()==INT_CMD)
10374 {
10375 q[i]=n_Init((int)(long)pl->m[i].Data(),cf);
10376 }
10377 else if (pl->m[i].Typ()==BIGINT_CMD)
10378 {
10379 q[i]=nMap((number)(pl->m[i].Data()),coeffs_BIGINT,cf);
10380 }
10381 else
10382 {
10383 Werror("bigint expected at pos %d",i+1);
10384 for(i++;i<rl;i++)
10385 {
10386 n_Delete(&(q[i]),cf);
10387 }
10388 omFree(x); // delete c
10389 omFree(q); // delete pl
10390 if (xx!=NULL) omFree(xx); // delete c
10391 return TRUE;
10392 }
10393 }
10394 }
10395 if (return_type==BIGINT_CMD)
10396 {
10397 CFArray i_v(rl);
10398 number n=n_ChineseRemainderSym(xx,q,rl,TRUE,i_v,coeffs_BIGINT);
10399 res->data=(char *)n;
10400 }
10401 else
10402 {
10403 /* called in modular.lib::chinrem_recursive: too many proc.
10404 #ifdef HAVE_VSPACE
10405 int cpus = (long) feOptValue(FE_OPT_CPUS);
10406 if ((cpus>1) && (rField_is_Q(currRing)))
10407 result=id_ChineseRemainder_0(x,q,rl,currRing); // deletes also x
10408 else
10409 #endif
10410 */
10411 result=id_ChineseRemainder(x,q,rl,currRing); // deletes also x
10412 c->Clean();
10413 if ((return_type==POLY_CMD) &&(result!=NULL))
10414 {
10415 res->data=(char *)result->m[0];
10416 result->m[0]=NULL;
10417 idDelete(&result);
10418 }
10419 else
10420 res->data=(char *)result;
10421 }
10422 for(i=rl-1;i>=0;i--)
10423 {
10424 n_Delete(&(q[i]),cf);
10425 }
10426 omFree(q);
10427 res->rtyp=return_type;
10428 return result==NULL;
10429}
10431{
10432 lists c=(lists)u->CopyD();
10434 res_l->Init(c->nr+1);
10435 BOOLEAN bo=FALSE;
10436 int tab_pos=iiTabIndex(dArithTab2,JJTAB2LEN,FAREY_CMD);
10437 for (unsigned i=0;i<=(unsigned)c->nr;i++)
10438 {
10439 sleftv tmp;
10440 tmp.Copy(v);
10441 bo=iiExprArith2TabIntern(&res_l->m[i],&c->m[i],FAREY_CMD,&tmp,TRUE,dArith2+tab_pos,c->m[i].rtyp,tmp.rtyp,dConvertTypes);
10442 if (bo) { Werror("farey failed for list entry %d",i+1); break;}
10443 }
10444 c->Clean();
10445 res->data=res_l;
10446 return bo;
10447}
10448// --------------------------------------------------------------------
10449static int jjCOMPARE_ALL(const void * aa, const void * bb)
10450{
10451 leftv a=(leftv)aa;
10452 int at=a->Typ();
10453 leftv b=(leftv)bb;
10454 int bt=b->Typ();
10455 if (at < bt) return -1;
10456 if (at > bt) return 1;
10457 int tab_pos=iiTabIndex(dArithTab2,JJTAB2LEN,'<');
10458 sleftv tmp;
10459 tmp.Init();
10460 iiOp='<';
10461 BOOLEAN bo=iiExprArith2TabIntern(&tmp,a,'<',b,FALSE,dArith2+tab_pos,at,bt,dConvertTypes);
10462 if (bo)
10463 {
10464 Werror(" no `<` for %s",Tok2Cmdname(at));
10465 unsigned long ad=(unsigned long)a->Data();
10466 unsigned long bd=(unsigned long)b->Data();
10467 if (ad<bd) return -1;
10468 else if (ad==bd) return 0;
10469 else return 1;
10470 }
10471 else if (tmp.data==NULL) /* not < */
10472 {
10474 tab_pos=iiTabIndex(dArithTab2,JJTAB2LEN,EQUAL_EQUAL);
10476 if (bo)
10477 {
10478 Werror(" no `==` for %s",Tok2Cmdname(at));
10479 unsigned long ad=(unsigned long)a->Data();
10480 unsigned long bd=(unsigned long)b->Data();
10481 if (ad<bd) return -1;
10482 else if (ad==bd) return 0;
10483 else return 1;
10484 }
10485 else if (tmp.data==NULL) /* not <,== */ return 1;
10486 else return 0;
10487 }
10488 else return -1;
10489}
10491{
10492 lists l=(lists)arg->Data();
10493 if (l->nr>0)
10494 {
10495 qsort(l->m,l->nr+1,sizeof(sleftv),jjCOMPARE_ALL);
10496 }
10497 return FALSE;
10498}
10500{
10501 lists l=(lists)arg->Data();
10502 if (l->nr>0)
10503 {
10504 qsort(l->m,l->nr+1,sizeof(sleftv),jjCOMPARE_ALL);
10505 int i, j, len;
10506 len=l->nr;
10507 i=0;
10508 while(i<len)
10509 {
10510 if(jjCOMPARE_ALL(&(l->m[i]),&(l->m[i+1]))==0)
10511 {
10512 l->m[i].CleanUp();
10513 for(j=i; j<len;j++) l->m[j]=l->m[j+1];
10514 l->m[len].Init();
10515 l->m[len].rtyp=DEF_CMD;
10516 len--;
10517 }
10518 else
10519 i++;
10520 }
10521 //Print("new len:%d\n",len);
10522 }
10523 return FALSE;
10524}
ideal getMinorIdealCache(const matrix mat, const int minorSize, const int k, const ideal iSB, const int cacheStrategy, const int cacheN, const int cacheW, const bool allDifferent)
Returns the specified set of minors (= subdeterminantes) of the given matrix.
ideal getMinorIdeal(const matrix mat, const int minorSize, const int k, const char *algorithm, const ideal iSB, const bool allDifferent)
Returns the specified set of minors (= subdeterminantes) of the given matrix.
ideal getMinorIdealHeuristic(const matrix mat, const int minorSize, const int k, const ideal iSB, const bool allDifferent)
Returns the specified set of minors (= subdeterminantes) of the given matrix.
void atSet(idhdl root, char *name, void *data, int typ)
Definition attrib.cc:153
void * atGet(idhdl root, const char *name, int t, void *defaultReturnValue)
Definition attrib.cc:132
#define atKill(H, A)
Definition attrib.h:49
static int ABS(int v)
Definition auxiliary.h:113
#define BITSET
Definition auxiliary.h:85
static int si_max(const int a, const int b)
Definition auxiliary.h:125
int BOOLEAN
Definition auxiliary.h:88
#define TRUE
Definition auxiliary.h:101
#define FALSE
Definition auxiliary.h:97
void * ADDRESS
Definition auxiliary.h:120
static int si_min(const int a, const int b)
Definition auxiliary.h:126
intvec * bim2iv(bigintmat *b)
Definition bigintmat.cc:339
bigintmat * bimMult(bigintmat *a, bigintmat *b)
Definition bigintmat.cc:253
bigintmat * bimSub(bigintmat *a, bigintmat *b)
Definition bigintmat.cc:216
bigintmat * bimAdd(bigintmat *a, bigintmat *b)
Matrix-Add/-Sub/-Mult so oder mit operator+/-/* ? @Note: NULL as a result means an error (non-compati...
Definition bigintmat.cc:180
#define BIMATELEM(M, I, J)
Definition bigintmat.h:133
struct blackbox_list * getBlackboxTypes()
return array of all define types.
Definition blackbox.cc:245
const char * getBlackboxName(const int t)
return the name to the type given by t (r/o)
Definition blackbox.cc:213
blackbox * getBlackboxStuff(const int t)
return the structure to the type given by t
Definition blackbox.cc:17
int blackboxIsCmd(const char *n, int &tok)
used by scanner: returns ROOT_DECL for known types (and the type number in tok)
Definition blackbox.cc:219
void printBlackboxTypes()
list all defined type (for debugging)
Definition blackbox.cc:236
void ** list
Definition blackbox.h:86
struct for containing list of blackbox names and the number of them.
Definition blackbox.h:84
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f ).
Definition cf_gcd.cc:676
Array< CanonicalForm > CFArray
const CanonicalForm CFMap CFMap & N
Definition cfEzgcd.cc:56
int l
Definition cfEzgcd.cc:100
int m
Definition cfEzgcd.cc:128
int i
Definition cfEzgcd.cc:132
int k
Definition cfEzgcd.cc:99
Variable x
Definition cfModGcd.cc:4090
int p
Definition cfModGcd.cc:4086
g
Definition cfModGcd.cc:4098
CanonicalForm fp
Definition cfModGcd.cc:4110
CanonicalForm cf
Definition cfModGcd.cc:4091
CanonicalForm b
Definition cfModGcd.cc:4111
CanonicalForm map(const CanonicalForm &primElem, const Variable &alpha, const CanonicalForm &F, const Variable &beta)
map from to such that is mapped onto
int ipower(int b, int m)
int ipower ( int b, int m )
Definition cf_util.cc:27
FILE * f
Definition checklibs.c:9
poly singclap_pmod(poly f, poly g, const ring r)
Definition clapsing.cc:732
ideal singclap_factorize(poly f, intvec **v, int with_exps, const ring r)
Definition clapsing.cc:983
VAR int singclap_factorize_retry
Definition clapsing.cc:981
poly singclap_pdivide(poly f, poly g, const ring r)
Definition clapsing.cc:649
BOOLEAN singclap_extgcd(poly f, poly g, poly &res, poly &pa, poly &pb, const ring r)
Definition clapsing.cc:505
number singclap_det_bi(bigintmat *m, const coeffs cf)
Definition clapsing.cc:1852
int singclap_det_i(intvec *m, const ring)
Definition clapsing.cc:1834
ideal singclap_sqrfree(poly f, intvec **v, int with_exps, const ring r)
Definition clapsing.cc:1377
Matrices of numbers.
Definition bigintmat.h:51
int cols() const
Definition bigintmat.h:144
int rows() const
Definition bigintmat.h:145
void set(int i, int j, number n, const coeffs C=NULL)
replace an entry with a copy (delete old + copy new!). NOTE: starts at [1,1]
Definition bigintmat.cc:93
int compare(const bigintmat *op) const
Definition bigintmat.cc:360
Definition idrec.h:35
utypes data
Definition idrec.h:40
int typ
Definition idrec.h:43
short ref
Definition idrec.h:46
const char * id
Definition idrec.h:39
void makeVector()
Definition intvec.h:103
intvec * delete_pos(int p)
Definition intvec.cc:842
void show(int mat=0, int spaces=0) const
Definition intvec.cc:149
int min_in()
Definition intvec.h:122
int length() const
Definition intvec.h:95
int compare(const intvec *o) const
Definition intvec.cc:206
int cols() const
Definition intvec.h:96
int rows() const
Definition intvec.h:97
long rank
Definition matpol.h:19
int & cols()
Definition matpol.h:24
int & rows()
Definition matpol.h:23
Class used for (list of) interpreter objects.
Definition subexpr.h:83
void * CopyD(int t)
Definition subexpr.cc:714
int Typ()
Definition subexpr.cc:1048
const char * name
Definition subexpr.h:87
package req_packhdl
Definition subexpr.h:106
int rtyp
Definition subexpr.h:91
void * Data()
Definition subexpr.cc:1192
void Init()
Definition subexpr.h:107
leftv next
Definition subexpr.h:86
const char * Name()
Definition subexpr.h:120
int listLength()
Definition subexpr.cc:51
void Copy(leftv e)
Definition subexpr.cc:689
void * data
Definition subexpr.h:88
leftv Next()
Definition subexpr.h:136
void CleanUp(ring r=currRing)
Definition subexpr.cc:351
BITSET flag
Definition subexpr.h:90
const char * Fullname()
Definition subexpr.h:125
Subexpr e
Definition subexpr.h:105
attr attribute
Definition subexpr.h:89
sleftv * m
Definition lists.h:46
void Clean(ring r=currRing)
Definition lists.h:26
INLINE_THIS void Init(int l=0)
int nr
Definition lists.h:44
Coefficient rings, fields and other domains suitable for Singular polynomials.
static FORCE_INLINE int n_ParDeg(number n, const coeffs r)
Definition coeffs.h:762
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
Definition coeffs.h:639
static FORCE_INLINE number n_Param(const int iParameter, const coeffs r)
return the (iParameter^th) parameter as a NEW number NOTE: parameter numbering: 1....
Definition coeffs.h:775
static FORCE_INLINE long n_Int(number &n, const coeffs r)
conversion of n to an int; 0 if not possible in Z/pZ: the representing int lying in (-p/2 ....
Definition coeffs.h:550
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of 'a' and 'b', i.e., a+b
Definition coeffs.h:653
static FORCE_INLINE number n_GetDenom(number &n, const coeffs r)
return the denominator of n (if elements of r are by nature not fractional, result is 1)
Definition coeffs.h:606
static FORCE_INLINE BOOLEAN nCoeff_is_Extension(const coeffs r)
Definition coeffs.h:844
static FORCE_INLINE number n_Random(siRandProc p, number p1, number p2, const coeffs cf)
Definition coeffs.h:968
@ n_algExt
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic
Definition coeffs.h:35
static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
in Z: return the gcd of 'a' and 'b' in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ,...
Definition coeffs.h:667
static FORCE_INLINE char * nCoeffString(const coeffs cf)
TODO: make it a virtual method of coeffs, together with: Decompose & Compose, rParameter & rPar.
Definition coeffs.h:961
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff 'n' is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2),...
Definition coeffs.h:500
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
Definition coeffs.h:703
static FORCE_INLINE number n_InpNeg(number n, const coeffs r)
in-place negation of n MUST BE USED: n = n_InpNeg(n) (no copy is returned)
Definition coeffs.h:560
static FORCE_INLINE void n_Power(number a, int b, number *res, const coeffs r)
fill res with the power a^b
Definition coeffs.h:635
static FORCE_INLINE number n_Farey(number a, number b, const coeffs r)
Definition coeffs.h:759
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of 'a' and 'b', i.e., a/b; raises an error if 'b' is not invertible in r exceptio...
Definition coeffs.h:618
static FORCE_INLINE number n_RePart(number i, const coeffs cf)
Definition coeffs.h:782
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition coeffs.h:470
static FORCE_INLINE int n_Size(number n, const coeffs r)
return a non-negative measure for the complexity of n; return 0 only when n represents zero; (used fo...
Definition coeffs.h:573
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of 'a' and 'b', i.e., a-b
Definition coeffs.h:658
static FORCE_INLINE number n_ChineseRemainderSym(number *a, number *b, int rl, BOOLEAN sym, CFArray &inv_cache, const coeffs r)
Definition coeffs.h:756
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition coeffs.h:461
static FORCE_INLINE char * nCoeffName(const coeffs cf)
Definition coeffs.h:965
static FORCE_INLINE number n_ExtGcd(number a, number b, number *s, number *t, const coeffs r)
beware that ExtGCD is only relevant for a few chosen coeff. domains and may perform something unexpec...
Definition coeffs.h:674
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition coeffs.h:541
static FORCE_INLINE number n_IntMod(number a, number b, const coeffs r)
for r a field, return n_Init(0,r) always: n_Div(a,b,r)*b+n_IntMod(a,b,r)==a n_IntMod(a,...
Definition coeffs.h:631
static FORCE_INLINE BOOLEAN n_Equal(number a, number b, const coeffs r)
TRUE iff 'a' and 'b' represent the same number; they may have different representations.
Definition coeffs.h:466
static FORCE_INLINE number n_GetNumerator(number &n, const coeffs r)
return the numerator of n (if elements of r are by nature not fractional, result is n)
Definition coeffs.h:611
static FORCE_INLINE number n_SubringGcd(number a, number b, const coeffs r)
Definition coeffs.h:669
static FORCE_INLINE number n_ImPart(number i, const coeffs cf)
Definition coeffs.h:785
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition coeffs.h:80
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition coeffs.h:581
static FORCE_INLINE BOOLEAN nCoeff_is_transExt(const coeffs r)
TRUE iff r represents a transcendental extension field.
Definition coeffs.h:916
static BOOLEAN pa(leftv res, leftv args)
Definition cohomo.cc:3770
static BOOLEAN pb(leftv res, leftv args)
Definition cohomo.cc:3796
#define Print
Definition emacs.cc:80
#define Warn
Definition emacs.cc:77
#define WarnS
Definition emacs.cc:78
return result
const CanonicalForm int s
Definition facAbsFact.cc:51
CanonicalForm res
Definition facAbsFact.cc:60
const CanonicalForm & w
Definition facAbsFact.cc:51
b *CanonicalForm B
Definition facBivar.cc:52
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
bool found
CFList tmp1
Definition facFqBivar.cc:75
CFList tmp2
Definition facFqBivar.cc:75
int j
Definition facHensel.cc:110
factory.h' is the user interface to Factory.
VAR void(* WerrorS_callback)(const char *s)
Definition feFopen.cc:21
FILE * feFopen(const char *path, const char *mode, char *where, short useWerror, short path_only)
Definition feFopen.cc:47
VAR short errorreported
Definition feFopen.cc:23
void WerrorS(const char *s)
Definition feFopen.cc:24
static void * feOptValue(feOptIndex opt)
Definition feOpt.h:40
VAR char my_yylinebuf[80]
Definition febase.cc:44
VAR int myynest
Definition febase.cc:41
void monitor(void *F, int mode)
Definition febase.cc:68
if(!FE_OPT_NO_SHELL_FLAG)
Definition fehelp.cc:1000
void newBuffer(char *s, feBufferTypes t, procinfo *pi, int lineno)
Definition fevoices.cc:166
const char sNoName_fe[]
Definition fevoices.cc:57
@ BT_execute
Definition fevoices.h:23
This file is work in progress and currently not part of the official Singular.
matrix singflint_kernel(matrix m, const ring R)
#define COMM_PLURAL
Definition gentable.cc:31
static int _gentable_sort_cmds(const void *a, const void *b)
compares to entry of cmdsname-list
Definition gentable.cc:191
#define jjWRONG3
Definition gentable.cc:126
#define NO_ZERODIVISOR
Definition gentable.cc:42
#define NO_LRING
Definition gentable.cc:54
#define NO_CONVERSION
Definition gentable.cc:51
int iiTestConvert(int inputType, int outputType)
Definition gentable.cc:298
const char * iiTwoOps(int t)
Definition gentable.cc:258
#define ALLOW_LP
Definition gentable.cc:33
#define RING_MASK
Definition gentable.cc:20
#define WARN_RING
Definition gentable.cc:49
#define NC_MASK
Definition gentable.cc:34
#define jjWRONG2
Definition gentable.cc:125
const char * Tok2Cmdname(int tok)
Definition gentable.cc:137
#define jjWRONG
Definition gentable.cc:124
static int RingDependend(int t)
Definition gentable.cc:23
#define NO_NC
Definition gentable.cc:29
#define ZERODIVISOR_MASK
Definition gentable.cc:21
#define STATIC_VAR
Definition globaldefs.h:7
#define EXTERN_VAR
Definition globaldefs.h:6
#define VAR
Definition globaldefs.h:5
@ PLUSPLUS
Definition grammar.cc:274
@ END_RING
Definition grammar.cc:311
@ IDEAL_CMD
Definition grammar.cc:285
@ MATRIX_CMD
Definition grammar.cc:287
@ BUCKET_CMD
Definition grammar.cc:284
@ BIGINTMAT_CMD
Definition grammar.cc:278
@ IMAP_CMD
Definition grammar.cc:299
@ GE
Definition grammar.cc:269
@ EQUAL_EQUAL
Definition grammar.cc:268
@ MAP_CMD
Definition grammar.cc:286
@ PROC_CMD
Definition grammar.cc:281
@ LE
Definition grammar.cc:270
@ BEGIN_RING
Definition grammar.cc:283
@ INTMAT_CMD
Definition grammar.cc:280
@ MODUL_CMD
Definition grammar.cc:288
@ SMATRIX_CMD
Definition grammar.cc:292
@ VECTOR_CMD
Definition grammar.cc:293
@ RESOLUTION_CMD
Definition grammar.cc:291
@ NOTEQUAL
Definition grammar.cc:273
@ BIGINTVEC_CMD
Definition grammar.cc:279
@ NUMBER_CMD
Definition grammar.cc:289
@ POLY_CMD
Definition grammar.cc:290
@ RING_CMD
Definition grammar.cc:282
@ FETCH_CMD
Definition grammar.cc:296
int cmdtok
Definition grammar.cc:174
BOOLEAN expected_parms
Definition grammar.cc:173
int yyparse(void)
Definition grammar.cc:2149
BOOLEAN yyInRingConstruction
Definition grammar.cc:172
ideal scKBase(int deg, ideal s, ideal Q, intvec *mv)
Definition hdegree.cc:1414
int scDimIntRing(ideal vid, ideal Q)
scDimInt for ring-coefficients
Definition hdegree.cc:136
long scMult0Int(ideal S, ideal Q)
Definition hdegree.cc:924
intvec * scIndIntvec(ideal S, ideal Q)
Definition hdegree.cc:284
int lp_kDim(const ideal _G)
Definition hdegree.cc:2081
int lp_gkDim(const ideal _G)
Definition hdegree.cc:1827
int scMultInt(ideal S, ideal Q)
Definition hdegree.cc:901
poly hFirstSeries0m(ideal A, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const ring Qt)
Definition hilb.cc:1425
poly hFirstSeries0p(ideal A, ideal Q, intvec *wdegree, const ring src, const ring Qt)
Definition hilb.cc:1384
intvec * hSecondSeries(intvec *hseries1)
Definition hilb.cc:71
intvec * hFirstSeries(ideal A, intvec *module_w, ideal Q, intvec *wdegree)
Definition hilb.cc:1512
bigintmat * hFirstSeries0b(ideal I, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const coeffs biv_cf)
Definition hilb.cc:2017
bigintmat * hSecondSeries0b(ideal I, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const coeffs biv_cf)
Definition hilb.cc:2039
void scDegree(ideal S, intvec *modulweight, ideal Q)
Definition hilb.cc:2055
void hLookSeries(ideal S, intvec *modulweight, ideal Q, intvec *wdegree)
Definition hilb.cc:220
leftv t_findTabelVal(stablerec *t, const char *s)
find the data to key s
Definition htable.cc:84
void t_addTable(stablerec *t, char *s, leftv v)
add a new entry (key s, data v) to table t, eats s, copies v
Definition htable.cc:92
GbVariant syGetAlgorithm(char *n, const ring r, const ideal)
Definition ideals.cc:3701
matrix idCoeffOfKBase(ideal arg, ideal kbase, poly how)
Definition ideals.cc:2673
void idLiftW(ideal P, ideal Q, int n, matrix &T, ideal &R, int *w)
Definition ideals.cc:1345
ideal idSyzygies(ideal h1, tHomog h, intvec **w, BOOLEAN setSyzComp, BOOLEAN setRegularity, int *deg, GbVariant alg)
Definition ideals.cc:834
matrix idDiff(matrix i, int k)
Definition ideals.cc:2194
BOOLEAN idTestHomModule(ideal m, ideal Q, intvec *w)
Definition ideals.cc:2125
ideal idLiftStd(ideal h1, matrix *T, tHomog hi, ideal *S, GbVariant alg, ideal h11)
Definition ideals.cc:980
ideal idQuot(ideal h1, ideal h2, BOOLEAN h1IsStb, BOOLEAN resultIsIdeal)
Definition ideals.cc:1537
ideal idSeries(int n, ideal M, matrix U, intvec *w)
Definition ideals.cc:2177
ideal idMinEmbedding_with_map_v(ideal arg, intvec **w, ideal &trans, int *g)
Definition ideals.cc:2879
ideal idElimination2(ideal h1, poly delVar, bigintmat *hilb, GbVariant alg)
Definition ideals.cc:1647
matrix idDiffOp(ideal I, ideal J, BOOLEAN multiply)
Definition ideals.cc:2207
ideal idElimination(ideal h1, poly delVar, intvec *hilb, GbVariant alg)
Definition ideals.cc:1889
ideal idSect(ideal h1, ideal h2, GbVariant alg)
Definition ideals.cc:315
ideal idMultSect(resolvente arg, int length, GbVariant alg)
Definition ideals.cc:472
ideal idLift(ideal mod, ideal submod, ideal *rest, BOOLEAN goodShape, BOOLEAN isSB, BOOLEAN divide, matrix *unit, GbVariant alg)
represents the generators of submod in terms of the generators of mod (Matrix(SM)*U-Matrix(rest)) = M...
Definition ideals.cc:1109
ideal idModulo(ideal h2, ideal h1, tHomog hom, intvec **w, matrix *T, GbVariant alg)
Definition ideals.cc:2468
ideal idMinBase(ideal h1, ideal *SB)
Definition ideals.cc:51
ideal id_Farey(ideal x, number N, const ring r)
Definition ideals.cc:3108
ideal idMinEmbedding(ideal arg, BOOLEAN inPlace, intvec **w)
Definition ideals.cc:2858
GbVariant
Definition ideals.h:119
@ GbDefault
Definition ideals.h:120
#define idDelete(H)
delete an ideal
Definition ideals.h:29
#define idSimpleAdd(A, B)
Definition ideals.h:42
#define idIsConstant(I)
Definition ideals.h:40
ideal id_Copy(ideal h1, const ring r)
copy an ideal
static BOOLEAN idIsZeroDim(ideal i)
Definition ideals.h:180
static BOOLEAN idHomModule(ideal m, ideal Q, intvec **w)
Definition ideals.h:96
#define idTest(id)
Definition ideals.h:47
static BOOLEAN idHomIdeal(ideal id, ideal Q=NULL)
Definition ideals.h:91
static ideal idMult(ideal h1, ideal h2)
hh := h1 * h2
Definition ideals.h:84
ideal idCopy(ideal A)
Definition ideals.h:60
ideal idAdd(ideal h1, ideal h2)
h1 + h2
Definition ideals.h:68
#define idMaxIdeal(D)
initialise the maximal ideal (at 0)
Definition ideals.h:33
ideal * resolvente
Definition ideals.h:18
static intvec * idSort(ideal id, BOOLEAN nolex=TRUE)
Definition ideals.h:188
ideal interpolation(const std::vector< ideal > &L, intvec *v)
EXTERN_VAR int inerror
static BOOLEAN length(leftv result, leftv arg)
Definition interval.cc:257
intvec * ivSub(intvec *a, intvec *b)
Definition intvec.cc:297
int ivTrace(intvec *o)
Definition intvec.cc:339
intvec * ivAdd(intvec *a, intvec *b)
Definition intvec.cc:249
intvec * ivMult(intvec *a, intvec *b)
Definition intvec.cc:349
intvec * ivTranp(intvec *o)
Definition intvec.cc:327
intvec * ivCopy(const intvec *o)
Definition intvec.h:146
#define ivTest(v)
Definition intvec.h:172
#define IMATELEM(M, I, J)
Definition intvec.h:86
static BOOLEAN jjUMINUS_MA(leftv res, leftv u)
Definition iparith.cc:3834
static BOOLEAN jjOP_BIM_I(leftv res, leftv u, leftv v)
Definition iparith.cc:244
static BOOLEAN jjRANK1(leftv res, leftv v)
Definition iparith.cc:4966
static BOOLEAN jjINDEX_V_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1524
static BOOLEAN jjIMPART(leftv res, leftv v)
Definition iparith.cc:4461
static BOOLEAN jjIm2Iv(leftv res, leftv v)
Definition iparith.cc:4454
const char * name
Definition gentable.cc:58
#define SIMPL_EQU
Definition iparith.cc:3354
static BOOLEAN jjQUOT(leftv res, leftv u, leftv v)
Definition iparith.cc:3105
static BOOLEAN jjUMINUS_IV(leftv res, leftv u)
Definition iparith.cc:3840
static BOOLEAN jjOPPOSITE(leftv res, leftv a)
Definition iparith.cc:5312
static int _gentable_sort_cmds(const void *a, const void *b)
compares to entry of cmdsname-list
Definition iparith.cc:9953
BOOLEAN jjWAITALL1(leftv res, leftv u)
Definition iparith.cc:5558
static BOOLEAN jjRESTART(leftv, leftv u)
Definition iparith.cc:8979
static BOOLEAN jjidHead(leftv res, leftv v)
Definition iparith.cc:5720
static BOOLEAN jjHILBERT(leftv, leftv v)
Definition iparith.cc:4345
static BOOLEAN jjTIMES_MA_P1(leftv res, leftv u, leftv v)
Definition iparith.cc:1100
static BOOLEAN jjLEADMONOM(leftv res, leftv v)
Definition iparith.cc:4620
static BOOLEAN jjOP_IV_I(leftv res, leftv u, leftv v)
Definition iparith.cc:280
static BOOLEAN jjstrlen(leftv res, leftv v)
Definition iparith.cc:5685
static BOOLEAN jjBRACK_Bim(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:5842
static BOOLEAN jjEXTGCD_P(leftv res, leftv u, leftv v)
Definition iparith.cc:2048
static BOOLEAN jjDET_BI(leftv res, leftv v)
Definition iparith.cc:4102
BOOLEAN jjWAIT1ST1(leftv res, leftv u)
Definition iparith.cc:5543
BOOLEAN jjLOAD(const char *s, BOOLEAN autoexport)
load lib/module given in v
Definition iparith.cc:5593
static BOOLEAN jjMATRIX_Mo(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6975
static BOOLEAN jjP2I(leftv res, leftv v)
Definition iparith.cc:4880
static BOOLEAN jjIS_RINGVAR_P(leftv res, leftv v)
Definition iparith.cc:4488
static BOOLEAN jjDOTDOT(leftv res, leftv u, leftv v)
Definition iparith.cc:333
static BOOLEAN jjFWALK3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6217
static BOOLEAN jjREPART(leftv res, leftv v)
Definition iparith.cc:4982
static BOOLEAN jjTIMES_MA_BI2(leftv res, leftv u, leftv v)
Definition iparith.cc:1096
static BOOLEAN jjMAP(leftv res, leftv u, leftv v)
Definition iparith.cc:1653
static BOOLEAN jjGT_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:1184
static BOOLEAN jjN2BI(leftv res, leftv v)
Definition iparith.cc:4763
static BOOLEAN jjRESERVEDLIST0(leftv res, leftv)
Definition iparith.cc:8526
short start
Definition iparith.cc:127
static BOOLEAN jjCHAR(leftv res, leftv v)
Definition iparith.cc:3949
static BOOLEAN jjOP_I_IM(leftv res, leftv u, leftv v)
Definition iparith.cc:316
static BOOLEAN jjBRACK_Ma_IV_I(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:5978
static BOOLEAN jjROWS_IV(leftv res, leftv v)
Definition iparith.cc:5027
static BOOLEAN jjLIFTSTD(leftv res, leftv u, leftv v)
Definition iparith.cc:2609
static BOOLEAN jjNULL(leftv, leftv)
Definition iparith.cc:3784
static BOOLEAN jjNEWSTRUCT2(leftv, leftv u, leftv v)
Definition iparith.cc:2807
static BOOLEAN jjBIV2IV(leftv res, leftv v)
Definition iparith.cc:4479
static BOOLEAN jjMONITOR2(leftv res, leftv u, leftv v)
Definition iparith.cc:2742
static BOOLEAN jjDIM(leftv res, leftv v)
Definition iparith.cc:4158
static BOOLEAN jjCOUNT_BIM(leftv res, leftv v)
Definition iparith.cc:3989
static BOOLEAN jjBRACKET(leftv res, leftv a, leftv b)
Definition iparith.cc:2918
static BOOLEAN jjCOLS_IV(leftv res, leftv v)
Definition iparith.cc:3971
static BOOLEAN jjNAMES_I(leftv res, leftv v)
Definition iparith.cc:4793
static BOOLEAN jjMULT(leftv res, leftv v)
Definition iparith.cc:4743
static BOOLEAN jjHOMOG1_WI(leftv res, leftv v, leftv u)
Definition iparith.cc:2507
static BOOLEAN jjPARDEG(leftv res, leftv v)
Definition iparith.cc:4836
static BOOLEAN jjDENOMINATOR(leftv res, leftv v)
Return the denominator of the input number.
Definition iparith.cc:4079
static BOOLEAN jjRANDOM(leftv res, leftv u, leftv v)
Definition iparith.cc:3112
static BOOLEAN jjIDEAL_Ma(leftv res, leftv v)
Definition iparith.cc:4418
static BOOLEAN jjDIVISION(leftv res, leftv u, leftv v)
Definition iparith.cc:1954
static BOOLEAN jjOP_I_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:297
static BOOLEAN jjmpTransp(leftv res, leftv v)
Definition iparith.cc:5748
static BOOLEAN jjOPTION_PL(leftv res, leftv v)
Definition iparith.cc:8375
static BOOLEAN jjEQUAL_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:1323
static BOOLEAN jjDET_S(leftv res, leftv v)
Definition iparith.cc:4152
static BOOLEAN jjL2R(leftv res, leftv v)
Definition iparith.cc:4580
static BOOLEAN jjREDUCE5(leftv res, leftv u)
Definition iparith.cc:8456
static BOOLEAN jjrCharStr(leftv res, leftv v)
Definition iparith.cc:5710
static BOOLEAN jjSUBST_Id_I(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6934
static BOOLEAN jjMINUS_B_P(leftv res, leftv u, leftv v)
Definition iparith.cc:909
static BOOLEAN jjHILBERT_IV(leftv res, leftv v)
Definition iparith.cc:4358
int iiArithFindCmd(const char *szName)
Definition iparith.cc:10025
static BOOLEAN jjIDEAL_R(leftv res, leftv v)
Definition iparith.cc:4437
static BOOLEAN jjINDEPSET(leftv res, leftv v)
Definition iparith.cc:4466
static BOOLEAN jjTYPEOF(leftv res, leftv v)
Definition iparith.cc:5428
static BOOLEAN jjLU_SOLVE(leftv res, leftv v)
Definition iparith.cc:7821
static BOOLEAN jjFACSTD(leftv res, leftv v)
Definition iparith.cc:4221
static BOOLEAN jjMEMORY(leftv res, leftv v)
Definition iparith.cc:4696
static BOOLEAN jjidTransp(leftv res, leftv v)
Definition iparith.cc:5778
static BOOLEAN jjLIFT(leftv res, leftv u, leftv v)
Definition iparith.cc:2589
static BOOLEAN jjUMINUS_BIM(leftv res, leftv u)
Definition iparith.cc:3847
static BOOLEAN jjSUBST_Bu(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6838
static BOOLEAN jjTIMES_MA_N2(leftv res, leftv u, leftv v)
Definition iparith.cc:1125
static BOOLEAN jjDIM_R(leftv res, leftv v)
Definition iparith.cc:5773
BOOLEAN jjSORTLIST(leftv, leftv arg)
Definition iparith.cc:10490
static BOOLEAN jjDUMP(leftv, leftv v)
Definition iparith.cc:4186
static BOOLEAN jjpMaxComp(leftv res, leftv v)
Definition iparith.cc:5738
static BOOLEAN jjCOEFFS1(leftv res, leftv v)
Definition iparith.cc:3954
static BOOLEAN jjREDUCE3_ID(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7227
static BOOLEAN jjELIMIN_HILB(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6177
static int jjCOMPARE_ALL(const void *aa, const void *bb)
Definition iparith.cc:10449
static BOOLEAN jjNAMEOF(leftv res, leftv v)
Definition iparith.cc:4775
static BOOLEAN jjPlural_mat_poly(leftv res, leftv a, leftv b)
Definition iparith.cc:2878
static BOOLEAN jjTIMES_SM(leftv res, leftv u, leftv v)
Definition iparith.cc:1152
static BOOLEAN jjMOD_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:2697
BOOLEAN jjUNIQLIST(leftv, leftv arg)
Definition iparith.cc:10499
static BOOLEAN jjTIMES_MA_I2(leftv res, leftv u, leftv v)
Definition iparith.cc:1134
static BOOLEAN jjSTATUS2L(leftv res, leftv u, leftv v)
Definition iparith.cc:3446
BOOLEAN(* proc3)(leftv, leftv, leftv, leftv)
Definition iparith.cc:161
static BOOLEAN jjGT_I(leftv res, leftv u, leftv v)
Definition iparith.cc:1191
static BOOLEAN jjPRIME(leftv res, leftv v)
Definition iparith.cc:4898
static BOOLEAN jjPFAC2(leftv res, leftv u, leftv v)
Definition iparith.cc:3298
static BOOLEAN jjidVec2Ideal(leftv res, leftv v)
Definition iparith.cc:5705
static BOOLEAN jjJACOB_P(leftv res, leftv v)
Definition iparith.cc:4504
static BOOLEAN jjSQR_FREE(leftv res, leftv u)
Definition iparith.cc:5199
static BOOLEAN jjSTD_HILB_W(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7290
static BOOLEAN jjEQUAL_I(leftv res, leftv u, leftv v)
Definition iparith.cc:1329
static BOOLEAN jjTIMES_MA_P2(leftv res, leftv u, leftv v)
Definition iparith.cc:1109
static BOOLEAN jjMODULO3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7014
static BOOLEAN jjSBA_1(leftv res, leftv v, leftv u)
Definition iparith.cc:5111
#define SIMPL_NORM
Definition iparith.cc:3356
static BOOLEAN jjCOEFFS3_P(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6142
static BOOLEAN jjCALL1MANY(leftv res, leftv u)
Definition iparith.cc:3945
static BOOLEAN jjPLUS_MA(leftv res, leftv u, leftv v)
Definition iparith.cc:824
short tokval
Definition gentable.cc:60
static BOOLEAN jjMINUS_V(leftv res, leftv u, leftv v)
Definition iparith.cc:904
static BOOLEAN jjINTERRED(leftv res, leftv v)
Definition iparith.cc:4472
static BOOLEAN jjJACOB_M(leftv res, leftv a)
Definition iparith.cc:4535
static BOOLEAN jjJET_ID_IV(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6374
static BOOLEAN jjTIMES_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:1055
static BOOLEAN jjBAREISS(leftv res, leftv v)
Definition iparith.cc:3879
static BOOLEAN jjREAD(leftv res, leftv v)
Definition iparith.cc:4973
static BOOLEAN jjLT_N(leftv res, leftv u, leftv v)
Definition iparith.cc:1223
static BOOLEAN jjMINUS_MA(leftv res, leftv u, leftv v)
Definition iparith.cc:952
static BOOLEAN jjFactModD_M(leftv res, leftv v)
Definition iparith.cc:8659
static BOOLEAN jjMATRIX_Id(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6952
static BOOLEAN jjEXTGCD_I(leftv res, leftv u, leftv v)
Definition iparith.cc:2020
static BOOLEAN jjIS_RINGVAR_S(leftv res, leftv v)
Definition iparith.cc:4493
static BOOLEAN jjDelete_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:1869
static BOOLEAN jjLE_N(leftv res, leftv u, leftv v)
Definition iparith.cc:1210
static BOOLEAN jjSUBST_P(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6851
static BOOLEAN jjROWS_BIM(leftv res, leftv v)
Definition iparith.cc:5022
static BOOLEAN jjCOMPARE_S(leftv res, leftv u, leftv v)
Definition iparith.cc:479
#define SIMPL_LMEQ
Definition iparith.cc:3352
int iiInitArithmetic()
initialisation of arithmetic structured data
Definition iparith.cc:9990
static BOOLEAN jjOR_I(leftv res, leftv u, leftv v)
Definition iparith.cc:1385
static BOOLEAN jjTIMES_MA_I1(leftv res, leftv u, leftv v)
Definition iparith.cc:1129
static BOOLEAN jjLIFTSTD_SYZ(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7151
static BOOLEAN jjBAREISS3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6097
static BOOLEAN jjRESERVED0(leftv, leftv)
Definition iparith.cc:8504
static BOOLEAN jjTIMES_MA_N1(leftv res, leftv u, leftv v)
Definition iparith.cc:1118
static BOOLEAN jjLIFT_4(leftv res, leftv U)
Definition iparith.cc:8131
static BOOLEAN jjSLIM_GB(leftv res, leftv u)
Definition iparith.cc:5042
static BOOLEAN jjMSTD(leftv res, leftv v)
Definition iparith.cc:4728
#define bit31
Definition iparith.cc:121
short cmd
Definition iparith.cc:126
static BOOLEAN jjBREAK1(leftv, leftv v)
Definition iparith.cc:7341
static BOOLEAN jjJET_ID_M(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6380
static BOOLEAN jjMINUS_BIM(leftv res, leftv u, leftv v)
Definition iparith.cc:942
static BOOLEAN jjnInt(leftv res, leftv u)
Definition iparith.cc:5783
static BOOLEAN jjSQR_FREE2(leftv res, leftv u, leftv dummy)
Definition iparith.cc:3394
static BOOLEAN jjCOEFFS3_Id(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6122
static BOOLEAN jjREGULARITY(leftv res, leftv v)
Definition iparith.cc:4977
static BOOLEAN jjHOMOG_W_M(leftv res, leftv v1, leftv v2, leftv v3)
Definition iparith.cc:6314
static BOOLEAN jjMINUS_N(leftv res, leftv u, leftv v)
Definition iparith.cc:899
static BOOLEAN jjBREAK0(leftv, leftv)
Definition iparith.cc:7334
static BOOLEAN jjTRACE_IV(leftv res, leftv v)
Definition iparith.cc:5297
BOOLEAN iiExprArith2(leftv res, leftv a, int op, leftv b, BOOLEAN proccall)
Definition iparith.cc:9178
static BOOLEAN jjMONOM(leftv res, leftv v)
Definition iparith.cc:2783
static BOOLEAN jjSort_Id(leftv res, leftv v)
Definition iparith.cc:5194
static BOOLEAN jjCOEF_M(leftv, leftv v)
Definition iparith.cc:7382
static BOOLEAN jjidMinBase(leftv res, leftv v)
Definition iparith.cc:5726
static BOOLEAN jjDEG_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1848
static BOOLEAN jjRING_2(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6085
static BOOLEAN jjMINUS_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:932
static BOOLEAN jjPREIMAGE_R(leftv res, leftv v)
Definition iparith.cc:4892
static BOOLEAN jjHOMOG_P(leftv res, leftv u, leftv v)
Definition iparith.cc:2448
static BOOLEAN jjBRACK_Im(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:5815
static BOOLEAN jjMATRIX_Ma(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6988
static BOOLEAN jjidMaxIdeal(leftv res, leftv v)
Definition iparith.cc:4401
static BOOLEAN jjMINOR_M(leftv res, leftv v)
Definition iparith.cc:6391
static BOOLEAN jjCOUNT_BI(leftv res, leftv v)
Definition iparith.cc:3984
static BOOLEAN jjPROC3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6078
static BOOLEAN jjKERNEL_M(leftv res, leftv v)
Definition iparith.cc:4556
static BOOLEAN jjCOLS_BIM(leftv res, leftv v)
Definition iparith.cc:3966
static BOOLEAN jjREDUCE3_CP(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7196
struct sValCmd3 * psValCmd3
Definition iparith.cc:186
static BOOLEAN jjBRACK_Ma_I_IV(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:5928
static BOOLEAN jjLE_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:1201
static BOOLEAN jjPLUS_B_P(leftv res, leftv u, leftv v)
Definition iparith.cc:795
static BOOLEAN jjPlural_mat_mat(leftv res, leftv a, leftv b)
Definition iparith.cc:2898
static BOOLEAN jjIDEAL_Map(leftv res, leftv v)
Definition iparith.cc:4427
static BOOLEAN jjPARSTR2(leftv res, leftv u, leftv v)
Definition iparith.cc:2821
BOOLEAN(* proc2)(leftv, leftv, leftv)
Definition iparith.cc:150
static BOOLEAN jjKoszul(leftv res, leftv u, leftv v)
Definition iparith.cc:2577
static BOOLEAN jjTIMES_N(leftv res, leftv u, leftv v)
Definition iparith.cc:998
static BOOLEAN jjINTERSECT_PL(leftv res, leftv v)
Definition iparith.cc:7666
static BOOLEAN jjTIMES_MA(leftv res, leftv u, leftv v)
Definition iparith.cc:1138
static BOOLEAN jjTIMES_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1062
static BOOLEAN jjPLUS_I(leftv res, leftv u, leftv v)
Definition iparith.cc:755
static BOOLEAN jjINTERSEC3S(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6349
static BOOLEAN jjRES3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7235
static BOOLEAN jjBIGINTVEC_PL(leftv res, leftv v)
Definition iparith.cc:7934
static BOOLEAN jjJET_P_IV(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6357
static BOOLEAN jjREDUCE_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:3153
static BOOLEAN jjCOEF(leftv res, leftv u, leftv v)
Definition iparith.cc:1793
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:9629
static BOOLEAN jjOP_REST(leftv res, leftv u, leftv v)
Definition iparith.cc:506
static BOOLEAN jjEXECUTE(leftv, leftv v)
Definition iparith.cc:4212
static BOOLEAN jjDEG_M_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1837
static BOOLEAN jjSTATUS3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7281
static BOOLEAN jjLEADEXP(leftv res, leftv v)
Definition iparith.cc:4602
static BOOLEAN jjDEG_M(leftv res, leftv u)
Definition iparith.cc:4039
static BOOLEAN jjPLUS_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:804
static BOOLEAN jjDIFF_COEF(leftv res, leftv u, leftv v)
Definition iparith.cc:4516
int iiArithRemoveCmd(char *szName)
static BOOLEAN jjGE_N(leftv res, leftv u, leftv v)
Definition iparith.cc:1178
static BOOLEAN jjEQUAL_SM(leftv res, leftv u, leftv v)
Definition iparith.cc:1341
static BOOLEAN jjINTERPOLATION(leftv res, leftv l, leftv v)
Definition iparith.cc:2527
static BOOLEAN jjSIMPL_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:3357
static BOOLEAN jjRING3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7276
static BOOLEAN jjREDUCE_P(leftv res, leftv u, leftv v)
Definition iparith.cc:3145
static BOOLEAN jjDIV_Ma(leftv res, leftv u, leftv v)
Definition iparith.cc:1294
static BOOLEAN jjFRES3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:2312
static BOOLEAN jjMODULO(leftv res, leftv u, leftv v)
Definition iparith.cc:2644
static BOOLEAN jjCOMPARE_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:339
STATIC_VAR int WerrorS_dummy_cnt
Definition iparith.cc:5664
static BOOLEAN jjREAD2(leftv res, leftv u, leftv v)
Definition iparith.cc:3129
static BOOLEAN jjREDUCE3_P(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7220
static BOOLEAN jjPAR1(leftv res, leftv v)
Definition iparith.cc:4820
static BOOLEAN jjnlInt(leftv res, leftv u)
Definition iparith.cc:5790
cmdnames * sCmds
array of existing commands
Definition iparith.cc:183
static BOOLEAN jjFAREY_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:2145
static BOOLEAN jjPLUS_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:873
static BOOLEAN jjGCD_N(leftv res, leftv u, leftv v)
Definition iparith.cc:2387
static BOOLEAN jjELIMIN(leftv res, leftv u, leftv v)
Definition iparith.cc:1974
static BOOLEAN jjPLUSPLUS(leftv, leftv u)
Definition iparith.cc:3798
static Subexpr jjMakeSub(leftv e)
Definition iparith.cc:8972
static BOOLEAN jjCHINREM_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:1682
static BOOLEAN jjROWS(leftv res, leftv v)
Definition iparith.cc:5016
static BOOLEAN jjJET_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:2555
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:9005
int IsCmd(const char *n, int &tok)
Definition iparith.cc:9775
static BOOLEAN jjSBA(leftv res, leftv v)
Definition iparith.cc:5084
static BOOLEAN jjOP_IM_I(leftv res, leftv u, leftv v)
Definition iparith.cc:301
static BOOLEAN jjJanetBasis(leftv res, leftv v)
Definition iparith.cc:2545
static BOOLEAN jjKBASE(leftv res, leftv v)
Definition iparith.cc:4574
static BOOLEAN jjTENSOR(leftv res, leftv u, leftv v)
Definition iparith.cc:3644
static BOOLEAN jjmpTrace(leftv res, leftv v)
Definition iparith.cc:5743
static BOOLEAN jjRING_PL(leftv res, leftv a)
Definition iparith.cc:8950
static BOOLEAN jjREDUCE4(leftv res, leftv u)
Definition iparith.cc:8385
static BOOLEAN jjFWALK(leftv res, leftv u, leftv v)
Definition iparith.cc:2361
static BOOLEAN jjTEST(leftv, leftv v)
Definition iparith.cc:8640
static BOOLEAN jjDIFF_ID_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:1932
static BOOLEAN jjSYZ_2(leftv res, leftv u, leftv v)
Definition iparith.cc:3572
static BOOLEAN jjPRUNE(leftv res, leftv v)
Definition iparith.cc:4904
static BOOLEAN jjDIVISION4(leftv res, leftv v)
Definition iparith.cc:7399
unsigned nLastIdentifier
valid identifiers are slot 1..nLastIdentifier
Definition iparith.cc:190
static BOOLEAN jjDEFINED(leftv res, leftv v)
Definition iparith.cc:4067
static BOOLEAN jjLagSolve(leftv res, leftv v)
Definition iparith.cc:4657
static BOOLEAN jjRING_1(leftv res, leftv u, leftv v)
Definition iparith.cc:1673
static BOOLEAN jjVDIM(leftv res, leftv v)
Definition iparith.cc:5516
static BOOLEAN jjHILBERT3Qt(leftv, leftv u, leftv v, leftv w)
Definition iparith.cc:6256
static BOOLEAN jjOP_I_BIM(leftv res, leftv u, leftv v)
Definition iparith.cc:259
static BOOLEAN jjCOUNT_N(leftv res, leftv v)
Definition iparith.cc:3995
static BOOLEAN jjHILBERT2(leftv res, leftv u, leftv v)
Definition iparith.cc:2410
static BOOLEAN jjFIND2(leftv res, leftv u, leftv v)
Definition iparith.cc:2294
static BOOLEAN jjCOEF_Id(leftv res, leftv u, leftv v)
Definition iparith.cc:1800
static BOOLEAN jjP2N(leftv res, leftv v)
Definition iparith.cc:4928
static BOOLEAN jjE(leftv res, leftv v)
Definition iparith.cc:4200
static BOOLEAN jjPOWER_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:625
static BOOLEAN jjTIMES_MA_BI1(leftv res, leftv u, leftv v)
Definition iparith.cc:1086
BOOLEAN iiExprArith1(leftv res, leftv a, int op)
Definition iparith.cc:9367
static BOOLEAN jjSTD_HILB_WP(leftv res, leftv INPUT)
Definition iparith.cc:8866
static BOOLEAN jjLISTRING(leftv res, leftv v)
Definition iparith.cc:4639
static BOOLEAN jjCOEFFS2_KB(leftv res, leftv u, leftv v)
Definition iparith.cc:1818
#define SIMPL_NULL
Definition iparith.cc:3355
static BOOLEAN jjLIFTSTD_M(leftv res, leftv U)
Definition iparith.cc:8162
static BOOLEAN jjELIMIN_ALG(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6169
static BOOLEAN jjVAR1(leftv res, leftv v)
Definition iparith.cc:5482
static BOOLEAN jjLEADCOEF(leftv res, leftv v)
Definition iparith.cc:4588
static BOOLEAN jjVARSTR2(leftv res, leftv u, leftv v)
Definition iparith.cc:3670
static BOOLEAN jjPLUS_N(leftv res, leftv u, leftv v)
Definition iparith.cc:772
static BOOLEAN jjSUBST_Id_X(leftv res, leftv u, leftv v, leftv w, int input_type)
Definition iparith.cc:6942
static BOOLEAN jjUMINUS_BI(leftv res, leftv u)
Definition iparith.cc:3810
int iiArithAddCmd(const char *szName, short nAlias, short nTokval, short nToktype, short nPos=-1)
Definition iparith.cc:10120
static BOOLEAN jjpLength(leftv res, leftv v)
Definition iparith.cc:5690
static BOOLEAN jjJET_P_P(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6364
static BOOLEAN jjLT_I(leftv res, leftv u, leftv v)
Definition iparith.cc:1218
static BOOLEAN jjIS_RINGVAR0(leftv res, leftv)
Definition iparith.cc:4499
static BOOLEAN jjEXTGCD_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:2006
static BOOLEAN jjBI2P(leftv res, leftv u)
Definition iparith.cc:3930
static BOOLEAN jjTWOSTD(leftv res, leftv a)
Definition iparith.cc:5346
static BOOLEAN jjGCD_I(leftv res, leftv u, leftv v)
Definition iparith.cc:2367
static BOOLEAN jjCONTRACT(leftv res, leftv u, leftv v)
Definition iparith.cc:1832
short toktype
Definition gentable.cc:61
static BOOLEAN jjFAC_P(leftv res, leftv u)
Definition iparith.cc:4261
static BOOLEAN jjREDUCE3_CID(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7208
static BOOLEAN jjFAREY_LI(leftv res, leftv u, leftv v)
Definition iparith.cc:10430
static BOOLEAN jjTRANSP_BIM(leftv res, leftv v)
Definition iparith.cc:5302
static BOOLEAN jjCOUNT_RES(leftv res, leftv v)
Definition iparith.cc:5768
#define ii_div_by_0
Definition iparith.cc:217
static BOOLEAN jjDelete_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1862
static BOOLEAN jjGE_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:1166
static BOOLEAN jjrOrdStr(leftv res, leftv v)
Definition iparith.cc:5753
static BOOLEAN jjKERNEL(leftv res, leftv u, leftv v)
Definition iparith.cc:2573
static BOOLEAN jjINTERSECT3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6336
static BOOLEAN jjBRACK_Ma(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:5870
sValCmdTab jjValCmdTab[]
Definition iparith.cc:130
static BOOLEAN jjMOD_N(leftv res, leftv u, leftv v)
Definition iparith.cc:2708
static BOOLEAN jjLOAD_E(leftv, leftv v, leftv u)
Definition iparith.cc:2633
static BOOLEAN jjNEWSTRUCT3(leftv, leftv u, leftv v, leftv w)
Definition iparith.cc:6670
static BOOLEAN jjHOMOG_P_W(leftv res, leftv u, leftv v, leftv)
Definition iparith.cc:6296
static BOOLEAN jjpHead(leftv res, leftv v)
Definition iparith.cc:5715
static BOOLEAN jjSUBST_Id(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6884
static BOOLEAN jjEQUAL_R(leftv res, leftv u, leftv v)
Definition iparith.cc:1347
static BOOLEAN jjCOUNT_L(leftv res, leftv v)
Definition iparith.cc:4000
struct sValCmdM * psValCmdM
Definition iparith.cc:187
static BOOLEAN jjDET_I(leftv res, leftv v)
Definition iparith.cc:4138
static BOOLEAN jjCOUNT_RG(leftv res, leftv v)
Definition iparith.cc:4017
static BOOLEAN jjSMATRIX_Mo(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7116
static BOOLEAN jjINTERSECT(leftv res, leftv u, leftv v)
Definition iparith.cc:2521
static BOOLEAN jjrVarStr(leftv res, leftv v)
Definition iparith.cc:5758
static BOOLEAN jjOP_BI_BIM(leftv res, leftv u, leftv v)
Definition iparith.cc:276
static BOOLEAN jjDIFF_P(leftv res, leftv u, leftv v)
Definition iparith.cc:1910
static BOOLEAN check_valid(const int p, const int op)
Definition iparith.cc:10179
static BOOLEAN jjSTRING_PL(leftv res, leftv v)
Definition iparith.cc:8606
static BOOLEAN jjMINUS_B(leftv res, leftv u, leftv v)
Definition iparith.cc:919
static BOOLEAN jjRSUM(leftv res, leftv u, leftv v)
Definition iparith.cc:3343
static BOOLEAN jjINDEX_I(leftv res, leftv u, leftv v)
Definition iparith.cc:1390
static BOOLEAN jjPOWER_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:568
static BOOLEAN jjMONITOR1(leftv res, leftv v)
Definition iparith.cc:2738
static BOOLEAN jjKLAMMER_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1572
static BOOLEAN jjFETCH(leftv res, leftv u, leftv v)
Definition iparith.cc:2166
static BOOLEAN jjCALL3ARG(leftv res, leftv u)
Definition iparith.cc:7370
static BOOLEAN jjSTD_1(leftv res, leftv u, leftv v)
Definition iparith.cc:3496
static BOOLEAN jjUMINUS_N(leftv res, leftv u)
Definition iparith.cc:3822
static BOOLEAN jjNUMERATOR(leftv res, leftv v)
Return the numerator of the input number.
Definition iparith.cc:4088
static BOOLEAN jjORD(leftv res, leftv v)
Definition iparith.cc:4814
static BOOLEAN jjTIMES_P(leftv res, leftv u, leftv v)
Definition iparith.cc:1008
static BOOLEAN jjUMINUS_I(leftv res, leftv u)
Definition iparith.cc:3817
static BOOLEAN jjPREIMAGE(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6680
static BOOLEAN jjBRACK_Ma_IV_IV(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6027
static BOOLEAN jjMRES_MAP(leftv res, leftv u, leftv v, leftv ma)
Definition iparith.cc:6587
static BOOLEAN jjPLUS_SM(leftv res, leftv u, leftv v)
Definition iparith.cc:836
BOOLEAN jjLOAD_TRY(const char *s)
Definition iparith.cc:5669
static BOOLEAN jjLIFT3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7129
static BOOLEAN jjENVELOPE(leftv res, leftv a)
Definition iparith.cc:5331
static BOOLEAN jjSetRing(leftv, leftv u)
Definition iparith.cc:3855
VAR int iiOp
Definition iparith.cc:219
static BOOLEAN jjMINUS_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:894
static BOOLEAN jjTIMES_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:991
static BOOLEAN jjFACSTD2(leftv res, leftv v, leftv w)
Definition iparith.cc:2112
static BOOLEAN jjINTVEC_PL(leftv res, leftv v)
Definition iparith.cc:7902
STATIC_VAR SArithBase sArithBase
Base entry for arithmetic.
Definition iparith.cc:198
static BOOLEAN jjEXPORTTO(leftv, leftv u, leftv v)
Definition iparith.cc:1994
static BOOLEAN jjPlural_num_poly(leftv res, leftv a, leftv b)
Definition iparith.cc:2838
static BOOLEAN jjDIV_P(leftv res, leftv u, leftv v)
Definition iparith.cc:1276
static BOOLEAN jjKBASE2(leftv res, leftv u, leftv v)
Definition iparith.cc:2560
static BOOLEAN jjPOWER_I(leftv res, leftv u, leftv v)
Definition iparith.cc:522
#define SIMPL_MULT
Definition iparith.cc:3353
static BOOLEAN jjRES(leftv res, leftv u, leftv v)
Definition iparith.cc:3162
static int iin_Int(number &n, coeffs cf)
Definition iparith.cc:222
static BOOLEAN jjPLUS_P_MA(leftv res, leftv u, leftv v)
Definition iparith.cc:859
static BOOLEAN jjMINRES_R(leftv res, leftv v)
Definition iparith.cc:4749
static BOOLEAN jjCOLS(leftv res, leftv v)
Definition iparith.cc:3961
static BOOLEAN jjPLUS_BIM(leftv res, leftv u, leftv v)
Definition iparith.cc:814
static BOOLEAN jjP2BI(leftv res, leftv v)
Definition iparith.cc:4860
static void WerrorS_dummy(const char *)
Definition iparith.cc:5665
static BOOLEAN jjGE_I(leftv res, leftv u, leftv v)
Definition iparith.cc:1173
long farey_cnt
Definition iparith.cc:9
static BOOLEAN jjTRANSP_IV(leftv res, leftv v)
Definition iparith.cc:5307
static BOOLEAN jjGT_N(leftv res, leftv u, leftv v)
Definition iparith.cc:1196
static BOOLEAN jjUNIVARIATE(leftv res, leftv v)
Definition iparith.cc:5477
static BOOLEAN jjMODULO4(leftv res, leftv u)
Definition iparith.cc:8303
static BOOLEAN jjHOMOG_ID_W(leftv res, leftv u, leftv v, leftv)
Definition iparith.cc:6278
static BOOLEAN jjWEDGE(leftv res, leftv u, leftv v)
Definition iparith.cc:3755
static BOOLEAN jjCOMPARE_P(leftv res, leftv u, leftv v)
Definition iparith.cc:452
static BOOLEAN jjFIND3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6186
static BOOLEAN jjLU_INVERSE(leftv res, leftv v)
Definition iparith.cc:7740
static BOOLEAN jjMODULO3S(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7065
static BOOLEAN jjBAREISS_BIM(leftv res, leftv v)
Definition iparith.cc:3902
static BOOLEAN jjPLUS_MA_P(leftv res, leftv u, leftv v)
Definition iparith.cc:848
static BOOLEAN jjSIMPL_P(leftv res, leftv u, leftv v)
Definition iparith.cc:3452
static BOOLEAN jjPFAC1(leftv res, leftv v)
Definition iparith.cc:4648
static BOOLEAN jjQRDS(leftv res, leftv INPUT)
Definition iparith.cc:8849
static BOOLEAN jjELIMIN_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1980
static BOOLEAN jjCONTENT(leftv res, leftv v)
Definition iparith.cc:3976
static BOOLEAN jjDIFF_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:1921
static BOOLEAN jjSTD(leftv res, leftv v)
Definition iparith.cc:5165
static BOOLEAN jjTIMES_BIM(leftv res, leftv u, leftv v)
Definition iparith.cc:1074
static BOOLEAN jjTIMES_I(leftv res, leftv u, leftv v)
Definition iparith.cc:978
static BOOLEAN jjDIV_N(leftv res, leftv u, leftv v)
Definition iparith.cc:1263
static BOOLEAN jjINTMAT3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6322
static BOOLEAN jjCOUNT_IV(leftv res, leftv v)
Definition iparith.cc:4012
static BOOLEAN jjFRES(leftv res, leftv u, leftv v)
Definition iparith.cc:2351
unsigned nCmdAllocated
number of commands-slots allocated
Definition iparith.cc:189
static BOOLEAN jjDUMMY(leftv res, leftv u)
Definition iparith.cc:3777
static BOOLEAN jjS2I(leftv res, leftv v)
Definition iparith.cc:5037
static BOOLEAN jjKLAMMER(leftv res, leftv u, leftv v)
Definition iparith.cc:1560
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:9164
static BOOLEAN jjBI2N(leftv res, leftv u)
Definition iparith.cc:3909
short alias
Definition gentable.cc:59
static BOOLEAN jjRIGHTSTD(leftv res, leftv v)
Definition iparith.cc:5365
BOOLEAN iiExprArithM(leftv res, leftv a, int op)
Definition iparith.cc:9668
static BOOLEAN jjCOMPARE_MA(leftv res, leftv u, leftv v)
Definition iparith.cc:424
BOOLEAN iiExprArith3(leftv res, int op, leftv a, leftv b, leftv c)
Definition iparith.cc:9577
static BOOLEAN jjGETDUMP(leftv, leftv v)
Definition iparith.cc:4277
static BOOLEAN jjidFreeModule(leftv res, leftv v)
Definition iparith.cc:5700
static BOOLEAN jjFAREY_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:2134
static BOOLEAN jjBRACKET_REC(leftv res, leftv a, leftv b, leftv c)
Definition iparith.cc:2945
static BOOLEAN jjCOMPARE_IV_I(leftv res, leftv u, leftv v)
Definition iparith.cc:397
static BOOLEAN jjRANDOM_Im(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6763
static BOOLEAN jjRESERVEDNAME(leftv res, leftv v)
Definition iparith.cc:4944
struct sValCmd1 * psValCmd1
Definition iparith.cc:184
static BOOLEAN jjDIVMOD_I(leftv res, leftv u, leftv v)
Definition iparith.cc:1227
static BOOLEAN jjLE_I(leftv res, leftv u, leftv v)
Definition iparith.cc:1205
static BOOLEAN jjTENSOR_Ma(leftv res, leftv u, leftv v)
Definition iparith.cc:3651
static BOOLEAN jjCOEFFS3_KB(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6136
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:9424
static BOOLEAN jjRMINUS(leftv res, leftv u, leftv v)
Definition iparith.cc:3324
BOOLEAN jjPROC(leftv res, leftv u, leftv v)
Definition iparith.cc:1617
static BOOLEAN jjPLUS_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:767
static BOOLEAN jjHILBERT3(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6226
static BOOLEAN jjDET2(leftv res, leftv u, leftv v)
Definition iparith.cc:1896
static BOOLEAN jjSTD_HILB(leftv res, leftv u, leftv v)
Definition iparith.cc:3468
static BOOLEAN jjAND_I(leftv res, leftv u, leftv v)
Definition iparith.cc:1380
static BOOLEAN jjINDEX_P_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1488
static BOOLEAN jjRPAR(leftv res, leftv v)
Definition iparith.cc:5032
static BOOLEAN jjJanetBasis2(leftv res, leftv u, leftv v)
Definition iparith.cc:2539
static BOOLEAN jjLOAD1(leftv, leftv v)
Definition iparith.cc:4635
static BOOLEAN jjCOLON(leftv res, leftv u, leftv v)
Definition iparith.cc:320
const char * Tok2Cmdname(int tok)
Definition iparith.cc:9899
static BOOLEAN jjRPLUS(leftv res, leftv u, leftv v)
Definition iparith.cc:3330
static BOOLEAN jjKERNEL_SM(leftv res, leftv v)
Definition iparith.cc:4565
static BOOLEAN jjCOLCOL(leftv res, leftv u, leftv v)
Definition iparith.cc:693
long all_farey
Definition iparith.cc:8
static BOOLEAN jjFAC_P2(leftv res, leftv u, leftv dummy)
Definition iparith.cc:2065
static BOOLEAN jjHOMOG_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:2465
static BOOLEAN jjrParStr(leftv res, leftv v)
Definition iparith.cc:5763
struct sValCmd2 * psValCmd2
Definition iparith.cc:185
static BOOLEAN jjDEG(leftv res, leftv v)
Definition iparith.cc:4031
static BOOLEAN jjFETCH_M(leftv res, leftv u)
Definition iparith.cc:7541
static BOOLEAN jjINDEX_V(leftv res, leftv u, leftv v)
Definition iparith.cc:1517
static BOOLEAN jjRINGLIST(leftv res, leftv v)
Definition iparith.cc:4987
static BOOLEAN jjidElem(leftv res, leftv v)
Definition iparith.cc:5695
static BOOLEAN jjDIM2(leftv res, leftv v, leftv w)
Definition iparith.cc:1937
static BOOLEAN jjOP_BIM_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:263
static BOOLEAN jjGCD_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:2380
static BOOLEAN jjBI2IM(leftv res, leftv u)
Definition iparith.cc:3924
static BOOLEAN jjRANK2(leftv res, leftv u, leftv v)
Definition iparith.cc:3120
static BOOLEAN jjDEGREE(leftv res, leftv v)
Definition iparith.cc:4050
static BOOLEAN jjLIFTSTD_ALG(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:7174
static BOOLEAN jjINDEPSET2(leftv res, leftv u, leftv v)
Definition iparith.cc:2514
static BOOLEAN jjWAITALL2(leftv res, leftv u, leftv v)
Definition iparith.cc:3707
static BOOLEAN jjOpenClose(leftv, leftv v)
Definition iparith.cc:4808
static BOOLEAN jjBRACK_S(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:5799
static BOOLEAN jjUMINUS_P(leftv res, leftv u)
Definition iparith.cc:3829
static BOOLEAN jjMINUS_SM(leftv res, leftv u, leftv v)
Definition iparith.cc:965
static BOOLEAN jjHIGHCORNER_M(leftv res, leftv v)
Definition iparith.cc:4298
static BOOLEAN jjNAMES(leftv res, leftv v)
Definition iparith.cc:4788
static BOOLEAN jjINDEX_P(leftv res, leftv u, leftv v)
Definition iparith.cc:1448
static BOOLEAN jjHIGHCORNER(leftv res, leftv v)
Definition iparith.cc:4291
static BOOLEAN jjEQUAL_Ma(leftv res, leftv u, leftv v)
Definition iparith.cc:1335
static BOOLEAN jjNAMES0(leftv res, leftv)
Definition iparith.cc:8370
#define SIMPL_NORMALIZE
Definition iparith.cc:3350
static BOOLEAN jjLOAD2(leftv, leftv, leftv v)
Definition iparith.cc:2629
static BOOLEAN jjALIGN_M(leftv res, leftv u, leftv v)
Definition iparith.cc:1779
static BOOLEAN jjWAIT1ST2(leftv res, leftv u, leftv v)
Definition iparith.cc:3683
static BOOLEAN jjDIV_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:1250
static BOOLEAN jjCOMPARE_BIM(leftv res, leftv u, leftv v)
Definition iparith.cc:367
static BOOLEAN jjEQUAL_N(leftv res, leftv u, leftv v)
Definition iparith.cc:1353
static BOOLEAN jjDelete_ID_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1876
static BOOLEAN jjDET2_S(leftv res, leftv u, leftv v)
Definition iparith.cc:1903
static BOOLEAN jjCOEFFS_Id(leftv res, leftv u, leftv v)
Definition iparith.cc:1807
STATIC_VAR si_char_2 Tok2Cmdname_buf
Definition iparith.cc:9898
static BOOLEAN jjPROC1(leftv res, leftv u)
Definition iparith.cc:3875
static BOOLEAN jjNOT(leftv res, leftv v)
Definition iparith.cc:4798
static BOOLEAN jjPARSTR1(leftv res, leftv v)
Definition iparith.cc:4842
static BOOLEAN jjSUBST_Id_N(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:6938
static BOOLEAN jjJET4(leftv res, leftv u)
Definition iparith.cc:7995
static BOOLEAN jjOPPOSE(leftv res, leftv a, leftv b)
Definition iparith.cc:2986
static BOOLEAN jjMOD_P(leftv res, leftv u, leftv v)
Definition iparith.cc:2719
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:9237
static BOOLEAN jjPLUS_B(leftv res, leftv u, leftv v)
Definition iparith.cc:782
static BOOLEAN jjGCD_P(leftv res, leftv u, leftv v)
Definition iparith.cc:2404
static BOOLEAN jjHOMOG1(leftv res, leftv v)
Definition iparith.cc:4368
static BOOLEAN jjDET(leftv res, leftv v)
Definition iparith.cc:4096
static void jjEQUAL_REST(leftv res, leftv u, leftv v)
Definition iparith.cc:1367
static BOOLEAN jjCOUNT_M(leftv res, leftv v)
Definition iparith.cc:4006
static BOOLEAN jjPLUS_V(leftv res, leftv u, leftv v)
Definition iparith.cc:777
#define SIMPL_LMDIV
Definition iparith.cc:3351
int iiTokType(int op)
Definition iparith.cc:230
static BOOLEAN jjKoszul_Id(leftv res, leftv u, leftv v)
Definition iparith.cc:2581
static BOOLEAN jjKLAMMER_rest(leftv res, leftv u, leftv v)
Definition iparith.cc:1599
static BOOLEAN jjCHINREM_ID(leftv res, leftv u, leftv v)
Definition iparith.cc:10231
static BOOLEAN jjPLUS_S(leftv res, leftv u, leftv v)
Definition iparith.cc:863
static BOOLEAN jjHOMOG1_W(leftv res, leftv v, leftv u)
Definition iparith.cc:2487
static BOOLEAN jjSBA_2(leftv res, leftv v, leftv u, leftv t)
Definition iparith.cc:5138
static BOOLEAN jjINDEX_IV(leftv res, leftv u, leftv v)
Definition iparith.cc:1412
char si_char_2[2]
Definition iparith.cc:9897
unsigned nCmdUsed
number of commands used
Definition iparith.cc:188
static BOOLEAN jjRING_LIST(leftv res, leftv v)
Definition iparith.cc:5009
static BOOLEAN jjBRACK_SM(leftv res, leftv u, leftv v, leftv w)
Definition iparith.cc:5899
static BOOLEAN jjSUBST_Test(leftv v, leftv w, int &ringvar, poly &monomexpr)
Definition iparith.cc:6810
static BOOLEAN jjMINUS_I(leftv res, leftv u, leftv v)
Definition iparith.cc:878
static BOOLEAN jjJET_P(leftv res, leftv u, leftv v)
Definition iparith.cc:2550
static BOOLEAN jjVARSTR1(leftv res, leftv v)
Definition iparith.cc:5499
char * iiArithGetCmd(int nPos)
Definition iparith.cc:10085
static BOOLEAN jjSTATUS_M(leftv res, leftv v)
Definition iparith.cc:8791
static BOOLEAN jjCALL1ARG(leftv res, leftv v)
Definition iparith.cc:7358
static BOOLEAN jjPRUNE_MAP(leftv res, leftv v, leftv ma)
Definition iparith.cc:3059
static BOOLEAN jjLT_BI(leftv res, leftv u, leftv v)
Definition iparith.cc:1214
static BOOLEAN jjPOWER_P(leftv res, leftv u, leftv v)
Definition iparith.cc:602
BOOLEAN jjLIST_PL(leftv res, leftv v)
Definition iparith.cc:8252
static BOOLEAN jjPLUSMINUS_Gen(leftv res, leftv u, leftv v)
Definition iparith.cc:631
static BOOLEAN jjCALL2ARG(leftv res, leftv u)
Definition iparith.cc:7362
static BOOLEAN jjINDEX_PBu(leftv res, leftv u, leftv v)
Definition iparith.cc:1465
static int iiTabIndex(const jjValCmdTab dArithTab, const int len, const int op)
Definition iparith.cc:9874
static BOOLEAN jjSYZYGY(leftv res, leftv v)
Definition iparith.cc:5226
static BOOLEAN jjPOWER_N(leftv res, leftv u, leftv v)
Definition iparith.cc:584
static BOOLEAN jjKLAMMER_PL(leftv res, leftv u)
Definition iparith.cc:8078
static BOOLEAN jjSUBST_M(leftv res, leftv u)
Definition iparith.cc:8822
static BOOLEAN jjEQUAL_P(leftv res, leftv u, leftv v)
Definition iparith.cc:1359
static BOOLEAN jjLU_DECOMP(leftv res, leftv v)
Definition iparith.cc:4666
static BOOLEAN jjPlural_num_mat(leftv res, leftv a, leftv b)
Definition iparith.cc:2858
static BOOLEAN jjIDEAL_PL(leftv res, leftv v)
Definition iparith.cc:7498
static BOOLEAN jjNVARS(leftv res, leftv v)
Definition iparith.cc:4803
static BOOLEAN jjERROR(leftv, leftv u)
Definition iparith.cc:1999
static BOOLEAN jjSTATUS2(leftv res, leftv u, leftv v)
Definition iparith.cc:3441
static BOOLEAN jjALIGN_V(leftv res, leftv u, leftv v)
Definition iparith.cc:1769
static BOOLEAN jjRINGLIST_C(leftv res, leftv v)
Definition iparith.cc:5002
BOOLEAN iiConvert(int inputType, int outputType, int index, leftv input, leftv output, const struct sConvertTypes *dConvertTypes)
Definition ipconv.cc:450
const struct sConvertTypes dConvertTypes[]
Definition table.h:1321
VAR omBin sip_command_bin
Definition ipid.cc:45
lists ipNameListLev(idhdl root, int lev)
Definition ipid.cc:627
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition ipid.cc:256
VAR package basePack
Definition ipid.cc:56
VAR idhdl currRingHdl
Definition ipid.cc:57
VAR package currPack
Definition ipid.cc:55
lists ipNameList(idhdl root)
Definition ipid.cc:604
#define IDMAP(a)
Definition ipid.h:135
#define IDMATRIX(a)
Definition ipid.h:134
EXTERN_VAR omBin sleftv_bin
Definition ipid.h:145
ip_command * command
Definition ipid.h:23
#define IDDATA(a)
Definition ipid.h:126
#define hasFlag(A, F)
Definition ipid.h:112
#define setFlag(A, F)
Definition ipid.h:113
#define IDIDEAL(a)
Definition ipid.h:133
#define IDPOLY(a)
Definition ipid.h:130
#define IDID(a)
Definition ipid.h:122
#define IDROOT
Definition ipid.h:19
#define IDINT(a)
Definition ipid.h:125
#define FLAG_TWOSTD
Definition ipid.h:107
BOOLEAN load_builtin(const char *newlib, BOOLEAN autoexport, SModulFunc_t init)
Definition iplib.cc:1304
#define IDPACKAGE(a)
Definition ipid.h:139
#define IDLEV(a)
Definition ipid.h:121
int(* SModulFunc_t)(SModulFunctions *)
Definition ipid.h:81
#define IDRING(a)
Definition ipid.h:127
#define IDTYP(a)
Definition ipid.h:119
#define FLAG_STD
Definition ipid.h:106
BOOLEAN iiLoadLIB(FILE *fp, const char *libnamebuf, const char *newlib, idhdl pl, BOOLEAN autoexport, BOOLEAN tellerror)
Definition iplib.cc:983
char * iiConvName(const char *libname)
Definition iplib.cc:1439
BOOLEAN iiGetLibStatus(const char *lib)
Definition iplib.cc:77
BOOLEAN iiMake_proc(idhdl pn, package pack, leftv args)
Definition iplib.cc:513
BOOLEAN iiTryLoadLib(leftv v, const char *id)
Definition iplib.cc:832
BOOLEAN load_modules(const char *newlib, char *fullname, BOOLEAN autoexport)
Definition iplib.cc:1294
INST_VAR sleftv iiRETURNEXPR
Definition iplib.cc:483
SModulFunc_t iiGetBuiltinModInit(const char *libname)
Definition iplib.cc:816
lists rDecompose(const ring r)
Definition ipshell.cc:2153
lists rDecompose_list_cf(const ring r)
Definition ipshell.cc:2114
BOOLEAN iiCheckTypes(leftv args, const short *type_list, int report)
check a list of arguemys against a given field of types return TRUE if the types match return FALSE (...
Definition ipshell.cc:6576
ring rInit(leftv pn, leftv rv, leftv ord)
Definition ipshell.cc:5628
leftv iiMap(map theMap, const char *what)
Definition ipshell.cc:618
int iiRegularity(lists L)
Definition ipshell.cc:1045
BOOLEAN rDecompose_CF(leftv res, const coeffs C)
Definition ipshell.cc:1943
void iiMakeResolv(resolvente r, int length, int rlen, char *name, int typ0, intvec **weights)
Definition ipshell.cc:854
void killlocals(int v)
Definition ipshell.cc:387
int exprlist_length(leftv v)
Definition ipshell.cc:551
BOOLEAN mpKoszul(leftv res, leftv c, leftv b, leftv id)
Definition ipshell.cc:3086
poly iiHighCorner(ideal I, int ak)
the largest monomial in R/I
Definition ipshell.cc:1606
lists scIndIndset(ideal S, BOOLEAN all, ideal Q)
Definition ipshell.cc:1111
idhdl rFindHdl(ring r, idhdl n)
Definition ipshell.cc:1701
syStrategy syConvList(lists li)
Definition ipshell.cc:3250
void test_cmd(int i)
Definition ipshell.cc:513
ring rCompose(const lists L, const BOOLEAN check_comp, const long bitmask, const int isLetterplace)
Definition ipshell.cc:2782
const char * lastreserved
Definition ipshell.cc:83
lists syConvRes(syStrategy syzstr, BOOLEAN toDel, int add_row_shift)
Definition ipshell.cc:3178
void rSetHdl(idhdl h)
Definition ipshell.cc:5129
BOOLEAN iiExport(leftv v, int toLev)
Definition ipshell.cc:1510
const struct sValCmd1 dArith1[]
Definition table.h:38
short arg
Definition gentable.cc:80
short res
Definition gentable.cc:70
BOOLEAN(* proc3)(leftv, leftv, leftv, leftv)
Definition ipshell.h:147
short arg1
Definition gentable.cc:71
const struct sValCmd2 dArith2[]
Definition table.h:325
short number_of_args
Definition gentable.cc:98
short valid_for
Definition gentable.cc:99
BOOLEAN(* proc2)(leftv, leftv, leftv)
Definition ipshell.h:136
BOOLEAN setOption(leftv res, leftv v)
Definition misc_ip.cc:570
short cmd
Definition gentable.cc:86
short cmd
Definition gentable.cc:69
short valid_for
Definition gentable.cc:91
short cmd
Definition gentable.cc:78
short valid_for
Definition gentable.cc:73
short res
Definition gentable.cc:97
short res
Definition gentable.cc:87
short arg1
Definition gentable.cc:88
short arg2
Definition gentable.cc:89
BOOLEAN(* proc1)(leftv, leftv)
Definition ipshell.h:124
const struct sValCmdM dArithM[]
Definition table.h:937
short valid_for
Definition gentable.cc:81
short arg3
Definition gentable.cc:90
short res
Definition gentable.cc:79
short arg2
Definition gentable.cc:72
const struct sValCmd3 dArith3[]
Definition table.h:801
short cmd
Definition gentable.cc:96
STATIC_VAR jList * T
Definition janet.cc:30
STATIC_VAR Poly * h
Definition janet.cc:971
ListNode * next
Definition janet.h:31
ideal id_Farey_0(ideal x, number N, const ring r)
Definition kChinese.cc:330
long kHomModDeg(poly p, const ring r)
Definition kstd1.cc:2421
ideal kMin_std2(ideal F, ideal Q, tHomog h, intvec **w, ideal &M, bigintmat *hilb, int syzComp, int reduced)
Definition kstd1.cc:3070
ideal kInterRed(ideal F, const ideal Q)
Definition kstd1.cc:3803
ideal kStd2(ideal F, ideal Q, tHomog h, intvec **w, bigintmat *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
generic interface to GB/SB computations, large hilbert vectors
Definition kstd1.cc:2607
ideal kSba(ideal F, ideal Q, tHomog h, intvec **w, int sbaOrder, int arri, bigintmat *hilb, int syzComp, int newIdeal, intvec *vw)
Definition kstd1.cc:2669
VAR intvec * kHomW
Definition kstd1.cc:2409
VAR intvec * kModW
Definition kstd1.cc:2409
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition kstd1.cc:3230
EXTERN_VAR int Kstd1_deg
Definition kstd1.h:70
ideal rightgb(ideal F, const ideal Q)
Definition kstd2.cc:4935
poly redNF(poly h, int &max_ind, int nonorm, kStrategy strat)
Definition kstd2.cc:2307
ideal_list kStdfac(ideal F, ideal Q, tHomog h, intvec **w, ideal D)
Definition kstdfac.cc:800
char * showOption()
Definition misc_ip.cc:713
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:2638
LINLINE number nlInit(long i, const coeffs r)
Definition longrat.cc:2578
void maFetchPermLP(const ring preimage_r, const ring dst_r, int *perm)
Definition maps.cc:298
void maFindPerm(char const *const *const preim_names, int preim_n, char const *const *const preim_par, int preim_p, char const *const *const names, int n, char const *const *const par, int nop, int *perm, int *par_perm, n_coeffType ch)
Definition maps.cc:155
void maFindPermLP(char const *const *const preim_names, int preim_n, char const *const *const preim_par, int preim_p, char const *const *const names, int n, char const *const *const par, int nop, int *perm, int *par_perm, n_coeffType ch, int lV)
Definition maps.cc:223
poly pSubstPoly(poly p, int var, poly image)
Definition maps_ip.cc:403
ideal idSubstPoly(ideal id, int n, poly e)
Definition maps_ip.cc:425
BOOLEAN maApplyFetch(int what, map theMap, leftv res, leftv w, ring preimage_r, int *perm, int *par_perm, int P, nMapFunc nMap)
Definition maps_ip.cc:45
ideal idSubstPar(ideal id, int n, poly e)
Definition maps_ip.cc:386
poly pSubstPar(poly p, int par, poly image)
Definition maps_ip.cc:266
BOOLEAN mp_IsDiagUnit(matrix U, const ring R)
Definition matpol.cc:810
matrix mp_Wedge(matrix a, int ar, const ring R)
Definition matpol.cc:1745
matrix mp_Transp(matrix a, const ring R)
Definition matpol.cc:247
ideal sm_Tensor(ideal A, ideal B, const ring r)
Definition matpol.cc:1827
ideal sm_Add(ideal a, ideal b, const ring R)
Definition matpol.cc:1867
matrix mp_CoeffProc(poly f, poly vars, const ring R)
Definition matpol.cc:392
matrix pMultMp(poly p, matrix a, const ring R)
Definition matpol.cc:158
void mp_Monomials(matrix c, int r, int var, matrix m, const ring R)
Definition matpol.cc:355
DetVariant mp_GetAlgorithmDet(matrix m, const ring r)
Definition matpol.cc:2108
matrix mp_CoeffProcId(ideal I, poly vars, const ring R)
Definition matpol.cc:469
poly sm_Det(ideal a, const ring r, DetVariant d)
Definition matpol.cc:2163
matrix mp_MultI(matrix a, long f, const ring R)
c = f*a
Definition matpol.cc:128
ideal sm_Sub(ideal a, ideal b, const ring R)
Definition matpol.cc:1877
ideal sm_Mult(ideal a, ideal b, const ring R)
Definition matpol.cc:1887
matrix mp_Sub(matrix a, matrix b, const ring R)
Definition matpol.cc:189
poly mp_Det(matrix a, const ring r, DetVariant d)
Definition matpol.cc:2139
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition matpol.cc:37
int mp_Compare(matrix a, matrix b, const ring R)
Definition matpol.cc:637
BOOLEAN sm_Equal(ideal a, ideal b, const ring R)
Definition matpol.cc:1999
matrix mp_Mult(matrix a, matrix b, const ring R)
Definition matpol.cc:206
BOOLEAN mp_Equal(matrix a, matrix b, const ring R)
Definition matpol.cc:656
matrix mp_Coeffs(ideal I, int var, const ring R)
corresponds to Maple's coeffs: var has to be the number of a variable
Definition matpol.cc:306
void mp_Coef2(poly v, poly mon, matrix *c, matrix *m, const ring R)
corresponds to Macauley's coef: the exponent vector of vars has to contain the variables,...
Definition matpol.cc:574
matrix mp_MultP(matrix a, poly p, const ring R)
multiply a matrix 'a' by a poly 'p', destroy the args
Definition matpol.cc:141
matrix mp_Copy(matrix a, const ring r)
copies matrix a (from ring r to r)
Definition matpol.cc:57
matrix mp_Add(matrix a, matrix b, const ring R)
Definition matpol.cc:172
matrix mp_InitP(int r, int c, poly p, const ring R)
make it a p * unit matrix
Definition matpol.cc:106
poly mp_Trace(matrix a, const ring R)
Definition matpol.cc:268
#define MATELEM(mat, i, j)
1-based access to matrix
Definition matpol.h:29
ip_smatrix * matrix
Definition matpol.h:43
#define MATROWS(i)
Definition matpol.h:26
#define MATCOLS(i)
Definition matpol.h:27
DetVariant
Definition matpol.h:35
lists primeFactorisation(const number n, const int pBound)
Factorises a given bigint number n into its prime factors less than or equal to a given bound,...
Definition misc_ip.cc:358
This file provides miscellaneous functionality.
#define TIMER_RESOLUTION
Definition mod2.h:35
#define assume(x)
Definition mod2.h:389
lib_types type_of_LIB(const char *newlib, char *libnamebuf)
Definition mod_lib.cc:27
lib_types
Definition mod_raw.h:16
@ LT_MACH_O
Definition mod_raw.h:16
@ LT_HPUX
Definition mod_raw.h:16
@ LT_SINGULAR
Definition mod_raw.h:16
@ LT_BUILTIN
Definition mod_raw.h:16
@ LT_ELF
Definition mod_raw.h:16
@ LT_NONE
Definition mod_raw.h:16
@ LT_NOTFOUND
Definition mod_raw.h:16
#define pIter(p)
Definition monomials.h:37
#define pNext(p)
Definition monomials.h:36
#define pSetCoeff0(p, n)
Definition monomials.h:59
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition monomials.h:44
BOOLEAN nuLagSolve(leftv res, leftv arg1, leftv arg2, leftv arg3)
find the (complex) roots an univariate polynomial Determines the roots of an univariate polynomial us...
Definition ipshell.cc:4681
slists * lists
The main handler for Singular numbers which are suitable for Singular polynomials.
Definition ap.h:40
ideal twostd(ideal I)
Compute two-sided GB:
Definition nc.cc:18
void newstruct_setup(const char *n, newstruct_desc d)
Definition newstruct.cc:699
newstruct_desc newstructChildFromString(const char *parent, const char *s)
Definition newstruct.cc:810
newstruct_desc newstructFromString(const char *s)
Definition newstruct.cc:803
CanonicalForm ndConvSingNFactoryN(number, BOOLEAN, const coeffs)
Definition numbers.cc:313
#define nDiv(a, b)
Definition numbers.h:32
#define nDelete(n)
Definition numbers.h:16
#define nInpNeg(n)
Definition numbers.h:21
#define nIsZero(n)
Definition numbers.h:19
#define nEqual(n1, n2)
Definition numbers.h:20
#define nSub(n1, n2)
Definition numbers.h:22
#define nCopy(n)
Definition numbers.h:15
#define nGreater(a, b)
Definition numbers.h:28
#define nAdd(n1, n2)
Definition numbers.h:18
#define nSize(n)
Definition numbers.h:39
#define nInvers(a)
Definition numbers.h:33
#define nIsOne(n)
Definition numbers.h:25
#define nNormalize(n)
Definition numbers.h:30
#define nInit(i)
Definition numbers.h:24
#define nMult(n1, n2)
Definition numbers.h:17
#define nPower(a, b, res)
Definition numbers.h:38
#define omStrDup(s)
#define omfree(addr)
#define omFreeSize(addr, size)
#define omAlloc(size)
#define omAllocBin(bin)
#define omAlloc0Bin(bin)
#define omRealloc(addr, size)
#define omFree(addr)
#define omAlloc0(size)
#define omFreeBin(addr, bin)
#define omFreeBinAddr(addr)
#define NULL
Definition omList.c:12
omInfo_t om_Info
Definition omStats.c:16
VAR unsigned si_opt_2
Definition options.c:6
VAR unsigned si_opt_1
Definition options.c:5
#define SI_SAVE_OPT2(A)
Definition options.h:22
#define Sy_bitL(x)
Definition options.h:32
#define BVERBOSE(a)
Definition options.h:35
#define OPT_REDTAIL_SYZ
Definition options.h:88
#define OPT_SB_1
Definition options.h:96
#define SI_SAVE_OPT1(A)
Definition options.h:21
#define SI_RESTORE_OPT1(A)
Definition options.h:24
#define SI_RESTORE_OPT2(A)
Definition options.h:25
#define Sy_bit(x)
Definition options.h:31
#define TEST_OPT_DEGBOUND
Definition options.h:115
#define TEST_OPT_RETURN_SB
Definition options.h:114
#define TEST_OPT_PROT
Definition options.h:105
#define V_IMAP
Definition options.h:53
#define V_DEG_STOP
Definition options.h:73
#define V_SHOW_USE
Definition options.h:52
static int index(p_Length length, p_Ord ord)
void pRestoreDegProcs(ring r, pFDegProc old_FDeg, pLDegProc old_lDeg)
Definition p_polys.cc:3774
poly p_Homogen(poly p, int varnum, const ring r)
Definition p_polys.cc:3319
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:4873
void p_Normalize(poly p, const ring r)
Definition p_polys.cc:3952
int p_MaxExpPerVar(poly p, int i, const ring r)
max exponent of variable x_i in p
Definition p_polys.cc:5159
int p_Compare(const poly a, const poly b, const ring R)
Definition p_polys.cc:5063
poly p_Series(int n, poly p, poly u, intvec *w, const ring R)
Definition p_polys.cc:4665
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:2893
poly p_Vec2Poly(poly v, int k, const ring r)
Definition p_polys.cc:3698
void p_SetModDeg(intvec *w, ring r)
Definition p_polys.cc:3798
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:3762
long p_Deg(poly a, const ring r)
Definition p_polys.cc:586
static poly p_Neg(poly p, const ring r)
Definition p_polys.h:1114
static int pLength(poly a)
Definition p_polys.h:190
static long p_MinComp(poly p, ring lmRing, ring tailRing)
Definition p_polys.h:315
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition p_polys.h:1167
static long p_Totaldegree(poly p, const ring r)
Definition p_polys.h:1528
void rChangeCurrRing(ring r)
Definition polys.cc:16
VAR coeffs coeffs_BIGINT
Definition polys.cc:14
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
poly pp_Divide(poly p, poly q, const ring r)
polynomial division a/b, ignoring the rest via singclap_pdivide resp. idLift does not destroy a,...
Definition polys.cc:178
poly singclap_gcd(poly f, poly g, const ring r)
polynomial gcd via singclap_gcd_r resp. idSyzygies destroys f and g
Definition polys.cc:409
Compatibility layer for legacy polynomial operations (over currRing).
#define pAdd(p, q)
Definition polys.h:204
static long pTotaldegree(poly p)
Definition polys.h:283
#define pDelete(p_ptr)
Definition polys.h:187
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL
Definition polys.h:68
#define pSetm(p)
Definition polys.h:272
#define pIsConstant(p)
like above, except that Comp must be 0
Definition polys.h:239
#define pSplit(p, r)
Definition polys.h:266
#define pNeg(p)
Definition polys.h:199
#define pGetComp(p)
Component.
Definition polys.h:38
#define pDiff(a, b)
Definition polys.h:297
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
Definition polys.h:32
void pNorm(poly p)
Definition polys.h:363
#define pNSet(n)
Definition polys.h:314
#define pVar(m)
Definition polys.h:381
#define pJet(p, m)
Definition polys.h:368
#define pSub(a, b)
Definition polys.h:288
#define ppMult_qq(p, q)
Definition polys.h:209
#define ppJetW(p, m, iv)
Definition polys.h:369
#define pMaxComp(p)
Definition polys.h:300
#define pLmInit(p)
like pInit, except that expvector is initialized to that of p, p must be != NULL
Definition polys.h:65
#define pIsUnit(p)
return true if the Lm is a constant <>0
Definition polys.h:241
#define pPower(p, q)
Definition polys.h:205
#define pSetComp(p, v)
Definition polys.h:39
#define pLmDelete(p)
assume p != NULL, deletes Lm(p)->coef and Lm(p)
Definition polys.h:77
#define pMult(p, q)
Definition polys.h:208
static void pLmFree(poly p)
frees the space of the monomial m, assumes m != NULL coef is not freed, m is not advanced
Definition polys.h:71
#define pSubst(p, n, e)
Definition polys.h:366
#define pSeries(n, p, u, w)
Definition polys.h:372
#define pGetExp(p, i)
Exponent.
Definition polys.h:42
#define pNormalize(p)
Definition polys.h:318
#define pInit()
allocates a new monomial and initializes everything to 0
Definition polys.h:62
#define pEqualPolys(p1, p2)
Definition polys.h:400
#define pSetExp(p, i, v)
Definition polys.h:43
#define pLmCmp(p, q)
returns 0|1|-1 if p=q|p>q|p<q w.r.t monomial ordering
Definition polys.h:106
#define pCopy(p)
return a copy of the poly
Definition polys.h:186
#define pLmFreeAndNext(p)
assumes p != NULL, deletes p, returns pNext(p)
Definition polys.h:75
#define pOne()
Definition polys.h:316
#define pIsUnivariate(p)
Definition polys.h:250
#define pISet(i)
Definition polys.h:313
#define pWTotaldegree(p)
Definition polys.h:284
ideal maGetPreimage(ring theImageRing, map theMap, ideal id, const ring dst_r)
Definition preimage.cc:57
int IsPrime(int p)
Definition prime.cc:61
void SPrintStart()
Definition reporter.cc:250
const char feNotImplemented[]
Definition reporter.cc:54
void PrintS(const char *s)
Definition reporter.cc:288
char * SPrintEnd()
Definition reporter.cc:277
void PrintLn()
Definition reporter.cc:314
void Werror(const char *fmt,...)
Definition reporter.cc:189
EXTERN_VAR int traceit
Definition reporter.h:24
#define TRACE_CALL
Definition reporter.h:44
#define SI_PROT_O
Definition reporter.h:54
#define SI_PROT_I
Definition reporter.h:53
#define mflush()
Definition reporter.h:58
int rSum(ring r1, ring r2, ring &sum)
Definition ring.cc:1408
int r_IsRingVar(const char *n, char **names, int N)
Definition ring.cc:213
int rChar(ring r)
Definition ring.cc:719
ring rMinusVar(const ring r, char *v)
undo rPlusVar
Definition ring.cc:6024
BOOLEAN rSamePolyRep(ring r1, ring r2)
returns TRUE, if r1 and r2 represents the monomials in the same way FALSE, otherwise this is an analo...
Definition ring.cc:1805
char * rParStr(ring r)
Definition ring.cc:654
char * rCharStr(const ring r)
TODO: make it a virtual method of coeffs, together with: Decompose & Compose, rParameter & rPar.
Definition ring.cc:652
ring rOpposite(ring src)
Definition ring.cc:5425
char * rOrdStr(ring r)
Definition ring.cc:526
void rDelete(ring r)
unconditionally deletes fields in r
Definition ring.cc:454
ring rDefault(const coeffs cf, int N, char **n, int ord_size, rRingOrder_t *ord, int *block0, int *block1, int **wvhdl, unsigned long bitmask)
Definition ring.cc:103
char * rVarStr(ring r)
Definition ring.cc:628
ring rPlusVar(const ring r, char *v, int left)
K[x],"y" -> K[x,y] resp. K[y,x].
Definition ring.cc:5942
ring rEnvelope(ring R)
Definition ring.cc:5819
int n_IsParam(const number m, const ring r)
TODO: rewrite somehow...
Definition ring.cc:5921
ring rCopy(ring r)
Definition ring.cc:1737
static BOOLEAN rField_is_Zp_a(const ring r)
Definition ring.h:540
static BOOLEAN rField_is_Z(const ring r)
Definition ring.h:520
static BOOLEAN rField_is_Zp(const ring r)
Definition ring.h:506
static BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition ring.h:774
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition ring.h:406
long(* pFDegProc)(poly p, ring r)
Definition ring.h:39
static ring rIncRefCnt(ring r)
Definition ring.h:854
static BOOLEAN rField_is_Domain(const ring r)
Definition ring.h:493
long(* pLDegProc)(poly p, int *length, ring r)
Definition ring.h:38
static int rPar(const ring r)
(r->cf->P)
Definition ring.h:610
static BOOLEAN rIsLPRing(const ring r)
Definition ring.h:417
@ ringorder_lp
Definition ring.h:78
@ ringorder_dp
Definition ring.h:79
static BOOLEAN rField_is_Q(const ring r)
Definition ring.h:517
static char const ** rParameter(const ring r)
(r->cf->parameter)
Definition ring.h:636
static BOOLEAN rField_is_numeric(const ring r)
Definition ring.h:526
static BOOLEAN rField_is_GF(const ring r)
Definition ring.h:532
static short rVar(const ring r)
define rVar(r) (r->N)
Definition ring.h:603
static BOOLEAN rHasMixedOrdering(const ring r)
Definition ring.h:775
#define rField_is_Ring(R)
Definition ring.h:491
idrec * idhdl
Definition ring.h:22
void sBucket_Add_p(sBucket_pt bucket, poly p, int length)
adds poly p to bucket destroys p!
Definition sbuckets.cc:203
void sBucketCanonicalize(sBucket_pt bucket)
Definition sbuckets.cc:401
sBucket_pt sBucketCreate(const ring r)
Definition sbuckets.cc:96
poly sBucketPeek(sBucket_pt b)
Definition sbuckets.cc:455
sBucket * sBucket_pt
Definition sbuckets.h:16
void sBucketDestroyAdd(sBucket_pt bucket, poly *p, int *length)
Definition sbuckets.h:68
BOOLEAN sdb_set_breakpoint(const char *pp, int given_lineno)
Definition sdb.cc:64
void sdb_show_bp()
Definition sdb.cc:57
ideal id_Vec2Ideal(poly vec, const ring R)
ideal idInit(int idsize, int rank)
initialise an ideal / module
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
void id_Norm(ideal id, const ring r)
ideal id = (id[i]), result is leadcoeff(id[i]) = 1
BOOLEAN id_HomModuleW(ideal id, ideal Q, const intvec *w, const intvec *module_w, const ring r)
void id_Normalize(ideal I, const ring r)
normialize all polys in id
ideal id_Transp(ideal a, const ring rRing)
transpose a module
ideal id_FreeModule(int i, const ring r)
the free module of rank i
ideal id_Homogen(ideal h, int varnum, const ring r)
ideal id_Power(ideal given, int exp, const ring r)
matrix id_Module2Matrix(ideal mod, const ring R)
ideal id_Head(ideal h, const ring r)
returns the ideals of initial terms
BOOLEAN id_HomIdealW(ideal id, ideal Q, const intvec *w, const ring r)
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
void id_DelDiv(ideal id, const ring r)
delete id[j], if LT(j) == coeff*mon*LT(i) and vice versa, i.e., delete id[i], if LT(i) == coeff*mon*L...
void id_DelMultiples(ideal id, const ring r)
ideal id = (id[i]), c any unit if id[i] = c*id[j] then id[j] is deleted for j > i
matrix id_Module2formatedMatrix(ideal mod, int rows, int cols, const ring R)
ideal id_Matrix2Module(matrix mat, const ring R)
converts mat to module, destroys mat
ideal id_ResizeModule(ideal mod, int rows, int cols, const ring R)
ideal id_Delete_Pos(const ideal I, const int p, const ring r)
void id_DelEquals(ideal id, const ring r)
ideal id = (id[i]) if id[i] = id[j] then id[j] is deleted for j > i
ideal id_Jet(const ideal i, int d, const ring R)
void id_DelLmEquals(ideal id, const ring r)
Delete id[j], if Lm(j) == Lm(i) and both LC(j), LC(i) are units and j > i.
ideal id_JetW(const ideal i, int d, intvec *iv, const ring R)
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
void id_Shift(ideal M, int s, const ring r)
ideal id_ChineseRemainder(ideal *xx, number *q, int rl, const ring r)
ideal id_Subst(ideal id, int n, poly e, const ring r)
#define IDELEMS(i)
static int idElem(const ideal F)
number of non-zero polys in F
int siRand()
Definition sirandom.c:42
#define R
Definition sirandom.c:27
#define A
Definition sirandom.c:24
#define M
Definition sirandom.c:25
#define Q
Definition sirandom.c:26
void sm_CallBareiss(ideal I, int x, int y, ideal &M, intvec **iv, const ring R)
Definition sparsmat.cc:347
ideal sm_CallSolv(ideal I, const ring R)
Definition sparsmat.cc:2316
sleftv * leftv
Definition structs.h:53
tHomog
Definition structs.h:31
@ isHomog
Definition structs.h:33
@ testHomog
Definition structs.h:34
@ isNotHomog
Definition structs.h:32
EXTERN_VAR omBin char_ptr_bin
Definition structs.h:73
#define loop
Definition structs.h:71
VAR omBin sSubexpr_bin
Definition subexpr.cc:40
void syMake(leftv v, const char *id, package pa)
Definition subexpr.cc:1613
INST_VAR sleftv sLastPrinted
Definition subexpr.cc:46
VAR BOOLEAN siq
Definition subexpr.cc:48
BOOLEAN assumeStdFlag(leftv h)
Definition subexpr.cc:1587
@ LANG_SINGULAR
Definition subexpr.h:22
@ LANG_MIX
Definition subexpr.h:22
@ LANG_C
Definition subexpr.h:22
@ LANG_TOP
Definition subexpr.h:22
resolvente syResolvente(ideal arg, int maxlength, int *length, intvec ***weights, BOOLEAN minim)
Definition syz.cc:403
syStrategy syMres_with_map(ideal arg, int maxlength, intvec *w, ideal &trans)
Definition syz.cc:1180
syStrategy syResolution(ideal arg, int maxlength, intvec *w, BOOLEAN minim)
Definition syz.cc:625
void syFix(syStrategy r)
Definition syz.cc:1230
ideal syMinBase(ideal arg)
Definition syz.cc:1021
syStrategy syHilb(ideal arg, int *length)
Definition syz2.cc:950
resolvente sySchreyerResolvente(ideal arg, int maxlength, int *length, BOOLEAN isMonomial=FALSE, BOOLEAN notReplace=FALSE)
Definition syz0.cc:855
syStrategy sySchreyer(ideal arg, int maxlength)
Definition syz0.cc:1018
ring syRing
Definition syz.h:56
int syDim(syStrategy syzstr)
Definition syz1.cc:1851
syStrategy syMinimize(syStrategy syzstr)
Definition syz1.cc:2394
syStrategy syCopy(syStrategy syzstr)
Definition syz1.cc:1886
resolvente minres
Definition syz.h:58
syStrategy syKosz(ideal arg, int *length)
Definition syz3.cc:1766
int sySize(syStrategy syzstr)
Definition syz1.cc:1831
short list_length
Definition syz.h:62
resolvente res
Definition syz.h:47
resolvente fullres
Definition syz.h:57
intvec ** weights
Definition syz.h:45
ssyStrategy * syStrategy
Definition syz.h:36
resolvente orderedRes
Definition syz.h:48
SRes resPairs
Definition syz.h:49
syStrategy syFrank(const ideal arg, const int length, const char *method, const bool use_cache=true, const bool use_tensor_trick=false)
Definition syz4.cc:792
syStrategy syLaScala3(ideal arg, int *length)
Definition syz1.cc:2433
int name
New type name for int.
ideal t_rep_gb(const ring r, ideal arg_I, int syz_comp, BOOLEAN F4_mode)
Definition tgb.cc:3581
int getRTimer()
Definition timer.cc:150
#define IDHDL
Definition tok.h:31
@ NCALGEBRA_CMD
Definition tok.h:138
@ ALIAS_CMD
Definition tok.h:34
@ BIGINT_CMD
Definition tok.h:38
@ CRING_CMD
Definition tok.h:56
@ LIST_CMD
Definition tok.h:118
@ INTVEC_CMD
Definition tok.h:101
@ PACKAGE_CMD
Definition tok.h:150
@ DEF_CMD
Definition tok.h:58
@ LRES_CMD
Definition tok.h:120
@ SUBST_CMD
Definition tok.h:188
@ HRES_CMD
Definition tok.h:91
@ KRES_CMD
Definition tok.h:109
@ OPEN_CMD
Definition tok.h:145
@ CNUMBER_CMD
Definition tok.h:47
@ LINK_CMD
Definition tok.h:117
@ STD_CMD
Definition tok.h:186
@ CHINREM_CMD
Definition tok.h:45
@ MRES_CMD
Definition tok.h:131
@ STRING_CMD
Definition tok.h:187
@ SRES_CMD
Definition tok.h:184
@ INTDIV_CMD
Definition tok.h:97
@ INT_CMD
Definition tok.h:96
@ KERNEL_CMD
Definition tok.h:107
@ FAREY_CMD
Definition tok.h:77
@ MAX_TOK
Definition tok.h:220
@ RES_CMD
Definition tok.h:169
#define NONE
Definition tok.h:223
#define COMMAND
Definition tok.h:29
#define UNKNOWN
Definition tok.h:224
#define ANY_TYPE
Definition tok.h:30
number ntDiff(number a, number d, const coeffs cf)
Definition transext.cc:897
ideal fractalWalkProc(leftv first, leftv second)
Definition walk_ip.cc:161
ideal walkProc(leftv first, leftv second)
Definition walk_ip.cc:55
int * iv2array(intvec *iv, const ring R)
Definition weight.cc:200
BOOLEAN jjStdJanetBasis(leftv res, leftv v, int flag)
flag: 0: JB, 1: SB
Definition wrapper.cc:50
#define omPrintStats(F)
Definition xalloc.h:231
#define omPrintInfo(F)
Definition xalloc.h:232
#define omPrintBinStats(F)
Definition xalloc.h:233
#define omUpdateInfo()
Definition xalloc.h:230