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