My Project
Loading...
Searching...
No Matches
ipassign.cc
Go to the documentation of this file.
1/****************************************
2* Computer Algebra System SINGULAR *
3****************************************/
4/*
5* ABSTRACT: interpreter:
6* assignment of expressions and lists to objects or lists
7*/
8
9#include "kernel/mod2.h"
10
11#define TRANSEXT_PRIVATES
13
14#include "misc/options.h"
15#include "misc/intvec.h"
16
17#include "coeffs/coeffs.h"
18#include "coeffs/numbers.h"
19#include "coeffs/bigintmat.h"
20#include "coeffs/longrat.h"
21
22
24
26#include "polys/matpol.h"
28#include "polys/nc/nc.h"
29#include "polys/nc/sca.h"
30#include "polys/prCopy.h"
31
32#include "kernel/polys.h"
33#include "kernel/ideals.h"
37#include "kernel/GBEngine/syz.h"
38
39//#include "weight.h"
40#include "tok.h"
41#include "ipid.h"
42#include "idrec.h"
43#include "subexpr.h"
44#include "lists.h"
45#include "ipconv.h"
46#include "attrib.h"
47#include "links/silink.h"
48#include "ipshell.h"
49#include "blackbox.h"
50#include "Singular/number2.h"
51
52/*=================== proc =================*/
54{
55 si_echo=(int)((long)(a->Data()));
56 return FALSE;
57}
59{
60 printlevel=(int)((long)(a->Data()));
61 return FALSE;
62}
64{
65 colmax=(int)((long)(a->Data()));
66 return FALSE;
67}
69{
70 timerv=(int)((long)(a->Data()));
71 startTimer();
72 return FALSE;
73}
74#ifdef HAVE_GETTIMEOFDAY
76{
77 rtimerv=(int)((long)(a->Data()));
78 initRTimer();
79 return FALSE;
80}
81#endif
83{
84 Kstd1_deg=(int)((long)(a->Data()));
85 if (Kstd1_deg!=0)
87 else
89 return FALSE;
90}
92{
93 Kstd1_mu=(int)((long)(a->Data()));
94 if (Kstd1_mu!=0)
96 else
98 return FALSE;
99}
101{
102 traceit=(int)((long)(a->Data()));
103 return FALSE;
104}
106{
107 if (currRing != NULL)
108 {
109 BOOLEAN shortOut = (BOOLEAN)((long)a->Data());
110 if (shortOut==0)
111 currRing->ShortOut = 0;
112 else
113 {
114 if (currRing->CanShortOut)
115 currRing->ShortOut = 1;
116 }
117 shortOut = currRing->ShortOut;
118 coeffs cf = currRing->cf;
119 while (nCoeff_is_Extension(cf))
120 {
121 cf->extRing->ShortOut = shortOut;
122 assume(cf->extRing != NULL);
123 cf = cf->extRing->cf;
124 }
125 }
126 return FALSE;
127}
129{
130 switch(IDTYP(h))
131 {
132 case NUMBER_CMD:
133 {
134 number n=(number)IDDATA(h);
135 number one = nInit(1);
136 number nn=nMult(n,one);
137 nDelete(&n);nDelete(&one);
138 IDDATA(h)=(char*)nn;
139 break;
140 }
141 case VECTOR_CMD:
142 case POLY_CMD:
143 {
144 poly p=(poly)IDDATA(h);
146 break;
147 }
148 case IDEAL_CMD:
149 case MODUL_CMD:
150 case MAP_CMD:
151 case MATRIX_CMD:
152 {
153 int i;
154 ideal I=(ideal)IDDATA(h);
155 for(i=IDELEMS(I)-1;i>=0;i--)
156 I->m[i]=p_MinPolyNormalize(I->m[i], currRing);
157 break;
158 }
159 case LIST_CMD:
160 {
161 lists L=(lists)IDDATA(h);
162 int i=L->nr;
163 for(;i>=0;i--)
164 {
165 jjMINPOLY_red((idhdl)&(L->m[i]));
166 }
167 break;
168 }
169 default:
170 //case RESOLUTION_CMD:
171 Werror("type %d too complex...set minpoly before",IDTYP(h)); break;
172 }
173}
174// change the coeff cf=K[x] (of type n_transExt) to K[x]/a
175// return NULL in error case
177{
178 if ( !nCoeff_is_transExt(cf) )
179 {
180 if(!nCoeff_is_algExt(cf) )
181 {
182 WerrorS("cannot set minpoly for these coeffients");
183 return NULL;
184 }
185 }
186 if (rVar(cf->extRing)!=1)
187 {
188 WerrorS("only univariate minpoly allowed");
189 return NULL;
190 }
191
192 number p = n_Copy(a,cf);
193 n_Normalize(p, cf);
194
195 if (n_IsZero(p, cf))
196 {
197 n_Delete(&p, cf);
198 return cf;
199 }
200
202
203 A.r = rCopy(cf->extRing); // Copy ground field!
204 // if minpoly was already set:
205 if( cf->extRing->qideal != NULL ) id_Delete(&(A.r->qideal),A.r);
206 ideal q = idInit(1,1);
207 if ((p==NULL) ||(NUM((fraction)p)==NULL))
208 {
209 WerrorS("Could not construct the alg. extension: minpoly==0");
210 // cleanup A: TODO
211 rDelete( A.r );
212 return NULL;
213 }
214 if (DEN((fraction)(p)) != NULL) // minpoly must be a fraction with poly numerator...!!
215 {
216 poly n=DEN((fraction)(p));
217 if(!p_IsConstant(n,cf->extRing))
218 {
219 WarnS("denominator must be constant - ignoring it");
220 }
221 p_Delete(&n,cf->extRing);
222 DEN((fraction)(p))=NULL;
223 }
224
225 q->m[0] = NUM((fraction)p);
226 A.r->qideal = q;
227
229 NUM((fractionObject *)p) = NULL; // not necessary, but still...
231
232 coeffs new_cf = nInitChar(n_algExt, &A);
233 if (new_cf==NULL)
234 {
235 WerrorS("Could not construct the alg. extension: illegal minpoly?");
236 // cleanup A: TODO
237 rDelete( A.r );
238 return NULL;
239 }
240 return new_cf;
241}
242
244{
245 if( !nCoeff_is_transExt(currRing->cf) && (currRing->idroot == NULL) && n_IsZero((number)a->Data(), currRing->cf) )
246 {
247#ifndef SING_NDEBUG
248 WarnS("Set minpoly over non-transcendental ground field to 0?!");
249 Warn("in >>%s<<",my_yylinebuf);
250#endif
251 return FALSE;
252 }
253
254
255 if ( !nCoeff_is_transExt(currRing->cf) )
256 {
257 WarnS("Trying to set minpoly over non-transcendental ground field...");
258 if(!nCoeff_is_algExt(currRing->cf) )
259 {
260 WerrorS("cannot set minpoly for these coeffients");
261 return TRUE;
262 }
263 }
264 if ((rVar(currRing->cf->extRing)!=1)
265 && !n_IsZero((number)a->Data(), currRing->cf) )
266 {
267 WerrorS("only univarite minpoly allowed");
268 return TRUE;
269 }
270
271 BOOLEAN redefine_from_algext=FALSE;
272 if ( currRing->idroot != NULL )
273 {
274 redefine_from_algext=(currRing->cf->extRing->qideal!=NULL);
275#ifndef SING_NDEBUG
276// idhdl p = currRing->idroot;
277//
278// WarnS("no minpoly allowed if there are local objects belonging to the basering: ");
279//
280// while(p != NULL)
281// {
282// PrintS(p->String(TRUE)); Print("(%s)\n",IDID(p));
283// p = p->next;
284// }
285#endif
286 }
287
288// assume (currRing->idroot==NULL);
289
290 number p = (number)a->CopyD(NUMBER_CMD);
291 n_Normalize(p, currRing->cf);
292
293 if (n_IsZero(p, currRing->cf))
294 {
295 n_Delete(&p, currRing->cf);
297 {
298#ifndef SING_NDEBUG
299 WarnS("minpoly is already 0...");
300#endif
301 return FALSE;
302 }
303 WarnS("cannot set minpoly to 0 / alg. extension?");
304 return TRUE;
305 }
306
307 // remove all object currently in the ring
308 while(currRing->idroot!=NULL)
309 {
310#ifndef SING_NDEBUG
311// Warn("killing a local object due to minpoly change: %s", IDID(currRing->idroot));
312#endif
313 killhdl2(currRing->idroot,&(currRing->idroot),currRing);
314 }
315
317
318 A.r = rCopy(currRing->cf->extRing); // Copy ground field!
319 // if minpoly was already set:
320 if( currRing->cf->extRing->qideal != NULL ) id_Delete(&(A.r->qideal),A.r);
321 ideal q = idInit(1,1);
322 if ((p==NULL) ||(NUM((fraction)p)==NULL))
323 {
324 WerrorS("Could not construct the alg. extension: minpoly==0");
325 // cleanup A: TODO
326 rDelete( A.r );
327 return TRUE;
328 }
329 if (!redefine_from_algext && (DEN((fraction)(p)) != NULL)) // minpoly must be a fraction with poly numerator...!!
330 {
331 poly n=DEN((fraction)(p));
332 if(!p_IsConstant(n,currRing->cf->extRing))
333 {
334 WarnS("denominator must be constant - ignoring it");
335 }
336 p_Delete(&n,currRing->cf->extRing);
337 DEN((fraction)(p))=NULL;
338 }
339
340 if (redefine_from_algext) q->m[0]=(poly)p;
341 else q->m[0] = NUM((fraction)p);
342 A.r->qideal = q;
343
344#if 0
345 PrintS("\nTrying to conver the currRing into an algebraic field: ");
346 PrintS("Ground poly. ring: \n");
347 rWrite( A.r );
348 PrintS("\nGiven MinPOLY: ");
349 p_Write( A.i->m[0], A.r );
350#endif
351
352 // :(
353// NUM((fractionObject *)p) = NULL; // makes 0/ NULL fraction - which should not happen!
354// n_Delete(&p, currRing->cf); // doesn't expect 0/ NULL :(
355 if (!redefine_from_algext)
356 {
358 NUM((fractionObject *)p) = NULL; // not necessary, but still...
360 }
361
362 coeffs new_cf = nInitChar(n_algExt, &A);
363 if (new_cf==NULL)
364 {
365 WerrorS("Could not construct the alg. extension: llegal minpoly?");
366 // cleanup A: TODO
367 rDelete( A.r );
368 return TRUE;
369 }
370 else
371 {
372 nKillChar(currRing->cf); currRing->cf=new_cf;
373 }
374 return FALSE;
375}
376
377
379{
380 poly p=(poly)a->CopyD(POLY_CMD);
381 pDelete(&(currRing->ppNoether));
382 (currRing->ppNoether)=p;
383 return FALSE;
384}
385/*=================== proc =================*/
386static void jiAssignAttr(leftv l,leftv r)
387{
388 // get the attribute of th right side
389 // and set it to l
390 leftv rv=r->LData();
391 if (rv!=NULL)
392 {
393 if (rv->e==NULL)
394 {
395 if (rv->attribute!=NULL)
396 {
397 attr la;
398 if (r->rtyp!=IDHDL)
399 {
400 la=rv->attribute;
401 rv->attribute=NULL;
402 }
403 else
404 {
405 la=rv->attribute->Copy();
406 }
407 l->attribute=la;
408 }
409 l->flag=rv->flag;
410 }
411 }
412 if (l->rtyp==IDHDL)
413 {
414 idhdl h=(idhdl)l->data;
415 IDATTR(h)=l->attribute;
416 IDFLAG(h)=l->flag;
417 }
418}
419static BOOLEAN jiA_INT(leftv res, leftv a, Subexpr e)
420{
421 if (e==NULL)
422 {
423 res->data=(void *)a->Data();
424 jiAssignAttr(res,a);
425 }
426 else
427 {
428 int i=e->start-1;
429 if (i<0)
430 {
431 Werror("index[%d] must be positive",i+1);
432 return TRUE;
433 }
434 intvec *iv=(intvec *)res->data;
435 if (e->next==NULL)
436 {
437 if (i>=iv->length())
438 {
439 intvec *iv1=new intvec(i+1);
440 (*iv1)[i]=(int)((long)(a->Data()));
441 intvec *ivn=ivAdd(iv,iv1);
442 delete iv;
443 delete iv1;
444 res->data=(void *)ivn;
445 }
446 else
447 (*iv)[i]=(int)((long)(a->Data()));
448 }
449 else
450 {
451 int c=e->next->start;
452 if ((i>=iv->rows())||(c<1)||(c>iv->cols()))
453 {
454 Werror("wrong range [%d,%d] in intmat %s(%d,%d)",i+1,c,res->Name(),iv->rows(),iv->cols());
455 return TRUE;
456 }
457 else
458 IMATELEM(*iv,i+1,c) = (int)((long)(a->Data()));
459 }
460 }
461 return FALSE;
462}
464{
465 ring old_r=currRing;
466 if (Sy_inset(FLAG_RING,res->flag))
467 {
468 if ((res-1)->data!=currRing)
469 {
470 if ((res-1)->data!=NULL)
471 {
472 old_r=(ring)(res-1)->data;
473 rDecRefCnt(old_r);
474 }
475 (res-1)->data=rIncRefCnt(currRing);
476 (res-1)->rtyp=RING_CMD;
477 }
478 }
480 return old_r;
481}
482static BOOLEAN jiA_NUMBER(leftv res, leftv a, Subexpr)
483{
484 number p=(number)a->CopyD(NUMBER_CMD);
485 if (errorreported) return TRUE;
486 if (res->data!=NULL) nDelete((number *)&res->data);
487 nNormalize(p);
488 res->data=(void *)p;
489 jiAssignAttr(res,a);
490 return FALSE;
491}
492#ifdef SINGULAR_4_2
493static BOOLEAN jiA_NUMBER2(leftv res, leftv a, Subexpr e)
494{
495 number2 n=(number2)a->CopyD(CNUMBER_CMD);
496 if (e==NULL)
497 {
498 if (res->data!=NULL)
499 {
500 number2 nn=(number2)res->data;
501 n2Delete(nn);
502 }
503 res->data=(void *)n;
504 jiAssignAttr(res,a);
505 }
506 else
507 {
508 int i=e->start-1;
509 if (i<0)
510 {
511 Werror("index[%d] must be positive",i+1);
512 return TRUE;
513 }
514 bigintmat *iv=(bigintmat *)res->data;
515 if (e->next==NULL)
516 {
517 WerrorS("only one index given");
518 return TRUE;
519 }
520 else
521 {
522 int c=e->next->start;
523 if ((i>=iv->rows())||(c<1)||(c>iv->cols()))
524 {
525 Werror("wrong range [%d,%d] in cmatrix %s(%d,%d)",i+1,c,res->Name(),iv->rows(),iv->cols());
526 return TRUE;
527 }
528 else if (iv->basecoeffs()==n->cf)
529 {
530 n_Delete((number *)&BIMATELEM(*iv,i+1,c),iv->basecoeffs());
531 BIMATELEM(*iv,i+1,c) = n->n;
532 }
533 else
534 {
535 WerrorS("different base");
536 return TRUE;
537 }
538 }
539 }
540 jiAssignAttr(res,a);
541 return FALSE;
542}
543static BOOLEAN jiA_NUMBER2_I(leftv res, leftv a, Subexpr e)
544{
545 if (e==NULL)
546 {
547 if (res->data!=NULL)
548 {
549 number2 nn=(number2)res->data;
550 number2 n=n2Init((long)a->Data(),nn->cf);
551 n2Delete(nn);
552 res->data=(void *)n;
553 }
554 else
555 {
556 WerrorS("no Ring avialable for conversion from int");
557 return TRUE;
558 }
559 }
560 else
561 {
562 int i=e->start-1;
563 if (i<0)
564 {
565 Werror("index[%d] must be positive",i+1);
566 return TRUE;
567 }
568 bigintmat *iv=(bigintmat *)res->data;
569 if (e->next==NULL)
570 {
571 WerrorS("only one index given");
572 return TRUE;
573 }
574 else
575 {
576 int c=e->next->start;
577 if ((i>=iv->rows())||(c<1)||(c>iv->cols()))
578 {
579 Werror("wrong range [%d,%d] in cmatrix %s(%d,%d)",i+1,c,res->Name(),iv->rows(),iv->cols());
580 return TRUE;
581 }
582 else
583 {
584 n_Delete((number *)&BIMATELEM(*iv,i+1,c),iv->basecoeffs());
585 BIMATELEM(*iv,i+1,c) = n_Init((long)a->Data(),iv->basecoeffs());
586 }
587 }
588 }
589 return FALSE;
590}
591static BOOLEAN jiA_NUMBER2_N(leftv res, leftv a, Subexpr e)
592{
593 if (e==NULL)
594 {
595 if (res->data!=NULL)
596 {
597 number2 nn=(number2)res->data;
598 number2 n=(number2)omAlloc(sizeof(*n));
599 n->cf=currRing->cf; n->cf->ref++;
600 n->n=(number)a->CopyD(NUMBER_CMD);
601 n2Delete(nn);
602 res->data=(void *)n;
603 }
604 else
605 {
606 number2 n=(number2)omAlloc(sizeof(*n));
607 n->cf=currRing->cf; n->cf->ref++;
608 n->n=(number)a->CopyD(NUMBER_CMD);
609 res->data=(void *)n;
610 }
611 }
612 else return TRUE; // TODO: list elements
613 return FALSE;
614}
615static BOOLEAN jiA_POLY2(leftv res, leftv a, Subexpr e)
616{
617 poly2 n=(poly2)a->CopyD(CPOLY_CMD);
618 if (e==NULL)
619 {
620 if (res->data!=NULL)
621 {
622 poly2 nn=(poly2)res->data;
623 p2Delete(nn);
624 }
625 res->data=(void *)n;
626 jiAssignAttr(res,a);
627 }
628 else
629 {
630 int i=e->start-1;
631 if (i<0)
632 {
633 Werror("index[%d] must be positive",i+1);
634 return TRUE;
635 }
636 WerrorS("not yet"); // TODO: list elem
637 return TRUE;
638 }
639 jiAssignAttr(res,a);
640 return FALSE;
641}
642static BOOLEAN jiA_POLY2_P(leftv res, leftv a, Subexpr e)
643{
644 if (e==NULL)
645 {
646 if (res->data!=NULL)
647 {
648 poly2 nn=(poly2)res->data;
649 poly2 n=(poly2)omAlloc(sizeof(*n));
650 n->cf=currRing; n->cf->ref++;
651 n->n=(poly)a->CopyD(POLY_CMD);
652 p2Delete(nn);
653 res->data=(void *)n;
654 }
655 else
656 {
657 poly2 n=(poly2)omAlloc(sizeof(*n));
658 n->cf=currRing; n->cf->ref++;
659 n->n=(poly)a->CopyD(POLY_CMD);
660 res->data=(void *)n;
661 }
662 }
663 else return TRUE; // TODO: list elements
664 return FALSE;
665}
666#endif
667static BOOLEAN jiA_BIGINT(leftv res, leftv a, Subexpr e)
668{
669 number p=(number)a->CopyD(BIGINT_CMD);
670 if (e==NULL)
671 {
672 if (res->data!=NULL) n_Delete((number *)&res->data,coeffs_BIGINT);
673 res->data=(void *)p;
674 }
675 else
676 {
677 int i=e->start-1;
678 if (i<0)
679 {
680 Werror("index[%d] must be positive",i+1);
681 return TRUE;
682 }
683 bigintmat *iv=(bigintmat *)res->data;
684 if ((e->next==NULL)&&(res->rtyp==BIGINTMAT_CMD))
685 {
686 WerrorS("only one index given");
687 return TRUE;
688 }
689 else
690 {
691 int c;
692 if (res->rtyp==BIGINTMAT_CMD) c=e->next->start;
693 else { c=i+1; i=0;}
694 if ((i>=iv->rows())||(c<1)||(c>iv->cols()))
695 {
696 Werror("wrong range [%d,%d] in bigintmat/bigintvec %s(%d,%d)",i+1,c,res->Name(),iv->rows(),iv->cols());
697 return TRUE;
698 }
699 else
700 {
701 n_Delete((number *)&BIMATELEM(*iv,i+1,c),iv->basecoeffs());
702 BIMATELEM(*iv,i+1,c) = p;
703 }
704 }
705 }
706 jiAssignAttr(res,a);
707 return FALSE;
708}
709static BOOLEAN jiA_BIGINT_N(leftv res, leftv a, Subexpr e)
710{
711 number p=(number)a->Data();
712 number pp=NULL;
713 if (currRing->cf->rep==n_rep_gap_rat)
714 {
715 if (SR_HDL(a) & SR_INT) pp=p;
716 else if (p->s==3) pp=nCopy(p);
717 else
718 {
719 WerrorS("cannot assign to bigint");
720 return TRUE;
721 }
722 }
723 else if (currRing->cf->rep==n_rep_gmp)
724 pp=coeffs_BIGINT->cfInitMPZ((mpz_ptr)p,coeffs_BIGINT);
725 else if (currRing->cf->rep==n_rep_int)
726 pp=coeffs_BIGINT->cfInit((long)p,coeffs_BIGINT);
727 else
728 {
729 WerrorS("cannot assign to bigint");
730 return TRUE;
731 }
732 if (e==NULL)
733 {
734 if (res->data!=NULL) n_Delete((number *)&res->data,coeffs_BIGINT);
735 res->data=(void*)pp;
736 }
737 else
738 {
739 int i=e->start-1;
740 if (i<0)
741 {
742 Werror("index[%d] must be positive",i+1);
743 return TRUE;
744 }
745 bigintmat *iv=(bigintmat *)res->data;
746 if ((e->next==NULL)&&(res->rtyp==BIGINTMAT_CMD))
747 {
748 WerrorS("only one index given");
749 return TRUE;
750 }
751 else
752 {
753 int c;
754 if (res->rtyp==BIGINTMAT_CMD) c=e->next->start;
755 else { c=i+1; i=0;}
756 if ((i>=iv->rows())||(c<1)||(c>iv->cols()))
757 {
758 Werror("wrong range [%d,%d] in bigintmat/bigintvec %s(%d,%d)",i+1,c,res->Name(),iv->rows(),iv->cols());
759 return TRUE;
760 }
761 else
762 {
763 n_Delete((number *)&BIMATELEM(*iv,i+1,c),iv->basecoeffs());
764 BIMATELEM(*iv,i+1,c) = pp;
765 }
766 }
767 }
768 jiAssignAttr(res,a);
769 return FALSE;
770}
772{
774 if (errorreported) return TRUE;
775 if (res->data!=NULL) ((lists)res->data)->Clean();
776 int add_row_shift = 0;
777 intvec *weights=(intvec*)atGet(a,"isHomog",INTVEC_CMD);
778 if (weights!=NULL) add_row_shift=weights->min_in();
779 res->data=(void *)syConvRes(r,TRUE,add_row_shift);
780 //jiAssignAttr(res,a);
781 return FALSE;
782}
783static BOOLEAN jiA_LIST(leftv res, leftv a,Subexpr)
784{
786 if (errorreported) return TRUE;
787 if (res->data!=NULL) ((lists)res->data)->Clean();
788 res->data=(void *)l;
789 jiAssignAttr(res,a);
790 return FALSE;
791}
792static BOOLEAN jiA_POLY(leftv res, leftv a,Subexpr e)
793{
794 poly p=(poly)a->CopyD(POLY_CMD);
795 if (errorreported) return TRUE;
796 pNormalize(p);
797 if (e==NULL)
798 {
799 if ((p!=NULL) && TEST_V_QRING && (currRing->qideal!=NULL)
800 && (!hasFlag(a,FLAG_QRING)))
801 {
804 }
805 if (res->data!=NULL) pDelete((poly*)&res->data);
806 res->data=(void*)p;
807 jiAssignAttr(res,a);
808 }
809 else
810 {
811 int i,j;
812 matrix m=(matrix)res->data;
813 i=e->start;
814 if (e->next==NULL)
815 {
816 j=i; i=1;
817 // for all ideal like data types: check indices
818 if (j>MATCOLS(m))
819 {
820 if (TEST_V_ALLWARN)
821 {
822 Warn("increase ideal %d -> %d in %s(%d):%s",MATCOLS(m),j,VoiceName(),VoiceLine(),my_yylinebuf);
823 }
824 pEnlargeSet(&(m->m),MATCOLS(m),j-MATCOLS(m));
825 MATCOLS(m)=j;
826 }
827 else if (j<=0)
828 {
829 Werror("index[%d] must be positive",j/*e->start*/);
830 return TRUE;
831 }
832 }
833 else
834 {
835 // for matrices: indices are correct (see ipExprArith3(..,'['..) )
836 j=e->next->start;
837 }
838 if ((p!=NULL) && TEST_V_QRING && (currRing->qideal!=NULL))
839 {
841 }
842 if (res->rtyp==SMATRIX_CMD)
843 {
844 p=pSub(p,SMATELEM(m,i-1,j-1,currRing));
845 pSetCompP(p,i);
846 m->m[j-1]=pAdd(m->m[j-1],p);
847 }
848 else
849 {
850 pDelete(&MATELEM(m,i,j));
851 MATELEM(m,i,j)=p;
852 /* for module: update rank */
853 if ((p!=NULL) && (pGetComp(p)!=0))
854 {
855 m->rank=si_max(m->rank,pMaxComp(p));
856 }
857 }
858 }
859 return FALSE;
860}
861static BOOLEAN jiA_1x1INTMAT(leftv res, leftv a,Subexpr e)
862{
863 if (/*(*/ res->rtyp!=INTMAT_CMD /*)*/) /*|| (e!=NULL) - TRUE because of type int */
864 {
865 // no error message: assignment simply fails
866 return TRUE;
867 }
868 intvec* am=(intvec*)a->CopyD(INTMAT_CMD);
869 if ((am->rows()!=1) || (am->cols()!=1))
870 {
871 WerrorS("must be 1x1 intmat");
872 delete am;
873 return TRUE;
874 }
875 intvec* m=(intvec *)res->data;
876 // indices are correct (see ipExprArith3(..,'['..) )
877 int i=e->start;
878 int j=e->next->start;
879 IMATELEM(*m,i,j)=IMATELEM(*am,1,1);
880 delete am;
881 return FALSE;
882}
883static BOOLEAN jiA_1x1MATRIX(leftv res, leftv a,Subexpr e)
884{
885 if (/*(*/ res->rtyp!=MATRIX_CMD /*)*/) /*|| (e!=NULL) - TRUE because of type poly */
886 {
887 // no error message: assignment simply fails
888 return TRUE;
889 }
891 if (errorreported) return TRUE;
892 if ((MATROWS(am)!=1) || (MATCOLS(am)!=1))
893 {
894 WerrorS("must be 1x1 matrix");
895 idDelete((ideal *)&am);
896 return TRUE;
897 }
898 matrix m=(matrix)res->data;
899 // indices are correct (see ipExprArith3(..,'['..) )
900 int i=e->start;
901 int j=e->next->start;
902 pDelete(&MATELEM(m,i,j));
903 pNormalize(MATELEM(am,1,1));
904 MATELEM(m,i,j)=MATELEM(am,1,1);
905 MATELEM(am,1,1)=NULL;
906 idDelete((ideal *)&am);
907 return FALSE;
908}
909static BOOLEAN jiA_STRING(leftv res, leftv a, Subexpr e)
910{
911 if (e==NULL)
912 {
913 void* tmp = res->data;
914 res->data=(void *)a->CopyD(STRING_CMD);
915 jiAssignAttr(res,a);
916 omfree(tmp);
917 }
918 else
919 {
920 char *s=(char *)res->data;
921 if ((e->start>0)&&(e->start<=(int)strlen(s)))
922 s[e->start-1]=(char)(*((char *)a->Data()));
923 else
924 {
925 Werror("string index %d out of range 1..%d",e->start,(int)strlen(s));
926 return TRUE;
927 }
928 }
929 return FALSE;
930}
931static BOOLEAN jiA_PROC(leftv res, leftv a, Subexpr)
932{
933 extern procinfo *iiInitSingularProcinfo(procinfo *pi, const char *libname,
934 const char *procname, int line,
935 long pos, BOOLEAN pstatic=FALSE);
936 if(res->data!=NULL) piKill((procinfo *)res->data);
937 if(a->Typ()==STRING_CMD)
938 {
939 res->data = (void *)omAlloc0Bin(procinfo_bin);
940 ((procinfo *)(res->data))->language=LANG_NONE;
941 iiInitSingularProcinfo((procinfo *)res->data,"",res->name,0,0);
942 ((procinfo *)res->data)->data.s.body=(char *)a->CopyD(STRING_CMD);
943 }
944 else
945 res->data=(void *)a->CopyD(PROC_CMD);
946 jiAssignAttr(res,a);
947 return FALSE;
948}
949static BOOLEAN jiA_INTVEC(leftv res, leftv a, Subexpr)
950{
951 //if ((res->data==NULL) || (res->Typ()==a->Typ()))
952 {
953 if (res->data!=NULL) delete ((intvec *)res->data);
954 res->data=(void *)a->CopyD(INTVEC_CMD);
955 jiAssignAttr(res,a);
956 return FALSE;
957 }
958#if 0
959 else
960 {
961 intvec *r=(intvec *)(res->data);
962 intvec *s=(intvec *)(a->Data());
963 int i=si_min(r->length(), s->length())-1;
964 for(;i>=0;i--)
965 {
966 (*r)[i]=(*s)[i];
967 }
968 return FALSE; //(r->length()< s->length());
969 }
970#endif
971}
973{
974 //Warn("bigintvec -> intvec in >>%s<<",my_yylinebuf);
975 if (res->data!=NULL) delete ((intvec *)res->data);
976 bigintmat *b=(bigintmat*)a->Data();
977 intvec *iv=new intvec(1,b->cols());
978 for(int i=0;i<b->cols();i++)
979 {
980 (*iv)[i]=n_Int(BIMATELEM(*b,1,i+1),coeffs_BIGINT);
981 }
982 res->data=(void *)iv;
983 jiAssignAttr(res,a);
984 return FALSE;
985}
987{
988 if (res->data!=NULL) delete ((bigintmat *)res->data);
989 res->data=(void *)a->CopyD();
990 jiAssignAttr(res,a);
991 return FALSE;
992}
994{
995 if (res->data!=NULL) delete ((bigintmat *)res->data);
996 intvec *aa=(intvec*)a->Data();
997 int l=aa->rows();
999 for(int i=0;i<l;i++)
1000 {
1001 number tp = n_Init((*aa)[i], coeffs_BIGINT);
1002 n_Delete(&BIMATELEM((*bim),1,i+1), coeffs_BIGINT);
1003 BIMATELEM((*bim),1,i+1)=tp;
1004 }
1005 res->data=(void*)bim;
1006 jiAssignAttr(res,a);
1007 return FALSE;
1008}
1009static BOOLEAN jiA_BUCKET(leftv res, leftv a, Subexpr e)
1010// there should be no assign bucket:=bucket, here we have poly:=bucket
1011{
1013 if (errorreported) return TRUE;
1014 poly p; int l;
1016 sleftv tmp;
1017 tmp.Init();
1018 tmp.rtyp=POLY_CMD;
1019 tmp.data=p;
1020 return jiA_POLY(res,&tmp,e);
1021}
1022static BOOLEAN jiA_IDEAL(leftv res, leftv a, Subexpr)
1023{
1024 ideal I=(ideal)a->CopyD(MATRIX_CMD);
1025 if (errorreported) return TRUE;
1026 if (res->data!=NULL) idDelete((ideal*)&res->data);
1027 res->data=(void*)I;
1028 if (a->rtyp==IDHDL) id_Normalize((ideal)a->Data(), currRing);
1029 else id_Normalize(I/*(ideal)res->data*/, currRing);
1030 jiAssignAttr(res,a);
1031 if (((res->rtyp==IDEAL_CMD)||(res->rtyp==MODUL_CMD))
1032 && (IDELEMS(I/*(ideal)(res->data)*/)==1)
1033 && (currRing->qideal==NULL)
1034 && (!rIsPluralRing(currRing))
1035 )
1036 {
1038 }
1039 if (TEST_V_QRING && (currRing->qideal!=NULL))
1040 {
1042 else jjNormalizeQRingId(res);
1043 }
1044 return FALSE;
1045}
1047{
1049 if (errorreported) return TRUE;
1050 if (res->data!=NULL) syKillComputation((syStrategy)res->data);
1051 res->data=(void*)R;
1052 jiAssignAttr(res,a);
1053 return FALSE;
1054}
1055static BOOLEAN jiA_MODUL_P(leftv res, leftv a, Subexpr)
1056/* module = poly */
1057{
1058 ideal I=idInit(1,1);
1059 I->m[0]=(poly)a->CopyD(POLY_CMD);
1060 if (errorreported) return TRUE;
1061 if (I->m[0]!=NULL) pSetCompP(I->m[0],1);
1062 pNormalize(I->m[0]);
1063 if (res->data!=NULL) idDelete((ideal*)&res->data);
1064 res->data=(void *)I;
1065 if (TEST_V_QRING && (currRing->qideal!=NULL))
1066 {
1068 else jjNormalizeQRingId(res);
1069 }
1070 return FALSE;
1071}
1072static BOOLEAN jiA_IDEAL_M(leftv res, leftv a, Subexpr)
1073{
1075 if (errorreported) return TRUE;
1076 if (TEST_V_ALLWARN)
1077 if (MATROWS(m)>1)
1078 Warn("assign matrix with %d rows to an ideal in >>%s<<",MATROWS(m),my_yylinebuf);
1079 IDELEMS((ideal)m)=MATROWS(m)*MATCOLS(m);
1080 ((ideal)m)->rank=1;
1081 MATROWS(m)=1;
1082 id_Normalize((ideal)m, currRing);
1083 if (res->data!=NULL) idDelete((ideal*)&res->data);
1084 res->data=(void *)m;
1085 if (TEST_V_QRING && (currRing->qideal!=NULL))
1086 {
1088 else jjNormalizeQRingId(res);
1089 }
1090 return FALSE;
1091}
1093{
1094 ideal m=(ideal)a->CopyD(MODUL_CMD);
1095 if (errorreported) return TRUE;
1096 if (m->rank>1)
1097 {
1098 Werror("rank of module is %ld in assignment to ideal",m->rank);
1099 return TRUE;
1100 }
1101 if (res->data!=NULL) idDelete((ideal*)&res->data);
1103 id_Shift(m,-1,currRing);
1104 m->rank=1;
1105 res->data=(void *)m;
1106 if (TEST_V_QRING && (currRing->qideal!=NULL))
1107 {
1109 else jjNormalizeQRingId(res);
1110 }
1111 return FALSE;
1112}
1113static BOOLEAN jiA_LINK(leftv res, leftv a, Subexpr)
1114{
1115 si_link l=(si_link)res->data;
1116
1117 if (l!=NULL) slCleanUp(l);
1118
1119 if (a->Typ() == STRING_CMD)
1120 {
1121 if (l == NULL)
1122 {
1124 res->data = (void *) l;
1125 }
1126 return slInit(l, (char *) a->Data());
1127 }
1128 else if (a->Typ() == LINK_CMD)
1129 {
1130 if (l != NULL) omFreeBin(l, sip_link_bin);
1131 res->data = slCopy((si_link)a->Data());
1132 return FALSE;
1133 }
1134 return TRUE;
1135}
1136// assign map -> map
1137static BOOLEAN jiA_MAP(leftv res, leftv a, Subexpr)
1138{
1139 if (res->data!=NULL)
1140 {
1141 omFreeBinAddr((ADDRESS)((map)res->data)->preimage);
1142 ((map)res->data)->preimage=NULL;
1143 idDelete((ideal*)&res->data);
1144 }
1145 res->data=(void *)a->CopyD(MAP_CMD);
1146 if (errorreported) return TRUE;
1147 jiAssignAttr(res,a);
1148 return FALSE;
1149}
1150// assign ideal -> map
1151static BOOLEAN jiA_MAP_ID(leftv res, leftv a, Subexpr)
1152{
1153 map f=(map)res->data;
1154 char *rn=f->preimage; // save the old/already assigned preimage ring name
1155 f->preimage=NULL;
1156 idDelete((ideal *)&f);
1157 res->data=(void *)a->CopyD(IDEAL_CMD);
1158 if (errorreported) return TRUE;
1159 f=(map)res->data;
1160 id_Normalize((ideal)f, currRing);
1161 f->preimage = rn;
1162 return FALSE;
1163}
1164static BOOLEAN jiA_QRING(leftv res, leftv a,Subexpr e)
1165{
1166 // the follwing can only happen, if:
1167 // - the left side is of type qring AND not an id
1168 if ((e!=NULL)||(res->rtyp!=IDHDL))
1169 {
1170 WerrorS("qring_id expected");
1171 return TRUE;
1172 }
1173
1174 ring old_ring=(ring)res->Data();
1175
1176 coeffs newcf = currRing->cf;
1177 ideal id = (ideal)a->Data(); //?
1178 if (errorreported) return TRUE;
1179 const int cpos = idPosConstant(id);
1181 if (cpos >= 0)
1182 {
1183 newcf = n_CoeffRingQuot1(p_GetCoeff(id->m[cpos], currRing), currRing->cf);
1184 if(newcf == NULL)
1185 return TRUE;
1186 }
1187 //qr=(ring)res->Data();
1188 //if (qr!=NULL) omFreeBin((ADDRESS)qr, ip_sring_bin);
1189 ring qr = rCopy(currRing);
1190 assume(qr->cf == currRing->cf);
1191
1192 if ( qr->cf != newcf )
1193 {
1194 nKillChar ( qr->cf ); // ???
1195 qr->cf = newcf;
1196 }
1197 // we have to fill it, but the copy also allocates space
1198 idhdl h=(idhdl)res->data; // we have res->rtyp==IDHDL
1199 IDRING(h)=qr;
1200
1201 ideal qid;
1202
1203 if((rField_is_Ring(currRing)) && (cpos != -1))
1204 {
1205 int i, j;
1206 int *perm = (int *)omAlloc0((qr->N+1)*sizeof(int));
1207
1208 for(i=qr->N;i>0;i--)
1209 perm[i]=i;
1210
1211 nMapFunc nMap = n_SetMap(currRing->cf, newcf);
1212 qid = idInit(IDELEMS(id)-1,1);
1213 for(i = 0, j = 0; i<IDELEMS(id); i++)
1214 if( i != cpos )
1215 qid->m[j++] = p_PermPoly(id->m[i], perm, currRing, qr, nMap, NULL, 0);
1216 }
1217 else
1218 qid = idrCopyR(id,currRing,qr);
1219
1220 idSkipZeroes(qid);
1221 //idPrint(qid);
1222 if ((idElem(qid)>1) || rIsSCA(currRing) || (currRing->qideal!=NULL))
1223 assumeStdFlag(a);
1224
1225 if (currRing->qideal!=NULL) /* we are already in a qring! */
1226 {
1227 ideal tmp=idSimpleAdd(qid,currRing->qideal);
1228 // both ideals should be GB, so dSimpleAdd is sufficient
1229 idDelete(&qid);
1230 qid=tmp;
1231 // delete the qr copy of quotient ideal!!!
1232 idDelete(&qr->qideal);
1233 }
1234 if (idElem(qid)==0)
1235 {
1236 qr->qideal = NULL;
1237 id_Delete(&qid,currRing);
1238 IDTYP(h)=RING_CMD;
1239 }
1240 else
1241 qr->qideal = qid;
1242
1243 // qr is a copy of currRing with the new qideal!
1244 #ifdef HAVE_PLURAL
1245 if(rIsPluralRing(currRing) &&(qr->qideal!=NULL))
1246 {
1247 if (!hasFlag(a,FLAG_TWOSTD))
1248 {
1249 Warn("%s is no twosided standard basis",a->Name());
1250 }
1251
1253 {
1254// WarnS("error in nc_SetupQuotient");
1255 }
1256 }
1257 #endif
1258 //rWrite(qr);
1259 rSetHdl((idhdl)res->data);
1260 if (old_ring!=NULL)
1261 {
1262 rDelete(old_ring);
1263 }
1264 return FALSE;
1265}
1266
1267static BOOLEAN jiA_RING(leftv res, leftv a, Subexpr e)
1268{
1269 BOOLEAN have_id=TRUE;
1270 if ((e!=NULL)||(res->rtyp!=IDHDL))
1271 {
1272 //WerrorS("id expected");
1273 //return TRUE;
1274 have_id=FALSE;
1275 }
1276 ring r=(ring)a->Data();
1277 if ((r==NULL)||(r->cf==NULL)) return TRUE;
1278 if (have_id)
1279 {
1280 idhdl rl=(idhdl)res->data;
1281 if (IDRING(rl)!=NULL) rKill(rl);
1282 IDRING(rl)=r;
1283 if ((IDLEV((idhdl)a->data)!=myynest) && (r==currRing))
1284 currRingHdl=(idhdl)res->data;
1285 }
1286 else
1287 {
1288 if (e==NULL) res->data=(char *)r;
1289 else
1290 {
1291 WerrorS("id expected");
1292 return TRUE;
1293 }
1294 }
1295 rIncRefCnt(r);
1296 jiAssignAttr(res,a);
1297 return FALSE;
1298}
1299static BOOLEAN jiA_PACKAGE(leftv res, leftv a, Subexpr)
1300{
1301 res->data=(void *)a->CopyD(PACKAGE_CMD);
1302 jiAssignAttr(res,a);
1303 return FALSE;
1304}
1305static BOOLEAN jiA_DEF(leftv res, leftv, Subexpr)
1306{
1307 res->data=(void *)0;
1308 return FALSE;
1309}
1310static BOOLEAN jiA_CRING(leftv res, leftv a, Subexpr)
1311{
1312 coeffs r=(coeffs)a->Data();
1313 if (errorreported) return TRUE;
1314 if (r==NULL) return TRUE;
1315 if (res->data!=NULL) nKillChar((coeffs)res->data);
1316 res->data=(void *)a->CopyD(CRING_CMD);
1317 jiAssignAttr(res,a);
1318 return FALSE;
1319}
1320
1321/*=================== table =================*/
1322#define IPASSIGN
1323#define D(A) A
1324#define NULL_VAL NULL
1325#include "table.h"
1326/*=================== operations ============================*/
1327/*2
1328* assign a = b
1329*/
1330static BOOLEAN jiAssign_1(leftv l, leftv r, int rt, BOOLEAN toplevel, BOOLEAN is_qring=FALSE)
1331{
1332 if (rt==0)
1333 {
1334 if (!errorreported) Werror("`%s` is undefined",r->Fullname());
1335 return TRUE;
1336 }
1337
1338 int lt=l->Typ();
1339 if (lt==0)
1340 {
1341 if (!errorreported) Werror("left side `%s` is undefined",l->Fullname());
1342 return TRUE;
1343 }
1344 if(rt==NONE)
1345 {
1346 if ((!TEST_V_ASSIGN_NONE)||(lt!=DEF_CMD))
1347 {
1348 WarnS("right side is not a datum, assignment ignored");
1349 Warn("in line >>%s<<",my_yylinebuf);
1350 // if (!errorreported)
1351 // WerrorS("right side is not a datum");
1352 //return TRUE;
1353 }
1354 return FALSE;
1355 }
1356
1357 if (lt==DEF_CMD)
1358 {
1359
1360 if (TEST_V_ALLWARN
1361 && (rt!=RING_CMD)
1362 && (l->name!=NULL)
1363 && (l->e==NULL)
1364 && (iiCurrArgs==NULL) /* not in proc header */
1365 )
1366 {
1367 Warn("use `%s` instead of `def` in %s:%d:%s",Tok2Cmdname(rt),
1369 }
1370 if (l->rtyp==IDHDL)
1371 {
1372 if((currRingHdl==NULL) && RingDependend(rt))
1373 {
1374 WerrorS("basering required");
1375 return TRUE;
1376 }
1377 if (rt==BUCKET_CMD) IDTYP((idhdl)l->data)=POLY_CMD;
1378 else IDTYP((idhdl)l->data)=rt;
1379 }
1380 else if (l->name!=NULL)
1381 {
1382 int rrt;
1383 if (rt==BUCKET_CMD) rrt=POLY_CMD;
1384 else rrt=rt;
1385 sleftv ll;
1386 iiDeclCommand(&ll,l,myynest,rrt,&IDROOT);
1387 memcpy(l,&ll,sizeof(sleftv));
1388 }
1389 else
1390 {
1391 if (rt==BUCKET_CMD) l->rtyp=POLY_CMD;
1392 else l->rtyp=rt;
1393 }
1394 lt=l->Typ();
1395 }
1396 else
1397 {
1398 if ((l->data==r->data)&&(l->e==NULL)&&(r->e==NULL))
1399 return FALSE;
1400 }
1401 leftv ld=l;
1402 if (l->rtyp==IDHDL)
1403 {
1404 if (lt!=RING_CMD)
1405 ld=(leftv)l->data;
1406 }
1407 else if (toplevel)
1408 {
1409 WerrorS("error in assign: left side is not an l-value");
1410 return TRUE;
1411 }
1412 if (lt>MAX_TOK)
1413 {
1414 blackbox *bb=getBlackboxStuff(lt);
1415#ifdef BLACKBOX_DEVEL
1416 Print("bb-assign: bb=%lx\n",bb);
1417#endif
1418 return (bb==NULL) || bb->blackbox_Assign(l,r);
1419 }
1420 if ((is_qring)
1421 &&(lt==RING_CMD)
1422 &&(rt==RING_CMD))
1423 {
1424 Warn("qring .. = <ring>; is misleading in >>%s<<",my_yylinebuf);
1425 }
1426 int start=0;
1427 while ((dAssign[start].res!=lt)
1428 && (dAssign[start].res!=0)) start++;
1429 int i=start;
1430 while ((dAssign[i].res==lt)
1431 && (dAssign[i].arg!=rt)) i++;
1432 if (dAssign[i].res==lt)
1433 {
1434 if (traceit&TRACE_ASSIGN) Print("assign %s=%s\n",Tok2Cmdname(lt),Tok2Cmdname(rt));
1435 BOOLEAN b;
1436 b=dAssign[i].p(ld,r,l->e);
1437 if(l!=ld) /* i.e. l is IDHDL, l->data is ld */
1438 {
1439 l->flag=ld->flag;
1440 l->attribute=ld->attribute;
1441 }
1442 return b;
1443 }
1444 // implicite type conversion ----------------------------------------------
1445 if (dAssign[i].res!=lt)
1446 {
1447 int ri;
1449 BOOLEAN failed=FALSE;
1450 i=start;
1451 //while ((dAssign[i].res!=lt)
1452 // && (dAssign[i].res!=0)) i++;
1453 while (dAssign[i].res==lt)
1454 {
1455 if ((ri=iiTestConvert(rt,dAssign[i].arg))!=0)
1456 {
1457 failed= iiConvert(rt,dAssign[i].arg,ri,r,rn);
1458 if(!failed)
1459 {
1460 failed= dAssign[i].p(ld,rn,l->e);
1462 Print("assign %s=%s ok? %d\n",Tok2Cmdname(lt),Tok2Cmdname(rn->rtyp),!failed);
1463 }
1464 // everything done, clean up temp. variables
1465 rn->CleanUp();
1467 if (failed)
1468 {
1469 // leave loop, goto error handling
1470 break;
1471 }
1472 else
1473 {
1474 if(l!=ld) /* i.e. l is IDHDL, l->data is ld */
1475 {
1476 l->flag=ld->flag;
1477 l->attribute=ld->attribute;
1478 }
1479 // everything ok, return
1480 return FALSE;
1481 }
1482 }
1483 i++;
1484 }
1485 // error handling ---------------------------------------------------
1486 if (!errorreported)
1487 {
1488 if ((l->rtyp==IDHDL) && (l->e==NULL))
1489 Werror("`%s`(%s) = `%s` is not supported",
1490 Tok2Cmdname(lt),l->Name(),Tok2Cmdname(rt));
1491 else
1492 Werror("`%s` = `%s` is not supported"
1493 ,Tok2Cmdname(lt),Tok2Cmdname(rt));
1494 if (BVERBOSE(V_SHOW_USE))
1495 {
1496 i=0;
1497 while ((dAssign[i].res!=lt)
1498 && (dAssign[i].res!=0)) i++;
1499 while (dAssign[i].res==lt)
1500 {
1501 Werror("expected `%s` = `%s`"
1502 ,Tok2Cmdname(lt),Tok2Cmdname(dAssign[i].arg));
1503 i++;
1504 }
1505 }
1506 }
1507 }
1508 return TRUE;
1509}
1510/*2
1511* assign sys_var = val
1512*/
1514{
1515 int rt=r->Typ();
1516
1517 if (rt==0)
1518 {
1519 if (!errorreported) Werror("`%s` is undefined",r->Fullname());
1520 return TRUE;
1521 }
1522 int i=0;
1523 int lt=l->rtyp;
1524 while (((dAssign_sys[i].res!=lt)
1525 || (dAssign_sys[i].arg!=rt))
1526 && (dAssign_sys[i].res!=0)) i++;
1527 if (dAssign_sys[i].res!=0)
1528 {
1529 if (!dAssign_sys[i].p(l,r))
1530 {
1531 // everything ok, clean up
1532 return FALSE;
1533 }
1534 }
1535 // implicite type conversion ----------------------------------------------
1536 if (dAssign_sys[i].res==0)
1537 {
1538 int ri;
1540 BOOLEAN failed=FALSE;
1541 i=0;
1542 while ((dAssign_sys[i].res!=lt)
1543 && (dAssign_sys[i].res!=0)) i++;
1544 while (dAssign_sys[i].res==lt)
1545 {
1546 if ((ri=iiTestConvert(rt,dAssign_sys[i].arg))!=0)
1547 {
1548 failed= ((iiConvert(rt,dAssign_sys[i].arg,ri,r,rn))
1549 || (dAssign_sys[i].p(l,rn)));
1550 // everything done, clean up temp. variables
1551 rn->CleanUp();
1553 if (failed)
1554 {
1555 // leave loop, goto error handling
1556 break;
1557 }
1558 else
1559 {
1560 // everything ok, return
1561 return FALSE;
1562 }
1563 }
1564 i++;
1565 }
1566 // error handling ---------------------------------------------------
1567 if(!errorreported)
1568 {
1569 Werror("`%s` = `%s` is not supported"
1570 ,Tok2Cmdname(lt),Tok2Cmdname(rt));
1571 if (BVERBOSE(V_SHOW_USE))
1572 {
1573 i=0;
1574 while ((dAssign_sys[i].res!=lt)
1575 && (dAssign_sys[i].res!=0)) i++;
1576 while (dAssign_sys[i].res==lt)
1577 {
1578 Werror("expected `%s` = `%s`"
1580 i++;
1581 }
1582 }
1583 }
1584 }
1585 return TRUE;
1586}
1588{
1589 /* right side is intvec, left side is list (of int)*/
1590 BOOLEAN nok;
1591 int i=0;
1592 leftv l1=l;
1593 leftv h;
1594 sleftv t;
1595 intvec *iv=(intvec *)r->Data();
1596 memset(&t,0,sizeof(sleftv));
1597 t.rtyp=INT_CMD;
1598 while ((i<iv->length())&&(l!=NULL))
1599 {
1600 t.data=(char *)(long)(*iv)[i];
1601 h=l->next;
1602 l->next=NULL;
1603 nok=jiAssign_1(l,&t,INT_CMD,TRUE);
1604 l->next=h;
1605 if (nok) return TRUE;
1606 i++;
1607 l=h;
1608 }
1609 l1->CleanUp();
1610 r->CleanUp();
1611 return FALSE;
1612}
1614{
1615 /* right side is vector, left side is list (of poly)*/
1616 BOOLEAN nok;
1617 leftv l1=l;
1618 ideal I=idVec2Ideal((poly)r->Data());
1619 leftv h;
1620 sleftv t;
1621 int i=0;
1622 memset(&t,0,sizeof(sleftv));
1623 while (l!=NULL)
1624 {
1625 t.rtyp=POLY_CMD;
1626 if (i>=IDELEMS(I))
1627 {
1628 t.data=NULL;
1629 }
1630 else
1631 {
1632 t.data=(char *)I->m[i];
1633 I->m[i]=NULL;
1634 }
1635 h=l->next;
1636 l->next=NULL;
1637 nok=jiAssign_1(l,&t,POLY_CMD,TRUE);
1638 l->next=h;
1639 t.CleanUp();
1640 if (nok)
1641 {
1642 idDelete(&I);
1643 return TRUE;
1644 }
1645 i++;
1646 l=h;
1647 }
1648 idDelete(&I);
1649 l1->CleanUp();
1650 r->CleanUp();
1651 //if (TEST_V_QRING && (currRing->qideal!=NULL)) l=jjNormalizeQRingP(l);
1652 return FALSE;
1653}
1655/* left side: list/def, has to be a "real" variable
1656* right side: expression list
1657*/
1658{
1659 int sl = r->listLength();
1661 lists oldL;
1662 leftv h=NULL,o_r=r;
1663 int i;
1664 int rt;
1665
1666 L->Init(sl);
1667 for (i=0;i<sl;i++)
1668 {
1669 if (h!=NULL) { /* e.g. not in the first step:
1670 * h is the pointer to the old sleftv,
1671 * r is the pointer to the next sleftv
1672 * (in this moment) */
1673 h->next=r;
1674 }
1675 h=r;
1676 r=r->next;
1677 h->next=NULL;
1678 rt=h->Typ();
1679 if ((rt==0)||(rt==NONE)||(rt==DEF_CMD))
1680 {
1681 L->Clean();
1682 Werror("`%s` is undefined",h->Fullname());
1683 //listall();
1684 goto err;
1685 }
1686 //if (rt==RING_CMD)
1687 //{
1688 // L->m[i].rtyp=rt;
1689 // L->m[i].data=h->Data();
1690 // ((ring)L->m[i].data)->ref++;
1691 //}
1692 //else
1693 L->m[i].CleanUp();
1694 L->m[i].Copy(h);
1695 if(errorreported)
1696 {
1697 L->Clean();
1698 goto err;
1699 }
1700 }
1701 oldL=(lists)l->Data();
1702 if (oldL!=NULL) oldL->Clean();
1703 if (l->rtyp==IDHDL)
1704 {
1705 IDLIST((idhdl)l->data)=L;
1706 IDTYP((idhdl)l->data)=LIST_CMD; // was possibly DEF_CMD
1707 if (lRingDependend(L)) ipMoveId((idhdl)l->data);
1708 }
1709 else
1710 {
1711 l->LData()->data=L;
1712 if ((l->e!=NULL) && (l->rtyp==DEF_CMD))
1713 l->rtyp=LIST_CMD;
1714 }
1715err:
1716 o_r->CleanUp();
1717 return errorreported;
1718}
1720{
1721 /* left side is intvec/intmat, right side is list (of int,intvec,intmat)*/
1722 leftv hh=r;
1723 int i = 0;
1724 while (hh!=NULL)
1725 {
1726 if (i>=iv->length())
1727 {
1729 {
1730 Warn("expression list length(%d) does not match intmat size(%d)",
1731 iv->length()+exprlist_length(hh),iv->length());
1732 }
1733 break;
1734 }
1735 if (hh->Typ() == INT_CMD)
1736 {
1737 (*iv)[i++] = (int)((long)(hh->Data()));
1738 }
1739 else if ((hh->Typ() == INTVEC_CMD)
1740 ||(hh->Typ() == INTMAT_CMD))
1741 {
1742 intvec *ivv = (intvec *)(hh->Data());
1743 int ll = 0,l = si_min(ivv->length(),iv->length());
1744 for (; l>0; l--)
1745 {
1746 (*iv)[i++] = (*ivv)[ll++];
1747 }
1748 }
1749 else
1750 {
1751 delete iv;
1752 return TRUE;
1753 }
1754 hh = hh->next;
1755 }
1756 if (l->rtyp==IDHDL)
1757 {
1758 if (IDINTVEC((idhdl)l->data)!=NULL) delete IDINTVEC((idhdl)l->data);
1759 IDINTVEC((idhdl)l->data)=iv;
1760 }
1761 else
1762 {
1763 if (l->data!=NULL) delete ((intvec*)l->data);
1764 l->data=(char*)iv;
1765 }
1766 return FALSE;
1767}
1769{
1770 /* left side is bigintmat, right side is list (of int,intvec,intmat)*/
1771 leftv hh=r;
1772 int i = 0;
1773 if (bim->length()==0) { WerrorS("bigintmat is 1x0"); delete bim; return TRUE; }
1774 while (hh!=NULL)
1775 {
1776 if (i>=bim->cols()*bim->rows())
1777 {
1779 {
1780 Warn("expression list length(%d) does not match bigintmat size(%d x %d)",
1781 exprlist_length(hh),bim->rows(),bim->cols());
1782 }
1783 break;
1784 }
1785 if (hh->Typ() == INT_CMD)
1786 {
1787 number tp = n_Init((int)((long)(hh->Data())), coeffs_BIGINT);
1788 bim->set(i++, tp);
1789 n_Delete(&tp, coeffs_BIGINT);
1790 }
1791 else if (hh->Typ() == BIGINT_CMD)
1792 {
1793 bim->set(i++, (number)(hh->Data()));
1794 }
1795 /*
1796 ((hh->Typ() == INTVEC_CMD)
1797 ||(hh->Typ() == INTMAT_CMD))
1798 {
1799 intvec *ivv = (intvec *)(hh->Data());
1800 int ll = 0,l = si_min(ivv->length(),iv->length());
1801 for (; l>0; l--)
1802 {
1803 (*iv)[i++] = (*ivv)[ll++];
1804 }
1805 }*/
1806 else
1807 {
1808 delete bim;
1809 return TRUE;
1810 }
1811 hh = hh->next;
1812 }
1813 if (IDBIMAT((idhdl)l->data)!=NULL) delete IDBIMAT((idhdl)l->data);
1814 IDBIMAT((idhdl)l->data)=bim;
1815 return FALSE;
1816}
1818{
1819 /* left side is bigintvec, right side is list (of int,intvec,intmat)*/
1820 leftv hh=r;
1821 int i = 0;
1822 delete bim;
1824 while (hh!=NULL)
1825 {
1826 if (i>=bim->cols())
1827 {
1829 {
1830 Warn("expression list length(%d) does not match bigintvec size(%d)",
1831 exprlist_length(hh),bim->cols());
1832 }
1833 break;
1834 }
1835 if (hh->Typ() == INT_CMD)
1836 {
1837 number tp = n_Init((int)((long)(hh->Data())), coeffs_BIGINT);
1838 bim->set(i++, tp);
1839 n_Delete(&tp, coeffs_BIGINT);
1840 }
1841 else if (hh->Typ() == BIGINT_CMD)
1842 {
1843 bim->set(i++, (number)(hh->Data()));
1844 }
1845 else
1846 {
1847 delete bim;
1848 return TRUE;
1849 }
1850 hh = hh->next;
1851 }
1852 if (IDBIMAT((idhdl)l->data)!=NULL) delete IDBIMAT((idhdl)l->data);
1853 IDBIMAT((idhdl)l->data)=bim;
1854 return bim==NULL;
1855}
1857{
1858 /* left side is string, right side is list of string*/
1859 leftv hh=r;
1860 int sl = 1;
1861 char *s;
1862 char *t;
1863 int tl;
1864 /* find the length */
1865 while (hh!=NULL)
1866 {
1867 if (hh->Typ()!= STRING_CMD)
1868 {
1869 return TRUE;
1870 }
1871 sl += strlen((char *)hh->Data());
1872 hh = hh->next;
1873 }
1874 s = (char * )omAlloc(sl);
1875 sl=0;
1876 hh = r;
1877 while (hh!=NULL)
1878 {
1879 t=(char *)hh->Data();
1880 tl=strlen(t);
1881 memcpy(s+sl,t,tl);
1882 sl+=tl;
1883 hh = hh->next;
1884 }
1885 s[sl]='\0';
1886 omFree((ADDRESS)IDDATA((idhdl)(l->data)));
1887 IDDATA((idhdl)(l->data))=s;
1888 return FALSE;
1889}
1891{
1892 /* right side is matrix, left side is list (of poly)*/
1893 BOOLEAN nok=FALSE;
1894 int i;
1896 leftv h;
1897 leftv ol=l;
1898 leftv o_r=r;
1899 sleftv t;
1900 memset(&t,0,sizeof(sleftv));
1901 t.rtyp=POLY_CMD;
1902 int mxn=MATROWS(m)*MATCOLS(m);
1903 loop
1904 {
1905 i=0;
1906 while ((i<mxn /*MATROWS(m)*MATCOLS(m)*/)&&(l!=NULL))
1907 {
1908 t.data=(char *)m->m[i];
1909 m->m[i]=NULL;
1910 h=l->next;
1911 l->next=NULL;
1912 idhdl hh=NULL;
1913 if ((l->rtyp==IDHDL)&&(l->Typ()==DEF_CMD)) hh=(idhdl)l->data;
1914 nok=jiAssign_1(l,&t,POLY_CMD,TRUE);
1915 if (hh!=NULL) { ipMoveId(hh);hh=NULL;}
1916 l->next=h;
1917 if (nok)
1918 {
1919 idDelete((ideal *)&m);
1920 goto ende;
1921 }
1922 i++;
1923 l=h;
1924 }
1925 idDelete((ideal *)&m);
1926 h=r;
1927 r=r->next;
1928 if (l==NULL)
1929 {
1930 if (r!=NULL)
1931 {
1932 WarnS("list length mismatch in assign (l>r)");
1933 nok=TRUE;
1934 }
1935 break;
1936 }
1937 else if (r==NULL)
1938 {
1939 WarnS("list length mismatch in assign (l<r)");
1940 nok=TRUE;
1941 break;
1942 }
1943 if ((r->Typ()==IDEAL_CMD)||(r->Typ()==MATRIX_CMD))
1944 {
1945 m=(matrix)r->CopyD(MATRIX_CMD);
1946 mxn=MATROWS(m)*MATCOLS(m);
1947 }
1948 else if (r->Typ()==POLY_CMD)
1949 {
1950 m=mpNew(1,1);
1951 MATELEM(m,1,1)=(poly)r->CopyD(POLY_CMD);
1952 pNormalize(MATELEM(m,1,1));
1953 mxn=1;
1954 }
1955 else
1956 {
1957 nok=TRUE;
1958 break;
1959 }
1960 }
1961ende:
1962 o_r->CleanUp();
1963 ol->CleanUp();
1964 return nok;
1965}
1967{
1968 /*left side are strings, right side is a string*/
1969 /*e.g. s[2..3]="12" */
1970 /*the case s=t[1..4] is handled in iiAssign,
1971 * the case s[2..3]=t[3..4] is handled in iiAssgn_rec*/
1972 BOOLEAN nok=FALSE;
1973 sleftv t;
1974 leftv h,l1=l;
1975 int i=0;
1976 char *ss;
1977 char *s=(char *)r->Data();
1978 int sl=strlen(s);
1979
1980 memset(&t,0,sizeof(sleftv));
1981 t.rtyp=STRING_CMD;
1982 while ((i<sl)&&(l!=NULL))
1983 {
1984 ss=(char *)omAlloc(2);
1985 ss[1]='\0';
1986 ss[0]=s[i];
1987 t.data=ss;
1988 h=l->next;
1989 l->next=NULL;
1990 nok=jiAssign_1(l,&t,STRING_CMD,TRUE);
1991 if (nok)
1992 {
1993 break;
1994 }
1995 i++;
1996 l=h;
1997 }
1998 r->CleanUp();
1999 l1->CleanUp();
2000 return nok;
2001}
2003{
2004 int i=l->e->start-1;
2005 if (i<0)
2006 {
2007 Werror("index[%d] must be positive",i+1);
2008 return TRUE;
2009 }
2010 if(l->attribute!=NULL)
2011 {
2012 atKillAll((idhdl)l);
2013 l->attribute=NULL;
2014 }
2015 l->flag=0;
2016 lists li;
2017 if (l->rtyp==IDHDL)
2018 {
2019 li=IDLIST((idhdl)l->data);
2020 }
2021 else
2022 {
2023 li=(lists)l->data;
2024 }
2025 if (i>li->nr)
2026 {
2027 if (TEST_V_ALLWARN)
2028 {
2029 Warn("increase list %d -> %d in %s(%d):%s",li->nr,i,VoiceName(),VoiceLine(),my_yylinebuf);
2030 }
2031 li->m=(leftv)omreallocSize(li->m,(li->nr+1)*sizeof(sleftv),(i+1)*sizeof(sleftv));
2032 memset(&(li->m[li->nr+1]),0,(i-li->nr)*sizeof(sleftv));
2033 int j=li->nr+1;
2034 for(;j<=i;j++)
2035 li->m[j].rtyp=DEF_CMD;
2036 li->nr=i;
2037 }
2038 leftv ld=&(li->m[i]);
2039 ld->e=l->e->next;
2040 BOOLEAN b;
2041 sleftv tmp;
2042 memset(&tmp,0,sizeof(sleftv));
2043 if (/*(ld->rtyp!=LIST_CMD)
2044 &&*/(ld->e==NULL)
2045 && (ld->Typ()!=r->Typ()))
2046 {
2047 ring old_r=jjCheck_FLAG_OTHER_RING(ld);
2048 tmp.rtyp=DEF_CMD;
2049 tmp.flag=ld->flag;
2050 b=iiAssign(&tmp,r,FALSE);
2051 ld->CleanUp(old_r);
2052 memcpy(ld,&tmp,sizeof(sleftv));
2053 }
2054 else if ((ld->e==NULL)
2055 && (ld->Typ()==r->Typ())
2056 && (ld->Typ()<MAX_TOK))
2057 {
2058 ring old_r=jjCheck_FLAG_OTHER_RING(ld);
2059 tmp.rtyp=r->Typ();
2060 tmp.flag=ld->flag;
2061 tmp.data=(char*)idrecDataInit(r->Typ());
2062 b=iiAssign(&tmp,r,FALSE);
2063 ld->CleanUp(old_r);
2064 memcpy(ld,&tmp,sizeof(sleftv));
2065 }
2066 else
2067 {
2068 b=iiAssign(ld,r,FALSE);
2069 if (l->e!=NULL) l->e->next=ld->e;
2070 ld->e=NULL;
2071 }
2072 return b;
2073}
2075{
2076 leftv l1=l;
2077 leftv r1=r;
2078 leftv lrest;
2079 leftv rrest;
2080 BOOLEAN b;
2081 do
2082 {
2083 lrest=l->next;
2084 rrest=r->next;
2085 l->next=NULL;
2086 r->next=NULL;
2087 b=iiAssign(l,r);
2088 l->next=lrest;
2089 r->next=rrest;
2090 l=lrest;
2091 r=rrest;
2092 } while ((!b)&&(l!=NULL));
2093 l1->CleanUp();
2094 r1->CleanUp();
2095 return b;
2096}
2098{
2099 if (errorreported) return TRUE;
2100 int ll=l->listLength();
2101 int rl;
2102 int lt=l->Typ();
2103 int rt=NONE;
2104 int is_qring=FALSE;
2105 BOOLEAN b=FALSE;
2106 if (l->rtyp==ALIAS_CMD)
2107 {
2108 Werror("`%s` is read-only",l->Name());
2109 }
2110
2111 if (l->rtyp==IDHDL)
2112 {
2113 atKillAll((idhdl)l->data);
2114 is_qring=hasFlag((idhdl)l->data,FLAG_QRING_DEF);
2115 IDFLAG((idhdl)l->data)=0;
2116 l->attribute=NULL;
2117 toplevel=FALSE;
2118 }
2119 else if (l->attribute!=NULL)
2120 atKillAll((idhdl)l);
2121 if (ll==1)
2122 {
2123 /* l[..] = ... */
2124 if(l->e!=NULL)
2125 {
2126 BOOLEAN like_lists=0;
2127 blackbox *bb=NULL;
2128 int bt;
2129 if (((bt=l->rtyp)>MAX_TOK)
2130 || ((l->rtyp==IDHDL) && ((bt=IDTYP((idhdl)l->data))>MAX_TOK)))
2131 {
2132 bb=getBlackboxStuff(bt);
2133 like_lists=BB_LIKE_LIST(bb); // bb like a list
2134 }
2135 else if (((l->rtyp==IDHDL) && (IDTYP((idhdl)l->data)==LIST_CMD))
2136 || (l->rtyp==LIST_CMD))
2137 {
2138 like_lists=2; // bb in a list
2139 }
2140 if(like_lists)
2141 {
2142 if (traceit&TRACE_ASSIGN) PrintS("assign list[..]=...or similar\n");
2143 if (like_lists==1)
2144 {
2145 // check blackbox/newtype type:
2146 if(bb->blackbox_CheckAssign(bb,l,r)) return TRUE;
2147 }
2148 b=jiAssign_list(l,r);
2149 if((!b) && (like_lists==2))
2150 {
2151 //Print("jjA_L_LIST: - 2 \n");
2152 if((l->rtyp==IDHDL) && (l->data!=NULL))
2153 {
2154 ipMoveId((idhdl)l->data);
2155 l->attribute=IDATTR((idhdl)l->data);
2156 l->flag=IDFLAG((idhdl)l->data);
2157 }
2158 }
2159 r->CleanUp();
2160 Subexpr h;
2161 while (l->e!=NULL)
2162 {
2163 h=l->e->next;
2165 l->e=h;
2166 }
2167 return b;
2168 }
2169 }
2170 if (lt>MAX_TOK)
2171 {
2172 blackbox *bb=getBlackboxStuff(lt);
2173#ifdef BLACKBOX_DEVEL
2174 Print("bb-assign: bb=%lx\n",bb);
2175#endif
2176 return (bb==NULL) || bb->blackbox_Assign(l,r);
2177 }
2178 // end of handling elems of list and similar
2179 rl=r->listLength();
2180 if (rl==1)
2181 {
2182 /* system variables = ... */
2183 if(((l->rtyp>=VECHO)&&(l->rtyp<=VPRINTLEVEL))
2184 ||((l->rtyp>=VALTVARS)&&(l->rtyp<=VMINPOLY)))
2185 {
2186 b=iiAssign_sys(l,r);
2187 r->CleanUp();
2188 //l->CleanUp();
2189 return b;
2190 }
2191 rt=r->Typ();
2192 /* a = ... */
2193 if ((lt!=MATRIX_CMD)
2194 &&(lt!=BIGINTMAT_CMD)
2195 &&(lt!=BIGINTVEC_CMD)
2196 &&(lt!=CMATRIX_CMD)
2197 &&(lt!=INTMAT_CMD)
2198 &&((lt==rt)||(lt!=LIST_CMD)))
2199 {
2200 b=jiAssign_1(l,r,rt,toplevel,is_qring);
2201 if (l->rtyp==IDHDL)
2202 {
2203 if ((lt==DEF_CMD)||(lt==LIST_CMD))
2204 {
2205 ipMoveId((idhdl)l->data);
2206 }
2207 l->attribute=IDATTR((idhdl)l->data);
2208 l->flag=IDFLAG((idhdl)l->data);
2209 l->CleanUp();
2210 }
2211 r->CleanUp();
2212 return b;
2213 }
2214 if (((lt!=LIST_CMD)
2215 &&((rt==MATRIX_CMD)
2216 ||(rt==BIGINTMAT_CMD)
2217 ||(rt==BIGINTVEC_CMD)
2218 ||(rt==CMATRIX_CMD)
2219 ||(rt==INTMAT_CMD)
2220 ||(rt==INTVEC_CMD)
2221 ||(rt==MODUL_CMD)))
2222 ||((lt==LIST_CMD)
2223 &&(rt==RESOLUTION_CMD))
2224 )
2225 {
2226 b=jiAssign_1(l,r,rt,toplevel);
2227 if((l->rtyp==IDHDL)&&(l->data!=NULL))
2228 {
2229 if ((lt==DEF_CMD) || (lt==LIST_CMD))
2230 {
2231 //Print("ipAssign - 3.0\n");
2232 ipMoveId((idhdl)l->data);
2233 }
2234 l->attribute=IDATTR((idhdl)l->data);
2235 l->flag=IDFLAG((idhdl)l->data);
2236 }
2237 r->CleanUp();
2238 Subexpr h;
2239 while (l->e!=NULL)
2240 {
2241 h=l->e->next;
2243 l->e=h;
2244 }
2245 return b;
2246 }
2247 }
2248 if (rt==NONE) rt=r->Typ();
2249 }
2250 else if (ll==(rl=r->listLength()))
2251 {
2252 b=jiAssign_rec(l,r);
2253 return b;
2254 }
2255 else
2256 {
2257 if (rt==NONE) rt=r->Typ();
2258 if (rt==INTVEC_CMD)
2259 return jiA_INTVEC_L(l,r);
2260 else if (rt==VECTOR_CMD)
2261 return jiA_VECTOR_L(l,r);
2262 else if ((rt==IDEAL_CMD)||(rt==MATRIX_CMD))
2263 return jiA_MATRIX_L(l,r);
2264 else if ((rt==STRING_CMD)&&(rl==1))
2265 return jiA_STRING_L(l,r);
2266 Werror("length of lists in assignment does not match (l:%d,r:%d)",
2267 ll,rl);
2268 return TRUE;
2269 }
2270
2271 leftv hh=r;
2272 BOOLEAN map_assign=FALSE;
2273 switch (lt)
2274 {
2275 case INTVEC_CMD:
2277 break;
2278 case INTMAT_CMD:
2279 {
2280 b=jjA_L_INTVEC(l,r,new intvec(IDINTVEC((idhdl)l->data)));
2281 break;
2282 }
2283 case BIGINTVEC_CMD:
2284 {
2285 b=jjA_L_BIGINTVEC(l, r, new bigintmat(IDBIMAT((idhdl)l->data)));
2286 break;
2287 }
2288 case BIGINTMAT_CMD:
2289 {
2290 b=jjA_L_BIGINTMAT(l, r, new bigintmat(IDBIMAT((idhdl)l->data)));
2291 break;
2292 }
2293 case MAP_CMD:
2294 {
2295 // first element in the list sl (r) must be a ring
2296 if ((rt == RING_CMD)&&(r->e==NULL))
2297 {
2298 omFreeBinAddr((ADDRESS)IDMAP((idhdl)l->data)->preimage);
2299 IDMAP((idhdl)l->data)->preimage = omStrDup (r->Fullname());
2300 /* advance the expressionlist to get the next element after the ring */
2301 hh = r->next;
2302 }
2303 else
2304 {
2305 WerrorS("expected ring-name");
2306 b=TRUE;
2307 break;
2308 }
2309 if (hh==NULL) /* map-assign: map f=r; */
2310 {
2311 WerrorS("expected image ideal");
2312 b=TRUE;
2313 break;
2314 }
2315 if ((hh->next==NULL)&&(hh->Typ()==IDEAL_CMD))
2316 {
2317 b=jiAssign_1(l,hh,IDEAL_CMD,toplevel); /* map-assign: map f=r,i; */
2319 return b;
2320 }
2321 //no break, handle the rest like an ideal:
2322 map_assign=TRUE; // and continue
2323 }
2324 case MATRIX_CMD:
2325 case IDEAL_CMD:
2326 case MODUL_CMD:
2327 {
2328 sleftv t;
2329 matrix olm = (matrix)l->Data();
2330 long rk;
2331 char *pr=((map)olm)->preimage;
2332 BOOLEAN module_assign=(/*l->Typ()*/ lt==MODUL_CMD);
2333 matrix lm ;
2334 long num;
2335 int j,k;
2336 int i=0;
2337 int mtyp=MATRIX_CMD; /*Type of left side object*/
2338 int etyp=POLY_CMD; /*Type of elements of left side object*/
2339
2340 if (lt /*l->Typ()*/==MATRIX_CMD)
2341 {
2342 rk=olm->rows();
2343 num=olm->cols()*rk /*olm->rows()*/;
2344 lm=mpNew(olm->rows(),olm->cols());
2345 int el;
2346 if ((traceit&TRACE_ASSIGN) && (num!=(el=exprlist_length(hh))))
2347 {
2348 Warn("expression list length(%d) does not match matrix size(%d)",el,num);
2349 }
2350 }
2351 else /* IDEAL_CMD or MODUL_CMD */
2352 {
2353 num=exprlist_length(hh);
2354 lm=(matrix)idInit(num,1);
2355 if (module_assign)
2356 {
2357 rk=0;
2358 mtyp=MODUL_CMD;
2359 etyp=VECTOR_CMD;
2360 }
2361 else
2362 rk=1;
2363 }
2364
2365 int ht;
2366 loop
2367 {
2368 if (hh==NULL)
2369 break;
2370 else
2371 {
2372 matrix rm;
2373 ht=hh->Typ();
2374 if ((j=iiTestConvert(ht,etyp))!=0)
2375 {
2376 b=iiConvert(ht,etyp,j,hh,&t);
2377 hh->next=t.next;
2378 if (b)
2379 { Werror("can not convert %s(%s) -> %s",Tok2Cmdname(ht),hh->Name(),Tok2Cmdname(etyp));
2380 break;
2381 }
2382 lm->m[i]=(poly)t.CopyD(etyp);
2383 pNormalize(lm->m[i]);
2384 if (module_assign) rk=si_max(rk,pMaxComp(lm->m[i]));
2385 i++;
2386 }
2387 else
2388 if ((j=iiTestConvert(ht,mtyp))!=0)
2389 {
2390 b=iiConvert(ht,mtyp,j,hh,&t);
2391 hh->next=t.next;
2392 if (b)
2393 { Werror("can not convert %s(%s) -> %s",Tok2Cmdname(ht),hh->Name(),Tok2Cmdname(mtyp));
2394 break;
2395 }
2396 rm = (matrix)t.CopyD(mtyp);
2397 if (module_assign)
2398 {
2399 j = si_min((int)num,rm->cols());
2400 rk=si_max(rk,rm->rank);
2401 }
2402 else
2403 j = si_min(num-i,(long)rm->rows() * (long)rm->cols());
2404 for(k=0;k<j;k++,i++)
2405 {
2406 lm->m[i]=rm->m[k];
2407 pNormalize(lm->m[i]);
2408 rm->m[k]=NULL;
2409 }
2410 idDelete((ideal *)&rm);
2411 }
2412 else
2413 {
2414 b=TRUE;
2415 Werror("can not convert %s(%s) -> %s",Tok2Cmdname(ht),hh->Name(),Tok2Cmdname(mtyp));
2416 break;
2417 }
2418 t.next=NULL;t.CleanUp();
2419 if (i==num) break;
2420 hh=hh->next;
2421 }
2422 }
2423 if (b)
2424 idDelete((ideal *)&lm);
2425 else
2426 {
2427 idDelete((ideal *)&olm);
2428 if (module_assign) lm->rank=rk;
2429 else if (map_assign) ((map)lm)->preimage=pr;
2430 l=l->LData();
2431 if (l->rtyp==IDHDL)
2432 IDMATRIX((idhdl)l->data)=lm;
2433 else
2434 l->data=(char *)lm;
2435 }
2436 break;
2437 }
2438 case STRING_CMD:
2439 b=jjA_L_STRING(l,r);
2440 break;
2441 //case DEF_CMD:
2442 case LIST_CMD:
2443 b=jjA_L_LIST(l,r);
2444 break;
2445 case NONE:
2446 case 0:
2447 Werror("cannot assign to %s",l->Fullname());
2448 b=TRUE;
2449 break;
2450 default:
2451 WerrorS("assign not impl.");
2452 b=TRUE;
2453 break;
2454 } /* end switch: typ */
2455 if (b && (!errorreported)) WerrorS("incompatible type in list assignment");
2456 r->CleanUp();
2457 return b;
2458}
2460{
2461 assume ((currRing->qideal!=NULL) && (!hasFlag(I,FLAG_QRING)));
2462 {
2463 if (I->e==NULL)
2464 {
2465 ideal I0=(ideal)I->Data();
2466 switch (I->Typ())
2467 {
2468 case IDEAL_CMD:
2469 case MODUL_CMD:
2470 {
2471 ideal F=idInit(1,1);
2472 ideal II=kNF(F,currRing->qideal,I0);
2473 idDelete(&F);
2474 if (I->rtyp!=IDHDL)
2475 {
2476 idDelete((ideal*)&(I0));
2477 I->data=II;
2478 }
2479 else
2480 {
2481 idhdl h=(idhdl)I->data;
2482 idDelete((ideal*)&IDIDEAL(h));
2483 IDIDEAL(h)=II;
2485 }
2486 break;
2487 }
2488 default: break;
2489 }
2491 }
2492 }
2493}
2494poly jj_NormalizeQRingP(poly p, const ring r)
2495{
2496 if((p!=NULL) && (r->qideal!=NULL))
2497 {
2498 ring save=currRing;
2499 if (r!=currRing) rChangeCurrRing(r);
2500 ideal F=idInit(1,1);
2501 poly p2=kNF(F,r->qideal,p);
2502 p_Normalize(p2,r);
2503 id_Delete(&F,r);
2504 p_Delete(&p,r);
2505 p=p2;
2506 if (r!=save) rChangeCurrRing(save);
2507 }
2508 return p;
2509}
2511{
2512 //Print("importfrom %s::%s ->.\n",v->Name(),u->Name() );
2513 assume(u->Typ()==PACKAGE_CMD);
2514 char *vn=(char *)v->Name();
2515 idhdl h=((package)(u->Data()))->idroot->get(vn /*v->Name()*/, myynest);
2516 if (h!=NULL)
2517 {
2518 //check for existence
2519 if (((package)(u->Data()))==basePack)
2520 {
2521 WarnS("source and destination packages are identical");
2522 return FALSE;
2523 }
2524 idhdl t=basePack->idroot->get(vn /*v->Name()*/, myynest);
2525 if (t!=NULL)
2526 {
2527 if (BVERBOSE(V_REDEFINE)) Warn("redefining %s (%s)",vn,my_yylinebuf);
2528 killhdl(t);
2529 }
2530 sleftv tmp_expr;
2531 if (iiDeclCommand(&tmp_expr,v,myynest,DEF_CMD,&IDROOT)) return TRUE;
2532 sleftv h_expr;
2533 memset(&h_expr,0,sizeof(h_expr));
2534 h_expr.rtyp=IDHDL;
2535 h_expr.data=h;
2536 h_expr.name=vn;
2537 return iiAssign(&tmp_expr,&h_expr);
2538 }
2539 else
2540 {
2541 Werror("`%s` not found in `%s`",v->Name(), u->Name());
2542 return TRUE;
2543 }
2544 return FALSE;
2545}
struct for passing initialization parameters to naInitChar
Definition algext.h:37
void * atGet(idhdl root, const char *name, int t, void *defaultReturnValue)
Definition attrib.cc:132
sattr * attr
Definition attrib.h:16
#define atKillAll(H)
Definition attrib.h:47
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
#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
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition cf_gcd.cc:676
CanonicalForm num(const CanonicalForm &f)
int l
Definition cfEzgcd.cc:100
int m
Definition cfEzgcd.cc:128
int i
Definition cfEzgcd.cc:132
int k
Definition cfEzgcd.cc:99
int p
Definition cfModGcd.cc:4086
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
FILE * f
Definition checklibs.c:9
Matrices of numbers.
Definition bigintmat.h:51
int length()
Definition bigintmat.h:143
int cols() const
Definition bigintmat.h:144
int rows() const
Definition bigintmat.h:145
coeffs basecoeffs() const
Definition bigintmat.h:146
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 min_in()
Definition intvec.h:122
int length() const
Definition intvec.h:95
int cols() const
Definition intvec.h:96
int rows() const
Definition intvec.h:97
long rank
Definition matpol.h:19
poly * m
Definition matpol.h:18
int & cols()
Definition matpol.h:24
int & rows()
Definition matpol.h:23
attr Copy()
Definition attrib.cc:33
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
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
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
leftv LData()
Definition subexpr.cc:1519
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 coeffs n_CoeffRingQuot1(number c, const coeffs r)
Definition coeffs.h:522
static FORCE_INLINE long n_Int(number &n, const coeffs r)
conversion of n to an int; 0 if not possible in Z/pZ: the representing int lying in (-p/2 ....
Definition coeffs.h:548
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition coeffs.h:455
static FORCE_INLINE BOOLEAN nCoeff_is_Extension(const coeffs r)
Definition coeffs.h:839
@ 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 nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
Definition coeffs.h:701
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition numbers.cc:406
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition coeffs.h:468
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition coeffs.h:459
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition coeffs.h:539
static FORCE_INLINE BOOLEAN nCoeff_is_algExt(const coeffs r)
TRUE iff r represents an algebraic extension field.
Definition coeffs.h:903
@ n_rep_gap_rat
(number), see longrat.h
Definition coeffs.h:118
@ n_rep_int
(int), see modulop.h
Definition coeffs.h:117
@ n_rep_gmp
(mpz_ptr), see rmodulon,h
Definition coeffs.h:122
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition coeffs.h:80
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition coeffs.h:579
void nKillChar(coeffs r)
undo all initialisations
Definition numbers.cc:556
static FORCE_INLINE BOOLEAN nCoeff_is_transExt(const coeffs r)
TRUE iff r represents a transcendental extension field.
Definition coeffs.h:911
#define Print
Definition emacs.cc:80
#define Warn
Definition emacs.cc:77
#define WarnS
Definition emacs.cc:78
const CanonicalForm int s
Definition facAbsFact.cc:51
CanonicalForm res
Definition facAbsFact.cc:60
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 int yylineno
Definition febase.cc:40
VAR char my_yylinebuf[80]
Definition febase.cc:44
VAR int si_echo
Definition febase.cc:35
VAR int myynest
Definition febase.cc:41
VAR Voice * currentVoice
Definition fevoices.cc:49
const char * VoiceName()
Definition fevoices.cc:58
int VoiceLine()
Definition fevoices.cc:66
int iiTestConvert(int inputType, int outputType)
Definition gentable.cc:298
const char * Tok2Cmdname(int tok)
Definition gentable.cc:137
static int RingDependend(int t)
Definition gentable.cc:23
#define EXTERN_VAR
Definition globaldefs.h:6
@ IDEAL_CMD
Definition grammar.cc:285
@ VALTVARS
Definition grammar.cc:306
@ MATRIX_CMD
Definition grammar.cc:287
@ BUCKET_CMD
Definition grammar.cc:284
@ BIGINTMAT_CMD
Definition grammar.cc:278
@ MAP_CMD
Definition grammar.cc:286
@ PROC_CMD
Definition grammar.cc:281
@ 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
@ BIGINTVEC_CMD
Definition grammar.cc:279
@ NUMBER_CMD
Definition grammar.cc:289
@ POLY_CMD
Definition grammar.cc:290
@ VMINPOLY
Definition grammar.cc:310
@ RING_CMD
Definition grammar.cc:282
#define idDelete(H)
delete an ideal
Definition ideals.h:29
#define idSimpleAdd(A, B)
Definition ideals.h:42
static ideal idVec2Ideal(poly vec)
Definition ideals.h:173
#define idPosConstant(I)
index of generator with leading term in ground ring (if any); otherwise -1
Definition ideals.h:37
static BOOLEAN length(leftv result, leftv arg)
Definition interval.cc:257
intvec * ivAdd(intvec *a, intvec *b)
Definition intvec.cc:249
#define IMATELEM(M, I, J)
Definition intvec.h:86
static BOOLEAN jiA_1x1INTMAT(leftv res, leftv a, Subexpr e)
Definition ipassign.cc:861
static BOOLEAN jiA_BIGINT_N(leftv res, leftv a, Subexpr e)
Definition ipassign.cc:709
static BOOLEAN jjA_L_BIGINTVEC(leftv l, leftv r, bigintmat *bim)
Definition ipassign.cc:1817
static BOOLEAN jiA_INTVEC(leftv res, leftv a, Subexpr)
Definition ipassign.cc:949
static BOOLEAN jiA_IDEAL_Mo(leftv res, leftv a, Subexpr)
Definition ipassign.cc:1092
static BOOLEAN jiA_MATRIX_L(leftv l, leftv r)
Definition ipassign.cc:1890
static BOOLEAN jiA_PACKAGE(leftv res, leftv a, Subexpr)
Definition ipassign.cc:1299
void jjNormalizeQRingId(leftv I)
Definition ipassign.cc:2459
static BOOLEAN jiA_1x1MATRIX(leftv res, leftv a, Subexpr e)
Definition ipassign.cc:883
static BOOLEAN jiA_INTVEC_BI(leftv res, leftv a, Subexpr)
Definition ipassign.cc:972
static ring jjCheck_FLAG_OTHER_RING(leftv res)
Definition ipassign.cc:463
static BOOLEAN jjPRINTLEVEL(leftv, leftv a)
Definition ipassign.cc:58
static BOOLEAN jjMINPOLY(leftv, leftv a)
Definition ipassign.cc:243
static BOOLEAN jjTRACE(leftv, leftv a)
Definition ipassign.cc:100
static BOOLEAN jiA_VECTOR_L(leftv l, leftv r)
Definition ipassign.cc:1613
static BOOLEAN jiA_BIGINT(leftv res, leftv a, Subexpr e)
Definition ipassign.cc:667
static BOOLEAN iiAssign_sys(leftv l, leftv r)
Definition ipassign.cc:1513
static BOOLEAN jiA_POLY(leftv res, leftv a, Subexpr e)
Definition ipassign.cc:792
static BOOLEAN jjCOLMAX(leftv, leftv a)
Definition ipassign.cc:63
static BOOLEAN jiAssign_rec(leftv l, leftv r)
Definition ipassign.cc:2074
static BOOLEAN jjECHO(leftv, leftv a)
Definition ipassign.cc:53
poly jj_NormalizeQRingP(poly p, const ring r)
Definition ipassign.cc:2494
static BOOLEAN jiAssign_1(leftv l, leftv r, int rt, BOOLEAN toplevel, BOOLEAN is_qring=FALSE)
Definition ipassign.cc:1330
static BOOLEAN jiA_BUCKET(leftv res, leftv a, Subexpr e)
Definition ipassign.cc:1009
static BOOLEAN jiA_RESOLUTION(leftv res, leftv a, Subexpr)
Definition ipassign.cc:1046
static BOOLEAN jiA_CRING(leftv res, leftv a, Subexpr)
Definition ipassign.cc:1310
static BOOLEAN jjMAXDEG(leftv, leftv a)
Definition ipassign.cc:82
static BOOLEAN jjA_L_LIST(leftv l, leftv r)
Definition ipassign.cc:1654
static void jiAssignAttr(leftv l, leftv r)
Definition ipassign.cc:386
BOOLEAN jjIMPORTFROM(leftv, leftv u, leftv v)
Definition ipassign.cc:2510
static BOOLEAN jjRTIMER(leftv, leftv a)
Definition ipassign.cc:75
static BOOLEAN jiA_RING(leftv res, leftv a, Subexpr e)
Definition ipassign.cc:1267
static BOOLEAN jiA_MAP(leftv res, leftv a, Subexpr)
Definition ipassign.cc:1137
static BOOLEAN jiA_INT(leftv res, leftv a, Subexpr e)
Definition ipassign.cc:419
static BOOLEAN jiA_STRING_L(leftv l, leftv r)
Definition ipassign.cc:1966
static BOOLEAN jjA_L_BIGINTMAT(leftv l, leftv r, bigintmat *bim)
Definition ipassign.cc:1768
static void jjMINPOLY_red(idhdl h)
Definition ipassign.cc:128
static BOOLEAN jiA_DEF(leftv res, leftv, Subexpr)
Definition ipassign.cc:1305
static BOOLEAN jiA_IDEAL(leftv res, leftv a, Subexpr)
Definition ipassign.cc:1022
static BOOLEAN jiA_MODUL_P(leftv res, leftv a, Subexpr)
Definition ipassign.cc:1055
static BOOLEAN jiA_BIGINTMAT(leftv res, leftv a, Subexpr)
Definition ipassign.cc:986
static BOOLEAN jiA_NUMBER(leftv res, leftv a, Subexpr)
Definition ipassign.cc:482
static BOOLEAN jiAssign_list(leftv l, leftv r)
Definition ipassign.cc:2002
static BOOLEAN jjA_L_STRING(leftv l, leftv r)
Definition ipassign.cc:1856
static BOOLEAN jiA_LIST_RES(leftv res, leftv a, Subexpr)
Definition ipassign.cc:771
coeffs jjSetMinpoly(coeffs cf, number a)
Definition ipassign.cc:176
static BOOLEAN jiA_LINK(leftv res, leftv a, Subexpr)
Definition ipassign.cc:1113
static BOOLEAN jiA_MAP_ID(leftv res, leftv a, Subexpr)
Definition ipassign.cc:1151
static BOOLEAN jiA_STRING(leftv res, leftv a, Subexpr e)
Definition ipassign.cc:909
static BOOLEAN jjSHORTOUT(leftv, leftv a)
Definition ipassign.cc:105
static BOOLEAN jjNOETHER(leftv, leftv a)
Definition ipassign.cc:378
BOOLEAN iiAssign(leftv l, leftv r, BOOLEAN toplevel)
Definition ipassign.cc:2097
static BOOLEAN jiA_IDEAL_M(leftv res, leftv a, Subexpr)
Definition ipassign.cc:1072
static BOOLEAN jiA_INTVEC_L(leftv l, leftv r)
Definition ipassign.cc:1587
static BOOLEAN jiA_QRING(leftv res, leftv a, Subexpr e)
Definition ipassign.cc:1164
static BOOLEAN jiA_LIST(leftv res, leftv a, Subexpr)
Definition ipassign.cc:783
static BOOLEAN jjMAXMULT(leftv, leftv a)
Definition ipassign.cc:91
static BOOLEAN jjTIMER(leftv, leftv a)
Definition ipassign.cc:68
static BOOLEAN jiA_BIGINTVEC_IV(leftv res, leftv a, Subexpr)
Definition ipassign.cc:993
static BOOLEAN jjA_L_INTVEC(leftv l, leftv r, intvec *iv)
Definition ipassign.cc:1719
static BOOLEAN jiA_PROC(leftv res, leftv a, Subexpr)
Definition ipassign.cc:931
BOOLEAN iiConvert(int inputType, int outputType, int index, leftv input, leftv output, const struct sConvertTypes *dConvertTypes)
Definition ipconv.cc:450
void killhdl2(idhdl h, idhdl *ih, ring r)
Definition ipid.cc:422
VAR package basePack
Definition ipid.cc:56
VAR idhdl currRingHdl
Definition ipid.cc:57
void killhdl(idhdl h, package proot)
Definition ipid.cc:391
void * idrecDataInit(int t)
Definition ipid.cc:116
void ipMoveId(idhdl tomove)
Definition ipid.cc:681
BOOLEAN piKill(procinfov pi)
Definition ipid.cc:724
#define IDMAP(a)
Definition ipid.h:135
#define IDMATRIX(a)
Definition ipid.h:134
EXTERN_VAR omBin sleftv_bin
Definition ipid.h:145
#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 IDINTVEC(a)
Definition ipid.h:128
#define IDBIMAT(a)
Definition ipid.h:129
#define IDIDEAL(a)
Definition ipid.h:133
#define IDFLAG(a)
Definition ipid.h:120
#define IDROOT
Definition ipid.h:19
#define FLAG_TWOSTD
Definition ipid.h:107
#define FLAG_QRING
Definition ipid.h:108
#define FLAG_QRING_DEF
Definition ipid.h:109
#define IDLEV(a)
Definition ipid.h:121
#define IDRING(a)
Definition ipid.h:127
#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
#define FLAG_RING
Definition ipid.h:111
procinfo * iiInitSingularProcinfo(procinfov pi, const char *libname, const char *procname, int, long pos, BOOLEAN pstatic)
Definition iplib.cc:1059
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
int exprlist_length(leftv v)
Definition ipshell.cc:551
VAR leftv iiCurrArgs
Definition ipshell.cc:81
lists syConvRes(syStrategy syzstr, BOOLEAN toDel, int add_row_shift)
Definition ipshell.cc:3172
void rSetHdl(idhdl h)
Definition ipshell.cc:5122
STATIC_VAR Poly * h
Definition janet.cc:971
poly kNF(ideal F, ideal Q, poly p, int syzComp, int lazyReduce)
Definition kstd1.cc:3224
EXTERN_VAR int Kstd1_deg
Definition kstd1.h:70
EXTERN_VAR int Kstd1_mu
Definition kstd1.h:70
#define pi
Definition libparse.cc:1145
static bool rIsSCA(const ring r)
Definition nc.h:190
bool nc_SetupQuotient(ring rGR, const ring rG=NULL, bool bCopy=false)
VAR omBin slists_bin
Definition lists.cc:23
BOOLEAN lRingDependend(lists L)
Definition lists.cc:222
#define SR_INT
Definition longrat.h:67
poly p_MinPolyNormalize(poly p, const ring r)
Definition maps.cc:430
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition matpol.cc:37
#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
#define p_GetCoeff(p, r)
Definition monomials.h:50
slists * lists
The main handler for Singular numbers which are suitable for Singular polynomials.
Definition qr.h:46
#define nDelete(n)
Definition numbers.h:16
#define nCopy(n)
Definition numbers.h:15
#define nNormalize(n)
Definition numbers.h:30
#define nInit(i)
Definition numbers.h:24
#define nMult(n1, n2)
Definition numbers.h:17
#define omStrDup(s)
#define omfree(addr)
#define omAlloc(size)
#define omreallocSize(addr, o_size, size)
#define omAllocBin(bin)
#define omAlloc0Bin(bin)
#define omFree(addr)
#define omAlloc0(size)
#define omFreeBin(addr, bin)
#define omFreeBinAddr(addr)
#define NULL
Definition omList.c:12
omBin_t * omBin
Definition omStructs.h:12
VAR unsigned si_opt_1
Definition options.c:5
#define Sy_inset(x, s)
Definition options.h:33
#define BVERBOSE(a)
Definition options.h:35
#define TEST_V_ALLWARN
Definition options.h:145
#define Sy_bit(x)
Definition options.h:31
#define V_REDEFINE
Definition options.h:45
#define TEST_V_QRING
Definition options.h:133
#define OPT_MULTBOUND
Definition options.h:90
#define OPT_DEGBOUND
Definition options.h:91
#define TEST_V_ASSIGN_NONE
Definition options.h:136
#define V_SHOW_USE
Definition options.h:52
poly p_PermPoly(poly p, const int *perm, const ring oldRing, const ring dst, nMapFunc nMap, const int *par_perm, int OldPar, BOOLEAN use_mult)
Definition p_polys.cc:4211
void p_Normalize(poly p, const ring r)
Definition p_polys.cc:3894
void pEnlargeSet(poly **p, int l, int increment)
Definition p_polys.cc:3776
void p_Write(poly p, ring lmRing, ring tailRing)
Definition polys0.cc:342
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition p_polys.h:1980
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903
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
Compatibility layer for legacy polynomial operations (over currRing)
#define pAdd(p, q)
Definition polys.h:204
#define pDelete(p_ptr)
Definition polys.h:187
#define pSetCompP(a, i)
Definition polys.h:304
#define pGetComp(p)
Component.
Definition polys.h:38
#define pSub(a, b)
Definition polys.h:288
#define pMaxComp(p)
Definition polys.h:300
#define pNormalize(p)
Definition polys.h:318
ideal idrCopyR(ideal id, ring src_r, ring dest_r)
Definition prCopy.cc:192
#define NUM
Definition readcf.cc:180
void PrintS(const char *s)
Definition reporter.cc:284
void Werror(const char *fmt,...)
Definition reporter.cc:189
EXTERN_VAR int traceit
Definition reporter.h:24
#define TRACE_ASSIGN
Definition reporter.h:46
EXTERN_VAR int colmax
Definition reporter.h:17
void rWrite(ring r, BOOLEAN details)
Definition ring.cc:227
void rDelete(ring r)
unconditionally deletes fields in r
Definition ring.cc:454
ring rCopy(ring r)
Definition ring.cc:1736
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 void rDecRefCnt(ring r)
Definition ring.h:850
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition ring.h:598
#define rField_is_Ring(R)
Definition ring.h:491
idrec * idhdl
Definition ring.h:22
sBucket * sBucket_pt
Definition sbuckets.h:16
void sBucketDestroyAdd(sBucket_pt bucket, poly *p, int *length)
Definition sbuckets.h:68
ideal idInit(int idsize, int rank)
initialise an ideal / module
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
void id_Normalize(ideal I, const ring r)
normialize all polys in id
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
void id_Shift(ideal M, int s, const ring r)
#define IDELEMS(i)
static int idElem(const ideal F)
number of non-zero polys in F
#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
#define loop
Definition structs.h:71
VAR omBin sSubexpr_bin
Definition subexpr.cc:40
VAR omBin procinfo_bin
Definition subexpr.cc:42
BOOLEAN assumeStdFlag(leftv h)
Definition subexpr.cc:1587
@ LANG_NONE
Definition subexpr.h:22
void syKillComputation(syStrategy syzstr, ring r=currRing)
Definition syz1.cc:1495
ssyStrategy * syStrategy
Definition syz.h:36
const struct sValAssign dAssign[]
Definition table.h:1419
const struct sValAssign_sys dAssign_sys[]
Definition table.h:1472
#define SR_HDL(A)
Definition tgb.cc:35
int startTimer()
Definition timer.cc:66
void initRTimer()
Definition timer.cc:136
VAR int rtimerv
Definition timer.cc:126
VAR int timerv
Definition timer.cc:17
#define IDHDL
Definition tok.h:31
@ ALIAS_CMD
Definition tok.h:34
@ BIGINT_CMD
Definition tok.h:38
@ CRING_CMD
Definition tok.h:56
@ LIST_CMD
Definition tok.h:118
@ 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
@ STRING_CMD
Definition tok.h:187
@ CPOLY_CMD
Definition tok.h:48
@ INT_CMD
Definition tok.h:96
@ MAX_TOK
Definition tok.h:220
#define NONE
Definition tok.h:223
VAR omBin fractionObjectBin
Definition transext.cc:89