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