My Project
Loading...
Searching...
No Matches
subexpr.cc
Go to the documentation of this file.
1/****************************************
2* Computer Algebra System SINGULAR *
3****************************************/
4/*
5* ABSTRACT: handling of leftv
6*/
7
8#include "kernel/mod2.h"
9#include "omalloc/omalloc.h"
10#include "misc/intvec.h"
11#include "misc/options.h"
12#include "coeffs/numbers.h"
13#include "coeffs/bigintmat.h"
14#include "coeffs/ffields.h" // nfShowMipo // minpoly printing...
16#include "polys/matpol.h"
18
19// #include "coeffs/longrat.h"
20
21#include "kernel/polys.h"
22#include "kernel/ideals.h"
24#include "kernel/GBEngine/syz.h"
26#include "Singular/tok.h"
27#include "Singular/ipid.h"
28#include "Singular/ipshell.h"
29#include "Singular/lists.h"
30#include "Singular/attrib.h"
32#include "Singular/attrib.h"
33#include "Singular/ipprint.h"
34#include "Singular/subexpr.h"
35#include "Singular/blackbox.h"
36#include "Singular/number2.h"
37
38#include <ctype.h>
39
45
47#ifdef SIQ
49#endif
50
52{
53 int n = 1;
54 leftv sl = next;
55 while (sl!=NULL)
56 {
57 n++;
58 sl=sl->next;
59 }
60 return n;
61}
62
63void sleftv::Print(leftv store, int spaces)
64{
65 int t=Typ();
66 if (errorreported) return;
67#ifdef SIQ
68 if (rtyp==COMMAND)
69 {
71 char ch[2];
72 ch[0]=c->op;ch[1]='\0';
73 const char *s=ch;
74 if (c->op>127) s=iiTwoOps(c->op);
75 ::Print("##command %d(%s), %d args\n",
76 c->op, s, c->argc);
77 if (c->argc>0)
78 c->arg1.Print(NULL,spaces+2);
79 if(c->argc<4)
80 {
81 if (c->argc>1)
82 c->arg2.Print(NULL,spaces+2);
83 if (c->argc>2)
84 c->arg3.Print(NULL,spaces+2);
85 }
86 PrintS("##end");
87 }
88 else
89#endif
90 {
91 const char *n=Name();
92 char *s;
93 void *d=Data();
94 if (errorreported) return;
95
96 switch (t /*=Typ()*/)
97 {
98 case CRING_CMD:
99 crPrint((coeffs)d);
100 break;
101#ifdef SINGULAR_4_2
102 case CNUMBER_CMD:
103 n2Print((number2)d);
104 break;
105 case CPOLY_CMD:
106 p2Print((poly2)d);
107 break;
108 case CMATRIX_CMD: // like BIGINTMAT
109#endif
110 case BIGINTMAT_CMD:
111 ((bigintmat *)d)->pprint(colmax);
112 break;
113 case BIGINTVEC_CMD:
114 ((bigintmat *)d)->pprint(4096); // allow longer bigintvec
115 break;
116 case BUCKET_CMD:
117 {
119 if ((e==NULL)
120 && (TEST_V_QRING)
121 &&(currRing->qideal!=NULL))
122 {
123 poly p=pCopy(sBucketPeek(b));
125 PrintNSpaces(spaces);
126 pWrite0(p);
127 pDelete(&p);
128 break;
129 }
130 else
132 }
133 break;
134 case UNKNOWN:
135 case DEF_CMD:
136 PrintNSpaces(spaces);
137 PrintS("`");PrintS(n);PrintS("`");
138 break;
139 case PACKAGE_CMD:
140 PrintNSpaces(spaces);
141 paPrint(n,(package)d);
142 break;
143 case LIB_CMD:
144 case NONE:
145 return;
146 case INTVEC_CMD:
147 case INTMAT_CMD:
148 ((intvec *)d)->show(t,spaces);
149 break;
150 case RING_CMD:
151 {
152 PrintNSpaces(spaces);
153 const ring r = (ring)d;
154 rWrite(r, currRing == r);
155 break;
156 }
157 case MATRIX_CMD:
158 iiWriteMatrix((matrix)d,n,2, currRing, spaces);
159 break;
160 case SMATRIX_CMD:
161 {
163 ipPrint_MA0(m, n);
164 id_Delete((ideal *) &m,currRing);
165 break;
166 }
167 case MODUL_CMD:
168 case IDEAL_CMD:
169 if ((TEST_V_QRING) &&(currRing->qideal!=NULL)
170 &&(!hasFlag(this,FLAG_QRING)))
171 {
172 jjNormalizeQRingId(this);
173 d=Data();
174 }
175 // no break:
176 case MAP_CMD:
177 iiWriteMatrix((matrix)d,n,1, currRing, spaces);
178 break;
179 case POLY_CMD:
180 case VECTOR_CMD:
181 if ((e==NULL)
182 && (TEST_V_QRING)
183 &&(currRing->qideal!=NULL)
184 &&(!hasFlag(this,FLAG_QRING)))
185 {
186 setFlag(this,FLAG_QRING);
187 poly p=(poly)d;
189 if (p!=(poly)d)
190 {
191 d=(void*)p;
192 if ((rtyp==POLY_CMD)||(rtyp==VECTOR_CMD)) data=d;
193 else if (rtyp==IDHDL)
194 {
195 idhdl h=(idhdl)data;
196 IDPOLY(h)=p;
198 }
199 }
200 }
201 PrintNSpaces(spaces);
202 pWrite0((poly)d);
203 break;
204 case RESOLUTION_CMD:
205 {
206 syStrategy tmp=(syStrategy)d;
208 break;
209 }
210 case STRING_CMD:
211 PrintNSpaces(spaces);
212 PrintS((char *)d);
213 break;
214 case INT_CMD:
215 PrintNSpaces(spaces);
216 ::Print("%ld",(long)d);
217 break;
218 case PROC_CMD:
219 {
221
222 PrintNSpaces(spaces);
223 PrintS("// libname : ");
224 PrintS(piProcinfo(pi, "libname"));
225 PrintLn();
226
227 PrintNSpaces(spaces);
228 PrintS("// procname : ");
229 PrintS(piProcinfo(pi, "procname"));
230 PrintLn();
231
232 PrintNSpaces(spaces);
233 PrintS("// type : ");
234 PrintS(piProcinfo(pi, "type"));
235 // ::Print("%-*.*s// ref : %s",spaces,spaces," ",
236 // piProcinfo(pi, "ref"));
237 break;
238 }
239 case LINK_CMD:
240 {
241 si_link l=(si_link)d;
242 PrintNSpaces(spaces);
243 ::Print("// type : %s\n", slStatus(l, "type"));
244 PrintNSpaces(spaces);
245 ::Print("// mode : %s\n", slStatus(l, "mode"));
246 PrintNSpaces(spaces);
247 ::Print("// name : %s\n", slStatus(l, "name"));
248 PrintNSpaces(spaces);
249 ::Print("// open : %s\n", slStatus(l, "open"));
250 PrintNSpaces(spaces);
251 ::Print("// read : %s\n", slStatus(l, "read"));
252 PrintNSpaces(spaces);
253 ::Print("// write: %s", slStatus(l, "write"));
254 break;
255 }
256 case BIGINT_CMD:
257 s=String(d);
258 if (s==NULL) return;
259 PrintNSpaces(spaces);
260 PrintS(s);
261 omFree((ADDRESS)s);
262 break;
263 case NUMBER_CMD:
264 {
265 number n=(number)d;
266 nNormalize(n);
267 if ((number)d !=n)
268 {
269 d=n;
270 if (rtyp==IDHDL) IDNUMBER(((idhdl)data))=n;
271 else if(rtyp==NUMBER_CMD) data=(void*)n;
272 }
273 s=String(d);
274 if (s==NULL) return;
275 PrintS(s);
276 omFree((ADDRESS)s);
277 break;
278 }
279 case LIST_CMD:
280 {
281 lists l=(lists)d;
282 if (lSize(l)<0)
283 {
284 PrintNSpaces(spaces);
285 PrintS("empty list\n");
286 }
287 else
288 {
289 int i=0;
290 for (;i<=l->nr;i++)
291 {
292 if (l->m[i].rtyp!=DEF_CMD)
293 {
294 PrintNSpaces(spaces);
295 ::Print("[%d]:\n",i+1);
296 l->m[i].Print(NULL,spaces+3);
297 }
298 }
299 }
300 break;
301 }
302
303 default:
304 if (t>MAX_TOK)
305 {
306 blackbox * bb=getBlackboxStuff(t);
307 PrintNSpaces(spaces);
308 if (bb!=NULL) { bb->blackbox_Print(bb,d); }
309 else { ::Print("Print: blackbox %d(bb=NULL)",t); }
310 }
311 else
312 ::Print("Print:unknown type %s(%d)", Tok2Cmdname(t),t);
313 } /* end switch: (Typ()) */
314 if ((store!=NULL)&&(store!=this))
315 store->CleanUp();
316 }
317 if (next!=NULL)
318 {
319 if (t==COMMAND) PrintLn();
320 else if (t!=LIST_CMD) PrintS(" ");
321 next->Print(NULL,spaces);
322 }
323 else if ((t!=LIST_CMD)&&(t!=SMATRIX_CMD))
324 {
325 PrintLn();
326 }
327#ifdef SIQ
328 if (rtyp!=COMMAND)
329#endif
330 {
331 if ((store!=NULL)
332 && (store!=this))
333 {
334 if((t/*Typ()*/!=LINK_CMD)
335 && (t/*Typ()*/!=PACKAGE_CMD)
336 && (t/*Typ()*/!=DEF_CMD)
337 )
338 {
339 store->rtyp=t/*Typ()*/;
340 store->data=CopyD();
341 if(attribute!=NULL)
342 {
343 store->attribute=CopyA();
344 }
345 store->flag=flag;
346 }
347 }
348 }
349}
350
351void sleftv::CleanUp(ring r)
352{
353 if (rtyp!=IDHDL)
354 {
355 if ((name!=NULL) && (name!=sNoName_fe) && (rtyp!=ALIAS_CMD))
356 {
357 //::Print("free %x (%s)\n",name,name);
358 omFree((ADDRESS)name); // may be larger >1000 char (large int)
359 }
360 //name=NULL;
361 //flag=0;
362 if (data!=NULL)
363 {
364 //if (rtyp==IDHDL) attribute=NULL; // is only a pointer to attribute of id
366 //data=NULL; // will be done by Init() at the end
367 }
368 if (attribute!=NULL)
369 {
370 switch (rtyp)
371 {
372 case PACKAGE_CMD:
373 //case IDHDL:
374 case ANY_TYPE:
375 case VECHO:
376 case VPRINTLEVEL:
377 case VCOLMAX:
378 case VTIMER:
379 case VRTIMER:
380 case VOICE:
381 case VMAXDEG:
382 case VMAXMULT:
383 case TRACE:
384 case VSHORTOUT:
385 case VNOETHER:
386 case VMINPOLY:
387 case 0:
388 //attribute=NULL; // will be done by Init() at the end
389 break;
390 default:
391 {
392 attribute->killAll(r);
393 }
394 }
395 }
396 }
397 Subexpr h;
398 while (e!=NULL)
399 {
400 h=e->next;
402 e=h;
403 }
404 //rtyp=NONE; // will be done by Init() at the end
405 if (next!=NULL)
406 {
407 leftv tmp_n;
408 do
409 {
410 tmp_n=next->next;
411 //next->name=NULL;
412 next->next=NULL;
413 next->CleanUp(r);
415 next=tmp_n;
416 } while (next!=NULL);
417 }
418 Init();
419}
420
422{
423 int rt=Typ();
424 if(::RingDependend(rt))
425 return TRUE;
426 if (rt==LIST_CMD)
427 return lRingDependend((lists)Data());
428 if (this->next!=NULL)
429 return this->next->RingDependend();
430 return FALSE;
431}
432
433static inline void * s_internalCopy(const int t, void *d)
434{
435 switch (t)
436 {
437 case CRING_CMD:
438 {
439 coeffs cf=(coeffs)d;
440 cf->ref++;
441 return (void*)d;
442 }
443#ifdef SINGULAR_4_2
444 case CNUMBER_CMD:
445 return (void*)n2Copy((number2)d);
446 case CPOLY_CMD:
447 return (void*)p2Copy((poly2)d);
448 case CMATRIX_CMD: // like BIGINTMAT
449#endif
450 case BIGINTMAT_CMD:
451 case BIGINTVEC_CMD:
452 return (void*)bimCopy((bigintmat *)d);
453 case BUCKET_CMD:
454 return (void*)sBucketCopy((sBucket_pt)d);
455 case INTVEC_CMD:
456 case INTMAT_CMD:
457 return (void *)ivCopy((intvec *)d);
458 case MATRIX_CMD:
459 return (void *)mp_Copy((matrix)d, currRing);
460 case SMATRIX_CMD:
461 case IDEAL_CMD:
462 case MODUL_CMD:
463 return (void *)idCopy((ideal)d);
464 case STRING_CMD:
465 return (void *)omStrDup((char *)d);
466 case PACKAGE_CMD:
467 return (void *)paCopy((package) d);
468 case PROC_CMD:
469 return (void *)piCopy((procinfov) d);
470 case POLY_CMD:
471 case VECTOR_CMD:
472 return (void *)pCopy((poly)d);
473 case INT_CMD:
474 return d;
475 case NUMBER_CMD:
476 return (void *)nCopy((number)d);
477 case BIGINT_CMD:
478 return (void *)n_Copy((number)d, coeffs_BIGINT);
479 case MAP_CMD:
480 return (void *)maCopy((map)d, currRing);
481 case LIST_CMD:
482 return (void *)lCopy((lists)d);
483 case LINK_CMD:
484 return (void *)slCopy((si_link) d);
485 case RING_CMD:
486 {
487 ring r=(ring)d;
488 if (r!=NULL)
489 {
490 rIncRefCnt(r);
491 //Print("s_internalCopy:+ ring %lx, ref %d\n",r,r->ref);
492 }
493 return d;
494 }
495 case RESOLUTION_CMD:
496 return (void*)syCopy((syStrategy)d);
497 case DEF_CMD:
498 case NONE:
499 case 0: /* type in error case */
500 break; /* error recovery: do nothing */
501 //case COMMAND:
502 default:
503 {
504 if (t>MAX_TOK)
505 {
506 blackbox *b=getBlackboxStuff(t);
507 if (b!=NULL) return b->blackbox_Copy(b,d);
508 return NULL;
509 }
510 else
511 Warn("s_internalCopy: cannot copy type %s(%d)",
512 Tok2Cmdname(t),t);
513 }
514 }
515 return NULL;
516}
517
518void s_internalDelete(const int t, void *d, const ring r)
519{
520 assume(d!=NULL);
521 switch (t)
522 {
523 case CRING_CMD:
524 {
525 coeffs cf=(coeffs)d;
526 if ((cf->ref<1)&&
527 ((cf->type <=n_GF)
528 ||((cf->type >=n_long_C)&&(cf->type <=n_CF))))
529 {
530 Warn("cannot kill `%s`",nCoeffName(cf));
531 }
532 else // allow nKillChar for n_long_R, extensions, and user defined:
533 nKillChar((coeffs)d);
534 break;
535 }
536#ifdef SINGULAR_4_2
537 case CNUMBER_CMD:
538 {
539 number2 n=(number2)d;
540 n2Delete(n);
541 break;
542 }
543 case CPOLY_CMD:
544 {
545 poly2 n=(poly2)d;
546 p2Delete(n);
547 break;
548 }
549 case CMATRIX_CMD: //like BIGINTMAT
550#endif
551 case BIGINTMAT_CMD:
552 case BIGINTVEC_CMD:
553 {
554 bigintmat *v=(bigintmat*)d;
555 delete v;
556 break;
557 }
558 case BUCKET_CMD:
559 {
562 break;
563 }
564 case INTVEC_CMD:
565 case INTMAT_CMD:
566 {
567 intvec *v=(intvec*)d;
568 delete v;
569 break;
570 }
571 case MAP_CMD:
572 {
573 map m=(map)d;
574 omFreeBinAddr((ADDRESS)m->preimage);
575 m->preimage=NULL; /* no break: continue as IDEAL*/
576 }
577 case SMATRIX_CMD:
578 case MATRIX_CMD:
579 case IDEAL_CMD:
580 case MODUL_CMD:
581 {
582 ideal i=(ideal)d;
583 id_Delete(&i,r);
584 break;
585 }
586 case STRING_CMD:
587 omFree(d);
588 break;
589 //case PACKAGE_CMD:
590 // return (void *)paCopy((package) d);
591 case PROC_CMD:
592 piKill((procinfo*)d);
593 break;
594 case POLY_CMD:
595 case VECTOR_CMD:
596 {
597 poly p=(poly)d;
598 p_Delete(&p,r);
599 break;
600 }
601 case NUMBER_CMD:
602 {
603 number n=(number)d;
604 n_Delete(&n,r->cf);
605 break;
606 }
607 case BIGINT_CMD:
608 {
609 number n=(number)d;
611 break;
612 }
613 case LIST_CMD:
614 {
615 lists l=(lists)d;
616 l->Clean(r);
617 break;
618 }
619 case LINK_CMD:
620 {
621 si_link l=(si_link)d;
622 slKill(l);
623 break;
624 }
625 case RING_CMD:
626 {
627 ring R=(ring)d;
628 if ((R!=currRing)||(R->ref>=0))
629 rKill(R);
630 #ifdef TEST
631 else
632 Print("currRing? ref=%d\n",R->ref);
633 #endif
634 break;
635 }
636 case RESOLUTION_CMD:
637 {
639 if (s!=NULL) syKillComputation(s,r);
640 break;
641 }
642 case COMMAND:
643 {
644 command cmd=(command)d;
645 if (cmd->arg1.rtyp!=0) cmd->arg1.CleanUp(r);
646 if (cmd->arg2.rtyp!=0) cmd->arg2.CleanUp(r);
647 if (cmd->arg3.rtyp!=0) cmd->arg3.CleanUp(r);
649 break;
650 }
651 case INT_CMD:
652 case DEF_CMD:
653 case ALIAS_CMD:
654 case PACKAGE_CMD:
655 case IDHDL:
656 case NONE:
657 case ANY_TYPE:
658 case VECHO:
659 case VPRINTLEVEL:
660 case VCOLMAX:
661 case VTIMER:
662 case VRTIMER:
663 case VOICE:
664 case VMAXDEG:
665 case VMAXMULT:
666 case TRACE:
667 case VSHORTOUT:
668 case VNOETHER:
669 case VMINPOLY:
670 case 0: /* type in error case */
671 break; /* error recovery: do nothing */
672 //case COMMAND:
673 //case COMMAND:
674 default:
675 {
676 if (t>MAX_TOK)
677 {
678 blackbox *b=getBlackboxStuff(t);
679 if (b!=NULL) b->blackbox_destroy(b,d);
680 break;
681 }
682 else
683 Warn("s_internalDelete: cannot delete type %s(%d)",
684 Tok2Cmdname(t),t);
685 }
686 }
687}
688
689void sleftv::Copy(leftv source)
690{
691 Init();
692 rtyp=source->Typ();
693 void *d=source->Data();
694 if(!errorreported)
695 {
696 if (rtyp==BUCKET_CMD)
697 {
699 data=(void*)pCopy(sBucketPeek((sBucket_pt)d));
700 }
701 else
703 if ((source->attribute!=NULL)||(source->e!=NULL))
704 attribute=source->CopyA();
705 flag=source->flag;
706 if (source->next!=NULL)
707 {
709 next->Copy(source->next);
710 }
711 }
712}
713
714void * sleftv::CopyD(int t)
715{
717 {
719 WerrorS("object from another ring");
720 return NULL;
721 }
722
723 if ((rtyp!=IDHDL)&&(rtyp!=ALIAS_CMD)&&(e==NULL))
724 {
725 if (iiCheckRing(t)) return NULL;
726 void *x = data;
727 if (rtyp==VNOETHER) x = (void *)pCopy((currRing->ppNoether));
728 else if ((rtyp==VMINPOLY) && nCoeff_is_algExt(currRing->cf) && (!nCoeff_is_GF(currRing->cf)))
729 {
730 const ring A = currRing->cf->extRing;
731
732 assume( A != NULL );
733 assume( A->qideal != NULL );
734
735 x=(void *)p_Copy(A->qideal->m[0], A);
736 }
737 data=NULL;
738 return x;
739 }
740 void *d=Data(); // will also do a iiCheckRing
741 if ((!errorreported) && (d!=NULL)) return s_internalCopy(t,d);
742 return NULL;
743}
744
745//void * sleftv::CopyD()
746//{
747 //if ((rtyp!=IDHDL)&&(e==NULL)
748 //&&(rtyp!=VNOETHER)&&(rtyp!=VMINPOLY))
749 //{
750 // void *x=data;
751 // data=NULL;
752 // return x;
753 //}
754// return CopyD(Typ());
755//}
756
758{
759 attr *a=Attribute();
760 if ((a!=NULL) && (*a!=NULL))
761 return (*a)->Copy();
762 return NULL;
763}
764
765char * sleftv::String(void *d, BOOLEAN typed, int dim)
766{
767#ifdef SIQ
768 if (rtyp==COMMAND)
769 {
770 ::Print("##command %d\n",((command)data)->op);
771 if (((command)data)->arg1.rtyp!=0)
772 ((command)data)->arg1.Print(NULL,2);
773 if (((command)data)->arg2.rtyp!=0)
774 ((command)data)->arg2.Print(NULL,2);
775 if (((command)data)->arg3.rtyp==0)
776 ((command)data)->arg3.Print(NULL,2);
777 PrintS("##end\n");
778 return omStrDup("");
779 }
780#endif
781 if (d==NULL) d=Data();
782 if (!errorreported)
783 {
784 char *s;
785 int t=Typ();
786 switch (t /*Typ()*/)
787 {
788 case INT_CMD:
789 if (typed)
790 {
791 #if SIZEOF_LONG==8
792 const size_t len=MAX_INT_LEN+17;
793 #else
794 const size_t len=MAX_INT_LEN+7;
795 #endif
796 s=(char*)omAlloc(len);
797 snprintf(s,len,"int(%ld)",(long)d);
798 }
799 else
800 {
801 #if SIZEOF_LONG==8
802 const size_t len=MAX_INT_LEN+12;
803 #else
804 const size_t len=MAX_INT_LEN+2;
805 #endif
806 s=(char*)omAlloc(len);
807 snprintf(s,len,"%ld",(long)d);
808 }
809 return s;
810
811 case STRING_CMD:
812 if (d == NULL)
813 {
814 if (typed) return omStrDup("\"\"");
815 return omStrDup("");
816 }
817 if (typed)
818 {
819 size_t len=strlen((char*) d) + 3;
820 s = (char*) omAlloc(len);
821 snprintf(s,len,"\"%s\"", (char*) d);
822 return s;
823 }
824 else
825 {
826 return omStrDup((char*)d);
827 }
828
829 case POLY_CMD:
830 case VECTOR_CMD:
831 if (typed)
832 {
833 char* ps = pString((poly) d);
834 size_t len=strlen(ps) + 10;
835 s = (char*) omAlloc(len);
836 snprintf(s,len,"%s(%s)", (t /*Typ()*/ == POLY_CMD ? "poly" : "vector"), ps);
837 omFree(ps);
838 return s;
839 }
840 else
841 return pString((poly)d);
842
843 case CRING_CMD:
844 return nCoeffString((coeffs)d);
845 #ifdef SINGULAR_4_2
846 case CNUMBER_CMD:
847 return n2String((number2)d,typed);
848 case CMATRIX_CMD:
849 {
850 bigintmat *b=(bigintmat*)d;
851 return b->String();
852 }
853 #endif
854
855 case NUMBER_CMD:
856 StringSetS((char*) (typed ? "number(" : ""));
858 {
859 nfShowMipo(currRing->cf);
860 }
861 else
862 {
863 nWrite((number)d);
864 }
865 StringAppendS((char*) (typed ? ")" : ""));
866 return StringEndS();
867
868 case BIGINT_CMD:
869 {
870 StringSetS((char*) (typed ? "bigint(" : ""));
871 number nl=(number)d;
873 StringAppendS((char*) (typed ? ")" : ""));
874 return StringEndS();
875 }
876 case BUCKET_CMD:
877 return sBucketString((sBucket_pt)d);
878 case MATRIX_CMD:
880 if (typed)
881 {
882 size_t len=strlen(s) + 40;
883 char* ns = (char*) omAlloc(len);
884 snprintf(ns,len, "matrix(ideal(%s),%d,%d)", s,
885 ((ideal) d)->nrows, ((ideal) d)->ncols);
886 omCheckAddr(ns);
887 return ns;
888 }
889 else
890 {
891 return omStrDup(s);
892 }
893
894 case IDEAL_CMD:
895 case MAP_CMD:
896 case MODUL_CMD:
897 case SMATRIX_CMD:
899 if (typed)
900 {
901 size_t len=strlen(s) + 10;
902 char* ns = (char*) omAlloc(len);
903 if ((t/*Typ()*/==IDEAL_CMD)||(t==MAP_CMD))
904 snprintf(ns,len, "ideal(%s)", s);
905 else /*MODUL_CMD, SMATRIX_CMD */
906 snprintf(ns,len, "module(%s)", s);
907 omFree(s);
908 omCheckAddr(ns);
909 return ns;
910 }
911 return s;
912
913 case INTVEC_CMD:
914 case INTMAT_CMD:
915 {
916 intvec *v=(intvec *)d;
917 s = v->String(dim);
918 if (typed)
919 {
920 char* ns;
921 if (t/*Typ()*/ == INTMAT_CMD)
922 {
923 size_t len=strlen(s) + 40;
924 ns = (char*) omAlloc(len);
925 snprintf(ns,len, "intmat(intvec(%s),%d,%d)", s, v->rows(), v->cols());
926 }
927 else
928 {
929 size_t len=strlen(s) + 10;
930 ns = (char*) omAlloc(len);
931 snprintf(ns,len, "intvec(%s)", s);
932 }
933 omCheckAddr(ns);
934 omFree(s);
935 return ns;
936 }
937 else
938 return s;
939 }
940 case BIGINTMAT_CMD:
941 {
942 bigintmat *bim=(bigintmat*)d;
943 s = bim->String();
944 if (typed)
945 {
946 size_t len=strlen(s) + 40;
947 char* ns = (char*) omAlloc(len);
948 snprintf(ns,len, "bigintmat(bigintvec(%s),%d,%d)", s, bim->rows(), bim->cols());
949 return ns;
950 }
951 else
952 return omStrDup(s);
953 }
954 case BIGINTVEC_CMD:
955 {
956 bigintmat *bim=(bigintmat*)d;
957 s = bim->String();
958 if (typed)
959 {
960 size_t len=strlen(s) + 40;
961 char* ns = (char*) omAlloc(len);
962 snprintf(ns,len, "bigintvec(%s)", s);
963 return ns;
964 }
965 else
966 return omStrDup(s);
967 }
968
969 case RING_CMD:
970 s = rString((ring)d);
971
972 if (typed)
973 {
974 char* ns;
975 ring r=(ring)d;
976 if (r->qideal!=NULL)
977 {
978 char* id = iiStringMatrix((matrix) ((ring) d)->qideal, dim,
979 currRing);
980 size_t len=strlen(s) + strlen(id) + 20;
981 ns = (char*) omAlloc(len);
982 snprintf(ns,len, "\"%s\";%sideal(%s)", s,(dim == 2 ? "\n" : " "), id);
983 }
984 else
985 {
986 size_t len=strlen(s) + 4;
987 ns = (char*) omAlloc(len);
988 snprintf(ns,len, "\"%s\"", s);
989 }
990 omFree(s);
991 omCheckAddr(ns);
992 return ns;
993 }
994 return s;
995 case RESOLUTION_CMD:
996 {
998 s = lString(l, typed, dim);
999 l->Clean();
1000 return s;
1001 }
1002
1003 case PROC_CMD:
1004 {
1005 procinfo* pi = (procinfo*) d;
1006 if((pi->language == LANG_SINGULAR) && (pi->data.s.body!=NULL))
1007 s = (pi->data.s.body);
1008 else
1009 s = (char *)"";
1010 if (typed)
1011 {
1012 size_t len=strlen(s) + 4;
1013 char* ns = (char*) omAlloc(len);
1014 snprintf(ns,len, "\"%s\"", s);
1015 return ns;
1016 }
1017 return omStrDup(s);
1018 }
1019
1020 case LINK_CMD:
1021 s = slString((si_link) d);
1022 if (typed)
1023 {
1024 size_t len=strlen(s) + 10;
1025 char* ns = (char*) omAlloc(len);
1026 snprintf(ns,len, "link(\"%s\")", s);
1028 omCheckAddr(ns);
1029 return ns;
1030 }
1031 return s;
1032
1033 case LIST_CMD:
1034 return lString((lists) d, typed, dim);
1035
1036 default:
1037 if(t> MAX_TOK)
1038 {
1039 blackbox *bb=getBlackboxStuff(t);
1040 if (bb!=NULL) return bb->blackbox_String(bb,d);
1041 }
1042 } /* end switch: (Typ()) */
1043 }
1044 return omStrDup("");
1045}
1046
1047
1049{
1050 if (e==NULL)
1051 {
1052 switch (rtyp)
1053 {
1054 case IDHDL:
1055 return IDTYP((idhdl)data);
1056 case ALIAS_CMD:
1057 {
1058 idhdl h=(idhdl)data;
1059 return ((idhdl)h->data.ustring)->typ;
1060 }
1061 case VECHO:
1062 case VPRINTLEVEL:
1063 case VCOLMAX:
1064 case VTIMER:
1065 case VRTIMER:
1066 case VOICE:
1067 case VMAXDEG:
1068 case VMAXMULT:
1069 case TRACE:
1070 case VSHORTOUT:
1071 return INT_CMD;
1072 case VMINPOLY:
1073 data=NULL;
1074 return NUMBER_CMD;
1075 case VNOETHER:
1076 data=NULL;
1077 return POLY_CMD;
1078 //case COMMAND:
1079 // return COMMAND;
1080 default:
1081 return rtyp;
1082 }
1083 }
1084 int r=0;
1085 int t=rtyp;
1086 void *d=data;
1087 if (t==IDHDL) t=IDTYP((idhdl)d);
1088 else if (t==ALIAS_CMD)
1089 { idhdl h=(idhdl)IDDATA((idhdl)data); t=IDTYP(h);d=IDDATA(h); }
1090 switch (t)
1091 {
1092#ifdef SINGULAR_4_2
1093 case CMATRIX_CMD:
1094 {
1095 bigintmat *b=(bigintmat*)d;
1096 if ((currRing!=NULL)&&(currRing->cf==b->basecoeffs()))
1097 return NUMBER_CMD;
1098 else
1099 return CNUMBER_CMD;
1100 }
1101#endif
1102 case INTVEC_CMD:
1103 case INTMAT_CMD:
1104 r=INT_CMD;
1105 break;
1106 case BIGINTVEC_CMD:
1107 case BIGINTMAT_CMD:
1108 r=BIGINT_CMD;
1109 break;
1110 case IDEAL_CMD:
1111 case MATRIX_CMD:
1112 case MAP_CMD:
1113 case SMATRIX_CMD:
1114 r=POLY_CMD;
1115 break;
1116 case MODUL_CMD:
1117 r=VECTOR_CMD;
1118 break;
1119 case STRING_CMD:
1120 r=STRING_CMD;
1121 break;
1122 default:
1123 {
1124 blackbox *b=NULL;
1125 if (t>MAX_TOK)
1126 {
1128 }
1129 if ((t==LIST_CMD)||((b!=NULL)&&BB_LIKE_LIST(b)))
1130 {
1131 lists l;
1132 if (rtyp==IDHDL) l=IDLIST((idhdl)d);
1133 else l=(lists)d;
1134 if ((0<e->start)&&(e->start<=l->nr+1))
1135 {
1136 Subexpr tmp=l->m[e->start-1].e;
1137 l->m[e->start-1].e=e->next;
1138 r=l->m[e->start-1].Typ();
1139 e->next=l->m[e->start-1].e;
1140 l->m[e->start-1].e=tmp;
1141 }
1142 else
1143 {
1144 //Warn("out of range: %d not in 1..%d",e->start,l->nr+1);
1145 r=DEF_CMD;
1146 }
1147 }
1148 else
1149 Werror("cannot index type %s(%d)",Tok2Cmdname(t),t);
1150 break;
1151 }
1152 }
1153 return r;
1154}
1155
1157{
1158 lists l=NULL;
1159 int r;
1160 if (rtyp==LIST_CMD)
1161 l=(lists)data;
1162 else if ((rtyp==IDHDL)&& (IDTYP((idhdl)data)==LIST_CMD))
1163 l=IDLIST((idhdl)data);
1164 else
1165 return Typ();
1166 //if (l!=NULL)
1167 {
1168 if ((e!=NULL) && (e->next!=NULL))
1169 {
1170 if ((0<e->start)&&(e->start<=l->nr+1))
1171 {
1172 l->m[e->start-1].e=e->next;
1173 r=l->m[e->start-1].LTyp();
1174 l->m[e->start-1].e=NULL;
1175 }
1176 else
1177 {
1178 //Warn("out of range: %d not in 1..%d",e->start,l->nr+1);
1179 r=NONE;
1180 }
1181 return r;
1182 }
1183 return LIST_CMD;
1184 }
1185 return Typ();
1186}
1187
1188#ifdef SINGULAR_4_2
1189STATIC_VAR snumber2 iiNumber2Data[4];
1190STATIC_VAR int iiCmatrix_index=0;
1191#endif
1193{
1194 if ((rtyp!=IDHDL) && iiCheckRing(rtyp))
1195 return NULL;
1197 {
1199 WerrorS("object from another ring");
1200 return NULL;
1201 }
1202 if (e==NULL)
1203 {
1204 switch (rtyp)
1205 {
1206 case ALIAS_CMD:
1207 {
1208 idhdl h=(idhdl)data;
1209 return ((idhdl)h->data.ustring)->data.ustring;
1210 }
1211 case VECHO: return (void *)(long)si_echo;
1212 case VPRINTLEVEL:return (void *)(long)printlevel;
1213 case VCOLMAX: return (void *)(long)colmax;
1214 case VTIMER: return (void *)(long)getTimer();
1215 case VRTIMER: return (void *)(long)getRTimer();
1216 case VOICE: return (void *)(long)(myynest+1);
1217 case VMAXDEG: return (void *)(long)Kstd1_deg;
1218 case VMAXMULT: return (void *)(long)Kstd1_mu;
1219 case TRACE: return (void *)(long)traceit;
1220 case VSHORTOUT: return (void *)(long)(currRing != NULL ? currRing->ShortOut : 0);
1221 case VMINPOLY:
1222 if ( (currRing != NULL) && nCoeff_is_algExt(currRing->cf) && !nCoeff_is_GF(currRing->cf))
1223 {
1224 /* Q(a), Fp(a), but not GF(q) */
1225 const ring A = currRing->cf->extRing;
1226
1227 assume( A != NULL );
1228 assume( A->qideal != NULL );
1229
1230 return (void *)A->qideal->m[0];
1231 }
1232 else
1233 return (void *)nInit(0);
1234
1235 case VNOETHER: return (void *) (currRing->ppNoether);
1236 case IDHDL:
1237 return IDDATA((idhdl)data);
1238 case COMMAND:
1239 //return NULL;
1240 default:
1241 return data;
1242 }
1243 }
1244 /* e != NULL : */
1245 int t=rtyp;
1246 void *d=data;
1247 if (t==IDHDL)
1248 {
1249 t=((idhdl)data)->typ;
1250 d=IDDATA((idhdl)data);
1251 }
1252 else if (t==ALIAS_CMD)
1253 {
1255 t=IDTYP(h);
1256 d=IDDATA(h);
1257 }
1258 if (iiCheckRing(t))
1259 return NULL;
1260 char *r=NULL;
1261 int index=e->start;
1262 switch (t)
1263 {
1264 case INTVEC_CMD:
1265 {
1266 intvec *iv=(intvec *)d;
1267 if ((index<1)||(index>iv->length()))
1268 {
1269 if (!errorreported)
1270 Werror("wrong range[%d] in intvec %s(%d)",index,this->Name(),iv->length());
1271 }
1272 else
1273 r=(char *)(long)((*iv)[index-1]);
1274 break;
1275 }
1276 case INTMAT_CMD:
1277 {
1278 intvec *iv=(intvec *)d;
1279 if ((index<1)
1280 ||(index>iv->rows())
1281 ||(e->next->start<1)
1282 ||(e->next->start>iv->cols()))
1283 {
1284 if (!errorreported)
1285 Werror("wrong range[%d,%d] in intmat %s(%dx%d)",index,e->next->start,
1286 this->Name(),iv->rows(),iv->cols());
1287 }
1288 else
1289 r=(char *)(long)(IMATELEM((*iv),index,e->next->start));
1290 break;
1291 }
1292 case BIGINTVEC_CMD:
1293 {
1294 bigintmat *m=(bigintmat *)d;
1295 if ((index<1)
1296 ||(index>m->cols()))
1297 {
1298 if (!errorreported)
1299 Werror("wrong range[%d] in bigintvec %s(%d)",index,this->Name(),m->cols());
1300 }
1301 else
1302 r=(char *)(BIMATELEM((*m),1,index));
1303 break;
1304 }
1305 case BIGINTMAT_CMD:
1306 {
1307 bigintmat *m=(bigintmat *)d;
1308 if ((index<1)
1309 ||(index>m->rows())
1310 ||(e->next->start<1)
1311 ||(e->next->start>m->cols()))
1312 {
1313 if (!errorreported)
1314 Werror("wrong range[%d,%d] in bigintmat %s(%dx%d)",index,e->next->start,
1315 this->Name(),m->rows(),m->cols());
1316 }
1317 else
1318 r=(char *)(BIMATELEM((*m),index,e->next->start));
1319 break;
1320 }
1321#ifdef SINGULAR_4_2
1322 case CMATRIX_CMD:
1323 {
1324 bigintmat *m=(bigintmat *)d;
1325 if ((index<1)
1326 ||(index>m->rows())
1327 ||(e->next->start<1)
1328 ||(e->next->start>m->cols()))
1329 {
1330 if (!errorreported)
1331 Werror("wrong range[%d,%d] in matrix %s(%dx%d)",index,e->next->start,
1332 this->Name(),m->rows(),m->cols());
1333 }
1334 else
1335 {
1336 iiNumber2Data[iiCmatrix_index].cf=m->basecoeffs();
1337 iiNumber2Data[iiCmatrix_index].n=BIMATELEM((*m),index,e->next->start);
1338 r=(char*)&iiNumber2Data[iiCmatrix_index];
1339 iiCmatrix_index=(iiCmatrix_index+1) % 4;
1340 }
1341 break;
1342 }
1343#endif
1344 case IDEAL_CMD:
1345 case MODUL_CMD:
1346 case MAP_CMD:
1347 {
1348 ideal I=(ideal)d;
1349 if ((index<1)||(index>IDELEMS(I)))
1350 {
1351 if (!errorreported)
1352 Werror("wrong range[%d] in ideal/module %s(%d)",index,this->Name(),IDELEMS(I));
1353 }
1354 else
1355 r=(char *)I->m[index-1];
1356 break;
1357 }
1358 case SMATRIX_CMD:
1359 {
1360 ideal I=(ideal)d;
1361 int c;
1362 sleftv tmp;
1363 tmp.Init();
1364 tmp.rtyp=POLY_CMD;
1365 if ((index>0)&& (index<=I->rank)
1366 && (e->next!=NULL)
1367 && ((c=e->next->start)>0) &&(c<=IDELEMS(I)))
1368 {
1369 r=(char*)SMATELEM(I,index-1,c-1,currRing);
1370 }
1371 else
1372 {
1373 r=NULL;
1374 }
1375 tmp.data=r;
1376 if ((rtyp==IDHDL)||(rtyp==SMATRIX_CMD))
1377 {
1378 tmp.next=next; next=NULL;
1379 d=NULL;
1380 CleanUp();
1381 memcpy(this,&tmp,sizeof(tmp));
1382 }
1383 // and, remember, r is also the result...
1384 else
1385 {
1386 // ???
1387 // here we still have a memory leak...
1388 // example: list L="123","456";
1389 // L[1][2];
1390 // therefore, it should never happen:
1391 assume(0);
1392 // but if it happens: here is the temporary fix:
1393 // omMarkAsStaticAddr(r);
1394 }
1395 break;
1396 }
1397 case STRING_CMD:
1398 {
1399 // this was a memory leak
1400 // we evalute it, cleanup and replace this leftv by it's evalutated form
1401 // the evalutated form will be build in tmp
1402 sleftv tmp;
1403 tmp.Init();
1404 tmp.rtyp=STRING_CMD;
1405 r=(char *)omAllocBin(size_two_bin);
1406 if ((index>0)&& (index<=(int)strlen((char *)d)))
1407 {
1408 r[0]=*(((char *)d)+index-1);
1409 r[1]='\0';
1410 }
1411 else
1412 {
1413 r[0]='\0';
1414 }
1415 tmp.data=r;
1416 if ((rtyp==IDHDL)||(rtyp==STRING_CMD))
1417 {
1418 tmp.next=next; next=NULL;
1419 //if (rtyp==STRING_CMD) { omFree((ADDRESS)data); }
1420 //data=NULL;
1421 d=NULL;
1422 CleanUp();
1423 memcpy(this,&tmp,sizeof(tmp));
1424 }
1425 // and, remember, r is also the result...
1426 else
1427 {
1428 // ???
1429 // here we still have a memory leak...
1430 // example: list L="123","456";
1431 // L[1][2];
1432 // therefore, it should never happen:
1433 assume(0);
1434 // but if it happens: here is the temporary fix:
1435 // omMarkAsStaticAddr(r);
1436 }
1437 break;
1438 }
1439 case MATRIX_CMD:
1440 {
1441 if ((index<1)
1442 ||(index>MATROWS((matrix)d))
1443 ||(e->next->start<1)
1444 ||(e->next->start>MATCOLS((matrix)d)))
1445 {
1446 if (!errorreported)
1447 Werror("wrong range[%d,%d] in matrix %s(%dx%d)",
1448 index,e->next->start,
1449 this->Name(),
1450 MATROWS((matrix)d),MATCOLS((matrix)d));
1451 }
1452 else
1453 r=(char *)MATELEM((matrix)d,index,e->next->start);
1454 break;
1455 }
1456 default:
1457 {
1458 blackbox *b=NULL;
1459 if (t>MAX_TOK)
1460 {
1462 }
1463 if ((t==LIST_CMD)||((b!=NULL)&&(BB_LIKE_LIST(b))))
1464 {
1465 lists l=(lists)d;
1466 if ((0<index)&&(index<=l->nr+1))
1467 {
1468 if ((e->next!=NULL)
1469 && (l->m[index-1].rtyp==STRING_CMD))
1470 // string[..].Data() modifies sleftv, so let's do it ourself
1471 {
1472 char *dd=(char *)l->m[index-1].data;
1473 int j=e->next->start-1;
1474 r=(char *)omAllocBin(size_two_bin);
1475 if ((j>=0) && (j<(int)strlen(dd)))
1476 {
1477 r[0]=*(dd+j);
1478 r[1]='\0';
1479 }
1480 else
1481 {
1482 r[0]='\0';
1483 }
1484 }
1485 else
1486 {
1487 Subexpr tmp=l->m[index-1].e;
1488 l->m[index-1].e=e->next;
1489 r=(char *)l->m[index-1].Data();
1490 e->next=l->m[index-1].e;
1491 l->m[index-1].e=tmp;
1492 }
1493 }
1494 else //if (!errorreported)
1495 Werror("wrong range[%d] in list %s(%d)",index,this->Name(),l->nr+1);
1496 }
1497 else
1498 Werror("cannot index %s of type %s(%d)",this->Name(),Tok2Cmdname(t),t);
1499 break;
1500 }
1501 }
1502 return r;
1503}
1504
1506{
1507 if (e==NULL) return &attribute;
1508 if ((rtyp==LIST_CMD)
1509 ||((rtyp==IDHDL)&&(IDTYP((idhdl)data)==LIST_CMD))
1510 || (rtyp>MAX_TOK)
1511 || ((rtyp==IDHDL)&&(IDTYP((idhdl)data)>MAX_TOK)))
1512 {
1513 leftv v=LData();
1514 return &(v->attribute);
1515 }
1516 return NULL;
1517}
1518
1520{
1521 if (e!=NULL)
1522 {
1523 lists l=NULL;
1524 blackbox *b=getBlackboxStuff(rtyp);
1525
1526 if ((rtyp==LIST_CMD)
1527 || ((b!=NULL)&&(BB_LIKE_LIST(b))))
1528 l=(lists)data;
1529 else if ((rtyp==IDHDL)&& (IDTYP((idhdl)data)==LIST_CMD))
1530 l=IDLIST((idhdl)data);
1531 else if ((rtyp==IDHDL)&& (IDTYP((idhdl)data)>MAX_TOK))
1532 {
1534 if (BB_LIKE_LIST(b)) l=IDLIST((idhdl)data);
1535 }
1536 else if (rtyp==ALIAS_CMD)
1537 {
1538 idhdl h=(idhdl)data;
1539 l= (lists)(((idhdl)h->data.ustring)->data.ustring);
1540 }
1541 if (l!=NULL)
1542 {
1543 if ((0>=e->start)||(e->start>l->nr+1))
1544 return NULL;
1545 if (e->next!=NULL)
1546 {
1547 l->m[e->start-1].e=e->next;
1548 leftv r=l->m[e->start-1].LData();
1549 l->m[e->start-1].e=NULL;
1550 return r;
1551 }
1552 return &(l->m[e->start-1]);
1553 }
1554 }
1555 return this;
1556}
1557
1558#if 0
1559leftv sleftv::LHdl()
1560{
1561 if (e!=NULL)
1562 {
1563 lists l=NULL;
1564
1565 if (rtyp==LIST_CMD)
1566 l=(lists)data;
1567 if ((rtyp==IDHDL)&& (IDTYP((idhdl)data)==LIST_CMD))
1568 l=IDLIST((idhdl)data);
1569 if (l!=NULL)
1570 {
1571 if ((0>=e->start)||(e->start>l->nr+1))
1572 return NULL;
1573 if (e->next!=NULL)
1574 {
1575 l->m[e->start-1].e=e->next;
1576 leftv r=l->m[e->start-1].LHdl();
1577 l->m[e->start-1].e=NULL;
1578 return r;
1579 }
1580 return &(l->m[e->start-1]);
1581 }
1582 }
1583 return this;
1584}
1585#endif
1586
1588{
1589 if (h->e!=NULL)
1590 {
1591 leftv hh=h->LData();
1592 if (h!=hh) return assumeStdFlag(h->LData());
1593 }
1594 if (!hasFlag(h,FLAG_STD))
1595 {
1596 if (!TEST_VERB_NSB)
1597 {
1598 if (TEST_V_ALLWARN)
1599 Warn("%s is no standard basis in >>%s<<",h->Name(),my_yylinebuf);
1600 else
1601 Warn("%s is no standard basis",h->Name());
1602 }
1603 return FALSE;
1604 }
1605 return TRUE;
1606}
1607
1608/*2
1609* transforms a name (as an string created by omAlloc or omStrDup)
1610* into an expression (sleftv), deletes the string
1611* utility for grammar and iparith
1612*/
1613void syMake(leftv v,const char * id, package pa)
1614{
1615 /* resolv an identifier: (to DEF_CMD, if siq>0)
1616 * 1) reserved id: done by scanner
1617 * 2) `basering` / 'Current`
1618 * 3) existing identifier, local
1619 * 4) ringvar, ringpar, local ring
1620 * 5) existing identifier, global
1621 * 6a) int/bigint
1622 * 6b) monom (resp. number), local ring: consisting of:
1623 * 6') ringvar, ringpar,global ring
1624 * 6'') monom (resp. number), local ring
1625 * 7) monom (resp. number), non-local ring
1626 * 8) basering
1627 * 9) `_`
1628 * 10) everything else is of type 0
1629 */
1630#ifdef TEST
1631 if ((*id<' ')||(*id>(char)126))
1632 {
1633 Print("wrong id :%s:\n",id);
1634 }
1635#endif
1636 idhdl save_ring=currRingHdl;
1637 v->Init();
1638 if(pa != NULL)
1639 {
1640 v->req_packhdl = pa;
1641 }
1642 else v->req_packhdl = currPack;
1643// if (v->req_packhdl!=basePack)
1644// Print("search %s in %s\n",id,v->req_packhdl->libname);
1645 idhdl h=NULL;
1646#ifdef SIQ
1647 if (siq<=0)
1648#endif
1649 {
1650 if (id[0]=='#')
1651 {
1652 h=ggetid(id);
1653 /* 3) existing identifier, local */
1654 if ((h!=NULL) && (IDLEV(h)==myynest))
1655 {
1656 if (id!=IDID(h)) omFreeBinAddr((ADDRESS)id); /*assume strlen(id) <1000 */
1657 goto id_found;
1658 }
1659 }
1660 else if ((id[0]!='-')&&(id[0]>='@' /* letters, _ */))
1661 {
1662 if (strcmp(id,"basering")==0)
1663 {
1664 if (currRingHdl!=NULL)
1665 {
1666 if (id!=IDID(currRingHdl)) omFreeBinAddr((ADDRESS)id);
1667 h=currRingHdl;
1668 goto id_found;
1669 }
1670 else
1671 {
1672 v->name = id;
1673 return; /* undefined */
1674 }
1675 }
1676 else if (strcmp(id,"Current")==0)
1677 {
1678 if (currPackHdl!=NULL)
1679 {
1681 h=currPackHdl;
1682 goto id_found;
1683 }
1684 else
1685 {
1686 v->name = id;
1687 return; /* undefined */
1688 }
1689 }
1690 if(v->req_packhdl!=currPack)
1691 {
1692 h=v->req_packhdl->idroot->get(id,myynest);
1693 }
1694 else
1695 {
1696 h=ggetid(id);
1697 }
1698 /* 3) existing identifier, local */
1699 if ((h!=NULL) && (IDLEV(h)==myynest))
1700 {
1701 if (id!=IDID(h)) omFreeBinAddr((ADDRESS)id); /*assume strlen(id) <1000 */
1702 goto id_found;
1703 }
1705 {
1707 }
1708 /* 4. local ring: ringvar */
1710 /*&& (!yyInRingConstruction)*/)
1711 {
1712 int vnr;
1713 if ((vnr=r_IsRingVar(id, currRing->names,currRing->N))>=0)
1714 {
1715 poly p=pOne();
1716 pSetExp(p,vnr+1,1);
1717 pSetm(p);
1718 v->data = (void *)p;
1719 v->name = id;
1720 v->rtyp = POLY_CMD;
1721 return;
1722 }
1723 if((n_NumberOfParameters(currRing->cf)>0)
1724 &&((vnr=r_IsRingVar(id, (char**)n_ParameterNames(currRing->cf),
1725 n_NumberOfParameters(currRing->cf))>=0)))
1726 {
1727 BOOLEAN ok=FALSE;
1728 poly p = pmInit(id,ok);
1729 if (ok && (p!=NULL))
1730 {
1731 v->data = pGetCoeff(p);
1732 pGetCoeff(p)=NULL;
1733 pLmFree(p);
1734 v->rtyp = NUMBER_CMD;
1735 v->name = id;
1736 return;
1737 }
1738 }
1739 }
1740 /* 5. existing identifier, global */
1741 if (h!=NULL)
1742 {
1743 if (id!=IDID(h)) omFreeBinAddr((ADDRESS)id); /*assume strlen(id) <1000 */
1744 goto id_found;
1745 }
1746 }
1747 else
1748 {
1749 /* 6a: int/bigint */
1750 int i=0;
1751 if (id[0]=='-') { i=1; }
1752 while(isdigit(id[i])) i++;
1753 if (id[i]=='\0')
1754 {
1755 int j=atoi(id);
1756 char tmp[MAX_INT_LEN+5];
1757 snprintf(tmp,MAX_INT_LEN+5,"%d",j);
1758 if (strcmp(tmp,id)!=0)
1759 {
1760 number n;
1761 n_Read(id,&n,coeffs_BIGINT);
1762 v->rtyp=BIGINT_CMD;
1763 v->data = n;
1764 }
1765 else
1766 {
1767 v->data=(void*)(long)j;
1768 v->rtyp=INT_CMD;
1769 }
1771 return;
1772 }
1773 }
1774 /* 6b local ring: number/poly */
1776 {
1777 BOOLEAN ok=FALSE;
1778 /*poly p = (!yyInRingConstruction) ? pmInit(id,ok) : (poly)NULL;*/
1779 poly p = pmInit(id,ok);
1780 if (ok)
1781 {
1782 if (p==NULL)
1783 {
1784 v->data = (void *)nInit(0);
1785 v->rtyp = NUMBER_CMD;
1786 #ifdef HAVE_PLURAL
1787 // in this case we may have monomials equal to 0 in p_Read
1788 v->name = id;
1789 #else
1791 #endif
1792 }
1793 else if (pIsConstant(p))
1794 {
1795 v->data = pGetCoeff(p);
1796 pGetCoeff(p)=NULL;
1797 pLmFree(p);
1798 v->rtyp = NUMBER_CMD;
1799 v->name = id;
1800 }
1801 else
1802 {
1803 v->name = id;
1804 #ifdef HAVE_SHIFTBBA
1805 if ((currRing->isLPring!=0)
1806 && (p_Totaldegree(p,currRing)>1))
1807 {
1809 /* v->rtyp = UNKNOWN; - already set */
1810 return; /* error, report "unknown id" */
1811 }
1812 #endif
1813 v->data = p;
1814 v->rtyp = POLY_CMD;
1815 }
1816 return;
1817 }
1818 }
1819 /* 7. non-local ring: number/poly */
1820 {
1821 BOOLEAN ok=FALSE;
1822 poly p = ((currRing!=NULL) /* ring required */
1823 && (currRingHdl!=NULL)
1824 /*&& (!yyInRingConstruction) - not in decl */
1825 && (IDLEV(currRingHdl)!=myynest)) /* already in case 4/6 */
1826 ? pmInit(id,ok) : (poly)NULL;
1827 if (ok)
1828 {
1829 if (p==NULL)
1830 {
1831 v->data = (void *)nInit(0);
1832 v->rtyp = NUMBER_CMD;
1834 }
1835 else
1836 if (pIsConstant(p))
1837 {
1838 v->data = pGetCoeff(p);
1839 pGetCoeff(p)=NULL;
1840 pLmFree(p);
1841 v->rtyp = NUMBER_CMD;
1842 v->name = id;
1843 }
1844 else
1845 {
1846 v->data = p;
1847 v->rtyp = POLY_CMD;
1848 v->name = id;
1849 }
1850 //if (TEST_V_ALLWARN /*&& (myynest>0)*/
1851 //&& ((r_IsRingVar(id, currRing->names,currRing->N)>=0)
1852 // || ((n_NumberOfParameters(currRing->cf)>0)
1853 // &&(r_IsRingVar(id, (char**)n_ParameterNames(currRing->cf),
1854 // n_NumberOfParameters(currRing->cf))>=0))))
1855 //{
1856 //// WARNING: do not use ring variable names in procedures
1857 // Warn("use of variable >>%s<< in a procedure in line %s",id,my_yylinebuf);
1858 //}
1859 return;
1860 }
1861 }
1862 /* 8. basering ? */
1863 if ((myynest>1)&&(currRingHdl!=NULL))
1864 {
1865 if (strcmp(id,IDID(currRingHdl))==0)
1866 {
1867 if (IDID(currRingHdl)!=id) omFreeBinAddr((ADDRESS)id); /*assume strlen (id) <1000 */
1868 h=currRingHdl;
1869 goto id_found;
1870 }
1871 }
1872 if((v->req_packhdl!=basePack) && (v->req_packhdl==currPack))
1873 {
1874 h=basePack->idroot->get(id,myynest);
1875 if (h!=NULL)
1876 {
1877 if (id!=IDID(h)) omFreeBinAddr((ADDRESS)id); /*assume strlen(id) <1000 */
1878 v->req_packhdl=basePack;
1879 goto id_found;
1880 }
1881 }
1882 }
1883#ifdef SIQ
1884 else
1885 v->rtyp=DEF_CMD;
1886#endif
1887 /* 9: _ */
1888 if (strcmp(id,"_")==0)
1889 {
1891 v->Copy(&sLastPrinted);
1892 }
1893 else
1894 {
1895 /* 10: everything else */
1896 /* v->rtyp = UNKNOWN;*/
1897 v->name = id;
1898 }
1899 currRingHdl=save_ring;
1900 return;
1901id_found: // we have an id (in h) found, to set the data in from h
1902 if (IDTYP(h)!=ALIAS_CMD)
1903 {
1904 v->rtyp = IDHDL;
1905 v->flag = IDFLAG(h);
1906 v->attribute=IDATTR(h);
1907 }
1908 else
1909 {
1910 v->rtyp = ALIAS_CMD;
1911 }
1912 v->name = IDID(h);
1913 v->data = (char *)h;
1914 currRingHdl=save_ring;
1915}
1916
1917void syMakeMonom(leftv v,const char * id)
1918{
1919 if (!isdigit(id[0]))
1920 {
1921 Print("non-digit:%s\n",id);
1922 }
1923 /* resolv an identifier: (to DEF_CMD, if siq>0)
1924 * 6) monom (resp. number), local ring
1925 * 7) monom (resp. number), non-local ring
1926 * 10) everything else is of type 0
1927 */
1928#ifdef TEST
1929 if ((*id<' ')||(*id>(char)126))
1930 {
1931 Print("wrong id :%s:\n",id);
1932 }
1933#endif
1934 idhdl save_ring=currRingHdl;
1935 v->Init();
1936 v->req_packhdl = currPack;
1937#ifdef SIQ
1938 if (siq<=0)
1939#endif
1940 {
1941 /* 6. local ring: number/poly */
1942 BOOLEAN ok=FALSE;
1943 poly p = pmInit(id,ok);
1944 if (ok)
1945 {
1946 if (p==NULL)
1947 {
1948 v->data = (void *)nInit(0);
1949 v->rtyp = NUMBER_CMD;
1950 #ifdef HAVE_PLURAL
1951 // in this case we may have monomials equal to 0 in p_Read
1952 if (rIsPluralRing(currRing)) v->name = omStrDup(id);
1953 #endif
1954 }
1955 else if (pIsConstant(p))
1956 {
1957 v->data = pGetCoeff(p);
1958 pGetCoeff(p)=NULL;
1959 pLmFree(p);
1960 v->rtyp = NUMBER_CMD;
1961 }
1962 else
1963 {
1964 v->name = omStrDup(id);
1965 #ifdef HAVE_SHIFTBBA
1966 if ((currRing->isLPring!=0)
1967 && (p_Totaldegree(p,currRing)>1))
1968 {
1970 /* v->rtyp = UNKNOWN; - already set */
1971 return; /* error, report "unknown id" */
1972 }
1973 #endif
1974 v->data = p;
1975 v->rtyp = POLY_CMD;
1976 }
1977 return;
1978 }
1979 }
1980#ifdef SIQ
1981 else
1982 {
1983 v->rtyp=DEF_CMD;
1984 }
1985#endif
1986 /* 9: _ */
1987 if (strcmp(id,"_")==0)
1988 {
1989 v->Copy(&sLastPrinted);
1990 }
1991 else
1992 {
1993 /* 10: everything else */
1994 /* v->rtyp = UNKNOWN;*/
1995 v->name = omStrDup(id);
1996 }
1997 currRingHdl=save_ring;
1998}
1999
2001{
2002 BOOLEAN nok=FALSE;
2003 leftv nn=next;
2004 next=NULL;
2005 if(rtyp==IDHDL)
2006 {
2007 int t=Typ();
2008 if (t!=PROC_CMD)
2009 {
2010 void *d=CopyD(t);
2011 data=d;
2012 rtyp=t;
2013 name=NULL;
2014 e=NULL;
2015 }
2016 }
2017 else if (rtyp==COMMAND)
2018 {
2019 command d=(command)data;
2020 if(d->op==PROC_CMD) //assume d->argc==2
2021 {
2022 char *what=(char *)(d->arg1.Data());
2023 idhdl h=ggetid(what);
2024 if((h!=NULL)&&(IDTYP(h)==PROC_CMD))
2025 {
2026 nok=d->arg2.Eval();
2027 if(!nok)
2028 {
2029 nok=iiMake_proc(h,req_packhdl,&d->arg2);
2030 this->CleanUp(currRing);
2031 if (!nok)
2032 {
2033 memcpy(this,&iiRETURNEXPR,sizeof(sleftv));
2034 iiRETURNEXPR.Init();
2035 }
2036 }
2037 }
2038 else nok=TRUE;
2039 }
2040 else if (d->op=='=') //assume d->argc==2
2041 {
2042 if ((d->arg1.rtyp!=IDHDL)&&(d->arg1.rtyp!=DEF_CMD))
2043 {
2044 nok=d->arg1.Eval();
2045 }
2046 if (!nok)
2047 {
2048 const char *n=d->arg1.name;
2049 nok=(n == NULL) || d->arg2.Eval();
2050 if (!nok)
2051 {
2052 int save_typ=d->arg1.rtyp;
2053 omCheckAddr((ADDRESS)n);
2054 if (d->arg1.rtyp!=IDHDL)
2055 syMake(&d->arg1,n);
2056 omCheckAddr((ADDRESS)d->arg1.name);
2057 if (d->arg1.rtyp==IDHDL)
2058 {
2059 n=omStrDup(IDID((idhdl)d->arg1.data));
2060 killhdl((idhdl)d->arg1.data);
2061 d->arg1.Init();
2062 //d->arg1.data=NULL;
2063 d->arg1.name=n;
2064 }
2065 d->arg1.rtyp=DEF_CMD;
2066 sleftv t;
2067 if(save_typ!=PROC_CMD) save_typ=d->arg2.rtyp;
2068 if (::RingDependend(d->arg2.rtyp))
2069 nok=iiDeclCommand(&t,&d->arg1,0,save_typ,&currRing->idroot);
2070 else
2071 nok=iiDeclCommand(&t,&d->arg1,0,save_typ,&IDROOT);
2072 memcpy(&d->arg1,&t,sizeof(sleftv));
2073 omCheckAddr((ADDRESS)d->arg1.name);
2074 nok=nok||iiAssign(&d->arg1,&d->arg2);
2075 omCheckIf(d->arg1.name != NULL, // OB: ????
2076 omCheckAddr((ADDRESS)d->arg1.name));
2077 if (!nok)
2078 {
2079 d->arg1.Init();
2080 this->CleanUp();
2081 rtyp=NONE;
2082 }
2083 }
2084 }
2085 else nok=TRUE;
2086 }
2087 else
2088 {
2089 sleftv tmp; tmp.Init();
2090 int toktype=iiTokType(d->op);
2091 if ((toktype==CMD_M)
2092 ||( toktype==ROOT_DECL_LIST)
2093 ||( toktype==RING_DECL_LIST))
2094 {
2095 if (d->argc <=3)
2096 {
2097 if (d->argc>=1) nok=d->arg1.Eval();
2098 if ((!nok) && (d->argc>=2))
2099 {
2100 nok=d->arg2.Eval();
2101 d->arg1.next=(leftv)omAllocBin(sleftv_bin);
2102 memcpy(d->arg1.next,&d->arg2,sizeof(sleftv));
2103 d->arg2.Init();
2104 }
2105 if ((!nok) && (d->argc==3))
2106 {
2107 nok=d->arg3.Eval();
2108 d->arg1.next->next=(leftv)omAllocBin(sleftv_bin);
2109 memcpy(d->arg1.next->next,&d->arg3,sizeof(sleftv));
2110 d->arg3.Init();
2111 }
2112 if (d->argc==0)
2113 nok=nok||iiExprArithM(&tmp,NULL,d->op);
2114 else
2115 nok=nok||iiExprArithM(&tmp,&d->arg1,d->op);
2116 }
2117 else
2118 {
2119 nok=d->arg1.Eval();
2120 nok=nok||iiExprArithM(&tmp,&d->arg1,d->op);
2121 }
2122 }
2123 else if (d->argc==1)
2124 {
2125 nok=d->arg1.Eval();
2126 nok=nok||iiExprArith1(&tmp,&d->arg1,d->op);
2127 }
2128 else if(d->argc==2)
2129 {
2130 nok=d->arg1.Eval();
2131 nok=nok||d->arg2.Eval();
2132 nok=nok||iiExprArith2(&tmp,&d->arg1,d->op,&d->arg2);
2133 }
2134 else if(d->argc==3)
2135 {
2136 nok=d->arg1.Eval();
2137 nok=nok||d->arg2.Eval();
2138 nok=nok||d->arg3.Eval();
2139 nok=nok||iiExprArith3(&tmp,d->op,&d->arg1,&d->arg2,&d->arg3);
2140 }
2141 else if(d->argc!=0)
2142 {
2143 nok=d->arg1.Eval();
2144 nok=nok||iiExprArithM(&tmp,&d->arg1,d->op);
2145 }
2146 else // d->argc == 0
2147 {
2148 nok = iiExprArithM(&tmp, NULL, d->op);
2149 }
2150 this->CleanUp();
2151 memcpy(this,&tmp,sizeof(tmp));
2152 }
2153 }
2154 else if (((rtyp==0)||(rtyp==DEF_CMD))
2155 &&(name!=NULL))
2156 {
2157 syMake(this,name);
2158 }
2159#ifdef MDEBUG
2160 switch(Typ())
2161 {
2162 case NUMBER_CMD:
2163#ifdef LDEBUG
2164 nTest((number)Data());
2165#endif
2166 break;
2167 case BIGINT_CMD:
2168#ifdef LDEBUG
2169 n_Test((number)Data(),coeffs_BIGINT);
2170#endif
2171 break;
2172 case POLY_CMD:
2173 pTest((poly)Data());
2174 break;
2175 case IDEAL_CMD:
2176 case MODUL_CMD:
2177 case MATRIX_CMD:
2178 {
2179 ideal id=(ideal)Data();
2180 omCheckAddrSize(id,sizeof(*id));
2181 int i=id->ncols*id->nrows-1;
2182 for(;i>=0;i--) pTest(id->m[i]);
2183 }
2184 break;
2185 }
2186#endif
2187 if (nn!=NULL) nok=nok||nn->Eval();
2188 next=nn;
2189 return nok;
2190}
2191
2193{
2194 omCheckAddrSize(this,sizeof(sattr));
2195 return s_internalCopy(atyp,data);
2196}
2197
sattr * attr
Definition attrib.h:16
int BOOLEAN
Definition auxiliary.h:88
#define TRUE
Definition auxiliary.h:101
#define FALSE
Definition auxiliary.h:97
void * ADDRESS
Definition auxiliary.h:120
bigintmat * bimCopy(const bigintmat *b)
same as copy constructor - apart from it being able to accept NULL as input
Definition bigintmat.cc:403
#define BIMATELEM(M, I, J)
Definition bigintmat.h:133
blackbox * getBlackboxStuff(const int t)
return the structure to the type given by t
Definition blackbox.cc:17
#define BB_LIKE_LIST(B)
Definition blackbox.h:53
int l
Definition cfEzgcd.cc:100
int m
Definition cfEzgcd.cc:128
int i
Definition cfEzgcd.cc:132
Variable x
Definition cfModGcd.cc:4090
int p
Definition cfModGcd.cc:4086
CanonicalForm cf
Definition cfModGcd.cc:4091
CanonicalForm b
Definition cfModGcd.cc:4111
int int ncols
Definition cf_linsys.cc:32
int nrows
Definition cf_linsys.cc:32
CanonicalForm map(const CanonicalForm &primElem, const Variable &alpha, const CanonicalForm &F, const Variable &beta)
map from to such that is mapped onto
Matrices of numbers.
Definition bigintmat.h:51
int cols() const
Definition bigintmat.h:144
int rows() const
Definition bigintmat.h:145
char * String()
IO: String returns a singular string containing the matrix, needs freeing afterwards.
Definition bigintmat.cc:430
int length() const
Definition intvec.h:95
int cols() const
Definition intvec.h:96
int rows() const
Definition intvec.h:97
Definition attrib.h:21
void * data
Definition attrib.h:25
void * CopyA()
Definition subexpr.cc:2192
int atyp
Definition attrib.h:27
Class used for (list of) interpreter objects.
Definition subexpr.h:83
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
BOOLEAN RingDependend()
Definition subexpr.cc:421
leftv next
Definition subexpr.h:86
int Eval()
Definition subexpr.cc:2000
int LTyp()
Definition subexpr.cc:1156
void * CopyD()
Definition subexpr.h:119
char * String(void *d=NULL, BOOLEAN typed=FALSE, int dim=1)
Called for conversion to string (used by string(..), write(..),..)
Definition subexpr.cc:765
const char * Name()
Definition subexpr.h:120
attr CopyA()
Definition subexpr.cc:757
int listLength()
Definition subexpr.cc:51
void Copy(leftv e)
Definition subexpr.cc:689
void * data
Definition subexpr.h:88
void CleanUp(ring r=currRing)
Definition subexpr.cc:351
attr * Attribute()
Definition subexpr.cc:1505
BITSET flag
Definition subexpr.h:90
void Print(leftv store=NULL, int spaces=0)
Called by type_cmd (e.g. "r;") or as default in jPRINT.
Definition subexpr.cc:63
Subexpr e
Definition subexpr.h:105
leftv LData()
Definition subexpr.cc:1519
attr attribute
Definition subexpr.h:89
int nr
Definition lists.h:44
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition coeffs.h:455
static FORCE_INLINE BOOLEAN nCoeff_is_GF(const coeffs r)
Definition coeffs.h:832
#define n_Test(a, r)
BOOLEAN n_Test(number a, const coeffs r)
Definition coeffs.h:713
@ n_GF
\GF{p^n < 2^16}
Definition coeffs.h:32
@ n_CF
?
Definition coeffs.h:48
@ n_long_C
complex floating point (GMP) numbers
Definition coeffs.h:41
static FORCE_INLINE char * nCoeffString(const coeffs cf)
TODO: make it a virtual method of coeffs, together with: Decompose & Compose, rParameter & rPar.
Definition coeffs.h:956
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition coeffs.h:771
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition coeffs.h:459
static FORCE_INLINE char * nCoeffName(const coeffs cf)
Definition coeffs.h:960
static FORCE_INLINE int n_NumberOfParameters(const coeffs r)
Returns the number of parameters.
Definition coeffs.h:767
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition coeffs.h:592
static FORCE_INLINE BOOLEAN nCoeff_is_algExt(const coeffs r)
TRUE iff r represents an algebraic extension field.
Definition coeffs.h:903
static FORCE_INLINE const char * n_Read(const char *s, number *a, const coeffs r)
!!! Recommendation: This method is too cryptic to be part of the user- !!! interface....
Definition coeffs.h:599
void nKillChar(coeffs r)
undo all initialisations
Definition numbers.cc:556
static BOOLEAN pa(leftv res, leftv args)
Definition cohomo.cc:3770
#define Print
Definition emacs.cc:80
#define Warn
Definition emacs.cc:77
const CanonicalForm int s
Definition facAbsFact.cc:51
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
int j
Definition facHensel.cc:110
VAR short errorreported
Definition feFopen.cc:23
void WerrorS(const char *s)
Definition feFopen.cc:24
VAR int printlevel
Definition febase.cc:36
VAR char my_yylinebuf[80]
Definition febase.cc:44
VAR int si_echo
Definition febase.cc:35
VAR int myynest
Definition febase.cc:41
const char sNoName_fe[]
Definition fevoices.cc:57
void nfShowMipo(const coeffs r)
Show the mininimal polynom.... NOTE: this is used by char * sleftv::String(void *d,...
Definition ffields.cc:547
const char * iiTwoOps(int t)
Definition gentable.cc:258
const char * Tok2Cmdname(int tok)
Definition gentable.cc:137
#define STATIC_VAR
Definition globaldefs.h:7
#define INST_VAR
Definition globaldefs.h:8
#define VAR
Definition globaldefs.h:5
@ IDEAL_CMD
Definition grammar.cc:285
@ MATRIX_CMD
Definition grammar.cc:287
@ BUCKET_CMD
Definition grammar.cc:284
@ RING_DECL_LIST
Definition grammar.cc:323
@ BIGINTMAT_CMD
Definition grammar.cc:278
@ MAP_CMD
Definition grammar.cc:286
@ PROC_CMD
Definition grammar.cc:281
@ INTMAT_CMD
Definition grammar.cc:280
@ LIB_CMD
Definition grammar.cc:328
@ ROOT_DECL_LIST
Definition grammar.cc:321
@ VMAXMULT
Definition grammar.cc:308
@ MODUL_CMD
Definition grammar.cc:288
@ VMAXDEG
Definition grammar.cc:307
@ SMATRIX_CMD
Definition grammar.cc:292
@ VECTOR_CMD
Definition grammar.cc:293
@ RESOLUTION_CMD
Definition grammar.cc:291
@ BIGINTVEC_CMD
Definition grammar.cc:279
@ NUMBER_CMD
Definition grammar.cc:289
@ POLY_CMD
Definition grammar.cc:290
@ VMINPOLY
Definition grammar.cc:310
@ CMD_M
Definition grammar.cc:319
@ RING_CMD
Definition grammar.cc:282
@ VNOETHER
Definition grammar.cc:309
BOOLEAN yyInRingConstruction
Definition grammar.cc:172
void ipPrint_MA0(matrix m, const char *name)
Definition ipprint.cc:57
ideal id_Copy(ideal h1, const ring r)
copy an ideal
ideal idCopy(ideal A)
Definition ideals.h:60
intvec * ivCopy(const intvec *o)
Definition intvec.h:146
#define IMATELEM(M, I, J)
Definition intvec.h:86
BOOLEAN iiExprArith2(leftv res, leftv a, int op, leftv b, BOOLEAN proccall)
Definition iparith.cc:9141
BOOLEAN iiExprArith1(leftv res, leftv a, int op)
Definition iparith.cc:9330
BOOLEAN iiExprArithM(leftv res, leftv a, int op)
Definition iparith.cc:9631
BOOLEAN iiExprArith3(leftv res, int op, leftv a, leftv b, leftv c)
Definition iparith.cc:9540
int iiTokType(int op)
Definition iparith.cc:229
void jjNormalizeQRingId(leftv I)
Definition ipassign.cc:2459
BOOLEAN iiAssign(leftv l, leftv r, BOOLEAN toplevel)
Definition ipassign.cc:2097
VAR omBin sip_command_bin
Definition ipid.cc:45
idhdl ggetid(const char *n)
Definition ipid.cc:558
VAR package basePack
Definition ipid.cc:56
VAR idhdl currRingHdl
Definition ipid.cc:57
VAR package currPack
Definition ipid.cc:55
void killhdl(idhdl h, package proot)
Definition ipid.cc:391
VAR idhdl currPackHdl
Definition ipid.cc:53
BOOLEAN piKill(procinfov pi)
Definition ipid.cc:724
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 FLAG_OTHER_RING
Definition ipid.h:110
#define setFlag(A, F)
Definition ipid.h:113
#define IDFLAG(a)
Definition ipid.h:120
#define IDPOLY(a)
Definition ipid.h:130
#define IDID(a)
Definition ipid.h:122
#define IDROOT
Definition ipid.h:19
#define FLAG_QRING
Definition ipid.h:108
#define IDNUMBER(a)
Definition ipid.h:132
#define IDLEV(a)
Definition ipid.h:121
#define jjNormalizeQRingP(p)
Definition ipid.h:103
#define IDTYP(a)
Definition ipid.h:119
#define FLAG_STD
Definition ipid.h:106
#define IDLIST(a)
Definition ipid.h:137
#define IDATTR(a)
Definition ipid.h:123
package paCopy(package pack)
Definition ipid.h:44
BOOLEAN iiMake_proc(idhdl pn, package pack, leftv args)
Definition iplib.cc:513
INST_VAR sleftv iiRETURNEXPR
Definition iplib.cc:483
int iiDeclCommand(leftv sy, leftv name, int lev, int t, idhdl *root, BOOLEAN isring, BOOLEAN init_b)
Definition ipshell.cc:1202
void rKill(ring r)
Definition ipshell.cc:6174
BOOLEAN iiCheckRing(int i)
Definition ipshell.cc:1581
lists syConvRes(syStrategy syzstr, BOOLEAN toDel, int add_row_shift)
Definition ipshell.cc:3172
void paPrint(const char *n, package p)
Definition ipshell.cc:6326
STATIC_VAR Poly * h
Definition janet.cc:971
EXTERN_VAR int Kstd1_deg
Definition kstd1.h:70
EXTERN_VAR int Kstd1_mu
Definition kstd1.h:70
#define pi
Definition libparse.cc:1145
char * lString(lists l, BOOLEAN typed, int dim)
Definition lists.cc:403
BOOLEAN lRingDependend(lists L)
Definition lists.cc:222
int lSize(lists L)
Definition lists.cc:25
lists lCopy(lists L)
Definition lists.cc:32
map maCopy(map theMap, const ring r)
Definition maps.cc:32
char * iiStringMatrix(matrix im, int dim, const ring r, char ch)
Definition matpol.cc:849
matrix mp_Copy(matrix a, const ring r)
copies matrix a (from ring r to r)
Definition matpol.cc:57
void iiWriteMatrix(matrix im, const char *n, int dim, const ring r, int spaces)
set spaces to zero by default
Definition matpol.cc:828
#define MATELEM(mat, i, j)
1-based access to matrix
Definition matpol.h:29
ip_smatrix * matrix
Definition matpol.h:43
#define SMATELEM(A, i, j, R)
Definition matpol.h:123
#define MATROWS(i)
Definition matpol.h:26
#define MATCOLS(i)
Definition matpol.h:27
#define assume(x)
Definition mod2.h:389
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
slists * lists
const int MAX_INT_LEN
Definition mylimits.h:13
The main handler for Singular numbers which are suitable for Singular polynomials.
void crPrint(coeffs c)
Definition number2.cc:25
#define nWrite(n)
Definition numbers.h:29
#define nCopy(n)
Definition numbers.h:15
#define nNormalize(n)
Definition numbers.h:30
#define nInit(i)
Definition numbers.h:24
#define nTest(a)
Definition numbers.h:35
#define omStrDup(s)
#define omCheckAddr(addr)
#define omAlloc(size)
#define omAllocBin(bin)
#define omCheckIf(cond, test)
#define omCheckAddrSize(addr, size)
#define omFree(addr)
#define omFreeBin(addr, bin)
#define omFreeBinAddr(addr)
#define omGetSpecBin(size)
Definition omBin.h:11
#define NULL
Definition omList.c:12
omBin_t * omBin
Definition omStructs.h:12
#define Sy_inset(x, s)
Definition options.h:33
#define TEST_V_ALLWARN
Definition options.h:145
#define Sy_bit(x)
Definition options.h:31
#define TEST_VERB_NSB
Definition options.h:139
#define TEST_V_QRING
Definition options.h:133
static int index(p_Length length, p_Ord ord)
static void p_LmDelete(poly p, const ring r)
Definition p_polys.h:725
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition p_polys.h:848
static long p_Totaldegree(poly p, const ring r)
Definition p_polys.h:1523
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
Compatibility layer for legacy polynomial operations (over currRing)
#define pTest(p)
Definition polys.h:415
#define pDelete(p_ptr)
Definition polys.h:187
#define pSetm(p)
Definition polys.h:272
#define pIsConstant(p)
like above, except that Comp must be 0
Definition polys.h:239
void pWrite0(poly p)
Definition polys.h:310
#define pmInit(a, b)
Definition polys.h:290
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 pSetExp(p, i, v)
Definition polys.h:43
char * pString(poly p)
Definition polys.h:307
#define pCopy(p)
return a copy of the poly
Definition polys.h:186
#define pOne()
Definition polys.h:316
void StringSetS(const char *st)
Definition reporter.cc:128
void StringAppendS(const char *st)
Definition reporter.cc:107
void PrintNSpaces(const int n)
Definition reporter.cc:364
void PrintS(const char *s)
Definition reporter.cc:284
char * StringEndS()
Definition reporter.cc:151
void PrintLn()
Definition reporter.cc:310
void Werror(const char *fmt,...)
Definition reporter.cc:189
EXTERN_VAR int traceit
Definition reporter.h:24
EXTERN_VAR int colmax
Definition reporter.h:17
void rWrite(ring r, BOOLEAN details)
Definition ring.cc:227
int r_IsRingVar(const char *n, char **names, int N)
Definition ring.cc:213
char * rString(ring r)
Definition ring.cc:678
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition ring.h:406
static ring rIncRefCnt(ring r)
Definition ring.h:849
static BOOLEAN rField_is_GF(const ring r)
Definition ring.h:527
idrec * idhdl
Definition ring.h:22
void sBucketPrint(sBucket_pt bucket)
Definition sbuckets.cc:466
char * sBucketString(sBucket_pt bucket)
Definition sbuckets.cc:461
void sBucketDeleteAndDestroy(sBucket_pt *bucket_pt)
Definition sbuckets.cc:110
sBucket_pt sBucketCopy(const sBucket_pt bucket)
Copy sBucket non-intrusive!!!
Definition sbuckets.cc:70
poly sBucketPeek(sBucket_pt b)
Definition sbuckets.cc:455
sBucket * sBucket_pt
Definition sbuckets.h:16
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
matrix id_Module2Matrix(ideal mod, const ring R)
#define IDELEMS(i)
#define R
Definition sirandom.c:27
#define A
Definition sirandom.c:24
ip_package * package
Definition structs.h:39
sleftv * leftv
Definition structs.h:53
procinfo * procinfov
Definition structs.h:56
VAR omBin sSubexpr_bin
Definition subexpr.cc:40
VAR omBin procinfo_bin
Definition subexpr.cc:42
void syMake(leftv v, const char *id, package pa)
Definition subexpr.cc:1613
VAR omBin libstack_bin
Definition subexpr.cc:43
void s_internalDelete(const int t, void *d, const ring r)
Definition subexpr.cc:518
STATIC_VAR omBin size_two_bin
Definition subexpr.cc:44
INST_VAR sleftv sLastPrinted
Definition subexpr.cc:46
static void * s_internalCopy(const int t, void *d)
Definition subexpr.cc:433
VAR BOOLEAN siq
Definition subexpr.cc:48
BOOLEAN assumeStdFlag(leftv h)
Definition subexpr.cc:1587
void syMakeMonom(leftv v, const char *id)
Definition subexpr.cc:1917
procinfov piCopy(procinfov pi)
Definition subexpr.h:149
void s_internalDelete(const int t, void *d, const ring r)
Definition subexpr.cc:518
sleftv * leftv
Definition subexpr.h:79
EXTERN_VAR omBin sSubexpr_bin
Definition subexpr.h:174
@ LANG_SINGULAR
Definition subexpr.h:22
const char * piProcinfo(procinfov pi, const char *request)
Definition ipid.cc:700
procinfo * procinfov
Definition subexpr.h:66
void syMake(leftv v, const char *name, package pa=NULL)
Definition subexpr.cc:1613
syStrategy syCopy(syStrategy syzstr)
Definition syz1.cc:1885
void syKillComputation(syStrategy syzstr, ring r=currRing)
Definition syz1.cc:1495
ssyStrategy * syStrategy
Definition syz.h:36
void syPrint(syStrategy syzstr, const char *currRingName)
Definition syz1.cc:1935
int getRTimer()
Definition timer.cc:150
long getTimer()
Definition timer.cc:80
#define IDHDL
Definition tok.h:31
@ VCOLMAX
Definition tok.h:211
@ ALIAS_CMD
Definition tok.h:34
@ BIGINT_CMD
Definition tok.h:38
@ CRING_CMD
Definition tok.h:56
@ LIST_CMD
Definition tok.h:118
@ VSHORTOUT
Definition tok.h:216
@ VPRINTLEVEL
Definition tok.h:217
@ INTVEC_CMD
Definition tok.h:101
@ PACKAGE_CMD
Definition tok.h:150
@ CMATRIX_CMD
Definition tok.h:46
@ DEF_CMD
Definition tok.h:58
@ VECHO
Definition tok.h:210
@ CNUMBER_CMD
Definition tok.h:47
@ LINK_CMD
Definition tok.h:117
@ TRACE
Definition tok.h:214
@ STRING_CMD
Definition tok.h:187
@ VTIMER
Definition tok.h:212
@ VRTIMER
Definition tok.h:213
@ VOICE
Definition tok.h:215
@ CPOLY_CMD
Definition tok.h:48
@ INT_CMD
Definition tok.h:96
@ MAX_TOK
Definition tok.h:220
#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
int dim(ideal I, ring r)