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