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